From 15c32e35190c4f7d00571da99fbb43598db172ce Mon Sep 17 00:00:00 2001 From: Knarkzel <85593302+knarkzel@users.noreply.github.com> Date: Fri, 10 May 2024 20:58:47 +0200 Subject: [PATCH 1/2] Copy files over first, then apply patchelf --- flake.nix | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/flake.nix b/flake.nix index 881cd7ee..be16ccad 100644 --- a/flake.nix +++ b/flake.nix @@ -134,35 +134,40 @@ 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} + '' + ( 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 + echo "Listing files in ${destination}/erts-14.2.1/bin/" + ls -al ${destination}/erts-14.2.1/bin/ + + # 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/* From a4bbe52ddac952c4adf7cb178bcfb3d70c7a50fc Mon Sep 17 00:00:00 2001 From: Knarkzel <85593302+knarkzel@users.noreply.github.com> Date: Fri, 10 May 2024 21:04:53 +0200 Subject: [PATCH 2/2] Make files writable for patchelf --- flake.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index be16ccad..9f7a8054 100644 --- a/flake.nix +++ b/flake.nix @@ -141,13 +141,15 @@ 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 '' - echo "Listing files in ${destination}/erts-14.2.1/bin/" - ls -al ${destination}/erts-14.2.1/bin/ - # 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