From 0362953e9a5e472b5cd66687e79a957b37e35e09 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 28 Mar 2023 04:14:03 +0900 Subject: 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. --- src/kernel-install/test-kernel-install.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/kernel-install') 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" -- cgit v1.2.1