2021-04-08 16:26:57 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2020-04-24 23:36:52 +00:00
|
|
|
, buildPackages
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config
|
2021-04-08 16:26:57 +00:00
|
|
|
, libusb-compat-0_1
|
|
|
|
, readline
|
|
|
|
, libewf
|
|
|
|
, perl
|
|
|
|
, zlib
|
|
|
|
, openssl
|
|
|
|
, libuv
|
|
|
|
, file
|
|
|
|
, libzip
|
|
|
|
, xxHash
|
|
|
|
, gtk2
|
|
|
|
, vte
|
|
|
|
, gtkdialog
|
|
|
|
, python3
|
|
|
|
, ruby
|
|
|
|
, lua
|
2021-04-22 02:08:21 +00:00
|
|
|
, capstone
|
2020-04-24 23:36:52 +00:00
|
|
|
, useX11 ? false
|
|
|
|
, rubyBindings ? false
|
|
|
|
, pythonBindings ? false
|
|
|
|
, luaBindings ? false
|
|
|
|
}:
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
let
|
2021-08-25 08:27:29 +00:00
|
|
|
# FIXME: Compare revision with https://github.com/radareorg/radare2/blob/master/libr/asm/arch/arm/v35arm64/Makefile#L20
|
2021-08-22 07:53:02 +00:00
|
|
|
arm64 = fetchFromGitHub {
|
|
|
|
owner = "radareorg";
|
|
|
|
repo = "vector35-arch-arm64";
|
2021-10-17 09:34:42 +00:00
|
|
|
rev = "3c5eaba46dab72ecb7d5f5b865a13fdeee95b464";
|
|
|
|
sha256 = "sha256-alcGEi+D8CptXzfznnuxQKCvU2mbzn2sQge5jSqLVpg=";
|
2021-08-22 07:53:02 +00:00
|
|
|
};
|
2021-12-19 01:06:50 +00:00
|
|
|
armv7 = fetchFromGitHub {
|
|
|
|
owner = "radareorg";
|
|
|
|
repo = "vector35-arch-armv7";
|
|
|
|
rev = "dde39f69ffea19fc37e681874b12cb4707bc4f30";
|
|
|
|
|
|
|
|
sha256 = "sha256-bnWQc0dScM9rhIdzf+iVXvMqYWq/bguEAUQPaZRgdlU=";
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
in
|
2021-04-25 03:57:28 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2021-04-08 16:26:57 +00:00
|
|
|
pname = "radare2";
|
2021-12-24 04:21:11 +00:00
|
|
|
version = "5.5.4";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-08 16:26:57 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "radare";
|
|
|
|
repo = "radare2";
|
2021-04-25 03:57:28 +00:00
|
|
|
rev = version;
|
2021-12-24 04:21:11 +00:00
|
|
|
sha256 = "sha256-zELmNpbT1JCt0UAzHwzcTDN9QZTLQY0+rG9zVRWxiFg=";
|
2021-04-08 16:26:57 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
preBuild = ''
|
|
|
|
cp -r ${arm64} libr/asm/arch/arm/v35arm64/arch-arm64
|
|
|
|
chmod -R +w libr/asm/arch/arm/v35arm64/arch-arm64
|
2021-12-19 01:06:50 +00:00
|
|
|
|
|
|
|
cp -r ${armv7} libr/asm/arch/arm/v35arm64/arch-armv7
|
|
|
|
chmod -R +w libr/asm/arch/arm/v35arm64/arch-armv7
|
2021-08-22 07:53:02 +00:00
|
|
|
'';
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
postFixup = lib.optionalString stdenv.isDarwin ''
|
|
|
|
for file in $out/bin/rasm2 $out/bin/ragg2 $out/bin/rabin2 $out/lib/libr_asm.${version}.dylib; do
|
|
|
|
install_name_tool -change libcapstone.4.dylib ${capstone}/lib/libcapstone.4.dylib $file
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2021-04-08 16:26:57 +00:00
|
|
|
postInstall = ''
|
|
|
|
install -D -m755 $src/binr/r2pm/r2pm $out/bin/r2pm
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-08 16:26:57 +00:00
|
|
|
WITHOUT_PULL = "1";
|
|
|
|
makeFlags = [
|
2021-04-25 03:57:28 +00:00
|
|
|
"GITTAP=${version}"
|
2021-04-08 16:26:57 +00:00
|
|
|
"RANLIB=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.bintools.targetPrefix}ranlib"
|
2021-12-06 16:07:01 +00:00
|
|
|
"CC=${stdenv.cc.targetPrefix}cc"
|
|
|
|
"HOST_CC=${stdenv.cc.targetPrefix}cc"
|
2021-04-08 16:26:57 +00:00
|
|
|
];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2021-04-08 16:26:57 +00:00
|
|
|
configureFlags = [
|
|
|
|
"--with-sysmagic"
|
|
|
|
"--with-syszip"
|
|
|
|
"--with-sysxxhash"
|
2021-04-22 02:08:21 +00:00
|
|
|
"--with-syscapstone"
|
2021-04-08 16:26:57 +00:00
|
|
|
"--with-openssl"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-08 16:26:57 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-08 16:26:57 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2021-04-22 02:08:21 +00:00
|
|
|
buildInputs = [
|
|
|
|
capstone
|
|
|
|
file
|
|
|
|
readline
|
|
|
|
libusb-compat-0_1
|
|
|
|
libewf
|
|
|
|
perl
|
|
|
|
zlib
|
|
|
|
openssl
|
|
|
|
libuv
|
2021-04-25 03:57:28 +00:00
|
|
|
] ++ lib.optional useX11 [ gtkdialog vte gtk2 ]
|
|
|
|
++ lib.optional rubyBindings [ ruby ]
|
|
|
|
++ lib.optional pythonBindings [ python3 ]
|
|
|
|
++ lib.optional luaBindings [ lua ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-08 16:26:57 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
# radare2 exposes r_lib which depends on these libraries
|
|
|
|
file # for its list of magic numbers (`libmagic`)
|
|
|
|
libzip
|
|
|
|
xxHash
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
meta = with lib; {
|
2021-04-08 16:26:57 +00:00
|
|
|
description = "unix-like reverse engineering framework and commandline tools";
|
2021-12-06 16:07:01 +00:00
|
|
|
homepage = "https://radare.org/";
|
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
maintainers = with maintainers; [ raskin makefu mic92 arkivm ];
|
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|