Refactor ubuntu-cpc hooks to allow us to handle images where the root

partition should not be partition 1.
ubuntu/yakkety
Steve Langasek 9 years ago
parent 7ec8dd87ac
commit 99cdaafd61

2
debian/changelog vendored

@ -18,6 +18,8 @@ livecd-rootfs (2.376) UNRELEASED; urgency=medium
environment, because auto/config and auto/build both rely on this. So environment, because auto/config and auto/build both rely on this. So
don't scatter dpkg --print-architecture calls throughout, especially don't scatter dpkg --print-architecture calls throughout, especially
when many of these are not cross-build-aware. 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 <lukasz.zemczak@ubuntu.com> Thu, 04 Feb 2016 17:31:18 +0100 -- Łukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> Thu, 04 Feb 2016 17:31:18 +0100

@ -41,6 +41,7 @@ mount_image() {
apt-get install -qqy kpartx apt-get install -qqy kpartx
trap clean_loops EXIT trap clean_loops EXIT
backing_img="$1" backing_img="$1"
local rootpart="$2"
kpartx_mapping="$(kpartx -s -v -a ${backing_img})" kpartx_mapping="$(kpartx -s -v -a ${backing_img})"
# Find the loop device # Find the loop device
@ -51,8 +52,12 @@ mount_image() {
exit 1 exit 1
fi 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 # 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 if [ ! -b "${rootfs_dev_mapper}" ]; then
echo "${rootfs_dev_mapper} is not a block device"; echo "${rootfs_dev_mapper} is not a block device";
exit 1 exit 1
@ -83,7 +88,7 @@ mount_partition() {
mount_disk_image() { mount_disk_image() {
local disk_image=${1} local disk_image=${1}
local mountpoint=${2} local mountpoint=${2}
mount_image ${disk_image} mount_image ${disk_image} 1
mount_partition "${rootfs_dev_mapper}" $mountpoint mount_partition "${rootfs_dev_mapper}" $mountpoint
local uefi_dev="/dev/mapper${loop_device///dev/}p15" local uefi_dev="/dev/mapper${loop_device///dev/}p15"

@ -1,13 +1,17 @@
#!/bin/bash -eux #!/bin/bash -eux
. /build/config/functions
case $ARCH in case $ARCH in
ppc64el) ppc64el)
echo "ppc64el disk images are handled separately" echo "ppc64el disk images are handled separately"
exit 0 exit 0
;; ;;
*)
ROOTPART=1
;;
esac esac
. /build/config/functions
create_empty_partition() { create_empty_partition() {
apt-get install -qqy parted apt-get install -qqy parted
parted_prefix="parted $1 --script --" parted_prefix="parted $1 --script --"
@ -16,14 +20,14 @@ create_empty_partition() {
${parted_prefix} mkpart primary 1 -1 ${parted_prefix} mkpart primary 1 -1
${parted_prefix} set 1 B ${parted_prefix} set 1 B
${parted_prefix} print ${parted_prefix} print
${parted_prefix} align-check opt 1 ${parted_prefix} align-check opt "$2"
} }
disk_image=binary/boot/disk.ext4 disk_image=binary/boot/disk.ext4
create_empty_disk_image "${disk_image}" create_empty_disk_image "${disk_image}"
create_empty_partition "${disk_image}" create_empty_partition "${disk_image}" "$ROOTPART"
mount_image "${disk_image}" mount_image "${disk_image}" "$ROOTPART"
# Copy the chroot in to the disk # Copy the chroot in to the disk
make_ext4_partition "${rootfs_dev_mapper}" make_ext4_partition "${rootfs_dev_mapper}"

@ -128,7 +128,7 @@ disk_image=binary/boot/disk-uefi.ext4
create_empty_disk_image "${disk_image}" create_empty_disk_image "${disk_image}"
create_partitions "${disk_image}" create_partitions "${disk_image}"
mount_image "${disk_image}" mount_image "${disk_image}" 1
# Copy the chroot in to the disk # Copy the chroot in to the disk
make_ext4_partition "${rootfs_dev_mapper}" make_ext4_partition "${rootfs_dev_mapper}"

@ -58,7 +58,7 @@ disk_image=binary/boot/disk.ext4
create_empty_disk_image "${disk_image}" create_empty_disk_image "${disk_image}"
create_partitions "${disk_image}" create_partitions "${disk_image}"
mount_image "${disk_image}" mount_image "${disk_image}" 1
# Copy the chroot in to the disk # Copy the chroot in to the disk
make_ext4_partition "${rootfs_dev_mapper}" make_ext4_partition "${rootfs_dev_mapper}"

Loading…
Cancel
Save