]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Trivial bashification and minor code rearrangement for initramfs compression.
authorVictor Lowther <victor.lowther@gmail.com>
Sat, 14 Aug 2010 19:23:26 +0000 (14:23 -0500)
committerHarald Hoyer <harald@redhat.com>
Mon, 23 Aug 2010 09:51:35 +0000 (11:51 +0200)
dracut

diff --git a/dracut b/dracut
index fcd32c1be3d2a3dd65486a50f8283c627986a07a..f70aa50045ed0d584d46783975695de56da829ca 100755 (executable)
--- 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"