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
1=== modified file 'debian/changelog'
2--- debian/changelog 2018-11-26 20:55:29 +0000
3+++ debian/changelog 2018-11-27 19:53:09 +0000
4@@ -1,3 +1,11 @@
5+livecd-rootfs (2.525.10ubuntu3) UNRELEASED; urgency=medium
6+
7+ * Include snaps in image manifests (LP: #1805497)
8+ * Change call to add grub efi packages using new create_manifests()
9+ function.
10+
11+ -- Cody Shepherd <cody.shepherd@canonical.com> Tue, 27 Nov 2018 11:51:32 -0800
12+
13 livecd-rootfs (2.525.10) bionic; urgency=medium
14
15 [ Cody Shepherd ]
16
17=== modified file 'live-build/auto/build'
18--- live-build/auto/build 2018-08-27 22:32:07 +0000
19+++ live-build/auto/build 2018-11-27 19:53:09 +0000
20@@ -503,6 +503,7 @@
21
22 # '--initramfs none' produces different manifest names.
23 if [ -e "binary/$INITFS/filesystem.packages" ]; then
24+ ./config/snap-seed-parse "chroot/" "binary/${INITFS}/filesystem.packages"
25 ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest"
26 chmod 644 "$PREFIX.manifest"
27 fi
28
29=== modified file 'live-build/auto/config'
30--- live-build/auto/config 2018-10-24 19:18:36 +0000
31+++ live-build/auto/config 2018-11-27 19:53:09 +0000
32@@ -33,6 +33,7 @@
33
34 mkdir -p config
35 cp -af /usr/share/livecd-rootfs/live-build/functions config/functions
36+cp -af /usr/share/livecd-rootfs/live-build/snap-seed-parse.py config/snap-seed-parse
37
38 mkdir -p config/package-lists
39
40
41=== modified file 'live-build/functions'
42--- live-build/functions 2018-04-19 00:01:40 +0000
43+++ live-build/functions 2018-11-27 19:53:09 +0000
44@@ -43,6 +43,17 @@
45 dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}"
46 }
47
48+create_manifest() {
49+ local chroot_root=${1}
50+ local target_file=${2}
51+ echo "create_manifest chroot_root: ${chroot_root}"
52+ dpkg-query --show --admindir="${chroot_root}/var/lib/dpkg" > ${target_file}
53+ echo "create_manifest call to dpkg-query finished."
54+ ./config/snap-seed-parse "${chroot_root}" "${target_file}"
55+ echo "create_manifest call to snap_seed_parse finished."
56+ echo "create_manifest finished"
57+}
58+
59 make_ext4_partition() {
60 device="$1"
61 label=${fs_label:+-L "${fs_label}"}
62
63=== added file 'live-build/snap-seed-parse.py'
64--- live-build/snap-seed-parse.py 1970-01-01 00:00:00 +0000
65+++ live-build/snap-seed-parse.py 2018-11-27 19:53:09 +0000
66@@ -0,0 +1,68 @@
67+#!/usr/bin/python3
68+
69+"""
70+Usage: snap-seed-parse [${chroot_dir}] <output file>
71+
72+This script looks for a seed.yaml path in the given root directory, parsing
73+it and appending the parsed lines to the given output file.
74+
75+The $chroot_dir argument is optional and will default to the empty string.
76+"""
77+
78+import argparse
79+import os.path
80+import re
81+import yaml
82+
83+
84+def log(msg):
85+ print("snap-seed-parse: {}".format(msg))
86+
87+
88+log("Parsing seed.yaml")
89+
90+parser = argparse.ArgumentParser()
91+parser.add_argument('chroot', nargs='?', default='',
92+ help='root dir for the chroot from which to generate the '
93+ 'manifest')
94+parser.add_argument('file', help='Output manifest to this file')
95+
96+ARGS = parser.parse_args()
97+CHROOT_ROOT = ARGS.chroot
98+FNAME = ARGS.file
99+
100+# Trim any trailing slashes for correct appending
101+log("CHROOT_ROOT: {}".format(CHROOT_ROOT))
102+if len(CHROOT_ROOT) > 0 and CHROOT_ROOT[-1] == '/':
103+ CHROOT_ROOT = CHROOT_ROOT[:-1]
104+
105+# This is where we expect to find the seed.yaml file
106+YAML_PATH = CHROOT_ROOT + '/var/lib/snapd/seed/seed.yaml'
107+
108+# Snaps are prepended with this string in the manifest
109+LINE_PREFIX = 'snap:'
110+
111+log("yaml path: {}".format(YAML_PATH))
112+if not os.path.isfile(YAML_PATH):
113+ log("WARNING: yaml path not found; no seeded snaps found.")
114+ exit(0)
115+else:
116+ log("yaml path found.")
117+
118+with open(YAML_PATH, 'r') as fh:
119+ yaml_lines = yaml.safe_load(fh)['snaps']
120+
121+log('Writing manifest to {}'.format(FNAME))
122+
123+with open(FNAME, 'a+') as fh:
124+ for item in yaml_lines:
125+ filestring = item['file']
126+ # Pull the revision number off the file name
127+ revision = filestring[filestring.rindex('_')+1:]
128+ revision = re.sub(r'[^0-9]', '', revision)
129+ fh.write("{}{}\t{}\t{}\n".format(LINE_PREFIX,
130+ item['name'],
131+ item['channel'],
132+ revision,
133+ ))
134+log('Manifest output finished.')
135
136=== modified file 'live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary'
137--- live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary 2018-09-20 11:43:39 +0000
138+++ live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary 2018-11-27 19:53:09 +0000
139@@ -26,4 +26,4 @@
140
141 teardown_mountpoint $rootfs_dir
142
143-dpkg-query --admindir=$rootfs_dir/var/lib/dpkg -W > $rootfs_dir.manifest
144+create_manifest "${rootfs_dir}" "${rootfs_dir}.manifest"
145
146=== modified file 'live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary'
147--- live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary 2018-10-25 16:22:46 +0000
148+++ live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary 2018-11-27 19:53:09 +0000
149@@ -97,7 +97,7 @@
150 # grub-efi packages that otherwise would not make it into the base
151 # manifest. filesystem.packages is moved into place via symlinking to
152 # livecd.ubuntu-cpc.manifest by live-build/auto/build after lb_binary runs
153- dpkg-query --show --admindir="mountpoint/var/lib/dpkg" > "binary/boot/filesystem.packages"
154+ create_manifest "mountpoint" "binary/boot/filesystem.packages"
155
156 chroot mountpoint grub-install "${loop_device}" \
157 --boot-directory=/boot \
158
159=== modified file 'live-build/ubuntu-server/hooks/030-root-squashfs.binary'
160--- live-build/ubuntu-server/hooks/030-root-squashfs.binary 2017-06-14 16:25:11 +0000
161+++ live-build/ubuntu-server/hooks/030-root-squashfs.binary 2018-11-27 19:53:09 +0000
162@@ -28,7 +28,7 @@
163 squashfs_f="${PWD}/livecd.${PROJECT}.squashfs"
164 squashfs_f_manifest="${squashfs_f}.manifest"
165
166-dpkg-query --admindir=binary/boot/squashfs.dir/var/lib/dpkg -W > ${squashfs_f_manifest}
167+create_manifest "binary/boot/squashfs.dir" "${squashfs_f_manifest}"
168
169 (cd "binary/boot/squashfs.dir/" &&
170 mksquashfs . ${squashfs_f} \

Subscribers

People subscribed via source and target branches