Accepting request 898426 from home:lnussel:usrmove

- early exit in case of overlayfs (boo#1187027)

OBS-URL: https://build.opensuse.org/request/show/898426
OBS-URL: https://build.opensuse.org/package/show/Base:System/compat-usrmerge?expand=0&rev=17
This commit is contained in:
Ludwig Nussel 2021-06-08 13:14:14 +00:00 committed by Git OBS Bridge
parent 3318269fb9
commit be2a961a1f
2 changed files with 27 additions and 5 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Jun 8 12:03:52 UTC 2021 - Ludwig Nussel <lnussel@suse.de>
- early exit in case of overlayfs (boo#1187027)
-------------------------------------------------------------------
Tue Jun 8 07:37:33 UTC 2021 - Fabian Vogt <fvogt@suse.com>

View File

@ -3,6 +3,19 @@
ROOT=
is_usrmerged() {
local r=1
for dir in bin sbin lib lib64; do
[ -d "$ROOT/$dir" ] || continue
[ -L "$ROOT/$dir" ] || return 1
r=0
done
return "$r"
}
# check if there's anything to do
is_usrmerged && exit 0
# the package is installed with AutoReq off, so no guarantee that
# coreutils actually works
if ! { cp --help && find --help; } > /dev/null; then
@ -12,7 +25,7 @@ fi
# clean up after ourselves no matter how we die.
cleanup() {
echo "Something failed, cleaning up"
echo "UsrMerge conversion failed, cleaning up"
for dir in bin sbin lib lib64; do
rm -rf -- "$ROOT/usr/${dir}.usrmerge"
done
@ -26,10 +39,16 @@ trap 'exit 1;' SIGINT
set -e
usrismountpoint=
if [ "$(stat -f -c %T "${ROOT:-/}")" = "overlayfs" ]; then
echo "UsrMerge conversion does not work on overlayfs"
exit 1
fi
CP_HARDLINK="-l"
while read dev mp other; do
[ "$mp" = "/usr" ] && usrismountpoint=1
[ "$mp" = "$ROOT/usr" ] && CP_HARDLINK=""
for dir in bin sbin lib lib64; do
[ -d "$ROOT/$dir" ] || continue
if [ "${mp#$ROOT/$dir}" != "$mp" ] || [ "${mp#$ROOT/usr/$dir}" != "$mp" ]; then
echo "Please unmount $mp before the conversion"
exit 1
@ -37,8 +56,6 @@ while read dev mp other; do
done
done < /proc/mounts
[ -n "$usrismountpoint" ] || CP_HARDLINK="-l"
# merge / and /usr in new dir in /usr
for dir in bin sbin lib lib64; do
rm -rf -- "$ROOT/usr/${dir}.usrmerge"