mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-08 05:57:26 +03:00
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. (cherry picked from commit 0362953e9a5e472b5cd66687e79a957b37e35e09)
This commit is contained in:
parent
9943f2af3d
commit
91ff21962d
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user