Skip to content

Commit

Permalink
scripts: Improve reproduction script by selecting the right repo revi…
Browse files Browse the repository at this point in the history
…sion

When reproducing an image which revision is not locally checked out in
git, build-container.sh was using the wrong git revision as well which
caused a false negative of the reproduction test. Address that by
checking out the git revision corresponding to the image tag that was
selected. For that purpose, build-container.sh is extended by
--git-refspec to select a specific revision in cloned repo used for the
build.

Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
jan-kiszka committed Mar 13, 2024
1 parent 9a2d850 commit 4a2425c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions scripts/build-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ usage()
"\t\tstarting the build and do not use image cache\n"
printf "%b" "--debian-tag\tUse specified tag for Debian base image\n" \
"\t\t(default=$DEFAULT_DEBIAN_TAG)\n"
printf "%b" "--git-refspec\tUse specified revision/branch of kas repository (default=HEAD)\n"
printf "%b" "--tag\t\tTag container with specified name (default=next)\n"
printf "%b" "--target\tBuild specified target(s) (default=\"kas kas-isar\")\n"
}
Expand Down Expand Up @@ -79,6 +80,7 @@ build_image()
ARCH=
CLEAN=
DEBIAN_TAG=
GIT_REFSPEC=HEAD
TARGETS=
TAG=next
while [ $# -gt 0 ]; do
Expand All @@ -94,6 +96,10 @@ while [ $# -gt 0 ]; do
shift
DEBIAN_TAG="$1"
;;
--git-refspec)
shift
GIT_REFSPEC="$1"
;;
--tag)
shift
TAG="$1"
Expand Down Expand Up @@ -127,6 +133,7 @@ fi
KAS_CLONE=$(mktemp -d --tmpdir kas-tmp.XXXXXXXXXX)
git clone . "$KAS_CLONE"
cd "$KAS_CLONE" || exit 1
git checkout -q $GIT_REFSPEC

RESULT=0
for TARGET in $TARGETS; do
Expand Down
8 changes: 7 additions & 1 deletion scripts/reproduce-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ if [ -z "$DEBIAN_TAG" ]; then
exit 1
fi

GIT_REFSPEC="$TAG"
if [ "$GIT_REFSPEC" = "latest" ]; then
GIT_REFSPEC=master
fi

# shellcheck disable=SC2086
"$(dirname "$0")/build-container.sh" $ARCH_OPT --target "$TARGET" \
--tag repro-test --debian-tag "$DEBIAN_TAG" --clean || exit 1
--tag repro-test --git-refspec "$GIT_REFSPEC" \
--debian-tag "$DEBIAN_TAG" --clean || exit 1

echo ""

Expand Down

0 comments on commit 4a2425c

Please sign in to comment.