mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
yq: Use install_yq.sh script from tests repository
Removes two (similar) functions that install `yq`. Instead of having different functions, use the one that we have in the tests repository. In addition, removes the `.ci/lib.sh` which only had an additional `clone_tests_repo` function which was not being used. Fixes: #939. Signed-off-by: Salvador Fuentes <salvador.fuentes@intel.com>
This commit is contained in:
parent
9116b56df4
commit
43ab57ffc5
68
.ci/lib.sh
68
.ci/lib.sh
@ -1,68 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright (c) 2018 Intel Corporation
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
# If we fail for any reason a message will be displayed
|
|
||||||
die() {
|
|
||||||
msg="$*"
|
|
||||||
echo "ERROR: $msg" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
export tests_repo="${tests_repo:-github.com/kata-containers/tests}"
|
|
||||||
export tests_repo_dir="$GOPATH/src/$tests_repo"
|
|
||||||
|
|
||||||
clone_tests_repo() {
|
|
||||||
# KATA_CI_NO_NETWORK is (has to be) ignored if there is
|
|
||||||
# no existing clone.
|
|
||||||
if [ -d "${tests_repo_dir}" ] && [ -n "${KATA_CI_NO_NETWORK:-}" ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
go get -d -u "$tests_repo" || true
|
|
||||||
}
|
|
||||||
|
|
||||||
install_yq() {
|
|
||||||
path=$1
|
|
||||||
local yq_path=${path}/yq
|
|
||||||
local yq_pkg="github.com/mikefarah/yq"
|
|
||||||
[ -x "${yq_path}" ] && return
|
|
||||||
|
|
||||||
case "$(uname -m)" in
|
|
||||||
"aarch64")
|
|
||||||
goarch=arm64
|
|
||||||
;;
|
|
||||||
|
|
||||||
"x86_64")
|
|
||||||
goarch=amd64
|
|
||||||
;;
|
|
||||||
|
|
||||||
"ppc64le")
|
|
||||||
goarch=ppc64le
|
|
||||||
;;
|
|
||||||
|
|
||||||
"s390x")
|
|
||||||
goarch=s390x
|
|
||||||
;;
|
|
||||||
|
|
||||||
"*")
|
|
||||||
echo "Arch $(uname -m) not supported"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
mkdir -p "${path}"
|
|
||||||
|
|
||||||
# Workaround to get latest release from github (to not use github token).
|
|
||||||
# Get the redirection to latest release on github.
|
|
||||||
yq_latest_url=$(curl -Ls -o /dev/null -w %{url_effective} "https://${yq_pkg}/releases/latest")
|
|
||||||
# The redirected url should include the latest release version
|
|
||||||
# https://github.com/mikefarah/yq/releases/tag/<VERSION-HERE>
|
|
||||||
yq_version=$(basename "${yq_latest_url}")
|
|
||||||
|
|
||||||
local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_linux_${goarch}"
|
|
||||||
curl -o "${yq_path}" -L ${yq_url}
|
|
||||||
chmod +x ${yq_path}
|
|
||||||
}
|
|
@ -10,7 +10,7 @@ set -o nounset
|
|||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
cidir=$(dirname "$0")
|
cidir=$(dirname "$0")
|
||||||
source "${cidir}/lib.sh"
|
source "${cidir}/../scripts/lib.sh"
|
||||||
source /etc/os-release
|
source /etc/os-release
|
||||||
|
|
||||||
pushd "${tests_repo_dir}"
|
pushd "${tests_repo_dir}"
|
||||||
|
@ -11,7 +11,7 @@ set -o pipefail
|
|||||||
CI=${CI:-}
|
CI=${CI:-}
|
||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
readonly toplevel_mk="${script_dir}/../Makefile"
|
readonly toplevel_mk="${script_dir}/../Makefile"
|
||||||
source "${script_dir}/lib.sh"
|
source "${script_dir}/../scripts/lib.sh"
|
||||||
|
|
||||||
make_target() {
|
make_target() {
|
||||||
target=$1
|
target=$1
|
||||||
|
2
Makefile
2
Makefile
@ -35,7 +35,7 @@ test-packaging-tools:
|
|||||||
@$(MK_DIR)/obs-packaging/build_from_docker.sh
|
@$(MK_DIR)/obs-packaging/build_from_docker.sh
|
||||||
|
|
||||||
$(YQ):
|
$(YQ):
|
||||||
@bash -c "source .ci/lib.sh; install_yq $${MK_DIR}"
|
@bash -c "source scripts/lib.sh; install_yq $${MK_DIR}"
|
||||||
|
|
||||||
$(VERSION_FILE):
|
$(VERSION_FILE):
|
||||||
@curl -sO $(VERSION_FILE_URL)
|
@curl -sO $(VERSION_FILE_URL)
|
||||||
|
@ -1,33 +1,31 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018-2020 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
export GOPATH=${GOPATH:-${HOME}/go}
|
export GOPATH=${GOPATH:-${HOME}/go}
|
||||||
kata_arch_sh="${GOPATH}/src/github.com/kata-containers/tests/.ci/kata-arch.sh"
|
export tests_repo="${tests_repo:-github.com/kata-containers/tests}"
|
||||||
|
export tests_repo_dir="$GOPATH/src/$tests_repo"
|
||||||
|
|
||||||
hub_bin="hub-bin"
|
hub_bin="hub-bin"
|
||||||
|
|
||||||
get_kata_arch() {
|
clone_tests_repo() {
|
||||||
go get -u github.com/kata-containers/tests || true
|
# KATA_CI_NO_NETWORK is (has to be) ignored if there is
|
||||||
[ -f "${kata_arch_sh}" ] || die "Not found $kata_arch_sh"
|
# no existing clone.
|
||||||
|
if [ -d "${tests_repo_dir}" ] && [ -n "${KATA_CI_NO_NETWORK:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
go get -d -u "$tests_repo" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
install_yq() {
|
install_yq() {
|
||||||
GOPATH=${GOPATH:-${HOME}/go}
|
clone_tests_repo
|
||||||
local yq_path="${GOPATH}/bin/yq"
|
pushd "$tests_repo_dir"
|
||||||
local yq_pkg="github.com/mikefarah/yq"
|
.ci/install_yq.sh
|
||||||
[ -x "${GOPATH}/bin/yq" ] && return
|
popd
|
||||||
|
|
||||||
get_kata_arch
|
|
||||||
goarch=$("${kata_arch_sh}" -g)
|
|
||||||
|
|
||||||
mkdir -p "${GOPATH}/bin"
|
|
||||||
|
|
||||||
# Workaround to get latest release from github (to not use github token).
|
|
||||||
# Get the redirection to latest release on github.
|
|
||||||
yq_latest_url=$(curl -Ls -o /dev/null -w %{url_effective} "https://${yq_pkg}/releases/latest")
|
|
||||||
# The redirected url should include the latest release version
|
|
||||||
# https://github.com/mikefarah/yq/releases/tag/<VERSION-HERE>
|
|
||||||
yq_version=$(basename "${yq_latest_url}")
|
|
||||||
|
|
||||||
local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_linux_${goarch}"
|
|
||||||
curl -o "${yq_path}" -L "${yq_url}"
|
|
||||||
chmod +x "${yq_path}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_from_kata_deps() {
|
get_from_kata_deps() {
|
||||||
|
Loading…
Reference in New Issue
Block a user