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