about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/analysis/radare2
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-04-28 14:39:00 +0000
committerAlyssa Ross <hi@alyssa.is>2021-06-10 08:52:36 +0000
commit693e64ef7421374338ddb1dc12b9573feec75972 (patch)
tree2526ac075d248699c35d63e04499890ee4381f5f /nixpkgs/pkgs/development/tools/analysis/radare2
parent7014df2256694d97093d6f2bb1db340d346dea88 (diff)
parent8e4fe32876ca15e3d5eb3ecd3ca0b224417f5f17 (diff)
downloadnixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.gz
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.bz2
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.lz
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.xz
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.zst
nixlib-693e64ef7421374338ddb1dc12b9573feec75972.zip
Merge commit '8e4fe32876ca15e3d5eb3ecd3ca0b224417f5f17'
Diffstat (limited to 'nixpkgs/pkgs/development/tools/analysis/radare2')
-rw-r--r--nixpkgs/pkgs/development/tools/analysis/radare2/default.nix62
-rwxr-xr-xnixpkgs/pkgs/development/tools/analysis/radare2/update.py121
2 files changed, 21 insertions, 162 deletions
diff --git a/nixpkgs/pkgs/development/tools/analysis/radare2/default.nix b/nixpkgs/pkgs/development/tools/analysis/radare2/default.nix
index 1622c6168606..e59c48f91d30 100644
--- a/nixpkgs/pkgs/development/tools/analysis/radare2/default.nix
+++ b/nixpkgs/pkgs/development/tools/analysis/radare2/default.nix
@@ -19,67 +19,38 @@
 , python3
 , ruby
 , lua
+, capstone
 , useX11 ? false
 , rubyBindings ? false
 , pythonBindings ? false
 , luaBindings ? false
 }:
 
-let
-  inherit (lib) optional;
-
-  #<generated>
-  # DO NOT EDIT! Automatically generated by ./update.py
-  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 {
+stdenv.mkDerivation rec {
   pname = "radare2";
-  inherit version;
+  version = "5.2.1";
 
   src = fetchFromGitHub {
     owner = "radare";
     repo = "radare2";
-    inherit rev sha256;
+    rev = version;
+    sha256 = "0n3k190qjhdlj10fjqijx6ismz0g7fk28i83j0480cxdqgmmlbxc";
   };
 
-  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}"
+    "GITTAP=${version}"
     "RANLIB=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.bintools.targetPrefix}ranlib"
   ];
   configureFlags = [
     "--with-sysmagic"
     "--with-syszip"
     "--with-sysxxhash"
+    "--with-syscapstone"
     "--with-openssl"
   ];
 
@@ -87,11 +58,20 @@ stdenv.mkDerivation {
   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 ];
+  buildInputs = [
+    capstone
+    file
+    readline
+    libusb-compat-0_1
+    libewf
+    perl
+    zlib
+    openssl
+    libuv
+  ] ++ lib.optional useX11 [ gtkdialog vte gtk2 ]
+    ++ lib.optional rubyBindings [ ruby ]
+    ++ lib.optional pythonBindings [ python3 ]
+    ++ lib.optional luaBindings [ lua ];
 
   propagatedBuildInputs = [
     # radare2 exposes r_lib which depends on these libraries
diff --git a/nixpkgs/pkgs/development/tools/analysis/radare2/update.py b/nixpkgs/pkgs/development/tools/analysis/radare2/update.py
deleted file mode 100755
index ede0a6058a94..000000000000
--- a/nixpkgs/pkgs/development/tools/analysis/radare2/update.py
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env nix-shell
-#!nix-shell -p nix -p python3 -p git -i python
-# USAGE - just run the script: ./update.py
-# When editing this file, make also sure it passes the mypy typecheck
-# and is formatted with black.
-import fileinput
-import json
-import xml.etree.ElementTree as ET
-from urllib.parse import urlparse
-import re
-import subprocess
-import tempfile
-import urllib.request
-from datetime import datetime
-from pathlib import Path
-from typing import Dict
-
-SCRIPT_DIR = Path(__file__).parent.resolve()
-
-
-def sh(*args: str) -> str:
-    out = subprocess.check_output(list(args))
-    return out.strip().decode("utf-8")
-
-
-def prefetch_github(owner: str, repo: str, ref: str) -> str:
-    return sh(
-        "nix-prefetch-url",
-        "--unpack",
-        f"https://github.com/{owner}/{repo}/archive/{ref}.tar.gz",
-    )
-
-
-def get_radare2_rev() -> str:
-    feed_url = "http://github.com/radareorg/radare2/releases.atom"
-    with urllib.request.urlopen(feed_url) as resp:
-        tree = ET.fromstring(resp.read())
-    releases = tree.findall(".//{http://www.w3.org/2005/Atom}entry")
-    for release in releases:
-        link = release.find("{http://www.w3.org/2005/Atom}link")
-        assert link is not None
-        url = urlparse(link.attrib["href"])
-        tag = url.path.split("/")[-1]
-        if re.match(r"[0-9.]+", tag):
-            return tag
-        else:
-            print(f"ignore {tag}")
-    raise RuntimeError(f"No release found at {feed_url}")
-
-
-def git(dirname: str, *args: str) -> str:
-    return sh("git", "-C", dirname, *args)
-
-
-def get_repo_info(dirname: str, rev: str) -> Dict[str, str]:
-    sha256 = prefetch_github("radare", "radare2", rev)
-
-    cs_ver = None
-    with open(Path(dirname).joinpath("shlr", "Makefile")) as makefile:
-        for l in makefile:
-            match = re.match("CS_VER=(\S+)", l)
-            if match:
-                cs_ver = match.group(1)
-    assert cs_ver is not None
-
-    cs_sha256 = prefetch_github("aquynh", "capstone", cs_ver)
-
-    return dict(
-        rev=rev,
-        sha256=sha256,
-        version_commit=git(dirname, "rev-list", "--all", "--count"),
-        gittap=git(dirname, "describe", "--tags", "--match", "[0-9]*"),
-        gittip=git(dirname, "rev-parse", "HEAD"),
-        cs_ver=cs_ver,
-        cs_sha256=cs_sha256,
-    )
-
-
-def main() -> None:
-    version = get_radare2_rev()
-
-    with tempfile.TemporaryDirectory() as dirname:
-        git(
-            dirname,
-            "clone",
-            "--branch",
-            version,
-            "https://github.com/radare/radare2",
-            ".",
-        )
-        nix_file = str(SCRIPT_DIR.joinpath("default.nix"))
-
-        info = get_repo_info(dirname, version)
-
-        timestamp = git(dirname, "log", "-n1", "--format=%at")
-
-        in_block = False
-        with fileinput.FileInput(nix_file, inplace=True) as f:
-            for l in f:
-                if "#<generated>" in l:
-                    in_block = True
-                    print(
-                        f"""  #<generated>
-  # DO NOT EDIT! Automatically generated by ./update.py
-  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:
-                    in_block = False
-                elif not in_block:
-                    print(l, end="")
-
-
-if __name__ == "__main__":
-    main()