fix nix + charset + bump dependencies (#2355)

* fix charset issues

* use '.skip-venv' in nix'ed pwndbg

* bump nix & python dependencies, gdb15.1, python3.12.4
This commit is contained in:
patryk4815 2024-08-14 00:19:23 +02:00 committed by GitHub
parent 8b24e27152
commit 620f38008c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 800 additions and 576 deletions

View File

@ -5,11 +5,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1694529238, "lastModified": 1710146030,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -26,11 +26,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1698974481, "lastModified": 1703863825,
"narHash": "sha256-yPncV9Ohdz1zPZxYHQf47S8S0VrnhV7nNhCawY46hDA=", "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nix-github-actions", "repo": "nix-github-actions",
"rev": "4bb5e752616262457bc7ca5882192a564c0472d2", "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -41,11 +41,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1698855203, "lastModified": 1723541349,
"narHash": "sha256-I9Vrh2ZXBZciGjgIXVhlHNc9XxRt0+bGlUGLGDXQ2r8=", "narHash": "sha256-LrmeqqHdPgAJsVKIJja8jGgRG/CA2y6SGT2TjX5Do68=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "39d2f0847ebbb57beb8fe3b992b043ad39afa0af", "rev": "4877ea239f4d02410c3516101faf35a81af0c30e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -66,11 +66,11 @@
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1707195113, "lastModified": 1723512448,
"narHash": "sha256-xPFxTMe4rKE/ZWLlOWv22qpGwpozpR+U1zhyf1040Zk=", "narHash": "sha256-VSTtxGKre1p6zd6ACuBmfDcR+BT9+ml8Y3KrSbfGFYU=",
"owner": "nix-community", "owner": "nix-community",
"repo": "poetry2nix", "repo": "poetry2nix",
"rev": "4eb2ac54029af42a001c9901194e9ce19cbd8a40", "rev": "ed52f844c4dd04dde45550c3189529854384124e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -122,11 +122,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1699786194, "lastModified": 1719749022,
"narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=", "narHash": "sha256-ddPKHcqaKCIFSFc/cvxS14goUhCOAwsM1PbMr0ZtHMg=",
"owner": "numtide", "owner": "numtide",
"repo": "treefmt-nix", "repo": "treefmt-nix",
"rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1", "rev": "8df5ff62195d4e67e2264df0b7f5e8c9995fd0bd",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -172,7 +172,12 @@ def main() -> None:
fixup_paths(src_root, venv_path) fixup_paths(src_root, venv_path)
# Force UTF-8 encoding (to_string=True to skip output appearing to the user) # Force UTF-8 encoding (to_string=True to skip output appearing to the user)
gdb.execute("set charset UTF-8", to_string=True) try:
gdb.execute("set target-wide-charset UTF-8", to_string=True)
gdb.execute("set charset UTF-8", to_string=True)
except gdb.error as e:
print(f"Warning: Cannot set gdb charset: '{e}'")
os.environ["PWNLIB_NOTERM"] = "1" os.environ["PWNLIB_NOTERM"] = "1"
import pwndbg # noqa: F811 import pwndbg # noqa: F811

View File

@ -5,9 +5,10 @@
let let
gdb = pwndbg.meta.gdb; gdb = pwndbg.meta.gdb;
python3 = pwndbg.meta.python3; python3 = pwndbg.meta.python3;
pwndbgVenv = pwndbg.meta.pwndbgVenv;
gdbBundledLib = pkgs.callPackage ./bundle { } "${gdb}/bin/gdb"; gdbBundledLib = pkgs.callPackage ./bundle { } "${gdb}/bin/gdb";
pyEnvBundledLib = pkgs.callPackage ./bundle { } "${pwndbg}/share/pwndbg/.venv/lib/"; pyEnvBundledLib = pkgs.callPackage ./bundle { } "${pwndbgVenv}/lib/";
ldName = pkgs.lib.readFile ( ldName = pkgs.lib.readFile (
pkgs.runCommand "bundle" { nativeBuildInputs = [ pkgs.patchelf ]; } '' pkgs.runCommand "bundle" { nativeBuildInputs = [ pkgs.patchelf ]; } ''
@ -20,8 +21,7 @@ let
dir="$(cd -- "$(dirname "$(dirname "$(realpath "$0")")")" >/dev/null 2>&1 ; pwd -P)" dir="$(cd -- "$(dirname "$(dirname "$(realpath "$0")")")" >/dev/null 2>&1 ; pwd -P)"
export PYTHONHOME="$dir" export PYTHONHOME="$dir"
export PYTHONPYCACHEPREFIX="$dir/cache/" export PYTHONPYCACHEPREFIX="$dir/cache/"
export PWNDBG_VENV_PATH="PWNDBG_PLEASE_SKIP_VENV" exec "$dir/lib/${ldName}" "$dir/exe/gdb" --quiet --early-init-eval-command="set auto-load safe-path /" --command=$dir/exe/gdbinit.py "$@"
exec "$dir/lib/${ldName}" "$dir/exe/gdb" --quiet --early-init-eval-command="set charset UTF-8" --early-init-eval-command="set auto-load safe-path /" --command=$dir/exe/gdbinit.py "$@"
''; '';
# for cache: pwndbg --eval-command="py import compileall; compileall.compile_dir('/usr/lib/pwndbg/'); exit()" # for cache: pwndbg --eval-command="py import compileall; compileall.compile_dir('/usr/lib/pwndbg/'); exit()"
@ -41,12 +41,13 @@ let
mkdir -p $out/pwndbg/exe/ mkdir -p $out/pwndbg/exe/
mkdir -p $out/pwndbg/share/gdb/ mkdir -p $out/pwndbg/share/gdb/
mkdir -p $out/pwndbg/cache/ mkdir -p $out/pwndbg/cache/
touch $out/pwndbg/exe/.skip-venv
cp -rf ${gdbBundledLib}/exe/* $out/pwndbg/exe/ cp -rf ${gdbBundledLib}/exe/* $out/pwndbg/exe/
cp -rf ${gdbBundledLib}/lib/* $out/pwndbg/lib/ cp -rf ${gdbBundledLib}/lib/* $out/pwndbg/lib/
cp -rf ${pyEnvBundledLib}/lib/* $out/pwndbg/lib/ cp -rf ${pyEnvBundledLib}/lib/* $out/pwndbg/lib/
cp -rf ${pwndbg}/share/pwndbg/.venv/share/gdb/* $out/pwndbg/share/gdb/ cp -rf ${pwndbgVenv}/share/gdb/* $out/pwndbg/share/gdb/
cp -rf ${gdb}/share/gdb/* $out/pwndbg/share/gdb/ cp -rf ${gdb}/share/gdb/* $out/pwndbg/share/gdb/
chmod -R +w $out chmod -R +w $out

View File

@ -58,13 +58,13 @@ let
sys.path.insert(0, '$out/share/pwndbg/')\n\ sys.path.insert(0, '$out/share/pwndbg/')\n\
os.environ['PATH'] += ':${binPath}'\n" -i $out/share/pwndbg/gdbinit.py os.environ['PATH'] += ':${binPath}'\n" -i $out/share/pwndbg/gdbinit.py
ln -s ${pyEnv} $out/share/pwndbg/.venv touch $out/share/pwndbg/.skip-venv
makeWrapper ${gdb}/bin/gdb $out/bin/pwndbg \ makeWrapper ${gdb}/bin/gdb $out/bin/pwndbg \
--add-flags "--quiet --early-init-eval-command=\"set auto-load safe-path /\" --command=$out/share/pwndbg/gdbinit.py" --add-flags "--quiet --early-init-eval-command=\"set auto-load safe-path /\" --command=$out/share/pwndbg/gdbinit.py"
''; '';
meta = { meta = {
pwndbgVenv = pyEnv;
python3 = python3; python3 = python3;
gdb = gdb; gdb = gdb;
}; };

1316
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -144,22 +144,22 @@ packages = [
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.8" python = "^3.8"
# Newer versions of capstone break tests # Newer versions of capstone break tests
capstone = "5.0.0.post1" capstone = "5.0.2"
# This is the last version of IPython that supports Python 3.8 # This is the last version of IPython that supports Python 3.8
ipython = "8.12.3" ipython = "8.12.3"
# Needed by Capstone due to https://github.com/pwndbg/pwndbg/pull/1946#issuecomment-1921603947 # Needed by Capstone due to https://github.com/pwndbg/pwndbg/pull/1946#issuecomment-1921603947
setuptools = "^70.0.0" setuptools = "^70.0.0"
psutil = "^5.9.8" psutil = "^5.9.8"
pwntools = "^4.12.0" pwntools = "^4.13.0"
pycparser = "^2.22" pycparser = "^2.22"
pyelftools = "^0.29" pyelftools = "^0.29"
pygments = "^2.17.2" pygments = "^2.18.0"
ropgadget = "7.3" ropgadget = "7.3"
sortedcontainers = "^2.4.0" sortedcontainers = "^2.4.0"
tabulate = "^0.9.0" tabulate = "^0.9.0"
typing-extensions = "^4.11.0" typing-extensions = "^4.12.0"
unicorn = "^2.0.1.post1" unicorn = "^2.0.1.post1"
requests = "^2.32.0" requests = "^2.32.3"
pt = {git = "https://github.com/martinradev/gdb-pt-dump", rev = "50227bda0b6332e94027f811a15879588de6d5cb"} pt = {git = "https://github.com/martinradev/gdb-pt-dump", rev = "50227bda0b6332e94027f811a15879588de6d5cb"}
[tool.poetry.group.dev] [tool.poetry.group.dev]