add call to get headerUnload
authorcturner <devnull@localhost>
Mon, 13 Sep 2004 18:55:24 +0000 (18:55 +0000)
committercturner <devnull@localhost>
Mon, 13 Sep 2004 18:55:24 +0000 (18:55 +0000)
CVS patchset: 7418
CVS date: 2004/09/13 18:55:24

perl-RPM2/RPM2.pm
perl-RPM2/RPM2.xs
perl-RPM2/test.pl

index a4ec81d..419cea3 100644 (file)
@@ -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.
index 1daf492..3b90739 100644 (file)
@@ -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
 
index 4910476..b7620fe 100644 (file)
@@ -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);