Diff openldap-2.4.59-r2 with a openldap-2.5.14

/usr/portage/net-nds/openldap/openldap-2.5.14.ebuild 2024-12-25 14:59:51.275270145 +0300
1
# Copyright 1999-2024 Gentoo Authors
1
# Copyright 1999-2023 Gentoo Authors
2 2
# Distributed under the terms of the GNU General Public License v2
3 3

  
4 4
EAPI=7
......
6 6
# Re cleanups:
7 7
# 2.5.x is an LTS release so we want to keep it for a while.
8 8

  
9
inherit autotools db-use flag-o-matic multilib multilib-minimal preserve-libs ssl-cert toolchain-funcs systemd tmpfiles
9
inherit autotools flag-o-matic multilib multilib-minimal preserve-libs ssl-cert toolchain-funcs systemd tmpfiles
10

  
11
MY_PV="$(ver_rs 1-2 _)"
10 12

  
11 13
BIS_PN=rfc2307bis.schema
12 14
BIS_PV=20140524
......
14 16

  
15 17
DESCRIPTION="LDAP suite of application and development tools"
16 18
HOMEPAGE="https://www.openldap.org/"
17

  
18
# upstream mirrors are mostly not working, using canonical URI
19 19
SRC_URI="
20
	https://openldap.org/software/download/OpenLDAP/openldap-release/${P}.tgz
21
	http://gpl.savoirfairelinux.net/pub/mirrors/openldap/openldap-release/${P}.tgz
22
	http://repository.linagora.org/OpenLDAP/openldap-release/${P}.tgz
23
	http://mirror.eu.oneandone.net/software/openldap/openldap-release/${P}.tgz
24
	mirror://gentoo/${BIS_P}"
20
	https://gitlab.com/openldap/${PN}/-/archive/OPENLDAP_REL_ENG_${MY_PV}/${PN}-OPENLDAP_REL_ENG_${MY_PV}.tar.bz2
21
	mirror://gentoo/${BIS_P}
22
"
23
S="${WORKDIR}"/${PN}-OPENLDAP_REL_ENG_${MY_PV}
25 24

  
26 25
LICENSE="OPENLDAP GPL-2"
27
SLOT="0"
28
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~mips ~ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux"
29

  
30
IUSE_DAEMON="crypt samba tcpd experimental minimal"
31
IUSE_BACKEND="+berkdb"
32
IUSE_OVERLAY="overlays perl"
33
IUSE_OPTIONAL="gnutls iodbc sasl ssl odbc debug ipv6 +syslog selinux static-libs test"
34
IUSE_CONTRIB="smbkrb5passwd kerberos kinit pbkdf2 sha2"
26
# Subslot added for bug #835654
27
SLOT="0/$(ver_cut 1-2)"
28
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~mips ~ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux"
29

  
30
IUSE_DAEMON="argon2 +cleartext crypt experimental minimal samba tcpd"
31
IUSE_OVERLAY="overlays perl autoca"
32
IUSE_OPTIONAL="debug gnutls iodbc ipv6 odbc sasl ssl selinux static-libs +syslog test"
33
IUSE_CONTRIB="kerberos kinit pbkdf2 sha2 smbkrb5passwd"
35 34
IUSE_CONTRIB="${IUSE_CONTRIB} cxx"
36
IUSE="${IUSE_DAEMON} ${IUSE_BACKEND} ${IUSE_OVERLAY} ${IUSE_OPTIONAL} ${IUSE_CONTRIB}"
35
IUSE="systemd ${IUSE_DAEMON} ${IUSE_BACKEND} ${IUSE_OVERLAY} ${IUSE_OPTIONAL} ${IUSE_CONTRIB}"
37 36
REQUIRED_USE="cxx? ( sasl )
38 37
	pbkdf2? ( ssl )
39
	test? ( berkdb )
38
	test? ( cleartext debug sasl )
39
	autoca? ( !gnutls )
40 40
	?? ( test minimal )
41 41
	kerberos? ( ?? ( kinit smbkrb5passwd ) )"
42 42
RESTRICT="!test? ( test )"
43 43

  
44
# always list newer first
45
# Do not add any AGPL-3 BDB here!
46
# See bug 525110, comment 15.
47
# Advanced usage: OPENLDAP_BDB_SLOTS in the environment can be used to force a slot during build.
48
BDB_SLOTS="${OPENLDAP_BDB_SLOTS:=5.3 4.8}"
49
BDB_PKGS=''
50
for _slot in $BDB_SLOTS; do BDB_PKGS="${BDB_PKGS} sys-libs/db:${_slot}" ; done
51

  
44
SYSTEM_LMDB_VER=0.9.30
52 45
# openssl is needed to generate lanman-passwords required by samba
53 46
COMMON_DEPEND="
47
	kernel_linux? ( sys-apps/util-linux )
54 48
	ssl? (
55 49
		!gnutls? (
56 50
			>=dev-libs/openssl-1.0.1h-r2:0=[${MULTILIB_USEDEP}]
......
64 58
	!minimal? (
65 59
		dev-libs/libltdl
66 60
		sys-fs/e2fsprogs
67
		>=dev-db/lmdb-0.9.18:=
61
		>=dev-db/lmdb-${SYSTEM_LMDB_VER}:=
62
		argon2? ( app-crypt/argon2:= )
68 63
		crypt? ( virtual/libcrypt:= )
69 64
		tcpd? ( sys-apps/tcp-wrappers )
70 65
		odbc? ( !iodbc? ( dev-db/unixODBC )
......
73 68
		samba? (
74 69
			dev-libs/openssl:0=
75 70
		)
76
		berkdb? (
77
			<sys-libs/db-6.0:=
78
			|| ( ${BDB_PKGS} )
79
			)
80 71
		smbkrb5passwd? (
81 72
			dev-libs/openssl:0=
82 73
			kerberos? ( app-crypt/heimdal )
83
			)
74
		)
84 75
		kerberos? (
85 76
			virtual/krb5
86 77
			kinit? ( !app-crypt/heimdal )
87
			)
88
		cxx? ( dev-libs/cyrus-sasl:= )
78
		)
89 79
	)
90 80
"
91 81
DEPEND="${COMMON_DEPEND}
......
146 136
)
147 137

  
148 138
PATCHES=(
149
	"${FILESDIR}"/${PN}-2.4.17-gcc44.patch
150

  
151
	"${FILESDIR}"/${PN}-2.2.14-perlthreadsfix.patch
152
	"${FILESDIR}"/${PN}-2.4.15-ppolicy.patch
153

  
154
	# bug #116045 - still present in 2.4.28
155
	"${FILESDIR}"/${PN}-2.4.35-contrib-smbk5pwd.patch
156
	# bug #408077 - samba4
157
	"${FILESDIR}"/${PN}-2.4.35-contrib-samba4.patch
158

  
159
	# bug #189817
160
	"${FILESDIR}"/${PN}-2.4.11-libldap_r.patch
161

  
162
	# bug #233633
163
	"${FILESDIR}"/${PN}-2.4.45-fix-lmpasswd-gnutls-symbols.patch
164

  
165
	# bug #281495
166
	"${FILESDIR}"/${PN}-2.4.28-gnutls-gcrypt.patch
167

  
168
	# bug #294350
169
	"${FILESDIR}"/${PN}-2.4.6-evolution-ntlm.patch
170

  
171
	# unbreak /bin/sh -> dash
172 139
	"${FILESDIR}"/${PN}-2.4.28-fix-dash.patch
173

  
174
	# bug #420959
175
	"${FILESDIR}"/${PN}-2.4.31-gcc47.patch
176

  
177
	# unbundle lmdb
178
	"${FILESDIR}"/${PN}-2.4.42-mdb-unbundle.patch
179

  
180
	# fix some compiler warnings
181
	"${FILESDIR}"/${PN}-2.4.47-warnings.patch
140
	"${FILESDIR}"/${PN}-2.6.1-system-mdb.patch
141
	"${FILESDIR}"/${PN}-2.6.1-cloak.patch
142
	"${FILESDIR}"/${PN}-2.6.1-flags.patch
143
	"${FILESDIR}"/${PN}-2.6.4-clang16.patch
144
	"${FILESDIR}"/${PN}-2.6.4-libressl.patch #903001
182 145
)
183 146

  
184 147
openldap_filecount() {
......
204 167
	openldap_found_tag=0
205 168
	have_files=0
206 169
	for each in ${openldap_datadirs[@]} ; do
207
		CURRENT_TAGDIR="${ROOT}$(sed "s:\/::" <<< ${each})"
170
		CURRENT_TAGDIR="${EROOT}$(sed "s:\/::" <<< ${each})"
208 171
		CURRENT_TAG="${CURRENT_TAGDIR}/${OPENLDAP_VERSIONTAG}"
209 172
		if [[ -d "${CURRENT_TAGDIR}" ]] && [[ "${openldap_found_tag}" == 0 ]] ; then
210 173
			einfo "- Checking ${each}..."
......
263 226
	[[ "${have_files}" == "1" ]] && einfo "DB files present" || einfo "No DB files present"
264 227

  
265 228
	# Now we must check for the major version of sys-libs/db linked against.
229
	# TODO: remove this as we dropped bdb support (gone upstream) in 2.6.1?
266 230
	SLAPD_PATH="${EROOT}/usr/$(get_libdir)/openldap/slapd"
267 231
	if [[ "${have_files}" == "1" ]] && [[ -f "${SLAPD_PATH}" ]]; then
268 232
		OLDVER="$(/usr/bin/ldd ${SLAPD_PATH} \
269 233
			| awk '/libdb-/{gsub("^libdb-","",$1);gsub(".so$","",$1);print $1}')"
270
		if use berkdb; then
271
			# find which one would be used
272
			for bdb_slot in ${BDB_SLOTS} ; do
273
				NEWVER="$(db_findver "=sys-libs/db-${bdb_slot}*")"
274
				[[ -n "${NEWVER}" ]] && break
275
			done
276
		fi
277 234
		local fail=0
278
		if [[ -z "${OLDVER}" ]] && [[ -z "${NEWVER}" ]]; then
235

  
236
		# This will not cover detection of cn=Config based configuration, but
237
		# it's hopefully good enough.
238
		if grep -sq '^backend.*shell' "${EROOT}"/etc/openldap/slapd.conf; then
239
			eerror "    OpenLDAP >= 2.6.x has dropped support for Shell backend."
240
			eerror "	You will need to migrate per upstream's migration notes"
241
			eerror "	at https://www.openldap.org/doc/admin25/appendix-upgrading.html."
242
			eerror "	Your existing database will not be accessible until it is"
243
			eerror "	converted away from backend shell!"
244
			echo
245
			fail=1
246
		fi
247
		if has_version "${CATEGORY}/${PN}[berkdb]" || grep -sq '^backend.*(bdb|hdb)' /etc/openldap/slapd.conf; then
248
			eerror "	OpenLDAP >= 2.5.x has dropped support for Berkeley DB."
249
			eerror "	You will need to migrate per upstream's migration notes"
250
			eerror "	at https://www.openldap.org/doc/admin25/appendix-upgrading.html."
251
			eerror "	Your existing database will not be accessible until it is"
252
			eerror "	converted to mdb!"
253
			echo
254
			fail=1
255
		elif [[ -z "${OLDVER}" ]] && [[ -z "${NEWVER}" ]]; then
279 256
			:
280 257
			# Nothing wrong here.
281 258
		elif [[ -z "${OLDVER}" ]] && [[ -n "${NEWVER}" ]]; then
......
331 308
	eerror " 7. slapadd -l ${l}"
332 309
	eerror " 8. chown ldap:ldap /var/lib/openldap-data/*"
333 310
	eerror " 9. /etc/init.d/slapd start"
334
	eerror "10. check that your data is intact."
335
	eerror "11. set up the new replication system."
311
	eerror "10. Check that your data is intact."
312
	eerror "11. Set up the new replication system."
336 313
	eerror
337 314
	if [[ "${FORCE_UPGRADE}" != "1" ]]; then
338 315
		die "You need to upgrade your database first"
......
357 334
}
358 335

  
359 336
src_prepare() {
360
	# ensure correct SLAPI path by default
361
	sed -e 's,\(#define LDAPI_SOCK\).*,\1 "'"${EPREFIX}"'/var/run/openldap/slapd.sock",' \
362
		-i include/ldap_defaults.h || die
337
	# The system copy of dev-db/lmdb must match the version that this copy
338
	# of OpenLDAP shipped with! See bug #588792.
339
	#
340
	# Fish out MDB_VERSION_MAJOR/MDB_VERSION_MINOR/MDB_VERSION_PATCH from
341
	# the bundled lmdb's header to find out the version.
342
	local bundled_lmdb_version=$(
343
		sed -En '/^#define MDB_VERSION_(MAJOR|MINOR|PATCH)(\s+)?/{s/[^0-9.]//gp}' \
344
			libraries/liblmdb/lmdb.h || die
345
		)
346
	printf -v bundled_lmdb_version "%s." ${bundled_lmdb_version}
347

  
348
	if [[ ${SYSTEM_LMDB_VER}. != ${bundled_lmdb_version} ]] ; then
349
		eerror "Source lmdb version: ${bundled_lmdb_version}"
350
		eerror "Ebuild lmdb version: ${SYSTEM_LMDB_VER}"
351
		die "Ebuild needs to update SYSTEM_LMDB_VER!"
352
	fi
353

  
354
	rm -r libraries/liblmdb || die 'could not removed bundled lmdb directory'
355

  
356
	local filename
357
	for filename in doc/drafts/draft-ietf-ldapext-acl-model-xx.txt; do
358
		iconv -f iso-8859-1 -t utf-8 "${filename}" > "${filename}.utf8"
359
		mv "${filename}.utf8" "${filename}"
360
	done
363 361

  
364 362
	default
365
	rm -r libraries/liblmdb || die
363

  
364
	sed -i \
365
		-e "s:\$(localstatedir)/run:${EPREFIX}/run:" \
366
		-e '/MKDIR.*.(DESTDIR)\/run/d' \
367
		-e '/MKDIR.*.(DESTDIR).*.(runstatedir)/d' \
368
		servers/slapd/Makefile.in || die 'adjusting slapd Makefile.in failed'
366 369

  
367 370
	pushd build &>/dev/null || die "pushd build"
368 371
	einfo "Making sure upstream build strip does not do stripping too early"
369 372
	sed -i.orig \
370 373
		-e '/^STRIP/s,-s,,g' \
371
		top.mk || die "Failed to block stripping"
374
		top.mk || die "Failed to remove too early stripping"
372 375
	popd &>/dev/null || die
373 376

  
374
	# wrong assumption that /bin/sh is /bin/bash
375
	sed \
376
		-e 's|/bin/sh|/bin/bash|g' \
377
		-i tests/scripts/* || die "sed failed"
378

  
379
	# Required for autoconf-2.70 #765043
380
	sed 's@^AM_INIT_AUTOMAKE.*@AC_PROG_MAKE_SET@' -i configure.in || die
381
	AT_NOEAUTOMAKE=yes eautoreconf
377
	# Fails with OpenSSL 3, bug #848894
378
	# https://bugs.openldap.org/show_bug.cgi?id=10009
379
	rm tests/scripts/test076-authid-rewrite || die
380

  
381
	eautoreconf
382
	multilib_copy_sources
382 383
}
383 384

  
384 385
build_contrib_module() {
385
	# <dir> <sources> <outputname>
386
	# <dir> [<target>]
386 387
	pushd "${S}/contrib/slapd-modules/$1" &>/dev/null || die "pushd contrib/slapd-modules/$1"
387
	einfo "Compiling contrib-module: $3"
388
	# Make sure it's uppercase
389
	local define_name="$(LC_ALL=C tr '[:lower:]' '[:upper:]' <<< "SLAPD_OVER_${1}")"
390
	"${lt}" --mode=compile --tag=CC \
391
		"${CC}" \
392
		-D${define_name}=SLAPD_MOD_DYNAMIC \
393
		-I"${BUILD_DIR}"/include \
394
		-I../../../include -I../../../servers/slapd ${CFLAGS} \
395
		-o ${2%.c}.lo -c $2 || die "compiling $3 failed"
396
	einfo "Linking contrib-module: $3"
397
	"${lt}" --mode=link --tag=CC \
398
		"${CC}" -module \
399
		${CFLAGS} \
400
		${LDFLAGS} \
401
		-rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
402
		-o $3.la ${2%.c}.lo || die "linking $3 failed"
388
	einfo "Compiling contrib-module: $1"
389
	local target="${2:-all}"
390
	emake \
391
		LDAP_BUILD="${BUILD_DIR}" prefix="${EPREFIX}/usr" \
392
		CC="${CC}" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" \
393
		"${target}"
403 394
	popd &>/dev/null || die
404 395
}
405 396

  
406
src_configure() {
407
	# connectionless ldap per bug #342439
408
	append-cppflags -DLDAP_CONNECTIONLESS
409

  
410
	multilib-minimal_src_configure
411
}
412

  
413 397
multilib_src_configure() {
414
	local myconf=()
398
	# Optional Features
399
	myconf+=(
400
		--enable-option-checking
401
		$(use_enable debug)
402
		--enable-dynamic
403
		$(use_enable syslog)
404
		$(use_enable ipv6)
405
		--enable-local
406
	)
415 407

  
416
	use debug && myconf+=( $(use_enable debug) )
408
	# Optional Packages
409
	myconf+=(
410
		--without-fetch
411
	)
417 412

  
418
	# ICU exists only in the configure, nowhere in the codebase, bug #510858
419
	export ac_cv_header_unicode_utypes_h=no ol_cv_lib_icu=no
413
	if use experimental ; then
414
		# connectionless ldap per bug #342439
415
		# connectionless is a unsupported feature according to Howard Chu
416
		# see https://bugs.openldap.org/show_bug.cgi?id=9739
417
		# (see also bug #892009)
418
		append-flags -DLDAP_CONNECTIONLESS
419
	fi
420 420

  
421 421
	if ! use minimal && multilib_is_native_abi; then
422
		local CPPFLAGS=${CPPFLAGS}
423

  
424
		# re-enable serverside overlay chains per bug #296567
425
		# see ldap docs chaper 12.3.1 for details
426
		myconf+=( --enable-ldap )
427

  
428
		# backends
429
		myconf+=( --enable-slapd )
430
		if use berkdb ; then
431
			einfo "Using Berkeley DB for local backend"
432
			myconf+=( --enable-bdb --enable-hdb )
433
			DBINCLUDE=$(db_includedir ${BDB_SLOTS})
434
			einfo "Using ${DBINCLUDE} for sys-libs/db version"
435
			# We need to include the slotted db.h dir for FreeBSD
436
			append-cppflags -I${DBINCLUDE}
437
		else
438
			myconf+=( --disable-bdb --disable-hdb )
439
		fi
440
		for backend in dnssrv ldap mdb meta monitor null passwd relay shell sock; do
441
			myconf+=( --enable-${backend}=mod )
442
		done
443

  
444
		myconf+=( $(use_enable perl perl mod) )
445

  
446
		myconf+=( $(use_enable odbc sql mod) )
447
		if use odbc ; then
448
			local odbc_lib="unixodbc"
449
			if use iodbc ; then
450
				odbc_lib="iodbc"
451
				append-cppflags -I"${EPREFIX}"/usr/include/iodbc
452
			fi
453
			myconf+=( --with-odbc=${odbc_lib} )
454
		fi
455

  
456
		# slapd options
422
		# SLAPD (Standalone LDAP Daemon) Options
423
		# overlay chaining requires '--enable-ldap' #296567
424
		# see https://www.openldap.org/doc/admin26/overlays.html#Chaining
457 425
		myconf+=(
426
			--enable-ldap=yes
427
			--enable-slapd
428
			$(use_enable cleartext)
458 429
			$(use_enable crypt)
430
			$(multilib_native_use_enable sasl spasswd)
459 431
			--disable-slp
460
			$(use_enable samba lmpasswd)
461
			$(use_enable syslog)
432
			$(use_enable tcpd wrappers)
462 433
		)
463 434
		if use experimental ; then
464 435
			myconf+=(
465 436
				--enable-dynacl
466
				--enable-aci=mod
437
				# ACI build as dynamic module not supported (yet)
438
				--enable-aci=yes
467 439
			)
468 440
		fi
469
		for option in aci cleartext modules rewrite rlookups slapi; do
441

  
442
		for option in modules rlookups slapi; do
470 443
			myconf+=( --enable-${option} )
471 444
		done
472 445

  
473
		# slapd overlay options
474
		# Compile-in the syncprov, the others as module
475
		myconf+=( --enable-syncprov=yes )
446
		# static SLAPD backends
447
		for backend in mdb; do
448
			myconf+=( --enable-${backend}=yes )
449
		done
450

  
451
		# module SLAPD backends
452
		for backend in asyncmeta dnssrv meta null passwd relay sock; do
453
			# missing modules: wiredtiger (not available in portage)
454
			myconf+=( --enable-${backend}=mod )
455
		done
456

  
457
		use perl && myconf+=( --enable-perl=mod )
458

  
459
		if use odbc ; then
460
			myconf+=( --enable-sql=mod )
461
			if use iodbc ; then
462
				myconf+=( --with-odbc="iodbc" )
463
				append-cflags -I"${EPREFIX}"/usr/include/iodbc
464
			else
465
				myconf+=( --with-odbc="unixodbc" )
466
			fi
467
		fi
468

  
476 469
		use overlays && myconf+=( --enable-overlays=mod )
470
		use autoca && myconf+=( --enable-autoca=mod ) || myconf+=( --enable-autoca=no )
471
		# compile-in the syncprov
472
		myconf+=( --enable-syncprov=yes )
477 473

  
474
		# SLAPD Password Module Options
475
		myconf+=(
476
			$(use_enable argon2)
477
		)
478

  
479
		# Optional Packages
480
		myconf+=(
481
			$(use_with systemd)
482
			$(multilib_native_use_with sasl cyrus-sasl)
483
		)
478 484
	else
479 485
		myconf+=(
480 486
			--disable-backends
481 487
			--disable-slapd
482
			--disable-bdb
483
			--disable-hdb
484 488
			--disable-mdb
485 489
			--disable-overlays
490
			--disable-autoca
486 491
			--disable-syslog
492
			--without-systemd
487 493
		)
488 494
	fi
489 495

  
490
	# basic functionality stuff
496
	# Library Generation & Linking Options
491 497
	myconf+=(
492
		$(use_enable ipv6)
493
		$(multilib_native_use_with sasl cyrus-sasl)
494
		$(multilib_native_use_enable sasl spasswd)
495
		$(use_enable tcpd wrappers)
498
		$(use_enable static-libs static)
499
		--enable-shared
500
		--enable-versioning
501
		--with-pic
496 502
	)
497 503

  
498
	# Some cross-compiling tests don't pan out well.
504
	# some cross-compiling tests don't pan out well.
499 505
	tc-is-cross-compiler && myconf+=(
500 506
		--with-yielding-select=yes
501 507
	)
502 508

  
503 509
	local ssl_lib="no"
504 510
	if use ssl || ( ! use minimal && use samba ) ; then
505
		ssl_lib="openssl"
506
		use gnutls && ssl_lib="gnutls"
511
		if use gnutls ; then
512
			myconf+=( --with-tls="gnutls" )
513
		else
514
			# disable MD2 hash function
515
			append-cflags -DOPENSSL_NO_MD2
516
			myconf+=( --with-tls="openssl" )
517
		fi
518
	else
519
		myconf+=( --with-tls="no" )
507 520
	fi
508 521

  
509
	myconf+=( --with-tls=${ssl_lib} )
510

  
511
	for basicflag in dynamic local proctitle shared; do
512
		myconf+=( --enable-${basicflag} )
513
	done
514

  
515 522
	tc-export AR CC CXX
516
	CONFIG_SHELL="/bin/sh" \
517
	ECONF_SOURCE="${S}" \
518
	STRIP=/bin/true \
519
	econf \
523

  
524
	ECONF_SOURCE="${S}" econf \
520 525
		--libexecdir="${EPREFIX}"/usr/$(get_libdir)/openldap \
521
		$(use_enable static-libs static) \
526
		--localstatedir="${EPREFIX}"/var \
527
		--runstatedir="${EPREFIX}"/run \
528
		--sharedstatedir="${EPREFIX}"/var/lib \
522 529
		"${myconf[@]}"
530

  
531
	# argument '--runstatedir' seems to have no effect therefore this workaround
532
	sed -i \
533
		-e 's:^runstatedir=.*:runstatedir=${EPREFIX}/run:' \
534
		configure contrib/ldapc++/configure contrib/ldaptcl/configure || die 'could not set runstatedir'
535

  
536
	sed -i \
537
		-e "s:/var/run/sasl2/mux:${EPREFIX}/run/sasl2/mux:" \
538
		doc/guide/admin/security.sdf || die 'could not fix run path in doc'
539

  
523 540
	emake depend
524 541
}
525 542

  
526 543
src_configure_cxx() {
527 544
	# This needs the libraries built by the first build run.
528
	# So we have to run it AFTER the main build, not just after the main
529
	# configure.
545
	# we have to run it AFTER the main build, not just after the main configure
530 546
	local myconf_ldapcpp=(
531
		--with-ldap-includes="${S}"/include
547
		--with-libldap="${E}/lib"
548
		--with-ldap-includes="${S}/include"
532 549
	)
533 550

  
534
	mkdir -p "${BUILD_DIR}"/contrib/ldapc++ || die
551
	mkdir -p "${BUILD_DIR}"/contrib/ldapc++ || die "could not create ${BUILD_DIR}/contrib/ldapc++ directory"
535 552
	pushd "${BUILD_DIR}/contrib/ldapc++" &>/dev/null || die "pushd contrib/ldapc++"
536 553

  
537
	local LDFLAGS=${LDFLAGS} CPPFLAGS=${CPPFLAGS}
538
	append-ldflags -L"${BUILD_DIR}"/libraries/liblber/.libs \
539
		-L"${BUILD_DIR}"/libraries/libldap/.libs
554
	local LDFLAGS="${LDFLAGS}"
555
	local CPPFLAGS="${CPPFLAGS}"
556

  
557
	append-ldflags -L"${BUILD_DIR}"/libraries/liblber/.libs -L"${BUILD_DIR}"/libraries/libldap/.libs
540 558
	append-cppflags -I"${BUILD_DIR}"/include
541
	ECONF_SOURCE=${S}/contrib/ldapc++ \
542
	econf "${myconf_ldapcpp[@]}" \
543
		CC="${CC}" \
544
		CXX="${CXX}"
545
	popd &>/dev/null || die
559

  
560
	ECONF_SOURCE="${S}"/contrib/ldapc++ econf "${myconf_ldapcpp[@]}"
561
	popd &>/dev/null || die "popd contrib/ldapc++"
546 562
}
547 563

  
548 564
multilib_src_compile() {
549 565
	tc-export AR CC CXX
550
	emake CC="${CC}" AR="${AR}" SHELL="${EPREFIX}"/bin/sh
551
	local lt="${BUILD_DIR}/libtool"
552
	export echo="echo"
566
	emake CC="$(tc-getCC)" SHELL="${EPREFIX}"/bin/sh
553 567

  
554 568
	if ! use minimal && multilib_is_native_abi ; then
555 569
		if use cxx ; then
556 570
			einfo "Building contrib library: ldapc++"
557 571
			src_configure_cxx
558 572
			pushd "${BUILD_DIR}/contrib/ldapc++" &>/dev/null || die "pushd contrib/ldapc++"
559
			emake CC="${CC}" CXX="${CXX}"
573
			emake
560 574
			popd &>/dev/null || die
561 575
		fi
562 576

  
......
578 592
				DEFS="${MY_DEFS}" \
579 593
				KRB5_INC="${MY_KRB5_INC}" \
580 594
				LDAP_BUILD="${BUILD_DIR}" \
581
				CC="${CC}" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap"
595
				libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap"
582 596
			popd &>/dev/null || die
583 597
		fi
584 598

  
......
588 602

  
589 603
			emake \
590 604
				LDAP_BUILD="${BUILD_DIR}" \
591
				CC="${CC}" libexecdir="/usr/$(get_libdir)/openldap"
605
				CC="$(tc-getCC)" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap"
592 606
			popd &>/dev/null || die
593 607
		fi
594 608

  
......
596 610
			if use kinit ; then
597 611
				build_contrib_module "kinit" "kinit.c" "kinit"
598 612
			fi
599
			pushd "${S}/contrib/slapd-modules/passwd" &>/dev/null || die "pushd contrib/slapd-modules/passwd"
600
			einfo "Compiling contrib-module: pw-kerberos"
601
			"${lt}" --mode=compile --tag=CC \
602
				"${CC}" \
603
				-I"${BUILD_DIR}"/include \
604
				-I../../../include \
605
				${CFLAGS} \
606
				$(krb5-config --cflags) \
607
				-DHAVE_KRB5 \
608
				-o kerberos.lo \
609
				-c kerberos.c || die "compiling pw-kerberos failed"
610
			einfo "Linking contrib-module: pw-kerberos"
611
			"${lt}" --mode=link --tag=CC \
612
				"${CC}" -module \
613
				${CFLAGS} \
614
				${LDFLAGS} \
615
				-rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
616
				-o pw-kerberos.la \
617
				kerberos.lo || die "linking pw-kerberos failed"
618
			popd &>/dev/null || die
613
			build_contrib_module "passwd" "pw-kerberos.la"
619 614
		fi
620 615

  
621 616
		if use pbkdf2; then
622
			pushd "${S}/contrib/slapd-modules/passwd/pbkdf2" &>/dev/null || die "pushd contrib/slapd-modules/passwd/pbkdf2"
623
			einfo "Compiling contrib-module: pw-pbkdf2"
624
			"${lt}" --mode=compile --tag=CC \
625
				"${CC}" \
626
				-I"${BUILD_DIR}"/include \
627
				-I../../../../include \
628
				${CFLAGS} \
629
				-o pbkdf2.lo \
630
				-c pw-pbkdf2.c || die "compiling pw-pbkdf2 failed"
631
			einfo "Linking contrib-module: pw-pbkdf2"
632
			"${lt}" --mode=link --tag=CC \
633
				"${CC}" -module \
634
				${CFLAGS} \
635
				${LDFLAGS} \
636
				-rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
637
				-o pw-pbkdf2.la \
638
				pbkdf2.lo || die "linking pw-pbkdf2 failed"
639
			popd &>/dev/null || die
617
			build_contrib_module "passwd/pbkdf2"
640 618
		fi
641 619

  
642 620
		if use sha2 ; then
643
			pushd "${S}/contrib/slapd-modules/passwd/sha2" &>/dev/null || die "pushd contrib/slapd-modules/passwd/sha2"
644
			einfo "Compiling contrib-module: pw-sha2"
645
			"${lt}" --mode=compile --tag=CC \
646
				"${CC}" \
647
				-I"${BUILD_DIR}"/include \
648
				-I../../../../include \
649
				${CFLAGS} \
650
				-o sha2.lo \
651
				-c sha2.c || die "compiling pw-sha2 failed"
652
			"${lt}" --mode=compile --tag=CC \
653
				"${CC}" \
654
				-I"${BUILD_DIR}"/include \
655
				-I../../../../include \
656
				${CFLAGS} \
657
				-o slapd-sha2.lo \
658
				-c slapd-sha2.c || die "compiling pw-sha2 failed"
659
			einfo "Linking contrib-module: pw-sha2"
660
			"${lt}" --mode=link --tag=CC \
661
				"${CC}" -module \
662
				${CFLAGS} \
663
				${LDFLAGS} \
664
				-rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
665
				-o pw-sha2.la \
666
				sha2.lo slapd-sha2.lo || die "linking pw-sha2 failed"
667
			popd &>/dev/null || die
621
			build_contrib_module "passwd/sha2"
668 622
		fi
669 623

  
670 624
		# We could build pw-radius if GNURadius would install radlib.h
671
		pushd "${S}/contrib/slapd-modules/passwd" &>/dev/null || die "pushd contrib/slapd-modules/passwd"
672
		einfo "Compiling contrib-module: pw-netscape"
673
		"${lt}" --mode=compile --tag=CC \
674
			"${CC}" \
675
			-I"${BUILD_DIR}"/include \
676
			-I../../../include \
677
			${CFLAGS} \
678
			-o netscape.lo \
679
			-c netscape.c || die "compiling pw-netscape failed"
680
		einfo "Linking contrib-module: pw-netscape"
681
		"${lt}" --mode=link --tag=CC \
682
			"${CC}" -module \
683
			${CFLAGS} \
684
			${LDFLAGS} \
685
			-rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
686
			-o pw-netscape.la \
687
			netscape.lo || die "linking pw-netscape failed"
688

  
689
		#build_contrib_module "acl" "posixgroup.c" "posixGroup" # example code only
690
		#build_contrib_module "acl" "gssacl.c" "gss" # example code only, also needs kerberos
691
		build_contrib_module "addpartial" "addpartial-overlay.c" "addpartial-overlay"
692
		build_contrib_module "allop" "allop.c" "overlay-allop"
693
		build_contrib_module "allowed" "allowed.c" "allowed"
694
		build_contrib_module "autogroup" "autogroup.c" "autogroup"
695
		build_contrib_module "cloak" "cloak.c" "cloak"
696
		# build_contrib_module "comp_match" "comp_match.c" "comp_match"
697
		# comp_match: really complex, adds new external deps, questionable demand
698
		build_contrib_module "denyop" "denyop.c" "denyop-overlay"
699
		build_contrib_module "dsaschema" "dsaschema.c" "dsaschema-plugin"
700
		build_contrib_module "dupent" "dupent.c" "dupent"
701
		build_contrib_module "lastbind" "lastbind.c" "lastbind"
625
		build_contrib_module "passwd" "pw-netscape.la"
626

  
627
		#build_contrib_module "acl" "posixgroup.la" # example code only
628
		#build_contrib_module "acl" "gssacl.la" # example code only, also needs kerberos
629
		build_contrib_module "addpartial"
630
		build_contrib_module "allop"
631
		build_contrib_module "allowed"
632
		build_contrib_module "autogroup"
633
		build_contrib_module "cloak"
634
		# build_contrib_module "comp_match" # really complex, adds new external deps, questionable demand
635
		build_contrib_module "denyop"
636
		build_contrib_module "dsaschema"
637
		build_contrib_module "dupent"
638
		build_contrib_module "lastbind"
702 639
		# lastmod may not play well with other overlays
703
		build_contrib_module "lastmod" "lastmod.c" "lastmod"
704
		build_contrib_module "noopsrch" "noopsrch.c" "noopsrch"
705
		#build_contrib_module "nops" "nops.c" "nops-overlay" https://bugs.gentoo.org/641576
706
		#build_contrib_module "nssov" "nssov.c" "nssov-overlay" RESO:LATER
707
		build_contrib_module "trace" "trace.c" "trace"
708
		popd &>/dev/null || die
640
		build_contrib_module "lastmod"
641
		build_contrib_module "noopsrch"
642
		#build_contrib_module "nops" https://bugs.gentoo.org/641576
643
		#build_contrib_module "nssov" RESO:LATER
644
		build_contrib_module "trace"
709 645
		# build slapi-plugins
710 646
		pushd "${S}/contrib/slapi-plugins/addrdnvalues" &>/dev/null || die "pushd contrib/slapi-plugins/addrdnvalues"
711 647
		einfo "Building contrib-module: addrdnvalues plugin"
712
		"${CC}" -shared \
648
		$(tc-getCC) -shared \
713 649
			-I"${BUILD_DIR}"/include \
714 650
			-I../../../include \
651
			${CPPFLAGS} \
715 652
			${CFLAGS} \
716 653
			-fPIC \
717 654
			${LDFLAGS} \
......
724 661
multilib_src_test() {
725 662
	if multilib_is_native_abi; then
726 663
		cd tests || die
727
		emake tests
664
		pwd
665

  
666
		# Increase various test timeouts/delays, bug #894012
667
		# We can't just double everything as there's a cumulative effect.
668
		export SLEEP0=2 # originally 1
669
		export SLEEP1=10 # originally 7
670
		export SLEEP2=20 # originally 15
671
		export TIMEOUT=16 # originally 8
672

  
673
		# emake test => runs only lloadd & mdb, in serial; skips ldif,sql,wt,regression
674
		# emake partests => runs ALL of the tests in parallel
675
		# wt/WiredTiger is not supported in Gentoo
676
		TESTS=( lloadd mdb )
677
		#TESTS+=( pldif ) # not done by default, so also exclude here
678
		#use odbc && TESTS+=( psql ) # not done by default, so also exclude here
679

  
680
		emake "${TESTS[@]}"
728 681
	fi
729 682
}
730 683

  
731 684
multilib_src_install() {
732
	local lt="${BUILD_DIR}/libtool"
733
	emake DESTDIR="${D}" SHELL="${EPREFIX}"/bin/sh install
685
	emake CC="$(tc-getCC)" \
686
		DESTDIR="${D}" SHELL="${EPREFIX}"/bin/sh install
734 687

  
735 688
	if ! use minimal && multilib_is_native_abi; then
736 689
		# openldap modules go here
......
749 702
		# use our config
750 703
		rm "${ED}"/etc/openldap/slapd.conf
751 704
		insinto /etc/openldap
752
		newins "${FILESDIR}"/${PN}-2.4.40-slapd-conf slapd.conf
705
		newins "${FILESDIR}"/${PN}-2.6.3-slapd-conf slapd.conf
753 706
		configfile="${ED}"/etc/openldap/slapd.conf
754 707

  
755 708
		# populate with built backends
......
768 721
		einfo "Install init scripts"
769 722
		sed -e "s,/usr/lib/,/usr/$(get_libdir)/," "${FILESDIR}"/slapd-initd-2.4.40-r2 > "${T}"/slapd || die
770 723
		doinitd "${T}"/slapd
771
		newconfd "${FILESDIR}"/slapd-confd-2.4.28-r1 slapd
724
		newconfd "${FILESDIR}"/slapd-confd-2.6.1 slapd
772 725

  
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
		newtmpfiles "${FILESDIR}"/slapd.tmpfilesd slapd.conf
726
		if use systemd; then
727
			# The systemd unit uses Type=notify, so it is useless without USE=systemd
728
			einfo "Install systemd service"
729
			rm -rf "${ED}"/{,usr/}lib/systemd
730
			sed -e "s,/usr/lib/,/usr/$(get_libdir)/," "${FILESDIR}"/slapd-2.6.1.service > "${T}"/slapd.service || die
731
			systemd_dounit "${T}"/slapd.service
732
			systemd_install_serviced "${FILESDIR}"/slapd.service.conf
733
			newtmpfiles "${FILESDIR}"/slapd.tmpfilesd slapd.conf
734
		fi
778 735

  
779
		# If built without SLP, we don't need to be before avahi
736
		# if built without SLP, we don't need to be before avahi
780 737
			sed -i \
781 738
				-e '/before/{s/avahi-daemon//g}' \
782 739
				"${ED}"/etc/init.d/slapd \
......
804 761
			cd "${S}/contrib/slapd-modules/samba4" || die
805 762
			emake DESTDIR="${D}" \
806 763
				LDAP_BUILD="${BUILD_DIR}" \
807
				libexecdir="/usr/$(get_libdir)/openldap" install
764
				libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" install
808 765
			newdoc README samba4-README
809 766
		fi
810 767

  
......
812 769
		cd "${S}/contrib/slapd-modules" || die
813 770
		for l in */*.la */*/*.la; do
814 771
			[[ -e ${l} ]] || continue
815
			"${lt}" --mode=install cp ${l} \
772
			libtool --mode=install cp ${l} \
816 773
				"${ED}"/usr/$(get_libdir)/openldap/openldap || \
817 774
				die "installing ${l} failed"
818 775
		done
......
837 794
		newins "${DISTDIR}"/${BIS_P} ${BIS_PN}
838 795

  
839 796
		docinto back-sock ; dodoc "${S}"/servers/slapd/back-sock/searchexample*
840
		docinto back-shell ; dodoc "${S}"/servers/slapd/back-shell/searchexample*
841 797
		docinto back-perl ; dodoc "${S}"/servers/slapd/back-perl/SampleLDAP.pm
842 798

  
843 799
		dosbin "${S}"/contrib/slapd-tools/statslog
......
856 812

  
857 813
pkg_preinst() {
858 814
	# keep old libs if any
859
	preserve_old_lib /usr/$(get_libdir)/{liblber,libldap_r,liblber}-2.3$(get_libname 0)
815
	preserve_old_lib /usr/$(get_libdir)/{liblber,libldap,libldap_r}-2.4$(get_libname 0)
860 816
	# bug 440470, only display the getting started help there was no openldap before,
861 817
	# or we are going to a non-minimal build
862 818
	! has_version net-nds/openldap || has_version 'net-nds/openldap[minimal]'
......
865 821

  
866 822
pkg_postinst() {
867 823
	if ! use minimal ; then
868
		tmpfiles_process slapd.conf
824
		if use systemd; then
825
			tmpfiles_process slapd.conf
826
		fi
869 827

  
870 828
		# You cannot build SSL certificates during src_install that will make
871 829
		# binary packages containing your SSL key, which is both a security risk
......
900 858
		elog "Getting started using OpenLDAP? There is some documentation available:"
901 859
		elog "Gentoo Guide to OpenLDAP Authentication"
902 860
		elog "(https://wiki.gentoo.org/wiki/Centralized_authentication_using_OpenLDAP)"
903
		elog "---"
904
		elog "An example file for tuning BDB backends with openldap is"
905
		elog "DB_CONFIG.fast.example in /usr/share/doc/${PF}/"
906 861
	fi
907 862

  
908
	preserve_old_lib_notify /usr/$(get_libdir)/{liblber,libldap,libldap_r}-2.3$(get_libname 0)
863
	preserve_old_lib_notify /usr/$(get_libdir)/{liblber,libldap,libldap_r}-2.4$(get_libname 0)
909 864
}
Thank you!