From 99cdaafd6117160a9c5ae9e52d414c13d0717c47 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Sat, 6 Feb 2016 00:34:16 -0800 Subject: [PATCH] Refactor ubuntu-cpc hooks to allow us to handle images where the root partition should not be partition 1. --- debian/changelog | 2 ++ live-build/ubuntu-cpc/functions | 9 +++++++-- live-build/ubuntu-cpc/hooks/032-disk-image.binary | 14 +++++++++----- .../ubuntu-cpc/hooks/033-disk-image-uefi.binary | 2 +- .../ubuntu-cpc/hooks/034-disk-image-ppc64el.binary | 2 +- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1e9bf317..ac857c83 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ livecd-rootfs (2.376) UNRELEASED; urgency=medium environment, because auto/config and auto/build both rely on this. So don't scatter dpkg --print-architecture calls throughout, especially when many of these are not cross-build-aware. + * Refactor ubuntu-cpc hooks to allow us to handle images where the root + partition should not be partition 1. -- Ɓukasz 'sil2100' Zemczak Thu, 04 Feb 2016 17:31:18 +0100 diff --git a/live-build/ubuntu-cpc/functions b/live-build/ubuntu-cpc/functions index f4557c9e..ee254d4b 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/ubuntu-cpc/functions @@ -41,6 +41,7 @@ mount_image() { apt-get install -qqy kpartx trap clean_loops EXIT backing_img="$1" + local rootpart="$2" kpartx_mapping="$(kpartx -s -v -a ${backing_img})" # Find the loop device @@ -51,8 +52,12 @@ mount_image() { exit 1 fi + # don't assume we know the separator between device number and partition + # number in the partition name, as this has changed over time. + partsep=$(echo "$loop_p1" | sed -e's/^loop[0-9]\+\(.*\)[0-9]\+/\1/') + # Find the rootfs location - rootfs_dev_mapper="/dev/mapper/${loop_p1}" + rootfs_dev_mapper="/dev/mapper/${loop_device}${partsep}${rootpart}" if [ ! -b "${rootfs_dev_mapper}" ]; then echo "${rootfs_dev_mapper} is not a block device"; exit 1 @@ -83,7 +88,7 @@ mount_partition() { mount_disk_image() { local disk_image=${1} local mountpoint=${2} - mount_image ${disk_image} + mount_image ${disk_image} 1 mount_partition "${rootfs_dev_mapper}" $mountpoint local uefi_dev="/dev/mapper${loop_device///dev/}p15" diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 95324ec6..3a758742 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -1,13 +1,17 @@ #!/bin/bash -eux + +. /build/config/functions + case $ARCH in ppc64el) echo "ppc64el disk images are handled separately" exit 0 ;; + *) + ROOTPART=1 + ;; esac -. /build/config/functions - create_empty_partition() { apt-get install -qqy parted parted_prefix="parted $1 --script --" @@ -16,14 +20,14 @@ create_empty_partition() { ${parted_prefix} mkpart primary 1 -1 ${parted_prefix} set 1 B ${parted_prefix} print - ${parted_prefix} align-check opt 1 + ${parted_prefix} align-check opt "$2" } disk_image=binary/boot/disk.ext4 create_empty_disk_image "${disk_image}" -create_empty_partition "${disk_image}" -mount_image "${disk_image}" +create_empty_partition "${disk_image}" "$ROOTPART" +mount_image "${disk_image}" "$ROOTPART" # Copy the chroot in to the disk make_ext4_partition "${rootfs_dev_mapper}" diff --git a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary index c84b4bab..8599ea8d 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -128,7 +128,7 @@ disk_image=binary/boot/disk-uefi.ext4 create_empty_disk_image "${disk_image}" create_partitions "${disk_image}" -mount_image "${disk_image}" +mount_image "${disk_image}" 1 # Copy the chroot in to the disk make_ext4_partition "${rootfs_dev_mapper}" diff --git a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary index e5d56664..6647c9ec 100755 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -58,7 +58,7 @@ disk_image=binary/boot/disk.ext4 create_empty_disk_image "${disk_image}" create_partitions "${disk_image}" -mount_image "${disk_image}" +mount_image "${disk_image}" 1 # Copy the chroot in to the disk make_ext4_partition "${rootfs_dev_mapper}"