From c37d5f04345d75af7cdd538c85eba09ffa34f68f Mon Sep 17 00:00:00 2001 From: CloudBuilder Date: Thu, 8 Nov 2018 19:26:11 +0000 Subject: [PATCH] Imported 2.544 No reason for CPC update specified. --- debian/changelog | 34 +++++++++++ live-build/auto/build | 6 +- live-build/auto/config | 1 + live-build/functions | 12 ++++ live-build/snap-seed-parse.py | 56 +++++++++++++++++++ .../hooks/031-0-create-root-dir.binary | 2 +- .../ubuntu-cpc/hooks/032-disk-image.binary | 2 +- .../hooks/033-disk-image-uefi.binary | 8 ++- .../ubuntu-cpc/hooks/042-vagrant.binary | 3 +- .../hooks/030-root-squashfs.binary | 2 +- 10 files changed, 119 insertions(+), 7 deletions(-) create mode 100755 live-build/snap-seed-parse.py diff --git a/debian/changelog b/debian/changelog index 50ee1908..b84a17fb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,37 @@ +livecd-rootfs (2.544) disco; urgency=medium + + [ Steve Langasek ] + * Properly fix the hard-linking of vmlinuz, taken astray by my misguided + merge review. + + [ Dimitri John Ledkov ] + * When calling snap-seed-parse append stdout to file, but redirect + stderr to stdout, thus unbreak autopkgtests. + + -- Dimitri John Ledkov Thu, 08 Nov 2018 15:40:42 +0000 + +livecd-rootfs (2.543) disco; urgency=medium + + [ Cody Shepherd ] + * Ensure pre-seeded snaps are now published in the image manifests. + * Include grub efi packages in manifests for uefi images. + + [ Aleksandr Bogdanov ] + * vagrant: disabling automatic console log file + + [ Ɓukasz 'sil2100' Zemczak ] + * Avoid issues of hard-linking to a symbolic vmlinuz as this can lead to a + dangling symlink. + + [ Steve Langasek ] + * Unconditionally set GRUB_FORCE_PARTUUID in cloud images; as of version + 2.02+dfsg1-5ubuntu5 grub will automatically fall back to booting with an + initrd if one is available, so we can now always attempt initramfsless + boot for cloud images which almost always works and causes only minimal + increase in boot time for cases where it does not. + + -- Steve Langasek Fri, 02 Nov 2018 14:40:17 -0700 + livecd-rootfs (2.542) cosmic; urgency=medium * Decide what model assertion series to fetch depending on the suite. Use 16 diff --git a/live-build/auto/build b/live-build/auto/build index 4b6fdc2e..0bead613 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -550,7 +550,9 @@ if [ "$PROJECT" = "ubuntu-touch" ] || [ "$PROJECT" = "ubuntu-touch-custom" ]; th fi # '--initramfs none' produces different manifest names. +# NB! we want stdout appended to the manifest, yet stderr to be printed on stdout if [ -e "binary/$INITFS/filesystem.packages" ]; then + ./config/snap-seed-parse "chroot/" 2>&1 >> "binary/${INITFS}/filesystem.packages" ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest" chmod 644 "$PREFIX.manifest" fi @@ -848,13 +850,13 @@ done NUMFLAVOURS="$(set -- $LB_LINUX_FLAVOURS; echo $#)" if [ "$NUMFLAVOURS" = 1 ] && [ "$LB_LINUX_FLAVOURS" != "none" ]; then # only one kernel flavour - if [ -e "binary/$INITFS/vmlinuz" ]; then + if [ -f "binary/$INITFS/vmlinuz" ] && ! [ -h "binary/$INITFS/vmlinuz" ]; then ln "binary/$INITFS/vmlinuz" "$PREFIX.kernel" chmod 644 "$PREFIX.kernel" else ln -sf "$PREFIX.kernel-$LB_LINUX_FLAVOURS" "$PREFIX.kernel" fi - if [ -e "binary/$INITFS/initrd.lz" ]; then + if [ -f "binary/$INITFS/initrd.lz" ] && ! [ -h "binary/$INITFS/initrd.lz" ]; then ln "binary/$INITFS/initrd.lz" "$PREFIX.initrd" chmod 644 "$PREFIX.initrd" else diff --git a/live-build/auto/config b/live-build/auto/config index 75fd11aa..bffbb7f7 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -33,6 +33,7 @@ fi mkdir -p config cp -af /usr/share/livecd-rootfs/live-build/functions config/functions +cp -af /usr/share/livecd-rootfs/live-build/snap-seed-parse.py config/snap-seed-parse mkdir -p config/package-lists diff --git a/live-build/functions b/live-build/functions index cf68ba16..f12a364b 100644 --- a/live-build/functions +++ b/live-build/functions @@ -43,6 +43,18 @@ create_empty_disk_image() { dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}" } +# NB! we want stdout appended to the manifest, yet stderr to be printed on stdout +create_manifest() { + local chroot_root=${1} + local target_file=${2} + echo "create_manifest chroot_root: ${chroot_root}" + dpkg-query --show --admindir="${chroot_root}/var/lib/dpkg" > ${target_file} + echo "create_manifest call to dpkg-query finished." + ./config/snap-seed-parse "${chroot_root}" 2>&1 >> ${target_file} + echo "create_manifest call to snap_seed_parse finished." + echo "create_manifest finished" +} + make_ext4_partition() { device="$1" label=${fs_label:+-L "${fs_label}"} diff --git a/live-build/snap-seed-parse.py b/live-build/snap-seed-parse.py new file mode 100755 index 00000000..c441dc5a --- /dev/null +++ b/live-build/snap-seed-parse.py @@ -0,0 +1,56 @@ +#!/usr/bin/python3 + +""" +Usage: snap-seed-parse ${chroot_dir} > somefile.manifest + +This script looks for a seed.yaml path in the given root directory, parsing +it and printing generated manifest lines to stdout for easy redirection. +""" + +import re +import sys +import yaml +import os.path + + +def log(msg): + sys.stderr.write("snap-seed-parse: {}\n".format(msg)) + + +log("Parsing seed.yaml") + +CHROOT_ROOT = sys.argv[1] if len(sys.argv) > 1 and len(sys.argv[1]) > 0 \ + else '' + +# Trim any trailing slashes for correct appending +log("CHROOT_ROOT: {}".format(CHROOT_ROOT)) +if len(CHROOT_ROOT) > 0 and CHROOT_ROOT[-1] == '/': + CHROOT_ROOT = CHROOT_ROOT[:-1] + +# This is where we expect to find the seed.yaml file +YAML_PATH = CHROOT_ROOT + '/var/lib/snapd/seed/seed.yaml' + +# Snaps are prepended with this string in the manifest +LINE_PREFIX = 'snap:' + +log("yaml path: {}".format(YAML_PATH)) +if not os.path.isfile(YAML_PATH): + log("WARNING: yaml path not found; no seeded snaps found.") + exit(0) +else: + log("yaml path found.") + +with open(YAML_PATH, 'r') as fh: + yaml_lines = yaml.safe_load(fh)['snaps'] + +# Loop over dict items, outputting one manifest line from each triplet +for item in yaml_lines: + filestring = item['file'] + # Pull the revision number off the file name + revision = filestring[filestring.rindex('_')+1:] + revision = re.sub(r'[^0-9]', '', revision) + print("{}{}\t{}\t{}".format(LINE_PREFIX, + item['name'], + item['channel'], + revision, + )) diff --git a/live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary b/live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary index a4d77bd7..6ba4fe9c 100755 --- a/live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary +++ b/live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary @@ -26,4 +26,4 @@ mkdir -p $rootfs_dir/lib/modules teardown_mountpoint $rootfs_dir -dpkg-query --admindir=$rootfs_dir/var/lib/dpkg -W > $rootfs_dir.manifest +create_manifest "${rootfs_dir}" "${rootfs_dir}.manifest" diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index f7516dde..5bdcf5d4 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -121,7 +121,7 @@ if [ "${should_install_grub}" -eq 1 ]; then rm mountpoint/tmp/device.map - if [ "${SUBPROJECT:-}" = minimized ] && [ -n "$partuuid" ]; then + if [ -n "$partuuid" ]; then echo "partuuid found for root device; forcing it in Grub" mkdir -p mountpoint/etc/default/grub.d echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid.cfg 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 56328150..7370fb6f 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -64,7 +64,7 @@ install_grub() { efi_boot_dir="/boot/efi/EFI/BOOT" chroot mountpoint mkdir -p "${efi_boot_dir}" - if [ "${SUBPROJECT:-}" = minimized ] && [ -n "$partuuid" ]; then + if [ -n "$partuuid" ]; then # FIXME: code duplicated between 032-disk-image.binary # and 033-disk-image-uefi.binary. We want to fix this to not # have initramfs-tools installed at all on these images. @@ -93,6 +93,12 @@ install_grub() { ;; esac + # This call to generate the package manifest is added here to capture + # grub-efi packages that otherwise would not make it into the base + # manifest. filesystem.packages is moved into place via symlinking to + # livecd.ubuntu-cpc.manifest by live-build/auto/build after lb_binary runs + create_manifest "mountpoint" "binary/boot/filesystem.packages" + chroot mountpoint grub-install "${loop_device}" \ --boot-directory=/boot \ --efi-directory=/boot/efi \ diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index cb6c593c..26a2c424 100755 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -163,7 +163,8 @@ Vagrant.configure("2") do |config| config.vm.provider "virtualbox" do |vb| vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ] - vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "${prefix}-console.log") ] +# Creating a console log file is not an expected behavior for vagrant boxes. LP #1777827 +# vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "${prefix}-console.log") ] end end EOF diff --git a/live-build/ubuntu-server/hooks/030-root-squashfs.binary b/live-build/ubuntu-server/hooks/030-root-squashfs.binary index ad34e76a..41c15001 100755 --- a/live-build/ubuntu-server/hooks/030-root-squashfs.binary +++ b/live-build/ubuntu-server/hooks/030-root-squashfs.binary @@ -28,7 +28,7 @@ cp -a chroot/* binary/boot/squashfs.dir squashfs_f="${PWD}/livecd.${PROJECT}.squashfs" squashfs_f_manifest="${squashfs_f}.manifest" -dpkg-query --admindir=binary/boot/squashfs.dir/var/lib/dpkg -W > ${squashfs_f_manifest} +create_manifest "binary/boot/squashfs.dir" "${squashfs_f_manifest}" (cd "binary/boot/squashfs.dir/" && mksquashfs . ${squashfs_f} \