Skip to content

Commit

Permalink
Update 550_rebuild_initramfs.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmeix committed Mar 15, 2022
1 parent c93a4d5 commit 2fbb8ed
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh
Expand Up @@ -47,29 +47,29 @@ if [ -f $VAR_DIR/recovery/initrd_modules ]; then
OLD_INITRD_MODULES=()
fi

Log "Original OLD_INITRD_MODULES are ${OLD_INITRD_MODULES[*]}"
# To see what has been added by the migration process, the new modules are added to the
# end of the list. To achieve this, we list the old modules twice in the variable
# NEW_INITRD_MODULES and then add the new modules. Then we use "uniq -u" to filter out
# the modules which only appear once in the list. The resulting array
# contains the new modules also.
Log "Original OLD_INITRD_MODULES=( ${OLD_INITRD_MODULES[*]} )"
# To see what has been added by the migration process, the new modules are added to the end of the list.
# To achieve this, we list the old modules twice in the variable NEW_INITRD_MODULES and then add the new modules.
# Then we use "uniq -u" to filter out the modules which only appear once in the list.
# The resulting array contains only the new modules:
NEW_INITRD_MODULES=( ${OLD_INITRD_MODULES[@]} ${OLD_INITRD_MODULES[@]} $( cat $TMP_DIR/storage_drivers ) )
NEW_INITRD_MODULES=( $( tr " " "\n" <<< "${NEW_INITRD_MODULES[*]}" | sort | uniq -u ) )

# uniq INITRD_MODULES
NEW_INITRD_MODULES=( $(tr " " "\n" <<< "${NEW_INITRD_MODULES[*]}" | sort | uniq -u) )
# Concatenate the old and new modules into a string:
INITRD_MODULES="${OLD_INITRD_MODULES[*]} ${NEW_INITRD_MODULES[*]}"
Log "New INITRD_MODULES='$INITRD_MODULES'"

Log "New INITRD_MODULES are ${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}' )
# Do not quote $INITRD_MODULES otherwise printf could not split words as separated arguments on separated lines:
WITH_INITRD_MODULES=$( printf '%s\n' $INITRD_MODULES | awk '{printf "--with=%s ", $1}' )

# Recreate any initrd or initramfs image under $TARGET_FS_ROOT/boot/ with new drivers
# Images ignored:
# kdump images as they are build by kdump
# initramfs rescue images (>= Rhel 7), which need all modules and
# are created by new-kernel-pkg
# initramfs rescue images (>= Rhel 7), which need all modules and are created by new-kernel-pkg
# initrd-plymouth.img (>= Rhel 7), which contains only files needed for graphical boot via plymouth

# The unalias originates from https://github.com/rear/rear/commit/d029e0dbe98b9fed496d8f3857bef132c8f165ad
# This is the only place in ReaR where unalias is called and it unaliases ls also for all subsequent scripts.
# TODO: Explain why this unalias is needed here and why it is also needed in all subsequent scripts:
unalias ls 2>/dev/null

for INITRD_IMG in $( ls $TARGET_FS_ROOT/boot/initramfs-*.img $TARGET_FS_ROOT/boot/initrd-*.img | egrep -v '(kdump|rescue|plymouth)' ) ; do
Expand All @@ -88,7 +88,7 @@ for INITRD_IMG in $( ls $TARGET_FS_ROOT/boot/initramfs-*.img $TARGET_FS_ROOT/boo
# 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 ; then
if chroot $TARGET_FS_ROOT $mkinitrd_binary -v -f $WITH_INITRD_MODULES $INITRD $kernel_version ; then
LogPrint "Updated initrd with new drivers for kernel $kernel_version."
else
LogPrint "WARNING:
Expand Down

0 comments on commit 2fbb8ed

Please sign in to comment.