aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHari Bathini <hbathini@linux.ibm.com>2021-06-11 15:20:28 +0530
committerHarald Hoyer <harald@hoyer.xyz>2021-06-29 09:53:19 +0200
commitf1138012c9dc44e6614466c0a8e929fc55e4a5dd (patch)
tree65eca7d109ed31d37a81b701fb16b639325f43c3
parenta97d2cedcf65a9a2fbff2591171f0163c7d3cb46 (diff)
downloaddracut-f1138012c9dc44e6614466c0a8e929fc55e4a5dd.tar.gz
fix(dracut.sh): handle '-i' option to include files beginning with '.'
While including a directory using '--include' option, the file and subdirectory names that begin with '.' are not included. Also, dracut throws a warning message when a subdirectory is empty or only has files or subdirectories that begin with '.'. For example, while trying to include /tmpdata directory with the below tree: # tree -a /tmpdata /tmpdata ├── .anothertestdir ├── testdir │   └── .testsubdir └── .testfile dracut throws the below warning message: # dracut --include /tmpdata /root cp: cannot stat '/tmpdata/testdir/*': No such file or directory # and this is how the included /tmpdata directory tree looks: # tree -a root root └── testdir No file or directory beginning with '.' is included & also, copying /tmpdata/testdir reported "No such file or directory" warning. Using '.' instead of '*' in the below command will fix the warning whether the directory being copied is empty or only has files or directories that begin with dot: $DRACUT_CP -t "$object_destdir" "$dracutsysrootdir$objectname"/* Also, enable 'dotglob' temporarily to include files and directories beginning with a `.' in the results of pathname expansion of source directory being included. Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
-rwxr-xr-xdracut.sh5
1 files changed, 4 insertions, 1 deletions
diff --git a/dracut.sh b/dracut.sh
index 60ac46f4..e7f47752 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -2067,6 +2067,8 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do
# check for preexisting symlinks, so we can cope with the
# symlinks to $prefix
# Objectname is a file or a directory
+ reset_dotglob="$(shopt -p dotglob)"
+ shopt -q -s dotglob
for objectname in "$src"/*; do
[[ -e $objectname || -L $objectname ]] || continue
if [[ -d $objectname ]]; then
@@ -2077,11 +2079,12 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do
mkdir -m 0755 -p "$object_destdir"
chmod --reference="$objectname" "$object_destdir"
fi
- $DRACUT_CP -t "$object_destdir" "$dracutsysrootdir$objectname"/*
+ $DRACUT_CP -t "$object_destdir" "$dracutsysrootdir$objectname"/.
else
$DRACUT_CP -t "$destdir" "$dracutsysrootdir$objectname"
fi
done
+ eval "$reset_dotglob"
elif [[ -e $src ]]; then
derror "$src is neither a directory nor a regular file"
else