From 00c8b06004b7f3fd25632ff3f86711e1c9e2da94 Mon Sep 17 00:00:00 2001 From: Cody Shepherd Date: Tue, 27 Nov 2018 11:16:45 -0800 Subject: [PATCH 1/4] Include snaps in image manifests --- debian/changelog | 6 ++++++ live-build/auto/build | 1 + live-build/auto/config | 1 + live-build/functions | 11 +++++++++++ .../ubuntu-cpc/hooks/031-0-create-root-dir.binary | 2 +- .../ubuntu-server/hooks/030-root-squashfs.binary | 2 +- 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 102da40e..5d5de20d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +livecd-rootfs (2.525.10ubuntu1) UNRELEASED; urgency=medium + + * Include snaps in image manifests + + -- Cody Shepherd Tue, 27 Nov 2018 11:16:13 -0800 + livecd-rootfs (2.525.10) bionic; urgency=medium [ Cody Shepherd ] diff --git a/live-build/auto/build b/live-build/auto/build index 110478a5..86de899a 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -503,6 +503,7 @@ fi # '--initramfs none' produces different manifest names. if [ -e "binary/$INITFS/filesystem.packages" ]; then + ./config/snap-seed-parse "chroot/" "binary/${INITFS}/filesystem.packages" ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest" chmod 644 "$PREFIX.manifest" fi diff --git a/live-build/auto/config b/live-build/auto/config index ba554125..366c4c38 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 3363bf2a..a06427d3 100644 --- a/live-build/functions +++ b/live-build/functions @@ -43,6 +43,17 @@ create_empty_disk_image() { dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}" } +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}" "${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/ubuntu-cpc/hooks/031-0-create-root-dir.binary b/live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary index a4d77bd7..6ba4fe9c 100644 --- 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-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} \ From 6527da055df5ff6ef9f07f67336bf1e837d8f857 Mon Sep 17 00:00:00 2001 From: Cody Shepherd Date: Tue, 27 Nov 2018 11:29:57 -0800 Subject: [PATCH 2/4] Change call to add grub efi packages using new create_manifests() function. --- debian/changelog | 6 ++++-- live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5d5de20d..d00e4c0e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,10 @@ -livecd-rootfs (2.525.10ubuntu1) UNRELEASED; urgency=medium +livecd-rootfs (2.525.10ubuntu2) UNRELEASED; urgency=medium * Include snaps in image manifests + * Change call to add grub efi packages using new create_manifests() + function. - -- Cody Shepherd Tue, 27 Nov 2018 11:16:13 -0800 + -- Cody Shepherd Tue, 27 Nov 2018 11:29:23 -0800 livecd-rootfs (2.525.10) bionic; urgency=medium 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 7839c49e..2dff6d22 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -97,7 +97,7 @@ install_grub() { # 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 - dpkg-query --show --admindir="mountpoint/var/lib/dpkg" > "binary/boot/filesystem.packages" + create_manifest "mountpoint" "binary/boot/filesystem.packages" chroot mountpoint grub-install "${loop_device}" \ --boot-directory=/boot \ From 64e53300298da91b06858648f59cf2eb11e087b7 Mon Sep 17 00:00:00 2001 From: Cody Shepherd Date: Tue, 27 Nov 2018 11:39:15 -0800 Subject: [PATCH 3/4] Adding snap-seed-parse.py (that might help) --- live-build/snap-seed-parse.py | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 live-build/snap-seed-parse.py diff --git a/live-build/snap-seed-parse.py b/live-build/snap-seed-parse.py new file mode 100755 index 00000000..d2c6ef28 --- /dev/null +++ b/live-build/snap-seed-parse.py @@ -0,0 +1,68 @@ +#!/usr/bin/python3 + +""" +Usage: snap-seed-parse [${chroot_dir}] + +This script looks for a seed.yaml path in the given root directory, parsing +it and appending the parsed lines to the given output file. + +The $chroot_dir argument is optional and will default to the empty string. +""" + +import argparse +import os.path +import re +import yaml + + +def log(msg): + print("snap-seed-parse: {}".format(msg)) + + +log("Parsing seed.yaml") + +parser = argparse.ArgumentParser() +parser.add_argument('chroot', nargs='?', default='', + help='root dir for the chroot from which to generate the ' + 'manifest') +parser.add_argument('file', help='Output manifest to this file') + +ARGS = parser.parse_args() +CHROOT_ROOT = ARGS.chroot +FNAME = ARGS.file + +# 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'] + +log('Writing manifest to {}'.format(FNAME)) + +with open(FNAME, 'a+') as fh: + 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) + fh.write("{}{}\t{}\t{}\n".format(LINE_PREFIX, + item['name'], + item['channel'], + revision, + )) +log('Manifest output finished.') From ac8e88866d20ee6a43e9d45a2820a66cafbe01be Mon Sep 17 00:00:00 2001 From: Cody Shepherd Date: Tue, 27 Nov 2018 11:52:40 -0800 Subject: [PATCH 4/4] Adding bug number to changelog. --- debian/changelog | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index d00e4c0e..0aa55d70 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -livecd-rootfs (2.525.10ubuntu2) UNRELEASED; urgency=medium +livecd-rootfs (2.525.10ubuntu3) UNRELEASED; urgency=medium - * Include snaps in image manifests + * Include snaps in image manifests (LP: #1805497) * Change call to add grub efi packages using new create_manifests() function. - -- Cody Shepherd Tue, 27 Nov 2018 11:29:23 -0800 + -- Cody Shepherd Tue, 27 Nov 2018 11:51:32 -0800 livecd-rootfs (2.525.10) bionic; urgency=medium