2019-01-06 18:10:47 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, python
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
|
|
|
, radare2
|
|
|
|
, coreutils
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "r2pipe";
|
2020-11-29 14:04:41 +00:00
|
|
|
version = "1.5.3";
|
2019-01-06 18:10:47 +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.
|
pythonPackages.r2pipe: Fix build
Regression introduced by 6556711c87f42e064ba01deb4c1e0aa917be8d66.
The string start and end quoting styles have changed in the upstream
source code between version 1.4.2 and version 1.5.3, so the checkPhase
now results in the following error:
======================================================================
ERROR: native (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: native
Traceback (most recent call last):
File ".../unittest/loader.py", line 154, in loadTestsFromName
module = __import__(module_name)
File "/build/r2pipe-1.5.3/r2pipe/native.py", line 113, in <module>
class RCore(Structure): # 1
File "/build/r2pipe-1.5.3/r2pipe/native.py", line 125, in RCore
cmd_str, r_core_cmd_str = register(
File "/build/r2pipe-1.5.3/r2pipe/native.py", line 108, in register
method = WrappedRMethod(cname, args, ret)
File "/build/r2pipe-1.5.3/r2pipe/native.py", line 53, in __init__
r2 = r2lib()
File "/build/r2pipe-1.5.3/r2pipe/native.py", line 27, in r2lib
raise ImportError("No native r_core library")
ImportError: No native r_core library
Signed-off-by: aszlig <aszlig@nix.build>
2020-12-30 15:09:05 +00:00
|
|
|
substituteInPlace r2pipe/native.py --replace 'find_library("r_core")' "'${libr_core}'"
|
2019-01-06 18:10:47 +00:00
|
|
|
|
|
|
|
# Fix the default r2 executable
|
pythonPackages.r2pipe: Fix build
Regression introduced by 6556711c87f42e064ba01deb4c1e0aa917be8d66.
The string start and end quoting styles have changed in the upstream
source code between version 1.4.2 and version 1.5.3, so the checkPhase
now results in the following error:
======================================================================
ERROR: native (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: native
Traceback (most recent call last):
File ".../unittest/loader.py", line 154, in loadTestsFromName
module = __import__(module_name)
File "/build/r2pipe-1.5.3/r2pipe/native.py", line 113, in <module>
class RCore(Structure): # 1
File "/build/r2pipe-1.5.3/r2pipe/native.py", line 125, in RCore
cmd_str, r_core_cmd_str = register(
File "/build/r2pipe-1.5.3/r2pipe/native.py", line 108, in register
method = WrappedRMethod(cname, args, ret)
File "/build/r2pipe-1.5.3/r2pipe/native.py", line 53, in __init__
r2 = r2lib()
File "/build/r2pipe-1.5.3/r2pipe/native.py", line 27, in r2lib
raise ImportError("No native r_core library")
ImportError: No native r_core library
Signed-off-by: aszlig <aszlig@nix.build>
2020-12-30 15:09:05 +00:00
|
|
|
substituteInPlace r2pipe/open_sync.py --replace 'r2e = "radare2"' "r2e = '${radare2}/bin/radare2'"
|
2019-01-06 18:10:47 +00:00
|
|
|
substituteInPlace r2pipe/open_base.py --replace 'which("radare2")' "'${radare2}/bin/radare2'"
|
|
|
|
'';
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2020-11-29 14:04:41 +00:00
|
|
|
sha256 = "8f3708195c8a6e91c5753940fd348cd821df1389d23b889b01b3e88acf407485";
|
2019-01-06 18:10:47 +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')
|
|
|
|
r2.quit()
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-01-06 18:10:47 +00:00
|
|
|
description = "Interact with radare2";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://github.com/radare/radare2-r2pipe";
|
2019-01-06 18:10:47 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ timokau ];
|
|
|
|
};
|
|
|
|
}
|