public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Peter Hjalmarsson" <xake@rymdraket.net>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/genkernel:xake commit in: /
Date: Mon, 11 Apr 2011 15:59:09 +0000 (UTC)	[thread overview]
Message-ID: <060b3aef60f26b18eabf54a99c3067e01f4dc9da.xake@gentoo> (raw)

commit:     060b3aef60f26b18eabf54a99c3067e01f4dc9da
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 15:58:43 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=060b3aef

Try to make compression format of the ramdisk customizable.

This is currently untested and might need some work, but should fix bug #279570.

---
 gen_cmdline.sh       |    6 ++++++
 gen_determineargs.sh |    1 +
 gen_initramfs.sh     |   40 ++++++++++++++++++++++++++++++++++++++--
 genkernel.conf       |   11 +++++++++++
 4 files changed, 56 insertions(+), 2 deletions(-)

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..e69b821 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -662,6 +662,43 @@ append_data() {
 	fi
 }
 
+compress_initramfs() {
+	local COMPRESS_COMMAND
+
+	case "${RAMDISK_FORMAT}" in
+		GZIP|gzip)
+			COMPRESS_COMMAND="gzip -9 -c"
+			RAMDISK_FORMAT="GZIP"
+		;;
+		BZIP2|bzip2)
+			COMPRESS_COMMAND="bzip2 -9 -c"
+			RAMDISK_FORMAT="BZIP2"
+		;;
+		XZ|xz)
+			COMPRESS_COMMAND="xz -9 -c"
+			RAMDISK_FORMAT="XZ"
+		;;
+		LZMA|lzma)
+			COMPRESS_COMMAND="lzma -9 -c"
+			RAMDISK_FORMAT="LZMA"
+		;;
+		LZO|lzo)
+			COMPRESS_COMMAND="lzop -9 -c"
+			RAMDISK_FORMAT="LZO"
+		;;
+		*)
+			print_info 1 "initramfs: Compression format for ramdisk not given or unsupported, using gzip as default"
+			COMPRESS_COMMAND="gzip -9 -c"
+			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}"
+
+	"${COMPRESS_COMMAND}" "$1" > "${CPIO}.compressed"
+	mv -f "${CPIO}.compressed" "${CPIO}"
+}
+
 create_initramfs() {
 	print_info 1 "initramfs: >> Initializing..."
 
@@ -706,8 +743,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..7b42d9f 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.



             reply	other threads:[~2011-04-11 15:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-11 15:59 Peter Hjalmarsson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-07-24  6:28 [gentoo-commits] proj/genkernel:xake commit in: / Peter Hjalmarsson
2012-07-24  6:28 Peter Hjalmarsson
2012-07-24  6:28 Peter Hjalmarsson
2012-07-24  6:28 Peter Hjalmarsson
2012-07-24  6:28 Peter Hjalmarsson
2012-07-24  6:28 Peter Hjalmarsson
2012-10-13 21:49 Robin H. Johnson
2012-10-13 21:49 Robin H. Johnson
2012-10-13 21:49 Robin H. Johnson
2012-10-13 21:49 Robin H. Johnson
2012-10-15 21:50 Peter Hjalmarsson
2012-10-15 21:50 Peter Hjalmarsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=060b3aef60f26b18eabf54a99c3067e01f4dc9da.xake@gentoo \
    --to=xake@rymdraket.net \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox