Blame SOURCES/0028-Add-lzo-lz4-compression-and-read-INITRD_COMPRESS.patch

712866
From 123feea1fab225478046db43454b10453df95b51 Mon Sep 17 00:00:00 2001
712866
From: P J P <ppandit@redhat.com>
712866
Date: Fri, 11 Oct 2013 19:26:51 +0530
712866
Subject: [PATCH] Add lzo, lz4 compression and read INITRD_COMPRESS
712866
712866
This patch adds support for lzop(1) & lz4(1) compression
712866
algorithms to compress iniramfs image file. Both are supported
712866
by the Linux kernel.
712866
712866
Linux kernel exports user's choice of initramfs compression
712866
algorithm as a shell environment variable: INITRD_COMPRESS.
712866
This patch adds support to read this variable and duly compress
712866
the initramfs image file.
712866
712866
Environment variable INITRD_COMPRESS has less precedence than the
712866
command line options --gzip, etc. Ie. command line options could
712866
override the compression algorithm defined by $INITRD_COMPRESS.
712866
712866
Signed-off-by: P J P <ppandit@redhat.com>
712866
712866
[Edited-by: Harald Hoyer: add documentation about lzo and lz4]
712866
---
712866
 dracut.8.asc | 16 ++++++++++++++++
712866
 dracut.sh    | 13 +++++++++++++
712866
 2 files changed, 29 insertions(+)
712866
712866
diff --git a/dracut.8.asc b/dracut.8.asc
712866
index 584514c..2ea6744 100644
712866
--- a/dracut.8.asc
712866
+++ b/dracut.8.asc
712866
@@ -365,6 +365,22 @@ Make sure your kernel has xz decompression support compiled in, otherwise you
712866
 will not be able to boot. Equivalent to "lzma --compress=xz --check=crc32 --lzma2=dict=1MiB"
712866
 ====
712866
 
712866
+**--lzo**::
712866
+    Compress the generated initramfs using lzop.
712866
+[WARNING]
712866
+====
712866
+Make sure your kernel has lzo decompression support compiled in, otherwise you
712866
+will not be able to boot.
712866
+====
712866
+
712866
+**--lz4**::
712866
+    Compress the generated initramfs using lz4.
712866
+[WARNING]
712866
+====
712866
+Make sure your kernel has lz4 decompression support compiled in, otherwise you
712866
+will not be able to boot.
712866
+====
712866
+
712866
 **--compress** _<compressor>_::
712866
     Compress the generated initramfs using the passed compression program. If
712866
     you pass it just the name of a compression program, it will call that
712866
diff --git a/dracut.sh b/dracut.sh
712866
index d9533dd..173a259 100755
712866
--- a/dracut.sh
712866
+++ b/dracut.sh
712866
@@ -165,6 +165,12 @@ Creates initial ramdisk images for preloading modules
712866
   --xz                  Compress the generated initramfs using xz.
712866
                          Make sure that your kernel has xz support compiled
712866
                          in, otherwise you will not be able to boot.
712866
+  --lzo                  Compress the generated initramfs using lzop.
712866
+                         Make sure that your kernel has lzo support compiled
712866
+                         in, otherwise you will not be able to boot.
712866
+  --lz4                  Compress the generated initramfs using lz4.
712866
+                         Make sure that your kernel has lz4 support compiled
712866
+                         in, otherwise you will not be able to boot.
712866
   --compress [COMPRESSION] Compress the generated initramfs with the
712866
                          passed compression program.  Make sure your kernel
712866
                          knows how to decompress the generated initramfs,
712866
@@ -342,6 +348,8 @@ TEMP=$(unset POSIXLY_CORRECT; getopt \
712866
     --long bzip2 \
712866
     --long lzma \
712866
     --long xz \
712866
+    --long lzo \
712866
+    --long lz4 \
712866
     --long no-compress \
712866
     --long gzip \
712866
     --long list-modules \
712866
@@ -430,6 +438,8 @@ while :; do
712866
         --bzip2)       compress_l="bzip2";;
712866
         --lzma)        compress_l="lzma";;
712866
         --xz)          compress_l="xz";;
712866
+        --lzo)         compress_l="lzo";;
712866
+        --lz4)         compress_l="lz4";;
712866
         --no-compress) _no_compress_l="cat";;
712866
         --gzip)        compress_l="gzip";;
712866
         --list-modules) do_list="yes";;
712866
@@ -673,6 +683,7 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
712866
 [[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware"
712866
 [[ $tmpdir_l ]] && tmpdir="$tmpdir_l"
712866
 [[ $tmpdir ]] || tmpdir=/var/tmp
712866
+[[ $INITRD_COMPRESS ]] && compress=$INITRD_COMPRESS
712866
 [[ $compress_l ]] && compress=$compress_l
712866
 [[ $show_modules_l ]] && show_modules=$show_modules_l
712866
 [[ $nofscks_l ]] && nofscks="yes"
712866
@@ -689,6 +700,8 @@ case $compress in
712866
     lzma)  compress="lzma -9";;
712866
     xz)    compress="xz --check=crc32 --lzma2=dict=1MiB";;
712866
     gzip)  compress="gzip -9"; command -v pigz > /dev/null 2>&1 && compress="pigz -9";;
712866
+    lzo)   compress="lzop -9";;
712866
+    lz4)   compress="lz4 -9";;
712866
 esac
712866
 if [[ $_no_compress_l = "cat" ]]; then
712866
     compress="cat"