]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut: Ajusting variables name for --include 35/head
authorErwan Velu <erwan.velu@enovance.com>
Fri, 19 Dec 2014 13:49:00 +0000 (14:49 +0100)
committerErwan Velu <erwan.velu@enovance.com>
Fri, 19 Dec 2014 13:49:00 +0000 (14:49 +0100)
When reading the --include part of the script, we had the following
issues to make the code easy to read:
- src & tgt were extract for the original options
- i variable was a file or a directory from src
- s variable was the directory name in case $i was a directory

"s" sounds very close to "src" while "s" is on the "tgt" side. Very
confusing.

"s" was defined before the "if it's a directory" statement while it's
only used inside the "if".

"i" was commit from the "src" but wasn't really explicit.

Having some lines mixing "i" and "s" takes a little time to get read
properly.

This patch offer the following changes:
- "i" is renamed to "objectname" as we don't know if its a file or a
  directory

- "s" is renamed to "object_destdir" as the object name becomes a
  directory on the destdir

- "object_destdir" (former "s") is moved inside the "if" statement as it's
  only used here

- tgt is finally renamed to "target" to be more explicit. We are not all
  native english ;o)

My 2 (semantic) cents,

dracut.sh

index 07e49658fbe1feeec147d51015b6dfc4e06c0706..0fb1dad1f6be2d65e1ad3b4d3dbf3ed4d646e9bd 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1487,27 +1487,29 @@ if [[ $kernel_only != yes ]]; then
     done
 fi
 
-while pop include_src src && pop include_target tgt; do
-    if [[ $src && $tgt ]]; then
+while pop include_src src && pop include_target target; do
+    if [[ $src && $target ]]; then
         if [[ -f $src ]]; then
-            inst $src $tgt
+            inst $src $target
         else
             ddebug "Including directory: $src"
-            destdir="${initdir}/${tgt}"
+            destdir="${initdir}/${target}"
             mkdir -p "$destdir"
             # check for preexisting symlinks, so we can cope with the
             # symlinks to $prefix
-            for i in "$src"/*; do
-                [[ -e "$i" || -h "$i" ]] || continue
-                s=${destdir}/${i#$src/}
-                if [[ -d "$i" ]]; then
-                    if ! [[ -e "$s" ]]; then
-                        mkdir -m 0755 -p "$s"
-                        chmod --reference="$i" "$s"
+            # Objectname is a file or a directory
+            for objectname in "$src"/*; do
+                [[ -e "$objectname" || -h "$objectname" ]] || continue
+                if [[ -d "$objectname" ]]; then
+                    # objectname is a directory, let's compute the final directory name
+                    object_destdir=${destdir}/${objectname#$src/}
+                    if ! [[ -e "$object_destdir" ]]; then
+                        mkdir -m 0755 -p "$object_destdir"
+                        chmod --reference="$objectname" "$object_destdir"
                     fi
-                    cp --reflink=auto --sparse=auto -fa -t "$s" "$i"/*
+                    cp --reflink=auto --sparse=auto -fa -t "$object_destdir" "$objectname"/*
                 else
-                    cp --reflink=auto --sparse=auto -fa -t "$destdir" "$i"
+                    cp --reflink=auto --sparse=auto -fa -t "$destdir" "$objectname"
                 fi
             done
         fi