Blame 0010-Add-lzo-lz4-compression-and-read-INITRD_COMPRESS.patch

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