### this file is sourced not run
PKGVER=2.3.3
PKGBUILD=1
PKGARCH=x86_64

# source: post BLFS 8.3 2018-10-16
TARBALL=dovecot-$PKGVER.tar.gz
MD5SUM=fd58476e01785f22d1b4ee56be0006f9
SRC_URL=http://www.dovecot.org/releases/2.3/$TARBALL
BUNDLE=

SLACKREQ='sqlite3 libclucene openssl' # gnutls if we configure it
SLACKDESC="dovecot: dovecot $PKGVER (IMAP/POP3 server)  
dovecot:  
dovecot: Dovecot is an Internet Message Access Protocol (IMAP) and Post Office 
dovecot: Protocol (POP) server, written primarily with security in mind. 
dovecot: Dovecot aims to be lightweight, fast and easy to set up as well as 
dovecot: highly configurable and easily extensible with plugins.  
dovecot: 
dovecot: https://dovecot.org/
dovecot: 
dovecot: 
dovecot:
"
SLACKSUG='postgresql'
SLACKINSTALL='
! grep -q dovecot  ./etc/passwd && echo "dovecot:x:42:42:Dovecot unprivileged user,,,:/dev/null:/bin/false" >> ./etc/passwd
! grep -q dovecot  ./etc/group  && echo "dovecot:x:42" >> ./etc/group
! grep -q dovenull ./etc/passwd && echo "dovenull:x:43:43:Dovecot login user,,,:/dev/null:/bin/false" >> ./etc/passwd
! grep -q dovenull ./etc/group  && echo "dovenull:x:43" >> ./etc/group
'

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	# create users - must be the same as the ones specified in SLACKINSTALL
	{	echo "cd /"
		echo "$SLACKINSTALL"
	} > /tmp/create-user &&
	sh /tmp/create-user

	# BLFS patch to avoid segfault in testing
	cd /tmp/dovecot* &&
	sed -e "s;#include <unistd.h>;&\n#include <crypt.h>;" \
		-i src/auth/mycrypt.c &&

    export ICU_DATA=/usr/share/icu/current/ && # so ICU knows where its data is
	CONFFLAGS="$CONFFLAGS \
		--docdir=/usr/share/doc/dovecot-$PKGVER \
		--disable-static  \
		--with-sqlite     \
		--with-cu         \
		--with-pgsql      \
		--with-lucene" &&
	# --without-icu     # probably faster without icu
	# --with-ssl=gnutls # gnutls is currently broken unfortunately
	# --with-mysql 
	pkg_build_autoconf &&
	pkg_build_slackdesc &&
	
	rm -f /etc/passwd /etc/group
}


