fa03a6d17d
In the rpm2cpio.sh script, the output of $COMPRESSION is tested for certain lowercase strings such as 'xz' in order to determine the decompression to use. The problem is that the output strings tested are from the output of 'file', which uses different cases in different versions e.g. file-5.09 prints: tmp/sysroots/x86_64-linux/usr/bin$ ./file xxx.tar.xz: XZ compressed data while file-5.03 prints: tmp/sysroots/x86_64-linux/usr/bin$ ./file xxx.tar.xz: xz compressed data In the former, the XZ string causes xz compressed payloads to incorrectly fall through to the catch-all lzma case. (From OE-Core rev: fe48e55988a2208bb7a3a2cc2bc641c41dbd1cb0) Signed-off-by: Tom Zanussi <tom.zanussi@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
54 lines
1.4 KiB
Bash
Executable file
54 lines
1.4 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# This comes from the RPM5 5.4.0 distribution.
|
|
|
|
pkg=$1
|
|
if [ "$pkg" = "" -o ! -e "$pkg" ]; then
|
|
echo "no package supplied" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
leadsize=96
|
|
o=`expr $leadsize + 8`
|
|
set `od -j $o -N 8 -t u1 $pkg`
|
|
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
|
|
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
|
|
# echo "sig il: $il dl: $dl"
|
|
|
|
sigsize=`expr 8 + 16 \* $il + $dl`
|
|
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`
|
|
set `od -j $o -N 8 -t u1 $pkg`
|
|
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
|
|
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
|
|
# echo "hdr il: $il dl: $dl"
|
|
|
|
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 -iq gzip; then
|
|
DECOMPRESSOR=gunzip
|
|
elif echo $COMPRESSION |grep -iq bzip2; then
|
|
DECOMPRESSOR=bunzip2
|
|
elif echo $COMPRESSION |grep -iq xz; then
|
|
DECOMPRESSOR=unxz
|
|
elif echo $COMPRESSION |grep -iq 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
|
|
|
|
$EXTRACTOR 2>/dev/null | $DECOMPRESSOR
|