Index: URPM-3.10/Makefile.PL
--- URPM-3.10/Makefile.PL.orig	2008-02-08 18:00:24 +0100
+++ URPM-3.10/Makefile.PL	2008-02-25 21:31:56 +0100
@@ -1,74 +1,7 @@
 use strict;
 use ExtUtils::MakeMaker;
 
-# where to find the rpm utility
-
-my $rpm_path = $ENV{RPM_PATH}; # this overrides
-
-unless (defined $rpm_path) {
-    for (qw(/bin/rpm /usr/bin/rpm)) {
-	if (-x) {
-	    $rpm_path = $_;
-	    last;
-	}
-    }
-}
-
-defined $rpm_path or die "Can't find rpm on this system\n";
-
-my $version = `LC_ALL=C $rpm_path --version`;
-# fix compiling with RCs:
-$version =~ s/-.*//;
-chomp $version;
-$version =~ s/(RPM version )|(rpm \(RPM\) )//;
-my $pversion = eval "v$version";
-$pversion ge v4.2 or die "Unable to build URPM with too old (or undetected) rpm version $version\n";
-
-# to generate the ChangeLog depending on the checkout layout
-my $commonusername = "../common/";
--d $commonusername or do {
-    $commonusername = "../../common/";
-    -d $commonusername or do {
-	$commonusername = "../../../common/";
-	-d $commonusername or $commonusername = "";
-    };
-};
-
-sub MY::postamble {
-    <<"**MM**";
-.PHONY: ChangeLog
-
-ChangeLog:
-	LC_ALL=C svn2cl --accum --strip-prefix=soft/rpm/perl-URPM/trunk --authors ${commonusername}username.xml
-	rm -f *.bak
-**MM**
-}
-
-my @rpmflags;
-if ($pversion ge v4.4.90 && $pversion lt v4.5) {
-    # rpm.org version
-    push @rpmflags, '-DRPM_ORG';
-} else {
-    # rpm5.org version
-    if ($pversion ge v4.4.5) {
-	push @rpmflags, '-DRPM_CALLBACK_LONGLONG';
-    } 
-    if ($pversion ge v4.4.6) {
-	push @rpmflags, '-DRPM_446';
-    }
-    if ($pversion ge v4.4.8) {
-	push @rpmflags, '-DRPM_448';
-    }
-    if ($pversion ge v4.5) {
-	push @rpmflags, '-DRPM_450';
-    }
-    if ($pversion ge v5.0.0) {
-	push @rpmflags, '-DRPM_500 -DWITH_DB';
-    }
-}
-my $ccflags = join(' ', '-Wall -fno-strict-aliasing', @rpmflags);
-
-print "Found RPM version $version (compiling with flags: $ccflags)\n";
+my $ccflags = '-fno-strict-aliasing';
 
 WriteMakefile(
     NAME	=> 'URPM',
@@ -77,8 +10,8 @@
     },
     CCFLAGS	=> $ccflags,
     VERSION_FROM	=> 'URPM.pm',
-    LIBS	=> [ '-lrpm -lrpmio -lrpmdb -lrpmbuild -lpopt -lz' ],
-    INC		=> '-I/usr/include/rpm',
+    LIBS	=> [ `openpkg rpm-config --ldflags --libs` ],
+    INC		=> `openpkg rpm-config --cflags --cppflags`,
     dist	=> { COMPRESS => "bzip2", SUFFIX => ".bz2" },
     realclean	=> { FILES => "t/RPMS/noarch/*" },
 );
Index: URPM-3.10/URPM.xs
--- URPM-3.10/URPM.xs.orig	2008-01-25 16:50:01 +0100
+++ URPM-3.10/URPM.xs	2008-02-25 21:27:12 +0100
@@ -22,7 +22,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <zlib.h>
-#include <libintl.h>
+#include <glob.h>
 
 #undef Fflush
 #undef Mkdir
@@ -80,6 +80,10 @@
 #include <rpm/rpmbuild.h>
 #include <rpm/rpmlog.h>
 
+#ifndef RPMSENSE_MISSINGOK
+#define RPMSENSE_MISSINGOK 0
+#endif
+
 struct s_Package {
   char *info;
   char *requires;
Index: rpmtools-5.3.6/Makefile.PL
--- rpmtools-5.3.6/Makefile.PL.orig	2008-02-05 09:52:26 +0100
+++ rpmtools-5.3.6/Makefile.PL	2008-02-25 21:27:12 +0100
@@ -35,8 +35,8 @@
         RPMTOOLSVERSION => $rpmtools_version,
         FROMC => 'parsehdlist rpm2header #rpm-find-leaves',
         FROMCC => '#gendepslist2 hdlist2names hdlist2files hdlist2prereq hdlist2groups',
-        LIBRPM => '-lrpm -lrpmio -lrpmdb -lrpmbuild -lz -lbz2 -lpopt',
-        INCRPM => '-I/usr/include/rpm',
+        LIBRPM => `openpkg rpm-config --ldflags --libs`,
+        INCRPM => `openpkg rpm-config --cflags --cppflags`,
     },
     depend => {
         clean_subdirs => 'cleanc',
@@ -49,7 +49,7 @@
     C		    => [],
     OBJECT	    => '',
     CCFLAGS	    => '-Wall',
-    OPTIMIZE	    => '-O3 -fomit-frame-pointer -fno-exceptions -pipe -s -ffast-math -fexpensive-optimizations',
+    OPTIMIZE	    => '-O2',
     INC		    => '',
     LIBS	    => [ '' ],
     INSTALLDIRS	    => 'vendor',
Index: rpmtools-5.3.6/parsehdlist.c
--- rpmtools-5.3.6/parsehdlist.c.orig	2007-06-22 13:46:09 +0200
+++ rpmtools-5.3.6/parsehdlist.c	2008-02-25 21:27:12 +0100
@@ -7,6 +7,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <errno.h>
+#include <rpm/glob.h>
 #include <rpm/rpmlib.h>
 #include <rpm/header.h>
 #include <stdio.h>
Index: rpmtools-5.3.6/rpm2header.c
--- rpmtools-5.3.6/rpm2header.c.orig	2007-12-17 13:50:16 +0100
+++ rpmtools-5.3.6/rpm2header.c	2008-02-25 21:27:12 +0100
@@ -5,7 +5,8 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <rpmlib.h>
+#include <rpm/glob.h>
+#include <rpm/rpmlib.h>
 #include <rpm/rpmts.h>
 
 #define FILENAME_TAG 1000000
Index: urpmi-5.6/Makefile.PL
--- urpmi-5.6/Makefile.PL.orig	2007-12-04 14:50:05 +0100
+++ urpmi-5.6/Makefile.PL	2008-02-25 21:27:12 +0100
@@ -60,6 +60,7 @@
     my $po = $with_po ? ' installpo' : '';
     my $gui = $with_gui ? ' installgurpmi2' : '';
     $inherited =~ s/^install ::/$& installconfigfiles installstatedir$po$gui/gm;
+    $inherited =~ s/^pure_install ::/$& installconfigfiles installstatedir$po$gui/gm;
     $inherited;
 }
 
@@ -101,10 +102,10 @@
 	install -m 644 inst.list skip.list \$(SYSCONFDIR)/urpmi
 
 installstatedir:
-	install -d \$(LOCALSTATEDIR)/urpmi
-	install -d \$(DESTDIR)/var/cache/urpmi/partial
-	install -d \$(DESTDIR)/var/cache/urpmi/headers
-	install -d \$(DESTDIR)/var/cache/urpmi/rpms
+	install -d \$(LOCALSTATEDIR)/urpmi/lib
+	install -d \$(DESTDIR)/\$(PREFIX)/var/urpmi/cache/partial
+	install -d \$(DESTDIR)/\$(PREFIX)/var/urpmi/cache/headers
+	install -d \$(DESTDIR)/\$(PREFIX)/var/urpmi/cache/rpms
 
 installgurpmi2: pure_install
 	ln -s -f consolehelper \$(DESTINSTALLSCRIPT)/gurpmi2
@@ -146,8 +147,8 @@
 	INST_MAN5DIR		=> 'blib/man5',
 	INST_MAN8DIR		=> 'blib/man8',
 	# We could read those values from rpm macros.
-	SYSCONFDIR		=> '$(DESTDIR)/etc',
-	LOCALSTATEDIR		=> '$(DESTDIR)/var/lib',
+	SYSCONFDIR		=> '$(DESTDIR)$(PREFIX)/etc',
+	LOCALSTATEDIR		=> '$(DESTDIR)$(PREFIX)/var',
     },
     EXE_FILES		=> [ @bin_scripts, @sbin_scripts ],
     PMLIBDIRS		=> [ qw(urpm) ],
Index: urpmi-5.6/urpm/sys.pm
--- urpmi-5.6/urpm/sys.pm.orig	2007-10-02 14:01:03 +0200
+++ urpmi-5.6/urpm/sys.pm	2008-02-25 21:27:12 +0100
@@ -114,7 +114,7 @@
 }
 
 sub proc_mounts() {
-    my @l = cat_('/proc/mounts') or warn "Can't read /proc/mounts: $!\n";
+    my @l = (-f '/proc/mounts' ? cat_('/proc/mounts') : ());
     @l;
 }
 
