From fe7e630857d2fd1c9b7af48f33d46e626ac6509e Mon Sep 17 00:00:00 2001 From: Bert Schulze Date: Sun, 4 Apr 2010 17:43:48 +0200 Subject: mkinitramfs: -c compression support / commandline override fixed the commandline argument to select the compressor. also your test with "command" needed to be negated otherwise the fallback to gzip would take place everytime. -- frohe ostern Bert Schulze [ nuked trailing whitespace, and add comment for usage() ] Signed-off-by: maximilian attems --- hook-functions | 10 ++++++---- mkinitramfs | 15 ++++++++++++--- mkinitramfs.8 | 9 +++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/hook-functions b/hook-functions index cf8ea54..ab2f486 100644 --- a/hook-functions +++ b/hook-functions @@ -465,6 +465,7 @@ auto_add_modules() esac } +# mkinitramfs help message usage() { cat >&2 << EOF @@ -472,10 +473,11 @@ usage() Usage: ${0} [OPTION]... -o outfile [version] Options: - -d confdir Specify an alternative configuration directory. - -k Keep temporary directory used to make the image. - -o outfile Write to outfile. - -r root Override ROOT setting in initramfs.conf. + -c compress Override COMPRESS setting in initramfs.conf. + -d confdir Specify an alternative configuration directory. + -k Keep temporary directory used to make the image. + -o outfile Write to outfile. + -r root Override ROOT setting in initramfs.conf. See mkinitramfs(8) for further details. EOF diff --git a/mkinitramfs b/mkinitramfs index 33ef99b..110aca8 100755 --- a/mkinitramfs +++ b/mkinitramfs @@ -11,7 +11,7 @@ errors_to="2>/dev/null" # BUSYBOXDIR="/usr/lib/initramfs-tools/bin/" export BUSYBOXDIR="/bin" -OPTIONS=`getopt -o d:ko:r:v -n "$0" -- "$@"` +OPTIONS=`getopt -o c:d:ko:r:v -n "$0" -- "$@"` # Check for non-GNU getopt if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi @@ -20,6 +20,10 @@ eval set -- "$OPTIONS" while true; do case "$1" in + -c) + compress="$2" + shift 2 + ;; -d) CONFDIR="$2" shift 2 @@ -124,8 +128,13 @@ case "${version}" in esac # Check userspace and kernel support for compressed initramfs images -compress=${COMPRESS} -if command -v ${compress} >/dev/null 2>&1; then +if [ -z "${compress}" ]; then + compress=${COMPRESS} +else + COMPRESS=${compress} +fi + +if ! command -v ${compress} >/dev/null 2>&1; then compress=gzip [ "${verbose}" = y ] && \ echo "No ${COMPRESS} in ${PATH}, using gzip" diff --git a/mkinitramfs.8 b/mkinitramfs.8 index d999957..7fdeefb 100644 --- a/mkinitramfs.8 +++ b/mkinitramfs.8 @@ -5,6 +5,8 @@ mkinitramfs \- low-level tool for generating an initramfs image .SH SYNOPSIS .B mkinitramfs +.RB [ \-c +.IR compress ] .RB [ \-d .IR confdir ] .RB [ \-k ] @@ -44,6 +46,13 @@ uses it as initial root file system. All finding of the root device happens in this early userspace. .SH OPTIONS +.TP +\fB \-c \fI compress +Override the +.B COMPRESS +setting in +.IR initramfs.conf . + .TP \fB \-d \fI confdir Set an alternate configuration directory. -- cgit v1.2.3