git.iko.soy/typeable/nixpkgs
on master help sign in
cutter: 1.12.0 -> 2.0.0

This also introduces rizin, which cutter builds on top

commitca9ca6eec9dfe610367cd82d7d20f17cf71736af authorJörg Thalheim <joerg@thalheim.io> dateTue 30 Mar 2021, 12:10 (6 years ago) parent77ca695
7 files changed+220−208
pkgs/development/tools/analysis/radare2/cutter.nix−63 pkgs/development/tools/analysis/radare2/default.nix+87−99 pkgs/development/tools/analysis/radare2/update.py+10−43 pkgs/development/tools/analysis/rizin/cutter.nix+46 pkgs/development/tools/analysis/rizin/default.nix+71 pkgs/top-level/aliases.nix+1 pkgs/top-level/all-packages.nix+5−3
pkgs/development/tools/analysis/radare2/cutter.nixdeleted−63
@@ -1,63 +0,0 @@
1−{ fetchFromGitHub, lib, mkDerivation
2−# nativeBuildInputs
3−, qmake, pkg-config
4−# Qt
5−, qtbase, qtsvg, qtwebengine
6−# buildInputs
7−, r2-for-cutter
8−, python3
9−, wrapQtAppsHook }:
10−
11−mkDerivation rec {
12− pname = "radare2-cutter";
13− version = "1.12.0";
14−
15− src = fetchFromGitHub {
16− owner = "radareorg";
17− repo = "cutter";
18− rev = "v${version}";
19− sha256 = "0ljj3j3apbbw628n2nyrxpbnclixx20bqjxm0xwggqzz9vywsar0";
20− };
21−
22− postUnpack = "export sourceRoot=$sourceRoot/src";
23−
24− # Remove this "very helpful" helper file intended for discovering r2,
25− # as it's a doozy of harddcoded paths and unexpected behavior.
26− # Happily Nix has everything all set so we don't need it,
27− # other than as basis for the qmakeFlags set below.
28− postPatch = ''
29− substituteInPlace Cutter.pro \
30− --replace "include(lib_radare2.pri)" ""
31− '';
32−
33− nativeBuildInputs = [ qmake pkg-config python3 wrapQtAppsHook ];
34− propagatedBuildInputs = [ python3.pkgs.pyside2 ];
35− buildInputs = [ qtbase qtsvg qtwebengine r2-for-cutter python3 ];
36−
37− qmakeFlags = with python3.pkgs; [
38− "CONFIG+=link_pkg-config"
39− "PKGCONFIG+=r_core"
40− # Leaving this enabled doesn't break build but generates errors
41− # at runtime (to console) about being unable to load needed bits.
42− # Disable until can be looked at.
43− "CUTTER_ENABLE_JUPYTER=false"
44− # Enable support for Python plugins
45− "CUTTER_ENABLE_PYTHON=true"
46− "CUTTER_ENABLE_PYTHON_BINDINGS=true"
47− "SHIBOKEN_EXTRA_OPTIONS+=-I${r2-for-cutter}/include/libr"
48− ];
49−
50− preBuild = ''
51− export NIX_LDFLAGS="$NIX_LDFLAGS $(pkg-config --libs python3-embed)"
52− qtWrapperArgs+=(--prefix PYTHONPATH : "$PYTHONPATH")
53− '';
54−
55− enableParallelBuilding = true;
56−
57− meta = with lib; {
58− description = "A Qt and C++ GUI for radare2 reverse engineering framework";
59− homepage = src.meta.homepage;
60− license = licenses.gpl3;
61− maintainers = with maintainers; [ mic92 dtzWill ];
62− };
63−}
pkgs/development/tools/analysis/radare2/default.nix+87−99
@@ -1,9 +1,21 @@
1−{lib, stdenv, fetchFromGitHub
1+{ lib
2+, stdenv
3+, fetchFromGitHub
24, buildPackages
35, pkg-config
4−, libusb-compat-0_1, readline, libewf, perl, zlib, openssl
5−, libuv, file, libzip, xxHash
6−, gtk2 ? null, vte ? null, gtkdialog ? null
6+, libusb-compat-0_1
7+, readline
8+, libewf
9+, perl
10+, zlib
11+, openssl
12+, libuv
13+, file
14+, libzip
15+, xxHash
16+, gtk2 ? null
17+, vte ? null
18+, gtkdialog ? null
719, python3 ? null
820, ruby ? null
921, lua ? null
@@ -21,108 +33,84 @@ assert pythonBindings -> python3 != null;
2133let
2234 inherit (lib) optional;
2335
24− generic = {
25− version_commit, # unused
26− gittap,
27− gittip,
28− rev,
29− version,
30− sha256,
31− cs_ver,
32− cs_sha256
33− }:
34− stdenv.mkDerivation {
35− pname = "radare2";
36− inherit version;
36+ #<generated>
37+ # DO NOT EDIT! Automatically generated by ./update.py
38+ gittap = "5.1.1";
39+ gittip = "a86f8077fc148abd6443384362a3717cd4310e64";
40+ rev = "5.1.1";
41+ version = "5.1.1";
42+ sha256 = "0hv9x31iabasj12g8f04incr1rbcdkxi3xnqn3ggp8gl4h6pf2f3";
43+ cs_ver = "4.0.2";
44+ cs_sha256 = "0y5g74yjyliciawpn16zhdwya7bd3d7b1cccpcccc2wg8vni1k2w";
45+ #</generated>
46+in
47+stdenv.mkDerivation {
48+ pname = "radare2";
49+ inherit version;
3750
38− src = fetchFromGitHub {
39− owner = "radare";
40− repo = "radare2";
41− inherit rev sha256;
42− };
51+ src = fetchFromGitHub {
52+ owner = "radare";
53+ repo = "radare2";
54+ inherit rev sha256;
55+ };
4356
44− postPatch = let
45− capstone = fetchFromGitHub {
46− owner = "aquynh";
47− repo = "capstone";
48− # version from $sourceRoot/shlr/Makefile
49− rev = cs_ver;
50− sha256 = cs_sha256;
51− };
52− in ''
53− mkdir -p build/shlr
54− cp -r ${capstone} capstone-${cs_ver}
55− chmod -R +w capstone-${cs_ver}
56− # radare 3.3 compat for radare2-cutter
57− (cd shlr && ln -s ../capstone-${cs_ver} capstone)
58− tar -czvf shlr/capstone-${cs_ver}.tar.gz capstone-${cs_ver}
59− '';
57+ postPatch =
58+ let
59+ capstone = fetchFromGitHub {
60+ owner = "aquynh";
61+ repo = "capstone";
62+ # version from $sourceRoot/shlr/Makefile
63+ rev = cs_ver;
64+ sha256 = cs_sha256;
65+ };
66+ in
67+ ''
68+ mkdir -p build/shlr
69+ cp -r ${capstone} capstone-${cs_ver}
70+ chmod -R +w capstone-${cs_ver}
71+ tar -czvf shlr/capstone-${cs_ver}.tar.gz capstone-${cs_ver}
72+ '';
6073
61− postInstall = ''
62− install -D -m755 $src/binr/r2pm/r2pm $out/bin/r2pm
63− '';
74+ postInstall = ''
75+ install -D -m755 $src/binr/r2pm/r2pm $out/bin/r2pm
76+ '';
6477
65− WITHOUT_PULL="1";
66− makeFlags = [
67− "GITTAP=${gittap}"
68− "GITTIP=${gittip}"
69− "RANLIB=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.bintools.targetPrefix}ranlib"
70− ];
71− configureFlags = [
72− "--with-sysmagic"
73− "--with-syszip"
74− "--with-sysxxhash"
75− "--with-openssl"
76− ];
78+ WITHOUT_PULL = "1";
79+ makeFlags = [
80+ "GITTAP=${gittap}"
81+ "GITTIP=${gittip}"
82+ "RANLIB=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.bintools.targetPrefix}ranlib"
83+ ];
84+ configureFlags = [
85+ "--with-sysmagic"
86+ "--with-syszip"
87+ "--with-sysxxhash"
88+ "--with-openssl"
89+ ];
7790
78− enableParallelBuilding = true;
79− depsBuildBuild = [ buildPackages.stdenv.cc ];
91+ enableParallelBuilding = true;
92+ depsBuildBuild = [ buildPackages.stdenv.cc ];
8093
81− nativeBuildInputs = [ pkg-config ];
82− buildInputs = [ file readline libusb-compat-0_1 libewf perl zlib openssl libuv ]
83− ++ optional useX11 [ gtkdialog vte gtk2 ]
84− ++ optional rubyBindings [ ruby ]
85− ++ optional pythonBindings [ python3 ]
86− ++ optional luaBindings [ lua ];
94+ nativeBuildInputs = [ pkg-config ];
95+ buildInputs = [ file readline libusb-compat-0_1 libewf perl zlib openssl libuv ]
96+ ++ optional useX11 [ gtkdialog vte gtk2 ]
97+ ++ optional rubyBindings [ ruby ]
98+ ++ optional pythonBindings [ python3 ]
99+ ++ optional luaBindings [ lua ];
87100
88− propagatedBuildInputs = [
89− # radare2 exposes r_lib which depends on these libraries
90− file # for its list of magic numbers (`libmagic`)
91− libzip
92− xxHash
93− ];
101+ propagatedBuildInputs = [
102+ # radare2 exposes r_lib which depends on these libraries
103+ file # for its list of magic numbers (`libmagic`)
104+ libzip
105+ xxHash
106+ ];
94107
95− meta = {
96− description = "unix-like reverse engineering framework and commandline tools";
97− homepage = "http://radare.org/";
98− license = lib.licenses.gpl2Plus;
99− maintainers = with lib.maintainers; [ raskin makefu mic92 ];
100− platforms = with lib.platforms; linux;
101− inherit version;
102− };
103− };
104−in {
105− #<generated>
106− # DO NOT EDIT! Automatically generated by ./update.py
107− radare2 = generic {
108− version_commit = "25741";
109− gittap = "5.1.1";
110− gittip = "a86f8077fc148abd6443384362a3717cd4310e64";
111− rev = "5.1.1";
112− version = "5.1.1";
113− sha256 = "0hv9x31iabasj12g8f04incr1rbcdkxi3xnqn3ggp8gl4h6pf2f3";
114− cs_ver = "4.0.2";
115− cs_sha256 = "0y5g74yjyliciawpn16zhdwya7bd3d7b1cccpcccc2wg8vni1k2w";
116− };
117− r2-for-cutter = generic {
118− version_commit = "24959";
119− gittap = "4.5.1";
120− gittip = "293cf5ae65ba4e28828095dcae212955593ba255";
121− rev = "4.5.1";
122− version = "4.5.1";
123− sha256 = "0qigy1px0jy74c5ig73dc2fqjcy6vcy76i25dx9r3as6zfpkkaxj";
124− cs_ver = "4.0.2";
125− cs_sha256 = "0y5g74yjyliciawpn16zhdwya7bd3d7b1cccpcccc2wg8vni1k2w";
108+ meta = {
109+ description = "unix-like reverse engineering framework and commandline tools";
110+ homepage = "http://radare.org/";
111+ license = lib.licenses.gpl2Plus;
112+ maintainers = with lib.maintainers; [ raskin makefu mic92 ];
113+ platforms = with lib.platforms; linux;
114+ inherit version;
126115 };
127− #</generated>
128116}
pkgs/development/tools/analysis/radare2/update.py+10−43
@@ -48,24 +48,6 @@ def get_radare2_rev() -> str:
4848 raise RuntimeError(f"No release found at {feed_url}")
4949
5050
51−def get_cutter_version() -> str:
52− version_expr = """
53−(with import <nixpkgs> {}; lib.getVersion (qt5.callPackage <radare2/cutter.nix> {}))
54−"""
55− return sh("nix", "eval", "--raw", version_expr.strip(), "-I", "radare2={0}".format(SCRIPT_DIR))
56−
57−
58−def get_r2_cutter_rev() -> str:
59− version = get_cutter_version()
60− url = f"https://api.github.com/repos/radareorg/cutter/contents?ref=v{version}"
61− with urllib.request.urlopen(url) as response:
62− data = json.load(response) # type: ignore
63− for entry in data:
64− if entry["name"] == "radare2":
65− return entry["sha"]
66− raise Exception("no radare2 submodule found in github.com/radareorg/cutter")
67−
68−
6951def git(dirname: str, *args: str) -> str:
7052 return sh("git", "-C", dirname, *args)
7153
@@ -94,43 +76,23 @@ def get_repo_info(dirname: str, rev: str) -> Dict[str, str]:
9476 )
9577
9678
97−def write_package_expr(version: str, info: Dict[str, str]) -> str:
98− return f"""generic {{
99− version_commit = "{info["version_commit"]}";
100− gittap = "{info["gittap"]}";
101− gittip = "{info["gittip"]}";
102− rev = "{info["rev"]}";
103− version = "{version}";
104− sha256 = "{info["sha256"]}";
105− cs_ver = "{info["cs_ver"]}";
106− cs_sha256 = "{info["cs_sha256"]}";
107− }}"""
108−
109−
11079def main() -> None:
111− radare2_rev = get_radare2_rev()
112− r2_cutter_rev = get_r2_cutter_rev()
80+ version = get_radare2_rev()
11381
11482 with tempfile.TemporaryDirectory() as dirname:
11583 git(
11684 dirname,
11785 "clone",
11886 "--branch",
119− radare2_rev,
87+ version,
12088 "https://github.com/radare/radare2",
12189 ".",
12290 )
12391 nix_file = str(SCRIPT_DIR.joinpath("default.nix"))
12492
125− radare2_info = get_repo_info(dirname, radare2_rev)
126−
127− git(dirname, "fetch", r2_cutter_rev)
128− git(dirname, "checkout", r2_cutter_rev)
93+ info = get_repo_info(dirname, version)
12994
13095 timestamp = git(dirname, "log", "-n1", "--format=%at")
131− r2_cutter_version = datetime.fromtimestamp(int(timestamp)).strftime("%Y-%m-%d")
132−
133− r2_cutter_info = get_repo_info(dirname, r2_cutter_rev)
13496
13597 in_block = False
13698 with fileinput.FileInput(nix_file, inplace=True) as f:
@@ -140,8 +102,13 @@ def main() -> None:
140102 print(
141103 f""" #<generated>
142104 # DO NOT EDIT! Automatically generated by ./update.py
143− radare2 = {write_package_expr(radare2_rev, radare2_info)};
144− r2-for-cutter = {write_package_expr(r2_cutter_version, r2_cutter_info)};
105+ gittap = "{info["gittap"]}";
106+ gittip = "{info["gittip"]}";
107+ rev = "{info["rev"]}";
108+ version = "{version}";
109+ sha256 = "{info["sha256"]}";
110+ cs_ver = "{info["cs_ver"]}";
111+ cs_sha256 = "{info["cs_sha256"]}";
145112 #</generated>"""
146113 )
147114 elif "#</generated>" in l:
pkgs/development/tools/analysis/rizin/cutter.nixnew file+46
@@ -0,0 +1,46 @@
1+{ fetchFromGitHub, lib, mkDerivation
2+# nativeBuildInputs
3+, qmake, pkg-config, cmake
4+# Qt
5+, qtbase, qtsvg, qtwebengine, qttools
6+# buildInputs
7+, rizin
8+, python3
9+, wrapQtAppsHook
10+}:
11+
12+mkDerivation rec {
13+ pname = "cutter";
14+ version = "2.0.0";
15+
16+ src = fetchFromGitHub {
17+ owner = "rizinorg";
18+ repo = "cutter";
19+ rev = "v${version}";
20+ sha256 = "sha256-uIN/NR+swu9Ie0wP2aBhw5WBvTe9NDmzSs+lQMCeavc=";
21+ fetchSubmodules = true;
22+ };
23+
24+ nativeBuildInputs = [ cmake qmake pkg-config python3 wrapQtAppsHook ];
25+ propagatedBuildInputs = [ python3.pkgs.pyside2 ];
26+ buildInputs = [ qtbase qttools qtsvg qtwebengine rizin python3 ];
27+
28+ cmakeFlags = [
29+ "-DCUTTER_USE_BUNDLED_RIZIN=OFF"
30+ "-DCUTTER_ENABLE_PYTHON=ON"
31+ "-DCUTTER_ENABLE_PYTHON_BINDINGS=ON"
32+ ];
33+
34+ preBuild = ''
35+ qtWrapperArgs+=(--prefix PYTHONPATH : "$PYTHONPATH")
36+ '';
37+
38+ enableParallelBuilding = true;
39+
40+ meta = with lib; {
41+ description = "Free and Open Source Reverse Engineering Platform powered by rizin";
42+ homepage = src.meta.homepage;
43+ license = licenses.gpl3;
44+ maintainers = with maintainers; [ mic92 dtzWill ];
45+ };
46+}
pkgs/development/tools/analysis/rizin/default.nixnew file+71
@@ -0,0 +1,71 @@
1+{ lib
2+, stdenv
3+, fetchurl
4+, pkg-config
5+, libusb-compat-0_1
6+, readline
7+, libewf
8+, perl
9+, zlib
10+, openssl
11+, libuv
12+, file
13+, libzip
14+, lz4
15+, xxHash
16+, meson
17+, cmake
18+, ninja
19+, capstone
20+, tree-sitter
21+}:
22+
23+stdenv.mkDerivation rec {
24+ pname = "rizin";
25+ version = "0.1.2";
26+
27+ src = fetchurl {
28+ url = "https://github.com/rizinorg/rizin/releases/download/v${version}/rizin-src-${version}.tar.xz";
29+ sha256 = "sha256-npUp8wJiKAaQKSigXtndhJLTJ4+pyFqa0FwDLBqR/sE=";
30+ };
31+
32+ mesonFlags = [
33+ "-Duse_sys_capstone=true"
34+ "-Duse_sys_magic=true"
35+ "-Duse_sys_libzip=true"
36+ "-Duse_sys_zlib=true"
37+ "-Duse_sys_xxhash=true"
38+ "-Duse_sys_lz4=true"
39+ "-Duse_sys_openssl=true"
40+ "-Duse_sys_tree_sitter=true"
41+ ];
42+
43+ enableParallelBuilding = true;
44+
45+ nativeBuildInputs = [ pkg-config meson ninja cmake ];
46+
47+ buildInputs = [
48+ file
49+ libzip
50+ capstone
51+ readline
52+ libusb-compat-0_1
53+ libewf
54+ perl
55+ zlib
56+ lz4
57+ openssl
58+ libuv
59+ tree-sitter
60+ xxHash
61+ ];
62+
63+ meta = {
64+ description = "UNIX-like reverse engineering framework and command-line toolset.";
65+ homepage = "https://rizin.re/";
66+ license = lib.licenses.gpl3Plus;
67+ maintainers = with lib.maintainers; [ raskin makefu mic92 ];
68+ platforms = with lib.platforms; linux;
69+ inherit version;
70+ };
71+}
pkgs/top-level/aliases.nix+1
@@ -608,6 +608,7 @@ mapAliases ({
608608 qt-3 = throw "qt-3 has been removed from nixpkgs, as it's unmaintained and insecure"; # added 2021-02-15
609609 rfkill = throw "rfkill has been removed, as it's included in util-linux"; # added 2020-08-23
610610 riak-cs = throw "riak-cs is not maintained anymore"; # added 2020-10-14
611+ radare2-cutter = cutter;
611612 rkt = throw "rkt was archived by upstream"; # added 2020-05-16
612613 ruby_2_0_0 = throw "ruby_2_0_0 was deprecated on 2018-02-13: use a newer version of ruby";
613614 ruby_2_1_0 = throw "ruby_2_1_0 was deprecated on 2018-02-13: use a newer version of ruby";
pkgs/top-level/all-packages.nix+5−3
@@ -13035,12 +13035,14 @@ in
1303513035
1303613036 r10k = callPackage ../tools/system/r10k { };
1303713037
13038− inherit (callPackages ../development/tools/analysis/radare2 ({
13038+ radare2 = callPackage ../development/tools/analysis/radare2 ({
1303913039 inherit (gnome2) vte;
1304013040 lua = lua5;
13041− } // (config.radare or {}))) radare2 r2-for-cutter;
13041+ } // (config.radare or {}));
1304213042
13043− radare2-cutter = libsForQt515.callPackage ../development/tools/analysis/radare2/cutter.nix { };
13043+ rizin = pkgs.callPackage ../development/tools/analysis/rizin { };
13044+
13045+ cutter = libsForQt515.callPackage ../development/tools/analysis/rizin/cutter.nix { };
1304413046
1304513047 ragel = ragelStable;
1304613048