mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
ynh_setup_source: properly handle --keep for directories when the dir already exists in the new setup
This commit is contained in:
parent
9489d200b2
commit
8e3e788842
1 changed files with 7 additions and 1 deletions
|
@ -374,7 +374,13 @@ ynh_setup_source() {
|
||||||
for stuff_to_keep in $keep; do
|
for stuff_to_keep in $keep; do
|
||||||
if [ -e "$keep_dir/$stuff_to_keep" ]; then
|
if [ -e "$keep_dir/$stuff_to_keep" ]; then
|
||||||
mkdir --parents "$(dirname "$dest_dir/$stuff_to_keep")"
|
mkdir --parents "$(dirname "$dest_dir/$stuff_to_keep")"
|
||||||
cp --archive "$keep_dir/$stuff_to_keep" "$dest_dir/$stuff_to_keep"
|
|
||||||
|
# We add "--no-target-directory" (short option is -T) to handle the special case
|
||||||
|
# when we "keep" a folder, but then the new setup already contains the same dir (but possibly empty)
|
||||||
|
# in which case a regular "cp" will create a copy of the directory inside the directory ...
|
||||||
|
# resulting in something like /var/www/$app/data/data instead of /var/www/$app/data
|
||||||
|
# cf https://unix.stackexchange.com/q/94831 for a more elaborate explanation on the option
|
||||||
|
cp --archive --no-target-directory "$keep_dir/$stuff_to_keep" "$dest_dir/$stuff_to_keep"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue