summary refs log tree commit diff
diff options
context:
space:
mode:
authorroot <root@node1.lecture.io>2014-01-22 18:15:57 +0100
committerroot <root@node1.lecture.io>2014-01-22 18:15:57 +0100
commit9683dc004570d2b46486ca59a0c1df630e44bcb9 (patch)
treefb8f0cf7d19a64e618364e1aa72490cd8c67053f
parent0621eebf86a4db8261f2487fdd93cae4fff5c384 (diff)
downloadhrmpf-9683dc004570d2b46486ca59a0c1df630e44bcb9.tar.gz
hrmpf-9683dc004570d2b46486ca59a0c1df630e44bcb9.tar.xz
hrmpf-9683dc004570d2b46486ca59a0c1df630e44bcb9.zip
using xpart instead of losetup -P, as -P is not supported by debian stable
mkfs.vfat thinks it writes to a raw device instead of a partition on debian. force it
-rw-r--r--mkimage.sh.in17
1 files changed, 12 insertions, 5 deletions
diff --git a/mkimage.sh.in b/mkimage.sh.in
index 31bc64a..c90d75f 100644
--- a/mkimage.sh.in
+++ b/mkimage.sh.in
@@ -32,7 +32,11 @@ trap 'printf "\nInterrupted! exiting...\n"; cleanup; exit 0' INT TERM HUP
 cleanup() {
     umount -f ${ROOTFSDIR}/boot 2>/dev/null
     umount -f ${ROOTFSDIR} 2>/dev/null
-    [ -e "$LOOPDEV" ] && losetup -d $LOOPDEV 2>/dev/null
+    if [ -e "$LOOPDEV" ]; then
+        partx -d $LOOPDEV 2>/dev/null
+        losetup -d $LOOPDEV 2>/dev/null
+    fi
+	
     [ -d "$ROOTFSDIR" ] && rmdir $ROOTFSDIR
 }
 
@@ -102,25 +106,27 @@ if [ -z "$FILENAME" ]; then
     FILENAME="void-image-$(date +%Y%m%d).img"
 fi
 
-for f in parted losetup mount mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}; do
+for f in parted partx losetup mount mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}; do
     if ! which ${f} >/dev/null; then
         die "Cannot find ${f}, exiting."
     fi
 done
 
 info_msg "Creating disk image ($IMGSIZE) ..."
-dd if=/dev/zero of=$FILENAME bs=$IMGSIZE count=1 conv=sparse >/dev/null 2>&1
+dd if=/dev/zero of=$FILENAME bs=$IMGSIZE count=1 >/dev/null 2>&1
 
 info_msg "Creating disk image partitions/filesystems ..."
 parted $FILENAME mktable msdos
 if [ "$BOOT_FSTYPE" = "vfat" ]; then
     _btype="fat32"
+    _args="-I"
 fi
 parted $FILENAME mkpart primary ${_btype} 4096s 256M
 parted $FILENAME mkpart primary ext2 256M 100%
 parted $FILENAME toggle 1 boot
-LOOPDEV=$(losetup --show --find -P $FILENAME)
-mkfs.${BOOT_FSTYPE} ${LOOPDEV}p1 >/dev/null 2>&1
+LOOPDEV=$(losetup --show --find $FILENAME)
+partx -a $LOOPDEV
+mkfs.${BOOT_FSTYPE} $_args ${LOOPDEV}p1 >/dev/null
 mkfs.${ROOT_FSTYPE} ${LOOPDEV}p2 >/dev/null 2>&1
 
 info_msg "Unpacking rootfs tarball ..."
@@ -141,6 +147,7 @@ fi
 
 umount ${ROOTFSDIR}/boot
 umount $ROOTFSDIR
+partx -d $LOOPDEV
 losetup -d $LOOPDEV
 rmdir $ROOTFSDIR