# 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'
+#include "rpmlib.h"
#include "rpmcli.h"
+
+#ifdef RPM2_RPM41
#include "rpmts.h"
+#endif
+
#include "header.h"
#include "rpmdb.h"
#include "misc.h"
_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;
*/
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);
else {
croak("error reading package");
}
+#ifdef RPM2_RPM41
ts = rpmtsFree(ts);
+#endif
void
_free_header(h)