From: Victor Lowther Date: Sat, 14 Aug 2010 19:23:26 +0000 (-0500) Subject: Trivial bashification and minor code rearrangement for initramfs compression. X-Git-Tag: 008~156 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b2ff4317f166bd2ba99371eec5d442ba3ede958a;p=thirdparty%2Fdracut.git Trivial bashification and minor code rearrangement for initramfs compression. --- diff --git a/dracut b/dracut index fcd32c1be..f70aa5004 100755 --- a/dracut +++ b/dracut @@ -136,10 +136,13 @@ while (($# > 0)); do --fstab) use_fstab_l="yes" ;; -h|--help) usage; exit 1 ;; -i|--include) include_src="$2"; include_target="$3"; shift 2;; - --gzip) [[ $compress != cat ]] && compress="gzip -9";; --bzip2) [[ $compress != cat ]] && compress="bzip2 -9";; --xz) [[ $compress != cat ]] && compress="xz -9";; --no-compress) compress="cat";; + --gzip) if [[ $compress != cat ]]; then + type pigz > /dev/null 2>&1 && compress="pigz -9" || \ + compress="gzip -9" + fi;; --ignore-kernel-modules) kernel_only="no"; no_kernel="yes" ignore_kmodules="yes" omit_dracutmodules_l+=\ kernel-modules @@ -258,7 +261,7 @@ fi hookdirs="cmdline pre-udev pre-trigger netroot pre-mount pre-pivot mount emergency" -[[ -n "$TMPDIR" ]] && ! [[ -w "$TMPDIR" ]] && unset TMPDIR +[[ $TMPDIR && ! -w $TMPDIR ]] && unset TMPDIR readonly initdir=$(mktemp -d -t initramfs.XXXXXX) trap 'ret=$?;rm -rf "$initdir";exit $ret;' EXIT # clean up after ourselves no matter how we die. @@ -357,7 +360,6 @@ type hardlink &>/dev/null && { hardlink "$initdir" 2>&1 } -[[ $compress = gzip* ]] && type pigz > /dev/null 2>&1 && compress="pigz -9" if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet | \ $compress > "$outfile"; ); then derror "dracut: creation of $outfile failed"