Index: trunk/dports/sysutils/rpm41/Portfile
===================================================================
--- trunk/dports/sysutils/rpm41/Portfile	(revision 3916)
+++ trunk/dports/sysutils/rpm41/Portfile	(revision 3916)
@@ -0,0 +1,78 @@
+# $Id: Portfile,v 1.1 2003/11/10 17:12:53 ssen Exp $
+
+PortSystem 1.0
+name			rpm41
+version			4.1.1
+platforms		darwin
+revision		0
+categories		sysutils archivers
+maintainers		ssen@opendarwin.org
+description		RedHat Package Manager
+
+master_sites		ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.1.x/
+checksums		md5 da4c87e95092aa9f0c85da3836e6b1c6
+distname		rpm-${version}
+
+depends_lib		lib:libbz2.1.0:bzip2 lib:libiconv.2:libiconv \
+			bin:python:python
+
+configure.args		--disable-nls --with-included-gettext \
+			--with-glob --with-libiconv-prefix=${prefix} \
+			--mandir=${prefix}/share/man
+
+variant darwin {
+	patchfiles-append \
+		patch-db3-configure.diff        patch-rpmheader.diff \
+		patch-dump.diff                 patch-rpmioc.diff \
+		patch-dumpdb.diff               patch-rpmioh.diff \
+		patch-lib-signature.diff        patch-rpmlead.diff \
+		patch-macros-in.diff            patch-rpmqv.diff \
+		patch-rpm2cpio.diff             patch-rpmsignature.diff \
+		patch-rpmarchive.diff           patch-systemh.diff \
+		patch-rpmrc.diff		patch-file-systemh.diff \
+		patch-file-filec.diff		patch-rpmio-Makefile-in.diff \
+		patch-fts.diff			patch-rpmrpc.diff \
+		patch-rpmdb-Makefile-in.diff	patch-lib-Makefile-in.diff \
+		patch-rpmdb-rpmdbc.diff		patch-build-Makefile-in.diff \
+		patch-tools-rpmfile.diff	patch-tools-Makefile-in.diff \
+		patch-Makefile-in.diff		patch-ltmain-sh.diff
+
+#patch-rpmrc-in.diff
+
+#		patch-autodeps-darwin-prov.diff	patch-autodeps-darwin-req.diff \
+#		patch-python-rpmmodule.diff	patch-python-makefile-in.diff
+
+	post-patch {
+		system "rm -rf \"${worksrcpath}/elfutils\""
+	}
+
+	pre-configure {
+	        system "mkdir -p ${workpath}/librt"
+		system "ln -sf /usr/lib/libSystem.B.dylib \
+				${workpath}/librt/librt.dylib"
+	}
+
+	configure.args-append --disable-optimized --disable-aio \
+			      --with-python=no --without-javaglue \
+		              --enable-broken-chown
+
+	configure.env   LDFLAGS="-L${prefix}/lib -L${workpath}/librt" \
+			CFLAGS="-I${prefix}/include -no-cpp-precomp" \
+			CPPFLAGS=""
+
+	post-destroot {
+		# where the RPM database to lives
+		system "mkdir -p '${destroot}${prefix}/var/lib/rpm'"
+		system "touch '${destroot}${prefix}/var/lib/rpm/.turd'"
+		system "mkdir -p '${destroot}${prefix}/src/apple/BUILD'"
+		system "touch '${destroot}${prefix}/src/apple/BUILD/.turd'"
+		system "mkdir -p '${destroot}${prefix}/src/apple/RPMS'"
+		system "touch '${destroot}${prefix}/src/apple/RPMS/.turd'"
+		system "mkdir -p '${destroot}${prefix}/src/apple/SOURCES'"
+		system "touch '${destroot}${prefix}/src/apple/SOURCES/.turd'"
+		system "mkdir -p '${destroot}${prefix}/src/apple/SPECS'"
+		system "touch '${destroot}${prefix}/src/apple/SPECS/.turd'"
+		system "mkdir -p '${destroot}${prefix}/src/apple/SRPMS'"
+		system "touch '${destroot}${prefix}/src/apple/SRPMS/.turd'"
+	}
+}
Index: trunk/dports/sysutils/rpm41/files/patch-Makefile-in.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-Makefile-in.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-Makefile-in.diff	(revision 3916)
@@ -0,0 +1,10 @@
+--- Makefile.in.orig	Sun Nov  9 19:49:40 2003
++++ Makefile.in	Sun Nov  9 19:56:31 2003
+@@ -228,6 +228,7 @@
+ 	-I$(top_srcdir)/rpmio \
+ 	-I$(top_srcdir)/beecrypt \
+ 	-I$(top_srcdir)/popt \
++	-I$(top_srcdir)/misc \
+ 	@WITH_LIBELF_INCLUDE@ \
+ 	@WITH_ZLIB_INCLUDE@ \
+ 	@INCPATH@
Index: trunk/dports/sysutils/rpm41/files/patch-autodeps-darwin-prov.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-autodeps-darwin-prov.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-autodeps-darwin-prov.diff	(revision 3916)
@@ -0,0 +1,48 @@
+--- /dev/null	Sat May 31 18:22:36 2003
++++ autodeps/darwin.prov	Sat May 31 18:21:55 2003
+@@ -0,0 +1,45 @@
++#!/usr/bin/perl
++# ----------------------------------------------------------
++#	find-provides for Darwin
++# ----------------------------------------------------------
++
++my %files;
++
++while (my $DEP = <STDIN>) {
++	chomp $DEP;
++
++	next if (-d $DEP);
++
++	next if ($DEP =~ m,\.class$,);
++
++	for my $ARCH ('ppc', 'i386') {
++		my $FILE = $DEP;
++		my $header;
++		my $FILE_esc = $FILE;
++		$FILE_esc =~ s/\'/\\\'/g;
++		if (open(OTOOL, "otool -arch '$ARCH' -hv '$FILE_esc' 2>/dev/null |")) {
++			while (<OTOOL>) {
++				if (/MH_MAGIC/) {
++						$header = $_;
++				}
++			}
++			close(OTOOL);
++			if (split(/\s+/, $header) and $_[4] eq 'DYLIB') {
++				if (open(OTOOL, "otool -arch '$ARCH' -DX '$FILE_esc' 2>/dev/null |")) {
++					chomp($FILE = <OTOOL>);
++					if ($FILE =~ m,\.framework/,) {
++						$FILE =~ s,^.*?/([^/]*?\.framework)/.*$,$1,;
++					}
++					$files{"$FILE-$ARCH"} = 1;
++				} else {
++					warn "couldn't determine install_name for '$FILE': $!\n";
++				}
++			}
++		} else {
++			warn "unable to run otool on $FILE: $!\n";
++			next;
++		}
++	}
++}
++
++print join("\n", sort keys %files), "\n";
Index: trunk/dports/sysutils/rpm41/files/patch-autodeps-darwin-req.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-autodeps-darwin-req.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-autodeps-darwin-req.diff	(revision 3916)
@@ -0,0 +1,72 @@
+--- /dev/null	Mon Jun  2 11:50:07 2003
++++ autodeps/darwin.req	Mon Jun  2 11:49:57 2003
+@@ -0,0 +1,69 @@
++#!/usr/bin/perl
++# ----------------------------------------------------------------
++#	find-requires for Darwin
++# ----------------------------------------------------------------
++
++my %files;
++my @check;
++my %receipts;
++my $usereceipts = 0;
++
++if (exists $ENV{'DP_USERECEIPTS'}) {
++	my $directory = $ENV{'DP_USERECEIPTS'};
++	if (opendir(DIR, $directory)) {
++		for my $receipt (grep(!/^\.\.?$/, readdir(DIR))) {
++			chomp($receipt);
++			my $receiptopen;
++			if ($receipt =~ /\.bz2$/) {
++				$receiptopen = "bzip2 -dc $directory/$receipt |";
++			} else {
++				$receiptopen = "$directory/$receipt";
++			}
++			if (open(RECEIPT, $receiptopen)) {
++				while (my $contents = <RECEIPT>) {
++					while ($contents =~ /\G.*?MD5 \((.+?)\)/gs) {
++						$receipts{$1} = 1;
++					}
++				}
++				close(RECEIPT);
++			} else {
++				warn "couldn't read $receipt: $!\n";
++			}
++		}
++		closedir(DIR);
++		$usereceipts = 1;
++	} else {
++		warn "couldn't open receipt directory: $!\n";
++	}
++}
++
++while (my $FILE = <STDIN>) {
++	chomp $FILE;
++
++	next if (-d $FILE);
++
++	next if ($FILE =~ m,\.class$,);
++
++	my $FILE_esc = $FILE;
++	$FILE_esc =~ s/\'/\\\'/g;
++
++	for my $ARCH ('ppc', 'i386') {
++		if (open(OTOOL, "otool -arch '$ARCH' -L '$FILE_esc' 2>/dev/null |")) {
++			while (<OTOOL>) {
++				if (/^\s*([^\s].*)\s+\(compatibility version/) {
++					my $dep = $1;
++					next if ($usereceipts and not exists $receipts{$dep});
++					if ($dep =~ m,\.framework/.*,) {
++						$dep =~ s,^.*?/([^/]*?\.framework)/.*$,$1,;
++					}
++					$files{"$dep-$ARCH"} = 1;
++				}
++			}
++			close(OTOOL);
++		} else {
++			warn "couldn't run otool on '$FILE': $!\n";
++		}
++	}
++}
++
++print join("\n", sort keys %files), "\n";
Index: trunk/dports/sysutils/rpm41/files/patch-build-Makefile-in.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-build-Makefile-in.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-build-Makefile-in.diff	(revision 3916)
@@ -0,0 +1,10 @@
+--- build/Makefile.in.orig	Sun Nov  9 12:44:19 2003
++++ build/Makefile.in	Sun Nov  9 12:44:42 2003
+@@ -213,6 +213,7 @@
+ 	-I$(top_srcdir)/rpmdb \
+ 	-I$(top_srcdir)/rpmio \
+ 	-I$(top_srcdir)/popt \
++	-I$(top_srcdir)/misc \
+ 	@WITH_LIBELF_INCLUDE@ \
+ 	@INCPATH@
+ 
Index: trunk/dports/sysutils/rpm41/files/patch-db3-configure.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-db3-configure.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-db3-configure.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- db3/configure.orig	Sat Jan 18 06:04:22 2003
++++ db3/configure	Sat Nov  8 18:47:13 2003
+@@ -15,7 +15,7 @@
+ cat Makefile.orig | sed -e '/^install[:-]/c\
+ .PHONY: listobjs\
+ listobjs:\
+-	@echo $(OBJS) $(C_OBJS) \
++\	@echo $(OBJS) $(C_OBJS) \
+ \
+ distdir install check:\
+ \
Index: trunk/dports/sysutils/rpm41/files/patch-dump.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-dump.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-dump.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- tools/dump.c Sun Jun 17 13:38:10 2001
++++ ../rpm-4.0.4/tools/dump.c      Thu Jul 11 12:59:25 2002
+@@ -4,6 +4,8 @@
+ #include "header_internal.h"
+ #include "debug.h"
+ 
++const char *program_name;
++
+ int main(int argc, char ** argv)
+ {
+     Header h;
Index: trunk/dports/sysutils/rpm41/files/patch-dumpdb.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-dumpdb.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-dumpdb.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- tools/dumpdb.c.orig	Thu May 16 09:56:10 2002
++++ tools/dumpdb.c	Sat Nov  8 18:47:14 2003
+@@ -7,6 +7,8 @@
+ 
+ #include "debug.h"
+ 
++const char *program_name;
++
+ int main(int argc, char ** argv)
+ {
+     unsigned int dspBlockNum = 0;		/* default to all */
Index: trunk/dports/sysutils/rpm41/files/patch-file-filec.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-file-filec.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-file-filec.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- file/file.c.orig	Sat Nov  8 19:01:16 2003
++++ file/file.c	Sat Nov  8 19:01:25 2003
+@@ -149,6 +149,8 @@
+ }
+ #endif
+ 
++const char *program_name;
++
+ /*
+  * main - parse arguments and handle options
+  */
Index: trunk/dports/sysutils/rpm41/files/patch-file-systemh.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-file-systemh.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-file-systemh.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- file/system.h.orig	Sat Nov  8 18:59:43 2003
++++ file/system.h	Sat Nov  8 18:59:55 2003
+@@ -306,7 +306,7 @@
+   }
+ #endif
+ /*@unchecked@*/
+-const char *__progname;
++extern const char *__progname;
+ 
+ #if HAVE_LOCALE_H
+ # include <locale.h>
Index: trunk/dports/sysutils/rpm41/files/patch-fts.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-fts.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-fts.diff	(revision 3916)
@@ -0,0 +1,42 @@
+--- rpmio/fts.h.orig	Sat Nov  8 20:39:29 2003
++++ rpmio/fts.h	Sat Nov  8 20:40:16 2003
+@@ -55,6 +55,10 @@
+ # define _D_EXACT_NAMLEN(d) ((d)->d_reclen)
+ #endif
+ 
++#if defined(__APPLE__)
++# define _D_EXACT_NAMLEN(d) ((d)->d_reclen)
++#endif
++
+ #endif
+ 
+ #include <sys/types.h>
+--- rpmio/fts.c.orig	Sat Nov  8 20:34:53 2003
++++ rpmio/fts.c	Sat Nov  8 20:42:10 2003
+@@ -59,6 +59,9 @@
+ #   define _STAT_VER		0
+ #   define __fxstat64(_stat_ver, _fd, _sbp)	fstat((_fd), (_sbp))
+ #endif
++#if defined(__APPLE__)
++#   define __errno_location() (__error())
++#endif
+ #include "system.h"
+ #include "fts.h"
+ #include "rpmio.h"
+@@ -1171,14 +1174,14 @@
+ fts_safe_changedir(FTS * sp, FTSENT * p, int fd, const char * path)
+ {
+ 	int ret, oerrno, newfd;
+-	struct stat64 sb;
++	struct stat sb;
+ 
+ 	newfd = fd;
+ 	if (ISSET(FTS_NOCHDIR))
+ 		return (0);
+ 	if (fd < 0 && (newfd = __open(path, O_RDONLY, 0)) < 0)
+ 		return (-1);
+-	if (__fxstat64(_STAT_VER, newfd, &sb)) {
++	if (fstat(newfd, &sb)) {
+ 		ret = -1;
+ 		goto bail;
+ 	}
Index: trunk/dports/sysutils/rpm41/files/patch-lib-Makefile-in.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-lib-Makefile-in.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-lib-Makefile-in.diff	(revision 3916)
@@ -0,0 +1,10 @@
+--- lib/Makefile.in.orig	Sun Nov  9 12:08:19 2003
++++ lib/Makefile.in	Sun Nov  9 12:08:44 2003
+@@ -213,6 +213,7 @@
+ 	-I$(top_srcdir)/rpmdb \
+ 	-I$(top_srcdir)/rpmio \
+ 	-I$(top_srcdir)/popt \
++	-I$(top_srcdir)/misc \
+ 	@INCPATH@
+ 
+ 
Index: trunk/dports/sysutils/rpm41/files/patch-lib-signature.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-lib-signature.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-lib-signature.diff	(revision 3916)
@@ -0,0 +1,12 @@
+--- lib/signature.c.orig	Sun Nov  9 17:38:03 2003
++++ lib/signature.c	Sun Nov  9 17:38:57 2003
+@@ -27,7 +27,8 @@
+ /*@access pgpDigParams@*/
+ 
+ #if !defined(__GLIBC__)
+-char ** environ = NULL;
++#include <crt_externs.h>
++#define environ (*_NSGetEnviron())
+ #endif
+ 
+ int rpmLookupSignatureType(int action)
Index: trunk/dports/sysutils/rpm41/files/patch-ltmain-sh.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-ltmain-sh.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-ltmain-sh.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- ltmain.sh.orig	Sun Nov  9 20:39:52 2003
++++ ltmain.sh	Sun Nov  9 20:40:00 2003
+@@ -1772,7 +1772,7 @@
+ 
+ 	  if test "$installed" = no; then
+ 	    notinst_deplibs="$notinst_deplibs $lib"
+-	    need_relink=yes
++	    need_relink=no
+ 	  fi
+ 
+ 	  if test -n "$old_archive_from_expsyms_cmds"; then
Index: trunk/dports/sysutils/rpm41/files/patch-macros-in.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-macros-in.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-macros-in.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- macros.in.orig	Fri Feb 21 19:27:43 2003
++++ macros.in	Fri Feb 21 19:27:55 2003
+@@ -163,7 +163,7 @@
+ %_tmppath		%{_var}/tmp
+ 
+ #	Path to top of build area.
+-%_topdir		%{_usrsrc}/redhat
++%_topdir		%{_usrsrc}/%{_vendor}
+ 
+ #	The path to the unzip executable (legacy, use %{__unzip} instead).
+ %_unzipbin		%{__unzip}
Index: trunk/dports/sysutils/rpm41/files/patch-python-makefile-in.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-python-makefile-in.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-python-makefile-in.diff	(revision 3916)
@@ -0,0 +1,35 @@
+--- python-orig/Makefile.in	Thu Feb 14 15:58:41 2002
++++ python/Makefile.in	Fri May 30 14:53:52 2003
+@@ -210,15 +210,15 @@
+ 	$(top_builddir)/popt/libpopt.la
+ 
+ 
+-LDADD = 
++LDADD = 
+ 
+ pythondir = $(prefix)/lib/python${PYVER}/site-packages
+-python_PROGRAMS = rpmmodule.so poptmodule.so
++python_LTLIBRARIES = rpmmodule.so poptmodule.so
+ 
+ rpmmodule_so_SOURCES = 
+-rpmmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,rpmmodule.so
++rpmmodule_so_LDFLAGS = $(mylibs) $(LIBS) -bundle -bundle_loader $(__PYTHON)
+ poptmodule_so_SOURCES = poptmodule.c
+-poptmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,poptmodule.so
++poptmodule_so_LDFLAGS = $(mylibs) $(LIBS) -bundle -bundle_loader $(__PYTHON)
+ 
+ noinst_LTLIBRARIES = librpmmodule.la
+ librpmmodule_la_SOURCES = rpmmodule.c hash.c upgrade.c
+@@ -476,10 +476,10 @@
+ 
+ 
+ rpmmodule.so: $(librpmmodule_la_OBJECTS)
+-	$(LINK) -o $@ $(librpmmodule_la_OBJECTS) $(rpmmodule_so_LDFLAGS)
++	$(LINK) $(librpmmodule_la_OBJECTS) $(rpmmodule_so_LDFLAGS)
+ 
+ poptmodule.so: $(poptmodule_so_OBJECTS)
+-	$(LINK) -o $@ $(poptmodule_so_OBJECTS) $(poptmodule_so_LDFLAGS)
++	$(LINK) $(poptmodule_so_OBJECTS) $(poptmodule_so_LDFLAGS)
+ 
+ .PHONY:	lclint
+ lclint:
Index: trunk/dports/sysutils/rpm41/files/patch-python-rpmmodule.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-python-rpmmodule.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-python-rpmmodule.diff	(revision 3916)
@@ -0,0 +1,10 @@
+--- python-orig/rpmmodule.c	Sun Feb  3 15:59:57 2002
++++ python/rpmmodule.c	Fri May 30 14:47:56 2003
+@@ -2,7 +2,6 @@
+  * \file python/rpmmodule.c
+  */
+ 
+-#include <alloca.h>
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <time.h>
Index: trunk/dports/sysutils/rpm41/files/patch-rpm2cpio.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpm2cpio.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpm2cpio.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- rpm2cpio.c   Sun Jun 17 13:43:29 2001
++++ ../rpm-4.0.4/rpm2cpio.c        Thu Jul 11 13:05:03 2002
+@@ -5,6 +5,8 @@
+ #include "rpmlib.h"
+ #include "debug.h"
+ 
++const char *program_name;
++
+ int main(int argc, char **argv)
+ {
+     FD_t fdi, fdo;
Index: trunk/dports/sysutils/rpm41/files/patch-rpmarchive.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmarchive.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmarchive.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- tools/rpmarchive.c   Sun Jun 17 13:39:50 2001
++++ ../rpm-4.0.4/tools/rpmarchive.c        Thu Jul 11 13:00:26 2002
+@@ -8,6 +8,8 @@
+ 
+ #include "debug.h"
+ 
++const char *program_name;
++
+ int main(int argc, char **argv)
+ {
+     FD_t fdi, fdo;
Index: trunk/dports/sysutils/rpm41/files/patch-rpmdb-Makefile-in.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmdb-Makefile-in.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmdb-Makefile-in.diff	(revision 3916)
@@ -0,0 +1,10 @@
+--- rpmdb/Makefile.in.orig	Sun Nov  9 11:39:27 2003
++++ rpmdb/Makefile.in	Sun Nov  9 11:39:45 2003
+@@ -213,6 +213,7 @@
+ 	-I$(top_srcdir)/rpmio \
+ 	-I$(top_srcdir)/beecrypt \
+ 	-I$(top_srcdir)/popt \
++	-I$(top_srcdir)/misc \
+ 	@WITH_LIBELF_INCLUDE@ \
+ 	@INCPATH@
+ 
Index: trunk/dports/sysutils/rpm41/files/patch-rpmdb-rpmdbc.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmdb-rpmdbc.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmdb-rpmdbc.diff	(revision 3916)
@@ -0,0 +1,12 @@
+--- rpmdb/rpmdb.c.orig	Sun Nov  9 11:51:23 2003
++++ rpmdb/rpmdb.c	Sun Nov  9 11:54:34 2003
+@@ -54,6 +54,9 @@
+ /*@unchecked@*/
+ static int _db_filter_dups = 0;
+ 
++FDIO_t fadio;
++const char *program_name;
++
+ #define	_DBI_FLAGS	0
+ #define	_DBI_PERMS	0644
+ #define	_DBI_MAJOR	-1
Index: trunk/dports/sysutils/rpm41/files/patch-rpmheader.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmheader.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmheader.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- tools/rpmheader.c    Sun Jun 17 13:40:16 2001
++++ ../rpm-4.0.4/tools/rpmheader.c Thu Jul 11 13:00:51 2002
+@@ -7,6 +7,8 @@
+ #include "signature.h"
+ #include "debug.h"
+ 
++const char *program_name;
++
+ int main(int argc, char **argv)
+ {
+     FD_t fdi, fdo;
Index: trunk/dports/sysutils/rpm41/files/patch-rpmio-Makefile-in.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmio-Makefile-in.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmio-Makefile-in.diff	(revision 3916)
@@ -0,0 +1,10 @@
+--- rpmio/Makefile.in.orig	Sat Nov  8 20:14:12 2003
++++ rpmio/Makefile.in	Sat Nov  8 20:14:48 2003
+@@ -214,6 +214,7 @@
+ INCLUDES = -I. \
+ 	-I$(top_srcdir) \
+ 	-I$(top_srcdir)/popt \
++	-I$(top_srcdir)/misc \
+ 	@INCPATH@
+ 
+ 
Index: trunk/dports/sysutils/rpm41/files/patch-rpmioc.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmioc.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmioc.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- rpmio/rpmio.c.orig	Fri Feb 28 08:25:29 2003
++++ rpmio/rpmio.c	Sat Nov  8 18:47:14 2003
+@@ -509,7 +509,7 @@
+ FDIO_t fdio = /*@-compmempass@*/ &fdio_s /*@=compmempass@*/ ;
+ 
+ /*@-redef@*/	/* see lib/falloc.c */
+-FDIO_t fadio;	/* XXX usually NULL, filled in when linked with rpm */
++extern FDIO_t fadio;	/* XXX usually NULL, filled in when linked with rpm */
+ /*@=redef@*/
+ 
+ int fdWritable(FD_t fd, int secs)
Index: trunk/dports/sysutils/rpm41/files/patch-rpmioh.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmioh.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmioh.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- ../rpm-4.0.4/rpmio/rpmio.h	Mon Jan 21 08:45:02 2002
++++ ./rpmio/rpmio.h	Fri Feb 21 02:37:40 2003
+@@ -10,7 +10,7 @@
+ #include <sys/stat.h>
+ #include <dirent.h>
+ /*@-noparams@*/
+-#include <glob.h>
++#include "glob.h"
+ /*@=noparams@*/
+ #include <stdio.h>
+ #include <stdlib.h>
Index: trunk/dports/sysutils/rpm41/files/patch-rpmlead.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmlead.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmlead.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- tools/rpmlead.c      Sun Jun 17 13:40:32 2001
++++ ../rpm-4.0.4/tools/rpmlead.c   Thu Jul 11 13:01:29 2002
+@@ -6,6 +6,8 @@
+ #include "rpmlead.h"
+ #include "debug.h"
+ 
++const char *program_name;
++
+ int main(int argc, char **argv)
+ {
+     FD_t fdi, fdo;
Index: trunk/dports/sysutils/rpm41/files/patch-rpmqv.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmqv.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmqv.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- rpmqv.c.orig	Tue Mar  4 07:32:57 2003
++++ rpmqv.c	Sat Nov  8 18:55:48 2003
+@@ -151,6 +151,8 @@
+ 	poptPrintUsage(con, fp, flags);
+ }
+ 
++const char *program_name;
++
+ /*@-bounds@*/ /* LCL: segfault */
+ /*@-mods@*/ /* FIX: shrug */
+ #if !defined(__GLIBC__) && !defined(__LCLINT__)
Index: trunk/dports/sysutils/rpm41/files/patch-rpmrc-in.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmrc-in.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmrc-in.diff	(revision 3916)
@@ -0,0 +1,53 @@
+--- rpmrc.in.orig	Sat May 31 14:04:27 2003
++++ rpmrc.in	Sat May 31 14:05:28 2003
+@@ -11,6 +11,8 @@
+ #############################################################
+ # Values for RPM_OPT_FLAGS for various platforms
+ 
++optflags: fat -O2
++
+ # XXX this is the i386 optflags that rpm has traditionally used in the past.
+ #optflags: i386 -O2 -m486 -fno-strength-reduce
+ optflags: i386 -O2 -march=i386 -mcpu=i686
+@@ -209,7 +211,7 @@
+ arch_compat: i686: i586
+ arch_compat: i586: i486
+ arch_compat: i486: i386
+-arch_compat: i386: noarch
++arch_compat: i386: noarch fat
+ 
+ arch_compat: osfmach3_i686: i686 osfmach3_i586
+ arch_compat: osfmach3_i586: i586 osfmach3_i486
+@@ -223,7 +225,7 @@
+ arch_compat: ppcpseries: ppc
+ arch_compat: ppc64: ppc
+ arch_compat: ppc: rs6000
+-arch_compat: rs6000: noarch
++arch_compat: rs6000: noarch fat
+ 
+ arch_compat: sun4c: sparc
+ arch_compat: sun4d: sparc
+@@ -293,7 +295,7 @@
+ buildarch_compat: i686: i586
+ buildarch_compat: i586: i486
+ buildarch_compat: i486: i386
+-buildarch_compat: i386: noarch
++buildarch_compat: i386: noarch fat
+ 
+ buildarch_compat: sun4c: noarch
+ buildarch_compat: sun4d: noarch
+@@ -312,10 +314,10 @@
+ 
+ buildarch_compat: m68k: noarch
+ 
+-buildarch_compat: ppciseries: noarch
+-buildarch_compat: ppcpseries: noarch
+-buildarch_compat: ppc: noarch
+-buildarch_compat: ppc64: noarch
++buildarch_compat: ppciseries: noarch fat
++buildarch_compat: ppcpseries: noarch fat
++buildarch_compat: ppc: noarch fat
++buildarch_compat: ppc64: noarch fat
+ 
+ buildarch_compat: mips: noarch
+ buildarch_compat: mipsel: noarch
Index: trunk/dports/sysutils/rpm41/files/patch-rpmrc.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmrc.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmrc.diff	(revision 3916)
@@ -0,0 +1,16 @@
+--- lib/rpmrc.c.orig	Fri Feb 21 20:21:37 2003
++++ lib/rpmrc.c	Fri Feb 21 20:21:58 2003
+@@ -960,6 +960,13 @@
+ 	    strcpy(un.machine, __power_pc() ? "ppc" : "rs6000");
+ 	    sprintf(un.sysname,"aix%s.%s", un.version, un.release);
+ 	}
++	else if(!strcmp(un.sysname, "Darwin")) {
++#ifdef __ppc__
++	  strcpy(un.machine, "ppc");
++#else ifdef __i386__
++	  strcpy(un.machine, "i386");
++#endif
++	}
+ 	else if (!strcmp(un.sysname, "SunOS")) {
+ 	    if (!strncmp(un.release,"4", 1)) /* SunOS 4.x */ {
+ 		int fd;
Index: trunk/dports/sysutils/rpm41/files/patch-rpmrpc.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmrpc.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmrpc.diff	(revision 3916)
@@ -0,0 +1,21 @@
+--- rpmio/rpmrpc.c.orig	Sat Nov  8 20:58:20 2003
++++ rpmio/rpmrpc.c	Sat Nov  8 22:15:26 2003
+@@ -1102,7 +1102,7 @@
+ # define DT_WHT		14
+ typedef struct __dirstream *	FTPDIR;
+ #else
+-typedef DIR *			FTPDIR;
++typedef struct __dirstream *	FTPDIR;
+ #endif
+ 
+ /*@unchecked@*/
+@@ -1287,7 +1287,9 @@
+     dp->d_reclen = 0;		/* W2DO? */
+ 
+ #if !defined(hpux) && !defined(sun)
++#if 0
+     dp->d_off = 0;		/* W2DO? */
++#endif
+ /*@-boundsread@*/
+     dp->d_type = dt[i];
+ /*@=boundsread@*/
Index: trunk/dports/sysutils/rpm41/files/patch-rpmsignature.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-rpmsignature.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-rpmsignature.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- tools/rpmsignature.c Sun Jun 17 13:40:44 2001
++++ ../rpm-4.0.4/tools/rpmsignature.c      Thu Jul 11 13:01:52 2002
+@@ -6,6 +6,8 @@
+ #include "signature.h"
+ #include "debug.h"
+ 
++const char *program_name;
++
+ int main(int argc, char **argv)
+ {
+     FD_t fdi, fdo;
Index: trunk/dports/sysutils/rpm41/files/patch-systemh.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-systemh.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-systemh.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- system.h.orig	Sat Mar  1 11:53:08 2003
++++ system.h	Sat Nov  8 18:57:32 2003
+@@ -352,7 +352,7 @@
+   }
+ #endif
+ /*@unchecked@*/
+-const char *__progname;
++extern const char *__progname;
+ 
+ #if HAVE_NETDB_H
+ #include <netdb.h>
Index: trunk/dports/sysutils/rpm41/files/patch-tools-Makefile-in.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-tools-Makefile-in.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-tools-Makefile-in.diff	(revision 3916)
@@ -0,0 +1,11 @@
+--- tools/Makefile.in.orig	Sun Nov  9 19:50:23 2003
++++ tools/Makefile.in	Sun Nov  9 19:50:58 2003
+@@ -273,7 +273,7 @@
+ noinst_PROGRAMS = convertdb1$(EXEEXT) dump$(EXEEXT) dumpdb$(EXEEXT) \
+ 	rpmarchive$(EXEEXT) rpmheader$(EXEEXT) rpmlead$(EXEEXT) \
+ 	rpmsignature$(EXEEXT)
+-pkgbin_PROGRAMS = debugedit$(EXEEXT) javadeps$(EXEEXT) rpmcache$(EXEEXT) \
++pkgbin_PROGRAMS = javadeps$(EXEEXT) rpmcache$(EXEEXT) \
+ 	rpmdeps$(EXEEXT) rpmfile$(EXEEXT)
+ PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) $(pkgbin_PROGRAMS)
+ 
Index: trunk/dports/sysutils/rpm41/files/patch-tools-rpmfile.diff
===================================================================
--- trunk/dports/sysutils/rpm41/files/patch-tools-rpmfile.diff	(revision 3916)
+++ trunk/dports/sysutils/rpm41/files/patch-tools-rpmfile.diff	(revision 3916)
@@ -0,0 +1,21 @@
+--- tools/rpmfile.c.orig	Sun Nov  9 20:27:19 2003
++++ tools/rpmfile.c	Sun Nov  9 20:27:46 2003
+@@ -30,6 +30,8 @@
+ #include "patchlevel.h"
+ #include "debug.h"
+ 
++#include "rpmio.h"
++
+ FILE_RCSID("@(#)Id: file.c,v 1.66 2002/07/03 19:00:41 christos Exp ")
+ 
+ /*@access fmagic @*/
+@@ -52,6 +54,9 @@
+ 			/* Global command-line options 		*/
+ /*@unchecked@*/
+ static	int	nobuffer = 0;   /* Do not buffer stdout */
++
++FDIO_t fadio;
++const char *program_name;
+ 
+ /*
+  * unwrap -- read a file of filenames, do each one.
