From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RuKye-0003m6-Mi for garchives@archives.gentoo.org; Mon, 06 Feb 2012 09:35:12 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DE339E05FE; Mon, 6 Feb 2012 09:35:04 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 99392E05FE for ; Mon, 6 Feb 2012 09:35:04 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0FC121B4046 for ; Mon, 6 Feb 2012 09:35:04 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 05D0680043 for ; Mon, 6 Feb 2012 09:35:03 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <94dc288487f2cb5c993ed471ed490a0031a65acc.robbat2@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: /, defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: ChangeLog defaults/config.sh gen_cmdline.sh gen_determineargs.sh gen_initramfs.sh genkernel.conf X-VCS-Directories: / defaults/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 94dc288487f2cb5c993ed471ed490a0031a65acc Date: Mon, 6 Feb 2012 09:35:03 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 78838352-5e08-41bf-be96-5634b4145246 X-Archives-Hash: 3437ac7c8be92b471408d8331acad684 commit: 94dc288487f2cb5c993ed471ed490a0031a65acc Author: Robin H. Johnson gentoo org> AuthorDate: Mon Feb 6 08:33:10 2012 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Mon Feb 6 09:31:59 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/genkernel.git= ;a=3Dcommit;h=3D94dc2884 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 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 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$ =20 + 06 Feb 2012; Robin H. Johnson defaults/config.sh, + gen_cmdline.sh, gen_determineargs.sh, gen_initramfs.sh, genkernel.conf= : + Import customizable compression for initramfs, based on Pentoo develop= ment. + 06 Feb 2012: Richard Yao arch/alpha/modules_l= oad, 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=3D"" KERNEL_BINARY=3D"arch/i386/boot/bzImage" KERNEL_BINARY_OVERRIDE=3D"" =20 -COMPRESS_INITRD=3Dyes +DEFAULT_COMPRESS_INITRD=3Dyes +DEFAULT_COMPRESS_INITRD_TYPE=3Dbest =20 # # 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=3D`parse_optbool "$*"` print_info 2 "CMD_INTEGRATED_INITRAMFS=3D${CMD_INTEGRATED_INITRAMFS}" ;; - --compress-initramfs|--no-compress-initramfs) + --compress-initramfs|--no-compress-initramfs|--compress-initrd|--no-co= mpress-initrd) CMD_COMPRESS_INITRD=3D`parse_optbool "$*"` print_info 2 "CMD_COMPRESS_INITRD=3D${CMD_COMPRESS_INITRD}" ;; + --compress-initramfs-type=3D*|--compress-initrd-type=3D*) + COMPRESS_INITRD_TYPE=3D`parse_opt "$*"` + print_info 2 "CMD_COMPRESS_INITRD_TYPE: ${CMD_LINUXRC}" + ;; --config=3D*) 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" =20 set_config_with_override STRING COMPRESS_INITRD CMD_COMPRESS_INITR= D "$DEFAULT_COMPRESS_INITRD" + set_config_with_override STRING COMPRESS_INITRD_TYPE CMD_COMPRESS_INITR= D_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 =20 - # Implement support for disabling compression - if isTrue "${COMPRESS_INITRD}" - then - compress_ext=3D".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=3D.*$|CONFIG_INITRAMFS_SOURCE=3D= \"${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=3D.*$/d' ${KERNEL_DIR}/.config - echo -e "CONFIG_INITRAMFS_SOURCE=3D\"${TMPDIR}/initramfs-${KV}.cpio${c= ompress_ext}\"\nCONFIG_INITRAMFS_ROOT_UID=3D0\nCONFIG_INITRAMFS_ROOT_GID=3D= 0" >> ${KERNEL_DIR}/.config + cat >>${KERNEL_DIR}/.config <<-EOF + CONFIG_INITRAMFS_SOURCE=3D"${TMPDIR}/initramfs-${KV}.cpio${compress_ex= t}" + CONFIG_INITRAMFS_ROOT_UID=3D0 + CONFIG_INITRAMFS_ROOT_GID=3D0 + EOF + else + if isTrue "${COMPRESS_INITRD}" + then + cmd_xz=3D$(type -p xz) + cmd_lzma=3D$(type -p lzma) + cmd_bzip2=3D$(type -p bzip2) + cmd_gzip=3D$(type -p gzip) + cmd_lzop=3D$(type -p lzop) + local compression + case ${COMPRESS_INITRD_TYPE} in + xz|lzma|bzip2|gzip2|lzo) compression=3D${COMPRESS_INITRD_TYPE} ;; + best) + if grep -sq '^CONFIG_RD_XZ=3Dy' ${KERNEL_DIR}/.config && test -n "$= {cmd_xz}" ; + compression=3Dxz + elif grep -sq '^CONFIG_RD_LZMA=3Dy' ${KERNEL_DIR}/.config && test -= n "${cmd_lzma}" ; + compression=3Dlzma + elif grep -sq '^CONFIG_RD_BZIP2=3Dy' ${KERNEL_DIR}/.config && test= -n "${cmd_bzip2}" ; + compression=3Dbzip2 + elif grep -sq '^CONFIG_RD_GZIP=3Dy' ${KERNEL_DIR}/.config && test -= n "${cmd_gzip}" ; + compression=3Dgzip + elif grep -sq '^CONFIG_RD_LZO=3Dy' ${KERNEL_DIR}/.config && test -n= "${cmd_lzop}" ; + compression=3Dlzo + fi ;; + esac + case $compression in + xz) compress_ext=3D'.xz' compress_cmd=3D"${cmd_xz} -e --check=3Dnone= -z -f -9" ;; + lzma) compress_ext=3D'.lzma' compress_cmd=3D"${cmd_lzma} -z -f -9" ;= ; + bzip2) compress_ext=3D'.bz2' compress_cmd=3D"${cmd_bzip2} -z -f -9" + gzip) compress_ext=3D'.gz' compress_cmd=3D"${cmd_gzip} -f -9" ;; + lzo) compress_ext=3D'.lzo' compress_cmd=3D"${cmd_lzop} -f -9" ;; + esac +=09 + 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 =20 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=3D"%%CACHE%%/gnupg-${GPG_VER}-%%ARCH%%.b= z2" =20 # Compress generated initramfs #COMPRESS_INITRD=3D"yes" +# Types of compression: best, xz, lzma, bzip2, gzip, lzop +# "best" selects the best available compression method +#COMPRESS_INITRD_TYPE=3D"best" =20 =20 # Create a self-contained env in the initramfs