diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 239c03a3..06fa4f39 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -9,24 +9,41 @@ case $ARCH in ;; *) ROOTPART=1 + ROOTPART_START=1 ;; esac -create_empty_partition() { +create_empty_partition_table() { apt-get install -qqy parted - parted_prefix="parted $1 --script --" - ${parted_prefix} mklabel msdos - ${parted_prefix} mkpart primary 1 -1 - ${parted_prefix} set 1 B + parted "$1" --script -- mklabel msdos +} + +create_empty_partition() { + local disk="$1" + local part="$2" + local start="$3" + local end="$4" + local bootable="$5" + + parted_prefix="parted $disk --script --" + ${parted_prefix} mkpart primary "$start" "$end" + if [ -n "$bootable" ]; then + ${parted_prefix} set "$part" B + fi ${parted_prefix} print - ${parted_prefix} align-check opt "$2" + ${parted_prefix} align-check opt "$part" } disk_image=binary/boot/disk.ext4 create_empty_disk_image "${disk_image}" -create_empty_partition "${disk_image}" "$ROOTPART" +create_empty_partition_table "${disk_image}" +if [ -n "$BOOTPART_START" ]; then + create_empty_partition "$disk_image" 1 "$BOOTPART_START" "$BOOTPART_END" 1 +fi +create_empty_partition "${disk_image}" "$ROOTPART" "$ROOTPART_START" -1 + mount_image "${disk_image}" "$ROOTPART" # Copy the chroot in to the disk @@ -34,8 +51,6 @@ make_ext4_partition "${rootfs_dev_mapper}" mkdir mountpoint mount "${rootfs_dev_mapper}" mountpoint cp -a chroot/* mountpoint/ -umount mountpoint -rmdir mountpoint case $ARCH in amd64|i386) should_install_grub=1;; @@ -43,9 +58,6 @@ case $ARCH in esac if [ "${should_install_grub}" -eq 1 ]; then - mkdir mountpoint - mount_partition "${rootfs_dev_mapper}" mountpoint - echo "(hd0) ${loop_device}" > mountpoint/tmp/device.map chroot mountpoint grub-install ${loop_device} chroot mountpoint grub-bios-setup \ @@ -56,14 +68,10 @@ if [ "${should_install_grub}" -eq 1 ]; then ${loop_device} rm mountpoint/tmp/device.map - umount_partition mountpoint - rmdir mountpoint fi if [ "$ARCH" = "s390x" ]; then # Do ZIPL install bits - mkdir mountpoint - mount_partition "${rootfs_dev_mapper}" mountpoint # Write out cloudy zipl.conf for future kernel updates cat << EOF > mountpoint/etc/zipl.conf @@ -89,9 +97,10 @@ EOF --targetblocksize=512 \ --targetoffset=2048 - umount_partition mountpoint - rmdir mountpoint fi +umount_partition mountpoint +rmdir mountpoint + clean_loops trap - EXIT