[CONSOLIDATED,PULL,103/113] rpm2cpio.sh: make compression tests case-insensitive

Submitted by Saul Wold on Jan. 3, 2012, 6:20 a.m. | Patch ID: 18149


Message ID d1569f2eb4c6c584784f11dbfb6d4b6e0a030a9f.1325571069.git.sgw@linux.intel.com
State New
Headers show

Commit Message

Saul Wold Jan. 3, 2012, 6:20 a.m.
From: Tom Zanussi <tom.zanussi@intel.com>

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.

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
 scripts/rpm2cpio.sh |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/rpm2cpio.sh b/scripts/rpm2cpio.sh
index 426fd77..5df8c0f 100755
--- a/scripts/rpm2cpio.sh
+++ b/scripts/rpm2cpio.sh
@@ -27,13 +27,13 @@  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
+if echo $COMPRESSION |grep -iq gzip; then
-elif echo $COMPRESSION |grep -q bzip2; then
+elif echo $COMPRESSION |grep -iq bzip2; then
-elif echo $COMPRESSION |grep -q xz; then
+elif echo $COMPRESSION |grep -iq xz; then
-elif echo $COMPRESSION |grep -q cpio; then
+elif echo $COMPRESSION |grep -iq cpio; then
 	# Most versions of file don't support LZMA, therefore we assume