Gentoo Archives: gentoo-commits

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