Index: trunk/dports/sysutils/rpm/Portfile
===================================================================
--- trunk/dports/sysutils/rpm/Portfile	(revision 2137)
+++ trunk/dports/sysutils/rpm/Portfile	(revision 2137)
@@ -0,0 +1,39 @@
+PortSystem 1.0
+name			rpm
+version			4.0.4
+platforms		darwin
+categories		sysutils archivers
+maintainers		ssen@opendarwin.org
+description		RedHat Package Manager
+
+master_sites		ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/
+checksums		md5 b0c3093d2f0d850760e59ac1db9bf152
+
+depends_lib		lib:libbz2.1.0:bzip2 lib:libiconv.2:libiconv
+
+configure.args		--disable-nls --with-included-gettext --with-glob --with-libiconv-prefix=${prefix}
+
+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
+
+	configure.args-append --disable-optimized --disable-aio \
+		--without-python
+
+	configure.env   LDFLAGS="-L${prefix}/lib -L${workpath}/librt" CFLAGS="-I${prefix}/include -no-cpp-precomp" CC="gcc -flat_namespace"
+
+	pre-build {
+	        system "mkdir -p ${workpath}/librt"
+		system "ln -sf /usr/lib/libSystem.B.dylib \
+				${workpath}/librt/librt.dylib"
+	}
+
+}
+
Index: trunk/dports/sysutils/rpm/files/patch-db3-configure.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-db3-configure.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-db3-configure.diff	(revision 2137)
@@ -0,0 +1,11 @@
+--- ../rpm-4.0.4/db3/configure	Fri Jul 27 12:20:43 2001
++++ ./db3/configure	Fri Feb 21 02:33:38 2003
+@@ -18,7 +18,7 @@
+ cat Makefile.orig | sed -e 's/ -g$/ -g -O2/' -e '/^install:/c\
+ .PHONY: listobjs\
+ listobjs:\
+-	@echo $(OBJS) $(C_OBJS) \
++\	@echo $(OBJS) $(C_OBJS) \
+ \
+ distdir install check:\
+ \
Index: trunk/dports/sysutils/rpm/files/patch-dump.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-dump.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-dump.diff	(revision 2137)
@@ -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/rpm/files/patch-dumpdb.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-dumpdb.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-dumpdb.diff	(revision 2137)
@@ -0,0 +1,11 @@
+--- tools/dumpdb.c       Sun Jun 17 13:47:35 2001
++++ ../rpm-4.0.4/tools/dumpdb.c    Thu Jul 11 12:59:58 2002
+@@ -4,6 +4,8 @@
+ #include "header_internal.h"
+ #include "debug.h"
+ 
++const char *program_name;
++
+ int main(int argc, char ** argv)
+ {
+     unsigned int dspBlockNum = 0;              /* default to all */
Index: trunk/dports/sysutils/rpm/files/patch-lib-signature.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-lib-signature.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-lib-signature.diff	(revision 2137)
@@ -0,0 +1,11 @@
+--- ../rpm-4.0.4/lib/signature.c	Sat Feb  2 15:55:49 2002
++++ ./lib/signature.c	Fri Feb 21 15:24:40 2003
+@@ -23,6 +23,8 @@
+ #include "signature.h"
+ #include "debug.h"
+ 
++extern char **environ;
++
+ /*@access Header@*/		/* XXX compared with NULL */
+ /*@access FD_t@*/		/* XXX compared with NULL */
+ 
Index: trunk/dports/sysutils/rpm/files/patch-macros-in.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-macros-in.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-macros-in.diff	(revision 2137)
@@ -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/rpm/files/patch-rpm2cpio.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-rpm2cpio.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-rpm2cpio.diff	(revision 2137)
@@ -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/rpm/files/patch-rpmarchive.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-rpmarchive.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-rpmarchive.diff	(revision 2137)
@@ -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/rpm/files/patch-rpmheader.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-rpmheader.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-rpmheader.diff	(revision 2137)
@@ -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/rpm/files/patch-rpmioc.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-rpmioc.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-rpmioc.diff	(revision 2137)
@@ -0,0 +1,11 @@
+--- ../rpm-4.0.4/rpmio/rpmio.c	Wed Feb 13 17:55:23 2002
++++ ./rpmio/rpmio.c	Fri Feb 21 15:59:22 2003
+@@ -521,8 +521,8 @@
+ 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/rpm/files/patch-rpmioh.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-rpmioh.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-rpmioh.diff	(revision 2137)
@@ -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/rpm/files/patch-rpmlead.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-rpmlead.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-rpmlead.diff	(revision 2137)
@@ -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/rpm/files/patch-rpmqv.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-rpmqv.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-rpmqv.diff	(revision 2137)
@@ -0,0 +1,11 @@
+--- rpmqv.c      Sun Feb  3 14:32:48 2002
++++ ../rpm-4.0.4/rpmqv.c   Thu Jul 11 13:06:03 2002
+@@ -281,6 +281,8 @@
+ 
+ }
+ 
++const char *program_name;
++
+ int main(int argc, const char ** argv)
+ {
+     enum modes bigMode = MODE_UNKNOWN;
Index: trunk/dports/sysutils/rpm/files/patch-rpmrc.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-rpmrc.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-rpmrc.diff	(revision 2137)
@@ -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/rpm/files/patch-rpmsignature.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-rpmsignature.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-rpmsignature.diff	(revision 2137)
@@ -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/rpm/files/patch-systemh.diff
===================================================================
--- trunk/dports/sysutils/rpm/files/patch-systemh.diff	(revision 2137)
+++ trunk/dports/sysutils/rpm/files/patch-systemh.diff	(revision 2137)
@@ -0,0 +1,11 @@
+--- ../rpm-4.0.4/system.h	Sun Jan 20 16:41:42 2002
++++ ./system.h	Fri Feb 21 13:31:05 2003
+@@ -333,7 +333,7 @@
+     else __progname = pn;		\
+   }
+ #endif
+-const char *__progname;
++extern const char *__progname;
+ 
+ #if HAVE_NETDB_H
+ #include <netdb.h>
