scripts: Foward port osbuilder scripts to update yq

This PR ports kata-containers/osbuilder#454 to kata 2.0

Fixes #576

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
Gabriela Cervantes 2020-08-26 11:48:52 -05:00
parent c14d44aba8
commit f879acd6e7
2 changed files with 11 additions and 9 deletions

View File

@ -56,12 +56,14 @@ function install_yq() {
die "Please install curl"
fi
local yq_version=2.3.0
local yq_version=3.1.0
local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_${goos}_${goarch}"
curl -o "${yq_path}" -LSsf ${yq_url}
## NOTE: ${var,,} => gives lowercase value of var
local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_${goos,,}_${goarch}"
curl -o "${yq_path}" -LSsf "${yq_url}"
[ $? -ne 0 ] && die "Download ${yq_url} failed"
chmod +x ${yq_path}
chmod +x "${yq_path}"
echo "Installed $(${yq_path} --version)"
if ! command -v "${yq_path}" >/dev/null; then
die "Cannot not get ${yq_path} executable"

View File

@ -375,13 +375,13 @@ RUN ln -sf /usr/bin/g++ /bin/musl-g++
detect_go_version()
{
info "Detecting go version"
typeset -r yq=$(command -v yq || command -v "${GOPATH}/bin/yq" || echo "${GOPATH}/bin/yq")
typeset yq=$(command -v yq || command -v ${GOPATH}/bin/yq || echo "${GOPATH}/bin/yq")
if [ ! -f "$yq" ]; then
source "$yq_file"
fi
info "Get Go version from ${kata_versions_file}"
GO_VERSION="$(cat "${kata_versions_file}" | $yq r - "languages.golang.meta.newest-version")"
GO_VERSION="$(cat "${kata_versions_file}" | $yq r -X - "languages.golang.meta.newest-version")"
[ "$?" == "0" ] && [ "$GO_VERSION" != "null" ]
}
@ -395,7 +395,7 @@ detect_rust_version()
fi
info "Get rust version from ${kata_versions_file}"
RUST_VERSION="$(cat "${kata_versions_file}" | $yq r - "languages.rust.meta.newest-version")"
RUST_VERSION="$(cat "${kata_versions_file}" | $yq r -X - "languages.rust.meta.newest-version")"
[ "$?" == "0" ] && [ "$RUST_VERSION" != "null" ]
}
@ -409,7 +409,7 @@ detect_cmake_version()
fi
info "Get cmake version from ${kata_versions_file}"
CMAKE_VERSION="$(cat "${kata_versions_file}" | $yq r - "externals.cmake.version")"
CMAKE_VERSION="$(cat "${kata_versions_file}" | $yq r -X - "externals.cmake.version")"
[ "$?" == "0" ] && [ "$CMAKE_VERSION" != "null" ]
}
@ -423,7 +423,7 @@ detect_musl_version()
fi
info "Get musl version from ${kata_versions_file}"
MUSL_VERSION="$(cat "${kata_versions_file}" | $yq r - "externals.musl.version")"
MUSL_VERSION="$(cat "${kata_versions_file}" | $yq r -X - "externals.musl.version")"
[ "$?" == "0" ] && [ "$MUSL_VERSION" != "null" ]
}