dotnet-sdk: patch shared libraries to find icu/libkrb5

This commit is contained in:
David McFarland
2022-09-14 08:43:44 -03:00
parent 848939f110
commit 747c5ca340
@@ -18,6 +18,7 @@ assert if type == "sdk" then packages != null else true;
, openssl_1_1
, libuuid
, zlib
, libkrb5
, curl
, lttng-ust_2_12
}:
@@ -41,23 +42,20 @@ stdenv.mkDerivation rec {
inherit pname version;
# Some of these dependencies are `dlopen()`ed.
rpath = lib.makeLibraryPath ([
stdenv.cc.cc
zlib
curl
icu
libunwind
libuuid
openssl_1_1
] ++ lib.optional stdenv.isLinux lttng-ust_2_12);
nativeBuildInputs = [
makeWrapper
] ++ lib.optional stdenv.isLinux autoPatchelfHook;
buildInputs = [
stdenv.cc.cc
];
zlib
icu
libkrb5
# this must be before curl for autoPatchElf to find it
# curl brings in its own openssl
openssl_1_1
curl
] ++ lib.optional stdenv.isLinux lttng-ust_2_12;
src = fetchurl (
srcs."${stdenv.hostPlatform.system}" or (throw
@@ -77,24 +75,30 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
postFixup = lib.optionalString stdenv.isLinux ''
patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $out/dotnet
patchelf --set-rpath "${rpath}" $out/dotnet
find $out -type f -name "*.so" -exec patchelf --set-rpath '$ORIGIN:${rpath}' {} \;
find $out -type f \( -name "apphost" -or -name "createdump" \) -exec patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" --set-rpath '$ORIGIN:${rpath}' {} \;
wrapProgram $out/bin/dotnet \
--prefix LD_LIBRARY_PATH : ${icu}/lib
'';
doInstallCheck = true;
installCheckPhase = ''
# Fixes cross
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
$out/bin/dotnet --info
'';
# Tell autoPatchelf about runtime dependencies.
# (postFixup phase is run before autoPatchelfHook.)
postFixup = lib.optionalString stdenv.isLinux ''
patchelf \
--add-needed libicui18n.so \
--add-needed libicuuc.so \
$out/shared/Microsoft.NETCore.App/*/libcoreclr.so \
$out/shared/Microsoft.NETCore.App/*/*System.Globalization.Native.so \
$out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
patchelf \
--add-needed libgssapi_krb5.so \
$out/shared/Microsoft.NETCore.App/*/*System.Net.Security.Native.so \
$out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
patchelf \
--add-needed libssl.so \
$out/shared/Microsoft.NETCore.App/*/*System.Security.Cryptography.Native.OpenSsl.so \
$out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
'';
setupHook = writeText "dotnet-setup-hook" ''
if [ ! -w "$HOME" ]; then
export HOME=$(mktemp -d) # Dotnet expects a writable home directory for its configuration files