public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/genkernel:xake commit in: /, doc/
@ 2011-04-11 17:51 Peter Hjalmarsson
  0 siblings, 0 replies; only message in thread
From: Peter Hjalmarsson @ 2011-04-11 17:51 UTC (permalink / raw
  To: gentoo-commits

commit:     9a724d7c41e34ef5c28d621e7dc9911a47a2eeee
Author:     Peter Hjalmarsson <xake <AT> rymdraket <DOT> net>
AuthorDate: Mon Apr 11 11:07:42 2011 +0000
Commit:     Peter Hjalmarsson <xake <AT> rymdraket <DOT> net>
CommitDate: Mon Apr 11 17:50:31 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=9a724d7c

Try to make compression format of the ramdisk customizable, fixes bug #279570

This is lightly tested but might need some work.
It is tested with gzip, bzip2, lzma, xz and lzo.
gzip is the default for legacy reasons
xz creates compared to gzip much smaller file, but is much slower
lzo creates compared to gzip just a little bigger file, but much faster
The rest are not as interesting and only supported for compeletness.

---
 doc/genkernel.8.txt  |    4 ++++
 gen_cmdline.sh       |    6 ++++++
 gen_determineargs.sh |    1 +
 gen_initramfs.sh     |   45 +++++++++++++++++++++++++++++++++++++++++++--
 genkernel.conf       |   11 +++++++++++
 5 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index afe2747..32755b4 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -154,6 +154,10 @@ KERNEL COMPILATION
     This builds a monolithic kernel without any modules on any
     initial ramdisks.
 
+*--ramdisk-format*=<format>::
+    This specifies a compression format for the ramdisk.
+    Supported values are gzip, bzip2, lzma, xz and lzo.
+
 
 KERNEL LOCATIONS
 ~~~~~~~~~~~~~~~~

diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 9e4009e..4ff6d3e 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -46,6 +46,8 @@ longusage() {
   echo "	--callback=<...>	Run the specified arguments after the"
   echo "				kernel and modules have been compiled"
   echo "	--static		Build a static (monolithic kernel)."
+  echo "	--ramdisk-format=<...>	Specify compression format for the ramdisk."
+  echo "				Supported formats are gzip, bzip2, lzma, xz and lzo"
   echo "  Kernel settings"
   echo "	--kerneldir=<dir>	Location of the kernel sources"
   echo "	--kernel-config=<file>	Kernel configuration file to use for compilation"
@@ -252,6 +254,10 @@ parse_cmdline() {
 			CMD_MDADM_CONFIG=`parse_opt "$*"`
 			print_info 2 "CMD_MDADM_CONFIG: $CMD_MDADM_CONFIG"
 			;;
+		--ramdisk-format=*)
+			CMD_RAMDISK_FORMAT=`parse_opt "$*"`
+			print_info 2 "CMD_RAMDISK_FORMAT: $CMD_RAMDISK_FORMAT"
+			;;
 		--no-busybox)
 			CMD_BUSYBOX=0
 			print_info 2 "CMD_BUSYBOX: ${CMD_BUSYBOX}"

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index e680569..54cd261 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -129,6 +129,7 @@ determine_real_args() {
 	set_config_with_override 1 KEYMAP               CMD_KEYMAP               "yes"
 	set_config_with_override 1 DOKEYMAPAUTO         CMD_DOKEYMAPAUTO
 	set_config_with_override 2 BUSYBOX_CONFIG       CMD_BUSYBOX_CONFIG
+	set_config_with_override 2 RAMDISK_FORMAT       CMD_RAMDISK_FORMAT
 
 	BOOTDIR=`arch_replace "${BOOTDIR}"`
 	BOOTDIR=${BOOTDIR%/}    # Remove any trailing slash

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 543f484..6c8a45c 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -662,6 +662,48 @@ append_data() {
 	fi
 }
 
+compress_initramfs() {
+	local COMPRESS_COMMAND COMPRESS_OPTIONS
+
+	COMPRESS_OPTIONS="-9 -c"
+
+	case "${RAMDISK_FORMAT}" in
+		GZIP|gzip)
+			COMPRESS_COMMAND="gzip"
+			RAMDISK_FORMAT="GZIP"
+		;;
+		BZIP2|bzip2)
+			COMPRESS_COMMAND="bzip2"
+			RAMDISK_FORMAT="BZIP2"
+		;;
+		XZ|xz)
+			COMPRESS_COMMAND="xz"
+			COMPRESS_OPTIONS="-9 -c --check=crc32"
+			RAMDISK_FORMAT="XZ"
+		;;
+		LZMA|lzma)
+			COMPRESS_COMMAND="lzma"
+			RAMDISK_FORMAT="LZMA"
+		;;
+		LZO|lzo)
+			COMPRESS_COMMAND="lzop"
+			RAMDISK_FORMAT="LZO"
+		;;
+		*)
+			print_info 1 "initramfs: Compression format for ramdisk not given or unsupported, using gzip as default"
+			COMPRESS_COMMAND="gzip"
+			RAMDISK_FORMAT="GZIP"
+		;;
+	esac
+
+	grep -q CONFIG_RD_"${RAMDISK_FORMAT}" "${KERNEL_DIR}"/.config || gen_die "Your current kernel does not support a ramdisk compressed with ${RAMDISK_FORMAT}"
+
+	which ${COMPRESS_COMMAND} > /dev/null 2>&1 || gen_die "You need to make sure command ${COMPRESS_COMMAND} is installed"
+
+	${COMPRESS_COMMAND} ${COMPRESS_OPTIONS} "$1" > "${CPIO}.compressed"
+	mv -f "${CPIO}.compressed" "${CPIO}"
+}
+
 create_initramfs() {
 	print_info 1 "initramfs: >> Initializing..."
 
@@ -706,8 +748,7 @@ create_initramfs() {
 		append_data 'overlay'
 	fi
 
-	gzip -9 "${CPIO}"
-	mv -f "${CPIO}.gz" "${CPIO}"
+	compress_initramfs "${CPIO}"
 
 	if isTrue "${INTEGRATED_INITRAMFS}"
 	then

diff --git a/genkernel.conf b/genkernel.conf
index a5988da..44f4dd1 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -106,6 +106,17 @@ DISKLABEL="yes"
 # This supersedes the "SPLASH_THEME" option of /etc/conf.d/splash (in early space).
 # SPLASH_THEME="gentoo"
 
+# This option makes it possible to choose what compressor the ramdisk should be
+# compressed with. Take care that the compressor is merged, and that the kernel 
+# has compiled in support for the decompressor.
+# Current supported formats are:
+# gzip (default, requires app-arch/gzip)
+# bzip2 (requires app-arch/bzip2)
+# lzma (requires app-arch/lzma or app-arch/xz)
+# xz (requires app-arch/xz)
+# lzo (requires app-arch/lzop)
+# RAMDISK_FORMAT="gzip"
+
 # =========Low Level Compile Settings=========
 #
 # GNU Make to use for kernel.  See also the --kernel-make command line option.



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-04-11 17:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-11 17:51 [gentoo-commits] proj/genkernel:xake commit in: /, doc/ Peter Hjalmarsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox