Gentoo Archives: gentoo-commits

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