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

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