a project to simplify installation of open source software
on Mac OS X and Darwin
# $Id: Portfile 21792 2007-02-07 15:33:48Z jwa@macports.org $
PortSystem 1.0
name postgresql7
version 7.4.16
categories databases
platforms darwin
maintainers mww@macports.org jwa@macports.org
description The most advanced open-source database available anywhere
long_description PostgreSQL is Object-Relational Database Management System. \
It supports almost all SQL constructs, including transactions, \
subselects, and user-defined types and functions. Write-ahead \
logging means increased performance while retaining data \
integrity.
homepage http://www.postgresql.org/
master_sites postgresql:source/v${version}
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}
checksums ${dbase} sha1 d3f36c6ace31d3725828aa9d86f4c08f266e33e3 \
${dopt} sha1 657fe7c4ae1ba3020de4594117a1ab5db45f61bc \
${dtest} sha1 565cfcfce7aae3e09ed1ecf0d7bc573ec0d31f96
use_bzip2 yes
depends_lib port:readline \
port:openssl \
port:zlib \
port:bison
worksrcdir postgresql-${version}
set libdir ${prefix}/lib/pgsql7
configure.args --sysconfdir=${prefix}/etc/pgsql7 \
--bindir=${libdir}/bin \
--libdir=${libdir} \
--includedir=${prefix}/include/pgsql7 \
--datadir=${prefix}/share/${name} \
--mandir=${prefix}/share/man \
--docdir=${prefix}/share/doc/${name} \
--with-docdir=${prefix}/share/doc/${name} \
--with-includes=${prefix}/include \
--with-libraries=${prefix}/lib \
--with-openssl=${prefix} \
--with-rendezvous \
--with-readline \
--with-zlib \
--enable-thread-safety \
--enable-integer-datetimes \
--enable-multibyte \
--enable-unicode
configure.env CPPFLAGS="-I${prefix}/include" \
CFLAGS="-I${prefix}/include" \
LDFLAGS="-L${prefix}/lib"
build.type gnu
post-build {
# build autovacuum
system "cd ${worksrcpath}/contrib/pg_autovacuum && ${build.cmd}"
# build tsearch2
system "cd ${worksrcpath}/contrib/tsearch2 && ${build.cmd}"
}
test.run yes
test.target check
# install headers too
destroot.target-append install-all-headers
post-destroot {
# install autovacuum
xinstall -m 755 -s ${worksrcpath}/contrib/pg_autovacuum/pg_autovacuum \
${destroot}${libdir}/bin
# install tsearch2
system "cd ${worksrcpath}/contrib/tsearch2 && ${build.cmd} install ${destroot.destdir}"
# symlinks
system "cd ${destroot}${prefix}/bin && ln -sf ${libdir}/bin/psql psql7"
# nuke nonsense
system "cd ${destroot}${prefix}/share && rm -rf doc"
}
# Defaults for database
set dbdir ${prefix}/var/db/pgsql7/defaultdb
set logdir ${prefix}/var/log/pgsql7
set dbuser postgres7
set dbgrp postgres
variant perl {
configure.args-append --with-perl
depends_lib-append lib:perl:perl5.8
}
variant java {
configure.args-append --with-java
depends_build port:apache-ant
depends_lib-append bin:java:kaffe
configure.env-append ANT=${prefix}/share/java/apache-ant/bin/ant
}
variant tcltk {
configure.args-append --with-tcl \
--with-tclconfig=${prefix}/lib \
--with-tkconfig=${prefix}/lib
configure.env-append TCLSH=${prefix}/bin/tclsh
depends_lib-append port:tcl port:tk
}
variant server {
startupitem.create yes
startupitem.init \
"PGCTL=${libdir}/bin/pg_ctl"
startupitem.start \
"su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL7DATA:=${dbdir}} start -l ${logdir}/postgres.log\""
startupitem.stop \
"su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL8DATA:=${dbdir}} stop -s -m fast\""
pre-destroot {
xinstall -m 755 -d ${destroot}${dbdir} \
${destroot}${prefix}/var/log/pgsql \
${destroot}${prefix}/var/db/pgsql
# Add User postgres:postgres
addgroup ${dbuser}
set gid [existsgroup ${dbgrp}]
adduser ${dbuser} shell=/bin/sh gid=${gid} \
home=${prefix}/var/db/pgsql7 \
realname=PostgreSQL-7\ Server
}
post-destroot {
destroot.keepdirs ${destroot}${prefix}/var/db/pgsql
system "cd ${destroot}${prefix}/var/log/pgsql && \
touch pgsql.log pg_autovacuum.log"
foreach d { db/pgsql log/pgsql log/pgsql/pgsql.log log/pgsql/pg_autovacuum.log } {
file attributes ${destroot}${prefix}/var/${d} \
-group ${dbgr} -owner ${dbuser}
}
}
post-install {
ui_msg "\nTo create a database instance, after install do\n\
sudo su ${dbuser} -c \'${libdir}/bin/initdb -D ${dbdir}\'"
}
}
platform darwin 8 {
configure.env-append CC=/usr/bin/gcc-4.0 CPP=/usr/bin/cpp-4.0 CXX=/usr/bin/g++-4.0
}