From 8b7be5699ee98fe9c96de9408b387af0e95c0450 Mon Sep 17 00:00:00 2001 From: panxiaohe Date: Wed, 26 May 2021 10:36:54 +0800 Subject: [PATCH] backport patches from upstream --- backport-fix-always-use-mkdir-p.patch | 359 ++++++++++++++++++ ...ission-is-an-addition-to-other-omiss.patch | 40 ++ dracut.spec | 11 +- 3 files changed, 408 insertions(+), 2 deletions(-) create mode 100644 backport-fix-always-use-mkdir-p.patch create mode 100644 backport-fix-dracut.sh-omission-is-an-addition-to-other-omiss.patch diff --git a/backport-fix-always-use-mkdir-p.patch b/backport-fix-always-use-mkdir-p.patch new file mode 100644 index 0000000..684f0d4 --- /dev/null +++ b/backport-fix-always-use-mkdir-p.patch @@ -0,0 +1,359 @@ +From 9cf7b1c529442d5abd6eaec4399d4ee77b95145e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=B3hann=20B=2E=20Gu=C3=B0mundsson?= +Date: Fri, 26 Feb 2021 13:44:05 +0000 +Subject: [PATCH] fix: always use mkdir -p + +Ensuring that directory creations dont trigger error if directory +previously existed as well as create parent directories if needed. + +Reference:https://github.com/dracutdevs/dracut/commit/9cf7b1c529442d5abd6eaec4399d4ee77b95145e +Conflict:context adaptation +--- + dracut.sh | 4 +- + modules.d/01fips/fips.sh | 2 +- + modules.d/80cms/cmssetup.sh | 2 +- + modules.d/90crypt/crypt-lib.sh | 2 +- + modules.d/90dmsquash-live/dmsquash-generator.sh | 2 +- + modules.d/90dmsquash-live/dmsquash-live-root.sh | 12 +- + modules.d/90livenet/livenet-generator.sh | 2 +- + modules.d/90mdraid/mdmon-pre-udev.sh | 2 +- + modules.d/95nbd/nbd-generator.sh | 2 +- + modules.d/95nfs/module-setup.sh | 2 +- + modules.d/99base/init.sh | 10 +- + modules.d/99shutdown/shutdown.sh | 4 +- + test/TEST-03-USR-MOUNT/create-root.sh | 2 +- + test/TEST-04-FULL-SYSTEMD/create-root.sh | 2 +- + test/TEST-11-LVM/test.sh | 2 +- + test/TEST-12-RAID-DEG/create-root.sh | 2 +- + test/TEST-14-IMSM/test.sh | 2 +- + test/TEST-17-LVM-THIN/test.sh | 2 +- + test/TEST-20-NFS/test.sh | 2 +- + 19 files changed, 30 insertions(+), 30 deletions(-) + +diff --git a/dracut.sh b/dracut.sh +index 25b0192..4c1c077 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -977,7 +977,7 @@ trap ' + trap 'exit 1;' SIGINT + + readonly initdir="${DRACUT_TMPDIR}/initramfs" +-mkdir "$initdir" ++mkdir -p "$initdir" + + if [[ $early_microcode = yes ]] || ( [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]] ); then + readonly early_cpio_dir="${DRACUT_TMPDIR}/earlycpio" +@@ -1967,7 +1967,7 @@ dinfo "*** Creating image file '$outfile' ***" + + if [[ $uefi = yes ]]; then + readonly uefi_outdir="$DRACUT_TMPDIR/uefi" +- mkdir "$uefi_outdir" ++ mkdir -p "$uefi_outdir" + fi + + if [[ $DRACUT_REPRODUCIBLE ]]; then +diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh +index 8fba135..b9b8d42 100755 +--- a/modules.d/01fips/fips.sh ++++ b/modules.d/01fips/fips.sh +@@ -44,7 +44,7 @@ mount_boot() + + [ -e "$boot" ] || return 1 + +- mkdir /boot ++ mkdir -p /boot + info "Mounting $boot as /boot" + mount -oro "$boot" /boot || return 1 + elif [ -d "$NEWROOT/boot" ]; then +diff --git a/modules.d/80cms/cmssetup.sh b/modules.d/80cms/cmssetup.sh +index 1cfce55..bbf49bf 100755 +--- a/modules.d/80cms/cmssetup.sh ++++ b/modules.d/80cms/cmssetup.sh +@@ -111,7 +111,7 @@ function readcmsfile() # $1=dasdport $2=filename + devname=$(cd /sys/bus/ccw/devices/$dev/block; set -- *; [ -b /dev/$1 ] && echo $1) + devname=${devname:-dasda} + +- [[ -d /mnt ]] || mkdir /mnt ++ [[ -d /mnt ]] || mkdir -p /mnt + if cmsfs-fuse --to=UTF-8 -a /dev/$devname /mnt; then + cat /mnt/$2 > /run/initramfs/$2 + umount /mnt || umount -l /mnt +diff --git a/modules.d/90crypt/crypt-lib.sh b/modules.d/90crypt/crypt-lib.sh +index 688ea25..12ee4af 100755 +--- a/modules.d/90crypt/crypt-lib.sh ++++ b/modules.d/90crypt/crypt-lib.sh +@@ -200,7 +200,7 @@ readkey() { + local mntp="/mnt/$(str_replace "keydev-$keydev-$keypath" '/' '-')" + + if [ ! -d "$mntp" ]; then +- mkdir "$mntp" ++ mkdir -p "$mntp" + mount -r "$keydev" "$mntp" || die 'Mounting rem. dev. failed!' + fi + fi +diff --git a/modules.d/90dmsquash-live/dmsquash-generator.sh b/modules.d/90dmsquash-live/dmsquash-generator.sh +index f57b1fc..cce29b9 100755 +--- a/modules.d/90dmsquash-live/dmsquash-generator.sh ++++ b/modules.d/90dmsquash-live/dmsquash-generator.sh +@@ -52,7 +52,7 @@ esac + + GENERATOR_DIR="$2" + [ -z "$GENERATOR_DIR" ] && exit 1 +-[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR" ++[ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR" + + getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay="" + getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes" +diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh +index 6324fe8..2b474b6 100755 +--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh ++++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh +@@ -121,7 +121,7 @@ do_live_overlay() { + + # need to know where to look for the overlay + if [ -z "$setup" -a -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then +- mkdir -m 0755 /run/initramfs/overlayfs ++ mkdir -m 0755 -p /run/initramfs/overlayfs + opt='' + [ -n "$readonly_overlay" ] && opt=-r + mount -n -t auto $devspec /run/initramfs/overlayfs || : +@@ -206,8 +206,8 @@ do_live_overlay() { + fi + fi + if [ -n "$overlayfs" ]; then +- mkdir -m 0755 /run/overlayfs +- mkdir -m 0755 /run/ovlwork ++ mkdir -m 0755 -p /run/overlayfs ++ mkdir -m 0755 -p /run/ovlwork + if [ -n "$readonly_overlay" ] && ! [ -h /run/overlayfs-r ]; then + info "No persistent overlay found." + unset -v readonly_overlay +@@ -237,7 +237,7 @@ do_live_overlay() { + + if [ -n "$thin_snapshot" ]; then + modprobe dm_thin_pool +- mkdir -m 0755 /run/initramfs/thin-overlay ++ mkdir -m 0755 -p /run/initramfs/thin-overlay + + # In block units (512b) + thin_data_sz=$(( $overlay_size * 1024 * 1024 / 512 )) +@@ -336,7 +336,7 @@ if [ -n "$FSIMG" ]; then + if [ -n "$writable_fsimg" ]; then + # mount the provided filesystem read/write + echo "Unpacking live filesystem (may take some time)" > /dev/kmsg +- mkdir -m 0755 /run/initramfs/fsimg/ ++ mkdir -m 0755 -p /run/initramfs/fsimg/ + if [ -n "$SQUASHED" ]; then + cp -v $FSIMG /run/initramfs/fsimg/rootfs.img + else +@@ -384,7 +384,7 @@ fi + ROOTFLAGS="$(getarg rootflags)" + + if [ -n "$overlayfs" ]; then +- mkdir -m 0755 /run/rootfsbase ++ mkdir -m 0755 -p /run/rootfsbase + if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then + ovlfs=$(readlink /run/overlayfs) + info "Resetting the OverlayFS overlay directory." +diff --git a/modules.d/90livenet/livenet-generator.sh b/modules.d/90livenet/livenet-generator.sh +index f0d1285..d825159 100755 +--- a/modules.d/90livenet/livenet-generator.sh ++++ b/modules.d/90livenet/livenet-generator.sh +@@ -41,7 +41,7 @@ esac + GENERATOR_DIR="$2" + [ -z "$GENERATOR_DIR" ] && exit 1 + +-[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR" ++[ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR" + + getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay="" + getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes" +diff --git a/modules.d/90mdraid/mdmon-pre-udev.sh b/modules.d/90mdraid/mdmon-pre-udev.sh +index fb9280d..b15cca8 100755 +--- a/modules.d/90mdraid/mdmon-pre-udev.sh ++++ b/modules.d/90mdraid/mdmon-pre-udev.sh +@@ -1,4 +1,4 @@ + #!/bin/sh + # save state dir for mdmon/mdadm for the real root +-[ -d /run/mdadm ] || mkdir -m 0755 /run/mdadm ++[ -d /run/mdadm ] || mkdir -m 0755 -p /run/mdadm + # backward compat link +diff --git a/modules.d/95nbd/nbd-generator.sh b/modules.d/95nbd/nbd-generator.sh +index de52d11..dccdacf 100755 +--- a/modules.d/95nbd/nbd-generator.sh ++++ b/modules.d/95nbd/nbd-generator.sh +@@ -9,7 +9,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh + GENERATOR_DIR="$2" + [ -z "$GENERATOR_DIR" ] && exit 1 + +-[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR" ++[ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR" + + ROOTFLAGS="$(getarg rootflags)" + +diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh +index f9bcedd..1a2be42 100755 +--- a/modules.d/95nfs/module-setup.sh ++++ b/modules.d/95nfs/module-setup.sh +@@ -89,7 +89,7 @@ install() { + if [ -f $dracutsysrootdir/lib/modprobe.d/nfs.conf ]; then + inst_multiple /lib/modprobe.d/nfs.conf + else +- [ -d $initdir/etc/modprobe.d/ ] || mkdir $initdir/etc/modprobe.d ++ [ -d $initdir/etc/modprobe.d/ ] || mkdir -p $initdir/etc/modprobe.d + echo "alias nfs4 nfs" > $initdir/etc/modprobe.d/nfs.conf + fi + +diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh +index 1111d09..106549b 100755 +--- a/modules.d/99base/init.sh ++++ b/modules.d/99base/init.sh +@@ -53,17 +53,17 @@ fi + [ ! -h /dev/stderr ] && ln -s /proc/self/fd/2 /dev/stderr >/dev/null 2>&1 + + if ! ismounted /dev/pts; then +- mkdir -m 0755 /dev/pts ++ mkdir -m 0755 -p /dev/pts + mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null + fi + + if ! ismounted /dev/shm; then +- mkdir -m 0755 /dev/shm ++ mkdir -m 0755 -p /dev/shm + mount -t tmpfs -o mode=1777,noexec,nosuid,nodev,strictatime tmpfs /dev/shm >/dev/null + fi + + if ! ismounted /run; then +- mkdir -m 0755 /newrun ++ mkdir -m 0755 -p /newrun + if ! str_starts "$(readlink -f /bin/sh)" "/run/"; then + mount -t tmpfs -o mode=0755,noexec,nosuid,nodev,strictatime tmpfs /newrun >/dev/null + else +@@ -99,7 +99,7 @@ if [ $UDEVVERSION -gt 166 ]; then + [ -d /run/udev ] || mkdir -p -m 0755 /run/udev + [ -d $UDEVRULESD ] || mkdir -p -m 0755 $UDEVRULESD + else +- mkdir -m 0755 /dev/.udev /dev/.udev/rules.d ++ mkdir -m 0755 -p /dev/.udev /dev/.udev/rules.d + export UDEVRULESD=/dev/.udev/rules.d + fi + +@@ -369,7 +369,7 @@ debug_on + + if ! [ -d "$NEWROOT"/run ]; then + NEWRUN=/dev/.initramfs +- mkdir -m 0755 "$NEWRUN" ++ mkdir -m 0755 -p "$NEWRUN" + mount --rbind /run/initramfs "$NEWRUN" + fi + +diff --git a/modules.d/99shutdown/shutdown.sh b/modules.d/99shutdown/shutdown.sh +index a30a126..89be9d2 100755 +--- a/modules.d/99shutdown/shutdown.sh ++++ b/modules.d/99shutdown/shutdown.sh +@@ -22,9 +22,9 @@ if [ "$(stat -c '%T' -f /)" = "tmpfs" ]; then + mount -o remount,rw / + fi + +-mkdir /oldsys ++mkdir -p /oldsys + for i in sys proc run dev; do +- mkdir /oldsys/$i ++ mkdir -p /oldsys/$i + mount --move /oldroot/$i /oldsys/$i + done + +diff --git a/test/TEST-03-USR-MOUNT/create-root.sh b/test/TEST-03-USR-MOUNT/create-root.sh +index 238fad0..e7de853 100755 +--- a/test/TEST-03-USR-MOUNT/create-root.sh ++++ b/test/TEST-03-USR-MOUNT/create-root.sh +@@ -26,7 +26,7 @@ btrfs device scan /dev/sda2 + btrfs device scan /dev/sdb2 + mkdir -p /root + mount -t btrfs /dev/sda2 /root +-[ -d /root/usr ] || mkdir /root/usr ++[ -d /root/usr ] || mkdir -p /root/usr + mount -t btrfs /dev/sdb2 /root/usr + btrfs subvolume create /root/usr/usr + umount /root/usr +diff --git a/test/TEST-04-FULL-SYSTEMD/create-root.sh b/test/TEST-04-FULL-SYSTEMD/create-root.sh +index 5de376c..8c29549 100755 +--- a/test/TEST-04-FULL-SYSTEMD/create-root.sh ++++ b/test/TEST-04-FULL-SYSTEMD/create-root.sh +@@ -27,7 +27,7 @@ btrfs device scan /dev/sda2 + btrfs device scan /dev/sdb2 + mkdir -p /root + mount -t btrfs /dev/sda2 /root +-[ -d /root/usr ] || mkdir /root/usr ++[ -d /root/usr ] || mkdir -p /root/usr + mount -t btrfs /dev/sdb2 /root/usr + btrfs subvolume create /root/usr/usr + umount /root/usr +diff --git a/test/TEST-11-LVM/test.sh b/test/TEST-11-LVM/test.sh +index c718ad5..89f1ca2 100755 +--- a/test/TEST-11-LVM/test.sh ++++ b/test/TEST-11-LVM/test.sh +@@ -45,7 +45,7 @@ test_setup() { + inst ./test-init.sh /sbin/init + find_binary plymouth >/dev/null && inst_multiple plymouth + cp -a /etc/ld.so.conf* $initdir/etc +- mkdir $initdir/run ++ mkdir -p $initdir/run + ldconfig -r "$initdir" + ) + +diff --git a/test/TEST-12-RAID-DEG/create-root.sh b/test/TEST-12-RAID-DEG/create-root.sh +index c210b58..4c10fd9 100755 +--- a/test/TEST-12-RAID-DEG/create-root.sh ++++ b/test/TEST-12-RAID-DEG/create-root.sh +@@ -27,7 +27,7 @@ mke2fs -L root /dev/dracut/root + mkdir -p /sysroot + mount /dev/dracut/root /sysroot + cp -a -t /sysroot /source/* +-mkdir /sysroot/run ++mkdir -p /sysroot/run + umount /sysroot + lvm lvchange -a n /dev/dracut/root + udevadm settle +diff --git a/test/TEST-14-IMSM/test.sh b/test/TEST-14-IMSM/test.sh +index 2f153ba..5acae94 100755 +--- a/test/TEST-14-IMSM/test.sh ++++ b/test/TEST-14-IMSM/test.sh +@@ -83,7 +83,7 @@ test_setup() { + inst ./test-init.sh /sbin/init + find_binary plymouth >/dev/null && inst_multiple plymouth + cp -a /etc/ld.so.conf* $initdir/etc +- mkdir $initdir/run ++ mkdir -p $initdir/run + ldconfig -r "$initdir" + ) + +diff --git a/test/TEST-17-LVM-THIN/test.sh b/test/TEST-17-LVM-THIN/test.sh +index e4755f7..018dd8b 100755 +--- a/test/TEST-17-LVM-THIN/test.sh ++++ b/test/TEST-17-LVM-THIN/test.sh +@@ -45,7 +45,7 @@ test_setup() { + inst ./test-init.sh /sbin/init + find_binary plymouth >/dev/null && inst_multiple plymouth + cp -a /etc/ld.so.conf* $initdir/etc +- mkdir $initdir/run ++ mkdir -p $initdir/run + ldconfig -r "$initdir" + ) + +diff --git a/test/TEST-20-NFS/test.sh b/test/TEST-20-NFS/test.sh +index 9d5493c..25b0b29 100755 +--- a/test/TEST-20-NFS/test.sh ++++ b/test/TEST-20-NFS/test.sh +@@ -352,7 +352,7 @@ test_setup() { + ( + export initdir=$TESTDIR/overlay + . $basedir/dracut-init.sh +- mkdir $TESTDIR/overlay ++ mkdir -p $TESTDIR/overlay + inst_multiple poweroff shutdown + inst_hook shutdown-emergency 000 ./hard-off.sh + inst_hook emergency 000 ./hard-off.sh +-- +1.8.3.1 + diff --git a/backport-fix-dracut.sh-omission-is-an-addition-to-other-omiss.patch b/backport-fix-dracut.sh-omission-is-an-addition-to-other-omiss.patch new file mode 100644 index 0000000..6487be8 --- /dev/null +++ b/backport-fix-dracut.sh-omission-is-an-addition-to-other-omiss.patch @@ -0,0 +1,40 @@ +From 96c313333d1a4f5e2c524a3a11c5b3aab24afc20 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=B3hann=20B=2E=20Gu=C3=B0mundsson?= +Date: Wed, 31 Mar 2021 19:17:43 +0000 +Subject: [PATCH] fix(dracut.sh): omission is an addition to other omissions in + conf files + +When omitting a module from the command line via -o or --omit +it's expected that it behaves in the same manner as adding a module from the +command line as in it does not overwrite existing omissions of other modules in +configuration file(s). + +Reference:https://github.com/dracutdevs/dracut/commit/96c313333d1a4f5e2c524a3a11c5b3aab24afc20 +Conflict:context adaptation +--- + dracut.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dracut.sh b/dracut.sh +index 4c1c077..83f2481 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -732,6 +732,7 @@ unset NPATH + + # these options add to the stuff in the config file + (( ${#add_dracutmodules_l[@]} )) && add_dracutmodules+=" ${add_dracutmodules_l[@]} " ++(( ${#omit_dracutmodules_l[@]} )) && omit_dracutmodules+=" ${omit_dracutmodules_l[@]} " + (( ${#force_add_dracutmodules_l[@]} )) && force_add_dracutmodules+=" ${force_add_dracutmodules_l[@]} " + (( ${#fscks_l[@]} )) && fscks+=" ${fscks_l[@]} " + (( ${#add_fstab_l[@]} )) && add_fstab+=" ${add_fstab_l[@]} " +@@ -741,7 +742,6 @@ unset NPATH + + # these options override the stuff in the config file + (( ${#dracutmodules_l[@]} )) && dracutmodules="${dracutmodules_l[@]}" +-(( ${#omit_dracutmodules_l[@]} )) && omit_dracutmodules="${omit_dracutmodules_l[@]}" + (( ${#filesystems_l[@]} )) && filesystems="${filesystems_l[@]}" + (( ${#fw_dir_l[@]} )) && fw_dir="${fw_dir_l[@]}" + (( ${#libdirs_l[@]} ))&& libdirs="${libdirs_l[@]}" +-- +1.8.3.1 + diff --git a/dracut.spec b/dracut.spec index d8cf65b..abc52d1 100644 --- a/dracut.spec +++ b/dracut.spec @@ -9,7 +9,7 @@ Name: dracut Version: 050 -Release: 4 +Release: 5 Summary: Initramfs generator using udev @@ -37,7 +37,9 @@ Patch0009: dracut-dasd-only-install-etc-dasd.conf-if-present.patch Patch0010: dracut-lib.sh-quote-variables-in-parameter-expansion.patch Patch0011: dracut-90crypt-module-setup.sh-fix-force-on-multiple-lines.patch Patch0012: Fix-test-in-lsinitrd.patch -Patch9000: add-option-to-include-file-metadata-in-initramfs.patch +Patch0013: add-option-to-include-file-metadata-in-initramfs.patch +Patch0014: backport-fix-always-use-mkdir-p.patch +Patch0015: backport-fix-dracut.sh-omission-is-an-addition-to-other-omiss.patch Source1: https://www.gnu.org/licenses/lgpl-2.1.txt Source2: openEuler.conf.example @@ -488,6 +490,11 @@ install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kerne %endif %changelog +* Wed May 26 2021 panxiaohe - 050-5 +- [add] backport patches from upstream + backport-fix-always-use-mkdir-p.patch + backport-fix-dracut.sh-omission-is-an-addition-to-other-omiss.patch + * Tue Dec 22 2020 Anakin Zhang - 050-4 - add -e option to include file metadata in initramfs -- Gitee