- # parted 1.8 added --machine for easier parsing; however,
- # debian still has 1.7 in unstable.
- partition_start=$(parted -s "$img" "unit B" "print" | sed -ne 's/^ 1[[:space:]]\+//p' | cut -dB -f1)
+ i=1
+ sed -ne 's/^LABEL=//p' configs/${CONFIG_TYPE}/fstab-ext3 | \
+ while read name mntpt fstype extra; do
+ partition_start=$(parted -m -s "$img" "unit B" "print" | grep "^$i" | cut -d: -f2 | cut -dB -f1)
+ partition_size=$(parted -m -s "$img" "unit B" "print" | grep "^$i" | cut -d: -f4 | cut -dB -f1)
+ bs=1024
+
+ # create the filesystems/swap
+ attach_loop "$img" "$partition_start"
+ if [ "$fstype" = "ext3" ]; then
+ mke2fs -q -b $bs -L "$name" -m0 -j "$LOOP_DEV" $((partition_size / bs))
+ tune2fs -c0 -i0 "$LOOP_DEV" # XXX: this is from OLPC days; do we still want this?
+ elif [ "$fstype" = "ext2" ]; then
+ mke2fs -q -b $bs -L "$name" -m0 "$LOOP_DEV" $((partition_size / bs))
+ tune2fs -c0 -i0 "$LOOP_DEV"
+ elif [ "$fstype" = "swap" ]; then
+ mkswap -L "$name" "$LOOP_DEV" $((partition_size / bs))
+ fi
+ detach_loop "$LOOP_DEV"
+
+ # mount the root partition if it's found
+ if [ "$mntpt" = "/" ]; then
+ mount "$img" "${mount_point_root}" -o loop,offset=$partition_start -t $fstype
+ fi
+
+ i=$((i + 1))
+ done