Be more helpful when requested compression is not available
authorSebastian Pipping <sebastian@pipping.org>
Sun, 8 Apr 2012 18:03:17 +0000 (20:03 +0200)
committerSebastian Pipping <sebastian@pipping.org>
Sun, 8 Apr 2012 18:03:17 +0000 (20:03 +0200)
gen_initramfs.sh

index be0da85d2d0ddcbbdb485eec638963711c8659b0..a33fa7e1b29e69e7816d4c1a82a3f45286bf570a 100755 (executable)
@@ -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