mkinitrd unification across distributions
 help / color / mirror / Atom feed
* [PATCHv2] dracut-initramfs-restore,lsinitrd: add LZ4 support
@ 2014-01-16 10:00 Koen Kooi
       [not found] ` <1389866454-28426-1-git-send-email-koen-QLwJDigV5abLmq1fohREcCpxlwaOVQ5f@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Koen Kooi @ 2014-01-16 10:00 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Koen Kooi

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.

The lz4 command chokes on '--', so abstract that out into the CAT select.

Something similar will need to be done for LZO.

Signed-off-by: Koen Kooi <koen-QLwJDigV5abLmq1fohREcCpxlwaOVQ5f@public.gmane.org>
---
 dracut-initramfs-restore.sh |  2 ++
 lsinitrd.sh                 | 22 ++++++++++++----------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh
index ec5fe18..f29c814 100644
--- a/dracut-initramfs-restore.sh
+++ b/dracut-initramfs-restore.sh
@@ -20,6 +20,8 @@ if zcat "$IMG"  | cpio -id --quiet >/dev/null; then
     rm -f -- .need_shutdown
 elif xzcat "$IMG"  | cpio -id --quiet >/dev/null; then
     rm -f -- .need_shutdown
+elif lz4 -d -c "$IMG"  | cpio -id --quiet >/dev/null; then
+    rm -f -- .need_shutdown
 else
     # something failed, so we clean up
     echo "Unpacking of $IMG to /run/initramfs failed" >&2
diff --git a/lsinitrd.sh b/lsinitrd.sh
index 584c29a..f9f243b 100755
--- a/lsinitrd.sh
+++ b/lsinitrd.sh
@@ -106,15 +106,17 @@ fi
 read -N 6 bin < "$image"
 case $bin in
     $'\x1f\x8b'*)
-        CAT="zcat";;
+        CAT="zcat --";;
     BZh*)
-        CAT="bzcat";;
+        CAT="bzcat --";;
     $'\x71\xc7'*|070701)
-        CAT="cat";;
+        CAT="cat --";;
+    $'\x04\x22'*)
+        CAT="lz4 -d -c";;
     *)
-        CAT="xzcat";
+        CAT="xzcat --";
         if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
-            CAT="xzcat --single-stream"
+            CAT="xzcat --single-stream --"
         fi
         ;;
 esac
@@ -126,7 +128,7 @@ if (( ${#filenames[@]} > 0 )); then
     for f in ${!filenames[@]}; do
         [[ $nofileinfo ]] || echo "initramfs:/$f"
         [[ $nofileinfo ]] || echo "========================================================================"
-        $CAT -- $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
+        $CAT $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
         ((ret+=$?))
         [[ $nofileinfo ]] || echo "========================================================================"
         [[ $nofileinfo ]] || echo
@@ -134,16 +136,16 @@ if (( ${#filenames[@]} > 0 )); then
 else
     echo "Image: $image: $(du -h $image | while read a b; do echo $a;done)"
     echo "========================================================================"
-    version=$($CAT -- "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/dracut-*' 2>/dev/null)
+    version=$($CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/dracut-*' 2>/dev/null)
     ((ret+=$?))
     echo "$version with dracut modules:"
-    $CAT -- "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/modules.txt' 2>/dev/null
+    $CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/modules.txt' 2>/dev/null
     ((ret+=$?))
     echo "========================================================================"
     if [ "$sorted" -eq 1 ]; then
-        $CAT -- "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
+        $CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
     else
-        $CAT -- "$image" | cpio --extract --verbose --quiet --list | sort -k9
+        $CAT "$image" | cpio --extract --verbose --quiet --list | sort -k9
     fi
     ((ret+=$?))
     echo "========================================================================"
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-28 14:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-16 10:00 [PATCHv2] dracut-initramfs-restore,lsinitrd: add LZ4 support Koen Kooi
     [not found] ` <1389866454-28426-1-git-send-email-koen-QLwJDigV5abLmq1fohREcCpxlwaOVQ5f@public.gmane.org>
2014-01-28 14:40   ` Harald Hoyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox