From d5c4f11daa8ff64eb87ba7e1a246dddcec4d4ff6 Mon Sep 17 00:00:00 2001
From: Steve Langasek <steve.langasek@canonical.com>
Date: Fri, 20 Oct 2017 23:10:26 -0700
Subject: [PATCH] * Use kvm kernel only on amd64. * Make non-x86 minimized
 images consistent with x86 by not explicitly   installing the server task. *
 Clean up dangling /boot/initrd.img symlink left behind on minimized   builds.

---
 debian/changelog                                 | 10 ++++++++++
 debian/tests/minimized                           | 10 +---------
 live-build/auto/config                           | 13 ++++++-------
 live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot |  5 +++++
 4 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 2a084acd..ab26cfb8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+livecd-rootfs (2.408.21) UNRELEASED; urgency=medium
+
+  * Use kvm kernel only on amd64.
+  * Make non-x86 minimized images consistent with x86 by not explicitly
+    installing the server task.
+  * Clean up dangling /boot/initrd.img symlink left behind on minimized
+    builds.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Fri, 20 Oct 2017 23:01:32 -0700
+
 livecd-rootfs (2.408.20) xenial; urgency=medium
 
   * Now that grub-related diversions have been factored out in 2.466
diff --git a/debian/tests/minimized b/debian/tests/minimized
index 0807a764..c5da93ee 100644
--- a/debian/tests/minimized
+++ b/debian/tests/minimized
@@ -1,11 +1,3 @@
 #!/bin/sh
 
-ARCH=$(dpkg --print-architecture)
-
-failure_code=1
-if [ "$ARCH" = ppc64el ]; then
-	# not a regression; don't block while debugging
-	failure_code=0
-fi
-
-env SELECTED_TRIPLETS=ubuntu-cpc:minimized:ubuntu-cpc debian/tests/default-bootstraps || exit $failure_code
+env SELECTED_TRIPLETS=ubuntu-cpc:minimized:ubuntu-cpc debian/tests/default-bootstraps
diff --git a/live-build/auto/config b/live-build/auto/config
index e73e2fe5..fca41dc5 100755
--- a/live-build/auto/config
+++ b/live-build/auto/config
@@ -511,7 +511,7 @@ case $PROJECT in
 			# linux-kvm is available since you control the
 			# archive and can provide this metapackage as
 			# necessary.
-			if [ -z "$EXTRA_PPAS" ] && [ "$SUITE" != xenial ]; then
+			if [ "$ARCH" != "amd64" ] || ([ -z "$EXTRA_PPAS" ] && [ "$SUITE" != xenial ]); then
 				KERNEL_FLAVOURS=virtual
 			else
 				KERNEL_FLAVOURS=kvm
@@ -520,6 +520,11 @@ case $PROJECT in
 			add_task install minimal standard cloud-image
 			add_package install ubuntu-minimal
 			KERNEL_FLAVOURS=virtual
+		        case $ARCH in
+				armhf|arm64|ppc64el|powerpc)
+					add_task install server
+					;;
+			esac
 		fi
 
 		BINARY_REMOVE_LINUX=false
@@ -528,19 +533,13 @@ case $PROJECT in
 			armhf)
 				KERNEL_FLAVOURS=generic-lpae
 				add_package install flash-kernel
-				add_task install server
 				;;
 			arm64)
 				KERNEL_FLAVOURS=generic
 				add_package install flash-kernel
-				add_task install server
-				;;
-			ppc64el)
-				add_task install server
 				;;
 			powerpc)
 				KERNEL_FLAVOURS=powerpc64-smp
-				add_task install server
 				;;
 		esac
 		OPTS="${OPTS:+$OPTS }--system=normal"
diff --git a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot
index 4a2df66e..3b2a3492 100755
--- a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot
+++ b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot
@@ -154,6 +154,11 @@ if [ -f "${rootd}/etc/overlayroot.conf" ] &&
    } > "${rootd}/etc/overlayroot.local.conf"
 fi
 
+# previous steps may have left a dangling symlink here with
+# SUBPROJECT=minimized and that breaks lb_chroot_hacks step
+if [ -L "${rootd}/boot/initrd.img" ] && [ ! -e "${rootd}/boot/initrd.img" ]; then
+	rm "${rootd}/boot/initrd.img"
+fi
 
 #### END COMMON ARCH FUNCTIONS