Skip to content

Commit 302793a

Browse files
dmnkspmatilai
authored andcommitted
Exit from mktree on failure
Right now, if the podman image fails to build or rpm fails to build/install, we happily continue and run the test-suite, only to eventually fail with some cryptic error, such as: error: cannot find rpm Not too helpful, indeed. Instead, just fail the whole tree preparation process if we encounter an error. Fix the return code of unshared() so that we don't fail on that, though. Also, when building the RPM layer, use a proper cleanup trap instead of ignoring SIGINT since a failing make_install() can now terminate the script. Fixes: #2667
1 parent 05c3b37 commit 302793a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tests/mktree.oci

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# OCI-based mktree backend
44

5+
set -e
6+
57
PROGRAM=$(basename $0)
68
if [ "$PROGRAM" == "mktree" ]; then
79
# Running from build directory
@@ -54,7 +56,7 @@ rpmtests()
5456

5557
unshared()
5658
{
57-
[ $(id -u) != 0 ] && [ $NATIVE == yes ] || return
59+
[ $(id -u) != 0 ] && [ $NATIVE == yes ] || return 0
5860
$PODMAN unshare $0 $CMD "$@"
5961
exit
6062
}
@@ -69,10 +71,9 @@ case $CMD in
6971
if [ $NATIVE == yes ]; then
7072
# Native build
7173
id=$($PODMAN create $IMAGE/base)
72-
trap : INT
74+
trap "$PODMAN rm $id >/dev/null" EXIT
7375
make_install $($PODMAN mount $id)
7476
$PODMAN commit -q $id $IMAGE
75-
$PODMAN rm $id >/dev/null
7677
else
7778
# Standalone build
7879
$PODMAN build --target full -t $IMAGE $ARGS

tests/mktree.rootfs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# The / filesystem should be read-only to prevent parallel tests from altering
88
# it (online changes to an underlying filesystem are disallowed in OverlayFS).
99

10+
set -e
11+
1012
CMD=$1; shift
1113
case $CMD in
1214
build)

0 commit comments

Comments
 (0)