diff --git a/compat-usrmerge.changes b/compat-usrmerge.changes index a873f68..94eb82c 100644 --- a/compat-usrmerge.changes +++ b/compat-usrmerge.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Jun 8 12:03:52 UTC 2021 - Ludwig Nussel + +- early exit in case of overlayfs (boo#1187027) + ------------------------------------------------------------------- Tue Jun 8 07:37:33 UTC 2021 - Fabian Vogt diff --git a/convertfs b/convertfs index 01cc310..e82a95d 100644 --- a/convertfs +++ b/convertfs @@ -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"