Improve reliability of image creation in build-all

This commit is contained in:
zador-blood-stained 2016-12-14 15:17:13 +03:00
parent ee87237e85
commit 7772883381
2 changed files with 13 additions and 1 deletions

View file

@ -374,14 +374,22 @@ prepare_partitions()
fi
# stage: mount image
# TODO: Needs mknod here in Docker?
# lock access to loop devices
exec {FD}>/var/lock/armbian-debootstrap-losetup
flock --verbose -x $FD | tee -a $DEST/debug/output.log
LOOP=$(losetup -f)
[[ -z $LOOP ]] && exit_with_error "Unable to find free loop device"
# NOTE: losetup -P option is not available in Trusty
[[ $CONTAINER_COMPAT == yes && ! -e $LOOP ]] && mknod -m0660 $LOOP b 7 ${LOOP//\/dev\/loop} > /dev/null
# TODO: Needs mknod here in Docker?
losetup $LOOP $CACHEDIR/${SDCARD}.raw
# loop device was grabbed here, unlock
flock -u $FD
partprobe $LOOP
# stage: create fs, mount partitions, create fstab

View file

@ -91,6 +91,10 @@ exit_with_error()
display_alert "Process terminated" "" "info"
# TODO: execute run_after_build here?
overlayfs_wrapper "cleanup"
# unlock loop device access in case of starvation
exec {FD}>/var/lock/armbian-debootstrap-losetup
losetup -u $FD
exit -1
}