Merge pull request #307655 from Mic92/pwndbg

pwngdb: make gdbinit.py self-contained
This commit is contained in:
Jörg Thalheim 2024-04-29 09:59:58 +02:00 committed by GitHub
commit fe4d0e07ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,7 +18,7 @@ let
python3.pkgs.ropgadget # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/commands/rop.py#L32 python3.pkgs.ropgadget # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/commands/rop.py#L32
]); ]);
in in
stdenv.mkDerivation rec { stdenv.mkDerivation {
pname = "pwndbg"; pname = "pwndbg";
version = lib.getVersion pwndbg-py; version = lib.getVersion pwndbg-py;
format = "other"; format = "other";
@ -31,20 +31,32 @@ stdenv.mkDerivation rec {
runHook preInstall runHook preInstall
mkdir -p $out/share/pwndbg mkdir -p $out/share/pwndbg
cp gdbinit.py $out/share/pwndbg cp gdbinit.py $out/share/pwndbg/gdbinit.py
chmod +x $out/share/pwndbg/gdbinit.py chmod +x $out/share/pwndbg/gdbinit.py
# First line is a import from future, so we need to append our imports after that
sed '2 i import sys, os
3 i [sys.path.append(p) for p in "${pythonPath}".split(":")]
4 i os.environ["PATH"] += ":${binPath}"' -i $out/share/pwndbg/gdbinit.py
# Don't require an in-package venv # Don't require an in-package venv
touch $out/share/pwndbg/.skip-venv touch $out/share/pwndbg/.skip-venv
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"
--prefix PATH : ${binPath} \
--set PYTHONPATH ${pythonPath} \
runHook postInstall runHook postInstall
''; '';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
# Check if pwndbg is installed correctly
HOME=$TMPDIR LC_CTYPE=C.UTF-8 $out/bin/pwndbg -ex exit
runHook postInstallCheck
'';
meta = with lib; { meta = with lib; {
description = "Exploit Development and Reverse Engineering with GDB Made Easy"; description = "Exploit Development and Reverse Engineering with GDB Made Easy";
mainProgram = "pwndbg"; mainProgram = "pwndbg";