Skip to content

Commit

Permalink
scripts: Foward port osbuilder scripts to update yq
Browse files Browse the repository at this point in the history
This PR ports kata-containers/osbuilder#454 to kata 2.0

Fixes #576

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
  • Loading branch information
GabyCT committed Aug 27, 2020
1 parent c14d44a commit f879acd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions tools/osbuilder/scripts/install-yq.sh
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions tools/osbuilder/scripts/lib.sh
Expand Up @@ -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" ]
}
Expand All @@ -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" ]
}
Expand All @@ -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" ]
}
Expand All @@ -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" ]
}

0 comments on commit f879acd

Please sign in to comment.