Gentoo Archives: gentoo-commits

From: Aaron Bauman <bman@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-nds/openldap/
Date: Sat, 16 Feb 2019 18:58:42
Message-Id: 1550343501.dd4a2dc7b7fd4832775fb65241d78371643014b6.bman@gentoo
1 commit: dd4a2dc7b7fd4832775fb65241d78371643014b6
2 Author: Stefan Strogin <stefan.strogin <AT> gmail <DOT> com>
3 AuthorDate: Sat Feb 16 07:47:09 2019 +0000
4 Commit: Aaron Bauman <bman <AT> gentoo <DOT> org>
5 CommitDate: Sat Feb 16 18:58:21 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dd4a2dc7
7
8 net-nds/openldap: add missing slot operator for libressl dependency
9
10 Package-Manager: Portage-2.3.60, Repoman-2.3.12
11 Signed-off-by: Stefan Strogin <stefan.strogin <AT> gmail.com>
12 Closes: https://github.com/gentoo/gentoo/pull/11070
13 Signed-off-by: Aaron Bauman <bman <AT> gentoo.org>
14
15 net-nds/openldap/openldap-2.4.45-r1.ebuild | 880 +++++++++++++++++++++++++++++
16 1 file changed, 880 insertions(+)
17
18 diff --git a/net-nds/openldap/openldap-2.4.45-r1.ebuild b/net-nds/openldap/openldap-2.4.45-r1.ebuild
19 new file mode 100644
20 index 00000000000..7d16acea025
21 --- /dev/null
22 +++ b/net-nds/openldap/openldap-2.4.45-r1.ebuild
23 @@ -0,0 +1,880 @@
24 +# Copyright 1999-2019 Gentoo Authors
25 +# Distributed under the terms of the GNU General Public License v2
26 +
27 +EAPI="5"
28 +
29 +inherit db-use eutils flag-o-matic multilib multilib-minimal ssl-cert versionator toolchain-funcs autotools user systemd
30 +
31 +BIS_PN=rfc2307bis.schema
32 +BIS_PV=20140524
33 +BIS_P="${BIS_PN}-${BIS_PV}"
34 +
35 +DESCRIPTION="LDAP suite of application and development tools"
36 +HOMEPAGE="http://www.OpenLDAP.org/"
37 +
38 +# mirrors are mostly not working, using canonical URI
39 +SRC_URI="ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/${P}.tgz
40 + mirror://gentoo/${BIS_P}"
41 +
42 +LICENSE="OPENLDAP GPL-2"
43 +SLOT="0"
44 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~x86-solaris"
45 +
46 +IUSE_DAEMON="crypt samba slp tcpd experimental minimal"
47 +IUSE_BACKEND="+berkdb"
48 +IUSE_OVERLAY="overlays perl"
49 +IUSE_OPTIONAL="gnutls iodbc sasl ssl odbc debug ipv6 libressl +syslog selinux static-libs"
50 +IUSE_CONTRIB="smbkrb5passwd kerberos kinit pbkdf2 sha2"
51 +IUSE_CONTRIB="${IUSE_CONTRIB} -cxx"
52 +IUSE="${IUSE_DAEMON} ${IUSE_BACKEND} ${IUSE_OVERLAY} ${IUSE_OPTIONAL} ${IUSE_CONTRIB}"
53 +
54 +REQUIRED_USE="cxx? ( sasl )
55 + ?? ( gnutls libressl )
56 + pbkdf2? ( ssl )"
57 +
58 +# always list newer first
59 +# Do not add any AGPL-3 BDB here!
60 +# See bug 525110, comment 15.
61 +# Advanced usage: OPENLDAP_BDB_SLOTS in the environment can be used to force a slot during build.
62 +BDB_SLOTS="${OPENLDAP_BDB_SLOTS:=5.3 5.1 4.8 4.7 4.6 4.5 4.4}"
63 +BDB_PKGS=''
64 +for _slot in $BDB_SLOTS; do BDB_PKGS="${BDB_PKGS} sys-libs/db:${_slot}" ; done
65 +
66 +# openssl is needed to generate lanman-passwords required by samba
67 +CDEPEND="
68 + ssl? (
69 + !gnutls? (
70 + !libressl? ( >=dev-libs/openssl-1.0.1h-r2:0=[${MULTILIB_USEDEP}] )
71 + )
72 + gnutls? ( >=net-libs/gnutls-2.12.23-r6[${MULTILIB_USEDEP}]
73 + libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP}] )
74 + >=dev-libs/libgcrypt-1.5.3:0[${MULTILIB_USEDEP}] ) )
75 + sasl? ( dev-libs/cyrus-sasl:= )
76 + !minimal? (
77 + sys-devel/libtool
78 + sys-libs/e2fsprogs-libs
79 + >=dev-db/lmdb-0.9.18:=
80 + tcpd? ( sys-apps/tcp-wrappers )
81 + odbc? ( !iodbc? ( dev-db/unixODBC )
82 + iodbc? ( dev-db/libiodbc ) )
83 + slp? ( net-libs/openslp )
84 + perl? ( dev-lang/perl:=[-build(-)] )
85 + samba? (
86 + !libressl? ( dev-libs/openssl:0= )
87 + libressl? ( dev-libs/libressl:0= )
88 + )
89 + berkdb? (
90 + <sys-libs/db-6.0:=
91 + || ( ${BDB_PKGS} )
92 + )
93 + smbkrb5passwd? (
94 + !libressl? ( dev-libs/openssl:0= )
95 + libressl? ( dev-libs/libressl:0= )
96 + kerberos? ( app-crypt/heimdal )
97 + )
98 + kerberos? (
99 + virtual/krb5
100 + kinit? ( !app-crypt/heimdal )
101 + )
102 + cxx? ( dev-libs/cyrus-sasl:= )
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/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[minimal]' ; then
319 + einfo "Skipping scan for previous datadirs as requested by minimal useflag"
320 + else
321 + openldap_find_versiontags
322 + fi
323 +
324 + # The user/group are only used for running daemons which are
325 + # disabled in minimal builds, so elide the accounts too.
326 + if ! use minimal ; then
327 + enewgroup ldap 439
328 + enewuser ldap 439 -1 /usr/$(get_libdir)/openldap ldap
329 + fi
330 +}
331 +
332 +src_prepare() {
333 + # ensure correct SLAPI path by default
334 + sed -i -e 's,\(#define LDAPI_SOCK\).*,\1 "'"${EPREFIX}"'/var/run/openldap/slapd.sock",' \
335 + "${S}"/include/ldap_defaults.h
336 +
337 + epatch "${FILESDIR}"/${PN}-2.4.17-gcc44.patch
338 +
339 + epatch \
340 + "${FILESDIR}"/${PN}-2.2.14-perlthreadsfix.patch \
341 + "${FILESDIR}"/${PN}-2.4.15-ppolicy.patch
342 +
343 + # bug #116045 - still present in 2.4.28
344 + epatch "${FILESDIR}"/${PN}-2.4.35-contrib-smbk5pwd.patch
345 + # bug #408077 - samba4
346 + epatch "${FILESDIR}"/${PN}-2.4.35-contrib-samba4.patch
347 +
348 + # bug #189817
349 + epatch "${FILESDIR}"/${PN}-2.4.11-libldap_r.patch
350 +
351 + # bug #233633
352 + epatch "${FILESDIR}"/${PN}-2.4.45-fix-lmpasswd-gnutls-symbols.patch
353 +
354 + # bug #281495
355 + epatch "${FILESDIR}"/${PN}-2.4.28-gnutls-gcrypt.patch
356 +
357 + # bug #294350
358 + epatch "${FILESDIR}"/${PN}-2.4.6-evolution-ntlm.patch
359 +
360 + # unbreak /bin/sh -> dash
361 + epatch "${FILESDIR}"/${PN}-2.4.28-fix-dash.patch
362 +
363 + # bug #420959
364 + epatch "${FILESDIR}"/${PN}-2.4.31-gcc47.patch
365 +
366 + # bug #622464
367 + epatch "${FILESDIR}"/${PN}-2.4.45-libressl.patch
368 +
369 + # unbundle lmdb
370 + epatch "${FILESDIR}"/${PN}-2.4.42-mdb-unbundle.patch
371 + rm -rf "${S}"/libraries/liblmdb
372 +
373 + epatch_user
374 +
375 + cd "${S}"/build || die
376 + einfo "Making sure upstream build strip does not do stripping too early"
377 + sed -i.orig \
378 + -e '/^STRIP/s,-s,,g' \
379 + top.mk || die "Failed to block stripping"
380 +
381 + # wrong assumption that /bin/sh is /bin/bash
382 + sed -i \
383 + -e 's|/bin/sh|/bin/bash|g' \
384 + "${S}"/tests/scripts/* || die "sed failed"
385 +
386 + cd "${S}" || die
387 +
388 + AT_NOEAUTOMAKE=yes eautoreconf
389 +}
390 +
391 +build_contrib_module() {
392 + # <dir> <sources> <outputname>
393 + cd "${S}/contrib/slapd-modules/$1" || die
394 + einfo "Compiling contrib-module: $3"
395 + # Make sure it's uppercase
396 + local define_name="$(echo "SLAPD_OVER_${1}" | LC_ALL=C tr '[:lower:]' '[:upper:]')"
397 + "${lt}" --mode=compile --tag=CC \
398 + "${CC}" \
399 + -D${define_name}=SLAPD_MOD_DYNAMIC \
400 + -I"${BUILD_DIR}"/include \
401 + -I../../../include -I../../../servers/slapd ${CFLAGS} \
402 + -o ${2%.c}.lo -c $2 || die "compiling $3 failed"
403 + einfo "Linking contrib-module: $3"
404 + "${lt}" --mode=link --tag=CC \
405 + "${CC}" -module \
406 + ${CFLAGS} \
407 + ${LDFLAGS} \
408 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
409 + -o $3.la ${2%.c}.lo || die "linking $3 failed"
410 +}
411 +
412 +src_configure() {
413 + # Bug 408001
414 + use elibc_FreeBSD && append-cppflags -DMDB_DSYNC=O_SYNC -DMDB_FDATASYNC=fsync
415 +
416 + # connectionless ldap per bug #342439
417 + append-cppflags -DLDAP_CONNECTIONLESS
418 +
419 + multilib-minimal_src_configure
420 +}
421 +
422 +multilib_src_configure() {
423 + local myconf=()
424 +
425 + use debug && myconf+=( $(use_enable debug) )
426 +
427 + # ICU exists only in the configure, nowhere in the codebase, bug #510858
428 + export ac_cv_header_unicode_utypes_h=no ol_cv_lib_icu=no
429 +
430 + if ! use minimal && multilib_is_native_abi; then
431 + local CPPFLAGS=${CPPFLAGS}
432 +
433 + # re-enable serverside overlay chains per bug #296567
434 + # see ldap docs chaper 12.3.1 for details
435 + myconf+=( --enable-ldap )
436 +
437 + # backends
438 + myconf+=( --enable-slapd )
439 + if use berkdb ; then
440 + einfo "Using Berkeley DB for local backend"
441 + myconf+=( --enable-bdb --enable-hdb )
442 + DBINCLUDE=$(db_includedir $BDB_SLOTS)
443 + einfo "Using $DBINCLUDE for sys-libs/db version"
444 + # We need to include the slotted db.h dir for FreeBSD
445 + append-cppflags -I${DBINCLUDE}
446 + else
447 + myconf+=( --disable-bdb --disable-hdb )
448 + fi
449 + for backend in dnssrv ldap mdb meta monitor null passwd relay shell sock; do
450 + myconf+=( --enable-${backend}=mod )
451 + done
452 +
453 + myconf+=( $(use_enable perl perl mod) )
454 +
455 + myconf+=( $(use_enable odbc sql mod) )
456 + if use odbc ; then
457 + local odbc_lib="unixodbc"
458 + if use iodbc ; then
459 + odbc_lib="iodbc"
460 + append-cppflags -I"${EPREFIX}"/usr/include/iodbc
461 + fi
462 + myconf+=( --with-odbc=${odbc_lib} )
463 + fi
464 +
465 + # slapd options
466 + myconf+=(
467 + $(use_enable crypt)
468 + $(use_enable slp)
469 + $(use_enable samba lmpasswd)
470 + $(use_enable syslog)
471 + )
472 + if use experimental ; then
473 + myconf+=(
474 + --enable-dynacl
475 + --enable-aci=mod
476 + )
477 + fi
478 + for option in aci cleartext modules rewrite rlookups slapi; do
479 + myconf+=( --enable-${option} )
480 + done
481 +
482 + # slapd overlay options
483 + # Compile-in the syncprov, the others as module
484 + myconf+=( --enable-syncprov=yes )
485 + use overlays && myconf+=( --enable-overlays=mod )
486 +
487 + else
488 + myconf+=(
489 + --disable-backends
490 + --disable-slapd
491 + --disable-bdb
492 + --disable-hdb
493 + --disable-mdb
494 + --disable-overlays
495 + --disable-syslog
496 + )
497 + fi
498 +
499 + # basic functionality stuff
500 + myconf+=(
501 + $(use_enable ipv6)
502 + $(multilib_native_use_with sasl cyrus-sasl)
503 + $(multilib_native_use_enable sasl spasswd)
504 + $(use_enable tcpd wrappers)
505 + )
506 +
507 + # Some cross-compiling tests don't pan out well.
508 + tc-is-cross-compiler && myconf+=(
509 + --with-yielding-select=yes
510 + )
511 +
512 + local ssl_lib="no"
513 + if use ssl || ( ! use minimal && use samba ) ; then
514 + ssl_lib="openssl"
515 + use gnutls && ssl_lib="gnutls"
516 + fi
517 +
518 + myconf+=( --with-tls=${ssl_lib} )
519 +
520 + for basicflag in dynamic local proctitle shared; do
521 + myconf+=( --enable-${basicflag} )
522 + done
523 +
524 + tc-export AR CC CXX
525 + ECONF_SOURCE=${S} \
526 + STRIP=/bin/true \
527 + econf \
528 + --libexecdir="${EPREFIX}"/usr/$(get_libdir)/openldap \
529 + $(use_enable static-libs static) \
530 + "${myconf[@]}"
531 + emake depend
532 +}
533 +
534 +src_configure_cxx() {
535 + # This needs the libraries built by the first build run.
536 + # So we have to run it AFTER the main build, not just after the main
537 + # configure.
538 + local myconf_ldapcpp=(
539 + --with-ldap-includes="${S}"/include
540 + )
541 +
542 + mkdir -p "${BUILD_DIR}"/contrib/ldapc++ || die
543 + cd "${BUILD_DIR}/contrib/ldapc++" || die
544 +
545 + local LDFLAGS=${LDFLAGS} CPPFLAGS=${CPPFLAGS}
546 + append-ldflags -L"${BUILD_DIR}"/libraries/liblber/.libs \
547 + -L"${BUILD_DIR}"/libraries/libldap/.libs
548 + append-cppflags -I"${BUILD_DIR}"/include
549 + ECONF_SOURCE=${S}/contrib/ldapc++ \
550 + econf "${myconf_ldapcpp[@]}" \
551 + CC="${CC}" \
552 + CXX="${CXX}"
553 +}
554 +
555 +multilib_src_compile() {
556 + tc-export AR CC CXX
557 + emake CC="${CC}" AR="${AR}" SHELL="${EPREFIX}"/bin/bash
558 + local lt="${BUILD_DIR}/libtool"
559 + export echo="echo"
560 +
561 + if ! use minimal && multilib_is_native_abi ; then
562 + if use cxx ; then
563 + einfo "Building contrib library: ldapc++"
564 + src_configure_cxx
565 + cd "${BUILD_DIR}/contrib/ldapc++" || die
566 + emake \
567 + CC="${CC}" CXX="${CXX}"
568 + fi
569 +
570 + if use smbkrb5passwd ; then
571 + einfo "Building contrib-module: smbk5pwd"
572 + cd "${S}/contrib/slapd-modules/smbk5pwd" || die
573 +
574 + MY_DEFS="-DDO_SHADOW"
575 + if use samba ; then
576 + MY_DEFS="${MY_DEFS} -DDO_SAMBA"
577 + MY_KRB5_INC=""
578 + fi
579 + if use kerberos ; then
580 + MY_DEFS="${MY_DEFS} -DDO_KRB5"
581 + MY_KRB5_INC="$(krb5-config --cflags)"
582 + fi
583 +
584 + emake \
585 + DEFS="${MY_DEFS}" \
586 + KRB5_INC="${MY_KRB5_INC}" \
587 + LDAP_BUILD="${BUILD_DIR}" \
588 + CC="${CC}" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap"
589 + fi
590 +
591 + if use overlays ; then
592 + einfo "Building contrib-module: samba4"
593 + cd "${S}/contrib/slapd-modules/samba4" || die
594 +
595 + emake \
596 + LDAP_BUILD="${BUILD_DIR}" \
597 + CC="${CC}" libexecdir="/usr/$(get_libdir)/openldap"
598 + fi
599 +
600 + if use kerberos ; then
601 + if use kinit ; then
602 + build_contrib_module "kinit" "kinit.c" "kinit"
603 + fi
604 + cd "${S}/contrib/slapd-modules/passwd" || die
605 + einfo "Compiling contrib-module: pw-kerberos"
606 + "${lt}" --mode=compile --tag=CC \
607 + "${CC}" \
608 + -I"${BUILD_DIR}"/include \
609 + -I../../../include \
610 + ${CFLAGS} \
611 + $(krb5-config --cflags) \
612 + -DHAVE_KRB5 \
613 + -o kerberos.lo \
614 + -c kerberos.c || die "compiling pw-kerberos failed"
615 + einfo "Linking contrib-module: pw-kerberos"
616 + "${lt}" --mode=link --tag=CC \
617 + "${CC}" -module \
618 + ${CFLAGS} \
619 + ${LDFLAGS} \
620 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
621 + -o pw-kerberos.la \
622 + kerberos.lo || die "linking pw-kerberos failed"
623 + fi
624 +
625 + if use pbkdf2; then
626 + cd "${S}/contrib/slapd-modules/passwd/pbkdf2" || die
627 + einfo "Compiling contrib-module: pw-pbkdf2"
628 + "${lt}" --mode=compile --tag=CC \
629 + "${CC}" \
630 + -I"${BUILD_DIR}"/include \
631 + -I../../../../include \
632 + ${CFLAGS} \
633 + -o pbkdf2.lo \
634 + -c pw-pbkdf2.c || die "compiling pw-pbkdf2 failed"
635 + einfo "Linking contrib-module: pw-pbkdf2"
636 + "${lt}" --mode=link --tag=CC \
637 + "${CC}" -module \
638 + ${CFLAGS} \
639 + ${LDFLAGS} \
640 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
641 + -o pw-pbkdf2.la \
642 + pbkdf2.lo || die "linking pw-pbkdf2 failed"
643 + fi
644 +
645 + if use sha2 ; then
646 + cd "${S}/contrib/slapd-modules/passwd/sha2" || die
647 + einfo "Compiling contrib-module: pw-sha2"
648 + "${lt}" --mode=compile --tag=CC \
649 + "${CC}" \
650 + -I"${BUILD_DIR}"/include \
651 + -I../../../../include \
652 + ${CFLAGS} \
653 + -o sha2.lo \
654 + -c sha2.c || die "compiling pw-sha2 failed"
655 + "${lt}" --mode=compile --tag=CC \
656 + "${CC}" \
657 + -I"${BUILD_DIR}"/include \
658 + -I../../../../include \
659 + ${CFLAGS} \
660 + -o slapd-sha2.lo \
661 + -c slapd-sha2.c || die "compiling pw-sha2 failed"
662 + einfo "Linking contrib-module: pw-sha2"
663 + "${lt}" --mode=link --tag=CC \
664 + "${CC}" -module \
665 + ${CFLAGS} \
666 + ${LDFLAGS} \
667 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
668 + -o pw-sha2.la \
669 + sha2.lo slapd-sha2.lo || die "linking pw-sha2 failed"
670 + fi
671 +
672 + # We could build pw-radius if GNURadius would install radlib.h
673 + cd "${S}/contrib/slapd-modules/passwd" || die
674 + einfo "Compiling contrib-module: pw-netscape"
675 + "${lt}" --mode=compile --tag=CC \
676 + "${CC}" \
677 + -I"${BUILD_DIR}"/include \
678 + -I../../../include \
679 + ${CFLAGS} \
680 + -o netscape.lo \
681 + -c netscape.c || die "compiling pw-netscape failed"
682 + einfo "Linking contrib-module: pw-netscape"
683 + "${lt}" --mode=link --tag=CC \
684 + "${CC}" -module \
685 + ${CFLAGS} \
686 + ${LDFLAGS} \
687 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
688 + -o pw-netscape.la \
689 + netscape.lo || die "linking pw-netscape failed"
690 +
691 + #build_contrib_module "acl" "posixgroup.c" "posixGroup" # example code only
692 + #build_contrib_module "acl" "gssacl.c" "gss" # example code only, also needs kerberos
693 + build_contrib_module "addpartial" "addpartial-overlay.c" "addpartial-overlay"
694 + build_contrib_module "allop" "allop.c" "overlay-allop"
695 + build_contrib_module "allowed" "allowed.c" "allowed"
696 + build_contrib_module "autogroup" "autogroup.c" "autogroup"
697 + build_contrib_module "cloak" "cloak.c" "cloak"
698 + # build_contrib_module "comp_match" "comp_match.c" "comp_match" # really complex, adds new external deps, questionable demand
699 + build_contrib_module "denyop" "denyop.c" "denyop-overlay"
700 + build_contrib_module "dsaschema" "dsaschema.c" "dsaschema-plugin"
701 + build_contrib_module "dupent" "dupent.c" "dupent"
702 + build_contrib_module "lastbind" "lastbind.c" "lastbind"
703 + # lastmod may not play well with other overlays
704 + build_contrib_module "lastmod" "lastmod.c" "lastmod"
705 + build_contrib_module "noopsrch" "noopsrch.c" "noopsrch"
706 + build_contrib_module "nops" "nops.c" "nops-overlay"
707 + #build_contrib_module "nssov" "nssov.c" "nssov-overlay" RESO:LATER
708 + build_contrib_module "trace" "trace.c" "trace"
709 + # build slapi-plugins
710 + cd "${S}/contrib/slapi-plugins/addrdnvalues" || die
711 + einfo "Building contrib-module: addrdnvalues plugin"
712 + "${CC}" -shared \
713 + -I"${BUILD_DIR}"/include \
714 + -I../../../include \
715 + ${CFLAGS} \
716 + -fPIC \
717 + ${LDFLAGS} \
718 + -o libaddrdnvalues-plugin.so \
719 + addrdnvalues.c || die "Building libaddrdnvalues-plugin.so failed"
720 +
721 + fi
722 +}
723 +
724 +multilib_src_test() {
725 + if multilib_is_native_abi; then
726 + cd tests || die
727 + emake tests || die "make tests failed"
728 + fi
729 +}
730 +
731 +multilib_src_install() {
732 + local lt="${BUILD_DIR}/libtool"
733 + emake DESTDIR="${D}" SHELL="${EPREFIX}"/bin/bash install
734 +
735 + if ! use minimal && multilib_is_native_abi; then
736 + # openldap modules go here
737 + # TODO: write some code to populate slapd.conf with moduleload statements
738 + keepdir /usr/$(get_libdir)/openldap/openldap/
739 +
740 + # initial data storage dir
741 + keepdir /var/lib/openldap-data
742 + use prefix || fowners ldap:ldap /var/lib/openldap-data
743 + fperms 0700 /var/lib/openldap-data
744 +
745 + echo "OLDPF='${PF}'" > "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}"
746 + echo "# do NOT delete this. it is used" >> "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}"
747 + echo "# to track versions for upgrading." >> "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}"
748 +
749 + # use our config
750 + rm "${ED}"etc/openldap/slapd.conf
751 + insinto /etc/openldap
752 + newins "${FILESDIR}"/${PN}-2.4.40-slapd-conf slapd.conf
753 + configfile="${ED}"etc/openldap/slapd.conf
754 +
755 + # populate with built backends
756 + ebegin "populate config with built backends"
757 + for x in "${ED}"usr/$(get_libdir)/openldap/openldap/back_*.so; do
758 + einfo "Adding $(basename ${x})"
759 + sed -e "/###INSERTDYNAMICMODULESHERE###$/a# moduleload\t$(basename ${x})" -i "${configfile}"
760 + done
761 + sed -e "s:###INSERTDYNAMICMODULESHERE###$:# modulepath\t${EPREFIX}/usr/$(get_libdir)/openldap/openldap:" -i "${configfile}"
762 + use prefix || fowners root:ldap /etc/openldap/slapd.conf
763 + fperms 0640 /etc/openldap/slapd.conf
764 + cp "${configfile}" "${configfile}".default
765 + eend
766 +
767 + # install our own init scripts and systemd unit files
768 + einfo "Install init scripts"
769 + sed -e "s,/usr/lib/,/usr/$(get_libdir)/," "${FILESDIR}"/slapd-initd-2.4.40-r2 > "${T}"/slapd || die
770 + doinitd "${T}"/slapd
771 + newconfd "${FILESDIR}"/slapd-confd-2.4.28-r1 slapd
772 +
773 + einfo "Install systemd service"
774 + sed -e "s,/usr/lib/,/usr/$(get_libdir)/," "${FILESDIR}"/slapd.service > "${T}"/slapd.service || die
775 + systemd_dounit "${T}"/slapd.service
776 + systemd_install_serviced "${FILESDIR}"/slapd.service.conf
777 + systemd_newtmpfilesd "${FILESDIR}"/slapd.tmpfilesd slapd.conf
778 +
779 + # If built without SLP, we don't need to be before avahi
780 + use slp \
781 + || sed -i \
782 + -e '/before/{s/avahi-daemon//g}' \
783 + "${ED}"etc/init.d/slapd
784 +
785 + if use cxx ; then
786 + einfo "Install the ldapc++ library"
787 + cd "${BUILD_DIR}/contrib/ldapc++" || die
788 + emake DESTDIR="${D}" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" install
789 + cd "${S}"/contrib/ldapc++ || die
790 + newdoc README ldapc++-README
791 + fi
792 +
793 + if use smbkrb5passwd ; then
794 + einfo "Install the smbk5pwd module"
795 + cd "${S}/contrib/slapd-modules/smbk5pwd" || die
796 + emake DESTDIR="${D}" \
797 + LDAP_BUILD="${BUILD_DIR}" \
798 + libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" install
799 + newdoc README smbk5pwd-README
800 + fi
801 +
802 + if use overlays ; then
803 + einfo "Install the samba4 module"
804 + cd "${S}/contrib/slapd-modules/samba4" || die
805 + emake DESTDIR="${D}" \
806 + LDAP_BUILD="${BUILD_DIR}" \
807 + libexecdir="/usr/$(get_libdir)/openldap" install
808 + newdoc README samba4-README
809 + fi
810 +
811 + einfo "Installing contrib modules"
812 + cd "${S}/contrib/slapd-modules" || die
813 + for l in */*.la */*/*.la; do
814 + [[ -e ${l} ]] || continue
815 + "${lt}" --mode=install cp ${l} \
816 + "${ED}"usr/$(get_libdir)/openldap/openldap || \
817 + die "installing ${l} failed"
818 + done
819 +
820 + dodoc "${FILESDIR}"/DB_CONFIG.fast.example
821 + docinto contrib
822 + doman */*.5
823 + #newdoc acl/README*
824 + newdoc addpartial/README addpartial-README
825 + newdoc allop/README allop-README
826 + newdoc allowed/README allowed-README
827 + newdoc autogroup/README autogroup-README
828 + newdoc dsaschema/README dsaschema-README
829 + newdoc passwd/README passwd-README
830 + cd "${S}/contrib/slapi-plugins" || die
831 + insinto /usr/$(get_libdir)/openldap/openldap
832 + doins */*.so
833 + docinto contrib
834 + newdoc addrdnvalues/README addrdnvalues-README
835 +
836 + insinto /etc/openldap/schema
837 + newins "${DISTDIR}"/${BIS_P} ${BIS_PN}
838 +
839 + docinto back-sock ; dodoc "${S}"/servers/slapd/back-sock/searchexample*
840 + docinto back-shell ; dodoc "${S}"/servers/slapd/back-shell/searchexample*
841 + docinto back-perl ; dodoc "${S}"/servers/slapd/back-perl/SampleLDAP.pm
842 +
843 + dosbin "${S}"/contrib/slapd-tools/statslog
844 + newdoc "${S}"/contrib/slapd-tools/README README.statslog
845 + fi
846 +
847 + use static-libs || prune_libtool_files --all
848 +}
849 +
850 +multilib_src_install_all() {
851 + dodoc ANNOUNCEMENT CHANGES COPYRIGHT README
852 + docinto rfc ; dodoc doc/rfc/*.txt
853 +}
854 +
855 +pkg_preinst() {
856 + # keep old libs if any
857 + preserve_old_lib /usr/$(get_libdir)/{liblber,libldap_r,liblber}-2.3$(get_libname 0)
858 + # bug 440470, only display the getting started help there was no openldap before,
859 + # or we are going to a non-minimal build
860 + ! has_version net-nds/openldap || has_version 'net-nds/openldap[minimal]'
861 + OPENLDAP_PRINT_MESSAGES=$((! $?))
862 +}
863 +
864 +pkg_postinst() {
865 + if ! use minimal ; then
866 + # You cannot build SSL certificates during src_install that will make
867 + # binary packages containing your SSL key, which is both a security risk
868 + # and a misconfiguration if multiple machines use the same key and cert.
869 + if use ssl; then
870 + install_cert /etc/openldap/ssl/ldap
871 + use prefix || chown ldap:ldap "${EROOT}"etc/openldap/ssl/ldap.*
872 + ewarn "Self-signed SSL certificates are treated harshly by OpenLDAP 2.[12]"
873 + ewarn "Self-signed SSL certificates are treated harshly by OpenLDAP 2.[12]"
874 + ewarn "add 'TLS_REQCERT allow' if you want to use them."
875 + fi
876 +
877 + if use prefix; then
878 + # Warn about prefix issues with slapd
879 + eerror "slapd might NOT be usable on Prefix systems as it requires root privileges"
880 + eerror "to start up, and requires that certain files directories be owned by"
881 + eerror "ldap:ldap. As Prefix does not support changing ownership of files and"
882 + eerror "directories, you will have to manually fix this yourself."
883 + fi
884 +
885 + # These lines force the permissions of various content to be correct
886 + use prefix || chown ldap:ldap "${EROOT}"var/run/openldap
887 + chmod 0755 "${EROOT}"var/run/openldap
888 + use prefix || chown root:ldap "${EROOT}"etc/openldap/slapd.conf{,.default}
889 + chmod 0640 "${EROOT}"etc/openldap/slapd.conf{,.default}
890 + use prefix || chown ldap:ldap "${EROOT}"var/lib/openldap-data
891 + fi
892 +
893 + if has_version 'net-nds/openldap[-minimal]' && ((${OPENLDAP_PRINT_MESSAGES})); then
894 + elog "Getting started using OpenLDAP? There is some documentation available:"
895 + elog "Gentoo Guide to OpenLDAP Authentication"
896 + elog "(https://wiki.gentoo.org/wiki/Centralized_authentication_using_OpenLDAP)"
897 + elog "---"
898 + elog "An example file for tuning BDB backends with openldap is"
899 + elog "DB_CONFIG.fast.example in /usr/share/doc/${PF}/"
900 + fi
901 +
902 + preserve_old_lib_notify /usr/$(get_libdir)/{liblber,libldap,libldap_r}-2.3$(get_libname 0)
903 +}