From 57ba0c77a23c2f040d152ee5c0ff49262fbf8f26 Mon Sep 17 00:00:00 2001 From: cturner Date: Sun, 9 Mar 2003 18:34:27 +0000 Subject: [PATCH] beginnings of control over the verify flags for transactions CVS patchset: 6669 CVS date: 2003/03/09 18:34:27 --- perl-RPM2/Changes | 9 +++++++++ perl-RPM2/MANIFEST | 1 + perl-RPM2/RPM2.pm | 24 +++++++++++++++++++++++- perl-RPM2/RPM2.xs | 35 ++++++++++++++++++++++++++++++++--- perl-RPM2/test.pl | 3 +++ 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 perl-RPM2/Changes diff --git a/perl-RPM2/Changes b/perl-RPM2/Changes new file mode 100644 index 0000000..8afa93b --- /dev/null +++ b/perl-RPM2/Changes @@ -0,0 +1,9 @@ +0.60 2003-03-08 cturner + * Add tagformat method on header objects from James Olin Oden + + * Redo a lot of the XS bindings to properly perform + refcounting on underlying C objects + + * Add expand_macro call to... expand a macro! + + * Add ability to change VS flags on open_package.. more coming diff --git a/perl-RPM2/MANIFEST b/perl-RPM2/MANIFEST index 757169a..aa3fe39 100644 --- a/perl-RPM2/MANIFEST +++ b/perl-RPM2/MANIFEST @@ -1,3 +1,4 @@ +Changes Makefile.PL MANIFEST README diff --git a/perl-RPM2/RPM2.pm b/perl-RPM2/RPM2.pm index 870c9df..f891c1e 100644 --- a/perl-RPM2/RPM2.pm +++ b/perl-RPM2/RPM2.pm @@ -13,6 +13,25 @@ use vars qw/@ISA/; bootstrap RPM2 $VERSION; +foreach my $tag (keys %RPM2::constants) { + my $sub = q { + sub [[method]] { + my $self = shift; + return $RPM2::constants{[[tag]]}; + } + }; + + my $method = lc $tag; + $method =~ s/^rpm//; + $sub =~ s/\[\[method\]\]/$method/g; + $sub =~ s/\[\[tag\]\]/$tag/g; + eval $sub; + + if ($@) { + die $@; + } +} + sub open_rpm_db { my $class = shift; my %params = @_; @@ -33,11 +52,14 @@ sub open_rpm_db { sub open_package { my $class = shift; my $file = shift; + my $flags = shift; + + $flags = RPM2->vsf_default unless defined $flags; open FH, "<$file" or die "Can't open $file: $!"; - my $hdr = RPM2::_read_package_info(*FH); + my $hdr = RPM2::_read_package_info(*FH, $flags); close FH; $hdr = RPM2::Header->_new_raw($hdr, realpath($file)); diff --git a/perl-RPM2/RPM2.xs b/perl-RPM2/RPM2.xs index 83ca883..ebd2930 100644 --- a/perl-RPM2/RPM2.xs +++ b/perl-RPM2/RPM2.xs @@ -23,15 +23,43 @@ _populate_header_tags(HV *href) } } +void +_populate_constant(HV *href, char *name, int val) +{ + hv_store(href, name, strlen(name), newSViv(val), 0); +} + +#define REGISTER_CONSTANT(name) _populate_constant(constants, #name, name) + MODULE = RPM2 PACKAGE = RPM2 PROTOTYPES: ENABLE BOOT: { - HV *header_tags; + HV *header_tags, *constants; rpmReadConfigFiles(NULL, NULL); + header_tags = perl_get_hv("RPM2::header_tag_map", TRUE); _populate_header_tags(header_tags); + + constants = perl_get_hv("RPM2::constants", TRUE); + + /* not the 'standard' way of doing perl constants, but a lot easier to maintain */ + REGISTER_CONSTANT(RPMVSF_DEFAULT); + REGISTER_CONSTANT(RPMVSF_NOHDRCHK); + REGISTER_CONSTANT(RPMVSF_NEEDPAYLOAD); + REGISTER_CONSTANT(RPMVSF_NOSHA1HEADER); + REGISTER_CONSTANT(RPMVSF_NOMD5HEADER); + REGISTER_CONSTANT(RPMVSF_NODSAHEADER); + REGISTER_CONSTANT(RPMVSF_NORSAHEADER); + REGISTER_CONSTANT(RPMVSF_NOSHA1); + REGISTER_CONSTANT(RPMVSF_NOMD5); + REGISTER_CONSTANT(RPMVSF_NODSA); + REGISTER_CONSTANT(RPMVSF_NORSA); + REGISTER_CONSTANT(_RPMVSF_NODIGESTS); + REGISTER_CONSTANT(_RPMVSF_NOSIGNATURES); + REGISTER_CONSTANT(_RPMVSF_NOHEADER); + REGISTER_CONSTANT(_RPMVSF_NOPAYLOAD); } void @@ -66,8 +94,9 @@ rpmvercmp(one, two) char* two void -_read_package_info(fp) +_read_package_info(fp, vsflags) FILE *fp + int vsflags PREINIT: #ifdef RPM2_RPM41 rpmts ts; @@ -90,7 +119,7 @@ _read_package_info(fp) fd = fdDup(fileno(fp)); #ifdef RPM2_RPM41 - rpmtsSetVSFlags(ts, _RPMVSF_NOSIGNATURES); + rpmtsSetVSFlags(ts, vsflags); rc = rpmReadPackageFile(ts, fd, "filename or other identifier", &ret); #else rc = rpmReadPackageInfo(fd, NULL, &ret); diff --git a/perl-RPM2/test.pl b/perl-RPM2/test.pl index c3c7b4b..3a286fb 100644 --- a/perl-RPM2/test.pl +++ b/perl-RPM2/test.pl @@ -116,3 +116,6 @@ RPM2->add_macro("rpm2_test_macro", "testval $$"); ok(RPM2->expand_macro("%rpm2_test_macro") eq "testval $$"); RPM2->delete_macro("rpm2_test_macro"); ok(RPM2->expand_macro("%rpm2_test_macro") eq "%rpm2_test_macro"); + +ok(RPM2->vsf_nosha1 == 65536); + -- 2.7.4