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

Proposed by Cody Shepherd on 2018-11-27
Status: Merged
Merged at revision: 1475
Proposed branch: lp:~codyshepherd/livecd-rootfs/xenial-proposed-snaps-manifest
Merge into: lp:~ubuntu-core-dev/livecd-rootfs/xenial-proposed
Diff against target: 149 lines (+93/-0)
6 files modified
debian/changelog (+6/-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/033-disk-image-uefi.binary (+6/-0)
To merge this branch: bzr merge lp:~codyshepherd/livecd-rootfs/xenial-proposed-snaps-manifest
Reviewer Review Type Date Requested Status
Steve Langasek 2018-11-27 Approve on 2018-12-10
Robert C Jennings (community) Approve on 2018-12-10
Dan Watkins (community) 2018-11-27 Approve on 2018-12-06
Review via email: mp+359649@code.launchpad.net

Commit message

Backport adding snaps to image manifests. LP: #1805497

Description of the change

Backport adding snaps to image manifests. LP: #1805497

To post a comment you must log in.
Steve Langasek (vorlon) wrote :

Sorry, the branch was out of date, it appears I failed to push after uploading 2.408.41. Can you fix up the changelog and resubmit?

Please note also that this is an Ubuntu-native package and debian/changelog should be generated using dch -U.

review: Needs Fixing
1476. By Cody Shepherd on 2018-11-29

Rebase

review: Approve
Robert C Jennings (rcj) wrote :

Thanks Cody, this looks good

review: Approve
Steve Langasek (vorlon) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2018-11-16 16:38:28 +0000
3+++ debian/changelog 2018-11-29 15:35:00 +0000
4@@ -1,3 +1,9 @@
5+livecd-rootfs (2.408.42) UNRELEASED; urgency=medium
6+
7+ * Backport adding snaps to image manifests (LP: #1805497)
8+
9+ -- Cody Shepherd <cody.shepherd@canonical.com> Thu, 29 Nov 2018 07:32:46 -0800
10+
11 livecd-rootfs (2.408.41) xenial; urgency=medium
12
13 * Disable checksum generation (LP: #1799773)
14
15=== modified file 'live-build/auto/build'
16--- live-build/auto/build 2018-10-29 16:57:43 +0000
17+++ live-build/auto/build 2018-11-29 15:35:00 +0000
18@@ -441,6 +441,7 @@
19
20 # '--initramfs none' produces different manifest names.
21 if [ -e "binary/$INITFS/filesystem.packages" ]; then
22+ ./config/snap-seed-parse "chroot/" "binary/${INITFS}/filesystem.packages"
23 ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest"
24 chmod 644 "$PREFIX.manifest"
25 fi
26
27=== modified file 'live-build/auto/config'
28--- live-build/auto/config 2018-11-16 16:37:10 +0000
29+++ live-build/auto/config 2018-11-29 15:35:00 +0000
30@@ -35,6 +35,7 @@
31
32 mkdir -p config
33 cp -af /usr/share/livecd-rootfs/live-build/functions config/functions
34+cp -af /usr/share/livecd-rootfs/live-build/snap-seed-parse.py config/snap-seed-parse
35
36 mkdir -p config/package-lists
37
38
39=== modified file 'live-build/functions'
40--- live-build/functions 2018-10-31 20:37:44 +0000
41+++ live-build/functions 2018-11-29 15:35:00 +0000
42@@ -43,6 +43,17 @@
43 dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}"
44 }
45
46+create_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+
57 make_ext4_partition() {
58 device="$1"
59 label=${fs_label:+-L "${fs_label}"}
60
61=== added file 'live-build/snap-seed-parse.py'
62--- live-build/snap-seed-parse.py 1970-01-01 00:00:00 +0000
63+++ live-build/snap-seed-parse.py 2018-11-29 15:35:00 +0000
64@@ -0,0 +1,68 @@
65+#!/usr/bin/python3
66+
67+"""
68+Usage: snap-seed-parse [${chroot_dir}] <output file>
69+
70+This script looks for a seed.yaml path in the given root directory, parsing
71+it and appending the parsed lines to the given output file.
72+
73+The $chroot_dir argument is optional and will default to the empty string.
74+"""
75+
76+import argparse
77+import os.path
78+import re
79+import yaml
80+
81+
82+def log(msg):
83+ print("snap-seed-parse: {}".format(msg))
84+
85+
86+log("Parsing seed.yaml")
87+
88+parser = argparse.ArgumentParser()
89+parser.add_argument('chroot', nargs='?', default='',
90+ help='root dir for the chroot from which to generate the '
91+ 'manifest')
92+parser.add_argument('file', help='Output manifest to this file')
93+
94+ARGS = parser.parse_args()
95+CHROOT_ROOT = ARGS.chroot
96+FNAME = ARGS.file
97+
98+# Trim any trailing slashes for correct appending
99+log("CHROOT_ROOT: {}".format(CHROOT_ROOT))
100+if len(CHROOT_ROOT) > 0 and CHROOT_ROOT[-1] == '/':
101+ CHROOT_ROOT = CHROOT_ROOT[:-1]
102+
103+# This is where we expect to find the seed.yaml file
104+YAML_PATH = CHROOT_ROOT + '/var/lib/snapd/seed/seed.yaml'
105+
106+# Snaps are prepended with this string in the manifest
107+LINE_PREFIX = 'snap:'
108+
109+log("yaml path: {}".format(YAML_PATH))
110+if not os.path.isfile(YAML_PATH):
111+ log("WARNING: yaml path not found; no seeded snaps found.")
112+ exit(0)
113+else:
114+ log("yaml path found.")
115+
116+with open(YAML_PATH, 'r') as fh:
117+ yaml_lines = yaml.safe_load(fh)['snaps']
118+
119+log('Writing manifest to {}'.format(FNAME))
120+
121+with open(FNAME, 'a+') as fh:
122+ for item in yaml_lines:
123+ filestring = item['file']
124+ # Pull the revision number off the file name
125+ revision = filestring[filestring.rindex('_')+1:]
126+ revision = re.sub(r'[^0-9]', '', revision)
127+ fh.write("{}{}\t{}\t{}\n".format(LINE_PREFIX,
128+ item['name'],
129+ item['channel'],
130+ revision,
131+ ))
132+log('Manifest output finished.')
133
134=== modified file 'live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary'
135--- live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary 2018-06-08 00:35:12 +0000
136+++ live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary 2018-11-29 15:35:00 +0000
137@@ -98,6 +98,12 @@
138 GRUB_PRELOAD_MODULES="${GRUB_PRELOAD_MODULES:-$grub_modules}"
139 EOF
140
141+ # This call to populate the package manifest is added here to capture
142+ # grub-efi packages that otherwise would not make it into the base
143+ # manifest. filesystem.packages is moved into place via symlinking to
144+ # livecd.ubuntu-cpc.manifest by live-build/auto/build after lb_binary runs
145+ create_manifest "mountpoint" "binary/boot/filesystem.packages"
146+
147 chroot mountpoint grub-install "${loop_device}" \
148 --boot-directory=/boot \
149 --efi-directory=/boot/efi \

Subscribers

People subscribed via source and target branches