From 2074041596d75a33fa5544d1ae7f332ed2401261 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 28 2023 08:58:16 +0000 Subject: import dracut-057-21.git20230214.el9 --- diff --git a/SOURCES/0013.patch b/SOURCES/0013.patch new file mode 100644 index 0000000..5aaff3b --- /dev/null +++ b/SOURCES/0013.patch @@ -0,0 +1,29 @@ +From bdd3fa585fcfa21f20d66f01568967c0d7a771d6 Mon Sep 17 00:00:00 2001 +From: Pavel Valena +Date: Tue, 16 Aug 2022 15:21:05 +0200 +Subject: [PATCH] ci: pull request template + +rhel-only +--- + .github/pull_request_template.md | 11 +++-------- + 1 file changed, 3 insertions(+), 8 deletions(-) + +diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md +index ef281c3d..8fcf4d33 100644 +--- a/.github/pull_request_template.md ++++ b/.github/pull_request_template.md +@@ -1,10 +1,5 @@ +-This pull request changes... ++ + +-## Changes ++(cherry picked from commit ... ) + +-## Checklist +-- [ ] I have tested it locally +-- [ ] I have reviewed and updated any documentation if relevant +-- [ ] I am providing new code and test(s) for it +- +-Fixes # ++Resolves: # + diff --git a/SOURCES/0014.patch b/SOURCES/0014.patch new file mode 100644 index 0000000..611319d --- /dev/null +++ b/SOURCES/0014.patch @@ -0,0 +1,42 @@ +From f93ac80a0b3e9017bf2c374b72126908a7f5cbde Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Mon, 8 Aug 2022 13:42:51 +0200 +Subject: [PATCH] refactor(url-lib): write curl output directly to file + +The redirection to stdout was originally added to workaround +https://bugzilla.redhat.com/show_bug.cgi?id=989133 (curl would create no +file if the source was empty), but I don't see that problem with current +curl. + +A nice side-effect of this change is that curl shows download progress. + +(cherry picked from commit 1343d21d8c0d1f7239e27165e9c7633b504f777f) + +Resolves: #2112475 +--- + modules.d/45url-lib/url-lib.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/modules.d/45url-lib/url-lib.sh b/modules.d/45url-lib/url-lib.sh +index e88fbc14..b009fd09 100755 +--- a/modules.d/45url-lib/url-lib.sh ++++ b/modules.d/45url-lib/url-lib.sh +@@ -67,7 +67,7 @@ curl_fetch_url() { + echo "$url" > /proc/self/fd/0 + if [ -n "$outloc" ]; then + # shellcheck disable=SC2086 +- curl $curl_args --output - -- "$url" > "$outloc" || return $? ++ curl $curl_args --output "$outloc" -- "$url" || return $? + else + local outdir + outdir="$(mkuniqdir /tmp curl_fetch_url)" +@@ -101,7 +101,7 @@ ctorrent_fetch_url() { + echo "$url" > /proc/self/fd/0 + if [ -n "$outloc" ]; then + # shellcheck disable=SC2086 +- curl $curl_args --output - -- "$url" > "$torrent_outloc" || return $? ++ curl $curl_args --output "$torrent_outloc" -- "$url" || return $? + else + local outdir + outdir="$(mkuniqdir /tmp torrent_fetch_url)" + diff --git a/SOURCES/0015.patch b/SOURCES/0015.patch new file mode 100644 index 0000000..d150853 --- /dev/null +++ b/SOURCES/0015.patch @@ -0,0 +1,45 @@ +From f5ef6694eae2696b10b4f6e5a0d72a29223651ce Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Tue, 20 Sep 2022 02:13:01 +0800 +Subject: [PATCH] fix(dracut-initramfs-restore.sh): initramfs detection not + working + +The path detection is not working on latest Fedora and some other +distros, and it fails to extract the initramfs. It seems the if +statement is broken by a previous commit, so let's fix it. + +Fixes: 3d8e1ad ('fix(dracut-initramfs-restore.sh): add missing default paths') +Signed-off-by: Kairui Song +(cherry picked from commit 481b87fa7a82be54663071ad9ad76c34e378ddc7) + +Resolves: #2149232 +--- + dracut-initramfs-restore.sh | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh +index 68ea3873..df6cb9a8 100644 +--- a/dracut-initramfs-restore.sh ++++ b/dracut-initramfs-restore.sh +@@ -27,14 +27,14 @@ fi + + mount -o ro /boot &> /dev/null || true + +-if [[ -d /efi/loader/entries ]] || [[ -L /efi/loader/entries ]] \ +- || [[ -d /efi/$MACHINE_ID ]] || [[ -L /efi/$MACHINE_ID ]]; then ++if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \ ++ && [[ -d /efi/$MACHINE_ID || -L /efi/$MACHINE_ID ]]; then + IMG="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd" +-elif [[ -d /boot/loader/entries ]] || [[ -L /boot/loader/entries ]] \ +- || [[ -d /boot/$MACHINE_ID ]] || [[ -L /boot/$MACHINE_ID ]]; then ++elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \ ++ && [[ -d /boot/$MACHINE_ID || -L /boot/$MACHINE_ID ]]; then + IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd" +-elif [[ -d /boot/efi/loader/entries ]] || [[ -L /boot/efi/loader/entries ]] \ +- || [[ -d /boot/efi/$MACHINE_ID ]] || [[ -L /boot/efi/$MACHINE_ID ]]; then ++elif [[ -d /boot/efi/loader/entries || -L /boot/efi/loader/entries ]] \ ++ && [[ -d /boot/efi/$MACHINE_ID || -L /boot/efi/$MACHINE_ID ]]; then + IMG="/boot/efi/$MACHINE_ID/$KERNEL_VERSION/initrd" + elif [[ -f /lib/modules/${KERNEL_VERSION}/initrd ]]; then + IMG="/lib/modules/${KERNEL_VERSION}/initrd" + diff --git a/SOURCES/0016.patch b/SOURCES/0016.patch new file mode 100644 index 0000000..65e1239 --- /dev/null +++ b/SOURCES/0016.patch @@ -0,0 +1,31 @@ +From 6a1d39e50d9f8a7f3765fa6cb85b34e6597d864d Mon Sep 17 00:00:00 2001 +From: Pavel Valena +Date: Tue, 6 Dec 2022 21:46:01 +0100 +Subject: [PATCH] fix(90kernel-modules): install blk modules using symbol + blk_alloc_disk + +Corresponding kernel symbol blk_cleanup_disk is no longer used in the nvdimm +driver and calls are made directly instead. + +blk_alloc_disk is used: +https://elixir.bootlin.com/linux/v6.1-rc8/source/drivers/nvdimm/pmem.c#L522 + +Resolves: #2149781 +--- + modules.d/90kernel-modules/module-setup.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh +index 191af041..0b9488c3 100755 +--- a/modules.d/90kernel-modules/module-setup.sh ++++ b/modules.d/90kernel-modules/module-setup.sh +@@ -2,7 +2,7 @@ + + # called by dracut + installkernel() { +- local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host|scsi_add_host_with_dma|blk_mq_alloc_disk|blk_cleanup_disk' ++ local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host|scsi_add_host_with_dma|blk_alloc_disk|blk_mq_alloc_disk|blk_cleanup_disk' + local -A _hostonly_drvs + + find_kernel_modules_external() { + diff --git a/SOURCES/0017.patch b/SOURCES/0017.patch new file mode 100644 index 0000000..6b6396b --- /dev/null +++ b/SOURCES/0017.patch @@ -0,0 +1,99 @@ +From 8ab3020205ea92cbef3ca250c924d9b500c5d9aa Mon Sep 17 00:00:00 2001 +From: Hari Bathini +Date: Tue, 12 Jul 2022 13:55:47 +0530 +Subject: [PATCH] fix(squash): build ld cache for squash loader + +Commit dc21638c3f0a fixes kdump kernel crash, due to non-conventional +library path in powerpc, by copying /etc/ld.so.cache under initdir. +While that works in general, it is vulnerable to failure because of +missing links, when the CPU is reconfigured to run in compatibility +mode of older CPU version. Avoid this by running ldconfig for squash +loader to create the necessary links & ld cache for it. Doing this +also saves a few kilobyes of space as the copied ld cache is bigger +in size than the one needed for squash loader environment. + +Fixes: dc21638c3f0a ("fix(squash): keep ld cache under initdir") +Cc: Pingfan Liu +Signed-off-by: Hari Bathini + +Resolves: rhbz#2122274 +--- + dracut-init.sh | 14 ++++++++++++++ + dracut.sh | 11 +---------- + modules.d/99squash/module-setup.sh | 8 +++----- + 3 files changed, 18 insertions(+), 15 deletions(-) + +diff --git a/dracut-init.sh b/dracut-init.sh +index 900e8b83..fe1b1426 100644 +--- a/dracut-init.sh ++++ b/dracut-init.sh +@@ -504,6 +504,20 @@ inst_rules_wildcard() { + [[ $_found ]] || dinfo "Skipping udev rule: $_rule" + } + ++# make sure that library links are correct and up to date ++build_ld_cache() { ++ for f in "$dracutsysrootdir"/etc/ld.so.conf "$dracutsysrootdir"/etc/ld.so.conf.d/*; do ++ [[ -f $f ]] && inst_simple "${f#$dracutsysrootdir}" ++ done ++ if ! $DRACUT_LDCONFIG -r "$initdir" -f /etc/ld.so.conf; then ++ if [[ $EUID == 0 ]]; then ++ derror "ldconfig exited ungracefully" ++ else ++ derror "ldconfig might need uid=0 (root) for chroot()" ++ fi ++ fi ++} ++ + prepare_udev_rules() { + if [ -z "$UDEVVERSION" ]; then + UDEVVERSION=$(udevadm --version) +diff --git a/dracut.sh b/dracut.sh +index 210a8275..d2f07ac6 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -2360,16 +2360,7 @@ fi + + if [[ $kernel_only != yes ]]; then + # make sure that library links are correct and up to date +- for f in "$dracutsysrootdir"/etc/ld.so.conf "$dracutsysrootdir"/etc/ld.so.conf.d/*; do +- [[ -f $f ]] && inst_simple "${f#$dracutsysrootdir}" +- done +- if ! $DRACUT_LDCONFIG -r "$initdir" -f /etc/ld.so.conf; then +- if [[ $EUID == 0 ]]; then +- derror "ldconfig exited ungracefully" +- else +- derror "ldconfig might need uid=0 (root) for chroot()" +- fi +- fi ++ build_ld_cache + fi + + if dracut_module_included "squash"; then +diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh +index c42eb679..f31ff556 100644 +--- a/modules.d/99squash/module-setup.sh ++++ b/modules.d/99squash/module-setup.sh +@@ -28,11 +28,6 @@ installpost() { + [[ $squash_dir == "$i"/* ]] || mv "$i" "$squash_dir"/ + done + +- # initdir also needs ld.so.* to make ld.so work +- inst /etc/ld.so.cache +- inst /etc/ld.so.conf +- inst_dir /etc/ld.so.conf.d +- + # Create mount points for squash loader + mkdir -p "$initdir"/squash/ + mkdir -p "$squash_dir"/squash/ +@@ -67,6 +62,9 @@ installpost() { + ln_r /usr/bin /bin + ln_r /usr/sbin /sbin + inst_simple "$moddir"/init-squash.sh /init ++ ++ # make sure that library links are correct and up to date for squash loader ++ build_ld_cache + } + + install() { + diff --git a/SOURCES/0018.patch b/SOURCES/0018.patch new file mode 100644 index 0000000..ab9a873 --- /dev/null +++ b/SOURCES/0018.patch @@ -0,0 +1,59 @@ +From 37e73a30c5b75a57de9e2bb6843eb9a1dab12abf Mon Sep 17 00:00:00 2001 +From: Laszlo Gombos +Date: Sun, 14 Aug 2022 22:46:10 +0000 +Subject: [PATCH] test(16-DMSQUASH): make it pass on arch + +Include additional kernel drivers and install squashfs-tools +into the arch container. + +(cherry picked from commit b8ffc87d13989f95c8f48ec64613dd9138835618) + +Related: #2135060 +--- + test/TEST-16-DMSQUASH/test.sh | 4 +++- + test/container/Dockerfile-Arch | 2 +- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/test/TEST-16-DMSQUASH/test.sh b/test/TEST-16-DMSQUASH/test.sh +index cf433489..52029375 100755 +--- a/test/TEST-16-DMSQUASH/test.sh ++++ b/test/TEST-16-DMSQUASH/test.sh +@@ -6,7 +6,7 @@ TEST_DESCRIPTION="live root on a squash filesystem" + KVERSION="${KVERSION-$(uname -r)}" + + # Uncomment this to debug failures +-# DEBUGFAIL="rd.shell rd.debug loglevel=7" ++#DEBUGFAIL="rd.shell rd.debug loglevel=7" + + test_run() { + dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1 +@@ -72,6 +72,7 @@ test_setup() { + # devices, volume groups, encrypted partitions, etc. + "$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \ + --modules "rootfs-block qemu" \ ++ --drivers "ext4 sd_mod" \ + --no-hostonly --no-hostonly-cmdline --no-early-microcode --nofscks --nomdadmconf --nohardlink --nostrip \ + --force "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 + rm -rf -- "$TESTDIR"/overlay +@@ -109,6 +110,7 @@ test_setup() { + "$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \ + --modules "dmsquash-live qemu" \ + --omit "rngd" \ ++ --drivers "ext4 sd_mod" \ + --no-hostonly --no-hostonly-cmdline \ + --force "$TESTDIR"/initramfs.testing "$KVERSION" || return 1 + +diff --git a/test/container/Dockerfile-Arch b/test/container/Dockerfile-Arch +index 922b8ede..ac1513a1 100644 +--- a/test/container/Dockerfile-Arch ++++ b/test/container/Dockerfile-Arch +@@ -9,7 +9,7 @@ RUN echo 'export DRACUT_NO_XATTR=1 KVERSION=$(cd /lib/modules; ls -1 | tail -1)' + + # Install needed packages for the dracut CI container + RUN pacman --noconfirm -Sy \ +- linux dash strace dhclient asciidoc cpio pigz \ ++ linux dash strace dhclient asciidoc cpio pigz squashfs-tools \ + qemu btrfs-progs mdadm dmraid nfs-utils nfsidmap lvm2 nbd \ + dhcp networkmanager multipath-tools vi tcpdump open-iscsi \ + git shfmt shellcheck astyle which base-devel && yes | pacman -Scc + diff --git a/SOURCES/0019.patch b/SOURCES/0019.patch new file mode 100644 index 0000000..acd4e7f --- /dev/null +++ b/SOURCES/0019.patch @@ -0,0 +1,425 @@ +From 8aa62b8cb28a41d4739633aee9b02e40dc4a75d0 Mon Sep 17 00:00:00 2001 +From: Matt Coleman +Date: Fri, 23 Sep 2022 19:28:25 -0400 +Subject: [PATCH] feat(dmsquash-live): add new dmsquash-live-autooverlay module + +Adapt to test properly with the CentOS Stream 9 container too. + +(cherry picked from commit a3c67d27e75223bb45df19f850d246ced9a09938) + +Co-authored-by: Neal Gompa + +Resolves: #2135060 +--- + .github/workflows/integration.yml | 1 + + man/dracut.cmdline.7.asc | 4 + + .../create-overlay-genrules.sh | 10 ++ + .../90dmsquash-live-autooverlay/create-overlay.sh | 119 +++++++++++++++++++++ + .../90dmsquash-live-autooverlay/module-setup.sh | 25 +++++ + pkgbuild/dracut.spec | 3 +- + test/TEST-16-DMSQUASH/create-root.sh | 12 ++- + test/TEST-16-DMSQUASH/test-init.sh | 6 ++ + test/TEST-16-DMSQUASH/test.sh | 38 ++++++- + test/container/Dockerfile-Arch | 2 +- + test/container/Dockerfile-CentOS-9-Stream | 2 + + test/container/Dockerfile-Debian | 1 + + test/container/Dockerfile-Fedora-latest | 1 + + test/container/Dockerfile-OpenSuse-latest | 2 +- + 14 files changed, 218 insertions(+), 8 deletions(-) + +diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml +index 40da300c..c22bf916 100644 +--- a/.github/workflows/integration.yml ++++ b/.github/workflows/integration.yml +@@ -98,6 +98,7 @@ jobs: + "11", + "12", + "13", ++ "16", + "17", + "20", + "21", +diff --git a/man/dracut.cmdline.7.asc b/man/dracut.cmdline.7.asc +index fda62fd1..40d13d83 100644 +--- a/man/dracut.cmdline.7.asc ++++ b/man/dracut.cmdline.7.asc +@@ -1161,6 +1161,10 @@ rd.live.overlay=/dev/sdb1:persistent-overlay.img + rd.live.overlay=UUID=99440c1f-8daa-41bf-b965-b7240a8996f4 + -- + ++**rd.live.overlay.cowfs=**__[btrfs|ext4|xfs]__:: ++Specifies the filesystem to use when formatting the overlay partition. ++The default is ext4. ++ + **rd.live.overlay.size=**____:: + Specifies a non-persistent Device-mapper overlay size in MiB. The default is + _32768_. +diff --git a/modules.d/90dmsquash-live-autooverlay/create-overlay-genrules.sh b/modules.d/90dmsquash-live-autooverlay/create-overlay-genrules.sh +new file mode 100755 +index 00000000..ed168d9f +--- /dev/null ++++ b/modules.d/90dmsquash-live-autooverlay/create-overlay-genrules.sh +@@ -0,0 +1,10 @@ ++#!/bin/sh ++ ++# shellcheck disable=SC2154 ++case "$root" in ++ live:/dev/*) ++ printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/create-overlay %s"\n' \ ++ "${root#live:/dev/}" "${root#live:}" >> /etc/udev/rules.d/95-create-overlay.rules ++ wait_for_dev -n "${root#live:}" ++ ;; ++esac +diff --git a/modules.d/90dmsquash-live-autooverlay/create-overlay.sh b/modules.d/90dmsquash-live-autooverlay/create-overlay.sh +new file mode 100755 +index 00000000..c89bda2b +--- /dev/null ++++ b/modules.d/90dmsquash-live-autooverlay/create-overlay.sh +@@ -0,0 +1,119 @@ ++#!/bin/sh ++ ++type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh ++ ++if getargbool 0 rd.live.debug -n -y rdlivedebug; then ++ exec > /tmp/create-overlay.$$.out ++ exec 2>> /tmp/create-overlay.$$.out ++ set -x ++fi ++ ++gatherData() { ++ overlay=$(getarg rd.live.overlay) ++ if [ -z "$overlay" ]; then ++ info "Skipping overlay creation: kernel command line parameter 'rd.live.overlay' is not set" ++ exit 0 ++ fi ++ # shellcheck disable=SC2086 ++ if ! str_starts ${overlay} LABEL=; then ++ die "Overlay creation failed: the partition must be set by LABEL in the 'rd.live.overlay' kernel parameter" ++ fi ++ ++ overlayLabel=${overlay#LABEL=} ++ # shellcheck disable=SC2086 ++ if [ -b /dev/disk/by-label/${overlayLabel} ]; then ++ info "Skipping overlay creation: overlay already exists" ++ exit 0 ++ fi ++ ++ filesystem=$(getarg rd.live.overlay.cowfs) ++ [ -z "$filesystem" ] && filesystem="ext4" ++ if [ "$filesystem" != "ext4" ] && [ "$filesystem" != "xfs" ] && [ "$filesystem" != "btrfs" ]; then ++ die "Overlay creation failed: only ext4, xfs, and btrfs are supported in the 'rd.live.overlay.cowfs' kernel parameter" ++ fi ++ ++ live_dir=$(getarg rd.live.dir) ++ [ -z "$live_dir" ] && live_dir="LiveOS" ++ ++ [ -z "$1" ] && exit 1 ++ rootDevice=$1 ++ ++ # The kernel command line's 'root=' parameter was parsed into the $root variable by the dmsquash-live module. ++ # $root contains the path to a symlink within /dev/disk/by-label, which points to a partition. ++ # This script needs that partition's parent block device. ++ # shellcheck disable=SC2046 ++ # shellcheck disable=SC2086 ++ rootDeviceAbsolutePath=$(readlink -f ${rootDevice}) ++ rootDeviceSysfsPath=/sys/class/block/${rootDeviceAbsolutePath##*/} ++ if [ -f "${rootDeviceSysfsPath}/partition" ]; then ++ # shellcheck disable=SC2086 ++ partition=$(cat ${rootDeviceSysfsPath}/partition) ++ else ++ partition=0 ++ fi ++ # shellcheck disable=SC2086 ++ readonly=$(cat ${rootDeviceSysfsPath}/ro) ++ # shellcheck disable=SC2086 ++ if [ "$partition" != "1" ] || [ "$readonly" != "0" ]; then ++ info "Skipping overlay creation: unpartitioned or read-only media detected" ++ exit 0 ++ fi ++ # shellcheck disable=SC2046 ++ # shellcheck disable=SC2086 ++ fullDriveSysfsPath=$(readlink -f ${rootDeviceSysfsPath}/..) ++ blockDevice=/dev/${fullDriveSysfsPath##*/} ++ currentPartitionCount=$(grep --count -E "${blockDevice#/dev/}[0-9]+" /proc/partitions) ++ ++ # shellcheck disable=SC2086 ++ freeSpaceStart=$(parted --script ${blockDevice} unit % print free \ ++ | awk -v x=${currentPartitionCount} '$1 == x {getline; print $1}') ++ if [ -z "$freeSpaceStart" ]; then ++ info "Skipping overlay creation: there is no free space after the last partition" ++ exit 0 ++ fi ++ partitionStart=$((${freeSpaceStart%.*} + 1)) ++ if [ $partitionStart -eq 100 ]; then ++ info "Skipping overlay creation: there is not enough free space after the last partition" ++ exit 0 ++ fi ++ ++ overlayPartition=${blockDevice}$((currentPartitionCount + 1)) ++ ++ label=$(blkid --match-tag LABEL --output value "$rootDevice") ++ uuid=$(blkid --match-tag UUID --output value "$rootDevice") ++ if [ -z "$label" ] || [ -z "$uuid" ]; then ++ die "Overlay creation failed: failed to look up root device label and UUID" ++ fi ++} ++ ++createPartition() { ++ # shellcheck disable=SC2086 ++ parted --script --align optimal ${blockDevice} mkpart primary ${partitionStart}% 100% ++} ++ ++createFilesystem() { ++ # shellcheck disable=SC2086 ++ mkfs.${filesystem} -L ${overlayLabel} ${overlayPartition} ++ ++ baseDir=/run/initramfs/create-overlayfs ++ mkdir -p ${baseDir} ++ # shellcheck disable=SC2086 ++ mount -t auto ${overlayPartition} ${baseDir} ++ ++ mkdir -p ${baseDir}/${live_dir}/ovlwork ++ # shellcheck disable=SC2086 ++ mkdir ${baseDir}/${live_dir}/overlay-${label}-${uuid} ++ ++ umount ${baseDir} ++ rm -r ${baseDir} ++} ++ ++main() { ++ gatherData "$1" ++ createPartition ++ udevsettle ++ createFilesystem ++ udevsettle ++} ++ ++main "$1" +diff --git a/modules.d/90dmsquash-live-autooverlay/module-setup.sh b/modules.d/90dmsquash-live-autooverlay/module-setup.sh +new file mode 100755 +index 00000000..c3712eba +--- /dev/null ++++ b/modules.d/90dmsquash-live-autooverlay/module-setup.sh +@@ -0,0 +1,25 @@ ++#!/bin/bash ++ ++check() { ++ # including a module dedicated to live environments in a host-only initrd doesn't make sense ++ [[ $hostonly ]] && return 1 ++ return 255 ++} ++ ++depends() { ++ echo dmsquash-live ++ return 0 ++} ++ ++installkernel() { ++ instmods btrfs ext4 xfs ++} ++ ++install() { ++ inst_multiple awk blkid cat grep mkdir mount parted readlink rmdir tr umount ++ inst_multiple -o mkfs.btrfs mkfs.ext4 mkfs.xfs ++ # shellcheck disable=SC2154 ++ inst_hook pre-udev 25 "$moddir/create-overlay-genrules.sh" ++ inst_script "$moddir/create-overlay.sh" "/sbin/create-overlay" ++ dracut_need_initqueue ++} +diff --git a/pkgbuild/dracut.spec b/pkgbuild/dracut.spec +index 38de47b4..e148bbf7 100644 +--- a/pkgbuild/dracut.spec ++++ b/pkgbuild/dracut.spec +@@ -138,7 +138,7 @@ Requires: %{name} >= %{version}-%{dist_free_release} + Requires: %{name} = %{version}-%{release} + %endif + Requires: %{name}-network = %{version}-%{release} +-Requires: tar gzip coreutils bash device-mapper curl ++Requires: tar gzip coreutils bash device-mapper curl parted + %if 0%{?fedora} + Requires: fuse ntfs-3g + %endif +@@ -461,6 +461,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/ + %files live + %{dracutlibdir}/modules.d/99img-lib + %{dracutlibdir}/modules.d/90dmsquash-live ++%{dracutlibdir}/modules.d/90dmsquash-live-autooverlay + %{dracutlibdir}/modules.d/90dmsquash-live-ntfs + %{dracutlibdir}/modules.d/90livenet + +diff --git a/test/TEST-16-DMSQUASH/create-root.sh b/test/TEST-16-DMSQUASH/create-root.sh +index 9bc1aa5d..c11e17e0 100755 +--- a/test/TEST-16-DMSQUASH/create-root.sh ++++ b/test/TEST-16-DMSQUASH/create-root.sh +@@ -11,9 +11,17 @@ udevadm control --reload + set -e + + udevadm settle +-mkfs.ext4 -q -L dracut /dev/disk/by-id/ata-disk_root ++ ++# create a single partition using 50% of the capacity of the image file created by test_setup() in test.sh ++sfdisk /dev/disk/by-id/ata-disk_root << EOF ++2048,161792 ++EOF ++ ++udevadm settle ++ ++mkfs.ext4 -q -L dracut /dev/disk/by-id/ata-disk_root-part1 + mkdir -p /root +-mount /dev/disk/by-id/ata-disk_root /root ++mount /dev/disk/by-id/ata-disk_root-part1 /root + mkdir -p /root/run /root/testdir + echo "Creating squashfs" + mksquashfs /source /root/testdir/rootfs.img -quiet +diff --git a/test/TEST-16-DMSQUASH/test-init.sh b/test/TEST-16-DMSQUASH/test-init.sh +index 068e8f38..959fa25f 100755 +--- a/test/TEST-16-DMSQUASH/test-init.sh ++++ b/test/TEST-16-DMSQUASH/test-init.sh +@@ -9,6 +9,12 @@ exec > /dev/console 2>&1 + + echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker + ++if grep -qF ' rd.live.overlay=LABEL=persist ' /proc/cmdline; then ++ # Writing to a file in the root filesystem lets test_run() verify that the autooverlay module successfully created ++ # and formatted the overlay partition and that the dmsquash-live module used it when setting up the rootfs overlay. ++ echo "dracut-autooverlay-success" > /overlay-marker ++fi ++ + export TERM=linux + export PS1='initramfs-test:\w\$ ' + [ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab +diff --git a/test/TEST-16-DMSQUASH/test.sh b/test/TEST-16-DMSQUASH/test.sh +index 52029375..58d73b0d 100755 +--- a/test/TEST-16-DMSQUASH/test.sh ++++ b/test/TEST-16-DMSQUASH/test.sh +@@ -5,8 +5,9 @@ TEST_DESCRIPTION="live root on a squash filesystem" + + KVERSION="${KVERSION-$(uname -r)}" + +-# Uncomment this to debug failures +-#DEBUGFAIL="rd.shell rd.debug loglevel=7" ++# Uncomment these to debug failures ++#DEBUGFAIL="rd.shell rd.debug rd.live.debug loglevel=7" ++#DEBUGTOOLS="setsid ls cat sfdisk" + + test_run() { + dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1 +@@ -23,6 +24,27 @@ test_run() { + -initrd "$TESTDIR"/initramfs.testing + + grep -U --binary-files=binary -F -m 1 -q dracut-root-block-success -- "$TESTDIR"/marker.img || return 1 ++ ++ rootPartitions=$(sfdisk -d "$TESTDIR"/root.img | grep -c 'root\.img[0-9]') ++ [ "$rootPartitions" -eq 1 ] || return 1 ++ ++ "$testdir"/run-qemu \ ++ "${disk_args[@]}" \ ++ -boot order=d \ ++ -append "rd.live.image rd.live.overlay.overlayfs=1 rd.live.overlay=LABEL=persist rd.live.dir=testdir root=LABEL=dracut console=ttyS0,115200n81 quiet selinux=0 rd.info rd.shell=0 panic=1 oops=panic softlockup_panic=1 $DEBUGFAIL" \ ++ -initrd "$TESTDIR"/initramfs.testing-autooverlay ++ ++ rootPartitions=$(sfdisk -d "$TESTDIR"/root.img | grep -c 'root\.img[0-9]') ++ [ "$rootPartitions" -eq 2 ] || return 1 ++ ++ ( ++ # Ensure that this test works when run with the `V=1` parameter, which runs the script with `set -o pipefail`. ++ set +o pipefail ++ ++ # Verify that the string "dracut-autooverlay-success" occurs in the second partition in the image file. ++ dd if="$TESTDIR"/root.img bs=1MiB skip=80 status=none \ ++ | grep -U --binary-files=binary -F -m 1 -q dracut-autooverlay-success ++ ) || return 1 + } + + test_setup() { +@@ -49,7 +71,7 @@ test_setup() { + ln -s dracut-util "${initdir}/usr/bin/dracut-getarg" + ln -s dracut-util "${initdir}/usr/bin/dracut-getargs" + +- inst_multiple mkdir ln dd stty mount poweroff ++ inst_multiple mkdir ln dd stty mount poweroff grep "$DEBUGTOOLS" + + cp -a -- /etc/ld.so.conf* "$initdir"/etc + ldconfig -r "$initdir" +@@ -115,6 +137,16 @@ test_setup() { + --force "$TESTDIR"/initramfs.testing "$KVERSION" || return 1 + + ls -sh "$TESTDIR"/initramfs.testing ++ ++ "$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \ ++ --modules "dmsquash-live-autooverlay qemu" \ ++ --omit "rngd" \ ++ --drivers "ext4 sd_mod" \ ++ --no-hostonly --no-hostonly-cmdline \ ++ --force "$TESTDIR"/initramfs.testing-autooverlay "$KVERSION" || return 1 ++ ++ ls -sh "$TESTDIR"/initramfs.testing-autooverlay ++ + rm -rf -- "$TESTDIR"/overlay + } + +diff --git a/test/container/Dockerfile-Arch b/test/container/Dockerfile-Arch +index ac1513a1..4112cc5b 100644 +--- a/test/container/Dockerfile-Arch ++++ b/test/container/Dockerfile-Arch +@@ -12,7 +12,7 @@ RUN pacman --noconfirm -Sy \ + linux dash strace dhclient asciidoc cpio pigz squashfs-tools \ + qemu btrfs-progs mdadm dmraid nfs-utils nfsidmap lvm2 nbd \ + dhcp networkmanager multipath-tools vi tcpdump open-iscsi \ +- git shfmt shellcheck astyle which base-devel && yes | pacman -Scc ++ git shfmt shellcheck astyle which base-devel glibc parted && yes | pacman -Scc + + RUN useradd -m build + RUN su build -c 'cd && git clone https://aur.archlinux.org/perl-config-general.git && cd perl-config-general && makepkg -s --noconfirm' +diff --git a/test/container/Dockerfile-CentOS-9-Stream b/test/container/Dockerfile-CentOS-9-Stream +index c9a96020..abcc067e 100644 +--- a/test/container/Dockerfile-CentOS-9-Stream ++++ b/test/container/Dockerfile-CentOS-9-Stream +@@ -33,8 +33,10 @@ RUN dnf -y install --enablerepo crb --setopt=install_weak_deps=False \ + make \ + mdadm \ + nfs-utils \ ++ parted \ + pigz \ + rpm-build \ ++ squashfs-tools \ + strace \ + sudo \ + tar \ +diff --git a/test/container/Dockerfile-Debian b/test/container/Dockerfile-Debian +index b4c1704e..15eb9958 100644 +--- a/test/container/Dockerfile-Debian ++++ b/test/container/Dockerfile-Debian +@@ -42,6 +42,7 @@ RUN apt-get update -y -qq && apt-get upgrade -y -qq && DEBIAN_FRONTEND=nonintera + network-manager \ + nfs-common \ + open-iscsi \ ++ parted \ + pigz \ + pkg-config \ + procps \ +diff --git a/test/container/Dockerfile-Fedora-latest b/test/container/Dockerfile-Fedora-latest +index 87c749f9..a38a72ef 100644 +--- a/test/container/Dockerfile-Fedora-latest ++++ b/test/container/Dockerfile-Fedora-latest +@@ -49,6 +49,7 @@ RUN dnf -y install --setopt=install_weak_deps=False \ + which \ + ShellCheck \ + shfmt \ ++ parted \ + && dnf -y update && dnf clean all + + # Set default command +diff --git a/test/container/Dockerfile-OpenSuse-latest b/test/container/Dockerfile-OpenSuse-latest +index 637d50c6..9aaf07b1 100644 +--- a/test/container/Dockerfile-OpenSuse-latest ++++ b/test/container/Dockerfile-OpenSuse-latest +@@ -13,7 +13,7 @@ RUN dnf -y install --setopt=install_weak_deps=False \ + strace libkmod-devel gcc bzip2 xz tar wget rpm-build make git bash-completion \ + sudo kernel dhcp-client qemu-kvm /usr/bin/qemu-system-$(uname -m) e2fsprogs \ + tcpdump iproute iputils kbd NetworkManager btrfsprogs tgt dbus-broker \ +- iscsiuio open-iscsi which ShellCheck procps pigz \ ++ iscsiuio open-iscsi which ShellCheck procps pigz parted squashfs \ + && dnf -y update && dnf clean all + + RUN shfmt_version=3.2.4; wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O /usr/local/bin/shfmt \ diff --git a/SOURCES/0020.patch b/SOURCES/0020.patch new file mode 100644 index 0000000..2043a54 --- /dev/null +++ b/SOURCES/0020.patch @@ -0,0 +1,39 @@ +From 3e912f878de8d310bd06199e03602c63d2b60dba Mon Sep 17 00:00:00 2001 +From: Radek Vykydal +Date: Tue, 20 Dec 2022 16:40:23 +0100 +Subject: [PATCH] fix(network-manager): allow running nm-run.sh multiple times + +This partially reverts +https://github.com/redhat-plumbers/dracut-rhel9/commit/77630365aed201a729c73a9ffda0733a75f3fee4 + +Anaconda needs to be able to run nm-run.sh to trigger online hooks again +after kickstart is fetched from storage and network is configured +accordingly. + +rhel-only +Resolves: rhbz#2157082 +--- + modules.d/35network-manager/nm-run.sh | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/modules.d/35network-manager/nm-run.sh b/modules.d/35network-manager/nm-run.sh +index 7d8d61fa..6110733d 100755 +--- a/modules.d/35network-manager/nm-run.sh ++++ b/modules.d/35network-manager/nm-run.sh +@@ -2,11 +2,12 @@ + + type source_hook > /dev/null 2>&1 || . /lib/dracut-lib.sh + +-if [ -e /tmp/nm.done ]; then +- return +-fi +- + if [ -z "$DRACUT_SYSTEMD" ]; then ++ ++ if [ -e /tmp/nm.done ]; then ++ return ++ fi ++ + # Only start NM if networking is needed + if [ -e /run/NetworkManager/initrd/neednet ]; then + for i in /usr/lib/NetworkManager/system-connections/* \ diff --git a/SPECS/dracut.spec b/SPECS/dracut.spec index 404e8c6..34fff9f 100644 --- a/SPECS/dracut.spec +++ b/SPECS/dracut.spec @@ -5,7 +5,7 @@ # strip the automatically generated dep here and instead co-own the # directory. %global __requires_exclude pkg-config -%define dist_free_release 13.git20220816 +%define dist_free_release 21.git20230214 Name: dracut Version: 057 @@ -41,6 +41,14 @@ Patch9: 0009.patch Patch10: 0010.patch Patch11: 0011.patch Patch12: 0012.patch +Patch13: 0013.patch +Patch14: 0014.patch +Patch15: 0015.patch +Patch16: 0016.patch +Patch17: 0017.patch +Patch18: 0018.patch +Patch19: 0019.patch +Patch20: 0020.patch Source1: https://www.gnu.org/licenses/lgpl-2.1.txt @@ -151,7 +159,7 @@ Requires: %{name} >= %{version}-%{dist_free_release} Requires: %{name} = %{version}-%{release} %endif Requires: %{name}-network = %{version}-%{release} -Requires: tar gzip coreutils bash device-mapper curl +Requires: tar gzip coreutils bash device-mapper curl parted %if 0%{?fedora} Requires: fuse ntfs-3g %endif @@ -474,6 +482,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/ %files live %{dracutlibdir}/modules.d/99img-lib %{dracutlibdir}/modules.d/90dmsquash-live +%{dracutlibdir}/modules.d/90dmsquash-live-autooverlay %{dracutlibdir}/modules.d/90dmsquash-live-ntfs %{dracutlibdir}/modules.d/90livenet @@ -498,6 +507,17 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/ %{_prefix}/lib/kernel/install.d/51-dracut-rescue.install %changelog +* Tue Feb 14 2023 Pavel Valena - 057-21.git20230214 +- fix(network-manager): allow running nm-run.sh multiple times + +* Tue Dec 13 2022 Pavel Valena - 057-20.git20221213 +- refactor(url-lib): write curl output directly to file +- fix(dracut-initramfs-restore.sh): initramfs detection not +- fix(90kernel-modules): install blk modules using symbol +- fix(squash): build ld cache for squash loader +- test(16-DMSQUASH): make it pass on arch +- feat(dmsquash-live): add new dmsquash-live-autooverlay module + * Tue Aug 16 2022 Pavel Valena - 057-13.git20220816 - fix(kernel-modules): always include nvmem driver on - fix(drm): add video drivers needed on hyper-v and similar