--- net-nds/openldap/openldap-2.4.45.ebuild +++ net-nds/openldap/openldap-2.4.46.ebuild @@ -1,9 +1,9 @@ # Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -EAPI="5" +EAPI=6 -inherit db-use eutils flag-o-matic multilib multilib-minimal ssl-cert versionator toolchain-funcs autotools user systemd +inherit db-use flag-o-matic multilib multilib-minimal ssl-cert eapi7-ver toolchain-funcs autotools user systemd BIS_PN=rfc2307bis.schema BIS_PV=20140524 @@ -77,7 +77,8 @@ kinit? ( !app-crypt/heimdal ) ) cxx? ( dev-libs/cyrus-sasl:= ) - )" + ) +)" DEPEND="${CDEPEND} sys-apps/groff" RDEPEND="${CDEPEND} @@ -125,6 +126,42 @@ /usr/include/TlsOptions.h ) +PATCHES=( + "${FILESDIR}"/${PN}-2.4.17-gcc44.patch + + "${FILESDIR}"/${PN}-2.2.14-perlthreadsfix.patch + "${FILESDIR}"/${PN}-2.4.15-ppolicy.patch + + # bug #116045 - still present in 2.4.28 + "${FILESDIR}"/${PN}-2.4.35-contrib-smbk5pwd.patch + # bug #408077 - samba4 + "${FILESDIR}"/${PN}-2.4.35-contrib-samba4.patch + + # bug #189817 + "${FILESDIR}"/${PN}-2.4.11-libldap_r.patch + + # bug #233633 + "${FILESDIR}"/${PN}-2.4.45-fix-lmpasswd-gnutls-symbols.patch + + # bug #281495 + "${FILESDIR}"/${PN}-2.4.28-gnutls-gcrypt.patch + + # bug #294350 + "${FILESDIR}"/${PN}-2.4.6-evolution-ntlm.patch + + # unbreak /bin/sh -> dash + "${FILESDIR}"/${PN}-2.4.28-fix-dash.patch + + # bug #420959 + "${FILESDIR}"/${PN}-2.4.31-gcc47.patch + + # bug #622464 + #"${FILESDIR}"/${PN}-2.4.45-libressl.patch + + # unbundle lmdb + "${FILESDIR}"/${PN}-2.4.42-mdb-unbundle.patch +) + openldap_filecount() { local dir="$1" find "${dir}" -type f ! -name '.*' ! -name 'DB_CONFIG*' | wc -l @@ -132,11 +169,11 @@ openldap_find_versiontags() { # scan for all datadirs - openldap_datadirs="" - if [ -f "${EROOT}"/etc/openldap/slapd.conf ]; then - openldap_datadirs="$(awk '{if($1 == "directory") print $2 }' ${EROOT}/etc/openldap/slapd.conf)" + local openldap_datadirs=() + if [[ -f "${EROOT}"/etc/openldap/slapd.conf ]]; then + openldap_datadirs=( $(awk '{if($1 == "directory") print $2 }' "${EROOT}"/etc/openldap/slapd.conf) ) #' fi - openldap_datadirs="${openldap_datadirs} ${OPENLDAP_DEFAULTDIR_VERSIONTAG}" + openldap_datadirs+=( ${openldap_datadirs} ${OPENLDAP_DEFAULTDIR_VERSIONTAG} ) einfo einfo "Scanning datadir(s) from slapd.conf and" @@ -147,28 +184,28 @@ # scan datadirs if we have a version tag openldap_found_tag=0 have_files=0 - for each in ${openldap_datadirs}; do - CURRENT_TAGDIR=${ROOT}`echo ${each} | sed "s:\/::"` - CURRENT_TAG=${CURRENT_TAGDIR}/${OPENLDAP_VERSIONTAG} - if [ -d ${CURRENT_TAGDIR} ] && [ ${openldap_found_tag} == 0 ] ; then + for each in ${openldap_datadirs[@]}; do + CURRENT_TAGDIR="${ROOT}$(sed "s:\/::" <<< ${each})" + CURRENT_TAG="${CURRENT_TAGDIR}/${OPENLDAP_VERSIONTAG}" + if [[ -d "${CURRENT_TAGDIR}" ]] && [[ "${openldap_found_tag}" == 0 ]] ; then einfo "- Checking ${each}..." - if [ -r ${CURRENT_TAG} ] ; then + if [[ -r "${CURRENT_TAG}" ]] ; then # yey, we have one :) einfo " Found Versiontag in ${each}" - source ${CURRENT_TAG} - if [ "${OLDPF}" == "" ] ; then + source "${CURRENT_TAG}" + if [[ "${OLDPF}" == "" ]] ; then eerror "Invalid Versiontag found in ${CURRENT_TAGDIR}" eerror "Please delete it" eerror die "Please kill the invalid versiontag in ${CURRENT_TAGDIR}" fi - OLD_MAJOR=`get_version_component_range 2-3 ${OLDPF}` + OLD_MAJOR=$(ver_cut 2-3 ${OLDPF}) - [ $(openldap_filecount ${CURRENT_TAGDIR}) -gt 0 ] && have_files=1 + [[ "$(openldap_filecount ${CURRENT_TAGDIR})" -gt 0 ]] && have_files=1 # are we on the same branch? - if [ "${OLD_MAJOR}" != "${PV:0:3}" ] ; then + if [[ "${OLD_MAJOR}" != "${PV:0:3}" ]] ; then ewarn " Versiontag doesn't match current major release!" if [[ "${have_files}" == "1" ]] ; then eerror " Versiontag says other major and you (probably) have datafiles!" @@ -182,7 +219,7 @@ fi else einfo " Non-tagged dir ${each}" - [ $(openldap_filecount ${each}) -gt 0 ] && have_files=1 + [[ "$(openldap_filecount ${each})" -gt 0 ]] && have_files=1 if [[ "${have_files}" == "1" ]] ; then einfo " EEK! Non-empty non-tagged datadir, counting `ls -a ${each} | wc -l` files" echo @@ -204,45 +241,45 @@ einfo fi done - [ "${have_files}" == "1" ] && einfo "DB files present" || einfo "No DB files present" + [[ "${have_files}" == "1" ]] && einfo "DB files present" || einfo "No DB files present" # Now we must check for the major version of sys-libs/db linked against. - SLAPD_PATH=${EROOT}/usr/$(get_libdir)/openldap/slapd - if [ "${have_files}" == "1" -a -f "${SLAPD_PATH}" ]; then + SLAPD_PATH="${EROOT}/usr/$(get_libdir)/openldap/slapd" + if [[ "${have_files}" == "1" ]] && [[ -f "${SLAPD_PATH}" ]]; then OLDVER="$(/usr/bin/ldd ${SLAPD_PATH} \ | awk '/libdb-/{gsub("^libdb-","",$1);gsub(".so$","",$1);print $1}')" if use berkdb; then # find which one would be used - for bdb_slot in $BDB_SLOTS ; do + for bdb_slot in ${BDB_SLOTS} ; do NEWVER="$(db_findver "=sys-libs/db-${bdb_slot}*")" - [[ -n "$NEWVER" ]] && break + [[ -n "${NEWVER}" ]] && break done fi local fail=0 - if [ -z "${OLDVER}" -a -z "${NEWVER}" ]; then + if [[ -z "${OLDVER}" ]] && [[ -z "${NEWVER}" ]]; then : # Nothing wrong here. - elif [ -z "${OLDVER}" -a -n "${NEWVER}" ]; then + elif [[ -z "${OLDVER}" ]] && [[ -n "${NEWVER}" ]]; then eerror " Your existing version of OpenLDAP was not built against" eerror " any version of sys-libs/db, but the new one will build" eerror " against ${NEWVER} and your database may be inaccessible." echo fail=1 - elif [ -n "${OLDVER}" -a -z "${NEWVER}" ]; then + elif [[ -n "${OLDVER}" ]]&& [[ -z "${NEWVER}" ]]; then eerror " Your existing version of OpenLDAP was built against" eerror " sys-libs/db:${OLDVER}, but the new one will not be" eerror " built against any version and your database may be" eerror " inaccessible." echo fail=1 - elif [ "${OLDVER}" != "${NEWVER}" ]; then + elif [[ "${OLDVER}" != "${NEWVER}" ]]; then eerror " Your existing version of OpenLDAP was built against" eerror " sys-libs/db:${OLDVER}, but the new one will build against" eerror " ${NEWVER} and your database would be inaccessible." echo fail=1 fi - [ "${fail}" == "1" ] && openldap_upgrade_howto + [[ "${fail}" == "1" ]] && openldap_upgrade_howto fi echo @@ -252,6 +289,7 @@ } openldap_upgrade_howto() { + local d l i eerror eerror "A (possible old) installation of OpenLDAP was detected," eerror "installation will not proceed for now." @@ -277,7 +315,7 @@ eerror "10. check that your data is intact." eerror "11. set up the new replication system." eerror - if [ "${FORCE_UPGRADE}" != "1" ]; then + if [[ "${FORCE_UPGRADE}" != "1" ]]; then die "You need to upgrade your database first" else eerror "You have the magical FORCE_UPGRADE=1 in place." @@ -308,69 +346,34 @@ src_prepare() { # ensure correct SLAPI path by default - sed -i -e 's,\(#define LDAPI_SOCK\).*,\1 "'"${EPREFIX}"'/var/run/openldap/slapd.sock",' \ - "${S}"/include/ldap_defaults.h - - epatch "${FILESDIR}"/${PN}-2.4.17-gcc44.patch - - epatch \ - "${FILESDIR}"/${PN}-2.2.14-perlthreadsfix.patch \ - "${FILESDIR}"/${PN}-2.4.15-ppolicy.patch + sed -e 's,\(#define LDAPI_SOCK\).*,\1 "'"${EPREFIX}"'/var/run/openldap/slapd.sock",' \ + -i include/ldap_defaults.h || die - # bug #116045 - still present in 2.4.28 - epatch "${FILESDIR}"/${PN}-2.4.35-contrib-smbk5pwd.patch - # bug #408077 - samba4 - epatch "${FILESDIR}"/${PN}-2.4.35-contrib-samba4.patch - - # bug #189817 - epatch "${FILESDIR}"/${PN}-2.4.11-libldap_r.patch + default + rm -r libraries/liblmdb || die - # bug #233633 - epatch "${FILESDIR}"/${PN}-2.4.45-fix-lmpasswd-gnutls-symbols.patch - - # bug #281495 - epatch "${FILESDIR}"/${PN}-2.4.28-gnutls-gcrypt.patch - - # bug #294350 - epatch "${FILESDIR}"/${PN}-2.4.6-evolution-ntlm.patch - - # unbreak /bin/sh -> dash - epatch "${FILESDIR}"/${PN}-2.4.28-fix-dash.patch - - # bug #420959 - epatch "${FILESDIR}"/${PN}-2.4.31-gcc47.patch - - # bug #622464 - epatch "${FILESDIR}"/${PN}-2.4.45-libressl.patch - - # unbundle lmdb - epatch "${FILESDIR}"/${PN}-2.4.42-mdb-unbundle.patch - rm -rf "${S}"/libraries/liblmdb - - epatch_user - - cd "${S}"/build || die + pushd build &>/dev/null || die einfo "Making sure upstream build strip does not do stripping too early" sed -i.orig \ -e '/^STRIP/s,-s,,g' \ top.mk || die "Failed to block stripping" # wrong assumption that /bin/sh is /bin/bash - sed -i \ + sed \ -e 's|/bin/sh|/bin/bash|g' \ - "${S}"/tests/scripts/* || die "sed failed" + -i tests/scripts/* || die "sed failed" - cd "${S}" || die + popd &>/dev/null || die AT_NOEAUTOMAKE=yes eautoreconf } build_contrib_module() { # <dir> <sources> <outputname> - cd "${S}/contrib/slapd-modules/$1" || die + pushd "contrib/slapd-modules/$1" &>/dev/null || die einfo "Compiling contrib-module: $3" # Make sure it's uppercase - local define_name="$(echo "SLAPD_OVER_${1}" | LC_ALL=C tr '[:lower:]' '[:upper:]')" + local define_name="$(LC_ALL=C tr '[:lower:]' '[:upper:]' <<< "SLAPD_OVER_${1}")" "${lt}" --mode=compile --tag=CC \ "${CC}" \ -D${define_name}=SLAPD_MOD_DYNAMIC \ @@ -384,6 +387,7 @@ ${LDFLAGS} \ -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \ -o $3.la ${2%.c}.lo || die "linking $3 failed" + popd &>/dev/null || die } src_configure() { @@ -416,8 +420,8 @@ if use berkdb ; then einfo "Using Berkeley DB for local backend" myconf+=( --enable-bdb --enable-hdb ) - DBINCLUDE=$(db_includedir $BDB_SLOTS) - einfo "Using $DBINCLUDE for sys-libs/db version" + DBINCLUDE=$(db_includedir ${BDB_SLOTS}) + einfo "Using ${DBINCLUDE} for sys-libs/db version" # We need to include the slotted db.h dir for FreeBSD append-cppflags -I${DBINCLUDE} else @@ -499,7 +503,7 @@ done tc-export AR CC CXX - ECONF_SOURCE=${S} \ + ECONF_SOURCE="${S}" \ STRIP=/bin/true \ econf \ --libexecdir="${EPREFIX}"/usr/$(get_libdir)/openldap \ @@ -517,7 +521,7 @@ ) mkdir -p "${BUILD_DIR}"/contrib/ldapc++ || die - cd "${BUILD_DIR}/contrib/ldapc++" || die + pushd "${BUILD_DIR}/contrib/ldapc++" &>/dev/null || die local LDFLAGS=${LDFLAGS} CPPFLAGS=${CPPFLAGS} append-ldflags -L"${BUILD_DIR}"/libraries/liblber/.libs \ @@ -527,6 +531,7 @@ econf "${myconf_ldapcpp[@]}" \ CC="${CC}" \ CXX="${CXX}" + popd &>/dev/null || die } multilib_src_compile() { @@ -539,14 +544,15 @@ if use cxx ; then einfo "Building contrib library: ldapc++" src_configure_cxx - cd "${BUILD_DIR}/contrib/ldapc++" || die + pushd "${BUILD_DIR}/contrib/ldapc++" &>/dev/null || die emake \ CC="${CC}" CXX="${CXX}" + popd &>/dev/null || die fi if use smbkrb5passwd ; then einfo "Building contrib-module: smbk5pwd" - cd "${S}/contrib/slapd-modules/smbk5pwd" || die + pushd contrib/slapd-modules/smbk5pwd &>/dev/null || die MY_DEFS="-DDO_SHADOW" if use samba ; then @@ -563,22 +569,24 @@ KRB5_INC="${MY_KRB5_INC}" \ LDAP_BUILD="${BUILD_DIR}" \ CC="${CC}" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" + popd &>/dev/null || die fi if use overlays ; then einfo "Building contrib-module: samba4" - cd "${S}/contrib/slapd-modules/samba4" || die + pushd contrib/slapd-modules/samba4 &>/dev/null || die emake \ LDAP_BUILD="${BUILD_DIR}" \ CC="${CC}" libexecdir="/usr/$(get_libdir)/openldap" + popd &>/dev/null || die fi if use kerberos ; then if use kinit ; then build_contrib_module "kinit" "kinit.c" "kinit" fi - cd "${S}/contrib/slapd-modules/passwd" || die + pushd contrib/slapd-modules/passwd &>/dev/null || die einfo "Compiling contrib-module: pw-kerberos" "${lt}" --mode=compile --tag=CC \ "${CC}" \ @@ -597,10 +605,11 @@ -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \ -o pw-kerberos.la \ kerberos.lo || die "linking pw-kerberos failed" + popd &>/dev/null || die fi if use pbkdf2; then - cd "${S}/contrib/slapd-modules/passwd/pbkdf2" || die + pushd contrib/slapd-modules/passwd/pbkdf2 &>/dev/null || die einfo "Compiling contrib-module: pw-pbkdf2" "${lt}" --mode=compile --tag=CC \ "${CC}" \ @@ -617,10 +626,11 @@ -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \ -o pw-pbkdf2.la \ pbkdf2.lo || die "linking pw-pbkdf2 failed" + popd &>/dev/null || die fi if use sha2 ; then - cd "${S}/contrib/slapd-modules/passwd/sha2" || die + pushd contrib/slapd-modules/passwd/sha2 &>/dev/null || die einfo "Compiling contrib-module: pw-sha2" "${lt}" --mode=compile --tag=CC \ "${CC}" \ @@ -644,10 +654,11 @@ -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \ -o pw-sha2.la \ sha2.lo slapd-sha2.lo || die "linking pw-sha2 failed" + popd &>/dev/null || die fi # We could build pw-radius if GNURadius would install radlib.h - cd "${S}/contrib/slapd-modules/passwd" || die + pushd contrib/slapd-modules/passwd &>/dev/null || die einfo "Compiling contrib-module: pw-netscape" "${lt}" --mode=compile --tag=CC \ "${CC}" \ @@ -683,8 +694,9 @@ build_contrib_module "nops" "nops.c" "nops-overlay" #build_contrib_module "nssov" "nssov.c" "nssov-overlay" RESO:LATER build_contrib_module "trace" "trace.c" "trace" + popd &>/dev/null || die # build slapi-plugins - cd "${S}/contrib/slapi-plugins/addrdnvalues" || die + pushd contrib/slapi-plugins/addrdnvalues &>/dev/null || die einfo "Building contrib-module: addrdnvalues plugin" "${CC}" -shared \ -I"${BUILD_DIR}"/include \ @@ -694,7 +706,7 @@ ${LDFLAGS} \ -o libaddrdnvalues-plugin.so \ addrdnvalues.c || die "Building libaddrdnvalues-plugin.so failed" - + popd &>/dev/null || die fi } @@ -719,26 +731,26 @@ use prefix || fowners ldap:ldap /var/lib/openldap-data fperms 0700 /var/lib/openldap-data - echo "OLDPF='${PF}'" > "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}" - echo "# do NOT delete this. it is used" >> "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}" - echo "# to track versions for upgrading." >> "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}" + echo "OLDPF='${PF}'" > "${ED%/}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}" + echo "# do NOT delete this. it is used" >> "${ED%/}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}" + echo "# to track versions for upgrading." >> "${ED%/}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}" # use our config - rm "${ED}"etc/openldap/slapd.conf + rm "${ED%/}"/etc/openldap/slapd.conf insinto /etc/openldap newins "${FILESDIR}"/${PN}-2.4.40-slapd-conf slapd.conf - configfile="${ED}"etc/openldap/slapd.conf + configfile="${ED%/}"/etc/openldap/slapd.conf # populate with built backends ebegin "populate config with built backends" - for x in "${ED}"usr/$(get_libdir)/openldap/openldap/back_*.so; do + for x in "${ED%/}"/usr/$(get_libdir)/openldap/openldap/back_*.so; do einfo "Adding $(basename ${x})" - sed -e "/###INSERTDYNAMICMODULESHERE###$/a# moduleload\t$(basename ${x})" -i "${configfile}" + sed -e "/###INSERTDYNAMICMODULESHERE###$/a# moduleload\t$(basename ${x})" -i "${configfile}" || die done sed -e "s:###INSERTDYNAMICMODULESHERE###$:# modulepath\t${EPREFIX}/usr/$(get_libdir)/openldap/openldap:" -i "${configfile}" use prefix || fowners root:ldap /etc/openldap/slapd.conf fperms 0640 /etc/openldap/slapd.conf - cp "${configfile}" "${configfile}".default + cp "${configfile}" "${configfile}".default || die eend # install our own init scripts and systemd unit files @@ -754,10 +766,12 @@ systemd_newtmpfilesd "${FILESDIR}"/slapd.tmpfilesd slapd.conf # If built without SLP, we don't need to be before avahi - use slp \ - || sed -i \ + if ! use slp ; then + sed -i \ -e '/before/{s/avahi-daemon//g}' \ - "${ED}"etc/init.d/slapd + "${ED%/}"/etc/init.d/slapd \ + || die + fi if use cxx ; then einfo "Install the ldapc++ library" @@ -790,7 +804,7 @@ for l in */*.la */*/*.la; do [[ -e ${l} ]] || continue "${lt}" --mode=install cp ${l} \ - "${ED}"usr/$(get_libdir)/openldap/openldap || \ + "${ED%/}"/usr/$(get_libdir)/openldap/openldap || \ die "installing ${l} failed" done @@ -821,7 +835,9 @@ newdoc "${S}"/contrib/slapd-tools/README README.statslog fi - use static-libs || prune_libtool_files --all + if ! use static-libs ; then + find "${ED}" \( -name '*.a' -o -name '*.la' \) -delete || die + fi } multilib_src_install_all() {