Index: trunk/dports/databases/postgresql8/Portfile
===================================================================
--- trunk/dports/databases/postgresql8/Portfile	(revision 14691)
+++ trunk/dports/databases/postgresql8/Portfile	(revision 14692)
@@ -1,3 +1,3 @@
-# $Id: Portfile,v 1.25 2005/10/05 13:33:11 mww Exp $
+# $Id: Portfile,v 1.26 2005/10/18 19:09:51 mww Exp $
 
 PortSystem 1.0
@@ -5,4 +5,5 @@
 name			postgresql8
 version			8.0.4
+revision		1
 categories		databases
 platforms		darwin
@@ -13,19 +14,27 @@
 				subselects, and user-defined types and functions. Write-ahead \
 				logging means increased performance while retaining data \
-				integrity.
+				integrity. Includes support for postgis.
 
 homepage		http://www.postgresql.org/
 master_sites	postgresql:source/v${version} \
-				ftp://ftp.postgresql.org/pub/source/v${version}/
+				ftp://ftp.postgresql.org/pub/source/v${version}/ \
+				http://postgis.refractions.net/download/:postgis
 set dbase		postgresql-base-${version}.tar.bz2
 set dopt		postgresql-opt-${version}.tar.bz2
 set dtest		postgresql-test-${version}.tar.bz2
-distfiles		${dbase} ${dopt} ${dtest}
+set postgis		postgis-1.0.4.tar.gz
+distfiles		${dbase} ${dopt} ${dtest} ${postgis}:postgis
 
 checksums		${dbase} md5 ece2604b7bc6c4c460d34113b1542725 \
 				${dopt} md5 27b8817f6ad1b81b55cdc8da55ed8295 \
-				${dtest} md5 2db4d072a359b5f62de96c10022ab8b8
-patchfiles		patch-PostgreSQL.darwin
+				${dtest} md5 2db4d072a359b5f62de96c10022ab8b8 \
+				${postgis} md5 b5a260c9ffdc663665b991f8016b7b85
 use_bzip2		yes
+extract.only	${dbase} ${dopt} ${dtest}
+post-extract {
+	set con		${worksrcpath}/contrib
+	system "cd ${con} && gunzip -dc ${distpath}/${postgis} | gnutar --no-same-owner -xf -"
+	file rename ${con}/postgis-1.0.4 ${con}/postgis
+}
 
 depends_lib		port:readline \
@@ -64,16 +73,20 @@
 
 set dbdir		${prefix}/var/db/pgsql8/defaultdb
-set contribs	"pg_autovacuum tsearch2"
+set logdir		${prefix}/var/log/pgsql8
+set dbuser		postgres8
+set dbgrp		postgres
+set contribs	"pg_autovacuum postgis tsearch2"
 
 post-build {
-	foreach contrib { ${contribs} } {
-		system "cd ${worksrcpath}/contrib/${contrib} && ${build.cmd}"
+	foreach contrib ${contribs} {
+		system "cd ${worksrcpath}/contrib/${contrib}/ && ${build.cmd}"
 	}
 }
 
 post-destroot {
-	foreach contrib { ${contribs} } {
-		system "cd ${worksrcpath}/contrib/${contrib} && \
-			${build.cmd} install ${destroot.destdir}"
+	foreach contrib ${contribs} {
+		system "echo contrib: \"${contrib}\""
+		system "cd ${worksrcpath}/contrib/${contrib}/ && \
+			${build.cmd} install ${destroot.destdir} && touch DONE"
 	}
 	system "cd ${destroot}${prefix}/bin && ln -sf ${libdir}/bin/psql psql8"
@@ -87,18 +100,26 @@
 }
 
+platform darwin 8 {
+	configure.env-append	CC=/usr/bin/gcc-4.0 CPP=/usr/bin/cpp-4.0 CXX=/usr/bin/g++-4.0
+}
+
 variant server {
+	startupitem.create	yes
+	startupitem.init	\
+"PGCTL=${libdir}/bin/pg_ctl"
+	startupitem.start	\
+"su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL8DATA:=${dbdir}} start -l ${logdir}/postgres.log\""
+	startupitem.stop	\
+"su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL8DATA:=${dbdir}} stop -s -m fast\""
+
 	pre-destroot {
-		set startupdir ${destroot}/Library/StartupItems/PostgreSQL8
-		set contrib ${worksrcpath}/contrib/start-scripts
-		xinstall -m 755 -d ${startupdir}
-		xinstall -m 755 ${contrib}/PostgreSQL.darwin ${startupdir}/PostgreSQL8
-		xinstall -m 644 ${contrib}/StartupParameters.plist.darwin \
-			${startupdir}/StartupParameters.plist
-		reinplace "s|__PREFIX__|${prefix}|g" ${startupdir}/PostgreSQL8
-		addgroup postgres
-		set gid [existsgroup postgres]
-		adduser postgres8 shell=/bin/sh gid=${gid} \
+		addgroup ${dbgrp}
+		set gid [existsgroup ${dbgrp}]
+		adduser ${dbuser} shell=/bin/sh gid=${gid} \
 			home=${prefix}/var/db/pgsql8 \
 			realname=PostgreSQL-8\ Server
+		xinstall -m 755 -d ${destroot}${logdir}
+		system "touch ${destroot}${logdir}/postgres.log"
+		system "chown ${dbuser}:${dbgrp} ${destroot}${logdir}/postgres.log"
 	}
 
@@ -106,9 +127,13 @@
 		ui_msg "\nTo create a database instance, after install do\n\
 			sudo mkdir -p ${dbdir}\n\
-			sudo chown postgres8:postgre ${dbdir}\n\
-			sudo su postgres8 -c \'${libdir}/bin/initdb -D ${dbdir}\'"
+			sudo chown ${dbuser}:postgre ${dbdir}\n\
+			sudo su ${dbuser} -c \'${libdir}/bin/initdb -D ${dbdir}\'"
 		ui_msg "\nTo activate the PostgreSQL8 server, add\n\
 			POSTGRESQL8=-YES-\n\
-			to your ${prefix}/etc/rc.local"
+			to your ${prefix}/etc/rc.conf"
+		ui_msg "\nTo change the location of your database, add\n\
+			POSTGRESQL8DATA=/location\n\
+			to your ${prefix}/etc/rc.conf"
 	}
 }
+
