From cbfeb9c8482ad42d7d206dbd6e8e736253cf1cd2 Mon Sep 17 00:00:00 2001
From: CloudBuilder <cloud-image-builders@lists.canonical.com>
Date: Tue, 10 Sep 2019 19:00:07 +0000
Subject: [PATCH] Imported 2.610

No reason for CPC update specified.
---
 debian/changelog                              | 20 ++++++++++++++
 live-build/auto/config                        | 14 ++++++++--
 .../hooks.d/chroot/999-cpc-fixes.chroot       | 27 ++-----------------
 .../999-ubuntu-image-customization.chroot     | 23 ++++++++++++++++
 4 files changed, 57 insertions(+), 27 deletions(-)
 create mode 100755 live-build/ubuntu-cpc/hooks.d/chroot/999-ubuntu-image-customization.chroot

diff --git a/debian/changelog b/debian/changelog
index cccd610b..13b59e2c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,23 @@
+livecd-rootfs (2.610) eoan; urgency=medium
+
+  * Fix a typo in the 999-ubuntu-image-customization.chroot hook.
+
+ -- Łukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>  Tue, 10 Sep 2019 17:35:00 +0200
+
+livecd-rootfs (2.609) eoan; urgency=medium
+
+  [ Ethan Hsieh ]
+  * Add support for the Nitrogen6x board (LP: #1838064).
+
+  [ Łukasz 'sil2100' Zemczak ]
+  * Do not initialize EXTRA_SNAPS with an empty value. Allow overrides via the
+    environment.
+  * Make sure that currently all ubuntu-image built images ship the NoCloud
+    system-boot clout-init datasource (as right now all u-i targets are
+    physical devices).
+
+ -- Łukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>  Tue, 10 Sep 2019 10:46:28 +0200
+
 livecd-rootfs (2.608) eoan; urgency=medium
 
   [ Iain Lane ]
diff --git a/live-build/auto/config b/live-build/auto/config
index 83a6f791..d851e453 100755
--- a/live-build/auto/config
+++ b/live-build/auto/config
@@ -332,6 +332,8 @@ case $IMAGEFORMAT in
 				MODEL=pi3-arm64 ;;
 			armhf+cm3)
 				MODEL=cm3 ;;
+			armhf+imx6)
+				MODEL=nitrogen6x ;;
 			*)
 				echo "Model $ARCH+${SUBARCH:-} unknown to livecd-rootfs" >&2
 				exit 1
@@ -340,7 +342,6 @@ case $IMAGEFORMAT in
 
 		if [ $PROJECT = "ubuntu-core" ]; then
 			# snap-based core images
-			EXTRA_SNAPS=""
 
 			case $MODEL in
 				pc-amd64|pc-i386)
@@ -360,7 +361,7 @@ case $IMAGEFORMAT in
 
 			case "$ARCH+${SUBARCH:-}" in
 				amd64+kassel)
-					EXTRA_SNAPS="core bluez alsa-utils"
+					EXTRA_SNAPS="$EXTRA_SNAPS core bluez alsa-utils"
 					;;
 				*) ;;
 			esac
@@ -394,6 +395,9 @@ case $IMAGEFORMAT in
 
 			echo "Configured ubuntu-image for the following gadget model: $MODEL"
 		fi
+
+		# Save the model name used for building, mostly for any model-specific hook execution
+		echo "MODEL=$MODEL" >> config/common
 		# Fake finished configuration for lb build
 		mkdir -p .build
 		touch .build/config
@@ -904,6 +908,12 @@ case $ARCH in
 				add_package install linux-firmware-raspi2 u-boot-rpi flash-kernel u-boot-tools wpasupplicant
 				BINARY_REMOVE_LINUX=false
 				;;
+			imx6)
+				COMPONENTS='main restricted universe multiverse'
+				KERNEL_FLAVOURS=generic
+				add_package install flash-kernel u-boot-tools wpasupplicant
+				BINARY_REMOVE_LINUX=false
+				;;
 
 		esac
 		;;
diff --git a/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot
index 561b4473..bc516092 100755
--- a/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot
+++ b/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot
@@ -22,18 +22,6 @@ _xchroot() {
 #### COMMON architecture independent functions
 arch=$(_xchroot "${rootd}" dpkg --print-architecture)
 
-fake_cloud_init() {
-    # If the cloud does not provide a meta-data service this should be run
-    # This will setup a nocloud datasource on the boot partition.
-    cat << EOF > ${rootd}/etc/cloud/cloud.cfg.d/99-fake_cloud.cfg
-# configure cloud-init for NoCloud
-datasource_list: [ NoCloud, None ]
-datasource:
-  NoCloud:
-    fs_label: system-boot
-EOF
-}
-
 ## --------------
 # remove 127.0.1.1 entry (LP: #440757)
 _xchroot "${rootd}" sh -c 'sed -i "/^127.0.1.1/d" /etc/hosts'
@@ -128,19 +116,8 @@ fi
 
 
 case $arch in
-	# ARM images are special
-	armhf|arm64)
-		# Dirty hack because SUBARCH doesn't exist when running chroot hooks,
-		# and we don't want raspi2 images to depend on a cloud data source:
-		if _xchroot "${rootd}" dpkg -l linux-image-raspi2 2>/dev/null | grep -q '^.i'; then
-			fake_cloud_init
-		fi
-
-		echo "Image architecture is ARM. Existing vmbuilder-fixups"
-
-		exit 0
-		;;
-	powerpc|ppc64el|s390x)
+	# ARM, ppc and s390 images are special
+	armhf|arm64|powerpc|ppc64el|s390x)
 		exit 0
 		;;
 esac
diff --git a/live-build/ubuntu-cpc/hooks.d/chroot/999-ubuntu-image-customization.chroot b/live-build/ubuntu-cpc/hooks.d/chroot/999-ubuntu-image-customization.chroot
new file mode 100755
index 00000000..75a5313f
--- /dev/null
+++ b/live-build/ubuntu-cpc/hooks.d/chroot/999-ubuntu-image-customization.chroot
@@ -0,0 +1,23 @@
+#!/bin/bash -ex
+
+. /root/config/common
+
+# Specific ubuntu-image chroot configuration goes here.
+# Currently the ubuntu-image IMAGEFORMAT is equivalent to building an image
+# for a physical device, not a cloud instance. For such images we want some
+# special cloud-init configuration that should not be happening for cloud
+# cases. This check should be changed to a per-MODEL/per-SUBARCH check once
+# we support building cloud images via ubuntu-image.
+if [ "$IMAGEFORMAT" == "ubuntu-image" ]; then
+    # If the cloud does not provide a meta-data service this should be run
+    # This will setup a nocloud datasource on the boot partition.
+    # This is the default behavior for our ubuntu-image built preinstalled
+    # images.
+    cat << EOF > /etc/cloud/cloud.cfg.d/99-fake_cloud.cfg
+# configure cloud-init for NoCloud
+datasource_list: [ NoCloud, None ]
+datasource:
+  NoCloud:
+    fs_label: system-boot
+EOF
+fi