autoPatchelfHook: expose script as top level package

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2024-09-06 20:38:58 +02:00
parent 1fc7b4e48c
commit 567bd7c6a6
No known key found for this signature in database
GPG Key ID: E13DFD4B47127951
4 changed files with 44 additions and 7 deletions

View File

@ -79,7 +79,7 @@ autoPatchelf() {
fi
done
@pythonInterpreter@ @autoPatchelfScript@ \
auto-patchelf \
${norecurse:+--no-recurse} \
--ignore-missing "${ignoreMissingDepsArray[@]}" \
--paths "$@" \

View File

@ -425,7 +425,7 @@ interpreter_arch: str = None # type: ignore
libc_lib: Path = None # type: ignore
if __name__ == "__main__":
nix_support = Path(os.environ['NIX_BINTOOLS']) / 'nix-support'
nix_support = Path(os.environ.get('NIX_BINTOOLS', os.environ['DEFAULT_BINTOOLS'])) / 'nix-support'
interpreter_path = Path((nix_support / 'dynamic-linker').read_text().strip())
libc_lib = Path((nix_support / 'orig-libc').read_text().strip()) / 'lib'

View File

@ -0,0 +1,41 @@
{
lib,
python3Packages,
}:
python3Packages.buildPythonApplication {
pname = "auto-patchelf";
version = "0-unstable-2024-08-14";
pyproject = false;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./auto-patchelf.py
];
};
dependencies = with python3Packages; [
pyelftools
];
installPhase = ''
runHook preInstall
install -Dm755 auto-patchelf.py $out/bin/auto-patchelf
runHook postInstall
'';
makeWrapperArgs = [
"--set DEFAULT_BINTOOLS $NIX_BINTOOLS"
];
meta = {
description = "Automatically patch ELF binaries using patchelf";
mainProgram = "auto-patchelf";
license = lib.licenses.mit;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ Scrumplex ];
};
}

View File

@ -188,11 +188,7 @@ with pkgs;
autoPatchelfHook = makeSetupHook {
name = "auto-patchelf-hook";
propagatedBuildInputs = [ bintools ];
substitutions = {
pythonInterpreter = "${python3.withPackages (ps: [ ps.pyelftools ])}/bin/python";
autoPatchelfScript = ../build-support/setup-hooks/auto-patchelf.py;
};
propagatedBuildInputs = [ auto-patchelf bintools ];
} ../build-support/setup-hooks/auto-patchelf.sh;
tomato-c = callPackage ../applications/misc/tomato-c { };