overlayfs: attempt to move directory before bailing out

When the script is running inside an overlayfs, it doesn't necessarily mean that it would fail. This happens only if the directory being moved is in the lowerdir. But for example when running in a container and building a chroot, and installing the usrmerge package, this wouldn't happen as the chroot is in the upperdir (it's new).

Move the overlayfs check to the perl script, and attempt to quickly move the directories back-and-forth before bailing out.

To reproduce:

$ debootstrap --variant=minbase --no-merged-usr sid /tmp/lower
$ mkdir /tmp/img /tmp/upper /tmp/work
$ mount -t overlay overlay /tmp/img -o upperdir=/tmp/upper,lowerdir=/tmp/lower,workdir=/tmp/work
$ chroot /tmp/img
$ /usr/lib/usrmerge/convert-usrmerge
Warning: overlayfs detected, /usr/lib/usrmerge/convert-usrmerge will not
be run automatically. See #1008202 for details.

If this is a container then it can be converted by unpacking the image, entering it with chroot(8), installling usrmerge and then repacking the image again. at /var/convert-usrmerge line 474.

Closes: #1020228

Edited by Luca Boccassi

Merge request reports

Loading