mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-12 12:29:11 +00:00
image: Make sure agent sha is correct
Fix image generation. Instead of use agent code from the host checkout to the agent source code in a clean GOPATH env. Make sure that the agent `commit id` is the correct before push to github or OBS. Fixes: #166 Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
@@ -15,11 +15,6 @@ project="kata-containers"
|
||||
|
||||
source "${script_dir}/../scripts/lib.sh"
|
||||
|
||||
get_kata_hash_from_tag() {
|
||||
repo=$1
|
||||
git ls-remote --tags "https://github.com/${project}/${repo}.git" | grep "refs/tags/${kata_version}^{}" | awk '{print $1}'
|
||||
}
|
||||
|
||||
gen_version_file() {
|
||||
local branch="$1"
|
||||
[ -n "${branch}" ] || exit 1
|
||||
|
@@ -16,10 +16,16 @@ readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly project="kata-containers"
|
||||
readonly tmp_dir=$(mktemp -d -t build-image-tmp.XXXXXXXXXX)
|
||||
readonly osbuilder_url=https://github.com/${project}/osbuilder.git
|
||||
export GOPATH="${tmp_dir}/go"
|
||||
|
||||
export GOPATH=${GOPATH:-${HOME}/go}
|
||||
source "${script_dir}/../../scripts/lib.sh"
|
||||
|
||||
exit_handler() {
|
||||
[ -d "${tmp_dir}" ] && sudo rm -rf "$tmp_dir"
|
||||
}
|
||||
trap exit_handler EXIT
|
||||
|
||||
arch_target="$(uname -m)"
|
||||
|
||||
kata_version="master"
|
||||
@@ -47,6 +53,7 @@ build_image() {
|
||||
sudo -E PATH="${PATH}" make image \
|
||||
DISTRO="${img_distro}" \
|
||||
DEBUG="${DEBUG:-}" \
|
||||
USE_DOCKER="1" \
|
||||
AGENT_VERSION="${agent_version}" \
|
||||
IMG_OS_VERSION="${img_os_version}" \
|
||||
DISTRO_ROOTFS="${tmp_dir}/rootfs-image"
|
||||
|
@@ -48,7 +48,7 @@ replace_list=(
|
||||
|
||||
verify
|
||||
rm -rf kata-containers.tar.gz
|
||||
image_tarball=$(find . -name 'kata-containers-'"${VERSION}"'-*.tar.gz')
|
||||
image_tarball=$(find . -name 'kata-containers-'"${VERSION}"'-'"${kata_agent_hash:0:11}"'-*.tar.gz')
|
||||
[ -f "${image_tarball}" ] || die "image not found"
|
||||
cp "${image_tarball}" kata-containers.tar.gz
|
||||
|
||||
|
@@ -17,6 +17,8 @@ readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly project="kata-containers"
|
||||
GOPATH=${GOPATH:-${HOME}/go}
|
||||
|
||||
source "${script_dir}/../scripts/lib.sh"
|
||||
|
||||
die() {
|
||||
msg="$*"
|
||||
echo "ERROR: ${FUNCNAME[1]} ${msg}" >&2
|
||||
@@ -56,9 +58,12 @@ main() {
|
||||
kata_version=${1:-}
|
||||
[ -n "${kata_version}" ] || usage "1"
|
||||
|
||||
image_tarball=$(find -name 'kata-containers-*.tar.gz' | grep "${kata_version}") ||
|
||||
agent_sha=$(get_kata_hash_from_tag "agent" "${kata_version}")
|
||||
# tarball only has 11 chars from agent sha
|
||||
agent_sha=${agent_sha:0:11}
|
||||
image_tarball=$(find -name 'kata-containers-*.tar.gz' | grep "${kata_version}" | grep "${agent_sha}") ||
|
||||
"${script_dir}/../obs-packaging/kata-containers-image/build_image.sh" -v "${kata_version}"
|
||||
image_tarball=$(find -name 'kata-containers-*.tar.gz' | grep "${kata_version}") || die "file not found ${image_tarball}"
|
||||
image_tarball=$(find -name 'kata-containers-*.tar.gz' | grep "${kata_version}" | grep "${agent_sha}" ) || die "file not found ${image_tarball}"
|
||||
|
||||
if [ ${push} == "true" ]; then
|
||||
hub -C "${GOPATH}/src/github.com/${project}/agent" release edit -a "${image_tarball}" "${kata_version}"
|
||||
|
@@ -82,3 +82,8 @@ build_hub() {
|
||||
./script/build -o "${hub_bin}"
|
||||
popd >>/dev/null
|
||||
}
|
||||
|
||||
get_kata_hash_from_tag() {
|
||||
repo=$1
|
||||
git ls-remote --tags "https://github.com/${project}/${repo}.git" | grep "refs/tags/${kata_version}^{}" | awk '{print $1}'
|
||||
}
|
||||
|
Reference in New Issue
Block a user