Merge lp:~laney/livecd-rootfs/snap-seeding into lp:livecd-rootfs

Proposed by Iain Lane
Status: Merged
Merged at revision: 1603
Proposed branch: lp:~laney/livecd-rootfs/snap-seeding
Merge into: lp:livecd-rootfs
Diff against target: 230 lines (+95/-80)
2 files modified
live-build/auto/build (+32/-37)
live-build/auto/config (+63/-43)
To merge this branch: bzr merge lp:~laney/livecd-rootfs/snap-seeding
Reviewer Review Type Date Requested Status
Colin Watson Approve
Ubuntu Core Development Team Pending
Review via email: mp+334061@code.launchpad.net

Description of the change

This goes along with

  https://code.launchpad.net/~laney/germinate/+git/germinate/+merge/334039

and relies on its output format.

Please review, but I guess we should merge this after germinate.

Note that we run germinate for all builds now. It only takes a few seconds and it's easier to get its output into the logs if we do it this way, but if that's unacceptable we can make it happen on the first use of inheritance().

To post a comment you must log in.
Revision history for this message
Iain Lane (laney) :
Revision history for this message
Colin Watson (cjwatson) wrote :

This basically seems OK, but as I mentioned in the germinate MP I think it's worth thinking about what we're going to do about classic snaps before landing any of this.

review: Approve
lp:~laney/livecd-rootfs/snap-seeding updated
1586. By Iain Lane

Support seeding of snaps

We run germinate during configure, and read from each resulting <seed>.snaps
file (expanded from STRUCTURE) to find out which snaps to seed. This is written
to config/seeded-snaps, which is read during build to download each one.

Revision history for this message
Iain Lane (laney) wrote :

Pushed an update to deal with "(classic)" and output this as "classic: true" in the corresponding seed.yaml stanza - please re-review.

Revision history for this message
Colin Watson (cjwatson) wrote :

Looks like it should do for now. Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'live-build/auto/build'
2--- live-build/auto/build 2017-12-11 12:22:31 +0000
3+++ live-build/auto/build 2018-01-04 12:13:16 +0000
4@@ -42,7 +42,7 @@
5 chroot chroot sh -c "
6 set -x;
7 cd /var/lib/snapd/seed;
8- SNAPPY_STORE_NO_CDN=1 snap download \"$snap\""
9+ SNAPPY_STORE_NO_CDN=1 snap download \"${snap%/*}\""
10 done
11 lb chroot_resolv remove
12
13@@ -55,12 +55,14 @@
14 file: ${CORE_SNAP}
15 EOF
16 for snap in "$@"; do
17+ snap_name=${snap%/*}
18 cat <<EOF >> chroot/var/lib/snapd/seed/seed.yaml
19- - name: $snap
20+ - name: ${snap_name}
21 channel: stable
22 EOF
23+ case ${snap} in */classic) echo " classic: true" >> chroot/var/lib/snapd/seed/seed.yaml;; esac
24 echo -n " file: " >> chroot/var/lib/snapd/seed/seed.yaml
25- (cd chroot/var/lib/snapd/seed; ls -1 ${snap}_*.snap) \
26+ (cd chroot/var/lib/snapd/seed; ls -1 ${snap_name}_*.snap) \
27 >> chroot/var/lib/snapd/seed/seed.yaml
28 done
29
30@@ -367,40 +369,33 @@
31 rm chroot/etc/apt/sources.list.preinstall chroot/etc/apt/sources.list.orig
32 fi
33 case $PROJECT:$SUBPROJECT in
34- ubuntu-server:live|ubuntu-mate:*)
35- assertions_dir="chroot/var/lib/snapd/seed/assertions"
36- model_assertion="$assertions_dir/generic-classic.model"
37- account_key_assertion="$assertions_dir/generic.account-key"
38- account_assertion="$assertions_dir/generic.account"
39-
40- mkdir -p "$assertions_dir"
41- snap known --remote model series=16 \
42- model=generic-classic brand-id=generic \
43- > "$model_assertion"
44- account_key=$(sed -n -e's/sign-key-sha3-384: //p' \
45- < "$model_assertion")
46-
47- snap known --remote account-key \
48- public-key-sha3-384="$account_key" \
49- > "$account_key_assertion"
50- account=$(sed -n -e's/account-id: //p' \
51- < "$account_key_assertion")
52-
53- snap known --remote account account-id=generic \
54- > "$account_assertion"
55- ;;
56- esac
57-
58- # FIXME: this should not be a hard-coded list in this script; this
59- # is an interim solution for 17.10.
60- case $PROJECT:$SUBPROJECT in
61- ubuntu-mate:*)
62- SNAP_LIST=pulsemixer
63- ;;
64- esac
65- if [ -n "$SNAP_LIST" ]; then
66- preinstall_snaps $SNAP_LIST
67- fi
68+ *)
69+ if [ -e "config/seeded-snaps" ]; then
70+ assertions_dir="chroot/var/lib/snapd/seed/assertions"
71+ model_assertion="$assertions_dir/generic-classic.model"
72+ account_key_assertion="$assertions_dir/generic.account-key"
73+ account_assertion="$assertions_dir/generic.account"
74+
75+ mkdir -p "$assertions_dir"
76+ snap known --remote model series=16 \
77+ model=generic-classic brand-id=generic \
78+ > "$model_assertion"
79+ account_key=$(sed -n -e's/sign-key-sha3-384: //p' \
80+ < "$model_assertion")
81+
82+ snap known --remote account-key \
83+ public-key-sha3-384="$account_key" \
84+ > "$account_key_assertion"
85+ account=$(sed -n -e's/account-id: //p' \
86+ < "$account_key_assertion")
87+
88+ snap known --remote account account-id=generic \
89+ > "$account_assertion"
90+ snap_list=$(cat config/seeded-snaps)
91+ preinstall_snaps $snap_list
92+ fi
93+ ;;
94+ esac
95
96 if [ "$PROJECT" = "ubuntu-touch" ] || [ "$PROJECT" = "ubuntu-touch-custom" ]; then
97 if [ "$ARCH" = "armhf" ]; then
98
99=== modified file 'live-build/auto/config'
100--- live-build/auto/config 2017-11-23 19:27:16 +0000
101+++ live-build/auto/config 2018-01-04 12:13:16 +0000
102@@ -254,13 +254,76 @@
103 OPTS="${OPTS:+$OPTS }--bootstrap-flavour=minimal --linux-packages=linux-image"
104 fi
105
106+# cribbed from cdimage, perhaps this should be a small helper script in germinate?
107+add_inheritance () {
108+ case " $inherit " in
109+ *" $1 "*)
110+ ;;
111+ *)
112+ inherit="${inherit:+$inherit }$1"
113+ ;;
114+ esac
115+}
116+
117+expand_inheritance () {
118+ for seed in $(grep "^$1:" config/germinate-output/structure | cut -d: -f2); do
119+ expand_inheritance "$seed"
120+ done
121+ add_inheritance "$1"
122+}
123+
124+inheritance () {
125+ inherit=
126+ expand_inheritance "$1"
127+ echo "$inherit"
128+}
129+
130+mkdir -p config/germinate-output
131+case $PROJECT in
132+ kubuntu-active*)
133+ SEED=kubuntu-active.$SUITE
134+ ;;
135+ kubuntu*)
136+ SEED=kubuntu.$SUITE
137+ ;;
138+ xubuntu*)
139+ SEED=xubuntu.$SUITE
140+ ;;
141+ *)
142+ SEED=ubuntu.$SUITE
143+ ;;
144+esac
145+
146+if ! [ -e config/germinate-output/structure ]; then
147+ echo "Running germinate..."
148+ (cd config/germinate-output && germinate --no-rdepends --no-installer \
149+ -S $SEEDMIRROR -m $MIRROR -d $SUITE -s $SEED \
150+ ${COMPONENTS:+-c "$COMPONENTS"} -a $ARCH)
151+fi
152+
153 case $PROJECT in
154 ubuntu|ubuntu-dvd)
155 add_task install minimal standard ubuntu-desktop
156 LIVE_TASK='ubuntu-live'
157+ BASE_SEED='desktop'
158+ SEEDS_EXPANDED=$(inheritance ${BASE_SEED})
159 case $ARCH in
160 amd64) add_package live $SIGNED_KERNEL_PACKAGE ;;
161 esac
162+ for seed in ${SEEDS_EXPANDED}; do
163+ echo "snap: considering ${seed}"
164+ file=config/germinate-output/${seed}.snaps
165+ [ -e "${file}" ] || continue
166+ # extract the first column (snap package name) from germinate's output
167+ # translate the human-readable "foo (classic)" into a
168+ # more machine readable "foo/classic"
169+ seed_snaps=$(sed -rn '1,/-----/d;/-----/,$d; s/(.*) \|.*/\1/; s, \(classic\),/classic,; p' "${file}")
170+ for snap in ${seed_snaps}; do
171+ echo "snap: found ${snap}"
172+ ALL_SNAPS="${ALL_SNAPS:+${ALL_SNAPS} }${snap}"
173+ done
174+ done
175+ echo "${ALL_SNAPS}" > config/seeded-snaps
176 ;;
177
178 ubuntu-desktop-next)
179@@ -939,51 +1002,8 @@
180 ;;
181 esac
182
183-# cribbed from cdimage, perhaps this should be a small helper script in germinate?
184-add_inheritance () {
185- case " $inherit " in
186- *" $1 "*)
187- ;;
188- *)
189- inherit="${inherit:+$inherit }$1"
190- ;;
191- esac
192-}
193-
194-expand_inheritance () {
195- for seed in $(grep "^$1:" config/germinate-output/structure | cut -d: -f2); do
196- expand_inheritance "$seed"
197- done
198- add_inheritance "$1"
199-}
200-
201-inheritance () {
202- inherit=
203- expand_inheritance "$1"
204- echo "$inherit"
205-}
206-
207 if [ "$PREINSTALLED" = "true" ]; then
208 if [ -n "$PREINSTALL_POOL_SEEDS" ]; then
209- mkdir -p config/germinate-output
210- case $PROJECT in
211- kubuntu-active*)
212- SEED=kubuntu-active.$SUITE
213- ;;
214- kubuntu*)
215- SEED=kubuntu.$SUITE
216- ;;
217- xubuntu*)
218- SEED=xubuntu.$SUITE
219- ;;
220- *)
221- SEED=ubuntu.$SUITE
222- ;;
223- esac
224- (cd config/germinate-output && germinate --no-rdepends --no-installer \
225- -S $SEEDMIRROR -m $MIRROR -d $SUITE -s $SEED \
226- ${COMPONENTS:+-c "$COMPONENTS"} -a $ARCH)
227-
228 UNWANTED_SEEDS="${LIVE_TASK:+$LIVE_TASK }boot installer required"
229 for i in $UNWANTED_SEEDS; do
230 UNWANTED_SEEDS="${UNWANTED_SEEDS:+$UNWANTED_SEEDS }$(inheritance $i)"

Subscribers

People subscribed via source and target branches