diff --git a/debian/changelog b/debian/changelog index e87c41a0..482044a8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ livecd-rootfs (2.441) UNRELEASED; urgency=medium * Add ubuntu-server-live for a subiquity-based server image. + * Refactor functions out of ubuntu-cpc and ubuntu-server hooks. -- Mathieu Trudel-Lapierre Thu, 23 Mar 2017 16:20:16 -0400 diff --git a/live-build/ubuntu-cpc/functions b/live-build/auto/functions similarity index 93% rename from live-build/ubuntu-cpc/functions rename to live-build/auto/functions index c7ff023b..af555998 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/auto/functions @@ -1,7 +1,7 @@ # vi: ts=4 expandtab syntax=sh -CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" -IMAGE_SIZE=$((2252*1024**2)) # 2.2G (the current size we ship) +imagesize=${IMAGE_SIZE:-$((2252*1024**2))} # 2.2G (the current size we ship) +fs_label="${FS_LABEL:-rootfs}" rootfs_dev_mapper= loop_device= @@ -28,13 +28,13 @@ clean_loops() { create_empty_disk_image() { # Prepare an empty disk image - dd if=/dev/zero of="$1" bs=1 count=0 seek="${IMAGE_SIZE}" + dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}" } make_ext4_partition() { device="$1" - - mkfs.ext4 -F -b 4096 -i 8192 -m 0 -L cloudimg-rootfs -E resize=536870912 "$device" + label=${fs_label:+-L "${fs_label}"} + mkfs.ext4 -F -b 4096 -i 8192 -m 0 ${label} -E resize=536870912 "$device" } mount_image() { @@ -103,7 +103,7 @@ mount_disk_image() { # such as updating grub and installing software cat > $mountpoint/usr/sbin/policy-rc.d << EOF #!/bin/sh -# ${CLOUD_IMG_STR} +# ${IMAGE_STR} echo "All runlevel operations denied by policy" >&2 exit 101 EOF @@ -251,9 +251,9 @@ convert_to_qcow2() { replace_grub_root_with_label() { # When update-grub is run, it will detect the disks in the build system. - # Instead, we want grub to use the cloudimg-rootfs labelled disk + # Instead, we want grub to use the right labelled disk CHROOT_ROOT="$1" - sed -i -e "s,root=[^ ]\+,root=LABEL=cloudimg-rootfs," \ + sed -i -e "s,root=[^ ]\+,root=LABEL=${fs_label}," \ "$CHROOT_ROOT/boot/grub/grub.cfg" } diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 0ed08b04..54df55a1 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -1,6 +1,9 @@ #!/bin/bash -ex -. /build/config/functions +IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" +FS_LABEL="cloudimg-rootfs" + +. auto/functions BOOTPART_START= BOOTPART_END= diff --git a/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary index 63a00894..f129384c 100755 --- a/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary +++ b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary @@ -17,7 +17,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. /build/config/functions +. auto/functions mkdir binary/boot/squashfs.dir cp -a chroot/* binary/boot/squashfs.dir 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 04a3c7df..e1ea4f9b 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -9,7 +9,10 @@ case $ARCH in ;; esac -. /build/config/functions +IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" +FS_LABEL="cloudimg-rootfs" + +. auto/functions apt-get -qqy install dosfstools gdisk 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 1f6b35a7..a0281ee2 100755 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -7,7 +7,10 @@ case $ARCH in ;; esac -. /build/config/functions +IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" +FS_LABEL="cloudimg-rootfs" + +. auto/functions create_partitions() { disk_image="$1" diff --git a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary index f9ab7e62..9b1c6c32 100755 --- a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary @@ -21,7 +21,7 @@ esac apt-get install -qqy qemu-utils -. /build/config/functions +. auto/functions if [ -f binary/boot/disk-uefi.ext4 ]; then convert_to_qcow2 binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.img diff --git a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary index 9a71f7ff..6c7bbeb0 100755 --- a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary @@ -18,7 +18,7 @@ case ${IMAGE_TARGETS:-} in ;; esac -. /build/config/functions +. auto/functions if [ -e binary/boot/disk-uefi.ext4 ]; then create_vmdk binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.vmdk diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index 3f962bd8..4be0b7f8 100755 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -44,7 +44,7 @@ case $ARCH in exit 0;; esac -. /build/config/functions +. auto/functions # Virtualbox is needed for making a small VMDK apt-get -qqy install genisoimage qemu-utils diff --git a/live-build/ubuntu-cpc/hooks/999-extras.binary b/live-build/ubuntu-cpc/hooks/999-extras.binary index ffc7c691..f5790201 100755 --- a/live-build/ubuntu-cpc/hooks/999-extras.binary +++ b/live-build/ubuntu-cpc/hooks/999-extras.binary @@ -9,7 +9,7 @@ if [ ! -d ${my_dir}/extra ]; then fi # Export the common functions to the extras -. /build/config/functions +. auto/functions # Cleaner execution /bin/run-parts --regex ".*\.binary" "${extra_d}" diff --git a/live-build/ubuntu-server-live/functions b/live-build/ubuntu-server-live/functions deleted file mode 120000 index bca29a2f..00000000 --- a/live-build/ubuntu-server-live/functions +++ /dev/null @@ -1 +0,0 @@ -../ubuntu-cpc/functions \ No newline at end of file diff --git a/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary b/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary index 48f60193..eb03d7fc 100755 --- a/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary +++ b/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary @@ -20,7 +20,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. /build/config/functions +. auto/functions mkdir binary/boot/squashfs.dir cp -a chroot/* binary/boot/squashfs.dir diff --git a/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary index e50f80ab..f71d9674 100755 --- a/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary +++ b/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary @@ -21,7 +21,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. /build/config/functions +. auto/functions SQUASH_ROOT=binary/boot/squashfs.dir OVERLAY_ROOT=binary/boot/overlay.dir