eBPF-based security platform
contrib: show what apt could not fetch when the runtime image fails
Puranjay Mohan92da6cd7879a
diff --git a/contrib/prepare-test-vm-runtime.sh b/contrib/prepare-test-vm-runtime.shindex 814f9100..1945f16f 100755--- a/contrib/prepare-test-vm-runtime.sh+++ b/contrib/prepare-test-vm-runtime.sh@@ -136,6 +136,10 @@ if ! TMPDIR="$GUESTFS_TMP_DIR" XDG_RUNTIME_DIR="$GUESTFS_RUNTIME_DIR" \if grep -q 'Attempted to kill init\|Kernel panic.*not syncing' "$CUSTOMIZE_LOG"; thenprintf '[test-vm-runtime] check: the selected kernel booted but is not compatible with the libguestfs appliance; use a distribution host kernel via SUPERMIN_KERNEL\n' >&2fi+ if grep -q '^\(Err\|W\):' "$CUSTOMIZE_LOG"; then+ printf '[test-vm-runtime] apt could not fetch:\n' >&2+ grep -A1 '^\(Err\|W\):' "$CUSTOMIZE_LOG" | head -40 >&2+ fiprintf '[test-vm-runtime] last diagnostics:\n' >&2tail -20 "$CUSTOMIZE_LOG" >&2rm -f -- "$CUSTOMIZE_LOG"diff --git a/testing/t0015-test-vm-cli.sh b/testing/t0015-test-vm-cli.shindex 73b2b4b0..f6fba570 100755--- a/testing/t0015-test-vm-cli.sh+++ b/testing/t0015-test-vm-cli.sh@@ -288,6 +288,25 @@ test_expect_success 'the runtime image passes the caller proxy to apt in the appgrep -q "plain http" "$WORK/dns-run.out"'+test_expect_success 'a failed runtime image shows what apt could not fetch' '+ mkdir -p "$WORK/aptfail-bin" &&+ printf "%s\n" "#!/bin/sh" \+ "echo \"Err:1 http://archive.ubuntu.com/ubuntu resolute InRelease\"" \+ "echo \" Temporary failure resolving archive.ubuntu.com\"" \+ "echo \"E: Unable to locate package ripgrep\"" \+ "exit 1" >"$WORK/aptfail-bin/virt-customize" &&+ chmod +x "$WORK/aptfail-bin/virt-customize" &&+ ! env PATH="$WORK/aptfail-bin:$WORK/dns-bin:$PATH" TMPDIR="$WORK" \+ LIBGUESTFS_CACHEDIR="$WORK/aptfail-cache" \+ ../contrib/prepare-test-vm-runtime.sh \+ --rootfs "$WORK/dns-rootfs" --cache-dir "$WORK/aptfail-cache/img" \+ --package-file ../contrib/test-vm-runtime-packages \+ --runtime-key aptfail --key-output "$WORK/aptfail-cache/key" \+ >"$WORK/aptfail.out" 2>&1 &&+ grep -q "apt could not fetch" "$WORK/aptfail.out" &&+ grep -q "Temporary failure resolving archive.ubuntu.com" "$WORK/aptfail.out"+'+test_expect_success 'the kernel package format follows the host package manager' 'printf "print:\n\t@echo \$(PACKAGE_FORMAT)\n" >"$WORK/print.mk" &&format() {