|
|
1755ca |
From 7812b7a7b02cc5b4e66c6544f8f8c8748ada00bf Mon Sep 17 00:00:00 2001
|
|
|
1755ca |
From: Erwan Velu <erwan.velu@enovance.com>
|
|
|
1755ca |
Date: Fri, 19 Dec 2014 14:49:00 +0100
|
|
|
1755ca |
Subject: [PATCH] dracut: Ajusting variables name for --include
|
|
|
1755ca |
|
|
|
1755ca |
When reading the --include part of the script, we had the following
|
|
|
1755ca |
issues to make the code easy to read:
|
|
|
1755ca |
- src & tgt were extract for the original options
|
|
|
1755ca |
- i variable was a file or a directory from src
|
|
|
1755ca |
- s variable was the directory name in case $i was a directory
|
|
|
1755ca |
|
|
|
1755ca |
"s" sounds very close to "src" while "s" is on the "tgt" side. Very
|
|
|
1755ca |
confusing.
|
|
|
1755ca |
|
|
|
1755ca |
"s" was defined before the "if it's a directory" statement while it's
|
|
|
1755ca |
only used inside the "if".
|
|
|
1755ca |
|
|
|
1755ca |
"i" was commit from the "src" but wasn't really explicit.
|
|
|
1755ca |
|
|
|
1755ca |
Having some lines mixing "i" and "s" takes a little time to get read
|
|
|
1755ca |
properly.
|
|
|
1755ca |
|
|
|
1755ca |
This patch offer the following changes:
|
|
|
1755ca |
- "i" is renamed to "objectname" as we don't know if its a file or a
|
|
|
1755ca |
directory
|
|
|
1755ca |
|
|
|
1755ca |
- "s" is renamed to "object_destdir" as the object name becomes a
|
|
|
1755ca |
directory on the destdir
|
|
|
1755ca |
|
|
|
1755ca |
- "object_destdir" (former "s") is moved inside the "if" statement as it's
|
|
|
1755ca |
only used here
|
|
|
1755ca |
|
|
|
1755ca |
- tgt is finally renamed to "target" to be more explicit. We are not all
|
|
|
1755ca |
native english ;o)
|
|
|
1755ca |
|
|
|
1755ca |
My 2 (semantic) cents,
|
|
|
1755ca |
|
|
|
1755ca |
Cherry-picked from: c9364f6ea296a03073bc4096756e3a61ca095c0e
|
|
|
1755ca |
Resolves: #1489882
|
|
|
1755ca |
---
|
|
|
1755ca |
dracut.sh | 29 ++++++++++++++++-------------
|
|
|
1755ca |
1 file changed, 16 insertions(+), 13 deletions(-)
|
|
|
1755ca |
|
|
|
1755ca |
diff --git a/dracut.sh b/dracut.sh
|
|
|
1755ca |
index 3b91b5e8..873274c0 100755
|
|
|
1755ca |
--- a/dracut.sh
|
|
|
1755ca |
+++ b/dracut.sh
|
|
|
1755ca |
@@ -1433,26 +1433,29 @@ if [[ $kernel_only != yes ]]; then
|
|
|
1755ca |
fi
|
|
|
1755ca |
fi
|
|
|
1755ca |
|
|
|
1755ca |
-while pop include_src src && pop include_target tgt; do
|
|
|
1755ca |
- if [[ $src && $tgt ]]; then
|
|
|
1755ca |
+while pop include_src src && pop include_target target; do
|
|
|
1755ca |
+ if [[ $src && $target ]]; then
|
|
|
1755ca |
if [[ -f $src ]]; then
|
|
|
1755ca |
- inst $src $tgt
|
|
|
1755ca |
+ inst $src $target
|
|
|
1755ca |
else
|
|
|
1755ca |
ddebug "Including directory: $src"
|
|
|
1755ca |
- mkdir -p "${initdir}/${tgt}"
|
|
|
1755ca |
+ destdir="${initdir}/${target}"
|
|
|
1755ca |
+ mkdir -p "$destdir"
|
|
|
1755ca |
# check for preexisting symlinks, so we can cope with the
|
|
|
1755ca |
# symlinks to $prefix
|
|
|
1755ca |
- for i in "$src"/*; do
|
|
|
1755ca |
- [[ -e "$i" || -h "$i" ]] || continue
|
|
|
1755ca |
- s=${initdir}/${tgt}/${i#$src/}
|
|
|
1755ca |
- if [[ -d "$i" ]]; then
|
|
|
1755ca |
- if ! [[ -e "$s" ]]; then
|
|
|
1755ca |
- mkdir -m 0755 -p "$s"
|
|
|
1755ca |
- chmod --reference="$i" "$s"
|
|
|
1755ca |
+ # Objectname is a file or a directory
|
|
|
1755ca |
+ for objectname in "$src"/*; do
|
|
|
1755ca |
+ [[ -e "$objectname" || -h "$objectname" ]] || continue
|
|
|
1755ca |
+ if [[ -d "$objectname" ]]; then
|
|
|
1755ca |
+ # objectname is a directory, let's compute the final directory name
|
|
|
1755ca |
+ object_destdir=${destdir}/${objectname#$src/}
|
|
|
1755ca |
+ if ! [[ -e "$object_destdir" ]]; then
|
|
|
1755ca |
+ mkdir -m 0755 -p "$object_destdir"
|
|
|
1755ca |
+ chmod --reference="$objectname" "$object_destdir"
|
|
|
1755ca |
fi
|
|
|
1755ca |
- cp --reflink=auto --sparse=auto -fa -t "$s" "$i"/*
|
|
|
1755ca |
+ cp --reflink=auto --sparse=auto -fa -t "$object_destdir" "$objectname"/*
|
|
|
1755ca |
else
|
|
|
1755ca |
- cp --reflink=auto --sparse=auto -fa -t "$s" "$i"
|
|
|
1755ca |
+ cp --reflink=auto --sparse=auto -fa -t "$destdir" "$objectname"
|
|
|
1755ca |
fi
|
|
|
1755ca |
done
|
|
|
1755ca |
fi
|