From 59293dd8928d6f0033a45fdef9e9f50a296a3a0b Mon Sep 17 00:00:00 2001 From: cturner Date: Mon, 13 Sep 2004 18:55:24 +0000 Subject: [PATCH] add call to get headerUnload CVS patchset: 7418 CVS date: 2004/09/13 18:55:24 --- perl-RPM2/RPM2.pm | 13 ++++++++++++- perl-RPM2/RPM2.xs | 12 +++++++++++- perl-RPM2/test.pl | 6 +++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/perl-RPM2/RPM2.pm b/perl-RPM2/RPM2.pm index a4ec81d..419cea3 100644 --- a/perl-RPM2/RPM2.pm +++ b/perl-RPM2/RPM2.pm @@ -8,7 +8,7 @@ use File::Basename qw/basename dirname/; use File::Spec (); use vars qw/$VERSION/; -$VERSION = '0.66'; +$VERSION = '0.67'; use vars qw/@ISA/; @ISA = qw/DynaLoader/; @@ -335,6 +335,12 @@ sub changelog { return @{$self->{changelog}}; } +sub raw_header { + my $self = shift; + + return RPM2::C::Header::_unload($self->{c_header}); +} + package RPM2::PackageIterator; sub new_iterator { @@ -711,6 +717,11 @@ If epoch is undefined for this package, it and the leading colon are omitted. TODO. +=item $hdr->raw_header() + +Return the binary representation of the header (ie, the rpm file +itself without the actual content of the files in the cpio archive). + =item $hdr->changelog() Returns a list of hash refs containing the change log data of the package. diff --git a/perl-RPM2/RPM2.xs b/perl-RPM2/RPM2.xs index 1daf492..3b90739 100644 --- a/perl-RPM2/RPM2.xs +++ b/perl-RPM2/RPM2.xs @@ -300,7 +300,7 @@ _read_package_info(fp, vsflags) PUSHs(h_sv); } else { - croak("error reading package"); + croak("error reading package (%d)", rc); } #ifdef RPM2_RPM41 ts = rpmtsFree(ts); @@ -512,6 +512,16 @@ _header_sprintf(h, format) PUSHs(sv_2mortal(newSVpv((char *)s, 0))); s = _free(s); +void +_unload(h) + Header h + PREINIT: + char *buf; + unsigned int size; + PPCODE: + size = headerSizeof(h, 0); + buf = headerUnload(h); + PUSHs(sv_2mortal(newSVpv(buf, size))); MODULE = RPM2 PACKAGE = RPM2::C::Transaction diff --git a/perl-RPM2/test.pl b/perl-RPM2/test.pl index 4910476..b7620fe 100644 --- a/perl-RPM2/test.pl +++ b/perl-RPM2/test.pl @@ -11,7 +11,7 @@ use strict; use Test; use strict; -BEGIN { plan tests => 63 }; +BEGIN { plan tests => 64 }; use RPM2; ok(1); # If we made it this far, we're ok. @@ -193,3 +193,7 @@ ok($t->close_db()); my @headers = RPM2->open_hdlist("hdlist-test.hdr"); ok(scalar @headers, 3, 'found three headers in hdlist-test.hdr'); ok(grep { $_->tag('name') eq 'mod_perl' } @headers); + +# ensure the raw header from hdlist-test.hdr's first entry is correct +my $binary_header = $headers[0]->raw_header; +ok(length($binary_header) == 6560); -- 2.7.4