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
=== modified file 'live-build/auto/build'
--- live-build/auto/build 2017-12-11 12:22:31 +0000
+++ live-build/auto/build 2018-01-04 12:13:16 +0000
@@ -42,7 +42,7 @@
42 chroot chroot sh -c "42 chroot chroot sh -c "
43 set -x;43 set -x;
44 cd /var/lib/snapd/seed;44 cd /var/lib/snapd/seed;
45 SNAPPY_STORE_NO_CDN=1 snap download \"$snap\""45 SNAPPY_STORE_NO_CDN=1 snap download \"${snap%/*}\""
46 done46 done
47 lb chroot_resolv remove47 lb chroot_resolv remove
4848
@@ -55,12 +55,14 @@
55 file: ${CORE_SNAP}55 file: ${CORE_SNAP}
56EOF56EOF
57 for snap in "$@"; do57 for snap in "$@"; do
58 snap_name=${snap%/*}
58 cat <<EOF >> chroot/var/lib/snapd/seed/seed.yaml59 cat <<EOF >> chroot/var/lib/snapd/seed/seed.yaml
59 - name: $snap60 - name: ${snap_name}
60 channel: stable61 channel: stable
61EOF62EOF
63 case ${snap} in */classic) echo " classic: true" >> chroot/var/lib/snapd/seed/seed.yaml;; esac
62 echo -n " file: " >> chroot/var/lib/snapd/seed/seed.yaml64 echo -n " file: " >> chroot/var/lib/snapd/seed/seed.yaml
63 (cd chroot/var/lib/snapd/seed; ls -1 ${snap}_*.snap) \65 (cd chroot/var/lib/snapd/seed; ls -1 ${snap_name}_*.snap) \
64 >> chroot/var/lib/snapd/seed/seed.yaml66 >> chroot/var/lib/snapd/seed/seed.yaml
65 done67 done
6668
@@ -367,40 +369,33 @@
367 rm chroot/etc/apt/sources.list.preinstall chroot/etc/apt/sources.list.orig369 rm chroot/etc/apt/sources.list.preinstall chroot/etc/apt/sources.list.orig
368 fi370 fi
369 case $PROJECT:$SUBPROJECT in371 case $PROJECT:$SUBPROJECT in
370 ubuntu-server:live|ubuntu-mate:*)372 *)
371 assertions_dir="chroot/var/lib/snapd/seed/assertions"373 if [ -e "config/seeded-snaps" ]; then
372 model_assertion="$assertions_dir/generic-classic.model"374 assertions_dir="chroot/var/lib/snapd/seed/assertions"
373 account_key_assertion="$assertions_dir/generic.account-key"375 model_assertion="$assertions_dir/generic-classic.model"
374 account_assertion="$assertions_dir/generic.account"376 account_key_assertion="$assertions_dir/generic.account-key"
375377 account_assertion="$assertions_dir/generic.account"
376 mkdir -p "$assertions_dir"378
377 snap known --remote model series=16 \379 mkdir -p "$assertions_dir"
378 model=generic-classic brand-id=generic \380 snap known --remote model series=16 \
379 > "$model_assertion"381 model=generic-classic brand-id=generic \
380 account_key=$(sed -n -e's/sign-key-sha3-384: //p' \382 > "$model_assertion"
381 < "$model_assertion")383 account_key=$(sed -n -e's/sign-key-sha3-384: //p' \
382384 < "$model_assertion")
383 snap known --remote account-key \385
384 public-key-sha3-384="$account_key" \386 snap known --remote account-key \
385 > "$account_key_assertion"387 public-key-sha3-384="$account_key" \
386 account=$(sed -n -e's/account-id: //p' \388 > "$account_key_assertion"
387 < "$account_key_assertion")389 account=$(sed -n -e's/account-id: //p' \
388390 < "$account_key_assertion")
389 snap known --remote account account-id=generic \391
390 > "$account_assertion"392 snap known --remote account account-id=generic \
391 ;;393 > "$account_assertion"
392 esac394 snap_list=$(cat config/seeded-snaps)
393395 preinstall_snaps $snap_list
394 # FIXME: this should not be a hard-coded list in this script; this396 fi
395 # is an interim solution for 17.10.397 ;;
396 case $PROJECT:$SUBPROJECT in398 esac
397 ubuntu-mate:*)
398 SNAP_LIST=pulsemixer
399 ;;
400 esac
401 if [ -n "$SNAP_LIST" ]; then
402 preinstall_snaps $SNAP_LIST
403 fi
404399
405 if [ "$PROJECT" = "ubuntu-touch" ] || [ "$PROJECT" = "ubuntu-touch-custom" ]; then400 if [ "$PROJECT" = "ubuntu-touch" ] || [ "$PROJECT" = "ubuntu-touch-custom" ]; then
406 if [ "$ARCH" = "armhf" ]; then401 if [ "$ARCH" = "armhf" ]; then
407402
=== modified file 'live-build/auto/config'
--- live-build/auto/config 2017-11-23 19:27:16 +0000
+++ live-build/auto/config 2018-01-04 12:13:16 +0000
@@ -254,13 +254,76 @@
254 OPTS="${OPTS:+$OPTS }--bootstrap-flavour=minimal --linux-packages=linux-image"254 OPTS="${OPTS:+$OPTS }--bootstrap-flavour=minimal --linux-packages=linux-image"
255fi255fi
256256
257# cribbed from cdimage, perhaps this should be a small helper script in germinate?
258add_inheritance () {
259 case " $inherit " in
260 *" $1 "*)
261 ;;
262 *)
263 inherit="${inherit:+$inherit }$1"
264 ;;
265 esac
266}
267
268expand_inheritance () {
269 for seed in $(grep "^$1:" config/germinate-output/structure | cut -d: -f2); do
270 expand_inheritance "$seed"
271 done
272 add_inheritance "$1"
273}
274
275inheritance () {
276 inherit=
277 expand_inheritance "$1"
278 echo "$inherit"
279}
280
281mkdir -p config/germinate-output
282case $PROJECT in
283 kubuntu-active*)
284 SEED=kubuntu-active.$SUITE
285 ;;
286 kubuntu*)
287 SEED=kubuntu.$SUITE
288 ;;
289 xubuntu*)
290 SEED=xubuntu.$SUITE
291 ;;
292 *)
293 SEED=ubuntu.$SUITE
294 ;;
295esac
296
297if ! [ -e config/germinate-output/structure ]; then
298 echo "Running germinate..."
299 (cd config/germinate-output && germinate --no-rdepends --no-installer \
300 -S $SEEDMIRROR -m $MIRROR -d $SUITE -s $SEED \
301 ${COMPONENTS:+-c "$COMPONENTS"} -a $ARCH)
302fi
303
257case $PROJECT in304case $PROJECT in
258 ubuntu|ubuntu-dvd)305 ubuntu|ubuntu-dvd)
259 add_task install minimal standard ubuntu-desktop306 add_task install minimal standard ubuntu-desktop
260 LIVE_TASK='ubuntu-live'307 LIVE_TASK='ubuntu-live'
308 BASE_SEED='desktop'
309 SEEDS_EXPANDED=$(inheritance ${BASE_SEED})
261 case $ARCH in310 case $ARCH in
262 amd64) add_package live $SIGNED_KERNEL_PACKAGE ;;311 amd64) add_package live $SIGNED_KERNEL_PACKAGE ;;
263 esac312 esac
313 for seed in ${SEEDS_EXPANDED}; do
314 echo "snap: considering ${seed}"
315 file=config/germinate-output/${seed}.snaps
316 [ -e "${file}" ] || continue
317 # extract the first column (snap package name) from germinate's output
318 # translate the human-readable "foo (classic)" into a
319 # more machine readable "foo/classic"
320 seed_snaps=$(sed -rn '1,/-----/d;/-----/,$d; s/(.*) \|.*/\1/; s, \(classic\),/classic,; p' "${file}")
321 for snap in ${seed_snaps}; do
322 echo "snap: found ${snap}"
323 ALL_SNAPS="${ALL_SNAPS:+${ALL_SNAPS} }${snap}"
324 done
325 done
326 echo "${ALL_SNAPS}" > config/seeded-snaps
264 ;;327 ;;
265328
266 ubuntu-desktop-next)329 ubuntu-desktop-next)
@@ -939,51 +1002,8 @@
939 ;;1002 ;;
940esac1003esac
9411004
942# cribbed from cdimage, perhaps this should be a small helper script in germinate?
943add_inheritance () {
944 case " $inherit " in
945 *" $1 "*)
946 ;;
947 *)
948 inherit="${inherit:+$inherit }$1"
949 ;;
950 esac
951}
952
953expand_inheritance () {
954 for seed in $(grep "^$1:" config/germinate-output/structure | cut -d: -f2); do
955 expand_inheritance "$seed"
956 done
957 add_inheritance "$1"
958}
959
960inheritance () {
961 inherit=
962 expand_inheritance "$1"
963 echo "$inherit"
964}
965
966if [ "$PREINSTALLED" = "true" ]; then1005if [ "$PREINSTALLED" = "true" ]; then
967 if [ -n "$PREINSTALL_POOL_SEEDS" ]; then1006 if [ -n "$PREINSTALL_POOL_SEEDS" ]; then
968 mkdir -p config/germinate-output
969 case $PROJECT in
970 kubuntu-active*)
971 SEED=kubuntu-active.$SUITE
972 ;;
973 kubuntu*)
974 SEED=kubuntu.$SUITE
975 ;;
976 xubuntu*)
977 SEED=xubuntu.$SUITE
978 ;;
979 *)
980 SEED=ubuntu.$SUITE
981 ;;
982 esac
983 (cd config/germinate-output && germinate --no-rdepends --no-installer \
984 -S $SEEDMIRROR -m $MIRROR -d $SUITE -s $SEED \
985 ${COMPONENTS:+-c "$COMPONENTS"} -a $ARCH)
986
987 UNWANTED_SEEDS="${LIVE_TASK:+$LIVE_TASK }boot installer required"1007 UNWANTED_SEEDS="${LIVE_TASK:+$LIVE_TASK }boot installer required"
988 for i in $UNWANTED_SEEDS; do1008 for i in $UNWANTED_SEEDS; do
989 UNWANTED_SEEDS="${UNWANTED_SEEDS:+$UNWANTED_SEEDS }$(inheritance $i)"1009 UNWANTED_SEEDS="${UNWANTED_SEEDS:+$UNWANTED_SEEDS }$(inheritance $i)"

Subscribers

People subscribed via source and target branches