diff --git a/Makefile b/Makefile index 2b7ff6c..0f553cb 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,7 @@ install-dirs: install: install-dirs install-locales $(INSTALL_PROGRAM) src/usbinstall.py $(DESTDIR)$(mambadir)/usbinstall/usbinstall.py $(INSTALL_SCRIPT) src/usbinstall.sh $(DESTDIR)$(sbindir)/usbinstall + $(INSTALL_SCRIPT) src/sdinstall-rpi.sh $(DESTDIR)$(sbindir)/sdinstall-rpi $(INSTALL_DATA) src/fdisk_template $(DESTDIR)$(mambadir)/usbinstall/fdisk_template $(INSTALL_DATA) src/img/*.png $(DESTDIR)$(mambadir)/usbinstall/img/ $(INSTALL_DATA) src/org.openmamba.usbinstall.policy $(DESTDIR)$(polkitdir)/org.openmamba.usbinstall.policy diff --git a/src/sdinstall-rpi.sh b/src/sdinstall-rpi.sh index 336d757..bdf1247 100755 --- a/src/sdinstall-rpi.sh +++ b/src/sdinstall-rpi.sh @@ -26,19 +26,31 @@ else PARTITION2=${DRIVE}2 fi -dd if=/dev/zero of=$DRIVE bs=1024 count=1024 +dd if=/dev/zero of=$DRIVE bs=1024 count=1024 || { + echo "ERROR: dd returned an error code of $?; aborting." + exit $? +} -set -- $(LC_ALL=C fdisk -l "$DRIVE" | grep "^Disk.*bytes$") +set -- $(LC_ALL=C fdisk -l "$DRIVE" | grep "^Disk.*bytes") SIZE="$5" -echo Disk Size: $SIZE bytes + +[ "$SIZE" ] || { + echo "ERROR: unable to detect disk size; aborting." + exit 1 +} + +echo "Disk Size: $SIZE bytes" CYLINDERS=`echo $SIZE/255/63/512 | bc` -echo Cylinders: $CYLINDERS +echo "Cylinders: $CYLINDERS" { echo ,9,0x0C,* echo ,,,- -} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE +} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE || { + echo "ERROR: sfdisk returned an error code of $?; aborting." + exit $? +} mkfs.vfat -F 32 -n "boot" $PARTITION1 mke2fs -t ext4 -j -L "openmamba" $PARTITION2