summaryrefslogtreecommitdiffstats
path: root/src/kernel-install/test-kernel-install.sh
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-03-27 21:14:03 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2023-03-30 09:23:07 +0200
commit0362953e9a5e472b5cd66687e79a957b37e35e09 (patch)
tree110c574c1ceec28e654331d9619e3a4bed8222bd /src/kernel-install/test-kernel-install.sh
parentman: drop trailing space and mention uki_generator at one more place (diff)
downloadsystemd-0362953e9a5e472b5cd66687e79a957b37e35e09.tar.xz
systemd-0362953e9a5e472b5cd66687e79a957b37e35e09.zip
test-kernel-install: several cleanups
- allow to run without $PROJECT_BUILD_ROOT, - drop unnecessary export for bootctl, - enable -x option to show commands, - use 'test ! -e' to check the nonexistence of files, - show more debugging logs.
Diffstat (limited to 'src/kernel-install/test-kernel-install.sh')
-rwxr-xr-xsrc/kernel-install/test-kernel-install.sh25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/kernel-install/test-kernel-install.sh b/src/kernel-install/test-kernel-install.sh
index bc833e4cb2..4cbf16f0df 100755
--- a/src/kernel-install/test-kernel-install.sh
+++ b/src/kernel-install/test-kernel-install.sh
@@ -1,16 +1,21 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
# shellcheck disable=SC2235
-set -eu
+set -eux
set -o pipefail
+export SYSTEMD_LOG_LEVEL=debug
+
kernel_install="${1:?}"
plugin="${2:?}"
+if [[ -d "${PROJECT_BUILD_ROOT:-}" ]]; then
+ bootctl="${PROJECT_BUILD_ROOT}/bootctl"
+else
+ bootctl=
+fi
D="$(mktemp --tmpdir --directory "test-kernel-install.XXXXXXXXXX")"
-export _KERNEL_INSTALL_BOOTCTL="$PROJECT_BUILD_ROOT/bootctl"
-
# shellcheck disable=SC2064
trap "rm -rf '$D'" EXIT INT QUIT PIPE
mkdir -p "$D/boot"
@@ -52,9 +57,9 @@ grep -qE 'initrd' "$BOOT_ROOT/the-token/1.1.1/initrd"
"$kernel_install" inspect
"$kernel_install" -v remove 1.1.1
-test ! -f "$entry"
-test ! -f "$BOOT_ROOT/the-token/1.1.1/linux"
-test ! -f "$BOOT_ROOT/the-token/1.1.1/initrd"
+test ! -e "$entry"
+test ! -e "$BOOT_ROOT/the-token/1.1.1/linux"
+test ! -e "$BOOT_ROOT/the-token/1.1.1/initrd"
# Invoke kernel-install as installkernel
ln -s --relative -v "$kernel_install" "$D/sources/installkernel"
@@ -86,7 +91,7 @@ grep -qE '^initrd .*/the-token/1.1.1/initrd' "$entry"
grep -qE 'image' "$BOOT_ROOT/the-token/1.1.1/linux"
grep -qE 'initrd' "$BOOT_ROOT/the-token/1.1.1/initrd"
-if test -x "$_KERNEL_INSTALL_BOOTCTL"; then
+if test -x "$bootctl"; then
echo "Testing bootctl"
e2="${entry%+*}_2.conf"
cp "$entry" "$e2"
@@ -97,14 +102,14 @@ if test -x "$_KERNEL_INSTALL_BOOTCTL"; then
# create file that is not referenced. Check if cleanup removes
# it but leaves the rest alone
:> "$BOOT_ROOT/the-token/1.1.2/initrd"
- "$_KERNEL_INSTALL_BOOTCTL" --root="$D" cleanup
+ "$bootctl" --root="$D" cleanup
test ! -e "$BOOT_ROOT/the-token/1.1.2/initrd"
test -e "$BOOT_ROOT/the-token/1.1.2/linux"
test -e "$BOOT_ROOT/the-token/1.1.1/linux"
test -e "$BOOT_ROOT/the-token/1.1.1/initrd"
# now remove duplicated entry and make sure files are left over
- "$_KERNEL_INSTALL_BOOTCTL" --root="$D" unlink "${e2##*/}"
+ "$bootctl" --root="$D" unlink "${e2##*/}"
test -e "$BOOT_ROOT/the-token/1.1.1/linux"
test -e "$BOOT_ROOT/the-token/1.1.1/initrd"
test -e "$entry"
@@ -112,7 +117,7 @@ if test -x "$_KERNEL_INSTALL_BOOTCTL"; then
# remove last entry referencing those files
entry_id="${entry##*/}"
entry_id="${entry_id%+*}.conf"
- "$_KERNEL_INSTALL_BOOTCTL" --root="$D" unlink "$entry_id"
+ "$bootctl" --root="$D" unlink "$entry_id"
test ! -e "$entry"
test ! -e "$BOOT_ROOT/the-token/1.1.1/linux"
test ! -e "$BOOT_ROOT/the-token/1.1.1/initrd"