summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-12-10 18:47:38 -0500
committerbd <bdunahu@operationnull.com>2025-12-10 19:13:22 -0500
commit0eac8ea45acf87e7dd4d10a4bdd22d96c1c3da35 (patch)
tree46f848fa5a97c3673850805abd947be37eace488
parent10a11335bfc775ca233a10156a75e8b74dd69335 (diff)
gnu: Add radare2.
* modules/tanelorn/packages/engineering.scm (radare2): New variable. * modules/tanelorn/packages/patches/radare2-fix-meson-build-to-use-sys-qjs.patch: New file. * modules/tanelorn/packages/patches/radare2-fix-meson-build-to-use-sys-sdb.patch: New file. * README: Add radare2.
-rw-r--r--README1
-rw-r--r--modules/tanelorn/packages/engineering.scm91
-rw-r--r--modules/tanelorn/packages/patches/radare2-fix-meson-build-to-use-sys-qjs.patch70
-rw-r--r--modules/tanelorn/packages/patches/radare2-fix-meson-build-to-use-sys-sdb.patch148
4 files changed, 309 insertions, 1 deletions
diff --git a/README b/README
index 4845e12..e0f1aee 100644
--- a/README
+++ b/README
@@ -9,5 +9,6 @@ The packages and services found here are optionally free for anyone to use, for
- *Engineering*
- sdb
+ - radare2
** Services
diff --git a/modules/tanelorn/packages/engineering.scm b/modules/tanelorn/packages/engineering.scm
index cab0c0d..32ff9ca 100644
--- a/modules/tanelorn/packages/engineering.scm
+++ b/modules/tanelorn/packages/engineering.scm
@@ -5,7 +5,17 @@
#:use-module (guix build-system meson)
#:use-module (guix git-download)
#:use-module (guix gexp)
- #:use-module (guix packages))
+ #:use-module (guix packages)
+ #:use-module (tanelorn packages)
+ #:use-module (gnu packages compression)
+ #:use-module (gnu packages digest)
+ #:use-module (gnu packages engineering)
+ #:use-module (gnu packages javascript)
+ #:use-module (gnu packages libevent)
+ #:use-module (gnu packages multiprecision)
+ #:use-module (gnu packages pkg-config)
+ #:use-module (gnu packages python)
+ #:use-module (gnu packages tls))
(define-public sdb
(package
@@ -40,3 +50,82 @@
(description "SDB is a simple key/value database based on djb's cdb disk
storage that supports JSON and array introspection.")
(license license:expat)))
+
+(define-public radare2-6.0.7
+ (package
+ (name "radare2")
+ (version "6.0.7")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/radareorg/radare2")
+ (commit version)))
+ (sha256
+ (base32
+ "1nkqa8mkmvmbc3812gf5ayfmzyf0krjgc1695rpkphw3fsl76rgx"))
+ (file-name (git-file-name name version))
+ (patches
+ (tanelorn-patches "radare2-fix-meson-build-to-use-sys-sdb.patch"
+ "radare2-fix-meson-build-to-use-sys-qjs.patch"))))
+ (build-system meson-build-system)
+ (arguments
+ (list
+ #:configure-flags
+ #~(list "-Duse_sys_capstone=true"
+ "-Duse_sys_magic=true"
+ "-Duse_sys_zip=true"
+ "-Duse_sys_zlib=true"
+ "-Duse_sys_lz4=true"
+ "-Duse_sys_xxhash=true"
+ "-Duse_sys_openssl=true")
+ #:phases
+ #~(modify-phases %standard-phases
+ ;; CHECK LATER: This patches an incorrect relative include.
+ (add-before 'build 'fix-relative-include
+ (lambda* _
+ (substitute* "../source/libr/arch/p/java/plugin.c"
+ (("include \".." all)
+ (string-append all "/..")))))
+ ;; These tests require sample binaries from an external repository.
+ (add-before 'check 'skip-tests
+ (lambda* _
+ (substitute* '("../source/test/unit/test_bin.c"
+ "../source/test/unit/test_dwarf.c"
+ "../source/test/unit/test_dwarf_info.c"
+ "../source/test/unit/test_dwarf_integration.c"
+ "../source/test/unit/test_pdb.c"
+ "../source/test/unit/test_r2pipe.c")
+ (("(^| )main *\\(.*" all)
+ (string-append all " exit (77);\n"))))))))
+ (inputs
+ (list capstone
+ gmp
+ libuv
+ libzip
+ lz4
+ openssl
+ python
+ quickjs-ng
+ sdb
+ zip
+ zlib))
+ (native-inputs
+ (list pkg-config))
+ (propagated-inputs
+ (list xxhash))
+ (home-page "https://radare.org/")
+ (synopsis "Reverse engineering framework")
+ (description
+ "Radare2 is a complete framework for reverse-engineering, debugging, and
+analyzing binaries. It is composed of a set of small utilities that can be
+used together or independently from the command line.
+
+Radare2 is built around a scriptable disassembler and hexadecimal editor that
+support a variety of executable formats for different processors and operating
+systems, through multiple back ends for local and remote files and disk
+images.
+
+It can also compare (@dfn{diff}) binaries with graphs and extract information
+like relocation symbols. It is able to deal with malformed binaries, making
+it suitable for security research and analysis.")
+ (license license:lgpl3)))
diff --git a/modules/tanelorn/packages/patches/radare2-fix-meson-build-to-use-sys-qjs.patch b/modules/tanelorn/packages/patches/radare2-fix-meson-build-to-use-sys-qjs.patch
new file mode 100644
index 0000000..4e862b0
--- /dev/null
+++ b/modules/tanelorn/packages/patches/radare2-fix-meson-build-to-use-sys-qjs.patch
@@ -0,0 +1,70 @@
+Use guix-provided qjs instead of a meson subproject.
+
+Patch by bdunahu <bdunahu@operationnull.com>.
+
+diff --git a/libr/lang/meson.build b/libr/lang/meson.build
+index 0742e0e531..a6367cea39 100644
+--- a/libr/lang/meson.build
++++ b/libr/lang/meson.build
+@@ -4,13 +4,11 @@ r_lang_sources = [
+
+ spp_inc = [platform_inc, include_directories('../../shlr/spp')]
+
+-qjs = subproject('qjs')
+-qjs_inc = qjs.get_variable('incs')
+-qjs_static = qjs.get_variable('qjs_static')
+
++qjs_dep = cc.find_library('qjs', required: true)
+
+ r_lang = library('r_lang', r_lang_sources,
+- include_directories: [platform_inc, spp_inc, qjs_inc],
++ include_directories: [platform_inc, spp_inc],
+ c_args: library_cflags,
+ dependencies: [
+ r_util_dep,
+@@ -21,19 +19,23 @@ r_lang = library('r_lang', r_lang_sources,
+ r_esil_dep,
+ r_muta_dep,
+ r_cons_dep,
++ qjs_dep,
+ ],
+- link_with: qjs_static,
+ install: true,
+ implicit_include_directories: false,
+ install_rpath: rpath_lib,
+ soversion: r2_libversion
+ )
+
+-r_lang_dep = declare_dependency(link_with: r_lang, include_directories: [platform_inc, qjs_inc])
++r_lang_dep = declare_dependency(
++ link_with: r_lang,
++ include_directories: [platform_inc],
++ dependencies: [qjs_dep],
++)
+
+ if get_option('blob')
+ r_lang_static = static_library('r_lang_static', r_lang_sources,
+- include_directories: [platform_inc, spp_inc, qjs_inc],
++ # include_directories: [platform_inc, spp_inc qjs_inc], # unused
+ c_args: library_cflags,
+ dependencies: [
+ r_util_static_dep,
+@@ -43,13 +45,15 @@ r_lang_static = static_library('r_lang_static', r_lang_sources,
+ r_muta_static_dep,
+ r_cons_static_dep,
+ ],
+- link_with: qjs_static,
++ # link_with: qjs_static, # unused
+ install: true,
+ implicit_include_directories: false,
+ )
+
+-r_lang_static_dep = declare_dependency(link_with: r_lang_static,
+- include_directories: [platform_inc, qjs_inc])
++r_lang_static_dep = declare_dependency(
++ link_with: r_lang_static,
++ # include_directories: [platform_inc, qjs_inc] # unused
++ )
+ endif
+
+ pkgconfig_mod.generate(r_lang,
diff --git a/modules/tanelorn/packages/patches/radare2-fix-meson-build-to-use-sys-sdb.patch b/modules/tanelorn/packages/patches/radare2-fix-meson-build-to-use-sys-sdb.patch
new file mode 100644
index 0000000..b5ba462
--- /dev/null
+++ b/modules/tanelorn/packages/patches/radare2-fix-meson-build-to-use-sys-sdb.patch
@@ -0,0 +1,148 @@
+Use guix-provided sdb instead of a meson subproject.
+
+Patch by bdunahu <bdunahu@operationnull.com>.
+
+diff --git a/libr/anal/d/meson.build b/libr/anal/d/meson.build
+index bc4b7ccf22..cd1af6e84b 100644
+--- a/libr/anal/d/meson.build
++++ b/libr/anal/d/meson.build
+@@ -117,7 +117,7 @@ if host_machine.system() != 'uefi'
+ output: fcnsign_sdb_files,
+ command: [sdb_exe, '-r', meson.current_source_dir()],
+ env: sdb_env,
+- depends: host_machine.system() == 'uefi' ? [windows_type_file] : [sdb_exe, windows_type_file],
++ depends: [windows_type_file],
+ build_by_default: true,
+ install: true,
+ install_dir: join_paths(r2_sdb, 'fcnsign')
+diff --git a/libr/asm/d/meson.build b/libr/asm/d/meson.build
+index 44b5356372..ffd8dab323 100644
+--- a/libr/asm/d/meson.build
++++ b/libr/asm/d/meson.build
+@@ -62,7 +62,6 @@ if host_machine.system() != 'uefi'
+ output: opcodes_sdb_files,
+ command: [sdb_exe, '-r', meson.current_source_dir()],
+ env: sdb_env,
+- depends: sdb_exe,
+ build_by_default: true,
+ install: true,
+ install_dir: join_paths(r2_sdb, 'opcodes')
+diff --git a/libr/bin/d/dll/meson.build b/libr/bin/d/dll/meson.build
+index 136aa381ac..d6a3ba88f7 100644
+--- a/libr/bin/d/dll/meson.build
++++ b/libr/bin/d/dll/meson.build
+@@ -170,7 +170,6 @@ if host_machine.system() != 'uefi'
+ output: dll_sdb_files,
+ command: [sdb_exe, '-r', meson.current_source_dir()],
+ env: sdb_env,
+- depends: sdb_exe,
+ build_by_default: true,
+ install: true,
+ install_dir: join_paths(r2_sdb, join_paths('format', 'dll'))
+diff --git a/libr/bin/d/meson.build b/libr/bin/d/meson.build
+index 0f5e160f02..347654406d 100644
+--- a/libr/bin/d/meson.build
++++ b/libr/bin/d/meson.build
+@@ -27,7 +27,6 @@ if host_machine.system() != 'uefi'
+ output: format_sdb_files,
+ command: [sdb_exe, '-r', meson.current_source_dir()],
+ env: format_sdb_env,
+- depends: sdb_exe,
+ build_by_default: true,
+ install: true,
+ install_dir: join_paths(r2_sdb, join_paths('format'))
+diff --git a/libr/fs/d/meson.build b/libr/fs/d/meson.build
+index 808c03666d..d507f58efb 100644
+--- a/libr/fs/d/meson.build
++++ b/libr/fs/d/meson.build
+@@ -21,7 +21,6 @@ if host_machine.system() != 'uefi'
+ output: fs_sdb_files,
+ command: [sdb_exe, '-r', meson.current_source_dir()],
+ env: sdb_env,
+- depends: sdb_exe,
+ build_by_default: true,
+ install: true,
+ install_dir: join_paths(r2_sdb, 'fs')
+diff --git a/libr/syscall/d/meson.build b/libr/syscall/d/meson.build
+index 13d7a78db5..5371e0fe2a 100644
+--- a/libr/syscall/d/meson.build
++++ b/libr/syscall/d/meson.build
+@@ -41,7 +41,6 @@ if host_machine.system() != 'uefi'
+ output: syscall_sdb_files,
+ command: [sdb_exe, '-r', '-r', meson.current_source_dir()],
+ env: sdb_env,
+- depends: sdb_exe,
+ build_by_default: true,
+ install: true,
+ install_dir: join_paths(r2_sdb, 'syscall')
+@@ -49,4 +48,3 @@ if host_machine.system() != 'uefi'
+ else
+ r_syscall_d_sources = []
+ endif
+-
+diff --git a/libr/util/d/meson.build b/libr/util/d/meson.build
+index 9f34b18642..14a08412be 100644
+--- a/libr/util/d/meson.build
++++ b/libr/util/d/meson.build
+@@ -40,7 +40,6 @@ if host_machine.system() != 'uefi'
+ output: charsets_sdb_files,
+ command: [sdb_exe, '-r', meson.current_source_dir()],
+ env: sdb_env,
+- depends: sdb_exe,
+ build_by_default: true,
+ install: true,
+ install_dir: join_paths(r2_sdb, 'charsets')
+diff --git a/meson.build b/meson.build
+index 52583b29cf..f26be0e41a 100644
+--- a/meson.build
++++ b/meson.build
+@@ -510,22 +510,11 @@ script_files = [
+ ]
+ install_data(script_files, install_dir: r2_scripts)
+
+-libsdb_sp = subproject('sdb')
+-libsdb_static = libsdb_sp.get_variable('libsdb_static')
+-if host_machine.system() == 'uefi'
+- libsdb_dynamic = libsdb_static
+-else
+- libsdb_dynamic = libsdb_sp.get_variable('libsdb').get_shared_lib()
+-endif
+-libsdb_includes = libsdb_sp.get_variable('sdb_inc')
+-libsdb_version = libsdb_sp.get_variable('sdb_version')
+-
+-sdb_dep = declare_dependency(
+- link_whole: libsdb_static,
+- include_directories: libsdb_includes
+-)
++libsdb_includes = []
++libsdb_version = 'never used'
+
+-sdb_exe = libsdb_sp.get_variable('sdb_exe')
++sdb_dep = dependency('sdb', required: true)
++sdb_exe = find_program('sdb', required: true).full_path()
+
+ if host_machine.system() == 'windows'
+ copyinout = [
+@@ -554,12 +543,7 @@ elif os_name == 'windows'
+ lib_extension = '.dll'
+ endif
+
+-libsdb_install = custom_target('libr2sdb',
+- input : libsdb_dynamic,
+- output : 'libsdb' + lib_extension,
+- command : copyinout,
+- install : true,
+- install_dir : get_option('libdir'))
++# We used to install libsdb here, but Guix already provides this.
+
+ sdb_gen_cmd_cgen = [ sdb_exe, '-t', '-C', '-o', '@OUTPUT@', '@INPUT@' ]
+ sdb_gen_cmd = [ sdb_exe, '@OUTPUT@', '==', '@INPUT@' ]
+@@ -575,7 +559,7 @@ spp_files = [
+ spp_inc = [platform_inc, include_directories(join_paths('shlr','spp'))]
+
+ libr2spp = static_library('r2spp', spp_files,
+- link_with: [ libsdb_static ], # libsdb_static,
++ dependencies: [ sdb_dep ],
+ include_directories: [ libsdb_includes, spp_inc ],
+ c_args: ['-DHAVE_R_UTIL', '-DUSE_R2=1'],
+ implicit_include_directories: false