Blame 0005-lsinitrd.sh-prevent-construct.patch

Harald Hoyer 240f09
From fd9f902477a8d8df6ce0fa1b044484c435fff247 Mon Sep 17 00:00:00 2001
Harald Hoyer 240f09
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 240f09
Date: Thu, 27 Mar 2014 09:27:53 +0100
Harald Hoyer 240f09
Subject: [PATCH] lsinitrd.sh: prevent < <$() construct
Harald Hoyer 240f09
MIME-Version: 1.0
Harald Hoyer 240f09
Content-Type: text/plain; charset=UTF-8
Harald Hoyer 240f09
Content-Transfer-Encoding: 8bit
Harald Hoyer 240f09
Harald Hoyer 240f09
Running dracut in a chroot environment, which has /dev not correctly
Harald Hoyer 240f09
setup will result in errors like:
Harald Hoyer 240f09
Harald Hoyer 240f09
/usr/bin/lsinitrd: line 164: /dev/fd/62: No such file or directory
Harald Hoyer 240f09
cpio: Malformed number �5�OK��
Harald Hoyer 240f09
cpio: Malformed number 5�OK��
Harald Hoyer 240f09
cpio: Malformed number �OK��
Harald Hoyer 240f09
Harald Hoyer 240f09
This is because bash wants /dev/fd/<num> for constructs like:
Harald Hoyer 240f09
foo < <$(bar)
Harald Hoyer 240f09
---
Harald Hoyer 240f09
 lsinitrd.sh | 50 +++++++++++++++++++++++++++++---------------------
Harald Hoyer 240f09
 1 file changed, 29 insertions(+), 21 deletions(-)
Harald Hoyer 240f09
Harald Hoyer 240f09
diff --git a/lsinitrd.sh b/lsinitrd.sh
Zbigniew Jędrzejewski-Szmek 7f4a44
index 8dc9032378..a697bc2b75 100755
Harald Hoyer 240f09
--- a/lsinitrd.sh
Harald Hoyer 240f09
+++ b/lsinitrd.sh
Harald Hoyer 240f09
@@ -160,27 +160,35 @@ case $bin in
Harald Hoyer 240f09
         ;;
Harald Hoyer 240f09
 esac
Harald Hoyer 240f09
 
Harald Hoyer 240f09
-if [[ $SKIP ]]; then
Harald Hoyer 240f09
-    read -N 6 bin < <($SKIP "$image")
Harald Hoyer 240f09
-fi
Harald Hoyer 240f09
-
Harald Hoyer 240f09
-case $bin in
Harald Hoyer 240f09
-    $'\x1f\x8b'*)
Harald Hoyer 240f09
-        CAT="zcat --";;
Harald Hoyer 240f09
-    BZh*)
Harald Hoyer 240f09
-        CAT="bzcat --";;
Harald Hoyer 240f09
-    $'\x71\xc7'*|070701)
Harald Hoyer 240f09
-        CAT="cat --"
Harald Hoyer 240f09
-        ;;
Harald Hoyer 240f09
-    $'\x02\x21'*)
Harald Hoyer 240f09
-        CAT="lz4 -d -c";;
Harald Hoyer 240f09
-    *)
Harald Hoyer 240f09
-        CAT="xzcat --";
Harald Hoyer 240f09
-        if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
Harald Hoyer 240f09
-            CAT="xzcat --single-stream --"
Harald Hoyer 240f09
-        fi
Harald Hoyer 240f09
-        ;;
Harald Hoyer 240f09
-esac
Harald Hoyer 240f09
+CAT=$({
Harald Hoyer 240f09
+        if [[ $SKIP ]]; then
Harald Hoyer 240f09
+            $SKIP "$image"
Harald Hoyer 240f09
+        else
Harald Hoyer 240f09
+            cat "$image"
Harald Hoyer 240f09
+        fi } | {
Harald Hoyer 240f09
+        read -N 6 bin
Harald Hoyer 240f09
+        case $bin in
Harald Hoyer 240f09
+            $'\x1f\x8b'*)
Harald Hoyer 240f09
+                echo "zcat --"
Harald Hoyer 240f09
+                ;;
Harald Hoyer 240f09
+            BZh*)
Harald Hoyer 240f09
+                echo "bzcat --"
Harald Hoyer 240f09
+                ;;
Harald Hoyer 240f09
+            $'\x71\xc7'*|070701)
Harald Hoyer 240f09
+                echo "cat --"
Harald Hoyer 240f09
+                ;;
Harald Hoyer 240f09
+            $'\x02\x21'*)
Harald Hoyer 240f09
+                echo "lz4 -d -c"
Harald Hoyer 240f09
+                ;;
Harald Hoyer 240f09
+            *)
Harald Hoyer 240f09
+                if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
Harald Hoyer 240f09
+                    echo "xzcat --single-stream --"
Harald Hoyer 240f09
+                else
Harald Hoyer 240f09
+                    echo "xzcat --"
Harald Hoyer 240f09
+                fi
Harald Hoyer 240f09
+                ;;
Harald Hoyer 240f09
+        esac
Harald Hoyer 240f09
+    })
Harald Hoyer 240f09
 
Harald Hoyer 240f09
 skipcpio()
Harald Hoyer 240f09
 {
Zbigniew Jędrzejewski-Szmek 7f4a44
-- 
Zbigniew Jędrzejewski-Szmek 7f4a44
1.9.3
Zbigniew Jędrzejewski-Szmek 7f4a44