#Maintainer: Thorsten Muehlfelder <thenktor(at)gmx.de>

pkgname=dovecot
pkgver=1.2.16
pkgrel=1tm
source=("http://www.dovecot.org/releases/1.2/dovecot-$pkgver.tar.gz" "rc.dovecot" "README.Slackware" "config-helper.sh")
url="http://www.dovecot.org/"
docs=('AUTHORS' 'COPYING' 'COPYING.LGPL' 'COPYING.MIT' 'ChangeLog' 'INSTALL' 'NEWS' 'README' 'README.Slackware' 'config-helper.sh' 'TODO')
options=('noautodotnew')

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (IMAP and POP3 server)"
"Dovecot is an open source  IMAP and POP3 server for Linux/UNIX-like"
"systems, written with security primarily in mind. Dovecot is an"
"excellent choice for both small and large installations. It's fast,"
"simple to set up, requires no special administration and it uses very"
"little memory."
"Make sure you read the documentation about how to set this up,"
"especially the info about creating dovecot user and groups in"
"/usr/doc/dovecot-$pkgver/README.Slackware"
)

build() {
	cd $startdir/src/${pkgname}-${pkgver}
	./configure --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX} --localstatedir=/var \
		--sysconfdir=/etc/dovecot \
		--with-moduledir=/usr/lib${LIBDIRSUFFIX}/dovecot/modules \
		--with-db \
		--with-mysql \
		--without-pgsql \
		--with-sqlite \
		--with-libcap \
		--without-pam \
		--with-ssl=openssl \
		--with-ssldir=/etc/dovecot/ssl \
		--without-gssapi \
		--with-ldap=plugin \
		--enable-header-install \
		--without-docs \
		--disable-static
	make -j $numjobs || return 1
	make DESTDIR=$startdir/pkg/ install || return 1

	# install rc script
	install -D -m755 ../rc.dovecot $startdir/pkg/etc/rc.d/rc.dovecot.new

	# create some dirs in /var
	mkdir -p $startdir/pkg/var/run/dovecot/
	mkdir -p $startdir/pkg/var/lib/dovecot

	# create the ssl dirs
	mkdir -p $startdir/pkg/etc/dovecot/ssl/certs
	mkdir -p $startdir/pkg/etc/dovecot/ssl/private
	sed -i "s#/etc/ssl#/etc/dovecot/ssl#" $startdir/pkg/etc/dovecot/dovecot-example.conf
}

doinst() {
	if [ -r etc/rc.d/rc.dovecot -a -r etc/rc.d/rc.dovecot.new ]; then
		chmod --reference=etc/rc.d/rc.dovecot etc/rc.d/rc.dovecot.new
	fi
	mv etc/rc.d/rc.dovecot.new etc/rc.d/rc.dovecot
}