Accepting request 879892 from home:lnussel:usrmove

- cp can't handle copying a dir over non-directories. So move those
  away in advance. Happened with /lib/udev existing as link on older
  distros

OBS-URL: https://build.opensuse.org/request/show/879892
OBS-URL: https://build.opensuse.org/package/show/Base:System/compat-usrmerge?expand=0&rev=8
This commit is contained in:
Ludwig Nussel 2021-03-18 13:44:16 +00:00 committed by Git OBS Bridge
parent 7217d89630
commit ccc2543924
2 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Mar 18 12:24:15 UTC 2021 - Ludwig Nussel <lnussel@suse.de>
- cp can't handle copying a dir over non-directories. So move those
away in advance. Happened with /lib/udev existing as link on older
distros
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Mar 15 17:41:10 UTC 2021 - Ludwig Nussel <lnussel@suse.de> Mon Mar 15 17:41:10 UTC 2021 - Ludwig Nussel <lnussel@suse.de>

View File

@ -33,6 +33,17 @@ for dir in bin sbin lib lib64; do
echo "Make a copy of \`$ROOT/$dir'." echo "Make a copy of \`$ROOT/$dir'."
[[ -d "$ROOT/$dir" ]] \ [[ -d "$ROOT/$dir" ]] \
&& cp -ax -l "$ROOT/$dir" "$ROOT/usr/${dir}.usrmerge" && cp -ax -l "$ROOT/$dir" "$ROOT/usr/${dir}.usrmerge"
# cp can't handle copying a dir over non-directories. So move
# those away in advance. Happened with /lib/udev existing as
# link on older distros
while read d; do
f="$ROOT/usr/$dir.usrmerge/$d"
if test -e "$f" -a \( -L "$f" -o ! -d "$f" \); then
echo "Warning: /$dir/$d conflicts with directory /usr/$dir/$d and will be removed"
rm -rf "$f.usrmerge~"
mv "$f" "$f.usrmerge~"
fi
done < <(find "$ROOT/usr/$dir" -type d -printf "%P\n" )
echo "Merge the copy with \`$ROOT/usr/$dir'." echo "Merge the copy with \`$ROOT/usr/$dir'."
[[ -d "$ROOT/usr/${dir}.usrmerge" ]] \ [[ -d "$ROOT/usr/${dir}.usrmerge" ]] \
|| mkdir -p "$ROOT/usr/${dir}.usrmerge" || mkdir -p "$ROOT/usr/${dir}.usrmerge"