From 4769d734b25fe16ea6c00038d935c33d48f02dee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20=27sil2100=27=20Zemczak?=
 <lukasz.zemczak@canonical.com>
Date: Tue, 23 Jun 2020 15:30:26 +0200
Subject: [PATCH] Make sure the brand-id is properly selected, allow channel
 overrides.

---
 live-build/auto/config | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/live-build/auto/config b/live-build/auto/config
index bb1ed313..a2c957e7 100755
--- a/live-build/auto/config
+++ b/live-build/auto/config
@@ -356,6 +356,7 @@ case $IMAGEFORMAT in
 		if [ $PROJECT = "ubuntu-core" ]; then
 			# snap-based core images
 
+			BRAND="canonical"
 			CHANNEL="${CHANNEL:-edge}"
 			case $MODEL in
 				pc-amd64|pc-i386)
@@ -381,8 +382,16 @@ case $IMAGEFORMAT in
 					# Ubuntu Core 18
 					MODEL="ubuntu-core-18-${MODEL#pc-}"
 					case $CHANNEL in
-						appliance*)
+						# Support a special-case channel for appliance images
+						appliance-*)
+							# Allow overriding the stability level for appliances
+							CHANNEL="${CHANNEL#appliance-}"
+							BRAND="ubuntu"
+							;;
+						appliance)
+							# Default appliance image
 							CHANNEL="stable"
+							BRAND="ubuntu"
 							;;
 					esac
 					UBUNTU_IMAGE_ARGS="$UBUNTU_IMAGE_ARGS -c $CHANNEL"
@@ -430,7 +439,7 @@ case $IMAGEFORMAT in
 			echo "IMAGEFORMAT=$IMAGEFORMAT" >> config/common
 			echo "UBUNTU_IMAGE_ARGS=\"$UBUNTU_IMAGE_ARGS\"" >> config/common
 			# Store model assertion in top dir to get it picked up later as a build artifact
-			env SNAPPY_STORE_NO_CDN=1 snap known --remote model series=16 model="$MODEL" brand-id=canonical > "$PREFIX".model-assertion
+			env SNAPPY_STORE_NO_CDN=1 snap known --remote model series=16 model="$MODEL" brand-id=$BRAND > "$PREFIX".model-assertion
 			echo "Configured ubuntu-image for the following model assertion:"
 			cat "$PREFIX".model-assertion
 			echo "----------------------------------------------------------"