Skip to content

Commit

Permalink
dotnetCorePackages.patchNupkgs: fix patchelf usage
Browse files Browse the repository at this point in the history
  • Loading branch information
GGG-KILLER committed Dec 7, 2024
1 parent 6d8ddd8 commit a00e463
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkgs/development/compilers/dotnet/patch-nupkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ writeShellScriptBin "patch-nupkgs" (
find "$x" -type f -print0 | while IFS= read -rd "" p; do
if [[ "$p" != *.nix-patched ]] \
&& isELF "$p" \
&& ${patchelf}/bin/patchelf --print-interpreter "$p" &>/dev/null; then
&& interpreter=$(${patchelf}/bin/patchelf --print-interpreter "$p") \
&& [ -n "$interpreter" ]; then
tmp="$p".$$.nix-patched
# if this fails to copy then another process must have patched it
cp --reflink=auto "$p" "$tmp" || continue
echo "Patchelfing $p as $tmp"
${patchelf}/bin/patchelf \
--set-interpreter "${stdenv.cc.bintools.dynamicLinker}" \
"$tmp" ||:
"$tmp"
# This makes sure that if the binary requires some specific runtime dependencies, it can find it.
# This fixes dotnet-built binaries like crossgen2
${patchelf}/bin/patchelf \
Expand All @@ -69,7 +72,8 @@ writeShellScriptBin "patch-nupkgs" (
"$tmp"
${patchelf}/bin/patchelf \
--add-rpath "${binaryRPath}" \
"$tmp" ||:
"$tmp"
mv "$tmp" "$p"
fi
done
Expand Down

0 comments on commit a00e463

Please sign in to comment.