ugh, rpm 4.1isms snuck in
authorcturner <devnull@localhost>
Mon, 10 Mar 2003 17:08:00 +0000 (17:08 +0000)
committercturner <devnull@localhost>
Mon, 10 Mar 2003 17:08:00 +0000 (17:08 +0000)
CVS patchset: 6674
CVS date: 2003/03/10 17:08:00

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

index a2a4a58..45c30e8 100644 (file)
@@ -54,7 +54,10 @@ sub open_package {
   my $file = shift;
   my $flags = shift;
 
-  $flags = RPM2->vsf_default unless defined $flags;
+  if (RPM2->rpm_api_version > 4.0 and not defined $flags) {
+    $flags = RPM2->vsf_default;
+  }
+  $flags ||= 0;
 
   open FH, "<$file"
     or die "Can't open $file: $!";
@@ -198,7 +201,7 @@ sub op_spaceship {
 sub is_source_package {
   my $self = shift;
 
-  return $self->tag("sourcepackage");
+  return RPM2::C::Header::_header_is_source($self->{c_header});
 }
 
 sub filename {
index ebd2930..4cb7f33 100644 (file)
 #include "perl.h"
 #include "XSUB.h"
 
+#if !defined(RPM2_RPM41) && !defined(RPM2_RPM40)
+#error Must define one of RPM2_RPM41 or RPM2_RPM40; perhaps Makefile.PL could not guess your RPM API version?
+#endif
+
 void
 _populate_header_tags(HV *href)
 {
@@ -45,6 +49,7 @@ BOOT:
        constants = perl_get_hv("RPM2::constants", TRUE);
 
        /* not the 'standard' way of doing perl constants, but a lot easier to maintain */
+#ifdef RPM2_RPM41
        REGISTER_CONSTANT(RPMVSF_DEFAULT);
        REGISTER_CONSTANT(RPMVSF_NOHDRCHK);
        REGISTER_CONSTANT(RPMVSF_NEEDPAYLOAD);
@@ -60,8 +65,23 @@ BOOT:
        REGISTER_CONSTANT(_RPMVSF_NOSIGNATURES);
        REGISTER_CONSTANT(_RPMVSF_NOHEADER);
        REGISTER_CONSTANT(_RPMVSF_NOPAYLOAD);
+#endif
     }
 
+double
+rpm_api_version(pkg)
+       char * pkg
+    CODE:
+#if defined(RPM2_RPM41) && ! defined(RPM2_RPM40)
+       RETVAL = (double)4.1;
+#endif
+#if ! defined(RPM2_RPM41) && defined(RPM2_RPM40)
+       RETVAL = (double)4.0;
+#endif
+    OUTPUT:
+       RETVAL
+
+
 void
 add_macro(pkg, name, val)
        char * pkg
@@ -277,6 +297,14 @@ _header_compare(h1, h2)
     OUTPUT:
         RETVAL
 
+int
+_header_is_source(h)
+       Header h
+    CODE:
+       RETVAL = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
+    OUTPUT:
+       RETVAL
+
 void
 _header_sprintf(h, format)
        Header h
index 3a286fb..5b295cd 100644 (file)
@@ -11,7 +11,7 @@ use strict;
 
 use Test;
 use strict;
-BEGIN { plan tests => 33 };
+BEGIN { plan tests => 35 };
 use RPM2;
 ok(1); # If we made it this far, we're ok.
 
@@ -117,5 +117,6 @@ 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);
+ok(RPM2->rpm_api_version == 4.1 or RPM2->rpm_api_version == 4.0);
+ok(RPM2->rpm_api_version == 4.0 or RPM2->vsf_nosha1 == 65536);