description="Lightweight Directory Access Protocol (LDAP) client and server"
url="http://www.openldap.org"

packager="spiky <spiky@nutyx.org>"
contributors="Pierre,Tnut"

makedepends=(autoconf m4)

name=openldap
version=2.6.8
runyx_version=20201011

source=(http://downloads.tuxfamily.org/nutyx/files/runyx-${runyx_version}.tar.xz
	https://www.openldap.org/software/download/OpenLDAP/openldap-release/$name-$version.tgz
	$name-$version-consolidated-1.patch)
prepare() {

(getent group  ldap > /dev/null) || groupadd -g 83 ldap
(getent passwd ldap > /dev/null) || useradd  -c "OpenLDAP Daemon Owner" \
         -d /var/lib/openldap -u 83 \
         -g ldap -s /bin/false ldap
cd $name-$version
patch -Np1 -i ../$name-$version-consolidated-1.patch
autoconf
}
build() {
cd $name-$version

./configure --prefix=/usr \
            --sysconfdir=/etc \
            --disable-static \
            --enable-dynamic \
            --disable-debug \
            --disable-slapd
make depend
make
make DESTDIR=$PKG install

rm $PKG/usr/lib/liblber.la

# Service
cd ../runyx-${runyx_version}
make DESTDIR=$PKG install-sysv-slapd
make DESTDIR=$PKG install-runyx-slapd
make DESTDIR=$PKG install-sysd-slapd
}
service() {
cd $PKG
bsdtar -cf \
$PKGMK_PACKAGE_DIR/$name.service${PKGMK_BUILDVER}${PKGMK_ARCH}.cards.tar \
lib/{systemd,init} etc/{init,rc.d}

rm -r etc/{rc.d,init}
rm -r lib/{init,systemd}
}
