# $Id$ PNAME="openldap" PVER="2.4.52" PBUILD="r2" SPLIT_PACKAGES="libldap libldap-dev openldap" PCAT="net-nds" HOMEPAGE="http://www.openldap.org/" # enable features or not (0|1) ENABLE_SASL=0 ENABLE_TCPWRAPPERS=0 LIB_DEPEND=">= dev-libs/openssl-1.1" if [[ ${ENABLE_SASL} = 1 ]] then LIB_DEPEND="${LIB_DEPEND} >= dev-libs/cyrus-sasl-2.1.26" fi if [[ ${ENABLE_TCPWRAPPERS} = 1 ]] then LIB_DEPEND="${LIB_DEPEND} >= sys-apps/tcp-wrappers-7" fi # requires libltdl.so.7 from libtool package LDAP_DEPEND=">= dev-db/db-6.2 >= sys-libs/libuuid-2.34 >= sys-libs/libltdl-2.4" SDEPEND="${LIB_DEPEND} ${LDAP_DEPEND} >= sys-apps/util-linux-2.34 >= sys-dev/libtool-2.4" SRCFILE="${PNAME}-${PVER}.tgz" SRCDIR="${BUILDDIR}/${PNAME}-${PVER}" sminclude multilib mtools systemd rpath msetfeature "!check" SRC_URI=( http://www.openldap.org/software/download/OpenLDAP/openldap-release/${SRCFILE} mirror://${PNAME}/${SRCFILE} mirror://${PNAME}/slapd.service mirror://${PNAME}/slapd.confd mirror://${PNAME}/slapd.tmpfile ) UP2DATE="updatecmd http://www.openldap.org/software/download/ | grep 'currently avail' | sed 's/.*OpenLDAP-\(.*\)\ is.*/\1/'" split_info_libldap() { DESCRIPTION="Lightweight Directory Access Protocol client libraries." DEPEND="${LIB_DEPEND}" } split_info_openldap() { DESCRIPTION="OpenLDAP is an open source implementation of the Lightweight Directory Access Protocol." DEPEND="== net-nds/libldap-${PVER} ${LDAP_DEPEND}" } pkg_setup() { preinstall_openldap } src_prepare() { munpack ${SRCFILE} || die local abi for abi in ${MULTILIB_ABIS} do cd ${SRCDIR}-${abi} # fix localstate dir to /run/openldap sed -i 's:#define LDAPI_SOCK LDAP_RUNDIR LDAP_DIRSEP "run" LDAP_DIRSEP "ldapi":#define LDAPI_SOCK LDAP_DIRSEP "run" LDAP_DIRSEP "openldap" LDAP_DIRSEP "ldapi":' include/ldap_defaults.h || die sed -i 's:%LOCALSTATEDIR%/run:/run/openldap:' servers/slapd/slapd.conf || die sed -i 's:-$(MKDIR) $(DESTDIR)$(localstatedir)/run:-$(MKDIR) $(DESTDIR)/run/openldap:' servers/slapd/Makefile.in || die # remove db version limits sed -i '/6.0.20/ a\\t__db_version_compat' build/openldap.m4 || die # non standard, autoreconf doesn't work libtoolize --force || die aclocal || die autoconf --force || die done } src_compile() { local myconf if [[ ${ENABLE_SASL} = 1 ]] then # enable sasl myconf+=" --with-cyrus-sasl" else # disable sasl myconf+=" --without-cyrus-sasl" fi if [[ ${ENABLE_TCPWRAPPERS} = 1 ]] then # enable tcp-wrappers myconf+=" --enable-wrappers" else # disable tcp-wrappers myconf+=" --disable-wrappers" fi # use mdb as default db, drop berkeley db support mconfigure \ --localstatedir=/var/lib/openldap \ --libexecdir=/usr/$(mlibdir)/openldap \ --enable-overlays=mod \ --enable-modules=yes \ ${myconf} \ || die mmake || die } src_install_libldap() { mmake -j1 -C libraries DESTDIR=${BINDIR} install || die } src_install_libldap-dev() { mmake -j1 -C include DESTDIR=${BINDIR} install || die mmake -j1 -C doc/man/man3 DESTDIR=${BINDIR} install || die # install ldap.conf man cp doc/man/man5/ldap.conf.5.tmp ldap.conf.5 || die minstallman ldap.conf.5 || die minstalldocs COPYRIGHT LICENSE || die } src_install_openldap() { mmake -j1 -C clients DESTDIR=${BINDIR} install || die mmake -j1 -C servers DESTDIR=${BINDIR} install || die mmake -j1 -C doc/man/man1 DESTDIR=${BINDIR} install || die mmake -j1 -C doc/man/man5 DESTDIR=${BINDIR} install || die mmake -j1 -C doc/man/man8 DESTDIR=${BINDIR} install || die # missing symlink mlink ../$(mlibdir)/openldap/slapd /usr/sbin/slapd || die # remove ldap.conf man, which is in the lib package mdelete /usr/share/man/man5/ldap.conf.5 || die # create runtime mkeepdir /var/lib/openldap || die mchown ldap:ldap /var/lib/openldap || die mchmod 0700 /var/lib/openldap || die # openldap modules dir mkeepdir /usr/$(mlibdir)/openldap/openldap || die # service minstallunit slapd.service || die minstallconf slapd.confd slapd || die minstalltmp slapd.tmpfile slapd.conf || die # remove insecure rpath mdeleterpath || die minstalldocs ANNOUNCEMENT CHANGES COPYRIGHT LICENSE || die } preinstall_openldap() { # adding ldap user mgroupadd -o "-g 439" ldap museradd -o "-u 439 -g ldap -d /var/lib/openldap -s /bin/false" ldap } postinstall_openldap() { mstartunit slapd.service } postremove_openldap() { mstopunit slapd.service }