Skip Menu |

This queue is for tickets about the Perl-RPM CPAN distribution.

Report information
The Basics
Id: 32600
Status: open
Priority: 0/
Queue: Perl-RPM

People
Owner: Nobody in particular
Requestors: strobert-cpan [...] strobe.net
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.51
Fixed in: (no value)



Subject: does not load headers from files on rpm >= 4.01
I am hoping this module is still alive. I am trying to use version 1.51 on a rpm ver 4.2 machine (happens to be fc1, but the error should be on anything 4.1 or newer). tieing RPM::Header to a file to read a non installed package's header from a file fails. I did some debugging over the past couple of days (combo of the perl debugger and cgdb to trap the C code) and after adding in the error messages from rpmReadHeader, I have found the issue. in rpm 4.01 and newer, rpmReadHeader is being called. however that function expects the seek position to be at the start of the header which is at least 96 bytes into the file. from reeading the RPM format docs it looks like there can be an optional digest/sig block bewteen the lead and the rpm header, but so far I haven't found a package that has one. and hardwired to 96 is what the RPM::Header::Pureperl package does. There is also a rpmReadPAckageFile API that looks to be the one to use. I have attached a patch that used that function and it seems like things are working now. It probably would not be hard to whip up a test case and add it to the package (thining maybe include a REALLY basic rpm to load). if there is interest, please let me know and I will see about writing one to add. It looks like the current cases just attach to a RPM database as opposed to individual rpm files.
Subject: perlrpm.patch
--- Perl-RPM-1.51/RPM/Header.xs.orig 2008-01-23 19:44:48.000000000 -0800 +++ Perl-RPM-1.51/RPM/Header.xs 2008-01-23 19:40:31.000000000 -0800 @@ -136,10 +136,14 @@ { Header h; int isSource = 0; +#if RPM_VERSION >= 0x040100 + rpmts ts; +#endif RPM_Header *hdr = Null(RPM_Header *); sv_setiv(rpm_errSV, 0); #if RPM_VERSION >= 0x040100 - if (rpmReadHeader(NULL, Fd, &h, NULL)) + ts = rpmtsCreate(); + if (rpmReadPackageFile(ts, Fd, "filename", &h)) #else if (rpmReadPackageHeader(Fd, &h, &isSource, Null(int *), Null(int *))) #endif @@ -150,6 +154,9 @@ rpmError(RPMERR_READ, "Error reading package header"); return hdr; } +#if RPM_VERSION >= 0x040100 + ts = rpmtsFree(ts); +#endif hdr = rpmhdr_TIEHASH_header(aTHX_ h); if (hdr) hdr->isSource = isSource; --- Perl-RPM-1.51/RPM.h.orig 2008-01-23 19:44:28.000000000 -0800 +++ Perl-RPM-1.51/RPM.h 2008-01-23 19:43:11.000000000 -0800 @@ -48,6 +48,10 @@ #include <rpmlib.h> #include <rpmdb.h> +#if RPM_VERSION >= 0x040100 +#include <rpmts.h> +#endif + /* Various flags. For now, one nybble for header and one for package. */ #define RPM_HEADER_MASK 0x0f #define RPM_HEADER_READONLY 0x01
From: strobert-bitcard [...] strobe.net
On Wed Jan 23 22:50:10 2008, strobert wrote: Show quoted text
> in rpm 4.01 and newer, rpmReadHeader is being called. however that > function expects the seek position to be at the start of the header > which is at least 96 bytes into the file. from reeading the RPM > format docs it looks like there can be an optional digest/sig block > bewteen the lead and the rpm header, but so far I haven't found a > package that has one. and hardwired to 96 is what the > RPM::Header::Pureperl package does. > > There is also a rpmReadPAckageFile API that looks to be the one to > use. > > I have attached a patch that used that function and it seems like > things are working now.
Any idea if/when this will get put into the upstream release? I have a local patch applied tot he RPM we built/use around here, but it would be nice to have it in the upstream code.