From: Sebastian Pipping Date: Sun, 8 Apr 2012 18:27:08 +0000 (+0200) Subject: Refactor code selecting best available initrd compression X-Git-Tag: v3.4.29~2^2~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=10a2bde198877d240a20d45a93cb523df13d35a0;p=genkernel.git Refactor code selecting best available initrd compression --- 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" ;;