RPM file format questions

Jordan Sissel jls at semicomplete.com
Sun Feb 19 20:18:53 UTC 2012


On Sun, Feb 19, 2012 at 3:08 AM, Panu Matilainen
<pmatilai at laiskiainen.org>wrote:

> On 02/19/2012 09:23 AM, Jordan Sissel wrote:
>
>> Howdy!
>>
>> I am implementing a library for reading and writing RPM files. I've used
>> the rpm source and from max-rpm[1] as documentation on the file format.
>>
>> [1] http://www.rpm.org/max-rpm/s1-**rpm-file-format-rpm-file-**
>> format.html<http://www.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html>
>>
>> I'm thus far able to happily read older RPMs from,CentOS5 and Fedora 10
>> (and earlier). I am not able to correctly read RPMs from CentOS 6 and
>> Fedora 11 (and beyond)
>>
>> The problem seems to be around the length of each header section
>> (signature and regular header). With older RPMs, my calculation
>> correctly computes the length, but for newer rpms (Fedora 11+ and
>> CentOS6+) I am usually short by 4 bytes.
>>
>> This causes me a problem because I'll read the Signature header and fail
>> when reading the next header because I'm 4 bytes behind the actual start
>> of the next header.
>>
>> I have wrangled it down to a small example script that can read older
>> rpms but fails on newer ones as described. I have also included some
>> data and output as well in a gist found here:
>>
>> https://gist.github.com/**1862256 <https://gist.github.com/1862256>
>>
>> If you have any pointers on how I'm reading these newer RPM files
>> incorrectly, I'd love to know :)
>>
>
> The fundamental package file format hasn't changed. There's a padding
> between signature and regular header which your script doesn't appear to
> take signature header padding into account, so you've basically just been
> lucky if you haven't been hit by that with older rpms.
>
> See eg http://rpm.org/gitweb?p=rpm.**git;a=blob;f=lib/signature.c;**h=**
> 63e59c00f255a538e48cbc8b0cf3b9**bd4a4dbd56;hb=HEAD#l203<http://rpm.org/gitweb?p=rpm.git;a=blob;f=lib/signature.c;h=63e59c00f255a538e48cbc8b0cf3b9bd4a4dbd56;hb=HEAD#l203>how to calculate the pad, or alternatively if you prefer reading obscure
> shell-script to C:
> http://rpm.org/gitweb?p=rpm.**git;a=blob;f=scripts/rpm2cpio.**sh;h=**
> b03ee361f7f6948c979195eefc5029**5aa8fa0cf7;hb=HEAD<http://rpm.org/gitweb?p=rpm.git;a=blob;f=scripts/rpm2cpio.sh;h=b03ee361f7f6948c979195eefc50295aa8fa0cf7;hb=HEAD>
>
>        - Panu -


Ahha, that's what I was missing. I have working sample code now with to
this information.

Thanks :)

-Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-list/attachments/20120219/e4bef804/attachment.html>


More information about the Rpm-list mailing list