[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#627665: option to remove kernel+initrd from compressed filesystem

On Mon, May 23, 2011 at 01:19:20PM +0100, Colin Watson wrote:
> The attached patch adds 'lb config --binary-remove-linux true'.  Feel
> free to rename the option if some other name would fit better, though.

I realised that making this work involved moving lb_binary_linux-image
before lb_binary_rootfs.  This doesn't seem to have any ill effects that
I can detect from reading the code, so I've attached an updated patch
that does this too.


Colin Watson                                       [cjwatson@ubuntu.com]
>From 2acebebb81869948ca302a9bd5a75a0e13730f4d Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@canonical.com>
Date: Mon, 23 May 2011 13:12:01 +0100
Subject: [PATCH] Add an option to remove the kernel and initrd from the compressed filesystem.

 functions/defaults.sh               |    2 ++
 manpages/en/lb_config.1             |    4 ++++
 scripts/build/lb_binary             |    2 +-
 scripts/build/lb_binary_linux-image |    6 ++++++
 scripts/build/lb_config             |   12 +++++++++++-
 5 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/functions/defaults.sh b/functions/defaults.sh
index 8526335..a1e5c83 100755
--- a/functions/defaults.sh
+++ b/functions/defaults.sh
@@ -826,6 +826,8 @@ Set_defaults ()
 	# Setting apt indices
 	case "${LB_MODE}" in
diff --git a/manpages/en/lb_config.1 b/manpages/en/lb_config.1
index 88fcc9b..5e247b4 100644
--- a/manpages/en/lb_config.1
+++ b/manpages/en/lb_config.1
@@ -33,6 +33,8 @@
 	[\fB\-\-binary\-filesystem\fR fat16|fat32|ext2]
+	[\fB\-\-binary\-remove\-linux\fR true|false]
 	[\fB\-\-bootappend\-install\fR \fIPARAMETER\fR|\fI"PARAMETERS"\fR]
 	[\fB\-\-bootappend\-live\fR \fIPARAMETER\fR|\fI"PARAMETERS"\fR]
@@ -281,6 +283,8 @@ defines the architecture of the to be build image. By default, this is set to th
 defines the image type to build. By default, for images using syslinux this is set to iso\-hybrid to build CD/DVD images that may also be used like usb\-hdd images, for non\-syslinux images, it defaults to iso.
 .IP "\fB\-\-binary\-filesystem\fR fat16|fat32|ext2" 4
 defines the filesystem to be used in the image type. This only has an effect if the selected binary image type does allow to choose a filesystem. For example, when selection iso the resulting CD/DVD has always the filesystem ISO9660. When building usb\-hdd images for usb sticks, this is active. Note that it defaults to fat16 on all architectures except sparc where it defaults to ext2. Also note that if you choose fat16 and your resulting binary image gets bigger than 2GB, the binary filesystem automatically gets switched to fat32.
+.IP "\fB\-\-binary\-remove\-linux\fR true|false" 4
+defines if the Linux kernel and initrd should be removed from the filesystem (they will still be published in the binary output directory). This is useful to reduce image size if the image is not meant to be installable, or if the installer is intelligent enough to copy the kernel and initrd from the top-level image rather than from the compressed filesystem. Default is false.
 .IP "\fB\-\-bootappend\-install\fR \fIPARAMETER\fR|""\fIPARAMETERS\fR""" 4
 sets boot parameters specific to debian\-installer, if included.
 .IP "\fB\-\-bootappend\-live\fR \fIPARAMETER\fR|""\fIPARAMETERS\fR""" 4
diff --git a/scripts/build/lb_binary b/scripts/build/lb_binary
index 738363d..fb10ed0 100755
--- a/scripts/build/lb_binary
+++ b/scripts/build/lb_binary
@@ -54,12 +54,12 @@ then
 # Building root filesystem
+lb binary_linux-image ${*}
 lb binary_rootfs ${*}
 lb binary_manifest ${*}
 # Prepare images
 lb binary_local-packagelists ${*}
-lb binary_linux-image ${*}
 lb binary_debian-installer ${*}
 lb binary_memtest ${*}
 lb binary_grub ${*}
diff --git a/scripts/build/lb_binary_linux-image b/scripts/build/lb_binary_linux-image
index cac19d8..c5a8cc6 100755
--- a/scripts/build/lb_binary_linux-image
+++ b/scripts/build/lb_binary_linux-image
@@ -76,6 +76,12 @@ mkdir -p "${DESTDIR}"
 cp chroot/boot/"${LINUX}"-* "${DESTDIR}"
 cp chroot/boot/initrd.img-* "${DESTDIR}"
+if [ "${LB_BINARY_REMOVE_LINUX}" = true ]
+	rm -f chroot/boot/"${LINUX}"-*
+	rm -f chroot/boot/initrd.img-*
 case "${LB_INITRAMFS}" in
 		if [ -e chroot/usr/share/doc/live-boot/parameters.txt ]
diff --git a/scripts/build/lb_config b/scripts/build/lb_config
index 0e36240..a2f90eb 100755
--- a/scripts/build/lb_config
+++ b/scripts/build/lb_config
@@ -41,6 +41,7 @@ USAGE="${PROGRAM}   [--apt apt|aptitude]\n\
 \t    [-a|--architectures ARCHITECTURE]\n\
 \t    [-b|--binary-images iso|iso-hybrid|net|tar|usb-hdd]\n\
 \t    [--binary-filesystem fat16|fat32|ext2]\n\
+\t    [--binary-remove-linux true|false]\n\
 \t    [--bootappend-install PARAMETER|\"PARAMETERS\"]\n\
 \t    [--bootappend-live PARAMETER|\"PARAMETERS\"]\n\
 \t    [--bootloader grub|syslinux|yaboot]\n\
@@ -159,7 +160,7 @@ Local_arguments ()
-		packages:,package-lists:,tasks:,security:,volatile:,backports:,binary-filesystem:,binary-images:,
+		packages:,package-lists:,tasks:,security:,volatile:,backports:,binary-filesystem:,binary-images:,binary-remove-linux:,
@@ -603,6 +604,11 @@ Local_arguments ()
 				shift 2
+			--binary-remove-linux)
+				shift 2
+				;;
 				shift 2
 # (Default: ${LB_BINARY_IMAGES})
+# \$LB_BINARY_REMOVE_LINUX: set whether to remove kernel from filesystem
 # \$LB_APT_INDICES: set apt/aptitude generic indices
 # (Default: ${LB_APT_INDICES})

Reply to: