From 2da7d2f141a9051c22f89e3d7c68e7215322b417 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Thu, 22 Feb 2018 20:09:18 +0000
Subject: openldap: update to 2.4.45

---
 abs/core/openldap/PKGBUILD          | 72 +++++++++++++++++++------------------
 abs/core/openldap/openldap.install  | 21 -----------
 abs/core/openldap/openldap.sysusers |  1 +
 abs/core/openldap/openldap.tmpfiles |  3 ++
 abs/core/openldap/slapd.tmpfiles    |  1 -
 5 files changed, 41 insertions(+), 57 deletions(-)
 delete mode 100644 abs/core/openldap/openldap.install
 create mode 100644 abs/core/openldap/openldap.sysusers
 create mode 100644 abs/core/openldap/openldap.tmpfiles
 delete mode 100644 abs/core/openldap/slapd.tmpfiles

diff --git a/abs/core/openldap/PKGBUILD b/abs/core/openldap/PKGBUILD
index 0131552..304224d 100644
--- a/abs/core/openldap/PKGBUILD
+++ b/abs/core/openldap/PKGBUILD
@@ -2,24 +2,25 @@
 # Maintainer:
 
 pkgbase=openldap
-pkgname=('libldap' 'openldap')
-pkgver=2.4.39
-pkgrel=1
-arch=('i686' 'x86_64')
-url="http://www.openldap.org/"
+pkgname=('openldap' 'libldap')
+pkgver=2.4.45
+pkgrel=4
+arch=('x86_64')
+url="https://www.openldap.org/"
 license=('custom')
-makedepends=('libltdl' 'libsasl' 'e2fsprogs' 'util-linux' 'chrpath')
-#options=('!makeflags')
-source=(ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/${pkgbase}-${pkgver}.tgz
-        slapd.service slapd.tmpfiles openldap-ntlm.patch)
-sha1sums=('2b8e8401214867c361f7212e7058f95118b5bd6c'
+makedepends=('libltdl' 'libsasl' 'e2fsprogs' 'util-linux' 'chrpath' 'unixodbc')
+options=('!makeflags' 'emptydirs')
+source=(https://www.openldap.org/software/download/OpenLDAP/openldap-release/${pkgbase}-${pkgver}.tgz
+        slapd.service openldap.tmpfiles openldap.sysusers openldap-ntlm.patch)
+sha1sums=('c98437385d3eaee80c9e2c09f3f0d4b7c140233d'
           '2441815efbfa01ad7a1d39068e5503b53d1d04b0'
-          '59241a813d7508294e4ef1cec3bfe1f5495e109d'
+          '1f68bd85fb50595c4e916db164d8e90e0c6e21ee'
+          '2bf64351c32b0bf0a70663bd42de22910998b795'
           'e4afd9f1c810ef4c4cd8fe1101dfe5887f2b7eef')
 
 # see http://www.openldap.org/faq/data/cache/756.html
 # there's no proper backend support for anything apart from
-# BerkeleyDB, if we don't want to drop local backend server support 
+# BerkeleyDB, if we don't want to drop local backend server support
 # we are forced to keep Berkeley DB here
 
 prepare() {
@@ -33,25 +34,24 @@ prepare() {
 
 build() {
   cd ${pkgbase}-${pkgver}
-  ./configure --prefix=/usr --mandir=/usr/share/man --libexecdir=/usr/lib \
+  autoconf
+  ./configure --prefix=/usr --libexecdir=/usr/lib \
     --sysconfdir=/etc --localstatedir=/var/lib/openldap --sbindir=/usr/bin \
-    --enable-ipv6 --enable-syslog --enable-local \
-    --enable-bdb --enable-hdb \
-    --enable-crypt --enable-dynamic \
-    --with-threads --disable-wrappers \
-    --without-fetch \
-    --enable-spasswd --with-cyrus-sasl \
-    --enable-overlays=mod --enable-modules=yes
+    --enable-dynamic --enable-syslog --enable-ipv6 --enable-local \
+    --enable-crypt --enable-spasswd --enable-modules \
+    --enable-backends --disable-ndb --enable-overlays=mod \
+    --with-cyrus-sasl --with-threads
   make
 
-  cd contrib/slapd-modules/nssov
-  make prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap
-  chrpath -d .libs/nssov.so
+  make -C contrib/slapd-modules/nssov OPT="$CFLAGS $CPPFLAGS" prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap
+  make -C contrib/slapd-modules/autogroup OPT="$CFLAGS $CPPFLAGS" prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap
+  make -C contrib/slapd-modules/lastbind OPT="$CFLAGS $CPPFLAGS" prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap
+  make -C contrib/slapd-modules/passwd/sha2 OPT="$CFLAGS $CPPFLAGS" prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap
 }
 
 check() {
   cd ${pkgbase}-${pkgver}
-  make test
+#  make test
 }
 
 package_libldap() {
@@ -66,7 +66,7 @@ package_libldap() {
     popd
   done
   install -Dm644 doc/man/man5/ldap.conf.5.tmp "${pkgdir}"/usr/share/man/man5/ldap.conf.5
-  
+
 # get rid of duplicate default conf files
   rm "${pkgdir}"/etc/openldap/*.default
 
@@ -78,10 +78,8 @@ package_libldap() {
 
 package_openldap() {
   pkgdesc="Lightweight Directory Access Protocol (LDAP) client and server"
-  depends=("libldap>=${pkgver}" 'libltdl')
+  depends=("libldap>=${pkgver}" 'libltdl' 'unixodbc')
   backup=('etc/openldap/slapd.conf' 'etc/openldap/slapd.ldif')
-  options=('emptydirs')
-  install=openldap.install
 
   cd ${pkgbase}-${pkgver}
   for dir in clients servers doc/man/man{1,5,8}; do
@@ -90,12 +88,13 @@ package_openldap() {
     popd
   done
 
-  pushd contrib/slapd-modules/nssov
-  install -m755 .libs/nssov.so.0.0.0 "${pkgdir}"/usr/lib/openldap
-  ln -s nssov.so.0.0.0 "${pkgdir}"/usr/lib/openldap/nssov.so
-  ln -s nssov.so.0.0.0 "${pkgdir}"/usr/lib/openldap/nssov.so.0
-  install -m444 ldapns.schema "${pkgdir}"/etc/openldap/schema
-  popd
+  make -C contrib/slapd-modules/autogroup prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap DESTDIR="$pkgdir" install
+  make -C contrib/slapd-modules/lastbind prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap DESTDIR="$pkgdir" install
+  make -C contrib/slapd-modules/passwd/sha2 prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap DESTDIR="$pkgdir" install
+  make -C contrib/slapd-modules/nssov prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap DESTDIR="$pkgdir" install
+  install -m644 contrib/slapd-modules/nssov/slapo-nssov.5 "${pkgdir}"/usr/share/man/man5/slapo-nssov.5
+  install -m644 contrib/slapd-modules/autogroup/slapo-autogroup.5 "${pkgdir}"/usr/share/man/man5/slapo-autogroup.5
+  install -m644 contrib/slapd-modules/lastbind/slapo-lastbind.5 "${pkgdir}"/usr/share/man/man5/slapo-lastbind.5
 
   rm "${pkgdir}"/usr/share/man/man5/ldap.conf.5
   rm -r "${pkgdir}"/run
@@ -109,8 +108,11 @@ package_openldap() {
   chmod 640 "${pkgdir}"/etc/openldap/{slapd.{conf,ldif},DB_CONFIG.example}
 
   install -dm700 -o 439 -g 439 "${pkgdir}"/var/lib/openldap
+  chown -R 439:439 "${pkgdir}"/var/lib/openldap
+
   install -dm700 -o 439 -g 439 "${pkgdir}"/etc/openldap/slapd.d
   install -Dm644 "${srcdir}"/slapd.service "${pkgdir}"/usr/lib/systemd/system/slapd.service
-  install -Dm644 "${srcdir}"/slapd.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/slapd.conf
+  install -Dm644 "${srcdir}"/openldap.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/openldap.conf
+  install -Dm644 "${srcdir}"/openldap.sysusers "${pkgdir}"/usr/lib/sysusers.d/openldap.conf
   install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
 }
diff --git a/abs/core/openldap/openldap.install b/abs/core/openldap/openldap.install
deleted file mode 100644
index a34ca1a..0000000
--- a/abs/core/openldap/openldap.install
+++ /dev/null
@@ -1,21 +0,0 @@
-post_install(){
-  systemd-tmpfiles --create slapd.conf
-  groupadd -g 439 ldap &>/dev/null
-  useradd -u 439 -g ldap -d /var/lib/openldap -s /bin/false ldap &>/dev/null
-  chown -R ldap:ldap var/lib/openldap &>/dev/null
-}
-
-post_upgrade(){
-  getent group ldap >/dev/null 2>&1 || groupadd -g 439 ldap &>/dev/null
-  getent passwd ldap >/dev/null 2>&1 || useradd -u 439 -g ldap -d /var/lib/openldap -s /bin/false ldap &>/dev/null
-  chown -R ldap:ldap var/lib/openldap &>/dev/null
-}
-
-post_remove(){
-  if getent passwd ldap >/dev/null 2>&1; then
-    userdel ldap
-  fi
-  if getent group ldap >/dev/null 2>&1; then
-    groupdel ldap
-  fi
-}
diff --git a/abs/core/openldap/openldap.sysusers b/abs/core/openldap/openldap.sysusers
new file mode 100644
index 0000000..362d6c1
--- /dev/null
+++ b/abs/core/openldap/openldap.sysusers
@@ -0,0 +1 @@
+u ldap 439 "LDAP Server" /var/lib/openldap
diff --git a/abs/core/openldap/openldap.tmpfiles b/abs/core/openldap/openldap.tmpfiles
new file mode 100644
index 0000000..9337fce
--- /dev/null
+++ b/abs/core/openldap/openldap.tmpfiles
@@ -0,0 +1,3 @@
+D /run/openldap 0755 ldap ldap -
+
+f /var/lib/openldap/.placeholder 0644 ldap ldap - "prevent pwcheck error; pacman should not remove ~ldap"
diff --git a/abs/core/openldap/slapd.tmpfiles b/abs/core/openldap/slapd.tmpfiles
deleted file mode 100644
index b22c831..0000000
--- a/abs/core/openldap/slapd.tmpfiles
+++ /dev/null
@@ -1 +0,0 @@
-D /run/openldap 0755 ldap ldap -
-- 
cgit v0.12