From fc890b15e7cdd25845f846e549087b9deafe21ac Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 6 Jul 2021 23:09:17 +1200 Subject: [PATCH] adjust hooks for move of live-server to layers --- .../hooks/02-installer-bits.chroot | 17 ++++ .../hooks/03-kernel-metapkg.chroot_early | 37 +++++++ .../hooks/030-root-squashfs.binary | 33 ------- .../hooks/032-installer-squashfs.binary | 97 ------------------- .../hooks/033-kernel-bits.binary | 94 ------------------ .../ubuntu-server/hooks/04-kernel-bits.binary | 16 +++ 6 files changed, 70 insertions(+), 224 deletions(-) create mode 100755 live-build/ubuntu-server/hooks/02-installer-bits.chroot create mode 100755 live-build/ubuntu-server/hooks/03-kernel-metapkg.chroot_early delete mode 100755 live-build/ubuntu-server/hooks/030-root-squashfs.binary delete mode 100755 live-build/ubuntu-server/hooks/032-installer-squashfs.binary delete mode 100755 live-build/ubuntu-server/hooks/033-kernel-bits.binary create mode 100755 live-build/ubuntu-server/hooks/04-kernel-bits.binary diff --git a/live-build/ubuntu-server/hooks/02-installer-bits.chroot b/live-build/ubuntu-server/hooks/02-installer-bits.chroot new file mode 100755 index 00000000..d71157cc --- /dev/null +++ b/live-build/ubuntu-server/hooks/02-installer-bits.chroot @@ -0,0 +1,17 @@ +#!/bin/bash -ex +# vi: ts=4 noexpandtab + +if [ "${PASS}" != "ubuntu-server.installer" ]; then + exit 0 +fi + +# Make sure NoCloud is last +values=$(echo get cloud-init/datasources | debconf-communicate | sed 's/^0 //;s/NoCloud, //;s/None/NoCloud, None/') +printf "%s\t%s\t%s\t%s\n" \ + cloud-init cloud-init/datasources multiselect "$values" | debconf-set-selections +dpkg-reconfigure --frontend=noninteractive cloud-init + +if [ `dpkg --print-architecture` = s390x ]; then + # because z/VM x3270 is just ttyS0 + cp -r /usr/lib/systemd/system/serial-getty@sclp_line0.service.d /usr/lib/systemd/system/serial-getty@ttyS0.service.d +fi diff --git a/live-build/ubuntu-server/hooks/03-kernel-metapkg.chroot_early b/live-build/ubuntu-server/hooks/03-kernel-metapkg.chroot_early new file mode 100755 index 00000000..921960e5 --- /dev/null +++ b/live-build/ubuntu-server/hooks/03-kernel-metapkg.chroot_early @@ -0,0 +1,37 @@ +#!/bin/bash -ex +# vi: ts=4 noexpandtab + +case $PASS in + ubuntu-server.installer.*) + flavor=${PASS##*.} + if [ "$flavor" = "generic" ]; then + kernel_metapkg=linux-generic + elif [ "$flavor" = "generic-hwe" ]; then + kernel_metapkg=linux-generic-hwe-$(lsb_release -sr) + else + echo "bogus flavor: $flavor" + exit 1 + fi + ;; + *) + exit 0 + ;; +esac + +cat < /etc/initramfs-tools/scripts/init-bottom/live-server +#!/bin/sh +case \$1 in +prereqs) exit 0;; +esac + +echo ${kernel_metapkg} > /run/kernel-meta-package +EOF +chmod +x /etc/initramfs-tools/scripts/init-bottom/live-server + +cat < /etc/initramfs-tools/conf.d/casperize.conf +export CASPER_GENERATE_UUID=1 +EOF + +cat < /etc/initramfs-tools/conf.d/default-layer.conf +LAYERFS_PATH=${PASS}.squashfs +EOF diff --git a/live-build/ubuntu-server/hooks/030-root-squashfs.binary b/live-build/ubuntu-server/hooks/030-root-squashfs.binary deleted file mode 100755 index 148490e9..00000000 --- a/live-build/ubuntu-server/hooks/030-root-squashfs.binary +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -ex -# vi: ts=4 noexpandtab -# -# Generate a squashfs root and manifest - -set -x -echo "030-root-squashfs.binary" - -case $IMAGE_TARGETS in - ""|*squashfs*) - ;; - *) - echo "Skipping squashfs build" - exit 0 - ;; -esac - -if [ -n "$SUBARCH" ]; then - echo "Skipping rootfs build for subarch flavor build" - exit 0 -fi - -. config/functions - -mkdir binary/boot/squashfs.dir -cp -a chroot/* binary/boot/squashfs.dir - -squashfs_f="${PWD}/livecd.${PROJECT}.squashfs" -squashfs_f_manifest="${squashfs_f}.manifest" - -create_manifest "binary/boot/squashfs.dir" "${squashfs_f_manifest}" - -create_squashfs "binary/boot/squashfs.dir/" ${squashfs_f} diff --git a/live-build/ubuntu-server/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server/hooks/032-installer-squashfs.binary deleted file mode 100755 index febee4c6..00000000 --- a/live-build/ubuntu-server/hooks/032-installer-squashfs.binary +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -ex -# vi: ts=4 noexpandtab -# -# Generate a squashfs root and manifest - -set -x - -echo "032-installer-squashfs.binary" - -case $IMAGE_TARGETS in - ""|*squashfs*) - ;; - *) - echo "Skipping squashfs build" - exit 0 - ;; -esac - -if [ -n "$SUBARCH" ]; then - echo "Skipping rootfs build for subarch flavor build" - exit 0 -fi - -. config/binary -. config/functions -. config/common - -FILESYSTEM_ROOT=binary/boot/squashfs.dir -INSTALLER_ROOT=binary/boot/installer.squashfs.dir -OVERLAY_ROOT=binary/overlay - -mkdir -p "$INSTALLER_ROOT" "$OVERLAY_ROOT" - -# Create an installer squashfs layer -mount_overlay "$FILESYSTEM_ROOT/" "$OVERLAY_ROOT/" "$INSTALLER_ROOT/" - -setup_mountpoint "$INSTALLER_ROOT" - -# Override JobRunningTimeoutSec to 0s on the .device unit that -# subiquity_config.mount depends on to avoid a 5s delay on switching -# to a new VT when there is no device there (LP: #1750117). -# It would be better to have this in ../includes.binary/overlay but -# you can't have backslashes in filenames in bzr branches! -ANSWERS_DEVICE_UNIT='dev-disk-by\x2duuid-00c629d6\x2d06ab\x2d4dfd\x2db21e\x2dc3186f34105d.device' -mkdir -p "$INSTALLER_ROOT/etc/systemd/system/$ANSWERS_DEVICE_UNIT.d" -cat > "$INSTALLER_ROOT/etc/systemd/system/$ANSWERS_DEVICE_UNIT.d/override.conf" < "$KERNEL_BITS_ROOT"/etc/initramfs-tools/conf.d/livecd-rootfs.conf - fi - echo "export CASPER_GENERATE_UUID=1" > "$KERNEL_BITS_ROOT"/etc/initramfs-tools/conf.d/casper.conf - - # Add a hook to record which kernel was booted and mount the - # modules.squashfs created below. - cat < "$KERNEL_BITS_ROOT"/etc/initramfs-tools/scripts/init-bottom/live-server -#!/bin/sh -case \$1 in -prereqs) exit 0;; -esac - -echo ${kernel_metapkg} > /run/kernel-meta-package -mkdir -p \$rootmnt/usr/lib/modules -mount \$rootmnt/cdrom/casper/extras/modules.squashfs-$flavor \$rootmnt/usr/lib/modules -mkdir -p /run/systemd/system/usr-lib-modules.mount.d -echo '[Mount]' >> /run/systemd/system/usr-lib-modules.mount.d/lazy.conf -echo 'LazyUnmount=yes' >> /run/systemd/system/usr-lib-modules.mount.d/lazy.conf -EOF - chmod +x "$KERNEL_BITS_ROOT"/etc/initramfs-tools/scripts/init-bottom/live-server - - # Install the kernel! - env DEBIAN_FRONTEND=noninteractive chroot $KERNEL_BITS_ROOT apt-get -y install ${kernel_metapkg} - - # Fish out generated kernel image and initrd - mv "$KERNEL_BITS_ROOT"/boot/initrd.img-* ${PWD}/livecd.${PROJECT}.initrd-$flavor - mv "$KERNEL_BITS_ROOT"/boot/vmlinu?-* ${PWD}/livecd.${PROJECT}.kernel-$flavor - - # Create squashfs containing all the modules - modules_squashfs_path="${PWD}/livecd.${PROJECT}.modules.squashfs-$flavor" - (cd "$KERNEL_BITS_ROOT/lib/modules" && - mksquashfs . $modules_squashfs_path -no-progress -xattrs -comp xz) - - # And clean up - teardown_mountpoint $KERNEL_BITS_ROOT - umount $KERNEL_BITS_ROOT - rm -rf $KERNEL_BITS_ROOT $KERNEL_BITS_OVERLAY -done diff --git a/live-build/ubuntu-server/hooks/04-kernel-bits.binary b/live-build/ubuntu-server/hooks/04-kernel-bits.binary new file mode 100755 index 00000000..3b5f0862 --- /dev/null +++ b/live-build/ubuntu-server/hooks/04-kernel-bits.binary @@ -0,0 +1,16 @@ +#!/bin/bash -eux +# vi: ts=4 noexpandtab + +case $PASS in + ubuntu-server.installer.*) + flavor=${PASS##*.} + ;; + *) + exit 0 + ;; +esac + +# Fish out generated kernel image and initrd +mv chroot/boot/initrd.img-* ${PWD}/livecd.${PROJECT}.initrd-$flavor +mv chroot/boot/vmlinu?-* ${PWD}/livecd.${PROJECT}.kernel-$flavor +chmod a+r ${PWD}/livecd.${PROJECT}.initrd-$flavor ${PWD}/livecd.${PROJECT}.kernel-$flavor