From e55a4a791001ac3d9845de89c09c61b08d3e244a Mon Sep 17 00:00:00 2001
From: Steve Langasek <steve.langasek@ubuntu.com>
Date: Tue, 23 May 2017 15:56:52 -0700
Subject: [PATCH] Import patches-unapplied version 2.445 to
 ubuntu/artful-proposed

Imported using git-ubuntu import.

Changelog parent: 2d6d50b86f5a69696218101a561a605cc4b2b20d

New changelog entries:
  * Resurrect Balint's fix from
    lp:~rbalint/livecd-rootfs/livecd-rootfs-autopkgtest-fix to wrap kpartx
    and trap spurious errors, since the problem is still being seen
    intermittently on i386 despite us calling sync before kpartx.
  [ Mathieu Trudel-Lapierre ]
  * Use ubuntu-server as the user for autologin on ubuntu-server live images.
  [ Simon Quigley ]
  * Use the correct task for lubuntu-next.
  * Use --no-install-recommends for lubuntu-next, consistent with lubuntu.
---
 debian/changelog                                 | 16 ++++++++++++++++
 live-build/auto/config                           |  6 +++++-
 live-build/functions                             | 13 ++++++++++++-
 .../system/getty@.service.d/autologin.conf       |  2 +-
 4 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index a5697547..a7e22612 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,19 @@
+livecd-rootfs (2.445) artful; urgency=medium
+
+  * Resurrect Balint's fix from
+    lp:~rbalint/livecd-rootfs/livecd-rootfs-autopkgtest-fix to wrap kpartx
+    and trap spurious errors, since the problem is still being seen
+    intermittently on i386 despite us calling sync before kpartx.
+
+  [ Mathieu Trudel-Lapierre ]
+  * Use ubuntu-server as the user for autologin on ubuntu-server live images.
+
+  [ Simon Quigley ]
+  * Use the correct task for lubuntu-next.
+  * Use --no-install-recommends for lubuntu-next, consistent with lubuntu.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Tue, 23 May 2017 15:56:52 -0700
+
 livecd-rootfs (2.444) artful; urgency=medium
 
   * For now, make sure all automated image builds are on the edge channel.
diff --git a/live-build/auto/config b/live-build/auto/config
index 34937680..60be6328 100755
--- a/live-build/auto/config
+++ b/live-build/auto/config
@@ -348,7 +348,7 @@ case $PROJECT in
 
 	lubuntu-next)
 		add_task install minimal standard lubuntu-qt-desktop
-		LIVE_TASK='lubuntu-next-live'
+		LIVE_TASK='lubuntu-live-qt'
 		case $ARCH in
 			amd64)	add_package live linux-signed-generic ;;
 		esac
@@ -356,6 +356,10 @@ case $PROJECT in
 		case $ARCH in
 			amd64|i386)	KERNEL_FLAVOURS=generic ;;
 		esac
+
+		# The Lubuntu STRUCTURE file has "feature
+		# no-follow-recommends". Mirror this.
+		export APT_OPTIONS="--yes --no-install-recommends"
 		;;
 
 	ubuntu-gnome)
diff --git a/live-build/functions b/live-build/functions
index 313a559b..c72c59a2 100644
--- a/live-build/functions
+++ b/live-build/functions
@@ -11,11 +11,22 @@ backing_img=
 apt-get -qqy install dosfstools gdisk
 
 clean_loops() {
+    local kpartx_ret
+    local kpartx_stdout
 
     if [ -n "${backing_img}" ]; then
         # sync before removing loop to avoid "Device or resource busy" errors
         sync
-        kpartx -v -d "${backing_img}"
+        kpartx_ret=""
+        kpartx_stdout=$(kpartx -v -d "${backing_img}") || kpartx_ret=$?
+        echo "$kpartx_stdout"
+        if [ -n "$kpartx_ret" ]; then
+            if echo "$kpartx_stdout" | grep -q "loop deleted: "; then
+                echo "Suppressing kpartx returning error (#860894)"
+            else
+                exit $kpartx_ret
+            fi
+        fi
         unset backing_img
     fi
 
diff --git a/live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf b/live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf
index 535e4f0c..a166aab4 100644
--- a/live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf
+++ b/live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf
@@ -1,3 +1,3 @@
 [Service]
 ExecStart=
-ExecStart=-/sbin/agetty --noclear -n --autologin ubuntu %I $TERM
+ExecStart=-/sbin/agetty --noclear -n --autologin ubuntu-server %I $TERM