diff --git a/live-build/auto/build b/live-build/auto/build index 4b6fdc2e..ce32376c 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -551,6 +551,7 @@ fi # '--initramfs none' produces different manifest names. if [ -e "binary/$INITFS/filesystem.packages" ]; then + ./snap_seed_parse.py $CHROOT_ROOT >> "binary/$INITFS/filesystem.packages" ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest" chmod 644 "$PREFIX.manifest" fi diff --git a/live-build/functions b/live-build/functions index cf68ba16..393b79e2 100644 --- a/live-build/functions +++ b/live-build/functions @@ -43,6 +43,14 @@ create_empty_disk_image() { dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}" } +create_manifest() { + local dpkg_opts=$1 + local target_file=$2 + local chroot_root=$3 + dpkg-query $dpkg_opts > $target_file + ./snap_seed_parse.py $chroot_root >> $target_file +} + 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..0921248c --- /dev/null +++ b/live-build/snap_seed_parse.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 + +""" +This file parses the seed.yaml file for the chroot and appends it to the +given manifest file. +""" + +import re +import sys +import yaml + +CHROOT_ROOT = sys.argv[1] if len(sys.argv) > 1 else '' +'''The chroot rooth path should be passed in by the caller''' +YAML_PATH = str(CHROOT_ROOT) + 'var/lib/snapd/seed/seed.yaml' +'''This is where we expect to find the seed.yaml file''' +LINE_PREFIX = 'snap:' +'''Snaps are prepended with this string in the manifest''' + +# Open the seed.yaml and ingest its contents +with open(YAML_PATH, 'r') as fh: + yaml_lines = yaml.load(fh)['snaps'] + +to_write = '' +# Loop over dict items, generating one manifest line from each +# triplet +for item in yaml_lines: + filestring = item['file'] + revision = filestring[filestring.rindex('_')+1:] + revision = re.sub(r'[^0-9]', '', revision) + to_write += "{}{}\t{}\t{}\n".format(LINE_PREFIX, + item['name'], + item['channel'], + revision, + ) + +# write accumulated text to stdout for redirection +print(to_write.strip('\n')) 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..9b7266d1 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,5 @@ mkdir -p $rootfs_dir/lib/modules teardown_mountpoint $rootfs_dir -dpkg-query --admindir=$rootfs_dir/var/lib/dpkg -W > $rootfs_dir.manifest +# dpkg-query --admindir=$rootfs_dir/var/lib/dpkg -W > $rootfs_dir.manifest +create_manifest "--admindir=$rootfs_dir/var/lib/dpkg -W" "$rootfs_dir.manifest" $roofs_dir diff --git a/live-build/ubuntu-server/hooks/030-root-squashfs.binary b/live-build/ubuntu-server/hooks/030-root-squashfs.binary index ad34e76a..6145f235 100755 --- a/live-build/ubuntu-server/hooks/030-root-squashfs.binary +++ b/live-build/ubuntu-server/hooks/030-root-squashfs.binary @@ -28,7 +28,8 @@ 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} +# dpkg-query --admindir=binary/boot/squashfs.dir/var/lib/dpkg -W > ${squashfs_f_manifest} +create_manifest "--admindir=binary/boot/squashfs.dir/var/lib/dpkg -W" "${squashfs_f_manifest}" "binary/boot/squashfs.dir" (cd "binary/boot/squashfs.dir/" && mksquashfs . ${squashfs_f} \