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
@ -1,33 +1,12 @@
|
|||||||
{ stdenv
|
{ stdenv
|
||||||
|
, python3
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
, gdb
|
, gdb
|
||||||
, future
|
}:
|
||||||
, isort
|
|
||||||
, psutil
|
|
||||||
, pycparser
|
|
||||||
, pyelftools
|
|
||||||
, python-ptrace
|
|
||||||
, ROPGadget
|
|
||||||
, six
|
|
||||||
, unicorn
|
|
||||||
, pygments
|
|
||||||
, }:
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
let
|
||||||
pname = "pwndbg";
|
pythonPath = with python3.pkgs; makePythonPath [
|
||||||
version = "2019.01.25";
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "pwndbg";
|
|
||||||
repo = "pwndbg";
|
|
||||||
rev = version;
|
|
||||||
sha256 = "0k7n6pcrj62ccag801yzf04a9mj9znghpkbnqwrzz0qn3rs42vgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
|
||||||
|
|
||||||
propagatedBuildInputs = [
|
|
||||||
future
|
future
|
||||||
isort
|
isort
|
||||||
psutil
|
psutil
|
||||||
@ -40,16 +19,27 @@ stdenv.mkDerivation rec {
|
|||||||
pygments
|
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 = ''
|
installPhase = ''
|
||||||
mkdir -p $out/share/pwndbg
|
mkdir -p $out/share/pwndbg
|
||||||
cp -r *.py pwndbg $out/share/pwndbg
|
cp -r *.py pwndbg $out/share/pwndbg
|
||||||
|
chmod +x $out/share/pwndbg/gdbinit.py
|
||||||
makeWrapper ${gdb}/bin/gdb $out/bin/pwndbg \
|
makeWrapper ${gdb}/bin/gdb $out/bin/pwndbg \
|
||||||
--add-flags "-q -x $out/share/pwndbg/gdbinit.py"
|
--add-flags "-q -x $out/share/pwndbg/gdbinit.py" \
|
||||||
'';
|
--set NIX_PYTHONPATH ${pythonPath}
|
||||||
|
|
||||||
preFixup = ''
|
|
||||||
sed -i "/import sys/a import sys; sys.path[0:0] = '$PYTHONPATH'.split(':')" \
|
|
||||||
$out/share/pwndbg/gdbinit.py
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
|
@ -5711,7 +5711,7 @@ in
|
|||||||
|
|
||||||
pwnat = callPackage ../tools/networking/pwnat { };
|
pwnat = callPackage ../tools/networking/pwnat { };
|
||||||
|
|
||||||
pwndbg = python3Packages.callPackage ../development/tools/misc/pwndbg { };
|
pwndbg = callPackage ../development/tools/misc/pwndbg { };
|
||||||
|
|
||||||
pycangjie = pythonPackages.pycangjie;
|
pycangjie = pythonPackages.pycangjie;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user