Merge lp:~codyshepherd/livecd-rootfs/snaps-manifest into lp:livecd-rootfs

Proposed by Cody Shepherd
Status: Merged
Merged at revision: 1706
Proposed branch: lp:~codyshepherd/livecd-rootfs/snaps-manifest
Merge into: lp:livecd-rootfs
Diff against target: 143 lines (+77/-2)
7 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 (+56/-0)
live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary (+1/-1)
live-build/ubuntu-server/hooks/030-root-squashfs.binary (+1/-1)
To merge this branch: bzr merge lp:~codyshepherd/livecd-rootfs/snaps-manifest
Reviewer Review Type Date Requested Status
Steve Langasek Needs Fixing
Robert C Jennings (community) Approve
Ubuntu Core Development Team Pending
Review via email: mp+357652@code.launchpad.net

Commit message

These changes ensure pre-seeded snaps are included in the image manifests.

Test builds have confirmed that manifests now include lines for snaps.

To post a comment you must log in.
Revision history for this message
Robert C Jennings (rcj) wrote :

This has been tested and used to provide snaps in the manifests for cosmic cloud-images. +1

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

oops, meant for that to be a core-dev review rather than a cloudware review.

Revision history for this message
Cody Shepherd (codyshepherd) wrote :

Thanks Steve! I pushed a couple changes in response to your comments.

1706. By Steve Langasek

Merge lp:~codyshepherd/livecd-rootfs/snaps-manifest

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-10-12 12:19:18 +0000
3+++ debian/changelog 2018-10-23 17:34:18 +0000
4@@ -1,3 +1,9 @@
5+livecd-rootfs (2.543) UNRELEASED; urgency=medium
6+
7+ * Ensure pre-seeded snaps are now published in the image manifests.
8+
9+ -- Cody Shepherd <cody.shepherd@canonical.com> Mon, 22 Oct 2018 10:16:19 -0700
10+
11 livecd-rootfs (2.542) cosmic; urgency=medium
12
13 * Decide what model assertion series to fetch depending on the suite. Use 16
14
15=== modified file 'live-build/auto/build'
16--- live-build/auto/build 2018-09-26 00:42:42 +0000
17+++ live-build/auto/build 2018-10-23 17:34:18 +0000
18@@ -551,6 +551,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-10-11 15:12:50 +0000
29+++ live-build/auto/config 2018-10-23 17:34:18 +0000
30@@ -33,6 +33,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-09-27 20:15:55 +0000
41+++ live-build/functions 2018-10-23 17:34:18 +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-10-23 17:34:18 +0000
64@@ -0,0 +1,56 @@
65+#!/usr/bin/python3
66+
67+"""
68+Usage: snap-seed-parse ${chroot_dir} > somefile.manifest
69+
70+This script looks for a seed.yaml path in the given root directory, parsing
71+it and printing generated manifest lines to stdout for easy redirection.
72+"""
73+
74+import re
75+import sys
76+import yaml
77+import os.path
78+
79+
80+def log(msg):
81+ sys.stderr.write("snap-seed-parse: {}\n".format(msg))
82+
83+
84+log("Parsing seed.yaml")
85+
86+CHROOT_ROOT = sys.argv[1] if len(sys.argv) > 1 and len(sys.argv[1]) > 0 \
87+ else ''
88+
89+# Trim any trailing slashes for correct appending
90+log("CHROOT_ROOT: {}".format(CHROOT_ROOT))
91+if len(CHROOT_ROOT) > 0 and CHROOT_ROOT[-1] == '/':
92+ CHROOT_ROOT = CHROOT_ROOT[:-1]
93+
94+# This is where we expect to find the seed.yaml file
95+YAML_PATH = CHROOT_ROOT + '/var/lib/snapd/seed/seed.yaml'
96+
97+# Snaps are prepended with this string in the manifest
98+LINE_PREFIX = 'snap:'
99+
100+log("yaml path: {}".format(YAML_PATH))
101+if not os.path.isfile(YAML_PATH):
102+ log("WARNING: yaml path not found; no seeded snaps found.")
103+ exit(0)
104+else:
105+ log("yaml path found.")
106+
107+with open(YAML_PATH, 'r') as fh:
108+ yaml_lines = yaml.safe_load(fh)['snaps']
109+
110+# Loop over dict items, outputting one manifest line from each triplet
111+for item in yaml_lines:
112+ filestring = item['file']
113+ # Pull the revision number off the file name
114+ revision = filestring[filestring.rindex('_')+1:]
115+ revision = re.sub(r'[^0-9]', '', revision)
116+ print("{}{}\t{}\t{}".format(LINE_PREFIX,
117+ item['name'],
118+ item['channel'],
119+ revision,
120+ ))
121
122=== modified file 'live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary'
123--- live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary 2018-09-20 11:37:25 +0000
124+++ live-build/ubuntu-cpc/hooks/031-0-create-root-dir.binary 2018-10-23 17:34:18 +0000
125@@ -26,4 +26,4 @@
126
127 teardown_mountpoint $rootfs_dir
128
129-dpkg-query --admindir=$rootfs_dir/var/lib/dpkg -W > $rootfs_dir.manifest
130+create_manifest "${rootfs_dir}" "${rootfs_dir}.manifest"
131
132=== modified file 'live-build/ubuntu-server/hooks/030-root-squashfs.binary'
133--- live-build/ubuntu-server/hooks/030-root-squashfs.binary 2017-06-14 16:25:11 +0000
134+++ live-build/ubuntu-server/hooks/030-root-squashfs.binary 2018-10-23 17:34:18 +0000
135@@ -28,7 +28,7 @@
136 squashfs_f="${PWD}/livecd.${PROJECT}.squashfs"
137 squashfs_f_manifest="${squashfs_f}.manifest"
138
139-dpkg-query --admindir=binary/boot/squashfs.dir/var/lib/dpkg -W > ${squashfs_f_manifest}
140+create_manifest "binary/boot/squashfs.dir" "${squashfs_f_manifest}"
141
142 (cd "binary/boot/squashfs.dir/" &&
143 mksquashfs . ${squashfs_f} \

Subscribers

People subscribed via source and target branches