tar2fs: chgrp and failsafe kpartx

The current state made vm images belong to root group,
no reason to not change those to the primary group of
the user building an image.

kpartx -d -s could fail in some circumstances,
make a safety cleanup call more verbose.
This commit is contained in:
Michael Shigorin 2017-08-02 22:09:27 +03:00
parent 209c610f80
commit aa7f2d8423

View File

@ -138,7 +138,10 @@ exit_handler() {
umount ${BOOTFS:+"$BOOTFS"} "$ROOTFS"{/dev,/proc,/sys,}
if [ -n "$LOOPDEV" ]; then
kpartx -d -s "$LOOPDEV"
kpartx -d -s "$LOOPDEV" || {
sleep 10
kpartx -d -s -v "$LOOPDEV"
}
losetup --detach "$LOOPDEV"
fi
rm -r -- "$ROOTFS"
@ -272,5 +275,5 @@ image=/boot/vmlinuz
fi
if [ -n "$SUDO_USER" ]; then
chown "$SUDO_USER" "$IMG" "$ROOTFS" "$WORKDIR"
chown "$SUDO_USER:$(id -g "$SUDO_USER")" "$IMG" "$ROOTFS" "$WORKDIR" ||:
fi