pwndbg: fix runtime python deps, fixes #71071
pwndbg is a Python module for gdb. The built-in interpreter is used and pwndbg offers additional routines. Packaging this is tricky because that interpreter needs to be used. Using `python3.withPackages` won't work. By setting `NIX_PYTHONPATH`, the interpreter should pick up pwndbg and its dependencies. If `NIX_PYTHONPATH` does not function we can fall back to `PYTHONPATH`. An example of when that won't work is if pwndbg runs a script of itself in a subshell. `NIX_PYTHONPATH` would be unset, but `PYTHONPATH` not.
This commit is contained in:
parent
80ac778c06
commit
27a9800e85
2 changed files with 22 additions and 32 deletions
|
@ -1,33 +1,12 @@
|
|||
{ stdenv
|
||||
, python3
|
||||
, fetchFromGitHub
|
||||
, makeWrapper
|
||||
, gdb
|
||||
, future
|
||||
, isort
|
||||
, psutil
|
||||
, pycparser
|
||||
, pyelftools
|
||||
, python-ptrace
|
||||
, ROPGadget
|
||||
, six
|
||||
, unicorn
|
||||
, pygments
|
||||
, }:
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "pwndbg";
|
||||
version = "2019.01.25";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "pwndbg";
|
||||
repo = "pwndbg";
|
||||
rev = version;
|
||||
sha256 = "0k7n6pcrj62ccag801yzf04a9mj9znghpkbnqwrzz0qn3rs42vgs";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
let
|
||||
pythonPath = with python3.pkgs; makePythonPath [
|
||||
future
|
||||
isort
|
||||
psutil
|
||||
|
@ -40,16 +19,27 @@ stdenv.mkDerivation rec {
|
|||
pygments
|
||||
];
|
||||
|
||||
in stdenv.mkDerivation rec {
|
||||
pname = "pwndbg";
|
||||
version = "2019.01.25";
|
||||
format = "other";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "pwndbg";
|
||||
repo = "pwndbg";
|
||||
rev = version;
|
||||
sha256 = "0k7n6pcrj62ccag801yzf04a9mj9znghpkbnqwrzz0qn3rs42vgs";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/pwndbg
|
||||
cp -r *.py pwndbg $out/share/pwndbg
|
||||
chmod +x $out/share/pwndbg/gdbinit.py
|
||||
makeWrapper ${gdb}/bin/gdb $out/bin/pwndbg \
|
||||
--add-flags "-q -x $out/share/pwndbg/gdbinit.py"
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
sed -i "/import sys/a import sys; sys.path[0:0] = '$PYTHONPATH'.split(':')" \
|
||||
$out/share/pwndbg/gdbinit.py
|
||||
--add-flags "-q -x $out/share/pwndbg/gdbinit.py" \
|
||||
--set NIX_PYTHONPATH ${pythonPath}
|
||||
'';
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
|
|
|
@ -5711,7 +5711,7 @@ in
|
|||
|
||||
pwnat = callPackage ../tools/networking/pwnat { };
|
||||
|
||||
pwndbg = python3Packages.callPackage ../development/tools/misc/pwndbg { };
|
||||
pwndbg = callPackage ../development/tools/misc/pwndbg { };
|
||||
|
||||
pycangjie = pythonPackages.pycangjie;
|
||||
|
||||
|
|
Loading…
Reference in a new issue