Merge pull request #118041 from Mic92/cutter

cutter: 1.12.0 -> 2.0.0
This commit is contained in:
Jörg Thalheim 2021-04-08 11:32:54 +01:00 committed by GitHub
commit 034c49f514
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 230 additions and 217 deletions

View file

@ -1,63 +0,0 @@
{ fetchFromGitHub, lib, mkDerivation
# nativeBuildInputs
, qmake, pkg-config
# Qt
, qtbase, qtsvg, qtwebengine
# buildInputs
, r2-for-cutter
, python3
, wrapQtAppsHook }:
mkDerivation rec {
pname = "radare2-cutter";
version = "1.12.0";
src = fetchFromGitHub {
owner = "radareorg";
repo = "cutter";
rev = "v${version}";
sha256 = "0ljj3j3apbbw628n2nyrxpbnclixx20bqjxm0xwggqzz9vywsar0";
};
postUnpack = "export sourceRoot=$sourceRoot/src";
# Remove this "very helpful" helper file intended for discovering r2,
# as it's a doozy of harddcoded paths and unexpected behavior.
# Happily Nix has everything all set so we don't need it,
# other than as basis for the qmakeFlags set below.
postPatch = ''
substituteInPlace Cutter.pro \
--replace "include(lib_radare2.pri)" ""
'';
nativeBuildInputs = [ qmake pkg-config python3 wrapQtAppsHook ];
propagatedBuildInputs = [ python3.pkgs.pyside2 ];
buildInputs = [ qtbase qtsvg qtwebengine r2-for-cutter python3 ];
qmakeFlags = with python3.pkgs; [
"CONFIG+=link_pkg-config"
"PKGCONFIG+=r_core"
# Leaving this enabled doesn't break build but generates errors
# at runtime (to console) about being unable to load needed bits.
# Disable until can be looked at.
"CUTTER_ENABLE_JUPYTER=false"
# Enable support for Python plugins
"CUTTER_ENABLE_PYTHON=true"
"CUTTER_ENABLE_PYTHON_BINDINGS=true"
"SHIBOKEN_EXTRA_OPTIONS+=-I${r2-for-cutter}/include/libr"
];
preBuild = ''
export NIX_LDFLAGS="$NIX_LDFLAGS $(pkg-config --libs python3-embed)"
qtWrapperArgs+=(--prefix PYTHONPATH : "$PYTHONPATH")
'';
enableParallelBuilding = true;
meta = with lib; {
description = "A Qt and C++ GUI for radare2 reverse engineering framework";
homepage = src.meta.homepage;
license = licenses.gpl3;
maintainers = with maintainers; [ mic92 dtzWill ];
};
}

View file

@ -1,9 +1,21 @@
{lib, stdenv, fetchFromGitHub
{ lib
, stdenv
, fetchFromGitHub
, buildPackages
, pkg-config
, libusb-compat-0_1, readline, libewf, perl, zlib, openssl
, libuv, file, libzip, xxHash
, gtk2 ? null, vte ? null, gtkdialog ? null
, libusb-compat-0_1
, readline
, libewf
, perl
, zlib
, openssl
, libuv
, file
, libzip
, xxHash
, gtk2 ? null
, vte ? null
, gtkdialog ? null
, python3 ? null
, ruby ? null
, lua ? null
@ -21,108 +33,84 @@ assert pythonBindings -> python3 != null;
let
inherit (lib) optional;
generic = {
version_commit, # unused
gittap,
gittip,
rev,
version,
sha256,
cs_ver,
cs_sha256
}:
stdenv.mkDerivation {
pname = "radare2";
inherit version;
src = fetchFromGitHub {
owner = "radare";
repo = "radare2";
inherit rev sha256;
};
postPatch = let
capstone = fetchFromGitHub {
owner = "aquynh";
repo = "capstone";
# version from $sourceRoot/shlr/Makefile
rev = cs_ver;
sha256 = cs_sha256;
};
in ''
mkdir -p build/shlr
cp -r ${capstone} capstone-${cs_ver}
chmod -R +w capstone-${cs_ver}
# radare 3.3 compat for radare2-cutter
(cd shlr && ln -s ../capstone-${cs_ver} capstone)
tar -czvf shlr/capstone-${cs_ver}.tar.gz capstone-${cs_ver}
'';
postInstall = ''
install -D -m755 $src/binr/r2pm/r2pm $out/bin/r2pm
'';
WITHOUT_PULL="1";
makeFlags = [
"GITTAP=${gittap}"
"GITTIP=${gittip}"
"RANLIB=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.bintools.targetPrefix}ranlib"
];
configureFlags = [
"--with-sysmagic"
"--with-syszip"
"--with-sysxxhash"
"--with-openssl"
];
enableParallelBuilding = true;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ pkg-config ];
buildInputs = [ file readline libusb-compat-0_1 libewf perl zlib openssl libuv ]
++ optional useX11 [ gtkdialog vte gtk2 ]
++ optional rubyBindings [ ruby ]
++ optional pythonBindings [ python3 ]
++ optional luaBindings [ lua ];
propagatedBuildInputs = [
# radare2 exposes r_lib which depends on these libraries
file # for its list of magic numbers (`libmagic`)
libzip
xxHash
];
meta = {
description = "unix-like reverse engineering framework and commandline tools";
homepage = "http://radare.org/";
license = lib.licenses.gpl2Plus;
maintainers = with lib.maintainers; [ raskin makefu mic92 ];
platforms = with lib.platforms; linux;
inherit version;
};
};
in {
#<generated>
# DO NOT EDIT! Automatically generated by ./update.py
radare2 = generic {
version_commit = "25741";
gittap = "5.1.1";
gittip = "a86f8077fc148abd6443384362a3717cd4310e64";
rev = "5.1.1";
version = "5.1.1";
sha256 = "0hv9x31iabasj12g8f04incr1rbcdkxi3xnqn3ggp8gl4h6pf2f3";
cs_ver = "4.0.2";
cs_sha256 = "0y5g74yjyliciawpn16zhdwya7bd3d7b1cccpcccc2wg8vni1k2w";
};
r2-for-cutter = generic {
version_commit = "24959";
gittap = "4.5.1";
gittip = "293cf5ae65ba4e28828095dcae212955593ba255";
rev = "4.5.1";
version = "4.5.1";
sha256 = "0qigy1px0jy74c5ig73dc2fqjcy6vcy76i25dx9r3as6zfpkkaxj";
cs_ver = "4.0.2";
cs_sha256 = "0y5g74yjyliciawpn16zhdwya7bd3d7b1cccpcccc2wg8vni1k2w";
};
gittap = "5.1.1";
gittip = "a86f8077fc148abd6443384362a3717cd4310e64";
rev = "5.1.1";
version = "5.1.1";
sha256 = "0hv9x31iabasj12g8f04incr1rbcdkxi3xnqn3ggp8gl4h6pf2f3";
cs_ver = "4.0.2";
cs_sha256 = "0y5g74yjyliciawpn16zhdwya7bd3d7b1cccpcccc2wg8vni1k2w";
#</generated>
in
stdenv.mkDerivation {
pname = "radare2";
inherit version;
src = fetchFromGitHub {
owner = "radare";
repo = "radare2";
inherit rev sha256;
};
postPatch =
let
capstone = fetchFromGitHub {
owner = "aquynh";
repo = "capstone";
# version from $sourceRoot/shlr/Makefile
rev = cs_ver;
sha256 = cs_sha256;
};
in
''
mkdir -p build/shlr
cp -r ${capstone} capstone-${cs_ver}
chmod -R +w capstone-${cs_ver}
tar -czvf shlr/capstone-${cs_ver}.tar.gz capstone-${cs_ver}
'';
postInstall = ''
install -D -m755 $src/binr/r2pm/r2pm $out/bin/r2pm
'';
WITHOUT_PULL = "1";
makeFlags = [
"GITTAP=${gittap}"
"GITTIP=${gittip}"
"RANLIB=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.bintools.targetPrefix}ranlib"
];
configureFlags = [
"--with-sysmagic"
"--with-syszip"
"--with-sysxxhash"
"--with-openssl"
];
enableParallelBuilding = true;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ pkg-config ];
buildInputs = [ file readline libusb-compat-0_1 libewf perl zlib openssl libuv ]
++ optional useX11 [ gtkdialog vte gtk2 ]
++ optional rubyBindings [ ruby ]
++ optional pythonBindings [ python3 ]
++ optional luaBindings [ lua ];
propagatedBuildInputs = [
# radare2 exposes r_lib which depends on these libraries
file # for its list of magic numbers (`libmagic`)
libzip
xxHash
];
meta = {
description = "unix-like reverse engineering framework and commandline tools";
homepage = "http://radare.org/";
license = lib.licenses.gpl2Plus;
maintainers = with lib.maintainers; [ raskin makefu mic92 ];
platforms = with lib.platforms; linux;
inherit version;
};
}

View file

@ -48,24 +48,6 @@ def get_radare2_rev() -> str:
raise RuntimeError(f"No release found at {feed_url}")
def get_cutter_version() -> str:
version_expr = """
(with import <nixpkgs> {}; lib.getVersion (qt5.callPackage <radare2/cutter.nix> {}))
"""
return sh("nix", "eval", "--raw", version_expr.strip(), "-I", "radare2={0}".format(SCRIPT_DIR))
def get_r2_cutter_rev() -> str:
version = get_cutter_version()
url = f"https://api.github.com/repos/radareorg/cutter/contents?ref=v{version}"
with urllib.request.urlopen(url) as response:
data = json.load(response) # type: ignore
for entry in data:
if entry["name"] == "radare2":
return entry["sha"]
raise Exception("no radare2 submodule found in github.com/radareorg/cutter")
def git(dirname: str, *args: str) -> str:
return sh("git", "-C", dirname, *args)
@ -94,43 +76,23 @@ def get_repo_info(dirname: str, rev: str) -> Dict[str, str]:
)
def write_package_expr(version: str, info: Dict[str, str]) -> str:
return f"""generic {{
version_commit = "{info["version_commit"]}";
gittap = "{info["gittap"]}";
gittip = "{info["gittip"]}";
rev = "{info["rev"]}";
version = "{version}";
sha256 = "{info["sha256"]}";
cs_ver = "{info["cs_ver"]}";
cs_sha256 = "{info["cs_sha256"]}";
}}"""
def main() -> None:
radare2_rev = get_radare2_rev()
r2_cutter_rev = get_r2_cutter_rev()
version = get_radare2_rev()
with tempfile.TemporaryDirectory() as dirname:
git(
dirname,
"clone",
"--branch",
radare2_rev,
version,
"https://github.com/radare/radare2",
".",
)
nix_file = str(SCRIPT_DIR.joinpath("default.nix"))
radare2_info = get_repo_info(dirname, radare2_rev)
git(dirname, "fetch", r2_cutter_rev)
git(dirname, "checkout", r2_cutter_rev)
info = get_repo_info(dirname, version)
timestamp = git(dirname, "log", "-n1", "--format=%at")
r2_cutter_version = datetime.fromtimestamp(int(timestamp)).strftime("%Y-%m-%d")
r2_cutter_info = get_repo_info(dirname, r2_cutter_rev)
in_block = False
with fileinput.FileInput(nix_file, inplace=True) as f:
@ -140,8 +102,13 @@ def main() -> None:
print(
f""" #<generated>
# DO NOT EDIT! Automatically generated by ./update.py
radare2 = {write_package_expr(radare2_rev, radare2_info)};
r2-for-cutter = {write_package_expr(r2_cutter_version, r2_cutter_info)};
gittap = "{info["gittap"]}";
gittip = "{info["gittip"]}";
rev = "{info["rev"]}";
version = "{version}";
sha256 = "{info["sha256"]}";
cs_ver = "{info["cs_ver"]}";
cs_sha256 = "{info["cs_sha256"]}";
#</generated>"""
)
elif "#</generated>" in l:

View file

@ -0,0 +1,46 @@
{ fetchFromGitHub, lib, mkDerivation
# nativeBuildInputs
, qmake, pkg-config, cmake
# Qt
, qtbase, qtsvg, qtwebengine, qttools
# buildInputs
, rizin
, python3
, wrapQtAppsHook
}:
mkDerivation rec {
pname = "cutter";
version = "2.0.0";
src = fetchFromGitHub {
owner = "rizinorg";
repo = "cutter";
rev = "v${version}";
sha256 = "sha256-uIN/NR+swu9Ie0wP2aBhw5WBvTe9NDmzSs+lQMCeavc=";
fetchSubmodules = true;
};
nativeBuildInputs = [ cmake qmake pkg-config python3 wrapQtAppsHook ];
propagatedBuildInputs = [ python3.pkgs.pyside2 ];
buildInputs = [ qtbase qttools qtsvg qtwebengine rizin python3 ];
cmakeFlags = [
"-DCUTTER_USE_BUNDLED_RIZIN=OFF"
"-DCUTTER_ENABLE_PYTHON=ON"
"-DCUTTER_ENABLE_PYTHON_BINDINGS=ON"
];
preBuild = ''
qtWrapperArgs+=(--prefix PYTHONPATH : "$PYTHONPATH")
'';
enableParallelBuilding = true;
meta = with lib; {
description = "Free and Open Source Reverse Engineering Platform powered by rizin";
homepage = src.meta.homepage;
license = licenses.gpl3;
maintainers = with maintainers; [ mic92 dtzWill ];
};
}

View file

@ -0,0 +1,71 @@
{ lib
, stdenv
, fetchurl
, pkg-config
, libusb-compat-0_1
, readline
, libewf
, perl
, zlib
, openssl
, libuv
, file
, libzip
, lz4
, xxHash
, meson
, cmake
, ninja
, capstone
, tree-sitter
}:
stdenv.mkDerivation rec {
pname = "rizin";
version = "0.1.2";
src = fetchurl {
url = "https://github.com/rizinorg/rizin/releases/download/v${version}/rizin-src-${version}.tar.xz";
sha256 = "sha256-npUp8wJiKAaQKSigXtndhJLTJ4+pyFqa0FwDLBqR/sE=";
};
mesonFlags = [
"-Duse_sys_capstone=true"
"-Duse_sys_magic=true"
"-Duse_sys_libzip=true"
"-Duse_sys_zlib=true"
"-Duse_sys_xxhash=true"
"-Duse_sys_lz4=true"
"-Duse_sys_openssl=true"
"-Duse_sys_tree_sitter=true"
];
enableParallelBuilding = true;
nativeBuildInputs = [ pkg-config meson ninja cmake ];
buildInputs = [
file
libzip
capstone
readline
libusb-compat-0_1
libewf
perl
zlib
lz4
openssl
libuv
tree-sitter
xxHash
];
meta = {
description = "UNIX-like reverse engineering framework and command-line toolset.";
homepage = "https://rizin.re/";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ raskin makefu mic92 ];
platforms = with lib.platforms; linux;
inherit version;
};
}

View file

@ -1,10 +1,11 @@
{ lib, stdenv, fetchurl }:
stdenv.mkDerivation rec {
name = "cutter-1.04";
pname = "tcp-cutter";
version = "1.04";
src = fetchurl {
url = "http://www.digitage.co.uk/digitage/files/cutter/${name}.tgz";
url = "http://www.digitage.co.uk/digitage/files/cutter/${pname}-${version}.tgz";
sha256 = "100iy31a3njif6vh9gfsqrm14hac05rrflla275gd4rkxdlnqcqv";
};

View file

@ -620,6 +620,7 @@ mapAliases ({
qt-3 = throw "qt-3 has been removed from nixpkgs, as it's unmaintained and insecure"; # added 2021-02-15
rfkill = throw "rfkill has been removed, as it's included in util-linux"; # added 2020-08-23
riak-cs = throw "riak-cs is not maintained anymore"; # added 2020-10-14
radare2-cutter = cutter;
rkt = throw "rkt was archived by upstream"; # added 2020-05-16
ruby_2_0_0 = throw "ruby_2_0_0 was deprecated on 2018-02-13: use a newer version of ruby";
ruby_2_1_0 = throw "ruby_2_1_0 was deprecated on 2018-02-13: use a newer version of ruby";

View file

@ -3674,7 +3674,7 @@ in
curlftpfs = callPackage ../tools/filesystems/curlftpfs { };
cutter = callPackage ../tools/networking/cutter { };
tcp-cutter = callPackage ../tools/networking/tcp-cutter { };
cwebbin = callPackage ../development/tools/misc/cwebbin { };
@ -13154,12 +13154,14 @@ in
r10k = callPackage ../tools/system/r10k { };
inherit (callPackages ../development/tools/analysis/radare2 ({
radare2 = callPackage ../development/tools/analysis/radare2 ({
inherit (gnome2) vte;
lua = lua5;
} // (config.radare or {}))) radare2 r2-for-cutter;
} // (config.radare or {}));
radare2-cutter = libsForQt515.callPackage ../development/tools/analysis/radare2/cutter.nix { };
rizin = pkgs.callPackage ../development/tools/analysis/rizin { };
cutter = libsForQt515.callPackage ../development/tools/analysis/rizin/cutter.nix { };
ragel = ragelStable;