Skip to content
Snippets Groups Projects
Unverified Commit 94d91768 authored by Oliver Smith's avatar Oliver Smith
Browse files

pmb/data/merge-usr: fix cannot overwrite error (MR 2388)

Don't just run one "mv" command to move everything from source to
target. This fails if the same directory already exists in target.
Instead, go into each directory in source, and move all files inside
that directory into the target directory structure.

Fix the following error:
  mv: cannot overwrite '/home/user/.local/var/pmbootstrap/chroot_native/usr/lib/sysctl.d': Directory not empty
parent 9a50d339
No related branches found
No related tags found
No related merge requests found
......@@ -17,12 +17,41 @@ if [ -L "$CHROOT"/bin ]; then
exit 1
fi
dir_is_empty() {
local dir="$1"
local i
for i in "$dir"/*; do
if [ "$i" = "$dir/*" ]; then
return 0
else
return 1
fi
done
}
merge() {
local src="$1"
local dest="$2"
local dir
cd "$CHROOT/$src"
for dir in $(find . -type d | sort -r); do
mkdir -p "$CHROOT/$dest/$dir"
if ! dir_is_empty "$dir"; then
mv "$dir"/* "$CHROOT/$dest/$dir"
fi
if [ "$dir" != "." ]; then
rmdir "$dir"
fi
done
cd "$CHROOT"
rmdir "$src"
mv "$CHROOT/$src/"* "$CHROOT/$dest/"
rmdir "$CHROOT/$src"
ln -s "/$dest" "$CHROOT/$src"
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment