Merge lp:~rcj/livecd-rootfs/trunk into lp:livecd-rootfs

Proposed by Robert C Jennings
Status: Merged
Approved by: Steve Langasek
Approved revision: 1707
Merged at revision: 1702
Proposed branch: lp:~rcj/livecd-rootfs/trunk
Merge into: lp:livecd-rootfs
Diff against target: 76 lines (+22/-3)
3 files modified
debian/changelog (+4/-0)
live-build/auto/config (+3/-0)
live-build/functions (+15/-3)
To merge this branch: bzr merge lp:~rcj/livecd-rootfs/trunk
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Francis Ginther (community) Approve
Dan Watkins (community) Needs Information
Review via email: mp+355791@code.launchpad.net

Commit message

Add the server snap seed to the ubuntu-cpc project

This patch adds the server snap seed to the ubuntu-cpc project and
allows hooks to replace generic snap assertion.

The generic assertion will be put in place if there are preseeded snaps.
A hook that wants to add its own model should be able to overwrite
the generic assertion. This patch allows a hook to continue unchanged
calling snap_prepare_assertions with a custom brand/model. The patch
will replace the generic brand/model if a custom brand/model is specified.
Prior to this patch the generic brand/model would remain in place.

To post a comment you must log in.
Revision history for this message
Dan Watkins (oddbloke) :
review: Needs Information
Revision history for this message
Robert C Jennings (rcj) :
Revision history for this message
Francis Ginther (fginther) wrote :

Looks good, just a follow up to Dan's comment.

review: Needs Fixing
Revision history for this message
Robert C Jennings (rcj) wrote :

Francis, updated.

Revision history for this message
Robert C Jennings (rcj) wrote :

This can be simplified to always overwrite the assertion if it exists. live-build/auto/build calls snap_prepare so we can drop the snap_prepare from snap_preseed. If a hook wants to specify a different model they can call snap_prepare with a custom brand/model.

Fixing...

Revision history for this message
Robert C Jennings (rcj) wrote :

I've tested these new changes and it works well. Doesn't break downstream cloud images. And it will allow subsequent hooks to overwrite non-generic assertions. Please review.

Revision history for this message
Francis Ginther (fginther) wrote :

Looks good, I have a couple of suggestions.

review: Needs Fixing
Revision history for this message
Robert C Jennings (rcj) :
Revision history for this message
Steve Langasek (vorlon) :
review: Needs Fixing
Revision history for this message
Robert C Jennings (rcj) :
Revision history for this message
Francis Ginther (fginther) wrote :

Approve

review: Approve
Revision history for this message
Robert C Jennings (rcj) wrote :

This is ready for review again. I've inspected images built with this; downloads had generic models with lxd, aws had lxd, amazon-ssm-agent, and the amazon model. Tested that calling snap_preseed without snap_prepare emits an error and exits the build.

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-09-26 00:43:50 +0000
3+++ debian/changelog 2018-09-27 20:16:14 +0000
4@@ -2,6 +2,10 @@
5
6 * Remove device nodes from Docker images. (LP: #1645468)
7
8+ [ Robert C Jennings ]
9+ * Add the server snap seed to the ubuntu-cpc project
10+ * Allow hooks to replace generic snap assertion
11+
12 -- Michael Hudson-Doyle <mwhudson@debian.org> Wed, 26 Sep 2018 12:43:23 +1200
13
14 livecd-rootfs (2.540) cosmic; urgency=medium
15
16=== modified file 'live-build/auto/config'
17--- live-build/auto/config 2018-09-19 14:24:26 +0000
18+++ live-build/auto/config 2018-09-27 20:16:14 +0000
19@@ -696,6 +696,9 @@
20 ubuntu:*|kubuntu*:*|lubuntu*:*|xubuntu*:*|ubuntu-mate*:*|ubuntustudio*:*|ubuntukylin*:*|ubuntu-budgie*:*)
21 BASE_SEED='desktop'
22 ;;
23+ ubuntu-cpc:*)
24+ BASE_SEED='server'
25+ ;;
26 ubuntu-server:live)
27 BASE_SEED='server'
28 # subiquity is seeded but in a separate squashfs via hooks; set HOOK_SNAPS and ALL_SNAPS.
29
30=== modified file 'live-build/functions'
31--- live-build/functions 2018-05-28 14:39:06 +0000
32+++ live-build/functions 2018-09-27 20:16:14 +0000
33@@ -427,6 +427,16 @@
34 local brand="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 1)"
35 local model="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 2)"
36
37+ # Clear the assertions if they already exist
38+ if [ -e "$model_assertion" ] ; then
39+ existing_model=$(awk '/^model: / {print $2}' $model_assertion)
40+ existing_brand=$(awk '/^brand-id: / {print $2}' $model_assertion)
41+ echo "snap_prepare_assertions: replacing $existing_brand:$existing_model with $brand:$model"
42+ rm "$model_assertion"
43+ rm "$account_key_assertion"
44+ rm "$account_assertion"
45+ fi
46+
47 if ! [ -e "$model_assertion" ] ; then
48 snap known --remote model series=16 \
49 model=$model brand-id=$brand \
50@@ -441,7 +451,6 @@
51 > "$account_key_assertion"
52 fi
53
54-
55 if ! [ -e "$account_assertion" ] ; then
56 local account=$(sed -n -e's/account-id: //p' < "$account_key_assertion")
57 snap known --remote account account-id=$account \
58@@ -468,13 +477,16 @@
59 }
60
61 snap_preseed() {
62- # Preseed a snap in the image
63+ # Preseed a snap in the image (snap_prepare must be called once prior)
64 local CHROOT_ROOT=$1
65 local SNAP=$2
66 # Per Ubuntu policy, all seeded snaps (with the exception of the core
67 # snap) must pull from stable/ubuntu-$(release_ver) as their channel.
68 local CHANNEL=${3:-"stable/ubuntu-$(release_ver)"}
69
70- snap_prepare $CHROOT_ROOT
71+ if [ ! -e "$CHROOT_ROOT/var/lib/snapd/seed/assertions/model" ]; then
72+ echo "ERROR: Snap model assertion not present, snap_prepare must be called"
73+ exit 1
74+ fi
75 _snap_preseed $CHROOT_ROOT $SNAP $CHANNEL
76 }

Subscribers

People subscribed via source and target branches