summaryrefslogtreecommitdiffstats
path: root/src/kernel-install/test-kernel-install.sh
diff options
context:
space:
mode:
authorLudwig Nussel <ludwig.nussel@suse.de>2022-12-08 16:27:31 +0100
committerLudwig Nussel <ludwig.nussel@suse.de>2023-01-19 14:24:43 +0100
commit8702496bfb0205764569782a9a2ebd11fd80e5e8 (patch)
tree1b610c546c1ef4fb3422341430edab09bf5873f3 /src/kernel-install/test-kernel-install.sh
parentchase-symlinks: new chase_symlinks_and_unlink() (diff)
downloadsystemd-8702496bfb0205764569782a9a2ebd11fd80e5e8.tar.xz
systemd-8702496bfb0205764569782a9a2ebd11fd80e5e8.zip
bootctl: unlink and cleanup functions
The unlink command removes an entry from the ESP including referenced files that are not referenced in other entries. That is useful eg to have multiple entries that use the same kernel with different options. The cleanup command removes all files that are not referenced by any entry.
Diffstat (limited to 'src/kernel-install/test-kernel-install.sh')
-rwxr-xr-xsrc/kernel-install/test-kernel-install.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/kernel-install/test-kernel-install.sh b/src/kernel-install/test-kernel-install.sh
index 2e44063668..f16bb9f50f 100755
--- a/src/kernel-install/test-kernel-install.sh
+++ b/src/kernel-install/test-kernel-install.sh
@@ -9,6 +9,8 @@ plugin="${2:?}"
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"
@@ -31,6 +33,7 @@ EOF
export KERNEL_INSTALL_CONF_ROOT="$D/sources"
export KERNEL_INSTALL_PLUGINS="$plugin"
export BOOT_ROOT="$D/boot"
+export BOOT_MNT="$D/boot"
export MACHINE_ID='3e0484f3634a418b8e6a39e8828b03e3'
"$kernel_install" -v add 1.1.1 "$D/sources/linux" "$D/sources/initrd"
@@ -82,3 +85,32 @@ 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
+ echo "Testing bootctl"
+ e2="${entry%+*}_2.conf"
+ cp "$entry" "$e2"
+ export SYSTEMD_ESP_PATH=/
+
+ # 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="$BOOT_ROOT" 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="$BOOT_ROOT" 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"
+ test ! -e "$e2"
+ # remove last entry referencing those files
+ entry_id="${entry##*/}"
+ entry_id="${entry_id%+*}.conf"
+ "$_KERNEL_INSTALL_BOOTCTL" --root="$BOOT_ROOT" 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"
+fi