diff options
author | cturner <devnull@localhost> | 2002-08-07 16:08:45 +0000 |
---|---|---|
committer | cturner <devnull@localhost> | 2002-08-07 16:08:45 +0000 |
commit | ddec1f33d559bad09493dfd24175e0f10ebd1a96 (patch) | |
tree | 494a8d1a7db44b4c68c307ba9d1003884416c6eb /perl-RPM2 | |
parent | d0f22dcaa2bf996bfb7c1ca06a7126fce2d43c36 (diff) | |
download | librpm-tizen-ddec1f33d559bad09493dfd24175e0f10ebd1a96.tar.gz librpm-tizen-ddec1f33d559bad09493dfd24175e0f10ebd1a96.tar.bz2 librpm-tizen-ddec1f33d559bad09493dfd24175e0f10ebd1a96.zip |
port 4.1 branch to this branch
CVS patchset: 5610
CVS date: 2002/08/07 16:08:45
Diffstat (limited to 'perl-RPM2')
-rw-r--r-- | perl-RPM2/Makefile.PL | 6 | ||||
-rw-r--r-- | perl-RPM2/RPM2.pm | 40 | ||||
-rw-r--r-- | perl-RPM2/RPM2.xs | 34 | ||||
-rw-r--r-- | perl-RPM2/test.pl | 8 |
4 files changed, 68 insertions, 20 deletions
diff --git a/perl-RPM2/Makefile.PL b/perl-RPM2/Makefile.PL index 03d333e3f..83f50c13b 100644 --- a/perl-RPM2/Makefile.PL +++ b/perl-RPM2/Makefile.PL @@ -2,16 +2,16 @@ use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. -my $libs = "-lrpm -lrpmdb -lrpmio -lpopt"; +my $libs = "-lrpm-4.1 -lrpmdb-4.1 -lrpmio-4.1 -lpopt"; # try to be smart about which shared libs we should load. # use the .la file. probably linux only. -if (open FH, "</usr/lib/librpm.la") { +if (0 and open FH, "</usr/lib/librpm.la") { my ($line, @rest) = grep { /^dependency_libs=/ } <FH>; if ($line and not @rest) { if ($line =~ /^dependency_libs='(.*)'$/) { - $libs = "-lrpm $1"; + $libs = "-lrpm-4.1 $1"; } } } diff --git a/perl-RPM2/RPM2.pm b/perl-RPM2/RPM2.pm index 823ab8629..711ef0246 100644 --- a/perl-RPM2/RPM2.pm +++ b/perl-RPM2/RPM2.pm @@ -6,7 +6,7 @@ use DynaLoader; use Data::Dumper; use vars qw/$VERSION/; -$VERSION = '0.10'; +$VERSION = '0.43'; use vars qw/@ISA/; @ISA = qw/DynaLoader/; @@ -56,18 +56,12 @@ sub open_package { open FH, "<$file" or die "Can't open $file: $!"; - my ($hdr, $sigs) = RPM2::_read_package_info(*FH); + my $hdr = RPM2::_read_package_info(*FH); close FH; $hdr = RPM2::Header->_new_raw($hdr, 1); - $sigs = RPM2::Header->_new_raw($sigs, 1); - if (wantarray) { - return ($hdr, $sigs); - } - else { - return $hdr; - } + return $hdr; } sub close_rpm_db { @@ -164,6 +158,9 @@ sub DESTROY { package RPM2::Header; +use overload '<=>' => \&op_spaceship, + 'bool' => \&op_bool; + sub _new_raw { my $class = shift; my $c_header = shift; @@ -188,6 +185,31 @@ sub tag { return RPM2::_header_tag($self->{header}, $tagmap{$tag}); } +sub compare { + my $h1 = shift; + my $h2 = shift; + + return RPM2::_header_compare($h1->{header}, $h2->{header}); +} + +sub op_bool { + my $self = shift; + + return defined($self) && defined($self->{header}); +} + +sub op_spaceship { + my $h1 = shift; + my $h2 = shift; + + my $ret = $h1->compare($h2); + + # rpmvercmp can return any neg/pos number; normalize here to -1, 0, 1 + return 1 if $ret > 0; + return -1 if $ret < 0; + return 0; +} + sub is_source_package { my $self = shift; diff --git a/perl-RPM2/RPM2.xs b/perl-RPM2/RPM2.xs index 4a7ef6b6a..20330d25e 100644 --- a/perl-RPM2/RPM2.xs +++ b/perl-RPM2/RPM2.xs @@ -1,5 +1,7 @@ #include "rpmcli.h" -#include "rpmlib.h" +#include "rpmts.h" +#include "header.h" +#include "rpmdb.h" #include "misc.h" #include "EXTERN.h" @@ -87,31 +89,40 @@ void _read_package_info(fp) FILE *fp PREINIT: + rpmts ts; Header ret; Header sigs; rpmRC rc; FD_t fd; PPCODE: + ts = rpmtsCreate(); + + /* XXX Determine type of signature verification when reading + vsflags |= _RPMTS_VSF_NOLEGACY; + vsflags |= _RPMTS_VSF_NODIGESTS; + vsflags |= _RPMTS_VSF_NOSIGNATURES; + xx = rpmtsSetVerifySigFlags(ts, vsflags); + */ + fd = fdDup(fileno(fp)); - rc = rpmReadPackageInfo(fd, &sigs, &ret); + rc = rpmReadPackageFile(ts, fd, "filename or other identifier", &ret); + Fclose(fd); if (rc == RPMRC_OK) { - SV *h_sv, *s_sv; + SV *h_sv; - EXTEND(SP, 2); + EXTEND(SP, 1); h_sv = sv_newmortal(); - s_sv = sv_newmortal(); sv_setref_pv(h_sv, "Header", (void *)ret); - sv_setref_pv(s_sv, "Header", (void *)sigs); PUSHs(h_sv); - PUSHs(s_sv); } else { croak("error reading package"); } + ts = rpmtsFree(ts); void _free_header(h) @@ -176,6 +187,15 @@ _header_tag(h, tag) headerFreeData(ret, type); int +_header_compare(h1, h2) + Header h1 + Header h2 + CODE: + RETVAL = rpmVersionCompare(h1, h2); + OUTPUT: + RETVAL + +int _header_is_source(h) Header h CODE: diff --git a/perl-RPM2/test.pl b/perl-RPM2/test.pl index a6d8f699a..4ea798782 100644 --- a/perl-RPM2/test.pl +++ b/perl-RPM2/test.pl @@ -8,7 +8,7 @@ use Test; use strict; -BEGIN { plan tests => 22 }; +BEGIN { plan tests => 26 }; use RPM2; ok(1); # If we made it this far, we're ok. @@ -85,6 +85,12 @@ ok($pkg); ok($pkg->name eq 'test-rpm'); ok($pkg->is_source_package); +my $pkg2 = RPM2->open_package("test-rpm-1.0-1.noarch.rpm"); +ok($pkg->compare($pkg2) == 0); +ok(($pkg <=> $pkg2) == 0); +ok(!($pkg < $pkg2)); +ok(!($pkg > $pkg2)); + # another rpm, handily provided by the rpmdb-redhat package my $other_rpm_dir = "/usr/lib/rpmdb/i386-redhat-linux/redhat"; if (-d $other_rpm_dir) { |