openldap: fix build if openssl or cyrus_sasl are overridden to null, add flag for cyrus_sasl, require openssl (#108046)

This commit is contained in:
sternenseemann 2021-02-19 01:35:39 +01:00 committed by GitHub
parent 78f333489e
commit dc7769bf7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,7 @@
{ lib, stdenv, fetchurl, openssl, cyrus_sasl, db, groff, libtool }: { lib, stdenv, fetchurl, openssl, db, groff, libtool
, withCyrusSasl ? true
, cyrus_sasl
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "openldap"; pname = "openldap";
@ -37,8 +40,7 @@ stdenv.mkDerivation rec {
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"--with-yielding_select=yes" "--with-yielding_select=yes"
"ac_cv_func_memcmp_working=yes" "ac_cv_func_memcmp_working=yes"
] ++ lib.optional (openssl == null) "--without-tls" ] ++ lib.optional (!withCyrusSasl) "--without-cyrus-sasl"
++ lib.optional (cyrus_sasl == null) "--without-cyrus-sasl"
++ lib.optional stdenv.isFreeBSD "--with-pic"; ++ lib.optional stdenv.isFreeBSD "--with-pic";
postBuild = '' postBuild = ''
@ -54,19 +56,21 @@ stdenv.mkDerivation rec {
"moduledir=$(out)/lib/modules" "moduledir=$(out)/lib/modules"
]; ];
# 1. Fixup broken libtool # 1. Libraries left in the build location confuse `patchelf --shrink-rpath`
# 2. Libraries left in the build location confuse `patchelf --shrink-rpath`
# Delete these to let patchelf discover the right path instead. # Delete these to let patchelf discover the right path instead.
# FIXME: that one can be removed when https://github.com/NixOS/patchelf/pull/98 # FIXME: that one can be removed when https://github.com/NixOS/patchelf/pull/98
# is in Nixpkgs patchelf. # is in Nixpkgs patchelf.
# 2. Fixup broken libtool for openssl and cyrus_sasl (if it is not disabled)
preFixup = '' preFixup = ''
sed -e 's,-lsasl2,-L${cyrus_sasl.out}/lib -lsasl2,' \ rm -r $out/var
-e 's,-lssl,-L${openssl.out}/lib -lssl,' \
-i $out/lib/libldap.la -i $out/lib/libldap_r.la
rm -rf $out/var
rm -r libraries/*/.libs rm -r libraries/*/.libs
rm -r contrib/slapd-modules/passwd/*/.libs rm -r contrib/slapd-modules/passwd/*/.libs
for f in $out/lib/libldap.la $out/lib/libldap_r.la; do
substituteInPlace "$f" --replace '-lssl' '-L${openssl.out}/lib -lssl'
'' + lib.optionalString withCyrusSasl ''
substituteInPlace "$f" --replace '-lsasl2' '-L${cyrus_sasl.out}/lib -lsasl2'
'' + ''
done
''; '';
postInstall = '' postInstall = ''