Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 682798 - app-arch/rpm2targz-9.0.0.5g: rpm2tar fails thinking it is not a rpm file
Summary: app-arch/rpm2targz-9.0.0.5g: rpm2tar fails thinking it is not a rpm file
Status: RESOLVED DUPLICATE of bug 576842
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-07 08:05 UTC by Pacho Ramos
Modified: 2021-03-16 23:23 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Check for lzma before rest (rpm2targz-9.0.0.5g-check-for-lzma-early.patch,1.20 KB, patch)
2020-04-25 14:34 UTC, Thomas Deutschmann (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pacho Ramos gentoo-dev 2019-04-07 08:05:21 UTC
It fails with this file:
http://kdl.cc.ksosoft.com/wps-community/download/8372/wps-office-11.1.0.8372-1.x86_64.rpm

$ rpm2tar wps-office-11.1.0.8372-1.x86_64.rpm 
gzip: stdin is encrypted -- not supported
rpm2tar: wps-office-11.1.0.8372-1.x86_64.rpm: failed to extract cpio via gzip (not actually an RPM?)

On the other hand, the newer rpm2tgz-1.2.2 (https://packages.slackware.com/?r=slackware-current&p=rpm2tgz-1.2.2-i586-2.txz) works fine
Comment 1 Thomas Deutschmann (RETIRED) gentoo-dev 2020-04-24 12:01:52 UTC
I am unable to download the linked rpm file. I guess it's using zstd for which we were lacking support (fixed in bug 719208).

Please re-open if you still have a problem with >=rpm2targz-9.0.0.5g-r2.
Comment 2 Pacho Ramos gentoo-dev 2020-04-25 08:39:44 UTC
It still fails :(

Now it seems it tries to use bzip (not zstd) to open it
$ rpm2targz -v wps-office-11.1.0.9505.XA-1.x86_64.rpm 
Processing file: wps-office-11.1.0.9505.XA-1.x86_64.rpm ... bzip2: (stdin) is not a bzip2 file.
rpm2targz: wps-office-11.1.0.9505.XA-1.x86_64.rpm: failed to extract cpio via bzip2 (not actually an RPM?)
FAIL

I tried with this:
http://wdl1.pcfg.cache.wpscdn.com/wpsdl/wpsoffice/download/linux/9505/wps-office-11.1.0.9505.XA-1.x86_64.rpm
Comment 3 Thomas Deutschmann (RETIRED) gentoo-dev 2020-04-25 14:34:01 UTC
Created attachment 634550 [details, diff]
Check for lzma before rest

I can confirm the issue.

The shown rpm file uses LZMA compression.
The problem with LZMA compression is, that it doesn't really use real magic numbers like the other compression methods which makes it difficult to detect LZMA.

In the shown example file, LZMA starts at 411227 but there's also bzip2 header at offset 11054078 and even gzip header a little bit later.

The attached patch moves LZMA check, which is using fuzzing, to the beginning. However, the original patch which added LZMA support in rpm2targz from SuSE explicitly added comment that they picked LZMA as last option because of the fuzzing. So I am not sure at the moment if this will cause a new regression. We need to collect some test files...


PS: rpm2tgz you mentioned doesn't work for me. It's failing for the same file.
Comment 4 Pacho Ramos gentoo-dev 2020-04-25 18:09:02 UTC
rpm2tgz still works for me as downloaded from:
https://packages.slackware.com/?r=slackware-current&p=rpm2tgz-1.2.2-i586-2.txz
$ ./rpm2targz ~/Descargas/wps-office-11.1.0.9505.XA-1.x86_64.rpm
$ file wps-office-11.1.0.9505.XA-1.x86_64.tar.gz 
wps-office-11.1.0.9505.XA-1.x86_64.tar.gz: gzip compressed data, was "wps-office-11.1.0.9505.XA-1.x86_64.tar", last modified: Sat Apr 25 18:03:18 2020, max compression, from Unix, original size modulo 2^32 965355520

But it relies on rpmcpio, also alien does (and works too)

Why not keeping lzma check as last option but try it when the rest have failed? Maybe that would be the "safest", as would only be tried when everything else have failed.
Comment 5 Thomas Deutschmann (RETIRED) gentoo-dev 2020-04-25 19:06:43 UTC
That's the problem, lzma is not failing. Like said, you will find valid bzip2 and even gzip header in that file. However, *after* (=in) the LZMA part...

So in this case the problem is that rpmoffset will call magic_finish() function once gzip, bzip2, xz or zstd header was detected. I.e. it will never try for LZMA.


Regarding rpm2tgz:

$ wget  http://slackware.cs.utah.edu/pub/slackware/slackware64-14.2/slackware64/a/rpm2tgz-1.2.2-x86_64-1.txz
$ tar -xaf rpm2tgz-1.2.2-x86_64-1.txz
$ ./usr/bin/rpm2targz /tmp/wps-office-11.1.0.9505.XA-1.x86_64.rpm
$ file wps-office-11.1.0.9505.XA-1.x86_64.tar.gz
wps-office-11.1.0.9505.XA-1.x86_64.tar.gz: gzip compressed data, was "wps-office-11.1.0.9505.XA-1.x86_64.tar", last modified: Sat Apr 25 19:00:37 2020, max compression, from Unix, original size modulo 2^32 10240

...so it's just an empty tar.gz file in my case...

rpmoffset from that txz file will fail.

Wondering how this is working for you.

PS: I also tried i586 version -- same result.
Comment 6 Pacho Ramos gentoo-dev 2020-04-26 14:33:58 UTC
In my case rpm2tgz works and generates a proper tarball:
$ ls -lh wps-office-11.1.0.9505.XA-1.x86_64.tar.gz 
-rw-r--r-- 1 pacho pacho 312M abr 26 16:28 wps-office-11.1.0.9505.XA-1.x86_64.tar.gz

(I also uncompressed it)

But I think it work because, in my setup, I have rpm installed... then, as I have rpm2cpio it uses it and it works (as alien does). In your case maybe you don't have rpm2cpio, then, it will fallback to rpmoffset and it fails
Comment 7 SpanKY gentoo-dev 2021-03-16 23:23:30 UTC
rpm2targz used to use rpmcpio when available, but then it fails when the user has an installed rpmcpio that is old or buggy.  we can't win :/.

*** This bug has been marked as a duplicate of bug 576842 ***