Gentoo Archives: gentoo-commits

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