From 83c1944b89ace9b45eb568db0bc21556ca567c07 Mon Sep 17 00:00:00 2001 From: CloudBuilder Date: Fri, 24 Jul 2020 16:19:12 +0000 Subject: [PATCH] Imported 2.664.4 No reason for CPC update specified. --- debian/changelog | 6 ++++++ live-build/functions | 26 +++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9d24ae1b..e8ada272 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +livecd-rootfs (2.664.4) focal; urgency=medium + + * snap_preseed: support channel specification with snap name (LP: #1882374) + + -- Dimitri John Ledkov Thu, 23 Jul 2020 19:12:10 +0100 + livecd-rootfs (2.664.3) focal; urgency=medium [ Ɓukasz 'sil2100' Zemczak ] diff --git a/live-build/functions b/live-build/functions index d86f27d6..2e505949 100644 --- a/live-build/functions +++ b/live-build/functions @@ -626,11 +626,31 @@ snap_prepare() { snap_preseed() { # Preseed a snap in the image (snap_prepare must be called once prior) local CHROOT_ROOT=$1 + # $2 can be in the form of snap_name/classic=track/risk/branch local SNAP=$2 + # strip CHANNEL specification + SNAP=${SNAP%=*} + # strip /classic confinement local SNAP_NAME=${SNAP%/*} - # Per Ubuntu policy, all seeded snaps (with the exception of the core - # snap) must pull from stable/ubuntu-$(release_ver) as their channel. - local CHANNEL=${3:-"stable/ubuntu-$(release_ver)"} + # Seed from the specified channel (e.g. core18 latest/stable) + # Or Channel endcoded in the snap name (e.g. lxd=4.0/stable/ubuntu-20.04) + # Or Ubuntu policy default channel latest/stable/ubuntu-$(release_ver) + local CHANNEL=${3:-} + if [ -z "$CHANNEL" ]; then + case $2 in + *=*) + CHANNEL=${2#*=} + ;; + *) + CHANNEL="stable/ubuntu-$(release_ver)" + ;; + esac + fi + + # At this point: + # SNAP_NAME is just the snap name + # SNAP is either $SNAP_NAME or $SNAP_NAME/classic for classic confined + # CHANNEL is the channel if [ ! -e "$CHROOT_ROOT/var/lib/snapd/seed/assertions/model" ]; then echo "ERROR: Snap model assertion not present, snap_prepare must be called"