17094c
From cbebaacfd05c55fddd11b3090983a2be1d2b48d3 Mon Sep 17 00:00:00 2001
17094c
From: Kairui Song <kasong@redhat.com>
17094c
Date: Wed, 17 Jul 2019 17:10:36 +0800
17094c
Subject: [PATCH] dracut.sh: Adjust squash and strip order
17094c
17094c
Previously with squash module, some binaries will be reinstalled, but
17094c
stripping happens before that so new installed binaries is not stripped.
17094c
So adjust the squash and strip order, ensure new installed binaries are
17094c
stripped just the same way with the old binaries.
17094c
17094c
Also split squash into two stage to make the split easier, move the
17094c
squash temp dir into initdir so stripping will cover that too,
17094c
and print more usefule message.
17094c
17094c
Signed-off-by: Kairui Song <kasong@redhat.com>
17094c
(cherry picked from commit 6a74c03b4a8472fb090015b32e652edfeadb5a10)
17094c
17094c
Resolves: #1776659
17094c
---
17094c
 dracut.sh | 43 +++++++++++++++++++++++++------------------
17094c
 1 file changed, 25 insertions(+), 18 deletions(-)
17094c
17094c
diff --git a/dracut.sh b/dracut.sh
17094c
index 223261d6..310646e3 100755
17094c
--- a/dracut.sh
17094c
+++ b/dracut.sh
17094c
@@ -1659,21 +1659,6 @@ for d in $(ldconfig_paths); do
17094c
     rmdir -p --ignore-fail-on-non-empty "$initdir/$d" >/dev/null 2>&1
17094c
 done
17094c
 
17094c
-if [[ $do_strip = yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then
17094c
-    dinfo "*** Stripping files ***"
17094c
-    find "$initdir" -type f \
17094c
-        -executable -not -path '*/lib/modules/*.ko' -print0 \
17094c
-        | xargs -r -0 $strip_cmd -g -p 2>/dev/null
17094c
-
17094c
-    # strip kernel modules, but do not touch signed modules
17094c
-    find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
17094c
-        | while read -r -d $'\0' f || [ -n "$f" ]; do
17094c
-        SIG=$(tail -c 28 "$f" | tr -d '\000')
17094c
-        [[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; }
17094c
-    done | xargs -r -0 $strip_cmd -g -p
17094c
-
17094c
-    dinfo "*** Stripping files done ***"
17094c
-fi
17094c
 if [[ $early_microcode = yes ]]; then
17094c
     dinfo "*** Generating early-microcode cpio image ***"
17094c
     ucode_dir=(amd-ucode intel-ucode)
17094c
@@ -1745,9 +1730,8 @@ if [[ $hostonly_cmdline == "yes" ]] ; then
17094c
     fi
17094c
 fi
17094c
 
17094c
-dinfo "*** Creating image file '$outfile' ***"
17094c
-
17094c
 if dracut_module_included "squash"; then
17094c
+    dinfo "*** Install squash loader ***"
17094c
     if ! check_kernel_config CONFIG_SQUASHFS; then
17094c
         dfatal "CONFIG_SQUASHFS have to be enabled for dracut squash module to work"
17094c
         exit 1
17094c
@@ -1761,7 +1745,7 @@ if dracut_module_included "squash"; then
17094c
         exit 1
17094c
     fi
17094c
 
17094c
-    readonly squash_dir="${DRACUT_TMPDIR}/squashfs"
17094c
+    readonly squash_dir="$initdir/squash/root"
17094c
     readonly squash_img=$initdir/squash/root.img
17094c
 
17094c
     # Currently only move "usr" "etc" to squashdir
17094c
@@ -1854,15 +1838,38 @@ if dracut_module_included "squash"; then
17094c
             fi
17094c
         done
17094c
     done
17094c
+fi
17094c
 
17094c
+if [[ $do_strip = yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then
17094c
+    dinfo "*** Stripping files ***"
17094c
+    find "$initdir" -type f \
17094c
+        -executable -not -path '*/lib/modules/*.ko' -print0 \
17094c
+        | xargs -r -0 $strip_cmd -g -p 2>/dev/null
17094c
+
17094c
+    # strip kernel modules, but do not touch signed modules
17094c
+    find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
17094c
+        | while read -r -d $'\0' f || [ -n "$f" ]; do
17094c
+        SIG=$(tail -c 28 "$f" | tr -d '\000')
17094c
+        [[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; }
17094c
+    done | xargs -r -0 $strip_cmd -g -p
17094c
+    dinfo "*** Stripping files done ***"
17094c
+fi
17094c
+
17094c
+if dracut_module_included "squash"; then
17094c
+    dinfo "*** Squashing the files inside the initramfs ***"
17094c
     mksquashfs $squash_dir $squash_img -comp xz -b 64K -Xdict-size 100% &> /dev/null
17094c
 
17094c
     if [[ $? != 0 ]]; then
17094c
         dfatal "dracut: Failed making squash image"
17094c
         exit 1
17094c
     fi
17094c
+
17094c
+    rm -rf $squash_dir
17094c
+    dinfo "*** Squashing the files inside the initramfs done ***"
17094c
 fi
17094c
 
17094c
+dinfo "*** Creating image file '$outfile' ***"
17094c
+
17094c
 if [[ $uefi = yes ]]; then
17094c
     readonly uefi_outdir="$DRACUT_TMPDIR/uefi"
17094c
     mkdir "$uefi_outdir"
17094c