summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaul Wold <sgw@linux.intel.com>2013-01-18 20:48:33 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-01-20 13:06:28 +0000
commit1377278187d20853304fe2689105f2848d796d86 (patch)
tree354dccfbc86f38cda65991069b25846ac53ba933
parent56a59ef12936dcc6464cf1d43dda6957a5aa8c65 (diff)
downloadopenembedded-core-1377278187d20853304fe2689105f2848d796d86.tar.gz
openembedded-core-1377278187d20853304fe2689105f2848d796d86.tar.bz2
openembedded-core-1377278187d20853304fe2689105f2848d796d86.zip
rpm2cpio: Update to match rpm4 specs for decompression
[YOCTO #3753] Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xmeta/recipes-devtools/rpm/rpm/rpm2cpio40
1 files changed, 14 insertions, 26 deletions
diff --git a/meta/recipes-devtools/rpm/rpm/rpm2cpio b/meta/recipes-devtools/rpm/rpm/rpm2cpio
index 00c4ec549e..6bcef6a4ce 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