Index: URPM-1.51/Makefile.PL
--- URPM-1.51/Makefile.PL.orig	2006-11-03 16:03:35 +0100
+++ URPM-1.51/Makefile.PL	2006-11-25 20:25:08 +0100
@@ -3,46 +3,15 @@
 
 # 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`;
-chomp $version;
-$version =~ s/RPM version //;
-$version =~ /^(?:4\.[2-9]|[5-9]|\d{2})/ 
-    or die "Unable to build URPM with too old (or undetected) rpm version $version\n";
-print "Found RPM version $version\n";
-
-# directory where to build an rpm of this
-my $rpmtopdir = `$rpm_path --eval '%{_topdir}'`;
-chomp $rpmtopdir;
-
-# 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 = "";
-    };
-};
+my $rpm_path = "";
+my $rpmtopdir = "";
 
 sub MY::postamble {
     <<"**MM**";
 .PHONY: ChangeLog rpmdist srpm rpm
 
 ChangeLog:
-	LC_ALL=C svn2cl --accum --strip-prefix=soft/rpm/perl-URPM/trunk --authors ${commonusername}username.xml
+	LC_ALL=C svn2cl --accum --strip-prefix=soft/rpm/perl-URPM/trunk --authors username.xml
 	rm -f *.bak
 
 rpmdist: dist
@@ -57,13 +26,7 @@
 **MM**
 }
 
-my $ccflags = '-Wall -fno-strict-aliasing';
-if ($version =~ /^4\.(4\.[5-9]$|4\.\d\d|[5-9]\.|\d\d)/) {
-    $ccflags .= ' -DRPM_CALLBACK_LONGLONG';
-}
-if ($version eq '4.4.6') {
-    $ccflags .= ' -DRPM_446';
-}
+my $ccflags = '-fno-strict-aliasing';
 
 WriteMakefile(
     NAME	=> 'URPM',
@@ -72,8 +35,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-1.51/URPM.xs
--- URPM-1.51/URPM.xs.orig	2006-11-17 17:43:04 +0100
+++ URPM-1.51/URPM.xs	2006-11-25 20:25:08 +0100
@@ -22,6 +22,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <zlib.h>
+#include <glob.h>
 
 #undef Fflush
 #undef Mkdir
Index: rpmtools-5.1.0/Makefile.PL
--- rpmtools-5.1.0/Makefile.PL.orig	2006-08-22 15:46:50 +0200
+++ rpmtools-5.1.0/Makefile.PL	2006-11-25 20:25:08 +0100
@@ -45,8 +45,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',
@@ -63,7 +63,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.1.0/parsehdlist.c
--- rpmtools-5.1.0/parsehdlist.c.orig	2006-06-13 13:19:09 +0200
+++ rpmtools-5.1.0/parsehdlist.c	2006-11-25 20:25:08 +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.1.0/rpm2header.c
--- rpmtools-5.1.0/rpm2header.c.orig	2006-06-12 11:10:34 +0200
+++ rpmtools-5.1.0/rpm2header.c	2006-11-25 20:25:08 +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-4.9.6/Makefile.PL
--- urpmi-4.9.6/Makefile.PL.orig	2006-11-17 18:51:28 +0100
+++ urpmi-4.9.6/Makefile.PL	2006-11-25 20:25:08 +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;
 }
 
@@ -110,10 +111,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
@@ -147,8 +148,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-4.9.6/urpm/sys.pm
--- urpmi-4.9.6/urpm/sys.pm.orig	2006-11-23 11:51:16 +0100
+++ urpmi-4.9.6/urpm/sys.pm	2006-11-25 20:26:24 +0100
@@ -94,7 +94,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;
 }
 
