e83cdd
From b6d52b504fc7eefc3f405f75463d9e818471ee99 Mon Sep 17 00:00:00 2001
e83cdd
From: Kairui Song <kasong@redhat.com>
e83cdd
Date: Mon, 11 Mar 2019 19:46:19 +0800
e83cdd
Subject: [PATCH] squash: fix and simplify required_in_root
e83cdd
e83cdd
If required target is a symbol link, create the link then following the
e83cdd
link. If it's a directory, create new directory, else just move it.
e83cdd
e83cdd
Signed-off-by: Kairui Song <kasong@redhat.com>
e83cdd
(cherry picked from commit 11ce69e4bd9172cf54251ea62bb4a5ead1700fd6)
e83cdd
e83cdd
Resolves: #1691705
e83cdd
---
e83cdd
 dracut.sh | 42 +++++++++++++++++++-----------------------
e83cdd
 1 file changed, 19 insertions(+), 23 deletions(-)
e83cdd
e83cdd
diff --git a/dracut.sh b/dracut.sh
e83cdd
index a0158f22..6de88b3e 100755
e83cdd
--- a/dracut.sh
e83cdd
+++ b/dracut.sh
e83cdd
@@ -1811,30 +1811,26 @@ if dracut_module_included "squash"; then
e83cdd
             required_in_root $(dirname $file)
e83cdd
         fi
e83cdd
 
e83cdd
-        if [[ -d $_sqsh_file ]]; then
e83cdd
-            if [[ -L $_sqsh_file ]]; then
e83cdd
-                cp --preserve=all -P $_sqsh_file $_init_file
e83cdd
-            else
e83cdd
-                mkdir $_init_file
e83cdd
-            fi
e83cdd
+        if [[ -L $_sqsh_file ]]; then
e83cdd
+          cp --preserve=all -P $_sqsh_file $_init_file
e83cdd
+          _sqsh_file=$(realpath $_sqsh_file 2>/dev/null)
e83cdd
+          if [[ -e $_sqsh_file ]] && [[ "$_sqsh_file" == "$squash_dir"* ]]; then
e83cdd
+            # Relative symlink
e83cdd
+            required_in_root ${_sqsh_file#$squash_dir/}
e83cdd
+            return
e83cdd
+          fi
e83cdd
+          if [[ -e $squash_dir$_sqsh_file ]]; then
e83cdd
+            # Absolute symlink
e83cdd
+            required_in_root ${_sqsh_file#/}
e83cdd
+            return
e83cdd
+          fi
e83cdd
+          required_in_root ${module_spec#$squash_dir/}
e83cdd
         else
e83cdd
-            if [[ -L $_sqsh_file ]]; then
e83cdd
-                cp --preserve=all -P $_sqsh_file $_init_file
e83cdd
-                _sqsh_file=$(realpath $_sqsh_file 2>/dev/null)
e83cdd
-                if [[ -e $_sqsh_file ]] && [[ "$_sqsh_file" == "$squash_dir"* ]]; then
e83cdd
-                    # Relative symlink
e83cdd
-                    required_in_root ${_sqsh_file#$squash_dir/}
e83cdd
-                    return
e83cdd
-                fi
e83cdd
-                if [[ -e $squash_dir$_sqsh_file ]]; then
e83cdd
-                    # Absolute symlink
e83cdd
-                    required_in_root ${_sqsh_file#/}
e83cdd
-                    return
e83cdd
-                fi
e83cdd
-                required_in_root ${module_spec#$squash_dir/}
e83cdd
-            else
e83cdd
-                mv $_sqsh_file $_init_file
e83cdd
-            fi
e83cdd
+          if [[ -d $_sqsh_file ]]; then
e83cdd
+            mkdir $_init_file
e83cdd
+          else
e83cdd
+            mv $_sqsh_file $_init_file
e83cdd
+          fi
e83cdd
         fi
e83cdd
     }
e83cdd
 
e83cdd