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