From 93d81670e0a6791ce7b9f037a7589fdf698d24cb Mon Sep 17 00:00:00 2001 From: TomAwezome Date: Fri, 17 Dec 2021 12:50:03 -0500 Subject: [PATCH] Clean-up new build scripts. Thanks to B4S3D for helpful tips on bash no-quote tilde expansion! --- build/build-iso.sh | 4 ++-- build/sync.sh | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/build/build-iso.sh b/build/build-iso.sh index 9d967824..c5900179 100755 --- a/build/build-iso.sh +++ b/build/build-iso.sh @@ -28,7 +28,7 @@ umount_tempdisk() { echo "Making temp vdisk, running auto-install..." qemu-img create -f raw $TMPDISK 192M -qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 512M -rtc base=localtime -cdrom AUTO.ISO -device isa-debug-exit +qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -cdrom AUTO.ISO -device isa-debug-exit echo "Mounting vdisk and copying src/..." rm ../src/Home/Registry.ZC 2> /dev/null @@ -38,7 +38,7 @@ sudo cp -r ../src/* $TMPMOUNT umount_tempdisk echo "Generating ISO..." -qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 512M -rtc base=localtime -device isa-debug-exit +qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -device isa-debug-exit echo "Extracting ISO from vdisk..." rm ./ZealOS-*.iso 2> /dev/null # comment this line if you want lingering old ISOs diff --git a/build/sync.sh b/build/sync.sh index 854155a9..0ff672fe 100755 --- a/build/sync.sh +++ b/build/sync.sh @@ -9,16 +9,21 @@ #alias sudo=doas # Set this -ZEALDISK="" +ZEALDISK= +# Examples: +#ZEALDISK=~/VirtualBox\ VMs/ZealOS/ZealOS.vdi +#ZEALDISK=~/vmware/ZealOS/ZealOS.vmdk +#ZEALDISK=ZealOS.qcow2 -[ -z $ZEALDISK ] && echo "Please edit this script with the full path to your ZealOS virtual disk." && exit 1 +[ -z "$ZEALDISK" ] && echo "Please edit this script with the full path to your ZealOS virtual disk." && exit 1 +[ ! -f "$ZEALDISK" ] && echo "\$ZEALDISK is not a path to a file." && exit 1 TMPMOUNT=/tmp/zealtmp -USAGE="Usage: $0 [ repo | vm ]" +USAGE="Usage: $0 [ repo | vm ] \n\n repo - overwrites src/ with virtual disk contents.\n vm - overwrites virtual disk with src/ contents.\n" mount_vdisk() { echo "Mounting virtual disk..." - sudo qemu-nbd -c /dev/nbd0 $ZEALDISK + sudo qemu-nbd -c /dev/nbd0 "$ZEALDISK" sudo partprobe /dev/nbd0 sudo mount /dev/nbd0p1 $TMPMOUNT } @@ -28,6 +33,7 @@ umount_vdisk() { sync sudo umount $TMPMOUNT sudo qemu-nbd -d /dev/nbd0 + sudo rm -rf $TMPMOUNT } if [ -z $1 ]