Merge pull request #2298 from fgiudici/yq_latest_fix

osbuilder/scripts: add support to yq version 4 and above
This commit is contained in:
GabyCT 2021-07-23 12:19:46 -05:00 committed by GitHub
commit 24cbb97f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -335,32 +335,52 @@ RUN ln -sf /usr/bin/g++ /bin/musl-g++
popd popd
} }
detect_rust_version() get_package_version_from_kata_yaml()
{ {
info "Detecting agent rust version" local yq_path="$1"
local yq_version
local yq_args
typeset -r yq=$(command -v yq || command -v "${GOPATH}/bin/yq" || echo "${GOPATH}/bin/yq") typeset -r yq=$(command -v yq || command -v "${GOPATH}/bin/yq" || echo "${GOPATH}/bin/yq")
if [ ! -f "$yq" ]; then if [ ! -f "$yq" ]; then
source "$yq_file" source "$yq_file"
fi fi
info "Get rust version from ${kata_versions_file}" yq_version=$($yq -V)
RUST_VERSION="$(cat "${kata_versions_file}" | $yq r -X - "languages.rust.meta.newest-version")" case $yq_version in
*"version "[1-3]*)
yq_args="r -X - ${yq_path}"
;;
*)
yq_args="e .${yq_path} -"
;;
esac
[ "$?" == "0" ] && [ "$RUST_VERSION" != "null" ] PKG_VERSION="$(cat "${kata_versions_file}" | $yq ${yq_args})"
[ "$?" == "0" ] && [ "$PKG_VERSION" != "null" ] && echo "$PKG_VERSION" || echo ""
}
detect_rust_version()
{
info "Detecting agent rust version"
local yq_path="languages.rust.meta.newest-version"
info "Get rust version from ${kata_versions_file}"
RUST_VERSION="$(get_package_version_from_kata_yaml "$yq_path")"
[ -n "$RUST_VERSION" ]
} }
detect_musl_version() detect_musl_version()
{ {
info "Detecting musl version" info "Detecting musl version"
typeset -r yq=$(command -v yq || command -v "${GOPATH}/bin/yq" || echo "${GOPATH}/bin/yq") local yq_path="externals.musl.version"
if [ ! -f "$yq" ]; then
source "$yq_file"
fi
info "Get musl version from ${kata_versions_file}" info "Get musl version from ${kata_versions_file}"
MUSL_VERSION="$(cat "${kata_versions_file}" | $yq r -X - "externals.musl.version")" MUSL_VERSION="$(get_package_version_from_kata_yaml "$yq_path")"
[ "$?" == "0" ] && [ "$MUSL_VERSION" != "null" ] [ -n "$MUSL_VERSION" ]
} }
before_starting_container() { before_starting_container() {