summaryrefslogtreecommitdiff
path: root/lsinitramfs
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2014-09-27 19:22:11 +0100
committerBen Hutchings <ben@decadent.org.uk>2014-09-27 19:53:20 +0100
commitfdec1d37468d1b74b0ea4792599c5e7822d6c0e1 (patch)
tree9140228894ea9c41a7e51ff5cfcc4a613559b5c5 /lsinitramfs
parent2a75843aa046fac4793bdaa2c5cfbe2d21a97d42 (diff)
lsinitramfs: Move the decompress | cpio pipeline into a function
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'lsinitramfs')
-rwxr-xr-xlsinitramfs30
1 files changed, 18 insertions, 12 deletions
diff --git a/lsinitramfs b/lsinitramfs
index f66d970..db179ca 100755
--- a/lsinitramfs
+++ b/lsinitramfs
@@ -40,24 +40,30 @@ while true; do
esac
done
+listarchive()
+{
+ archive="$1"
+ if zcat -t "${archive}" >/dev/null 2>&1 ; then
+ zcat "${archive}" | cpio ${cpio_args}
+ elif xzcat -t "${archive}" >/dev/null 2>&1 ; then
+ xzcat "${archive}" | cpio ${cpio_args}
+ elif bzip2 -t "${archive}" >/dev/null 2>&1 ; then
+ bzip2 -c -d "${archive}" | cpio ${cpio_args}
+ elif lzop -t "${archive}" >/dev/null 2>&1 ; then
+ lzop -c -d "${archive}" | cpio ${cpio_args}
+ elif file "$initramfs" 2>/dev/null | grep -q "cpio archive" ; then
+ echo "lsinitramfs does not yet support cpio archive initramfs files." >&2
+ echo "See http://bugs.debian.org/717805 for more information." >&2
+ fi
+}
+
for initramfs in "$@" ; do
if ! [ -r "${initramfs}" ] ; then
echo "Specified file could not be read." >&2
exit 1
else
echo "${initramfs}"
- if zcat -t "${initramfs}" >/dev/null 2>&1 ; then
- zcat "${initramfs}" | cpio ${cpio_args}
- elif xzcat -t "$initramfs" >/dev/null 2>&1 ; then
- xzcat "$initramfs" | cpio ${cpio_args}
- elif bzip2 -t "$initramfs" >/dev/null 2>&1 ; then
- bzip2 -c -d "$initramfs" | cpio ${cpio_args}
- elif lzop -t "$initramfs" >/dev/null 2>&1 ; then
- lzop -c -d "$initramfs" | cpio ${cpio_args}
- elif file "$initramfs" 2>/dev/null | grep -q "cpio archive" ; then
- echo "lsinitramfs does not yet support cpio archive initramfs files." >&2
- echo "See http://bugs.debian.org/717805 for more information." >&2
- fi
+ listarchive "${initramfs}"
fi
done