Skip to content

Commit

Permalink
Copy files over first, then apply patchelf (#466)
Browse files Browse the repository at this point in the history
* Copy files over first, then apply patchelf

* Make files writable for patchelf
  • Loading branch information
svelterust authored May 11, 2024
1 parent 8c9a0ab commit 7a4c906
Showing 1 changed file with 31 additions and 24 deletions.
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

0 comments on commit 7a4c906

Please sign in to comment.