2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, python
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
|
|
|
, radare2
|
|
|
|
, coreutils
|
2022-12-17 10:02:37 +00:00
|
|
|
, pythonOlder
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "r2pipe";
|
2024-01-25 14:12:00 +00:00
|
|
|
version = "1.8.8";
|
2022-12-17 10:02:37 +00:00
|
|
|
format = "setuptools";
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.7";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postPatch = let
|
|
|
|
r2lib = "${lib.getOutput "lib" radare2}/lib";
|
|
|
|
libr_core = "${r2lib}/libr_core${stdenv.hostPlatform.extensions.sharedLibrary}";
|
|
|
|
in
|
|
|
|
''
|
|
|
|
# Fix find_library, can be removed after
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/7307 is resolved.
|
2021-01-15 22:18:51 +00:00
|
|
|
substituteInPlace r2pipe/native.py --replace 'find_library("r_core")' "'${libr_core}'"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Fix the default r2 executable
|
2021-01-15 22:18:51 +00:00
|
|
|
substituteInPlace r2pipe/open_sync.py --replace 'r2e = "radare2"' "r2e = '${radare2}/bin/radare2'"
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace r2pipe/open_base.py --replace 'which("radare2")' "'${radare2}/bin/radare2'"
|
|
|
|
'';
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2024-01-25 14:12:00 +00:00
|
|
|
hash = "sha256-wAOmO5bev1zgPcJoiqKlS4anUKayo8HsncQXM+b1clQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Tiny sanity check to make sure r2pipe finds radare2 (since r2pipe doesn't
|
|
|
|
# provide its own tests):
|
|
|
|
# Analyze ls with the fastest analysis and do nothing with the result.
|
|
|
|
postCheck = ''
|
|
|
|
${python.interpreter} <<EOF
|
|
|
|
import r2pipe
|
|
|
|
r2 = r2pipe.open('${coreutils}/bin/ls')
|
|
|
|
r2.cmd('a')
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Interact with radare2";
|
|
|
|
homepage = "https://github.com/radare/radare2-r2pipe";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ timokau ];
|
|
|
|
};
|
|
|
|
}
|