From c0ed5530a5f904ab63ccffa2ce3ec43f4720be49 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 8 Apr 2012 19:41:34 +0200 Subject: [PATCH 1/7] Fix initrd compression "gzip", reported by Peter Gantner (bug #411197) --- ChangeLog | 3 +++ gen_initramfs.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 82da676..8c35954 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ # Distributed under the GPL v2 # $Id$ + 08 Apr 2012; Sebastian Pipping gen_initramfs.sh: + Fix initrd compression "gzip", reported by Peter Gantner (bug #411197) + 30 Mar 2012; Sebastian Pipping genkernel: Bump version to 3.4.28 diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 419d557..09592bc 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -707,7 +707,7 @@ create_initramfs() { cmd_lzop=$(type -p lzop) local compression case ${COMPRESS_INITRD_TYPE} in - xz|lzma|bzip2|gzip2|lzo) compression=${COMPRESS_INITRD_TYPE} ;; + xz|lzma|bzip2|gzip|lzo) compression=${COMPRESS_INITRD_TYPE} ;; best) if grep -sq '^CONFIG_RD_XZ=y' ${KERNEL_DIR}/.config && test -n "${cmd_xz}" ; then compression=xz From cfca839587edf11c76f9c1f7781dfba3d0c96d56 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 8 Apr 2012 19:42:15 +0200 Subject: [PATCH 2/7] Error out on unknown initrd compression, reported by Peter Gantner (bug #411197) --- ChangeLog | 4 ++++ gen_initramfs.sh | 3 +++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8c35954..c728da5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ # Distributed under the GPL v2 # $Id$ + 08 Apr 2012; Sebastian Pipping gen_initramfs.sh: + Error out on unknown initrd compression, reported by Peter Gantner (bug + #411197) + 08 Apr 2012; Sebastian Pipping gen_initramfs.sh: Fix initrd compression "gzip", reported by Peter Gantner (bug #411197) diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 09592bc..be0da85 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -720,6 +720,9 @@ create_initramfs() { elif grep -sq '^CONFIG_RD_LZO=y' ${KERNEL_DIR}/.config && test -n "${cmd_lzop}" ; then compression=lzo fi ;; + *) + gen_die "Compression '${COMPRESS_INITRD_TYPE}' unknown" + ;; esac case $compression in xz) compress_ext='.xz' compress_cmd="${cmd_xz} -e --check=none -z -f -9" ;; From b7efd3d65836d2ddba3396154e77e7ce62ed0710 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 8 Apr 2012 20:03:17 +0200 Subject: [PATCH 3/7] Be more helpful when requested compression is not available --- gen_initramfs.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gen_initramfs.sh b/gen_initramfs.sh index be0da85..a33fa7e 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -705,9 +705,15 @@ create_initramfs() { cmd_bzip2=$(type -p bzip2) cmd_gzip=$(type -p gzip) cmd_lzop=$(type -p lzop) + pkg_xz='app-arch/xz-utils' + pkg_lzma='app-arch/xz-utils' + pkg_bzip2='app-arch/bzip2' + pkg_gzip='app-arch/gzip' + pkg_lzop='app-arch/lzop' local compression case ${COMPRESS_INITRD_TYPE} in - xz|lzma|bzip2|gzip|lzo) compression=${COMPRESS_INITRD_TYPE} ;; + xz|lzma|bzip2|gzip) compression=${COMPRESS_INITRD_TYPE} ;; + lzo) compression=lzop ;; best) if grep -sq '^CONFIG_RD_XZ=y' ${KERNEL_DIR}/.config && test -n "${cmd_xz}" ; then compression=xz @@ -718,18 +724,24 @@ create_initramfs() { elif grep -sq '^CONFIG_RD_GZIP=y' ${KERNEL_DIR}/.config && test -n "${cmd_gzip}" ; then compression=gzip elif grep -sq '^CONFIG_RD_LZO=y' ${KERNEL_DIR}/.config && test -n "${cmd_lzop}" ; then - compression=lzo + compression=lzop fi ;; *) gen_die "Compression '${COMPRESS_INITRD_TYPE}' unknown" ;; esac + + # Check for actual availability + cmd_variable_name=cmd_${compression} + pkg_variable_name=pkg_${compression} + [[ -z "${!cmd_variable_name}" ]] && gen_die "Compression '${compression}' is not available. Please install package '${!pkg_variable_name}'." + 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" ;; + lzop) compress_ext='.lzo' compress_cmd="${cmd_lzop} -f -9" ;; esac if [ -n "${compression}" ]; then From 0da4543b8a23b882e536293a8af095707ebafb91 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 8 Apr 2012 20:27:01 +0200 Subject: [PATCH 4/7] Support comression "lzop" (not just "lzo") as wrongly advertised by comments in genkernel.conf before --- ChangeLog | 4 ++++ gen_initramfs.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c728da5..2533e58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ # Distributed under the GPL v2 # $Id$ + 08 Apr 2012; Sebastian Pipping gen_initramfs.sh: + Support comression "lzop" (not just "lzo") as wrongly advertised by comments + in genkernel.conf before + 08 Apr 2012; Sebastian Pipping gen_initramfs.sh: Error out on unknown initrd compression, reported by Peter Gantner (bug #411197) diff --git a/gen_initramfs.sh b/gen_initramfs.sh index a33fa7e..066c389 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -712,7 +712,7 @@ create_initramfs() { pkg_lzop='app-arch/lzop' local compression case ${COMPRESS_INITRD_TYPE} in - xz|lzma|bzip2|gzip) compression=${COMPRESS_INITRD_TYPE} ;; + xz|lzma|bzip2|gzip|lzop) compression=${COMPRESS_INITRD_TYPE} ;; lzo) compression=lzop ;; best) if grep -sq '^CONFIG_RD_XZ=y' ${KERNEL_DIR}/.config && test -n "${cmd_xz}" ; then From 10a2bde198877d240a20d45a93cb523df13d35a0 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 8 Apr 2012 20:27:08 +0200 Subject: [PATCH 5/7] Refactor code selecting best available initrd compression --- gen_initramfs.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 066c389..082d525 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -715,17 +715,21 @@ create_initramfs() { xz|lzma|bzip2|gzip|lzop) compression=${COMPRESS_INITRD_TYPE} ;; lzo) compression=lzop ;; best) - if grep -sq '^CONFIG_RD_XZ=y' ${KERNEL_DIR}/.config && test -n "${cmd_xz}" ; then - compression=xz - elif grep -sq '^CONFIG_RD_LZMA=y' ${KERNEL_DIR}/.config && test -n "${cmd_lzma}" ; then - compression=lzma - elif grep -sq '^CONFIG_RD_BZIP2=y' ${KERNEL_DIR}/.config && test -n "${cmd_bzip2}" ; then - compression=bzip2 - elif grep -sq '^CONFIG_RD_GZIP=y' ${KERNEL_DIR}/.config && test -n "${cmd_gzip}" ; then - compression=gzip - elif grep -sq '^CONFIG_RD_LZO=y' ${KERNEL_DIR}/.config && test -n "${cmd_lzop}" ; then - compression=lzop - fi ;; + for tuple in \ + 'CONFIG_RD_XZ cmd_xz xz' \ + 'CONFIG_RD_LZMA cmd_lzma lzma' \ + 'CONFIG_RD_BZIP2 cmd_bzip2 bzip' \ + 'CONFIG_RD_GZIP cmd_gzip gzip' \ + 'CONFIG_RD_LZO cmd_lzop lzop'; do + set -- ${tuple} + kernel_option=$1 + cmd_variable_name=$2 + if grep -sq "^${kernel_option}=y" ${KERNEL_DIR}/.config && test -n "${!cmd_variable_name}" ; then + compression=$3 + break + fi + done + ;; *) gen_die "Compression '${COMPRESS_INITRD_TYPE}' unknown" ;; From 66e5a247041af5406dfbc90acda436c3db0fa463 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 8 Apr 2012 20:24:14 +0200 Subject: [PATCH 6/7] Add "fastest" to supported initrd compressions --- ChangeLog | 4 ++++ gen_initramfs.sh | 4 ++-- genkernel.conf | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2533e58..2db901a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ # Distributed under the GPL v2 # $Id$ + 08 Apr 2012; Sebastian Pipping gen_initramfs.sh, + genkernel.conf: + Add "fastest" to supported initrd compressions + 08 Apr 2012; Sebastian Pipping gen_initramfs.sh: Support comression "lzop" (not just "lzo") as wrongly advertised by comments in genkernel.conf before diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 082d525..4838234 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -714,7 +714,7 @@ create_initramfs() { case ${COMPRESS_INITRD_TYPE} in xz|lzma|bzip2|gzip|lzop) compression=${COMPRESS_INITRD_TYPE} ;; lzo) compression=lzop ;; - best) + best|fastest) for tuple in \ 'CONFIG_RD_XZ cmd_xz xz' \ 'CONFIG_RD_LZMA cmd_lzma lzma' \ @@ -726,7 +726,7 @@ create_initramfs() { cmd_variable_name=$2 if grep -sq "^${kernel_option}=y" ${KERNEL_DIR}/.config && test -n "${!cmd_variable_name}" ; then compression=$3 - break + [[ ${COMPRESS_INITRD_TYPE} == best ]] && break fi done ;; diff --git a/genkernel.conf b/genkernel.conf index 0d14271..c5e7aee 100644 --- a/genkernel.conf +++ b/genkernel.conf @@ -314,8 +314,9 @@ GPG_BINCACHE="%%CACHE%%/gnupg-${GPG_VER}-%%ARCH%%.bz2" # Compress generated initramfs #COMPRESS_INITRD="yes" -# Types of compression: best, xz, lzma, bzip2, gzip, lzop +# Types of compression: best, xz, lzma, bzip2, gzip, lzop, fastest # "best" selects the best available compression method +# "fastest" selects the fastest available compression method #COMPRESS_INITRD_TYPE="best" From 14a930ba44b8e839a8c0bb81c23b6433dee4dbdf Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 8 Apr 2012 20:29:22 +0200 Subject: [PATCH 7/7] Extend change log --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2db901a..0e6d697 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,9 @@ Support comression "lzop" (not just "lzo") as wrongly advertised by comments in genkernel.conf before + 08 Apr 2012; Sebastian Pipping gen_initramfs.sh: + Be more helpful when requested compression is not available + 08 Apr 2012; Sebastian Pipping gen_initramfs.sh: Error out on unknown initrd compression, reported by Peter Gantner (bug #411197)