return RPM 4.0 support... sort of
authorcturner <devnull@localhost>
Wed, 7 Aug 2002 17:05:35 +0000 (17:05 +0000)
committercturner <devnull@localhost>
Wed, 7 Aug 2002 17:05:35 +0000 (17:05 +0000)
CVS patchset: 5612
CVS date: 2002/08/07 17:05:35

perl-RPM2/Makefile.PL
perl-RPM2/RPM2.xs

index 83f50c1..e6fe3c9 100644 (file)
@@ -2,26 +2,35 @@ 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-4.1 -lrpmdb-4.1 -lrpmio-4.1 -lpopt";
+my $libs = "-lrpm -lrpmdb -lrpmio -lpopt";
 
 # try to be smart about which shared libs we should load.
 # use the .la file.  probably linux only.
 
-if (0 and open FH, "</usr/lib/librpm.la") {
+if (open FH, "</usr/lib/librpm.la") {
   my ($line, @rest) = grep { /^dependency_libs=/ } <FH>;
   if ($line and not @rest) {
     if ($line =~ /^dependency_libs='(.*)'$/) {
-      $libs = "-lrpm-4.1 $1";
+      $libs = "-lrpm $1";
     }
   }
 }
 
+my @defines;
+# detect which rpm is running.  ugly but necessary... for now.
+if (-e '/usr/include/rpm/rpmts.h') {
+  push @defines, '-DRPM2_RPM41';
+}
+else {
+  push @defines, '-DRPM2_RPM40';
+}
+
 WriteMakefile(
     'NAME'             => 'RPM2',
     'VERSION_FROM'     => 'RPM2.pm', # finds $VERSION
     'PREREQ_PM'                => {}, # e.g., Module::Name => 1.1
     'LIBS'             => [ $libs ], # e.g., '-lm'
-    'DEFINE'           => '', # e.g., '-DHAVE_SOMETHING'
+    'DEFINE'           => join(" ", @defines), # e.g., '-DHAVE_SOMETHING'
     'INC'              => '-I/usr/include/rpm', # e.g., '-I/usr/include/other'
     'TYPEMAPS'          => [ 'typemap' ],
     'OPTIMIZE'          => '-g'
index 20330d2..c981897 100644 (file)
@@ -1,5 +1,10 @@
+#include "rpmlib.h"
 #include "rpmcli.h"
+
+#ifdef RPM2_RPM41
 #include "rpmts.h"
+#endif
+
 #include "header.h"
 #include "rpmdb.h"
 #include "misc.h"
@@ -89,13 +94,17 @@ void
 _read_package_info(fp)
        FILE *fp
     PREINIT:
+#ifdef RPM2_RPM41
        rpmts ts;
+#endif
        Header ret;
        Header sigs;
        rpmRC rc;
        FD_t fd;
     PPCODE:
+#ifdef RPM2_RPM41
        ts = rpmtsCreate();
+#endif
 
         /* XXX Determine type of signature verification when reading
        vsflags |= _RPMTS_VSF_NOLEGACY;
@@ -105,7 +114,11 @@ _read_package_info(fp)
         */ 
 
        fd = fdDup(fileno(fp));
+#ifdef RPM2_RPM41
        rc = rpmReadPackageFile(ts, fd, "filename or other identifier", &ret);
+#else
+       rc = rpmReadPackageInfo(fd, NULL, &ret);
+#endif
 
        Fclose(fd);
 
@@ -122,7 +135,9 @@ _read_package_info(fp)
        else {
            croak("error reading package");
        }
+#ifdef RPM2_RPM41
        ts = rpmtsFree(ts);
+#endif
 
 void
 _free_header(h)