From 12d193bb8d108f5718dc12053ccf78a1b6a876ce Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Tue, 27 Feb 2024 07:50:50 +0100 Subject: debvm-create: fix --skip ext4 We were truncating the output file after generating it. Instead, split the logic and create the file prior to running mmdebstrap to make permission failures fail early. --- bin/debvm-create | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'bin/debvm-create') diff --git a/bin/debvm-create b/bin/debvm-create index a8d5727..0e1a969 100755 --- a/bin/debvm-create +++ b/bin/debvm-create @@ -409,6 +409,12 @@ else } fi +if check_skip ext4; then + set -- "$SUITE" "$IMAGE" "$@" + set -x + exec mmdebstrap "$@" +fi + TEMPROOT= cleanup() { if test -n "$TEMPROOT"; then @@ -416,23 +422,17 @@ cleanup() { fi } -if check_skip ext4; then - set -- "$IMAGE" "$@" -else - trap cleanup EXIT - trap 'exit 1' HUP INT QUIT TERM - TEMPROOT="$(mktemp -d)" - - set -- "$TEMPROOT" "$@" -fi +trap cleanup EXIT +trap 'exit 1' HUP INT QUIT TERM +TEMPROOT="$(mktemp -d)" -set -- "$SUITE" "$@" +set -- "$SUITE" "$TEMPROOT" "$@" set -ex -mmdebstrap "$@" - # Create and truncate the file with "normal" permission. : >"$IMAGE" -check_skip ext4 || - run_inside_userns /sbin/mkfs.ext4 -L debvm -d "$TEMPROOT" "$IMAGE" "$SIZE" + +mmdebstrap "$@" + +run_inside_userns /sbin/mkfs.ext4 -L debvm -d "$TEMPROOT" "$IMAGE" "$SIZE" -- cgit v1.2.3