public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Robin H. Johnson" <robbat2@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/genkernel:master commit in: /, defaults/
Date: Mon,  6 Feb 2012 09:35:03 +0000 (UTC)	[thread overview]
Message-ID: <94dc288487f2cb5c993ed471ed490a0031a65acc.robbat2@gentoo> (raw)

commit:     94dc288487f2cb5c993ed471ed490a0031a65acc
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Feb  6 08:33:10 2012 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Feb  6 09:31:59 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=94dc2884

Customizable initramfs compression based on Pentoo genkernel fork

This implements customizable initramfs compression, based on the Pentoo
genkernel fork (SVN revs r2142, r2145, by Jens Pranaitis
<jens <AT> chaox.net>).

New configuration option COMPRESS_INITRD_TYPE to allow manual selection,
whereas the Pentoo fork provided auto-selection based on what was
available in the kernel configuration. Auto-selection is used by
default, and is available with the argument of 'best' to the new option.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

---
 ChangeLog            |    4 +++
 defaults/config.sh   |    3 +-
 gen_cmdline.sh       |    6 ++++-
 gen_determineargs.sh |    1 +
 gen_initramfs.sh     |   62 ++++++++++++++++++++++++++++++++++++++-----------
 genkernel.conf       |    3 ++
 6 files changed, 63 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d6e4dcf..e2cc9ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@
 # Distributed under the GPL v2
 # $Id$
 
+  06 Feb 2012; Robin H. Johnson <robbat2@gentoo.org> defaults/config.sh,
+  gen_cmdline.sh, gen_determineargs.sh, gen_initramfs.sh, genkernel.conf:
+  Import customizable compression for initramfs, based on Pentoo development.
+
   06 Feb 2012: Richard Yao <ryao@cs.stonybrook.edu> arch/alpha/modules_load,
   arch/arm/modules_load, arch/ia64/modules_load, arch/mips/modules_load,
   arch/parisc/modules_load, arch/parisc64/modules_load, arch/ppc/modules_load,

diff --git a/defaults/config.sh b/defaults/config.sh
index d135e0e..7ee9ef2 100755
--- a/defaults/config.sh
+++ b/defaults/config.sh
@@ -12,7 +12,8 @@ KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="arch/i386/boot/bzImage"
 KERNEL_BINARY_OVERRIDE=""
 
-COMPRESS_INITRD=yes
+DEFAULT_COMPRESS_INITRD=yes
+DEFAULT_COMPRESS_INITRD_TYPE=best
 
 #
 # Arch-specific defaults that can be overridden in the config file or on the

diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index de56a25..aabaa7e 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -537,10 +537,14 @@ parse_cmdline() {
 			CMD_INTEGRATED_INITRAMFS=`parse_optbool "$*"`
 			print_info 2 "CMD_INTEGRATED_INITRAMFS=${CMD_INTEGRATED_INITRAMFS}"
 			;;
-		--compress-initramfs|--no-compress-initramfs)
+		--compress-initramfs|--no-compress-initramfs|--compress-initrd|--no-compress-initrd)
 			CMD_COMPRESS_INITRD=`parse_optbool "$*"`
 			print_info 2 "CMD_COMPRESS_INITRD=${CMD_COMPRESS_INITRD}"
 			;;
+		--compress-initramfs-type=*|--compress-initrd-type=*)
+			COMPRESS_INITRD_TYPE=`parse_opt "$*"`
+			print_info 2 "CMD_COMPRESS_INITRD_TYPE: ${CMD_LINUXRC}"
+			;;
 		--config=*)
 			print_info 2 "CMD_GK_CONFIG: `parse_opt "$*"`"
 			;;

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index e6ed0a3..4a21530 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -76,6 +76,7 @@ determine_real_args() {
 	set_config_with_override STRING KNAME                CMD_KERNNAME             "genkernel"
 
 	set_config_with_override STRING COMPRESS_INITRD      CMD_COMPRESS_INITRD      "$DEFAULT_COMPRESS_INITRD"
+	set_config_with_override STRING COMPRESS_INITRD_TYPE CMD_COMPRESS_INITRD_TYPE "$DEFAULT_COMPRESS_INITRD_TYPE"
 	set_config_with_override STRING MAKEOPTS             CMD_MAKEOPTS             "$DEFAULT_MAKEOPTS"
 	set_config_with_override STRING KERNEL_MAKE          CMD_KERNEL_MAKE          "$DEFAULT_KERNEL_MAKE"
 	set_config_with_override STRING UTILS_MAKE           CMD_UTILS_MAKE           "$DEFAULT_UTILS_MAKE"

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 170361b..3aab15d 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -686,23 +686,57 @@ create_initramfs() {
 		append_data 'overlay'
 	fi
 
-	# Implement support for disabling compression
-	if isTrue "${COMPRESS_INITRD}"
-	then
-		compress_ext=".gz"
-		print_info 1 "        >> Compressing cpio data..."
-		gzip -9 "${CPIO}" || gen_die "Compression failed"
-		mv -f "${CPIO}.gz" "${CPIO}" || gen_die "Rename failed"
-	fi
-
-
 	if isTrue "${INTEGRATED_INITRAMFS}"
 	then
-#		cp ${TMPDIR}/initramfs-${KV} ${KERNEL_DIR}/usr/initramfs_data.cpio.gz
-		mv ${TMPDIR}/initramfs-${KV} ${TMPDIR}/initramfs-${KV}.cpio${compress_ext}
-#		sed -i "s|^.*CONFIG_INITRAMFS_SOURCE=.*$|CONFIG_INITRAMFS_SOURCE=\"${TMPDIR}/initramfs-${KV}.cpio.gz\"|" ${KERNEL_DIR}/.config
+		# Explicitly do not compress if we are integrating into the kernel.
+		# The kernel will do a better job of it than us.
+		mv ${TMPDIR}/initramfs-${KV} ${TMPDIR}/initramfs-${KV}.cpio
 		sed -i '/^.*CONFIG_INITRAMFS_SOURCE=.*$/d' ${KERNEL_DIR}/.config
-		echo -e "CONFIG_INITRAMFS_SOURCE=\"${TMPDIR}/initramfs-${KV}.cpio${compress_ext}\"\nCONFIG_INITRAMFS_ROOT_UID=0\nCONFIG_INITRAMFS_ROOT_GID=0" >> ${KERNEL_DIR}/.config
+		cat >>${KERNEL_DIR}/.config	<<-EOF
+		CONFIG_INITRAMFS_SOURCE="${TMPDIR}/initramfs-${KV}.cpio${compress_ext}"
+		CONFIG_INITRAMFS_ROOT_UID=0
+		CONFIG_INITRAMFS_ROOT_GID=0
+		EOF
+	else
+		if isTrue "${COMPRESS_INITRD}"
+		then
+			cmd_xz=$(type -p xz)
+			cmd_lzma=$(type -p lzma)
+			cmd_bzip2=$(type -p bzip2)
+			cmd_gzip=$(type -p gzip)
+			cmd_lzop=$(type -p lzop)
+			local compression
+			case ${COMPRESS_INITRD_TYPE} in
+				xz|lzma|bzip2|gzip2|lzo) compression=${COMPRESS_INITRD_TYPE} ;;
+				best)
+					if grep -sq '^CONFIG_RD_XZ=y' ${KERNEL_DIR}/.config && test -n "${cmd_xz}" ;
+						compression=xz
+					elif grep -sq '^CONFIG_RD_LZMA=y' ${KERNEL_DIR}/.config && test -n "${cmd_lzma}" ;
+						compression=lzma
+					elif grep -sq '^CONFIG_RD_BZIP2=y' ${KERNEL_DIR}/.config  && test -n "${cmd_bzip2}" ;
+						compression=bzip2
+					elif grep -sq '^CONFIG_RD_GZIP=y' ${KERNEL_DIR}/.config && test -n "${cmd_gzip}" ;
+						compression=gzip
+					elif grep -sq '^CONFIG_RD_LZO=y' ${KERNEL_DIR}/.config && test -n "${cmd_lzop}" ;
+						compression=lzo
+					fi ;;
+			esac
+			case $compression in
+				xz) compress_ext='.xz' compress_cmd="${cmd_xz} -e --check=none -z -f -9" ;;
+				lzma) compress_ext='.lzma' compress_cmd="${cmd_lzma} -z -f -9" ;;
+				bzip2) compress_ext='.bz2' compress_cmd="${cmd_bzip2} -z -f -9"
+				gzip) compress_ext='.gz' compress_cmd="${cmd_gzip} -f -9" ;;
+				lzo) compress_ext='.lzo' compress_cmd="${cmd_lzop} -f -9" ;;
+			esac
+	
+			if [ -n "${compression}" ]; then
+				print_info 1 "        >> Compressing cpio data (${compress_ext})..."
+				${compress_cmd} "${CPIO}" || gen_die "Compression (${compress_cmd}) failed"
+				mv -f "${CPIO}${compress_ext}" "${CPIO}" || gen_die "Rename failed"
+			else
+				print_info 1 "        >> Not compressing cpio data ..."
+			fi
+		fi
 	fi
 
 	if isTrue "${CMD_INSTALL}"

diff --git a/genkernel.conf b/genkernel.conf
index 7032ac7..22b18d7 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -319,6 +319,9 @@ GPG_BINCACHE="%%CACHE%%/gnupg-${GPG_VER}-%%ARCH%%.bz2"
 
 # Compress generated initramfs
 #COMPRESS_INITRD="yes"
+# Types of compression: best, xz, lzma, bzip2, gzip, lzop
+# "best" selects the best available compression method
+#COMPRESS_INITRD_TYPE="best"
 
 
 # Create a self-contained env in the initramfs



             reply	other threads:[~2012-02-06  9:35 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-06  9:35 Robin H. Johnson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-07-23 23:57 [gentoo-commits] proj/genkernel:master commit in: /, defaults/ Thomas Deutschmann
2019-11-26 13:50 Thomas Deutschmann
2019-07-21 16:26 Thomas Deutschmann
2017-09-04  5:36 Robin H. Johnson
2017-01-08  1:57 Robin H. Johnson
2017-01-07 23:50 Robin H. Johnson
2017-01-02 23:25 Robin H. Johnson
2016-05-16  6:55 Robin H. Johnson
2016-01-05 19:39 Robin H. Johnson
2016-01-05 19:39 Robin H. Johnson
2013-06-06  3:36 [gentoo-commits] proj/genkernel:ryao " Richard Yao
2013-06-03 23:49 ` [gentoo-commits] proj/genkernel:master " Richard Yao
2013-04-25  6:22 Fabio Erculiani
2012-10-16  0:03 Robin H. Johnson
2012-10-03 16:24 Sebastian Pipping
2012-08-30 16:20 Fabio Erculiani
2012-08-12 19:04 Sebastian Pipping
2012-07-24 18:01 Robin H. Johnson
2012-07-24 17:29 Robin H. Johnson
2012-07-24  8:29 Robin H. Johnson
2012-07-19 20:12 Richard Yao
2012-07-09 17:51 Sebastian Pipping
2012-07-08 17:05 Sebastian Pipping
2012-05-17 18:34 Sebastian Pipping
2012-03-17  1:27 Sebastian Pipping
2012-03-17  1:27 Sebastian Pipping
2012-03-17  1:27 Sebastian Pipping
2012-03-17  1:27 Sebastian Pipping
2012-02-20  6:58 Robin H. Johnson
2012-02-09  7:42 Robin H. Johnson
2012-02-06  8:19 Robin H. Johnson
2012-01-14 23:22 Sebastian Pipping
2012-01-13 23:19 Sebastian Pipping
2012-01-13 23:19 Sebastian Pipping
2012-01-06  6:37 Robin H. Johnson
2011-11-08 17:21 Sebastian Pipping
2011-10-08 21:22 Fabio Erculiani
2011-09-13  9:54 Fabio Erculiani
2011-09-11  7:40 Fabio Erculiani
2011-08-30 15:34 Sebastian Pipping
2011-07-27 17:38 Sebastian Pipping
2011-05-31 10:58 Sebastian Pipping

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=94dc288487f2cb5c993ed471ed490a0031a65acc.robbat2@gentoo \
    --to=robbat2@gentoo.org \
    --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