From c841db5f23276e12866b5c5d05f7abb7a7d7a2a9 Mon Sep 17 00:00:00 2001 From: Bela Lubkin Date: Tue, 18 Mar 2014 03:17:40 -0700 Subject: [PATCH] - Use $IMAGE_FILE instead of NookManager.img, makes ad hoc testing easier - Use `losetup -f` to get a usable loop device: some may be in use - Use `parted --align=minimal` to allow tighter control over partition shape - Explicitly start partition at 16KiB rather than relying on "cyl" alignment - "An" SD card :) --- build.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index 46b2738..768e5bd 100755 --- a/build.sh +++ b/build.sh @@ -181,25 +181,28 @@ cp "$BDIR/patched-jars/android.policy.jar" "$OUTDIR/files/system/framework/" cp "$BDIR/patched-jars/services.jar" "$OUTDIR/files/system/framework/" # Create image -dd if=/dev/zero of=NookManager.img bs=1MiB count=64 -sudo losetup /dev/loop0 NookManager.img -sudo parted /dev/loop0 mklabel msdos -sudo parted /dev/loop0 --align=cyl mkpart primary fat32 0 100% -sudo parted /dev/loop0 set 1 boot on -sudo losetup -o 16384 /dev/loop1 /dev/loop0 -sudo mkdosfs -F 32 -n "NookManager" /dev/loop1 +IMAGE_FILE=NookManager.img +dd if=/dev/zero of=$IMAGE_FILE bs=1MiB count=64 +WHOLE_CARD=$(sudo losetup -f) +sudo losetup $WHOLE_CARD $IMAGE_FILE +BOOTFS_DEV=$(sudo losetup -f) +sudo parted $WHOLE_CARD mklabel msdos +sudo parted $WHOLE_CARD --align=minimal mkpart primary fat32 16384B 100% +sudo parted $WHOLE_CARD set 1 boot on +sudo losetup -o 16384 $BOOTFS_DEV $WHOLE_CARD +sudo mkdosfs -F 32 -n "NookManager" $BOOTFS_DEV if [ ! -d "$BDIR/tmpmount" ]; then mkdir "$BDIR/tmpmount" fi -sudo mount -t vfat -o uid=$(id -ur) -o gid=$(id -gr) /dev/loop1 "$BDIR/tmpmount" +sudo mount -t vfat -o uid=$(id -ur) -o gid=$(id -gr) $BOOTFS_DEV "$BDIR/tmpmount" rsync -a "$OUTDIR/" "$BDIR/tmpmount/" sync sudo umount "$BDIR/tmpmount" -sudo losetup -d /dev/loop1 +sudo losetup -d $BOOTFS_DEV sync -sudo losetup -d /dev/loop0 +sudo losetup -d $WHOLE_CARD -echo "Build Complete. You can now flash NookManager.img to a SD card." +echo "Build Complete. You can now flash $IMAGE_FILE to an SD card."