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

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