# vim: set syn=sh et ai sw=2 st=2 ts=2 tw=0:
#Packager: JRD <jrd@enialis.net>

pkgname=postgresql
pkgver=9.2.2
pkgrel=1rl
source=(http://ftp.postgresql.org/pub/source/v${pkgver}/${pkgname}-${pkgver}.tar.bz2 postgresd.conf install-script.sh rc.postgresd)
sourcetemplate=http://people.salixos.org/jrd/salix/$pkgname/$pkgver-\$arch-$pkgrel/
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo")
url=http://www.postgresql.org/
options=("noautodotnew")
dotnew=("etc/postgresd.conf")

doinst() {
  # keep exec rights (or not) on the /etc/rc.d/rc.postresd service
  if [ -e etc/rc.d/rc.postgresd ] && [ ! -x etc/rc.d/rc.postgresd ]; then
    chmod -x etc/rc.d/rc.postgresd.new
  fi
  mv etc/rc.d/rc.postgresd.new etc/rc.d/rc.postgresd
}

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (open source database system)"
"It has more than 15 years of active development and a proven"
"architecture that has earned it a strong reputation for reliability,"
"data integrity, and correctness. It is fully ACID compliant, has full"
"support for foreign keys, joins, views, triggers, and stored"
"procedures (in multiple languages). It includes most SQL:2008 data"
"types and supports storage of BLOB, including pictures, sounds, or"
"video."
"GSSAPI AND Kerberos auth are not available."
"See /usr/doc/$pkgname-$pkgver/install-script.sh"
)

build() {
  cd $SRC/$pkgname-$pkgver || return 1
  ./configure \
    --prefix=/usr \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --localstatedir=/var \
    --sysconfdir=/etc \
    --build=$arch-slackware-linux \
    --with-tcl \
    --with-perl \
    --with-python \
    --with-ldap \
    --with-openssl \
    --with-libxml \
    --with-libxslt \
    --enable-thread-safety \
    || return 1
  make -j $numjobs || return 1
  make install DESTDIR=$PKG || return 1
  mkdir -p $PKG/usr/doc/$pkgname-$pkgver $PKG/etc/rc.d
  cp $SRC/install-script.sh $PKG/usr/doc/$pkgname-$pkgver/
  cp $SRC/postgresd.conf $PKG/etc/
  cp $SRC/rc.postgresd $PKG/etc/rc.d/rc.postgresd.new
  chmod +x $PKG/usr/doc/$pkgname-$pkgver/install-script.sh $PKG/etc/rc.d/rc.postgresd.new
}