diff --git a/0100-test-SYSTEMD-INITRD-be-more-careful-with-set-e-and-s.patch b/0100-test-SYSTEMD-INITRD-be-more-careful-with-set-e-and-s.patch new file mode 100644 index 0000000..2ec3387 --- /dev/null +++ b/0100-test-SYSTEMD-INITRD-be-more-careful-with-set-e-and-s.patch @@ -0,0 +1,59 @@ +From 7edb5a72481052de7da5827ddf2dcb665e5a4ca4 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 6 Aug 2025 16:22:34 +0200 +Subject: [PATCH 29/30] test(SYSTEMD-INITRD): be more careful with `set -e` and + subshells + +When the condition in the subshell fails (i.e. none of the +dracut*.service files is found), it doesn't trigger shell exit due to +`set -e` as it's a part of a larger condition (&& ...), but since it's +the last command of that subshell, it sets the subshell error code to 1. +This is then treated by the parent shell as an error and the test is +incorrectly interrupted and marked as failed. + +For comparison: + +$ (set -ex; echo begin; (for f in dracut*.service; do [[ -e "$f" ]] && echo fail; done); echo end); echo $? ++ echo begin +begin ++ for f in dracut*.service ++ [[ -e dracut*.service ]] +1 + +$ (set -ex; echo begin; (for f in dracut*.service; do if [[ -e "$f" ]]; then echo nope; fi; done); echo end); echo $? ++ echo begin +begin ++ for f in dracut*.service ++ [[ -e dracut*.service ]] ++ echo end +end +0 + +Follow-up for 80350104949708c60806a255765e87d7b1d5a98c + +(cherry picked from commit 6fcb4f37b8c40a5085e631bf79f862b0f062ef1a) + +Resolves: RHEL-108215 +--- + test/TEST-42-SYSTEMD-INITRD/test.sh | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/test/TEST-42-SYSTEMD-INITRD/test.sh b/test/TEST-42-SYSTEMD-INITRD/test.sh +index 34ddcbd6..51dc82fb 100755 +--- a/test/TEST-42-SYSTEMD-INITRD/test.sh ++++ b/test/TEST-42-SYSTEMD-INITRD/test.sh +@@ -90,7 +90,10 @@ test_setup() { + ( + cd "$TESTDIR"/initrd/dracut.*/initramfs/usr/lib/systemd/system/ + for f in dracut*.service; do +- [ -e "$f" ] && echo "unexpected dracut service found: $f" && return 1 ++ if [ -e "$f" ]; then ++ echo "unexpected dracut service found: $f" ++ return 1 ++ fi + done + ) + +-- +2.50.1 + diff --git a/0102-test-use-network-instead-of-network-legacy.patch b/0102-test-use-network-instead-of-network-legacy.patch new file mode 100644 index 0000000..694d356 --- /dev/null +++ b/0102-test-use-network-instead-of-network-legacy.patch @@ -0,0 +1,136 @@ +From 88796914fa725c674196c63109fdc3fdae2f0e9d Mon Sep 17 00:00:00 2001 +From: Pavel Valena +Date: Fri, 7 Feb 2025 08:37:27 +0100 +Subject: [PATCH 08/30] build: upgrade to dracut 105 + +also add .dist/rebase.sh tool to help with rebases. + +Resolves: RHEL-65204 +--- + test/TEST-60-NFS/test.sh | 3 ++- + test/TEST-61-MULTINIC/test.sh | 2 +- + test/TEST-62-BONDBRIDGEVLAN/test.sh | 2 +- + test/TEST-70-ISCSI/test.sh | 4 ++-- + test/TEST-71-ISCSI-MULTI/test.sh | 4 ++-- + test/TEST-72-NBD/test.sh | 6 +++--- + 6 files changed, 11 insertions(+), 10 deletions(-) + +diff --git a/test/TEST-60-NFS/test.sh b/test/TEST-60-NFS/test.sh +index cd1689e4..f6efea36 100755 +--- a/test/TEST-60-NFS/test.sh ++++ b/test/TEST-60-NFS/test.sh +@@ -375,8 +375,9 @@ test_setup() { + ) + # Make server's dracut image + "$DRACUT" -i "$TESTDIR"/overlay / \ +- -a "network-legacy ${SERVER_DEBUG:+debug}" \ ++ -a "network ${SERVER_DEBUG:+debug}" \ + -d "af_packet piix ide-gd_mod ata_piix ext4 sd_mod i6300esb virtio_net" \ ++ + --no-hostonly-cmdline -N \ + -f "$TESTDIR"/initramfs.server "$KVERSION" + } +diff --git a/test/TEST-61-MULTINIC/test.sh b/test/TEST-61-MULTINIC/test.sh +index 367d7d24..5dcd931e 100755 +--- a/test/TEST-61-MULTINIC/test.sh ++++ b/test/TEST-61-MULTINIC/test.sh +@@ -358,7 +358,7 @@ test_setup() { + ) + # Make server's dracut image + "$DRACUT" -i "$TESTDIR"/overlay / \ +- -m "bash rootfs-block kernel-modules watchdog qemu network-legacy ${SERVER_DEBUG:+debug}" \ ++ -m "bash rootfs-block kernel-modules watchdog qemu network ${SERVER_DEBUG:+debug}" \ + -d "af_packet piix ide-gd_mod ata_piix ext4 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd i6300esb virtio_net" \ + --no-hostonly-cmdline -N \ + -f "$TESTDIR"/initramfs.server "$KVERSION" +diff --git a/test/TEST-62-BONDBRIDGEVLAN/test.sh b/test/TEST-62-BONDBRIDGEVLAN/test.sh +index 5188c099..1f3878b1 100755 +--- a/test/TEST-62-BONDBRIDGEVLAN/test.sh ++++ b/test/TEST-62-BONDBRIDGEVLAN/test.sh +@@ -393,7 +393,7 @@ test_setup() { + # Make server's dracut image + "$DRACUT" -i "$TESTDIR"/overlay / \ + --no-early-microcode \ +- -m "rootfs-block kernel-modules watchdog qemu network network-legacy ${SERVER_DEBUG:+debug}" \ ++ -m "rootfs-block kernel-modules watchdog qemu network network ${SERVER_DEBUG:+debug}" \ + -d "ipvlan macvlan af_packet piix ide-gd_mod ata_piix ext4 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd virtio-net i6300esb" \ + --no-hostonly-cmdline -N \ + -f "$TESTDIR"/initramfs.server "$KVERSION" +diff --git a/test/TEST-70-ISCSI/test.sh b/test/TEST-70-ISCSI/test.sh +index ff27da53..879b7bd8 100755 +--- a/test/TEST-70-ISCSI/test.sh ++++ b/test/TEST-70-ISCSI/test.sh +@@ -173,7 +173,7 @@ test_setup() { + # Create what will eventually be the server root filesystem onto an overlay + "$DRACUT" -N --keep --tmpdir "$TESTDIR" \ + --add-confdir test-root \ +- -a network-legacy \ ++ -a "${USE_NETWORK}" \ + -d "iscsi_tcp crc32c ipv6" \ + -I "modprobe chmod ip setsid pidof tgtd tgtadm /etc/passwd" \ + --install-optional "/etc/netconfig dhcpd /etc/group /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/services /usr/etc/nsswitch.conf /usr/etc/rpc /usr/etc/protocols /usr/etc/services" \ +@@ -210,7 +210,7 @@ test_setup() { + + # Make server's dracut image + "$DRACUT" \ +- -a "test network-legacy" \ ++ -a "test network" \ + -d "piix ide-gd_mod ata_piix ext4 sd_mod drbg virtio_net virtio_pci virtio_scsi" \ + -i "./server.link" "/etc/systemd/network/01-server.link" \ + -i ./wait-if-server.sh /lib/dracut/hooks/pre-mount/99-wait-if-server.sh \ +diff --git a/test/TEST-71-ISCSI-MULTI/test.sh b/test/TEST-71-ISCSI-MULTI/test.sh +index 2950fc14..0c37c7cc 100755 +--- a/test/TEST-71-ISCSI-MULTI/test.sh ++++ b/test/TEST-71-ISCSI-MULTI/test.sh +@@ -183,7 +183,7 @@ test_setup() { + rm -rf -- "$TESTDIR"/overlay + "$DRACUT" -N --keep --tmpdir "$TESTDIR" \ + --add-confdir test-root \ +- -a "network-legacy iscsi" \ ++ -a "${USE_NETWORK} iscsi" \ + -d "iscsi_tcp crc32c ipv6 af_packet" \ + -I "ip grep sleep setsid chmod modprobe pidof tgtd tgtadm" \ + --install-optional "/etc/netconfig dhcpd /etc/group /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/services /usr/etc/nsswitch.conf /usr/etc/rpc /usr/etc/protocols /usr/etc/services" \ +@@ -228,7 +228,7 @@ test_setup() { + + # Make server's dracut image + "$DRACUT" -i "$TESTDIR"/overlay / \ +- -a "test rootfs-block kernel-modules network-legacy ${SERVER_DEBUG:+debug}" \ ++ -a "test rootfs-block kernel-modules network ${SERVER_DEBUG:+debug}" \ + -d "af_packet piix ide-gd_mod ata_piix ext4 sd_mod drbg virtio_net" \ + -i "./server.link" "/etc/systemd/network/01-server.link" \ + -i "./wait-if-server.sh" "/lib/dracut/hooks/pre-mount/99-wait-if-server.sh" \ +diff --git a/test/TEST-72-NBD/test.sh b/test/TEST-72-NBD/test.sh +index e25f449e..3f05b09c 100755 +--- a/test/TEST-72-NBD/test.sh ++++ b/test/TEST-72-NBD/test.sh +@@ -277,7 +277,7 @@ EOF + + "$DRACUT" --keep --tmpdir "$TESTDIR" \ + --add-confdir test-root \ +- -a "network-legacy" \ ++ -a "network" \ + -I "ip grep sleep nbd-server chmod modprobe pidof" \ + --install-optional "/etc/netconfig dhcpd /etc/group /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/services /usr/etc/nsswitch.conf /usr/etc/rpc /usr/etc/protocols /usr/etc/services" \ + -i /tmp/config /etc/nbd-server/config \ +@@ -295,7 +295,7 @@ EOF + # devices, volume groups, encrypted partitions, etc. + "$DRACUT" -N -i "$TESTDIR"/overlay / \ + --add-confdir test-makeroot \ +- -a "network-legacy" \ ++ -a "${USE_NETWORK}" \ + -i ./create-server-root.sh /lib/dracut/hooks/initqueue/01-create-server-root.sh \ + --nomdadmconf \ + --no-hostonly-cmdline -N \ +@@ -338,7 +338,7 @@ test_setup() { + -i "/tmp/key" "/etc/key" + + "$DRACUT" -N -i "$TESTDIR"/overlay / \ +- -a "test network-legacy ${SERVER_DEBUG:+debug}" \ ++ -a "test network ${SERVER_DEBUG:+debug}" \ + -d "af_packet piix ide-gd_mod ata_piix ext4 sd_mod drbg virtio_net" \ + -i "./server.link" "/etc/systemd/network/01-server.link" \ + -i "./wait-if-server.sh" "/lib/dracut/hooks/pre-mount/99-wait-if-server.sh" \ +-- +2.50.1 + diff --git a/dracut.spec b/dracut.spec index 6c322fd..e6e39e8 100644 --- a/dracut.spec +++ b/dracut.spec @@ -8,7 +8,7 @@ Name: dracut Version: 107 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Initramfs generator using udev @@ -92,6 +92,14 @@ Patch22: 0022-improvement-74nvmf-lookup-required-NIC-kernel-module.patch # Author: Tomas Bzatek Patch23: 0023-fix-74nvmf-set-root-nvmf.patch + +# test(SYSTEMD-INITRD): be more careful with `set -e` and subshells +# Author: Frantisek Sumsal +Patch100: 0100-test-SYSTEMD-INITRD-be-more-careful-with-set-e-and-s.patch +# test: use network instead of network-legacy +# Author: Pavel Valena +#Patch102: 0102-test-use-network-instead-of-network-legacy.patch + # Please use source-git to work with this spec file: # HowTo: https://packit.dev/source-git/work-with-source-git # Source-git repository: https://github.com/redhat-plumbers/dracut-rhel10/ @@ -513,6 +521,11 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/ %{_prefix}/lib/kernel/install.d/51-dracut-rescue.install %changelog +* Mon Aug 18 2025 Pavel Valena - 107-3 +- test(SYSTEMD-INITRD): be more careful with `set -e` and subshells +- test: fixup NFS test.sh + Resolves: RHEL-108215,RHEL-97473 + * Thu Aug 07 2025 Pavel Valena - 107-2 - fix: improve hostonly sloppy mode - fix(dracut.sh): don't pass empty string as dir