From 54649b40c35cc6dc38af7e2e854f369ccf20d9a6 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Tue, 17 Apr 2018 14:46:56 -0400 Subject: [PATCH 01/10] Allow custom model assertions in snap_prepare_assertions This also splits up the preparation in to two functions, so that images that want to use a custom model assertion but don't have any snaps to preinstall don't end up with the core snap installed. --- live-build/functions | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/live-build/functions b/live-build/functions index f3e1df0b..c3f1cb11 100644 --- a/live-build/functions +++ b/live-build/functions @@ -412,9 +412,12 @@ EOF (cd $snaps_dir; ls -1 ${SNAP_NAME}_*.snap) >> $seed_yaml } -snap_prepare() { - # Configure basic snapd assertions and pre-seeds the 'core' snap +snap_prepare_assertions() { + # Configure basic snapd assertions local CHROOT_ROOT=$1 + # Optional. If set, should be a colon-separated string of brand:model to be + # used for the image's model assertion + local CUSTOM_BRAND_MODEL=$2 local seed_dir="$CHROOT_ROOT/var/lib/snapd/seed" local snaps_dir="$seed_dir/snaps" @@ -426,9 +429,16 @@ snap_prepare() { mkdir -p "$assertions_dir" mkdir -p "$snaps_dir" + local brand="generic" + local model="generic-classic" + if [ -n "$CUSTOM_BRAND_MODEL" ] ; then + brand="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 1)" + brand="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 2)" + fi + if ! [ -e "$model_assertion" ] ; then snap known --remote model series=16 \ - model=generic-classic brand-id=generic \ + model=$model brand-id=$brand \ > "$model_assertion" fi @@ -446,6 +456,16 @@ snap_prepare() { snap known --remote account account-id=$account \ > "$account_assertion" fi +} + +snap_prepare() { + # Configure basic snapd assertions and pre-seeds the 'core' snap + local CHROOT_ROOT=$1 + # Optional. If set, should be a colon-separated string of brand:model to be + # used for the image's model assertion + local CUSTOM_BRAND_MODEL=$2 + + snap_prepare_assertions "$CHROOT_ROOT" "$CUSTOM_BRAND_MODEL" # Download the core snap if ! [ -f $snaps_dir/core_[0-9]*.snap ] ; then From d908e89a52595d74439427f4093c166de6717b16 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Tue, 17 Apr 2018 16:32:44 -0400 Subject: [PATCH 02/10] Fix typo --- live-build/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/functions b/live-build/functions index c3f1cb11..7d368d99 100644 --- a/live-build/functions +++ b/live-build/functions @@ -433,7 +433,7 @@ snap_prepare_assertions() { local model="generic-classic" if [ -n "$CUSTOM_BRAND_MODEL" ] ; then brand="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 1)" - brand="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 2)" + model="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 2)" fi if ! [ -e "$model_assertion" ] ; then From ed50ee0e0dbd0ec1df96826bed213ad7b5424a60 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Tue, 17 Apr 2018 17:35:10 -0400 Subject: [PATCH 03/10] Fix use of unbound variable --- live-build/functions | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/live-build/functions b/live-build/functions index 7d368d99..484e5046 100644 --- a/live-build/functions +++ b/live-build/functions @@ -417,7 +417,7 @@ snap_prepare_assertions() { local CHROOT_ROOT=$1 # Optional. If set, should be a colon-separated string of brand:model to be # used for the image's model assertion - local CUSTOM_BRAND_MODEL=$2 + local CUSTOM_BRAND_MODEL=${2:-generic:generic-classic} local seed_dir="$CHROOT_ROOT/var/lib/snapd/seed" local snaps_dir="$seed_dir/snaps" @@ -429,8 +429,6 @@ snap_prepare_assertions() { mkdir -p "$assertions_dir" mkdir -p "$snaps_dir" - local brand="generic" - local model="generic-classic" if [ -n "$CUSTOM_BRAND_MODEL" ] ; then brand="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 1)" model="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 2)" From a844c6f8cd56140f4896bf2ca9741d4fdd1e6e61 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Tue, 17 Apr 2018 22:01:47 -0400 Subject: [PATCH 04/10] Fix another unbound variable --- live-build/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/functions b/live-build/functions index 484e5046..ac4912f5 100644 --- a/live-build/functions +++ b/live-build/functions @@ -461,7 +461,7 @@ snap_prepare() { local CHROOT_ROOT=$1 # Optional. If set, should be a colon-separated string of brand:model to be # used for the image's model assertion - local CUSTOM_BRAND_MODEL=$2 + local CUSTOM_BRAND_MODEL=${2:-generic:generic-classic} snap_prepare_assertions "$CHROOT_ROOT" "$CUSTOM_BRAND_MODEL" From a09c14c0ab3932cd4392137e148beb7df4be45de Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Wed, 18 Apr 2018 10:06:55 -0400 Subject: [PATCH 05/10] Fix missing local variables --- live-build/functions | 3 +++ 1 file changed, 3 insertions(+) diff --git a/live-build/functions b/live-build/functions index ac4912f5..aa74c7dc 100644 --- a/live-build/functions +++ b/live-build/functions @@ -463,6 +463,9 @@ snap_prepare() { # used for the image's model assertion local CUSTOM_BRAND_MODEL=${2:-generic:generic-classic} + local seed_dir="$CHROOT_ROOT/var/lib/snapd/seed" + local snaps_dir="$seed_dir/snaps" + snap_prepare_assertions "$CHROOT_ROOT" "$CUSTOM_BRAND_MODEL" # Download the core snap From 265218c1cb265110fbc6ed69caadff44e3e1fa35 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Wed, 18 Apr 2018 12:41:47 -0400 Subject: [PATCH 06/10] Don't include model assertion name in FS path (LP: #1764541) There can only be one model assertion, so we don't need to disambiguate them. This also brings us in line with the behaviour of `snap prepare-image`, and consistency is nice. --- live-build/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/functions b/live-build/functions index aa74c7dc..eb612911 100644 --- a/live-build/functions +++ b/live-build/functions @@ -422,7 +422,7 @@ snap_prepare_assertions() { local seed_dir="$CHROOT_ROOT/var/lib/snapd/seed" local snaps_dir="$seed_dir/snaps" local assertions_dir="$seed_dir/assertions" - local model_assertion="$assertions_dir/generic-classic.model" + local model_assertion="$assertions_dir/model" local account_key_assertion="$assertions_dir/generic.account-key" local account_assertion="$assertions_dir/generic.account" From 38518507ecca6e03dc31c876c84b79085a57c418 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Wed, 18 Apr 2018 14:47:41 -0400 Subject: [PATCH 07/10] Generalise other assertion paths --- live-build/functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/live-build/functions b/live-build/functions index eb612911..acf2da90 100644 --- a/live-build/functions +++ b/live-build/functions @@ -423,8 +423,8 @@ snap_prepare_assertions() { local snaps_dir="$seed_dir/snaps" local assertions_dir="$seed_dir/assertions" local model_assertion="$assertions_dir/model" - local account_key_assertion="$assertions_dir/generic.account-key" - local account_assertion="$assertions_dir/generic.account" + local account_key_assertion="$assertions_dir/account-key" + local account_assertion="$assertions_dir/account" mkdir -p "$assertions_dir" mkdir -p "$snaps_dir" From fe76613e69a4242f4829f51176e4b73e0588702e Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Wed, 18 Apr 2018 20:00:43 -0400 Subject: [PATCH 08/10] Require brand:model to be passed to snap_prepare_assertions We only need the default in one place, so remove it from all but the top-level function. --- live-build/functions | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/live-build/functions b/live-build/functions index acf2da90..b1a33d2d 100644 --- a/live-build/functions +++ b/live-build/functions @@ -415,9 +415,9 @@ EOF snap_prepare_assertions() { # Configure basic snapd assertions local CHROOT_ROOT=$1 - # Optional. If set, should be a colon-separated string of brand:model to be - # used for the image's model assertion - local CUSTOM_BRAND_MODEL=${2:-generic:generic-classic} + # A colon-separated string of brand:model to be used for the image's model + # assertion + local CUSTOM_BRAND_MODEL=$2 local seed_dir="$CHROOT_ROOT/var/lib/snapd/seed" local snaps_dir="$seed_dir/snaps" From 42ef796b9246373aab21b0fbc676962a9198ca2b Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Wed, 18 Apr 2018 20:01:40 -0400 Subject: [PATCH 09/10] Remove necessarily true conditional --- live-build/functions | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/live-build/functions b/live-build/functions index b1a33d2d..3363bf2a 100644 --- a/live-build/functions +++ b/live-build/functions @@ -429,10 +429,8 @@ snap_prepare_assertions() { mkdir -p "$assertions_dir" mkdir -p "$snaps_dir" - if [ -n "$CUSTOM_BRAND_MODEL" ] ; then - brand="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 1)" - model="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 2)" - fi + local brand="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 1)" + local model="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 2)" if ! [ -e "$model_assertion" ] ; then snap known --remote model series=16 \ From 44274041a67d1a5b03e2683614524f8166e0b049 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Thu, 19 Apr 2018 11:47:18 -0400 Subject: [PATCH 10/10] Add changelog entry --- debian/changelog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/debian/changelog b/debian/changelog index bb0893d8..fb2f7e07 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +livecd-rootfs (2.522) bionic; urgency=medium + + * Allow the configuration of model assertions independent of preseeding + snaps. + * Allow non-generic model assertions to be configured. + * Don't include the name of the model assertion in the path we write it out + to (LP: #1764541). + + -- Daniel Watkins Thu, 19 Apr 2018 11:44:38 -0400 + livecd-rootfs (2.521) bionic; urgency=medium * In subiquity image, mount additional squashfs in /media.