Blame SOURCES/0090-dracut-initramfs-restore-lsinitrd-add-LZ4-support.patch

712866
From a0b85db18e163a14144230ae67c43ac23246b7ea Mon Sep 17 00:00:00 2001
712866
From: Koen Kooi <koen@dominion.thruhere.net>
712866
Date: Thu, 16 Jan 2014 11:00:54 +0100
712866
Subject: [PATCH] dracut-initramfs-restore,lsinitrd: add LZ4 support
712866
712866
Dracut claims to have LZ4 support, but trying to use it will result in an xzcat failure at the end due to missing CAT support.
712866
712866
The lz4 command chokes on '--', so abstract that out into the CAT select.
712866
712866
Something similar will need to be done for LZO.
712866
712866
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
712866
---
712866
 dracut-initramfs-restore.sh |  2 ++
712866
 lsinitrd.sh                 | 22 ++++++++++++----------
712866
 2 files changed, 14 insertions(+), 10 deletions(-)
712866
712866
diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh
5c6c2a
index ec5fe180..f29c8146 100644
712866
--- a/dracut-initramfs-restore.sh
712866
+++ b/dracut-initramfs-restore.sh
712866
@@ -20,6 +20,8 @@ if zcat "$IMG"  | cpio -id --quiet >/dev/null; then
712866
     rm -f -- .need_shutdown
712866
 elif xzcat "$IMG"  | cpio -id --quiet >/dev/null; then
712866
     rm -f -- .need_shutdown
712866
+elif lz4 -d -c "$IMG"  | cpio -id --quiet >/dev/null; then
712866
+    rm -f -- .need_shutdown
712866
 else
712866
     # something failed, so we clean up
712866
     echo "Unpacking of $IMG to /run/initramfs failed" >&2
712866
diff --git a/lsinitrd.sh b/lsinitrd.sh
5c6c2a
index 584c29a9..f9f243bb 100755
712866
--- a/lsinitrd.sh
712866
+++ b/lsinitrd.sh
712866
@@ -106,15 +106,17 @@ fi
712866
 read -N 6 bin < "$image"
712866
 case $bin in
712866
     $'\x1f\x8b'*)
712866
-        CAT="zcat";;
712866
+        CAT="zcat --";;
712866
     BZh*)
712866
-        CAT="bzcat";;
712866
+        CAT="bzcat --";;
712866
     $'\x71\xc7'*|070701)
712866
-        CAT="cat";;
712866
+        CAT="cat --";;
712866
+    $'\x04\x22'*)
712866
+        CAT="lz4 -d -c";;
712866
     *)
712866
-        CAT="xzcat";
712866
+        CAT="xzcat --";
712866
         if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
712866
-            CAT="xzcat --single-stream"
712866
+            CAT="xzcat --single-stream --"
712866
         fi
712866
         ;;
712866
 esac
712866
@@ -126,7 +128,7 @@ if (( ${#filenames[@]} > 0 )); then
712866
     for f in ${!filenames[@]}; do
712866
         [[ $nofileinfo ]] || echo "initramfs:/$f"
712866
         [[ $nofileinfo ]] || echo "========================================================================"
712866
-        $CAT -- $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
712866
+        $CAT $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
712866
         ((ret+=$?))
712866
         [[ $nofileinfo ]] || echo "========================================================================"
712866
         [[ $nofileinfo ]] || echo
712866
@@ -134,16 +136,16 @@ if (( ${#filenames[@]} > 0 )); then
712866
 else
712866
     echo "Image: $image: $(du -h $image | while read a b; do echo $a;done)"
712866
     echo "========================================================================"
712866
-    version=$($CAT -- "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/dracut-*' 2>/dev/null)
712866
+    version=$($CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/dracut-*' 2>/dev/null)
712866
     ((ret+=$?))
712866
     echo "$version with dracut modules:"
712866
-    $CAT -- "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/modules.txt' 2>/dev/null
712866
+    $CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/modules.txt' 2>/dev/null
712866
     ((ret+=$?))
712866
     echo "========================================================================"
712866
     if [ "$sorted" -eq 1 ]; then
712866
-        $CAT -- "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
712866
+        $CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
712866
     else
712866
-        $CAT -- "$image" | cpio --extract --verbose --quiet --list | sort -k9
712866
+        $CAT "$image" | cpio --extract --verbose --quiet --list | sort -k9
712866
     fi
712866
     ((ret+=$?))
712866
     echo "========================================================================"