Gentoo Archives: gentoo-commits

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