Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 321439 - app-arch/rpm2targz: unable to unpack lzma compressed rpms
Summary: app-arch/rpm2targz: unable to unpack lzma compressed rpms
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
: 377173 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-25 11:54 UTC by Peter Volkov (RETIRED)
Modified: 2012-05-17 04:54 UTC (History)
3 users (show)

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


Attachments
rpmoffset.c.patch (rpmoffset.c.patch,1017 bytes, patch)
2010-05-25 11:55 UTC, Peter Volkov (RETIRED)
Details | Diff
lzma patch with xz fix (lzma.patch,1.41 KB, text/plain)
2010-08-05 20:25 UTC, Onur Küçük
Details
rpm2targz-lzma.patch (rpm2targz-lzma.patch,2.26 KB, patch)
2010-08-23 04:00 UTC, SpanKY
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Volkov (RETIRED) gentoo-dev 2010-05-25 11:54:11 UTC
Hi. Altlinux uses rpm files which are packed with lzma. For example download[1] src.rpm and try to rpm2targz it - that fail. I've found inside lzma-4.32.7.tar.bz2 code to check if that's lzma archive:

int find_lzma_header(unsigned char *buf) {
    return (buf[0] < 0xE1
        && buf[0] == 0x5d
        && buf[4] < 0x20
        && (memcmp (buf + 10 , "\x00\x00\x00", 3) == 0
            || (memcmp (buf + 5, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 8) == 0)));
}

and patched rpmoffset.c to check for lzma too (patch follows). Now it works, but it makes code not such nice as it was before... Patch follows.

[1] http://sisyphus.ru/ru/srpm/Sisyphus/man-pages-ru/get
[2] lzma-4.32.7/extra/scanlzma/scanlzma.c
Comment 1 Peter Volkov (RETIRED) gentoo-dev 2010-05-25 11:55:52 UTC
Created attachment 232875 [details, diff]
rpmoffset.c.patch

The question is should we go this way or what? In any case there is real need to support lzma packed rpms...
Comment 2 SpanKY gentoo-dev 2010-05-25 18:14:48 UTC
that wont work on all lzma archives either as some implementations fill out the filesize field (that 8 byte field).

simply extend the existing magic logic and look for the first few lzma bytes.  also post a link to an archive that isnt working for you.
Comment 3 Peter Volkov (RETIRED) gentoo-dev 2010-05-27 14:06:53 UTC
This is link on archive that does not work:

ftp://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/files/SRPMS/man-pages-ru-0.98-alt19.src.rpm

This link could became invalid also the one in comment #0 should work.

And I'm not sure how to extend magic logic... :( As I understand this code if people fill filesize field then they should have memcmp (buf + 10 , "\x00\x00\x00", 3) == 0 so afais this is handled with this check.
Comment 4 Onur Küçük 2010-08-05 20:24:58 UTC
With this patch applied, some (maybe all ?) rpm files created with xz fails to unpack. The problem is, they contain lzma signature and it is present towards the beginning of the file. I have made some modifications, so that rpmoffset continues to search when lzma is detected, in case there is xz data later in the file. See [1] for example. There are a few more rpms in that folder to test with too.

http://cekirdek.pardus.org.tr/~onur/rpm2targz/system-config-nfs-1.3.49-1.fc12.noarch.rpm
Comment 5 Onur Küçük 2010-08-05 20:25:47 UTC
Created attachment 241561 [details]
lzma patch with xz fix
Comment 6 SpanKY gentoo-dev 2010-08-23 04:00:06 UTC
Created attachment 244145 [details, diff]
rpm2targz-lzma.patch

it isnt that there is a lzma signature so much that the lzma check is way too permissive.  the current code:

+    buf[0] < 0xE1 && buf[0] == 0x5d
this is dumb because you cant have a value of 0x5d without being less than 0xe1

the gist of it is that if you have a bit stream that matches:
  0x5d 0x.. 0x.. 0x.. (0x.. < 0x20) 0x.. 0x.. 0x.. 0x.. 0x.. 0x00 0x00 0x00

that's a bit too fuzzy for my tastes.

at any rate, the current patches have style issues up the wazoo, so try this patch instead.
Comment 7 Onur Küçük 2010-08-25 17:40:08 UTC
(In reply to comment #6)
...
> that's a bit too fuzzy for my tastes.

 Agreed, but IIRC that is how it is with (old) lzma

> at any rate, the current patches have style issues up the wazoo, so try this
> patch instead.

 This patch looks fine to me, I have tested with some samples, no problem so far.


Comment 8 Jeff Johnson 2010-09-09 15:56:05 UTC
tracked at https://bugs.launchpad.net/gentoo/+bug/634154
Comment 9 SpanKY gentoo-dev 2010-09-09 17:39:39 UTC
why ?  i see no point in that.
Comment 10 Peter Volkov (RETIRED) gentoo-dev 2011-05-01 10:44:50 UTC
(In reply to comment #6)
> Created attachment 244145 [details, diff]
> rpm2targz-lzma.patch
> 
> at any rate, the current patches have style issues up the wazoo, so try this
> patch instead.

It works for me too. Can we have it in the tree?
Comment 11 Pacho Ramos gentoo-dev 2011-07-31 18:35:46 UTC
*** Bug 377173 has been marked as a duplicate of this bug. ***
Comment 12 Pacho Ramos gentoo-dev 2011-07-31 18:38:24 UTC
I also suffer from this problem as openSUSE is also providing this kind of rpm files :-S

Could that patch be applied if possible? Thanks a lot
Comment 13 chris stankevitz 2011-11-28 18:59:55 UTC
Hi,

Can someone tell me how to apply this patch to my system?  I need to unpack a lzma rpm.  I'm willing to make portage overlay, jump through hoops, stand on head, etc, I just need to know what to do.

Thank you
Comment 14 chris stankevitz 2011-11-28 19:09:44 UTC
This shows the basic idea to get a patch:

http://en.gentoo-wiki.com/wiki/Writing_Ebuilds#Adding_a_patch

1. Create a portage overlay for rpm2targz
2. Add the patch to the files directory
3. Modify the ebuild as per the above link
4. ebuild xxx digest
5. emerge -vat rpm2targz