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:
Jose Carlos Venegas Munoz
2018-08-30 15:35:39 -05:00
parent fe2d20ee4f
commit 33214c90d6
5 changed files with 20 additions and 8 deletions

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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}"

View File

@@ -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}'
}