summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--perl-RPM2/Makefile.PL17
-rw-r--r--perl-RPM2/RPM2.xs15
2 files changed, 28 insertions, 4 deletions
diff --git a/perl-RPM2/Makefile.PL b/perl-RPM2/Makefile.PL
index 83f50c13b..e6fe3c91d 100644
--- a/perl-RPM2/Makefile.PL
+++ b/perl-RPM2/Makefile.PL
@@ -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'
diff --git a/perl-RPM2/RPM2.xs b/perl-RPM2/RPM2.xs
index 20330d25e..c9818979b 100644
--- a/perl-RPM2/RPM2.xs
+++ b/perl-RPM2/RPM2.xs
@@ -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)