3
0

- exit early if one of the affected directories has mountpoint

beneath it

OBS-URL: https://build.opensuse.org/package/show/Base:System/compat-usrmerge?expand=0&rev=13
This commit is contained in:
Ludwig Nussel 2021-06-02 15:29:59 +00:00 committed by Git OBS Bridge
parent ba81243db7
commit 4090c927d8
2 changed files with 20 additions and 5 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Jun 2 15:29:15 UTC 2021 - Ludwig Nussel <lnussel@suse.com>
- exit early if one of the affected directories has mountpoint
beneath it
-------------------------------------------------------------------
Tue Jun 1 23:27:08 UTC 2021 - Niklas Haas <obs@haasn.xyz>

View File

@ -25,6 +25,15 @@ mountpoint -q "$ROOT/usr" || CP_HARDLINK="-l"
set -e
while read dev mp other; do
for dir in bin sbin lib lib64; do
if [ "${mp#$ROOT/$dir}" != "$mp" ] || [ "${mp#$ROOT/usr/$dir}" != "$mp" ]; then
echo "Please unmount $mp before the conversion"
exit 1
fi
done
done < /proc/mounts
# merge / and /usr in new dir in /usr
for dir in bin sbin lib lib64; do
rm -rf -- "$ROOT/usr/${dir}.usrmerge"
@ -43,7 +52,7 @@ for dir in bin sbin lib lib64; do
rm -rf "$f.usrmerge~"
mv "$f" "$f.usrmerge~"
fi
done < <(find "$ROOT/usr/$dir" -type d -printf "%P\n" )
done < <(find "$ROOT/usr/$dir" -xdev -type d -printf "%P\n" )
echo "Merge the copy with \`$ROOT/usr/$dir'."
[[ -d "$ROOT/usr/${dir}.usrmerge" ]] \
|| mkdir -p "$ROOT/usr/${dir}.usrmerge"
@ -51,14 +60,14 @@ for dir in bin sbin lib lib64; do
echo "Clean up duplicates in \`$ROOT/usr/$dir'."
# delete all symlinks that have been backed up. /usr versions
# override / ones
find "$ROOT/usr/${dir}.usrmerge" -type l -name '*.usrmerge~' -delete || :
find "$ROOT/usr/${dir}.usrmerge" -xdev -type l -name '*.usrmerge~' -delete || :
# in rare cases the symlinks may point from /usr to /, so remove
# the link in that case
while read file; do
o=${file%%.usrmerge~}
[ -L "$o" ] && mv -f "$file" "$o"
done < <(find "$ROOT/usr/${dir}.usrmerge" \
-name '*.usrmerge~' -type f)
-xdev -name '*.usrmerge~' -type f)
done
# switch over merged dirs in /usr
for dir in bin sbin lib lib64; do
@ -72,7 +81,7 @@ done
for dir in bin sbin lib lib64; do
if [ ! -L "$ROOT/$dir" -a -d "$ROOT/$dir" ]; then
echo "Create \`$ROOT/$dir' symlink."
rm -rf "$ROOT/${dir}.usrmerge" || :
rm --one-file-system -rf "$ROOT/${dir}.usrmerge" || :
ln -s usr/$dir "$ROOT/${dir}.usrmerge"
/usr/libexec/xmv "$ROOT/$dir" "$ROOT/${dir}.usrmerge"
fi
@ -88,7 +97,7 @@ for dir in bin sbin lib lib64; do
if [ -d "$d" ]; then
echo "$d ..."
mv "$d" "$d~"
rm -rf "$d~"
rm --one-file-system -rf "$d~"
fi
done
done