Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy files over first, then apply patchelf #466

Merged
merged 2 commits into from
May 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -134,35 +134,42 @@
BURRITO_ERTS_PATH = "/tmp/beam/";
BURRITO_TARGET = lib.optional localBuild burritoExe.${system};

preBuild =
preBuild = let
destination = "/tmp/beam/otp";
in
''
export HOME="$TEMPDIR"
mkdir -p ${destination}
cp -r --no-preserve=timestamps ${beam}/. ${destination}
chmod -R u+w ${destination} # Make all copied files writable

# Listing files in the destination to confirm
echo "Listing files in ${destination}/erts-14.2.1/bin/"
ls -al ${destination}/erts-14.2.1/bin/
'' +
(
if (pkgs.stdenv.isLinux)
then ''
ls -al ${beam}/erts-14.2.1/bin/
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/beam.smp
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/ct_run
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/dialyzer
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/dyn_erl
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/epmd
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/erl_call
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/erl_child_setup
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/erlc
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/erlexec
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/escript
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/heart
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/inet_gethost
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/run_erl
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/to_erl
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/typer
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${beam}/erts-14.2.1/bin/yielding_c_fun
# Applying patchelf to binaries in the copied directory
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/beam.smp
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/ct_run
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/dialyzer
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/dyn_erl
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/epmd
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/erl_call
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/erl_child_setup
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/erlc
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/erlexec
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/escript
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/heart
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/inet_gethost
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/run_erl
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/to_erl
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/typer
patchelf --set-interpreter ${muslPkg}/${rawmusl.file} ${destination}/erts-14.2.1/bin/yielding_c_fun
''
else ""
)
+ ''
export HOME="$TEMPDIR"
mkdir -p /tmp/beam/otp
cp -r --no-preserve=timestamps ${beam}/. /tmp/beam/otp
'';
);

postInstall = ''
chmod +x ./burrito_out/*
Expand Down