Diff openldap-2.4.59-r2 with a openldap-2.5.14

/usr/portage/net-nds/openldap/openldap-2.5.14.ebuild 2023-10-09 14:52:34.724368482 +0300
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
13 15
BIS_P="${BIS_PN}-${BIS_PV}"
14 16

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

  
18
# upstream mirrors are mostly not working, using canonical URI
18
HOMEPAGE="https://www.openldap.org/"
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 ~ia64 ~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 ~ia64 ~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=$(sed -En '/^#define MDB_VERSION_(MAJOR|MINOR|PATCH)(\s+)?/{s/[^0-9.]//gp}' libraries/liblmdb/lmdb.h || die)
343
	printf -v bundled_lmdb_version "%s." ${bundled_lmdb_version}
344

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

  
351
	rm -r libraries/liblmdb || die 'could not removed bundled lmdb directory'
352

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

  
364 359
	default
365
	rm -r libraries/liblmdb || die
360

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

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

  
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
374
	# Fails with OpenSSL 3, bug #848894
375
	# https://bugs.openldap.org/show_bug.cgi?id=10009
376
	rm tests/scripts/test076-authid-rewrite || die
377

  
378
	eautoreconf
379
	multilib_copy_sources
382 380
}
383 381

  
384 382
build_contrib_module() {
385
	# <dir> <sources> <outputname>
383
	# <dir> [<target>]
386 384
	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"
385
	einfo "Compiling contrib-module: $1"
386
	local target="${2:-all}"
387
	emake \
388
		LDAP_BUILD="${BUILD_DIR}" prefix="${EPREFIX}/usr" \
389
		CC="${CC}" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" \
390
		"${target}"
403 391
	popd &>/dev/null || die
404 392
}
405 393

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

  
410
	multilib-minimal_src_configure
411
}
412

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

  
416
	use debug && myconf+=( $(use_enable debug) )
405
	# Optional Packages
406
	myconf+=(
407
		--without-fetch
408
	)
417 409

  
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
410
	if use experimental ; then
411
		# connectionless ldap per bug #342439
412
		# connectionless is a unsupported feature according to Howard Chu
413
		# see https://bugs.openldap.org/show_bug.cgi?id=9739
414
		# (see also bug #892009)
415
		append-flags -DLDAP_CONNECTIONLESS
416
	fi
420 417

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

  
439
		for option in modules rlookups slapi; do
470 440
			myconf+=( --enable-${option} )
471 441
		done
472 442

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

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

  
454
		use perl && myconf+=( --enable-perl=mod )
455

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

  
476 466
		use overlays && myconf+=( --enable-overlays=mod )
467
		use autoca && myconf+=( --enable-autoca=mod ) || myconf+=( --enable-autoca=no )
468
		# compile-in the syncprov
469
		myconf+=( --enable-syncprov=yes )
470

  
471
		# SLAPD Password Module Options
472
		myconf+=(
473
			$(use_enable argon2)
474
		)
477 475

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

  
490
	# basic functionality stuff
493
	# Library Generation & Linking Options
491 494
	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)
495
		$(use_enable static-libs static)
496
		--enable-shared
497
		--enable-versioning
498
		--with-pic
496 499
	)
497 500

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

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

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

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

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

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

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

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

  
523 537
	emake depend
524 538
}
525 539

  
526 540
src_configure_cxx() {
527 541
	# 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.
542
	# we have to run it AFTER the main build, not just after the main configure
530 543
	local myconf_ldapcpp=(
531
		--with-ldap-includes="${S}"/include
544
		--with-libldap="${E}/lib"
545
		--with-ldap-includes="${S}/include"
532 546
	)
533 547

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

  
537
	local LDFLAGS=${LDFLAGS} CPPFLAGS=${CPPFLAGS}
538
	append-ldflags -L"${BUILD_DIR}"/libraries/liblber/.libs \
539
		-L"${BUILD_DIR}"/libraries/libldap/.libs
551
	local LDFLAGS="${LDFLAGS}"
552
	local CPPFLAGS="${CPPFLAGS}"
553

  
554
	append-ldflags -L"${BUILD_DIR}"/libraries/liblber/.libs -L"${BUILD_DIR}"/libraries/libldap/.libs
540 555
	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
556

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

  
548 561
multilib_src_compile() {
549 562
	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"
563
	emake CC="$(tc-getCC)" SHELL="${EPREFIX}"/bin/sh
553 564

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

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

  
......
588 599

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

  
......
596 607
			if use kinit ; then
597 608
				build_contrib_module "kinit" "kinit.c" "kinit"
598 609
			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
610
			build_contrib_module "passwd" "pw-kerberos.la"
619 611
		fi
620 612

  
621 613
		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
614
			build_contrib_module "passwd/pbkdf2"
640 615
		fi
641 616

  
642 617
		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
618
			build_contrib_module "passwd/sha2"
668 619
		fi
669 620

  
670 621
		# 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" # really complex, adds new external deps, questionable demand
697
		build_contrib_module "denyop" "denyop.c" "denyop-overlay"
698
		build_contrib_module "dsaschema" "dsaschema.c" "dsaschema-plugin"
699
		build_contrib_module "dupent" "dupent.c" "dupent"
700
		build_contrib_module "lastbind" "lastbind.c" "lastbind"
622
		build_contrib_module "passwd" "pw-netscape.la"
623

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

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

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

  
677
		emake "${TESTS[@]}"
727 678
	fi
728 679
}
729 680

  
730 681
multilib_src_install() {
731
	local lt="${BUILD_DIR}/libtool"
732
	emake DESTDIR="${D}" SHELL="${EPREFIX}"/bin/sh install
682
	emake CC="$(tc-getCC)" \
683
		DESTDIR="${D}" SHELL="${EPREFIX}"/bin/sh install
733 684

  
734 685
	if ! use minimal && multilib_is_native_abi; then
735 686
		# openldap modules go here
......
748 699
		# use our config
749 700
		rm "${ED}"/etc/openldap/slapd.conf
750 701
		insinto /etc/openldap
751
		newins "${FILESDIR}"/${PN}-2.4.40-slapd-conf slapd.conf
702
		newins "${FILESDIR}"/${PN}-2.6.3-slapd-conf slapd.conf
752 703
		configfile="${ED}"/etc/openldap/slapd.conf
753 704

  
754 705
		# populate with built backends
......
766 717
		einfo "Install init scripts"
767 718
		sed -e "s,/usr/lib/,/usr/$(get_libdir)/," "${FILESDIR}"/slapd-initd-2.4.40-r2 > "${T}"/slapd || die
768 719
		doinitd "${T}"/slapd
769
		newconfd "${FILESDIR}"/slapd-confd-2.4.28-r1 slapd
720
		newconfd "${FILESDIR}"/slapd-confd-2.6.1 slapd
770 721

  
771
		einfo "Install systemd service"
772
		sed -e "s,/usr/lib/,/usr/$(get_libdir)/," "${FILESDIR}"/slapd.service > "${T}"/slapd.service || die
773
		systemd_dounit "${T}"/slapd.service
774
		systemd_install_serviced "${FILESDIR}"/slapd.service.conf
775
		newtmpfiles "${FILESDIR}"/slapd.tmpfilesd slapd.conf
722
		if use systemd; then
723
			# The systemd unit uses Type=notify, so it is useless without USE=systemd
724
			einfo "Install systemd service"
725
			rm -rf "${ED}"/{,usr/}lib/systemd
726
			sed -e "s,/usr/lib/,/usr/$(get_libdir)/," "${FILESDIR}"/slapd-2.6.1.service > "${T}"/slapd.service || die
727
			systemd_dounit "${T}"/slapd.service
728
			systemd_install_serviced "${FILESDIR}"/slapd.service.conf
729
			newtmpfiles "${FILESDIR}"/slapd.tmpfilesd slapd.conf
730
		fi
776 731

  
777
		# If built without SLP, we don't need to be before avahi
732
		# if built without SLP, we don't need to be before avahi
778 733
			sed -i \
779 734
				-e '/before/{s/avahi-daemon//g}' \
780 735
				"${ED}"/etc/init.d/slapd \
......
802 757
			cd "${S}/contrib/slapd-modules/samba4" || die
803 758
			emake DESTDIR="${D}" \
804 759
				LDAP_BUILD="${BUILD_DIR}" \
805
				libexecdir="/usr/$(get_libdir)/openldap" install
760
				libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" install
806 761
			newdoc README samba4-README
807 762
		fi
808 763

  
......
810 765
		cd "${S}/contrib/slapd-modules" || die
811 766
		for l in */*.la */*/*.la; do
812 767
			[[ -e ${l} ]] || continue
813
			"${lt}" --mode=install cp ${l} \
768
			libtool --mode=install cp ${l} \
814 769
				"${ED}"/usr/$(get_libdir)/openldap/openldap || \
815 770
				die "installing ${l} failed"
816 771
		done
......
835 790
		newins "${DISTDIR}"/${BIS_P} ${BIS_PN}
836 791

  
837 792
		docinto back-sock ; dodoc "${S}"/servers/slapd/back-sock/searchexample*
838
		docinto back-shell ; dodoc "${S}"/servers/slapd/back-shell/searchexample*
839 793
		docinto back-perl ; dodoc "${S}"/servers/slapd/back-perl/SampleLDAP.pm
840 794

  
841 795
		dosbin "${S}"/contrib/slapd-tools/statslog
......
854 808

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

  
864 818
pkg_postinst() {
865 819
	if ! use minimal ; then
866
		tmpfiles_process slapd.conf
820
		if use systemd; then
821
			tmpfiles_process slapd.conf
822
		fi
867 823

  
868 824
		# You cannot build SSL certificates during src_install that will make
869 825
		# binary packages containing your SSL key, which is both a security risk
......
898 854
		elog "Getting started using OpenLDAP? There is some documentation available:"
899 855
		elog "Gentoo Guide to OpenLDAP Authentication"
900 856
		elog "(https://wiki.gentoo.org/wiki/Centralized_authentication_using_OpenLDAP)"
901
		elog "---"
902
		elog "An example file for tuning BDB backends with openldap is"
903
		elog "DB_CONFIG.fast.example in /usr/share/doc/${PF}/"
904 857
	fi
905 858

  
906
	preserve_old_lib_notify /usr/$(get_libdir)/{liblber,libldap,libldap_r}-2.3$(get_libname 0)
859
	preserve_old_lib_notify /usr/$(get_libdir)/{liblber,libldap,libldap_r}-2.4$(get_libname 0)
907 860
}
Thank you!