#!/bin/sh
#
# Copyright 2004 Dagmar d'Surreal <rivyqntzne@tznvy.pbz>
# Copyright 2005, 2006 Scott Harmon
# Available under the terms of the GNU GPL.
#

NAME="postgresql"
VERSION="8.4.2"
REVISION="1"

PKG_SOURCEURL='http://ftp2.it.postgresql.org/mirrors/postgres/source/v$VERSION/$NAME-$VERSION.tar.bz2'

PKG_PATCH[0]="rc.postgresql.new"
PKG_PATCH[1]="postgresql.logrotate"
PKG_PATCH[2]="doinst.sh"

. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh

cflags
cxxflags
prepare
analyzesource

configure --prefix=/usr \
          --mandir=/usr/man \
          --with-tcl \
          --with-perl \
          --with-python \
          --with-ldap \
          --with-openssl \
          --with-xml \
          --enable-nls 

make
makeinstall

# Firstly we create the dir where the data will be hold, and change the ownership.
createdir $PKG_STAGEROOT/var/lib/pgsql/data
spewdo "chown -R postgres:postgres $PKG_STAGEROOT/var/lib/pgsql"
spewdo "chmod 700 $PKG_STAGEROOT/var/lib/pgsql"
spewdo "chmod 700 $PKG_STAGEROOT/var/lib/pgsql/data"

createdir $PKG_STAGEROOT$PKG_SYSCONFDIR/rc.d
findpatch initscript rc.postgresql.new
sysvinitsetup $initscript 345 55

createdir $PKG_STAGEROOT$PKG_SYSCONFDIR/logrotate.d
findpatch logrotate postgresql.logrotate
spewdo "cp $logrotate $PKG_STAGEROOT/etc/logrotate.d/postgresql.new"

tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup
