From: Saul Wold <sgw@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH] rpm2cpio: Update to match rpm4 specs for decompression
Date: Fri, 18 Jan 2013 20:48:33 -0800 [thread overview]
Message-ID: <1358570913-10128-1-git-send-email-sgw@linux.intel.com> (raw)
[YOCTO #3753]
Signed-off-by: Saul Wold <sgw@linux.intel.com>
---
meta/recipes-devtools/rpm/rpm/rpm2cpio | 40 ++++++++++++----------------------
1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/meta/recipes-devtools/rpm/rpm/rpm2cpio b/meta/recipes-devtools/rpm/rpm/rpm2cpio
index 00c4ec5..6bcef6a 100755
--- a/meta/recipes-devtools/rpm/rpm/rpm2cpio
+++ b/meta/recipes-devtools/rpm/rpm/rpm2cpio
@@ -1,5 +1,8 @@
#!/bin/sh
+# Prevent gawk >= 4.0.x from getting funny ideas wrt UTF in printf()
+LANG=C
+
pkg=$1
if [ "$pkg" = "" -o ! -e "$pkg" ]; then
echo "no package supplied" 1>&2
@@ -22,30 +25,15 @@ dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
hdrsize=`expr 8 + 16 \* $il + $dl`
o=`expr $o + $hdrsize`
-EXTRACTOR="dd if=$pkg ibs=$o skip=1"
-
-COMPRESSION=`($EXTRACTOR |file -) 2>/dev/null`
-if echo $COMPRESSION |grep -q gzip; then
- DECOMPRESSOR=gunzip
-elif echo $COMPRESSION |grep -q bzip2; then
- DECOMPRESSOR=bunzip2
-elif echo $COMPRESSION |grep -q xz; then
- DECOMPRESSOR=unxz
-elif echo $COMPRESSION |grep -q cpio; then
- DECOMPRESSOR=cat
-else
- # Most versions of file don't support LZMA, therefore we assume
- # anything not detected is LZMA
- DECOMPRESSOR=`which unlzma 2>/dev/null`
- case "$DECOMPRESSOR" in
- /* ) ;;
- * ) DECOMPRESSOR=`which lzmash 2>/dev/null`
- case "$DECOMPRESSOR" in
- /* ) DECOMPRESSOR="lzmash -d -c" ;;
- * ) DECOMPRESSOR=cat ;;
- esac
- ;;
- esac
-fi
+comp=`dd if=$pkg ibs=$o skip=1 count=1 2>/dev/null | dd bs=3 count=1 2> /dev/null`
-$EXTRACTOR 2>/dev/null | $DECOMPRESSOR
+gz="`echo . | awk '{ printf("%c%c", 0x1f, 0x8b); }'`"
+lzma="`echo . | awk '{ printf("%cLZ", 0xff); }'`"
+xz="`echo . | awk '{ printf("%c7z", 0xfd); }'`"
+case "$comp" in
+ BZh) dd if="$pkg" ibs=$o skip=1 2>/dev/null | bunzip2 ;;
+ "$gz"*) dd if="$pkg" ibs=$o skip=1 2>/dev/null | gunzip ;;
+ "$xz"*) dd if="$pkg" ibs=$o skip=1 2>/dev/null | xzcat ;;
+ "$lzma"*) dd if="$pkg" ibs=$o skip=1 2>/dev/null | unlzma ;;
+ *) echo "Unrecognized rpm file: $pkg"; exit 1 ;;
+esac
--
1.8.0.2
reply other threads:[~2013-01-19 5:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358570913-10128-1-git-send-email-sgw@linux.intel.com \
--to=sgw@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.