From 884e1cda7cf999ef15dd78a54a9ce0bf99afd8de Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Tue, 16 Apr 2013 12:44:25 +0200
Subject: [PATCH] lsinitrd: drop use of "file"
---
dracut.spec | 4 +---
lsinitrd.sh | 38 ++++++++++++++++++++------------------
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/dracut.spec b/dracut.spec
index 197e9a0..3d42af2 100644
--- a/dracut.spec
+++ b/dracut.spec
@@ -84,11 +84,9 @@ Requires: findutils
Requires: grep
Requires: hardlink
Requires: gzip xz
-Requires: module-init-tools >= 3.7-9
+Requires: kmod
Requires: sed
-Requires: file
Requires: kpartx
-Requires: kbd kbd-misc
%if 0%{?fedora} || 0%{?rhel} > 6
Requires: util-linux >= 2.21
diff --git a/lsinitrd.sh b/lsinitrd.sh
index 42e30d9..0481975 100755
--- a/lsinitrd.sh
+++ b/lsinitrd.sh
@@ -103,37 +103,39 @@ if ! [[ -f "$image" ]]; then
exit 1
fi
-CAT=zcat
-FILE_T=$(file --dereference "$image")
-
-if echo "test"|xz|xz -dc --single-stream >/dev/null 2>&1; then
- XZ_SINGLE_STREAM="--single-stream"
-fi
-
-if [[ "$FILE_T" =~ :\ gzip\ compressed\ data ]]; then
- CAT=zcat
-elif [[ "$FILE_T" =~ :\ xz\ compressed\ data ]]; then
- CAT="xzcat $XZ_SINGLE_STREAM"
-elif [[ "$FILE_T" =~ :\ XZ\ compressed\ data ]]; then
- CAT="xzcat $XZ_SINGLE_STREAM"
-elif [[ "$FILE_T" =~ :\ LZMA ]]; then
- CAT="xzcat $XZ_SINGLE_STREAM"
-elif [[ "$FILE_T" =~ :\ data ]]; then
- CAT="xzcat $XZ_SINGLE_STREAM"
-fi
+read -N 6 bin < "$image"
+case $bin in
+ $'\x1f\x8b'*)
+ CAT="zcat";;
+ BZh*)
+ CAT="bzcat";;
+ 070701)
+ CAT="cat";;
+ *)
+ CAT="xzcat";
+ if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
+ CAT="xzcat --single-stream"
+ fi
+ ;;
+esac
if (( ${#filenames[@]} > 0 )); then
$CAT $image | cpio --extract --verbose --quiet --to-stdout ${!filenames[@]} 2>/dev/null
exit $?
fi
+ret=0
+
echo "$image: $(du -h $image | while read a b; do echo $a;done)"
echo "========================================================================"
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout '*lib/dracut/dracut-*' 2>/dev/null
+((ret+=$?))
echo "========================================================================"
if [ "$sorted" -eq 1 ]; then
$CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
else
$CAT "$image" | cpio --extract --verbose --quiet --list | sort -k9
fi
+((ret+=$?))
echo "========================================================================"
+exit $ret