Gentoo Archives: gentoo-commits

From: Patrick McLean <chutzpah@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-nds/openldap/
Date: Tue, 07 Feb 2017 20:07:53
Message-Id: 1486498061.0f6336d03b42615c04381febe8d98f0928350439.chutzpah@gentoo
1 commit: 0f6336d03b42615c04381febe8d98f0928350439
2 Author: Patrick McLean <chutzpah <AT> gentoo <DOT> org>
3 AuthorDate: Tue Feb 7 20:06:36 2017 +0000
4 Commit: Patrick McLean <chutzpah <AT> gentoo <DOT> org>
5 CommitDate: Tue Feb 7 20:07:41 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0f6336d0
7
8 net-nds/openldap: Revision bump, add USE=pbkdf2 for pbkdf2 password support
9
10 Package-Manager: Portage-2.3.3, Repoman-2.3.1
11
12 net-nds/openldap/metadata.xml | 1 +
13 net-nds/openldap/openldap-2.4.44-r1.ebuild | 853 +++++++++++++++++++++++++++++
14 2 files changed, 854 insertions(+)
15
16 diff --git a/net-nds/openldap/metadata.xml b/net-nds/openldap/metadata.xml
17 index b53a10a..cda62a6 100644
18 --- a/net-nds/openldap/metadata.xml
19 +++ b/net-nds/openldap/metadata.xml
20 @@ -12,6 +12,7 @@
21 <flag name="smbkrb5passwd">Enable overlay for syncing ldap, unix and
22 lanman passwords</flag>
23 <flag name="minimal">Build libraries &amp; userspace tools only. Does not install any server code.</flag>
24 + <flag name="pbkdf2">Enable support for pbkdf2 passwords</flag>
25 </use>
26 <upstream>
27 <remote-id type="cpe">cpe:/a:openldap:openldap</remote-id>
28
29 diff --git a/net-nds/openldap/openldap-2.4.44-r1.ebuild b/net-nds/openldap/openldap-2.4.44-r1.ebuild
30 new file mode 100644
31 index 00000000..7e7c7a0
32 --- /dev/null
33 +++ b/net-nds/openldap/openldap-2.4.44-r1.ebuild
34 @@ -0,0 +1,853 @@
35 +# Copyright 1999-2017 Gentoo Foundation
36 +# Distributed under the terms of the GNU General Public License v2
37 +# $Id$
38 +
39 +EAPI="5"
40 +
41 +inherit db-use eutils flag-o-matic multilib multilib-minimal ssl-cert versionator toolchain-funcs autotools user systemd
42 +
43 +BIS_PN=rfc2307bis.schema
44 +BIS_PV=20140524
45 +BIS_P="${BIS_PN}-${BIS_PV}"
46 +
47 +DESCRIPTION="LDAP suite of application and development tools"
48 +HOMEPAGE="http://www.OpenLDAP.org/"
49 +
50 +# mirrors are mostly not working, using canonical URI
51 +SRC_URI="ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/${P}.tgz
52 + mirror://gentoo/${BIS_P}"
53 +
54 +LICENSE="OPENLDAP GPL-2"
55 +SLOT="0"
56 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~x86-solaris"
57 +
58 +IUSE_DAEMON="crypt icu samba slp tcpd experimental minimal"
59 +IUSE_BACKEND="+berkdb"
60 +IUSE_OVERLAY="overlays perl"
61 +IUSE_OPTIONAL="gnutls iodbc sasl ssl odbc debug ipv6 libressl +syslog selinux static-libs"
62 +IUSE_CONTRIB="smbkrb5passwd kerberos kinit pbkdf2"
63 +IUSE_CONTRIB="${IUSE_CONTRIB} -cxx"
64 +IUSE="${IUSE_DAEMON} ${IUSE_BACKEND} ${IUSE_OVERLAY} ${IUSE_OPTIONAL} ${IUSE_CONTRIB}"
65 +
66 +REQUIRED_USE="cxx? ( sasl )
67 + ?? ( gnutls libressl )
68 + pbkdf2? ( ssl )"
69 +
70 +# always list newer first
71 +# Do not add any AGPL-3 BDB here!
72 +# See bug 525110, comment 15.
73 +BDB_SLOTS='5.3 5.1 4.8 4.7 4.6 4.5 4.4'
74 +BDB_PKGS=''
75 +for _slot in $BDB_SLOTS; do BDB_PKGS="${BDB_PKGS} sys-libs/db:${_slot}" ; done
76 +
77 +# openssl is needed to generate lanman-passwords required by samba
78 +CDEPEND="icu? ( dev-libs/icu:= )
79 + ssl? (
80 + !gnutls? (
81 + !libressl? ( >=dev-libs/openssl-1.0.1h-r2:0[${MULTILIB_USEDEP}] )
82 + )
83 + gnutls? ( >=net-libs/gnutls-2.12.23-r6[${MULTILIB_USEDEP}]
84 + libressl? ( dev-libs/libressl[${MULTILIB_USEDEP}] )
85 + >=dev-libs/libgcrypt-1.5.3:0[${MULTILIB_USEDEP}] ) )
86 + sasl? ( dev-libs/cyrus-sasl:= )
87 + !minimal? (
88 + sys-devel/libtool
89 + sys-libs/e2fsprogs-libs
90 + >=dev-db/lmdb-0.9.18:=
91 + tcpd? ( sys-apps/tcp-wrappers )
92 + odbc? ( !iodbc? ( dev-db/unixODBC )
93 + iodbc? ( dev-db/libiodbc ) )
94 + slp? ( net-libs/openslp )
95 + perl? ( dev-lang/perl:=[-build(-)] )
96 + samba? (
97 + !libressl? ( dev-libs/openssl:0 )
98 + libressl? ( dev-libs/libressl )
99 + )
100 + berkdb? (
101 + <sys-libs/db-6.0:=
102 + || ( ${BDB_PKGS} )
103 + )
104 + smbkrb5passwd? (
105 + !libressl? ( dev-libs/openssl:0 )
106 + libressl? ( dev-libs/libressl )
107 + kerberos? ( app-crypt/heimdal )
108 + )
109 + kerberos? (
110 + virtual/krb5
111 + kinit? ( !app-crypt/heimdal )
112 + )
113 + cxx? ( dev-libs/cyrus-sasl:= )
114 + )
115 + abi_x86_32? (
116 + !<=app-emulation/emul-linux-x86-baselibs-20140508-r3
117 + !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
118 + )"
119 +DEPEND="${CDEPEND}
120 + sys-apps/groff"
121 +RDEPEND="${CDEPEND}
122 + selinux? ( sec-policy/selinux-ldap )
123 +"
124 +# for tracking versions
125 +OPENLDAP_VERSIONTAG=".version-tag"
126 +OPENLDAP_DEFAULTDIR_VERSIONTAG="/var/lib/openldap-data"
127 +
128 +MULTILIB_WRAPPED_HEADERS=(
129 + # USE=cxx
130 + /usr/include/LDAPAsynConnection.h
131 + /usr/include/LDAPAttrType.h
132 + /usr/include/LDAPAttribute.h
133 + /usr/include/LDAPAttributeList.h
134 + /usr/include/LDAPConnection.h
135 + /usr/include/LDAPConstraints.h
136 + /usr/include/LDAPControl.h
137 + /usr/include/LDAPControlSet.h
138 + /usr/include/LDAPEntry.h
139 + /usr/include/LDAPEntryList.h
140 + /usr/include/LDAPException.h
141 + /usr/include/LDAPExtResult.h
142 + /usr/include/LDAPMessage.h
143 + /usr/include/LDAPMessageQueue.h
144 + /usr/include/LDAPModList.h
145 + /usr/include/LDAPModification.h
146 + /usr/include/LDAPObjClass.h
147 + /usr/include/LDAPRebind.h
148 + /usr/include/LDAPRebindAuth.h
149 + /usr/include/LDAPReferenceList.h
150 + /usr/include/LDAPResult.h
151 + /usr/include/LDAPSaslBindResult.h
152 + /usr/include/LDAPSchema.h
153 + /usr/include/LDAPSearchReference.h
154 + /usr/include/LDAPSearchResult.h
155 + /usr/include/LDAPSearchResults.h
156 + /usr/include/LDAPUrl.h
157 + /usr/include/LDAPUrlList.h
158 + /usr/include/LdifReader.h
159 + /usr/include/LdifWriter.h
160 + /usr/include/SaslInteraction.h
161 + /usr/include/SaslInteractionHandler.h
162 + /usr/include/StringList.h
163 + /usr/include/TlsOptions.h
164 +)
165 +
166 +openldap_filecount() {
167 + local dir="$1"
168 + find "${dir}" -type f ! -name '.*' ! -name 'DB_CONFIG*' | wc -l
169 +}
170 +
171 +openldap_find_versiontags() {
172 + # scan for all datadirs
173 + openldap_datadirs=""
174 + if [ -f "${EROOT}"/etc/openldap/slapd.conf ]; then
175 + openldap_datadirs="$(awk '{if($1 == "directory") print $2 }' ${EROOT}/etc/openldap/slapd.conf)"
176 + fi
177 + openldap_datadirs="${openldap_datadirs} ${OPENLDAP_DEFAULTDIR_VERSIONTAG}"
178 +
179 + einfo
180 + einfo "Scanning datadir(s) from slapd.conf and"
181 + einfo "the default installdir for Versiontags"
182 + einfo "(${OPENLDAP_DEFAULTDIR_VERSIONTAG} may appear twice)"
183 + einfo
184 +
185 + # scan datadirs if we have a version tag
186 + openldap_found_tag=0
187 + have_files=0
188 + for each in ${openldap_datadirs}; do
189 + CURRENT_TAGDIR=${ROOT}`echo ${each} | sed "s:\/::"`
190 + CURRENT_TAG=${CURRENT_TAGDIR}/${OPENLDAP_VERSIONTAG}
191 + if [ -d ${CURRENT_TAGDIR} ] && [ ${openldap_found_tag} == 0 ] ; then
192 + einfo "- Checking ${each}..."
193 + if [ -r ${CURRENT_TAG} ] ; then
194 + # yey, we have one :)
195 + einfo " Found Versiontag in ${each}"
196 + source ${CURRENT_TAG}
197 + if [ "${OLDPF}" == "" ] ; then
198 + eerror "Invalid Versiontag found in ${CURRENT_TAGDIR}"
199 + eerror "Please delete it"
200 + eerror
201 + die "Please kill the invalid versiontag in ${CURRENT_TAGDIR}"
202 + fi
203 +
204 + OLD_MAJOR=`get_version_component_range 2-3 ${OLDPF}`
205 +
206 + [ $(openldap_filecount ${CURRENT_TAGDIR}) -gt 0 ] && have_files=1
207 +
208 + # are we on the same branch?
209 + if [ "${OLD_MAJOR}" != "${PV:0:3}" ] ; then
210 + ewarn " Versiontag doesn't match current major release!"
211 + if [[ "${have_files}" == "1" ]] ; then
212 + eerror " Versiontag says other major and you (probably) have datafiles!"
213 + echo
214 + openldap_upgrade_howto
215 + else
216 + einfo " No real problem, seems there's no database."
217 + fi
218 + else
219 + einfo " Versiontag is fine here :)"
220 + fi
221 + else
222 + einfo " Non-tagged dir ${each}"
223 + [ $(openldap_filecount ${each}) -gt 0 ] && have_files=1
224 + if [[ "${have_files}" == "1" ]] ; then
225 + einfo " EEK! Non-empty non-tagged datadir, counting `ls -a ${each} | wc -l` files"
226 + echo
227 +
228 + eerror
229 + eerror "Your OpenLDAP Installation has a non tagged datadir that"
230 + eerror "possibly contains a database at ${CURRENT_TAGDIR}"
231 + eerror
232 + eerror "Please export data if any entered and empty or remove"
233 + eerror "the directory, installation has been stopped so you"
234 + eerror "can take required action"
235 + eerror
236 + eerror "For a HOWTO on exporting the data, see instructions in the ebuild"
237 + eerror
238 + openldap_upgrade_howto
239 + die "Please move the datadir ${CURRENT_TAGDIR} away"
240 + fi
241 + fi
242 + einfo
243 + fi
244 + done
245 + [ "${have_files}" == "1" ] && einfo "DB files present" || einfo "No DB files present"
246 +
247 + # Now we must check for the major version of sys-libs/db linked against.
248 + SLAPD_PATH=${EROOT}/usr/$(get_libdir)/openldap/slapd
249 + if [ "${have_files}" == "1" -a -f "${SLAPD_PATH}" ]; then
250 + OLDVER="$(/usr/bin/ldd ${SLAPD_PATH} \
251 + | awk '/libdb-/{gsub("^libdb-","",$1);gsub(".so$","",$1);print $1}')"
252 + if use berkdb; then
253 + # find which one would be used
254 + for bdb_slot in $BDB_SLOTS ; do
255 + NEWVER="$(db_findver "=sys-libs/db-${bdb_slot}*")"
256 + [[ -n "$NEWVER" ]] && break
257 + done
258 + fi
259 + local fail=0
260 + if [ -z "${OLDVER}" -a -z "${NEWVER}" ]; then
261 + :
262 + # Nothing wrong here.
263 + elif [ -z "${OLDVER}" -a -n "${NEWVER}" ]; then
264 + eerror " Your existing version of OpenLDAP was not built against"
265 + eerror " any version of sys-libs/db, but the new one will build"
266 + eerror " against ${NEWVER} and your database may be inaccessible."
267 + echo
268 + fail=1
269 + elif [ -n "${OLDVER}" -a -z "${NEWVER}" ]; then
270 + eerror " Your existing version of OpenLDAP was built against"
271 + eerror " sys-libs/db:${OLDVER}, but the new one will not be"
272 + eerror " built against any version and your database may be"
273 + eerror " inaccessible."
274 + echo
275 + fail=1
276 + elif [ "${OLDVER}" != "${NEWVER}" ]; then
277 + eerror " Your existing version of OpenLDAP was built against"
278 + eerror " sys-libs/db:${OLDVER}, but the new one will build against"
279 + eerror " ${NEWVER} and your database would be inaccessible."
280 + echo
281 + fail=1
282 + fi
283 + [ "${fail}" == "1" ] && openldap_upgrade_howto
284 + fi
285 +
286 + echo
287 + einfo
288 + einfo "All datadirs are fine, proceeding with merge now..."
289 + einfo
290 +}
291 +
292 +openldap_upgrade_howto() {
293 + eerror
294 + eerror "A (possible old) installation of OpenLDAP was detected,"
295 + eerror "installation will not proceed for now."
296 + eerror
297 + eerror "As major version upgrades can corrupt your database,"
298 + eerror "you need to dump your database and re-create it afterwards."
299 + eerror
300 + eerror "Additionally, rebuilding against different major versions of the"
301 + eerror "sys-libs/db libraries will cause your database to be inaccessible."
302 + eerror ""
303 + d="$(date -u +%s)"
304 + l="/root/ldapdump.${d}"
305 + i="${l}.raw"
306 + eerror " 1. /etc/init.d/slurpd stop ; /etc/init.d/slapd stop"
307 + eerror " 2. slapcat -l ${i}"
308 + eerror " 3. egrep -v '^(entry|context)CSN:' <${i} >${l}"
309 + eerror " 4. mv /var/lib/openldap-data/ /var/lib/openldap-data-backup/"
310 + eerror " 5. emerge --update \=net-nds/${PF}"
311 + eerror " 6. etc-update, and ensure that you apply the changes"
312 + eerror " 7. slapadd -l ${l}"
313 + eerror " 8. chown ldap:ldap /var/lib/openldap-data/*"
314 + eerror " 9. /etc/init.d/slapd start"
315 + eerror "10. check that your data is intact."
316 + eerror "11. set up the new replication system."
317 + eerror
318 + if [ "${FORCE_UPGRADE}" != "1" ]; then
319 + die "You need to upgrade your database first"
320 + else
321 + eerror "You have the magical FORCE_UPGRADE=1 in place."
322 + eerror "Don't say you weren't warned about data loss."
323 + fi
324 +}
325 +
326 +pkg_setup() {
327 + if ! use sasl && use cxx ; then
328 + die "To build the ldapc++ library you must emerge openldap with sasl support"
329 + fi
330 + # Bug #322787
331 + if use minimal && ! has_version "net-nds/openldap" ; then
332 + einfo "No datadir scan needed, openldap not installed"
333 + elif use minimal && has_version "net-nds/openldap" && built_with_use net-nds/openldap minimal ; then
334 + einfo "Skipping scan for previous datadirs as requested by minimal useflag"
335 + else
336 + openldap_find_versiontags
337 + fi
338 +
339 + # The user/group are only used for running daemons which are
340 + # disabled in minimal builds, so elide the accounts too.
341 + if ! use minimal ; then
342 + enewgroup ldap 439
343 + enewuser ldap 439 -1 /usr/$(get_libdir)/openldap ldap
344 + fi
345 +}
346 +
347 +src_prepare() {
348 + # ensure correct SLAPI path by default
349 + sed -i -e 's,\(#define LDAPI_SOCK\).*,\1 "'"${EPREFIX}"'/var/run/openldap/slapd.sock",' \
350 + "${S}"/include/ldap_defaults.h
351 +
352 + epatch "${FILESDIR}"/${PN}-2.4.17-gcc44.patch
353 +
354 + epatch \
355 + "${FILESDIR}"/${PN}-2.2.14-perlthreadsfix.patch \
356 + "${FILESDIR}"/${PN}-2.4.15-ppolicy.patch
357 +
358 + # bug #116045 - still present in 2.4.28
359 + epatch "${FILESDIR}"/${PN}-2.4.35-contrib-smbk5pwd.patch
360 + # bug #408077 - samba4
361 + epatch "${FILESDIR}"/${PN}-2.4.35-contrib-samba4.patch
362 +
363 + # bug #189817
364 + epatch "${FILESDIR}"/${PN}-2.4.11-libldap_r.patch
365 +
366 + # bug #233633
367 + epatch "${FILESDIR}"/${PN}-2.4.17-fix-lmpasswd-gnutls-symbols.patch
368 +
369 + # bug #281495
370 + epatch "${FILESDIR}"/${PN}-2.4.28-gnutls-gcrypt.patch
371 +
372 + # bug #294350
373 + epatch "${FILESDIR}"/${PN}-2.4.6-evolution-ntlm.patch
374 +
375 + # unbreak /bin/sh -> dash
376 + epatch "${FILESDIR}"/${PN}-2.4.28-fix-dash.patch
377 +
378 + # bug #420959
379 + epatch "${FILESDIR}"/${PN}-2.4.31-gcc47.patch
380 +
381 + # unbundle lmdb
382 + epatch "${FILESDIR}"/${PN}-2.4.42-mdb-unbundle.patch
383 + rm -rf "${S}"/libraries/liblmdb
384 +
385 + cd "${S}"/build || die
386 + einfo "Making sure upstream build strip does not do stripping too early"
387 + sed -i.orig \
388 + -e '/^STRIP/s,-s,,g' \
389 + top.mk || die "Failed to block stripping"
390 +
391 + # wrong assumption that /bin/sh is /bin/bash
392 + sed -i \
393 + -e 's|/bin/sh|/bin/bash|g' \
394 + "${S}"/tests/scripts/* || die "sed failed"
395 +
396 + cd "${S}" || die
397 +
398 + AT_NOEAUTOMAKE=yes eautoreconf
399 +}
400 +
401 +build_contrib_module() {
402 + # <dir> <sources> <outputname>
403 + cd "${S}/contrib/slapd-modules/$1" || die
404 + einfo "Compiling contrib-module: $3"
405 + # Make sure it's uppercase
406 + local define_name="$(echo "SLAPD_OVER_${1}" | LC_ALL=C tr '[:lower:]' '[:upper:]')"
407 + "${lt}" --mode=compile --tag=CC \
408 + "${CC}" \
409 + -D${define_name}=SLAPD_MOD_DYNAMIC \
410 + -I"${BUILD_DIR}"/include \
411 + -I../../../include -I../../../servers/slapd ${CFLAGS} \
412 + -o ${2%.c}.lo -c $2 || die "compiling $3 failed"
413 + einfo "Linking contrib-module: $3"
414 + "${lt}" --mode=link --tag=CC \
415 + "${CC}" -module \
416 + ${CFLAGS} \
417 + ${LDFLAGS} \
418 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
419 + -o $3.la ${2%.c}.lo || die "linking $3 failed"
420 +}
421 +
422 +src_configure() {
423 + # Bug 408001
424 + use elibc_FreeBSD && append-cppflags -DMDB_DSYNC=O_SYNC -DMDB_FDATASYNC=fsync
425 +
426 + # connectionless ldap per bug #342439
427 + append-cppflags -DLDAP_CONNECTIONLESS
428 +
429 + multilib-minimal_src_configure
430 +}
431 +
432 +multilib_src_configure() {
433 + local myconf=()
434 +
435 + use debug && myconf+=( $(use_enable debug) )
436 +
437 + # ICU usage is not configurable
438 + export ac_cv_header_unicode_utypes_h="$(multilib_is_native_abi && use icu && echo yes || echo no)"
439 +
440 + if ! use minimal && multilib_is_native_abi; then
441 + local CPPFLAGS=${CPPFLAGS}
442 +
443 + # re-enable serverside overlay chains per bug #296567
444 + # see ldap docs chaper 12.3.1 for details
445 + myconf+=( --enable-ldap )
446 +
447 + # backends
448 + myconf+=( --enable-slapd )
449 + if use berkdb ; then
450 + einfo "Using Berkeley DB for local backend"
451 + myconf+=( --enable-bdb --enable-hdb )
452 + DBINCLUDE=$(db_includedir $BDB_SLOTS)
453 + einfo "Using $DBINCLUDE for sys-libs/db version"
454 + # We need to include the slotted db.h dir for FreeBSD
455 + append-cppflags -I${DBINCLUDE}
456 + else
457 + myconf+=( --disable-bdb --disable-hdb )
458 + fi
459 + for backend in dnssrv ldap mdb meta monitor null passwd relay shell sock; do
460 + myconf+=( --enable-${backend}=mod )
461 + done
462 +
463 + myconf+=( $(use_enable perl perl mod) )
464 +
465 + myconf+=( $(use_enable odbc sql mod) )
466 + if use odbc ; then
467 + local odbc_lib="unixodbc"
468 + if use iodbc ; then
469 + odbc_lib="iodbc"
470 + append-cppflags -I"${EPREFIX}"/usr/include/iodbc
471 + fi
472 + myconf+=( --with-odbc=${odbc_lib} )
473 + fi
474 +
475 + # slapd options
476 + myconf+=(
477 + $(use_enable crypt)
478 + $(use_enable slp)
479 + $(use_enable samba lmpasswd)
480 + $(use_enable syslog)
481 + )
482 + if use experimental ; then
483 + myconf+=(
484 + --enable-dynacl
485 + --enable-aci=mod
486 + )
487 + fi
488 + for option in aci cleartext modules rewrite rlookups slapi; do
489 + myconf+=( --enable-${option} )
490 + done
491 +
492 + # slapd overlay options
493 + # Compile-in the syncprov, the others as module
494 + myconf+=( --enable-syncprov=yes )
495 + use overlays && myconf+=( --enable-overlays=mod )
496 +
497 + else
498 + myconf+=(
499 + --disable-backends
500 + --disable-slapd
501 + --disable-bdb
502 + --disable-hdb
503 + --disable-mdb
504 + --disable-overlays
505 + --disable-syslog
506 + )
507 + fi
508 +
509 + # basic functionality stuff
510 + myconf+=(
511 + $(use_enable ipv6)
512 + $(multilib_native_use_with sasl cyrus-sasl)
513 + $(multilib_native_use_enable sasl spasswd)
514 + $(use_enable tcpd wrappers)
515 + )
516 +
517 + # Some cross-compiling tests don't pan out well.
518 + tc-is-cross-compiler && myconf+=(
519 + --with-yielding-select=yes
520 + )
521 +
522 + local ssl_lib="no"
523 + if use ssl || ( ! use minimal && use samba ) ; then
524 + ssl_lib="openssl"
525 + use gnutls && ssl_lib="gnutls"
526 + fi
527 +
528 + myconf+=( --with-tls=${ssl_lib} )
529 +
530 + for basicflag in dynamic local proctitle shared; do
531 + myconf+=( --enable-${basicflag} )
532 + done
533 +
534 + tc-export AR CC CXX
535 + ECONF_SOURCE=${S} \
536 + STRIP=/bin/true \
537 + econf \
538 + --libexecdir="${EPREFIX}"/usr/$(get_libdir)/openldap \
539 + $(use_enable static-libs static) \
540 + "${myconf[@]}"
541 + emake depend
542 +}
543 +
544 +src_configure_cxx() {
545 + # This needs the libraries built by the first build run.
546 + # So we have to run it AFTER the main build, not just after the main
547 + # configure.
548 + local myconf_ldapcpp=(
549 + --with-ldap-includes="${S}"/include
550 + )
551 +
552 + mkdir -p "${BUILD_DIR}"/contrib/ldapc++ || die
553 + cd "${BUILD_DIR}/contrib/ldapc++" || die
554 +
555 + local LDFLAGS=${LDFLAGS} CPPFLAGS=${CPPFLAGS}
556 + append-ldflags -L"${BUILD_DIR}"/libraries/liblber/.libs \
557 + -L"${BUILD_DIR}"/libraries/libldap/.libs
558 + append-cppflags -I"${BUILD_DIR}"/include
559 + ECONF_SOURCE=${S}/contrib/ldapc++ \
560 + econf "${myconf_ldapcpp[@]}" \
561 + CC="${CC}" \
562 + CXX="${CXX}"
563 +}
564 +
565 +multilib_src_compile() {
566 + tc-export AR CC CXX
567 + emake CC="${CC}" AR="${AR}" SHELL="${EPREFIX}"/bin/bash
568 + local lt="${BUILD_DIR}/libtool"
569 + export echo="echo"
570 +
571 + if ! use minimal && multilib_is_native_abi ; then
572 + if use cxx ; then
573 + einfo "Building contrib library: ldapc++"
574 + src_configure_cxx
575 + cd "${BUILD_DIR}/contrib/ldapc++" || die
576 + emake \
577 + CC="${CC}" CXX="${CXX}"
578 + fi
579 +
580 + if use smbkrb5passwd ; then
581 + einfo "Building contrib-module: smbk5pwd"
582 + cd "${S}/contrib/slapd-modules/smbk5pwd" || die
583 +
584 + MY_DEFS="-DDO_SHADOW"
585 + if use samba ; then
586 + MY_DEFS="${MY_DEFS} -DDO_SAMBA"
587 + MY_KRB5_INC=""
588 + fi
589 + if use kerberos ; then
590 + MY_DEFS="${MY_DEFS} -DDO_KRB5"
591 + MY_KRB5_INC="$(krb5-config --cflags)"
592 + fi
593 +
594 + emake \
595 + DEFS="${MY_DEFS}" \
596 + KRB5_INC="${MY_KRB5_INC}" \
597 + LDAP_BUILD="${BUILD_DIR}" \
598 + CC="${CC}" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap"
599 + fi
600 +
601 + if use overlays ; then
602 + einfo "Building contrib-module: samba4"
603 + cd "${S}/contrib/slapd-modules/samba4" || die
604 +
605 + emake \
606 + LDAP_BUILD="${BUILD_DIR}" \
607 + CC="${CC}" libexecdir="/usr/$(get_libdir)/openldap"
608 + fi
609 +
610 + if use kerberos ; then
611 + if use kinit ; then
612 + build_contrib_module "kinit" "kinit.c" "kinit"
613 + fi
614 + cd "${S}/contrib/slapd-modules/passwd" || die
615 + einfo "Compiling contrib-module: pw-kerberos"
616 + "${lt}" --mode=compile --tag=CC \
617 + "${CC}" \
618 + -I"${BUILD_DIR}"/include \
619 + -I../../../include \
620 + ${CFLAGS} \
621 + $(krb5-config --cflags) \
622 + -DHAVE_KRB5 \
623 + -o kerberos.lo \
624 + -c kerberos.c || die "compiling pw-kerberos failed"
625 + einfo "Linking contrib-module: pw-kerberos"
626 + "${lt}" --mode=link --tag=CC \
627 + "${CC}" -module \
628 + ${CFLAGS} \
629 + ${LDFLAGS} \
630 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
631 + -o pw-kerberos.la \
632 + kerberos.lo || die "linking pw-kerberos failed"
633 + fi
634 +
635 + if use pbkdf2; then
636 + cd "${S}/contrib/slapd-modules/passwd/pbkdf2" || die
637 + einfo "Compiling contrib-module: pw-pbkdf2"
638 + "${lt}" --mode=compile --tag=CC \
639 + "${CC}" \
640 + -I"${BUILD_DIR}"/include \
641 + -I../../../../include \
642 + ${CFLAGS} \
643 + -o pbkdf2.lo \
644 + -c pw-pbkdf2.c || die "compiling pw-pbkdf2 failed"
645 + einfo "Linking contrib-module: pw-pbkdf2"
646 + "${lt}" --mode=link --tag=CC \
647 + "${CC}" -module \
648 + ${CFLAGS} \
649 + ${LDFLAGS} \
650 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
651 + -o pw-pbkdf2.la \
652 + pbkdf2.lo || die "linking pw-pbkdf2 failed"
653 + fi
654 +
655 + # We could build pw-radius if GNURadius would install radlib.h
656 + cd "${S}/contrib/slapd-modules/passwd" || die
657 + einfo "Compiling contrib-module: pw-netscape"
658 + "${lt}" --mode=compile --tag=CC \
659 + "${CC}" \
660 + -I"${BUILD_DIR}"/include \
661 + -I../../../include \
662 + ${CFLAGS} \
663 + -o netscape.lo \
664 + -c netscape.c || die "compiling pw-netscape failed"
665 + einfo "Linking contrib-module: pw-netscape"
666 + "${lt}" --mode=link --tag=CC \
667 + "${CC}" -module \
668 + ${CFLAGS} \
669 + ${LDFLAGS} \
670 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
671 + -o pw-netscape.la \
672 + netscape.lo || die "linking pw-netscape failed"
673 +
674 + #build_contrib_module "acl" "posixgroup.c" "posixGroup" # example code only
675 + #build_contrib_module "acl" "gssacl.c" "gss" # example code only, also needs kerberos
676 + build_contrib_module "addpartial" "addpartial-overlay.c" "addpartial-overlay"
677 + build_contrib_module "allop" "allop.c" "overlay-allop"
678 + build_contrib_module "allowed" "allowed.c" "allowed"
679 + build_contrib_module "autogroup" "autogroup.c" "autogroup"
680 + build_contrib_module "cloak" "cloak.c" "cloak"
681 + # build_contrib_module "comp_match" "comp_match.c" "comp_match" # really complex, adds new external deps, questionable demand
682 + build_contrib_module "denyop" "denyop.c" "denyop-overlay"
683 + build_contrib_module "dsaschema" "dsaschema.c" "dsaschema-plugin"
684 + build_contrib_module "dupent" "dupent.c" "dupent"
685 + build_contrib_module "lastbind" "lastbind.c" "lastbind"
686 + # lastmod may not play well with other overlays
687 + build_contrib_module "lastmod" "lastmod.c" "lastmod"
688 + build_contrib_module "noopsrch" "noopsrch.c" "noopsrch"
689 + build_contrib_module "nops" "nops.c" "nops-overlay"
690 + #build_contrib_module "nssov" "nssov.c" "nssov-overlay" RESO:LATER
691 + build_contrib_module "trace" "trace.c" "trace"
692 + # build slapi-plugins
693 + cd "${S}/contrib/slapi-plugins/addrdnvalues" || die
694 + einfo "Building contrib-module: addrdnvalues plugin"
695 + "${CC}" -shared \
696 + -I"${BUILD_DIR}"/include \
697 + -I../../../include \
698 + ${CFLAGS} \
699 + -fPIC \
700 + ${LDFLAGS} \
701 + -o libaddrdnvalues-plugin.so \
702 + addrdnvalues.c || die "Building libaddrdnvalues-plugin.so failed"
703 +
704 + fi
705 +}
706 +
707 +multilib_src_test() {
708 + if multilib_is_native_abi; then
709 + cd tests || die
710 + emake tests || die "make tests failed"
711 + fi
712 +}
713 +
714 +multilib_src_install() {
715 + local lt="${BUILD_DIR}/libtool"
716 + emake DESTDIR="${D}" SHELL="${EPREFIX}"/bin/bash install
717 + use static-libs || prune_libtool_files --all
718 +
719 + if ! use minimal && multilib_is_native_abi; then
720 + # openldap modules go here
721 + # TODO: write some code to populate slapd.conf with moduleload statements
722 + keepdir /usr/$(get_libdir)/openldap/openldap/
723 +
724 + # initial data storage dir
725 + keepdir /var/lib/openldap-data
726 + use prefix || fowners ldap:ldap /var/lib/openldap-data
727 + fperms 0700 /var/lib/openldap-data
728 +
729 + echo "OLDPF='${PF}'" > "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}"
730 + echo "# do NOT delete this. it is used" >> "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}"
731 + echo "# to track versions for upgrading." >> "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}"
732 +
733 + # use our config
734 + rm "${ED}"etc/openldap/slapd.conf
735 + insinto /etc/openldap
736 + newins "${FILESDIR}"/${PN}-2.4.40-slapd-conf slapd.conf
737 + configfile="${ED}"etc/openldap/slapd.conf
738 +
739 + # populate with built backends
740 + ebegin "populate config with built backends"
741 + for x in "${ED}"usr/$(get_libdir)/openldap/openldap/back_*.so; do
742 + einfo "Adding $(basename ${x})"
743 + sed -e "/###INSERTDYNAMICMODULESHERE###$/a# moduleload\t$(basename ${x})" -i "${configfile}"
744 + done
745 + sed -e "s:###INSERTDYNAMICMODULESHERE###$:# modulepath\t${EPREFIX}/usr/$(get_libdir)/openldap/openldap:" -i "${configfile}"
746 + use prefix || fowners root:ldap /etc/openldap/slapd.conf
747 + fperms 0640 /etc/openldap/slapd.conf
748 + cp "${configfile}" "${configfile}".default
749 + eend
750 +
751 + # install our own init scripts and systemd unit files
752 + einfo "Install init scripts"
753 + newinitd "${FILESDIR}"/slapd-initd-2.4.40-r2 slapd
754 + newconfd "${FILESDIR}"/slapd-confd-2.4.28-r1 slapd
755 + einfo "Install systemd service"
756 + systemd_dounit "${FILESDIR}"/slapd.service
757 + systemd_install_serviced "${FILESDIR}"/slapd.service.conf
758 + systemd_newtmpfilesd "${FILESDIR}"/slapd.tmpfilesd slapd.conf
759 +
760 + if [[ $(get_libdir) != lib ]]; then
761 + sed -e "s,/usr/lib/,/usr/$(get_libdir)/," -i \
762 + "${ED}"/etc/init.d/slapd \
763 + "${ED}"/usr/lib/systemd/system/slapd.service || die
764 + fi
765 + # If built without SLP, we don't need to be before avahi
766 + use slp \
767 + || sed -i \
768 + -e '/before/{s/avahi-daemon//g}' \
769 + "${ED}"etc/init.d/slapd
770 +
771 + if use cxx ; then
772 + einfo "Install the ldapc++ library"
773 + cd "${BUILD_DIR}/contrib/ldapc++" || die
774 + emake DESTDIR="${D}" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" install
775 + cd "${S}"/contrib/ldapc++ || die
776 + newdoc README ldapc++-README
777 + fi
778 +
779 + if use smbkrb5passwd ; then
780 + einfo "Install the smbk5pwd module"
781 + cd "${S}/contrib/slapd-modules/smbk5pwd" || die
782 + emake DESTDIR="${D}" \
783 + LDAP_BUILD="${BUILD_DIR}" \
784 + libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" install
785 + newdoc README smbk5pwd-README
786 + fi
787 +
788 + if use overlays ; then
789 + einfo "Install the samba4 module"
790 + cd "${S}/contrib/slapd-modules/samba4" || die
791 + emake DESTDIR="${D}" \
792 + LDAP_BUILD="${BUILD_DIR}" \
793 + libexecdir="/usr/$(get_libdir)/openldap" install
794 + newdoc README samba4-README
795 + fi
796 +
797 + einfo "Installing contrib modules"
798 + cd "${S}/contrib/slapd-modules" || die
799 + for l in */*.la */*/*.la; do
800 + [[ -e ${l} ]] || continue
801 + "${lt}" --mode=install cp ${l} \
802 + "${ED}"usr/$(get_libdir)/openldap/openldap || \
803 + die "installing ${l} failed"
804 + done
805 +
806 + dodoc "${FILESDIR}"/DB_CONFIG.fast.example
807 + docinto contrib
808 + doman */*.5
809 + #newdoc acl/README*
810 + newdoc addpartial/README addpartial-README
811 + newdoc allop/README allop-README
812 + newdoc allowed/README allowed-README
813 + newdoc autogroup/README autogroup-README
814 + newdoc dsaschema/README dsaschema-README
815 + newdoc passwd/README passwd-README
816 + cd "${S}/contrib/slapi-plugins" || die
817 + insinto /usr/$(get_libdir)/openldap/openldap
818 + doins */*.so
819 + docinto contrib
820 + newdoc addrdnvalues/README addrdnvalues-README
821 +
822 + insinto /etc/openldap/schema
823 + newins "${DISTDIR}"/${BIS_P} ${BIS_PN}
824 +
825 + docinto back-sock ; dodoc "${S}"/servers/slapd/back-sock/searchexample*
826 + docinto back-shell ; dodoc "${S}"/servers/slapd/back-shell/searchexample*
827 + docinto back-perl ; dodoc "${S}"/servers/slapd/back-perl/SampleLDAP.pm
828 +
829 + dosbin "${S}"/contrib/slapd-tools/statslog
830 + newdoc "${S}"/contrib/slapd-tools/README README.statslog
831 + fi
832 +}
833 +
834 +multilib_src_install_all() {
835 + dodoc ANNOUNCEMENT CHANGES COPYRIGHT README
836 + docinto rfc ; dodoc doc/rfc/*.txt
837 +}
838 +
839 +pkg_preinst() {
840 + # keep old libs if any
841 + preserve_old_lib /usr/$(get_libdir)/{liblber,libldap_r,liblber}-2.3$(get_libname 0)
842 + # bug 440470, only display the getting started help there was no openldap before,
843 + # or we are going to a non-minimal build
844 + ! has_version net-nds/openldap || has_version 'net-nds/openldap[minimal]'
845 + OPENLDAP_PRINT_MESSAGES=$((! $?))
846 +}
847 +
848 +pkg_postinst() {
849 + if ! use minimal ; then
850 + # You cannot build SSL certificates during src_install that will make
851 + # binary packages containing your SSL key, which is both a security risk
852 + # and a misconfiguration if multiple machines use the same key and cert.
853 + if use ssl; then
854 + install_cert /etc/openldap/ssl/ldap
855 + use prefix || chown ldap:ldap "${EROOT}"etc/openldap/ssl/ldap.*
856 + ewarn "Self-signed SSL certificates are treated harshly by OpenLDAP 2.[12]"
857 + ewarn "Self-signed SSL certificates are treated harshly by OpenLDAP 2.[12]"
858 + ewarn "add 'TLS_REQCERT allow' if you want to use them."
859 + fi
860 +
861 + if use prefix; then
862 + # Warn about prefix issues with slapd
863 + eerror "slapd might NOT be usable on Prefix systems as it requires root privileges"
864 + eerror "to start up, and requires that certain files directories be owned by"
865 + eerror "ldap:ldap. As Prefix does not support changing ownership of files and"
866 + eerror "directories, you will have to manually fix this yourself."
867 + fi
868 +
869 + # These lines force the permissions of various content to be correct
870 + use prefix || chown ldap:ldap "${EROOT}"var/run/openldap
871 + chmod 0755 "${EROOT}"var/run/openldap
872 + use prefix || chown root:ldap "${EROOT}"etc/openldap/slapd.conf{,.default}
873 + chmod 0640 "${EROOT}"etc/openldap/slapd.conf{,.default}
874 + use prefix || chown ldap:ldap "${EROOT}"var/lib/openldap-data
875 + fi
876 +
877 + if has_version 'net-nds/openldap[-minimal]' && ((${OPENLDAP_PRINT_MESSAGES})); then
878 + elog "Getting started using OpenLDAP? There is some documentation available:"
879 + elog "Gentoo Guide to OpenLDAP Authentication"
880 + elog "(https://www.gentoo.org/doc/en/ldap-howto.xml)"
881 + elog "---"
882 + elog "An example file for tuning BDB backends with openldap is"
883 + elog "DB_CONFIG.fast.example in /usr/share/doc/${PF}/"
884 + fi
885 +
886 + preserve_old_lib_notify /usr/$(get_libdir)/{liblber,libldap,libldap_r}-2.3$(get_libname 0)
887 +}