Changes to add snaps to manifests

This commit is contained in:
Cody Shepherd 2018-10-15 13:47:07 -07:00
parent e453f96548
commit 5bd200fd7a
No known key found for this signature in database
GPG Key ID: 0DB7E5F05C3FAB5F
5 changed files with 50 additions and 2 deletions

View File

@ -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

View File

@ -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}"}

37
live-build/snap_seed_parse.py Executable file
View File

@ -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'))

View File

@ -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

View File

@ -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} \