Add enhanced error handling to make-image-raw
This commit is contained in:
parent
256dd3b2f0
commit
a026ea863c
@ -1,8 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if
|
||||
export DISK_IMAGE="$2"
|
||||
export ROOT_MOUNT="$OPUS_OUTPUT/mount"
|
||||
export ROOT_MOUNT="$1-mount"
|
||||
set +e
|
||||
|
||||
(
|
||||
set -e
|
||||
|
||||
# Get the approximate size required for the image
|
||||
export DISK_SIZE=$(du -sb "$1" | cut -f1)
|
||||
@ -44,7 +47,7 @@ if
|
||||
mount "${DISK_LOOP}p2" "$ROOT_MOUNT"
|
||||
|
||||
# Add files
|
||||
dupe "$1/." "$ROOT_MOUNT"
|
||||
cp -a "$1/." "$ROOT_MOUNT"
|
||||
|
||||
# Make fstab
|
||||
echo "UUID=$(blkid -o value -s UUID "${DISK_LOOP}p1") none swap sw 0 0" >"$ROOT_MOUNT/etc/fstab"
|
||||
@ -60,10 +63,8 @@ if
|
||||
umount -l "$ROOT_MOUNT"
|
||||
rmdir "$ROOT_MOUNT"
|
||||
losetup -d "$DISK_LOOP"
|
||||
then
|
||||
set +e
|
||||
else
|
||||
set +e
|
||||
)
|
||||
if [ $? != 0 ]; then
|
||||
echo
|
||||
echo Script execution ended due to error. Cleaning up...
|
||||
umount -l "$ROOT_MOUNT"
|
||||
|
Loading…
Reference in New Issue
Block a user