Blob Blame History Raw
commit 389e5026df575ad98695191044257cf2b33d565b
Author: pcahyna <pcahyna@users.noreply.github.com>
Date:   Mon Jul 4 15:48:43 2022 +0200

    Merge pull request #2825 from lzaoral/replace-mkinitrd-with-dracut
    
    Replace `mkinitrd` with `dracut` on Fedora and RHEL

diff --git a/usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh b/usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh
index 3476b77f..f296e624 100644
--- a/usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh
+++ b/usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh
@@ -61,7 +61,7 @@ NEW_INITRD_MODULES=( $(tr " " "\n" <<< "${NEW_INITRD_MODULES[*]}" | sort | uniq
 Log "New INITRD_MODULES='${OLD_INITRD_MODULES[@]} ${NEW_INITRD_MODULES[@]}'"
 INITRD_MODULES="${OLD_INITRD_MODULES[@]} ${NEW_INITRD_MODULES[@]}"
 
-WITH_INITRD_MODULES=$( printf '%s\n' ${INITRD_MODULES[@]} | awk '{printf "--with=%s ", $1}' )
+WITH_INITRD_MODULES=$( printf '%s\n' ${INITRD_MODULES[@]} | awk '{printf "--add-drivers=%s ", $1}' )
 
 # Recreate any initrd or initramfs image under $TARGET_FS_ROOT/boot/ with new drivers
 # Images ignored:
@@ -76,19 +76,19 @@ for INITRD_IMG in $( ls $TARGET_FS_ROOT/boot/initramfs-*.img $TARGET_FS_ROOT/boo
     # Do not use KERNEL_VERSION here because that is readonly in the rear main script:
     kernel_version=$( basename $( echo $INITRD_IMG ) | cut -f2- -d"-" | sed s/"\.img"// )
     INITRD=$( echo $INITRD_IMG | egrep -o "/boot/.*" )
-    LogPrint "Running mkinitrd..."
-    # Run mkinitrd directly in chroot without a login shell in between (see https://github.com/rear/rear/issues/862).
-    # We need the mkinitrd binary in the chroot environment i.e. the mkinitrd binary in the recreated system.
-    # Normally we would use a login shell like: chroot $TARGET_FS_ROOT /bin/bash --login -c 'type -P mkinitrd'
+    LogPrint "Running dracut..."
+    # Run dracut directly in chroot without a login shell in between (see https://github.com/rear/rear/issues/862).
+    # We need the dracut binary in the chroot environment i.e. the dracut binary in the recreated system.
+    # Normally we would use a login shell like: chroot $TARGET_FS_ROOT /bin/bash --login -c 'type -P dracut'
     # because otherwise there is no useful PATH (PATH is only /bin) so that 'type -P' won't find it
     # but we cannot use a login shell because that contradicts https://github.com/rear/rear/issues/862
     # so that we use a plain (non-login) shell and set a (hopefully) reasonable PATH:
-    local mkinitrd_binary=$( chroot $TARGET_FS_ROOT /bin/bash -c 'PATH=/sbin:/usr/sbin:/usr/bin:/bin type -P mkinitrd' )
-    # If there is no mkinitrd in the chroot environment plain 'chroot $TARGET_FS_ROOT' will hang up endlessly
+    local dracut_binary=$( chroot $TARGET_FS_ROOT /bin/bash -c 'PATH=/sbin:/usr/sbin:/usr/bin:/bin type -P dracut' )
+    # If there is no dracut in the chroot environment plain 'chroot $TARGET_FS_ROOT' will hang up endlessly
     # and then "rear recover" cannot be aborted with the usual [Ctrl]+[C] keys.
     # Use plain $var because when var contains only blanks test "$var" results true because test " " results true:
-    if test $mkinitrd_binary ; then
-        if chroot $TARGET_FS_ROOT $mkinitrd_binary -v -f ${WITH_INITRD_MODULES[@]} $INITRD $kernel_version >&2 ; then
+    if test $dracut_binary ; then
+        if chroot $TARGET_FS_ROOT $dracut_binary -v -f ${WITH_INITRD_MODULES[@]} $INITRD $kernel_version >&2 ; then
             LogPrint "Updated initrd with new drivers for kernel $kernel_version."
         else
             LogPrint "WARNING:
@@ -99,7 +99,7 @@ and decide yourself, whether the system will boot or not.
         fi
     else
         LogPrint "WARNING:
-Cannot create initrd (found no mkinitrd in the recreated system).
+Cannot create initrd (found no dracut in the recreated system).
 Check the recreated system (mounted at $TARGET_FS_ROOT)
 and decide yourself, whether the system will boot or not.
 "