From 7cad865d13a215874319a6eb35714576ff68e289 Mon Sep 17 00:00:00 2001 From: Eric Ernst Date: Tue, 6 Oct 2020 16:48:35 -0700 Subject: [PATCH] packaging: fix image build script There were a couple of issues with the build-scripts discovered while doing release: - Relative paths are error prone. Fix error. - short_commit_length is used to truncate sha for commits when appending agent version to resulting files. Before this was in pkglib.sh, which is otherwise an unused file from when we supported OBS. Add this define to lib.sh, which is sourced by the applicable packaging scripts. There's plenty of room for improvement, but these fixes make the existing scripts functional again. Fixes: #871 Signed-off-by: Eric Ernst --- tools/packaging/guest-image/build_image.sh | 5 +++-- tools/packaging/scripts/lib.sh | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/packaging/guest-image/build_image.sh b/tools/packaging/guest-image/build_image.sh index 979064cd3e..e33f998013 100755 --- a/tools/packaging/guest-image/build_image.sh +++ b/tools/packaging/guest-image/build_image.sh @@ -13,13 +13,14 @@ set -o pipefail readonly script_name="$(basename "${BASH_SOURCE[0]}")" readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +readonly packaging_root_dir="$(cd "${script_dir}/../" && pwd)" readonly repo_root_dir="$(cd "${script_dir}/../../../" && pwd)" readonly osbuilder_dir="$(cd "${repo_root_dir}/tools/osbuilder" && pwd)" readonly tmp_dir=$(mktemp -d -t build-image-tmp.XXXXXXXXXX) export GOPATH="${tmp_dir}/go" export GOPATH=${GOPATH:-${HOME}/go} -source "${repo_root_dir}/scripts/lib.sh" +source "${packaging_root_dir}/scripts/lib.sh" exit_handler() { [ -d "${tmp_dir}" ] && sudo rm -rf "$tmp_dir" @@ -28,7 +29,7 @@ trap exit_handler EXIT arch_target="$(uname -m)" -source "${repo_root_dir}/versions.txt" +source "${packaging_root_dir}/versions.txt" readonly destdir="${PWD}" diff --git a/tools/packaging/scripts/lib.sh b/tools/packaging/scripts/lib.sh index c4fe53f82e..649b53a3ea 100644 --- a/tools/packaging/scripts/lib.sh +++ b/tools/packaging/scripts/lib.sh @@ -11,6 +11,8 @@ export tests_repo_dir="$GOPATH/src/$tests_repo" this_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +short_commit_length=10 + hub_bin="hub-bin" clone_tests_repo() {