Merge lp:~codyshepherd/livecd-rootfs/bionic-proposed-snaps-manifest into lp:~ubuntu-core-dev/livecd-rootfs/bionic-proposed

Proposed by Cody Shepherd
Status: Merged
Merged at revision: 1693
Proposed branch: lp:~codyshepherd/livecd-rootfs/bionic-proposed-snaps-manifest
Merge into: lp:~ubuntu-core-dev/livecd-rootfs/bionic-proposed
Diff against target: 170 lines (+92/-3)
8 files modified
debian/changelog (+8/-0)
live-build/auto/build (+1/-0)
live-build/auto/config (+1/-0)
live-build/functions (+11/-0)
live-build/snap-seed-parse.py (+68/-0)
live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary (+1/-1)
live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary (+1/-1)
live-build/ubuntu-server/hooks/030-root-squashfs.binary (+1/-1)
To merge this branch: bzr merge lp:~codyshepherd/livecd-rootfs/bionic-proposed-snaps-manifest
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Robert C Jennings (community) Approve
Dan Watkins (community) Approve
Review via email: mp+359645@code.launchpad.net

Commit message

Backport inclusion of snaps in image manifests. LP: #1805497.

Description of the change

Backport inclusion of snaps in image manifests. LP: #1805497.

To post a comment you must log in.
1692. By Cody Shepherd

Adding snap-seed-parse.py (that might help)

1693. By Cody Shepherd

Adding bug number to changelog.

Revision history for this message
Dan Watkins (oddbloke) :
review: Approve
Revision history for this message
Robert C Jennings (rcj) wrote :

Nice clean backport, looking forward to having this for the build system

review: Approve
Revision history for this message
Steve Langasek (vorlon) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2018-11-26 20:55:29 +0000
+++ debian/changelog 2018-11-27 19:53:09 +0000
@@ -1,3 +1,11 @@
1livecd-rootfs (2.525.10ubuntu3) UNRELEASED; urgency=medium
2
3 * Include snaps in image manifests (LP: #1805497)
4 * Change call to add grub efi packages using new create_manifests()
5 function.
6
7 -- Cody Shepherd <cody.shepherd@canonical.com> Tue, 27 Nov 2018 11:51:32 -0800
8
1livecd-rootfs (2.525.10) bionic; urgency=medium9livecd-rootfs (2.525.10) bionic; urgency=medium
210
3 [ Cody Shepherd ]11 [ Cody Shepherd ]
412
=== modified file 'live-build/auto/build'
--- live-build/auto/build 2018-08-27 22:32:07 +0000
+++ live-build/auto/build 2018-11-27 19:53:09 +0000
@@ -503,6 +503,7 @@
503503
504# '--initramfs none' produces different manifest names.504# '--initramfs none' produces different manifest names.
505if [ -e "binary/$INITFS/filesystem.packages" ]; then505if [ -e "binary/$INITFS/filesystem.packages" ]; then
506 ./config/snap-seed-parse "chroot/" "binary/${INITFS}/filesystem.packages"
506 ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest"507 ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest"
507 chmod 644 "$PREFIX.manifest"508 chmod 644 "$PREFIX.manifest"
508fi509fi
509510
=== modified file 'live-build/auto/config'
--- live-build/auto/config 2018-10-24 19:18:36 +0000
+++ live-build/auto/config 2018-11-27 19:53:09 +0000
@@ -33,6 +33,7 @@
3333
34mkdir -p config34mkdir -p config
35cp -af /usr/share/livecd-rootfs/live-build/functions config/functions35cp -af /usr/share/livecd-rootfs/live-build/functions config/functions
36cp -af /usr/share/livecd-rootfs/live-build/snap-seed-parse.py config/snap-seed-parse
3637
37mkdir -p config/package-lists38mkdir -p config/package-lists
3839
3940
=== modified file 'live-build/functions'
--- live-build/functions 2018-04-19 00:01:40 +0000
+++ live-build/functions 2018-11-27 19:53:09 +0000
@@ -43,6 +43,17 @@
43 dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}"43 dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}"
44}44}
4545
46create_manifest() {
47 local chroot_root=${1}
48 local target_file=${2}
49 echo "create_manifest chroot_root: ${chroot_root}"
50 dpkg-query --show --admindir="${chroot_root}/var/lib/dpkg" > ${target_file}
51 echo "create_manifest call to dpkg-query finished."
52 ./config/snap-seed-parse "${chroot_root}" "${target_file}"
53 echo "create_manifest call to snap_seed_parse finished."
54 echo "create_manifest finished"
55}
56
46make_ext4_partition() {57make_ext4_partition() {
47 device="$1"58 device="$1"
48 label=${fs_label:+-L "${fs_label}"}59 label=${fs_label:+-L "${fs_label}"}
4960
=== added file 'live-build/snap-seed-parse.py'
--- live-build/snap-seed-parse.py 1970-01-01 00:00:00 +0000
+++ live-build/snap-seed-parse.py 2018-11-27 19:53:09 +0000
@@ -0,0 +1,68 @@
1#!/usr/bin/python3
2
3"""
4Usage: snap-seed-parse [${chroot_dir}] <output file>
5
6This script looks for a seed.yaml path in the given root directory, parsing
7it and appending the parsed lines to the given output file.
8
9The $chroot_dir argument is optional and will default to the empty string.
10"""
11
12import argparse
13import os.path
14import re
15import yaml
16
17
18def log(msg):
19 print("snap-seed-parse: {}".format(msg))
20
21
22log("Parsing seed.yaml")
23
24parser = argparse.ArgumentParser()
25parser.add_argument('chroot', nargs='?', default='',
26 help='root dir for the chroot from which to generate the '
27 'manifest')
28parser.add_argument('file', help='Output manifest to this file')
29
30ARGS = parser.parse_args()
31CHROOT_ROOT = ARGS.chroot
32FNAME = ARGS.file
33
34# Trim any trailing slashes for correct appending
35log("CHROOT_ROOT: {}".format(CHROOT_ROOT))
36if len(CHROOT_ROOT) > 0 and CHROOT_ROOT[-1] == '/':
37 CHROOT_ROOT = CHROOT_ROOT[:-1]
38
39# This is where we expect to find the seed.yaml file
40YAML_PATH = CHROOT_ROOT + '/var/lib/snapd/seed/seed.yaml'
41
42# Snaps are prepended with this string in the manifest
43LINE_PREFIX = 'snap:'
44
45log("yaml path: {}".format(YAML_PATH))
46if not os.path.isfile(YAML_PATH):
47 log("WARNING: yaml path not found; no seeded snaps found.")
48 exit(0)
49else:
50 log("yaml path found.")
51
52with open(YAML_PATH, 'r') as fh:
53 yaml_lines = yaml.safe_load(fh)['snaps']
54
55log('Writing manifest to {}'.format(FNAME))
56
57with open(FNAME, 'a+') as fh:
58 for item in yaml_lines:
59 filestring = item['file']
60 # Pull the revision number off the file name
61 revision = filestring[filestring.rindex('_')+1:]
62 revision = re.sub(r'[^0-9]', '', revision)
63 fh.write("{}{}\t{}\t{}\n".format(LINE_PREFIX,
64 item['name'],
65 item['channel'],
66 revision,
67 ))
68log('Manifest output finished.')
069
=== modified file 'live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary'
--- live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary 2018-09-20 11:43:39 +0000
+++ live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary 2018-11-27 19:53:09 +0000
@@ -26,4 +26,4 @@
2626
27teardown_mountpoint $rootfs_dir27teardown_mountpoint $rootfs_dir
2828
29dpkg-query --admindir=$rootfs_dir/var/lib/dpkg -W > $rootfs_dir.manifest29create_manifest "${rootfs_dir}" "${rootfs_dir}.manifest"
3030
=== modified file 'live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary'
--- live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary 2018-10-25 16:22:46 +0000
+++ live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary 2018-11-27 19:53:09 +0000
@@ -97,7 +97,7 @@
97 # grub-efi packages that otherwise would not make it into the base97 # grub-efi packages that otherwise would not make it into the base
98 # manifest. filesystem.packages is moved into place via symlinking to98 # manifest. filesystem.packages is moved into place via symlinking to
99 # livecd.ubuntu-cpc.manifest by live-build/auto/build after lb_binary runs99 # livecd.ubuntu-cpc.manifest by live-build/auto/build after lb_binary runs
100 dpkg-query --show --admindir="mountpoint/var/lib/dpkg" > "binary/boot/filesystem.packages"100 create_manifest "mountpoint" "binary/boot/filesystem.packages"
101101
102 chroot mountpoint grub-install "${loop_device}" \102 chroot mountpoint grub-install "${loop_device}" \
103 --boot-directory=/boot \103 --boot-directory=/boot \
104104
=== modified file 'live-build/ubuntu-server/hooks/030-root-squashfs.binary'
--- live-build/ubuntu-server/hooks/030-root-squashfs.binary 2017-06-14 16:25:11 +0000
+++ live-build/ubuntu-server/hooks/030-root-squashfs.binary 2018-11-27 19:53:09 +0000
@@ -28,7 +28,7 @@
28squashfs_f="${PWD}/livecd.${PROJECT}.squashfs"28squashfs_f="${PWD}/livecd.${PROJECT}.squashfs"
29squashfs_f_manifest="${squashfs_f}.manifest"29squashfs_f_manifest="${squashfs_f}.manifest"
3030
31dpkg-query --admindir=binary/boot/squashfs.dir/var/lib/dpkg -W > ${squashfs_f_manifest}31create_manifest "binary/boot/squashfs.dir" "${squashfs_f_manifest}"
3232
33(cd "binary/boot/squashfs.dir/" &&33(cd "binary/boot/squashfs.dir/" &&
34 mksquashfs . ${squashfs_f} \34 mksquashfs . ${squashfs_f} \

Subscribers

People subscribed via source and target branches