c2f1e0
From 456c3badc622cb8c4b6ec59bc37436f3d50f7ed5 Mon Sep 17 00:00:00 2001
c2f1e0
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Nykr=C3=BDn?= <lnykryn@redhat.com>
c2f1e0
Date: Fri, 9 Jul 2021 12:32:00 +0200
c2f1e0
Subject: [PATCH] Merge pull request #7 from lnykryn/bz1977347
c2f1e0
c2f1e0
Bz1977347
c2f1e0
---
c2f1e0
 dracut.sh                          | 7 +++++--
c2f1e0
 modules.d/99squash/module-setup.sh | 8 ++++----
c2f1e0
 2 files changed, 9 insertions(+), 6 deletions(-)
c2f1e0
c2f1e0
diff --git a/dracut.sh b/dracut.sh
c2f1e0
index 60ac46f4..78917763 100755
c2f1e0
--- a/dracut.sh
c2f1e0
+++ b/dracut.sh
c2f1e0
@@ -2067,9 +2067,11 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do
c2f1e0
             # check for preexisting symlinks, so we can cope with the
c2f1e0
             # symlinks to $prefix
c2f1e0
             # Objectname is a file or a directory
c2f1e0
+            reset_dotglob="$(shopt -p dotglob)"
c2f1e0
+            shopt -q -s dotglob
c2f1e0
             for objectname in "$src"/*; do
c2f1e0
                 [[ -e $objectname || -L $objectname ]] || continue
c2f1e0
-                if [[ -d $objectname ]]; then
c2f1e0
+                if [[ -d $objectname ]] && [[ ! -L $objectname ]]; then
c2f1e0
                     # objectname is a directory, let's compute the final directory name
c2f1e0
                     object_destdir=${destdir}/${objectname#$src/}
c2f1e0
                     if ! [[ -e $object_destdir ]]; then
c2f1e0
@@ -2077,11 +2079,12 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do
c2f1e0
                         mkdir -m 0755 -p "$object_destdir"
c2f1e0
                         chmod --reference="$objectname" "$object_destdir"
c2f1e0
                     fi
c2f1e0
-                    $DRACUT_CP -t "$object_destdir" "$dracutsysrootdir$objectname"/*
c2f1e0
+                    $DRACUT_CP -t "$object_destdir" "$dracutsysrootdir$objectname"/.
c2f1e0
                 else
c2f1e0
                     $DRACUT_CP -t "$destdir" "$dracutsysrootdir$objectname"
c2f1e0
                 fi
c2f1e0
             done
c2f1e0
+            eval "$reset_dotglob"
c2f1e0
         elif [[ -e $src ]]; then
c2f1e0
             derror "$src is neither a directory nor a regular file"
c2f1e0
         else
c2f1e0
diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh
c2f1e0
index e3196213..a2525cff 100644
c2f1e0
--- a/modules.d/99squash/module-setup.sh
c2f1e0
+++ b/modules.d/99squash/module-setup.sh
c2f1e0
@@ -42,19 +42,19 @@ installpost() {
c2f1e0
     # Install required modules and binaries for the squash image init script.
c2f1e0
     if [[ $_busybox ]]; then
c2f1e0
         inst "$_busybox" /usr/bin/busybox
c2f1e0
-        for _i in sh echo mount modprobe mkdir switch_root grep; do
c2f1e0
+        for _i in sh echo mount modprobe mkdir switch_root grep umount; do
c2f1e0
             ln_r /usr/bin/busybox /usr/bin/$_i
c2f1e0
         done
c2f1e0
     else
c2f1e0
-        DRACUT_RESOLVE_DEPS=1 inst_multiple sh mount modprobe mkdir switch_root grep
c2f1e0
+        DRACUT_RESOLVE_DEPS=1 inst_multiple sh mount modprobe mkdir switch_root grep umount
c2f1e0
     fi
c2f1e0
 
c2f1e0
     hostonly="" instmods "loop" "squashfs" "overlay"
c2f1e0
     dracut_kernel_post
c2f1e0
 
c2f1e0
     # Install squash image init script.
c2f1e0
-    ln -sfn /usr/bin "$initdir/bin"
c2f1e0
-    ln -sfn /usr/sbin "$initdir/sbin"
c2f1e0
+    ln_r /usr/bin /bin
c2f1e0
+    ln_r /usr/sbin /sbin
c2f1e0
     inst_simple "$moddir"/init-squash.sh /init
c2f1e0
 }
c2f1e0
 
c2f1e0