From 6bcb29a25c1bddf150ed91919b940ace3dba8289 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@canonical.com>
Date: Wed, 8 Jun 2011 10:07:26 +0200
Subject: Make --initramfs none work more consistently (Closes: #627887).

---
 scripts/build/lb_binary_grub     | 10 +++++++++-
 scripts/build/lb_binary_grub2    | 10 +++++++++-
 scripts/build/lb_binary_manifest |  5 +++++
 scripts/build/lb_binary_memtest  |  4 ++++
 scripts/build/lb_binary_net      |  4 ++++
 scripts/build/lb_binary_rootfs   |  4 ++++
 scripts/build/lb_binary_silo     |  7 ++++++-
 scripts/build/lb_binary_yaboot   | 10 +++++++++-
 scripts/build/lb_chroot_hacks    |  6 +++++-
 9 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/scripts/build/lb_binary_grub b/scripts/build/lb_binary_grub
index ee14bd900..39aca30d3 100755
--- a/scripts/build/lb_binary_grub
+++ b/scripts/build/lb_binary_grub
@@ -68,7 +68,7 @@ Grub_live_entry ()
 	APPEND="${4}"
 
 	LINUX_LIVE="${LINUX_LIVE}\ntitle\t\tDebian GNU/Linux - ${LABEL}"
-	LINUX_LIVE="${LINUX_LIVE}\nkernel\t\t/${KERNEL} boot=${INITFS} config LB_BOOTAPPEND_LIVE ${APPEND}"
+	LINUX_LIVE="${LINUX_LIVE}\nkernel\t\t/${KERNEL} ${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}"
 	LINUX_LIVE="${LINUX_LIVE}\ninitrd\t\t/${INITRD}"
 }
 
@@ -125,6 +125,10 @@ case "${LB_INITRAMFS}" in
 	live-boot)
 		INITFS="live"
 		;;
+
+	*)
+		INITFS=""
+		;;
 esac
 
 # Setting destination directory
@@ -138,6 +142,10 @@ case "${LB_BINARY_IMAGES}" in
 			live-boot)
 				DESTDIR_LIVE="binary/live"
 				;;
+
+			*)
+				DESTDIR_LIVE="binary/boot"
+				;;
 		esac
 
 		DESTDIR_INSTALL="binary/install"
diff --git a/scripts/build/lb_binary_grub2 b/scripts/build/lb_binary_grub2
index 8f076b2fc..b0298911b 100755
--- a/scripts/build/lb_binary_grub2
+++ b/scripts/build/lb_binary_grub2
@@ -68,7 +68,7 @@ Grub_live_entry ()
 	APPEND="${4}"
 
 	LINUX_LIVE="${LINUX_LIVE}\nmenuentry \"Debian GNU/Linux - ${LABEL}\" {"
-	LINUX_LIVE="${LINUX_LIVE}\nlinux\t\t/${KERNEL} boot=${INITFS} config LB_BOOTAPPEND_LIVE ${APPEND}"
+	LINUX_LIVE="${LINUX_LIVE}\nlinux\t\t/${KERNEL} ${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}"
 	LINUX_LIVE="${LINUX_LIVE}\ninitrd\t\t/${INITRD}"
 	LINUX_LIVE="${LINUX_LIVE}\n}"
 }
@@ -99,6 +99,10 @@ case "${LB_INITRAMFS}" in
 	live-boot)
 		INITFS="live"
 		;;
+
+	*)
+		INITFS=""
+		;;
 esac
 
 # Setting destination directory
@@ -112,6 +116,10 @@ case "${LB_BINARY_IMAGES}" in
 			live-boot)
 				DESTDIR_LIVE="binary/live"
 				;;
+
+			*)
+				DESTDIR_LIVE="binary/live"
+				;;
 		esac
 
 		DESTDIR_INSTALL="binary/install"
diff --git a/scripts/build/lb_binary_manifest b/scripts/build/lb_binary_manifest
index 4b4913348..0ae9051d8 100755
--- a/scripts/build/lb_binary_manifest
+++ b/scripts/build/lb_binary_manifest
@@ -53,6 +53,11 @@ case "${LB_INITRAMFS}" in
 		INITFS="live"
 		SUFFIX="packages"
 		;;
+
+	*)
+		INITFS="boot"
+		SUFFIX="packages"
+		;;
 esac
 
 # Add filesystem.packages
diff --git a/scripts/build/lb_binary_memtest b/scripts/build/lb_binary_memtest
index a539ee666..8155b147a 100755
--- a/scripts/build/lb_binary_memtest
+++ b/scripts/build/lb_binary_memtest
@@ -87,6 +87,10 @@ case "${LB_INITRAMFS}" in
 	live-boot)
 		DESTDIR="binary/live"
 		;;
+
+	*)
+		DESTDIR="binary/boot"
+		;;
 esac
 
 Check_multiarchitectures
diff --git a/scripts/build/lb_binary_net b/scripts/build/lb_binary_net
index 9cac050f4..133a203f6 100755
--- a/scripts/build/lb_binary_net
+++ b/scripts/build/lb_binary_net
@@ -69,6 +69,10 @@ then
 		live-boot)
 			ORIGDIR="binary/live"
 			;;
+
+		*)
+			ORIGDIR="binary/boot"
+			;;
 	esac
 
 	# Find defaults
diff --git a/scripts/build/lb_binary_rootfs b/scripts/build/lb_binary_rootfs
index f2993f1af..70a6dc7dc 100755
--- a/scripts/build/lb_binary_rootfs
+++ b/scripts/build/lb_binary_rootfs
@@ -56,6 +56,10 @@ case "${LB_INITRAMFS}" in
 	live-boot)
 		INITFS="live"
 		;;
+
+	*)
+		INITFS="boot"
+		;;
 esac
 
 # Creating directory
diff --git a/scripts/build/lb_binary_silo b/scripts/build/lb_binary_silo
index ac2e2d073..5834a0b5b 100755
--- a/scripts/build/lb_binary_silo
+++ b/scripts/build/lb_binary_silo
@@ -82,7 +82,7 @@ Silo_live_entry ()
 	LINUX_LIVE="${LINUX_LIVE}\nimage=${DIRECTORY}/${KERNEL}\n"
 	LINUX_LIVE="${LINUX_LIVE}\t  label=${LABEL}\n"
 	LINUX_LIVE="${LINUX_LIVE}\t  initrd=${DIRECTORY}/${INITRD}\n"
-	LINUX_LIVE="${LINUX_LIVE}\t  append=\"boot=${INITFS} config LB_BOOTAPPEND_LIVE ${APPEND}\"\n"
+	LINUX_LIVE="${LINUX_LIVE}\t  append=\"${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}\"\n"
 }
 
 Silo_install_entry ()
@@ -117,6 +117,11 @@ case "${LB_INITRAMFS}" in
 		INITFS="live"
 		DESTDIR_LIVE="binary/live"
 		;;
+
+	*)
+		INITFS=""
+		DESTDIR_LIVE="binary/boot"
+		;;
 esac
 
 # Creating directory
diff --git a/scripts/build/lb_binary_yaboot b/scripts/build/lb_binary_yaboot
index ee2452bb8..4613b8a19 100755
--- a/scripts/build/lb_binary_yaboot
+++ b/scripts/build/lb_binary_yaboot
@@ -72,7 +72,7 @@ Yaboot_live_entry ()
 	LINUX_LIVE="${LINUX_LIVE}\nimage=${DIRECTORY}/${KERNEL}\n"
 	LINUX_LIVE="${LINUX_LIVE}\tlabel=${LABEL}\n"
 	LINUX_LIVE="${LINUX_LIVE}\tinitrd=${DIRECTORY}/${INITRD}\n"
-	LINUX_LIVE="${LINUX_LIVE}\tappend=\"boot=${INITFS} config LB_BOOTAPPEND_LIVE ${APPEND}\"\n"
+	LINUX_LIVE="${LINUX_LIVE}\tappend=\"${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}\"\n"
 	LINUX_LIVE="${LINUX_LIVE}\tinitrd-size=10240\n"
 }
 
@@ -132,6 +132,10 @@ case "${LB_INITRAMFS}" in
 	live-boot)
 		INITFS="live"
 		;;
+
+	*)
+		INITFS=""
+		;;
 esac
 
 # Setting destination directory
@@ -145,6 +149,10 @@ case "${LB_BINARY_IMAGES}" in
 			live-boot)
 				DESTDIR_LIVE="binary/live"
 				;;
+
+			*)
+				DESTDIR_LIVE="binary/boot"
+				;;
 		esac
 
 		DESTDIR_INSTALL="binary/install"
diff --git a/scripts/build/lb_chroot_hacks b/scripts/build/lb_chroot_hacks
index 2a58c0f75..ab5e3ab04 100755
--- a/scripts/build/lb_chroot_hacks
+++ b/scripts/build/lb_chroot_hacks
@@ -214,9 +214,13 @@ case "${LB_INITRAMFS}" in
 	live-boot)
 		ID="1000"
 		;;
+
+	*)
+		ID=""
+		;;
 esac
 
-if [ -d chroot/home/${LB_USERNAME} ]
+if [ -d chroot/home/${LB_USERNAME} ] && [ "${ID}" ]
 then
 	chown -R --quiet ${ID}:${ID} chroot/home/${LB_USERNAME}
 fi
-- 
cgit v1.2.3