Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mklive.sh: fix issues with error handling and unmounting pseudofs #365

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions mklive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ mount_pseudofs() {
done
}
umount_pseudofs() {
umount -R -f "$ROOTFS"/sys >/dev/null 2>&1
umount -R -f "$ROOTFS"/dev >/dev/null 2>&1
umount -R -f "$ROOTFS"/proc >/dev/null 2>&1
for f in sys dev proc; do
if ! umount -R -f "$ROOTFS/$f"; then
info_msg "ERROR: failed to unmount $ROOTFS/$f/"
return 1
fi
done
}
error_out() {
umount_pseudofs
[ -d "$BUILDDIR" -a -z "$KEEP_BUILDDIR" ] && rm -rf "$BUILDDIR"
exit "${1:=0}"
trap - INT TERM 0
umount_pseudofs || exit "${1:-0}"
[ -d "$BUILDDIR" ] && [ -z "$KEEP_BUILDDIR" ] && rm -rf --one-file-system "$BUILDDIR"
exit "${1:-0}"
}

usage() {
Expand Down Expand Up @@ -263,7 +267,7 @@ generate_grub_efi_boot() {
}

generate_squashfs() {
umount_pseudofs
umount_pseudofs || exit 1

# Find out required size for the rootfs and create an ext3fs image off it.
ROOTFS_SIZE=$(du --apparent-size -sm "$ROOTFS"|awk '{print $1}')
Expand Down