Bug 602423

Summary: rpm2cpio fails on rhel-6 rpms
Product: Red Hat Enterprise Linux 5 Reporter: Jay Fenlason <fenlason>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED NEXTRELEASE QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: medium Docs Contact:
Priority: low    
Version: 5.5CC: b24warbaby, ffesti, herrold, iav, jcpunk, jfeeney, kolyshkin, pasteur, phr, slukasik
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-11 14:14:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Parmesan for the fettucini
none
patched parmezan, works for me on rhel5 none

Description Jay Fenlason 2010-06-09 20:09:02 UTC
Description of problem:
rpm2cpio produces garbage when asked to extract a rhel-6 rpm

Version-Release number of selected component (if applicable):
rpm-4.4.2.3-18.el5

How reproducible:
always

Steps to Reproduce:
1.rpm2cpio - < {rhel-6 package}.rpm | cpio -id
2.Note that your console output is now full of garbage.
3.
  
Actual results:
Blood and fettuccini everywhere

Expected results:
rpm extracts, or error is reported.

Additional info:

Comment 1 Jeff Johnson 2010-06-09 21:08:03 UTC
Created attachment 422705 [details]
Parmesan for the fettucini

Surely you know what to do with a shell script:

    $ wc -l rpm2cpio.sh
    51 rpm2cpio.sh

Comment 2 Kirill Kolyshkin 2010-10-13 10:28:51 UTC
shell script doesn't work for me on a centos 5 system:

# Getting RPM
$ wget http://ftp.redhat.com/redhat/rhel/beta/6/i386/os/Packages/kernel-devel-2.6.32-19.el6.i686.rpm

# Checking if it's OK
$ rpm -K kernel-devel-2.6.32-19.el6.i686.rpmkernel-devel-2.6.32-19.el6.i686.rpm: RSA sha1 (MD5) (PGP) md5 NOT OK (MISSING KEYS: PGP#f21541eb)

# Trying to unpack
$ rpm2cpio.sh kernel-devel-2.6.32-19.el6.i686.rpm  | cpio -id
/usr/bin/unlzma: (stdin): File format not recognized
cpio: premature end of archive

# Shell trace follows
$ bash -x rpm2cpio.sh kernel-devel-2.6.32-19.el6.i686.rpm  | cpio 
cpio: You must specify one of -oipt options.
Try `cpio --help' or `cpio --usage' for more information.

+ pkg=kernel-devel-2.6.32-19.el6.i686.rpm
+ '[' kernel-devel-2.6.32-19.el6.i686.rpm = '' -o '!' -e kernel-devel-2.6.32-19.el6.i686.rpm ']'
+ leadsize=96
++ expr 96 + 8
+ o=104
++ od -j 104 -N 8 -t u1 kernel-devel-2.6.32-19.el6.i686.rpm
+ set 0000150 0 0 0 7 0 0 4 132 0000160
++ expr 256 '*' '(' 256 '*' '(' 256 '*' 0 + 0 ')' + 0 ')' + 7
+ il=7
++ expr 256 '*' '(' 256 '*' '(' 256 '*' 0 + 0 ')' + 4 ')' + 132
+ dl=1156
++ expr 8 + 16 '*' 7 + 1156
+ sigsize=1276
++ expr 104 + 1276 + '(' 8 - '(' 1276 % 8 ')' ')' % 8 + 8
+ o=1392
++ od -j 1392 -N 8 -t u1 kernel-devel-2.6.32-19.el6.i686.rpm
+ set 0002560 0 0 0 53 0 19 195 180 0002570
++ expr 256 '*' '(' 256 '*' '(' 256 '*' 0 + 0 ')' + 0 ')' + 53
+ il=53
++ expr 256 '*' '(' 256 '*' '(' 256 '*' 0 + 19 ')' + 195 ')' + 180
+ dl=1295284
++ expr 8 + 16 '*' 53 + 1295284
+ hdrsize=1296140
++ expr 1392 + 1296140
+ o=1297532
+ EXTRACTOR='dd if=kernel-devel-2.6.32-19.el6.i686.rpm ibs=1297532 skip=1'
+ COMPRESSION='/dev/stdin: data'
+ echo /dev/stdin: data
+ grep -q gzip
+ echo /dev/stdin: data
+ grep -q bzip2
+ echo /dev/stdin: data
+ grep -q xz
+ echo /dev/stdin: data
+ grep -q cpio
++ which unlzma
+ DECOMPRESSOR=/usr/bin/unlzma
+ case "$DECOMPRESSOR" in
+ dd if=kernel-devel-2.6.32-19.el6.i686.rpm ibs=1297532 skip=1
+ /usr/bin/unlzma
/usr/bin/unlzma: (stdin): File format not recognized
[kir@ovzdl tmp]$ bash -x rpm2cpio.sh kernel-devel-2.6.32-19.el6.i686.rpm
+ pkg=kernel-devel-2.6.32-19.el6.i686.rpm
+ '[' kernel-devel-2.6.32-19.el6.i686.rpm = '' -o '!' -e kernel-devel-2.6.32-19.el6.i686.rpm ']'
+ leadsize=96
++ expr 96 + 8
+ o=104
++ od -j 104 -N 8 -t u1 kernel-devel-2.6.32-19.el6.i686.rpm
+ set 0000150 0 0 0 7 0 0 4 132 0000160
++ expr 256 '*' '(' 256 '*' '(' 256 '*' 0 + 0 ')' + 0 ')' + 7
+ il=7
++ expr 256 '*' '(' 256 '*' '(' 256 '*' 0 + 0 ')' + 4 ')' + 132
+ dl=1156
++ expr 8 + 16 '*' 7 + 1156
+ sigsize=1276
++ expr 104 + 1276 + '(' 8 - '(' 1276 % 8 ')' ')' % 8 + 8
+ o=1392
++ od -j 1392 -N 8 -t u1 kernel-devel-2.6.32-19.el6.i686.rpm
+ set 0002560 0 0 0 53 0 19 195 180 0002570
++ expr 256 '*' '(' 256 '*' '(' 256 '*' 0 + 0 ')' + 0 ')' + 53
+ il=53
++ expr 256 '*' '(' 256 '*' '(' 256 '*' 0 + 19 ')' + 195 ')' + 180
+ dl=1295284
++ expr 8 + 16 '*' 53 + 1295284
+ hdrsize=1296140
++ expr 1392 + 1296140
+ o=1297532
+ EXTRACTOR='dd if=kernel-devel-2.6.32-19.el6.i686.rpm ibs=1297532 skip=1'
+ COMPRESSION='/dev/stdin: data'
+ echo /dev/stdin: data
+ grep -q gzip
+ echo /dev/stdin: data
+ grep -q bzip2
+ echo /dev/stdin: data
+ grep -q xz
+ echo /dev/stdin: data
+ grep -q cpio
++ which unlzma
+ DECOMPRESSOR=/usr/bin/unlzma
+ case "$DECOMPRESSOR" in
+ dd if=kernel-devel-2.6.32-19.el6.i686.rpm ibs=1297532 skip=1
+ /usr/bin/unlzma
/usr/bin/unlzma: (stdin): File format not recognized

Comment 3 Kirill Kolyshkin 2010-10-13 10:52:51 UTC
Bug #528693 is related, dealing with the same problem, only from mc perspective.

Some more diags:
$ dd if=kernel-devel-2.6.32-19.el6.i686.rpm ibs=1297532 skip=1 | hexdump -C | head -1
00000000  fd 37 7a 58 5a 00 00 0a  e1 fb 0c a1 02 00 21 01  |.7zXZ.........!.|

Now it looks like the signature is from xz, the problem with rpm2cpio.sh is it uses file utility which does not recognize xz.

$ rpm -q file xz
file-4.17-15.el5_3.1
xz-4.999.9-0.3.beta.20091007git.el5

Here's my dirty workaround to the above rpm2cpio.sh script that does not work with RHEL5.5's file utility:

--- /usr/local/bin/rpm2cpio.sh.oldfile	2010-10-13 13:58:33.000000000 +0400
+++ /usr/local/bin/rpm2cpio.sh	2010-10-13 14:51:37.000000000 +0400
@@ -33,6 +33,8 @@
 	DECOMPRESSOR=unxz
 elif echo $COMPRESSION |grep -q cpio; then
 	DECOMPRESSOR=cat
+elif $EXTRACTOR | od -x | head -1 | grep -q '37fd 587a '; then
+	DECOMPRESSOR=unxz
 else
 	# Most versions of file don't support LZMA, therefore we assume
 	# anything not detected is LZMA

Comment 4 Kirill Kolyshkin 2010-10-13 10:55:34 UTC
Created attachment 453182 [details]
patched parmezan, works for me on rhel5

Comment 5 Panu Matilainen 2013-03-07 10:49:33 UTC
*** Bug 837945 has been marked as a duplicate of this bug. ***

Comment 6 Florian Festi 2013-03-11 14:14:04 UTC
RHEL5 is now in the development phase 2. This limits updates to critical issues only. While this issue might be annoying it is now too late to get it fixed. Sorry.

Comment 7 Philip Rowlands 2014-10-31 12:58:40 UTC
In case anyone stumbles on this bug wanting a quick fix on RHEL5:
$ yum install xz file rpm
$ rpm -qpR foo.rpm | grep -i xz
rpmlib(PayloadIsXz) <= 5.2-1

# foo.rpm has a payload with XZ compression. Although rpm2cpio doesn't understand the xz format, it still emits the compressed file intact.

$ rpm2cpio foo.rpm | xzcat > foo.cpio
$ cpio -idmv < foo.cpio

$ cpio -idm < foo.cpio
278 blocks
$ ls -l
total 156
-rw-r--r-- 1 phil   staff 141864 Oct 31 12:33 foo.cpio
drwxr-xr-x 3 phil   staff   4096 Oct 31 12:34 usr

Comment 8 b24warbaby 2015-08-17 23:39:49 UTC
This problems exists on PPC / Fedora releases too