alpinelinux / alpine-chroot-install

Install Alpine Linux in chroot with a breeze. Build ARM on Travis CI or any other x86_64 CI.
MIT License
290 stars 59 forks source link

Destroy script unmounting too much #30

Closed douglas-raillard-arm closed 2 years ago

douglas-raillard-arm commented 3 years ago

The destroy script lists too many mount points:

        cat /proc/mounts | cut -d' ' -f2 | grep "^$SCRIPT_DIR" | sort -r

If $SCRIPT_DIR has itself been mounted (e.g. a bind mount, a USB drive, an overlayfs, etc), then it will be part of the list and unmounted by destroy, even though this is outside of the scope of alpine-chroot-install tooling. Instead, it should list the mount points that start with SCRIPT_DIR but are not equal to SCRIPT_DIR:

        cat /proc/mounts | cut -d' ' -f2 | grep "^$SCRIPT_DIR" | grep -v "^$SCRIPT_DIR$" | sort -r

Or alternatively, trying to match an extra char in the path with .:

        cat /proc/mounts | cut -d' ' -f2 | grep "^$SCRIPT_DIR." | sort -r