commit:     1c28e908cbcf88be92d030870e17574408cb455d
Author:     John Helmert III <ajak <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 15 04:51:49 2024 +0000
Commit:     John Helmert III <ajak <AT> gentoo <DOT> org>
CommitDate: Sun Dec 15 04:52:24 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1c28e908

dev-util/rizin: depend on libpcre2[jit], force bundled tree-sitter-c

Rizin can automagically pick up a dependency on an incompatible
system-tree-sitter-c, so instead force usage of the forked
subproject. Note that I'm patching this as a one-off in this version
since the forked package has been renamed upstream and thus this
should be obsolete by the next release.

Also add a dependency on libpcre2[jit], since Rizin automagically
enables usage of it based on the target architecture, and we're not
keyworded for anywhere that doesn't have support except for x32, for
which usage is likely exceedingly rare (if existent).

Bug: https://bugs.gentoo.org/943666
Closes: https://bugs.gentoo.org/945113
Signed-off-by: John Helmert III <ajak <AT> gentoo.org>

 .../rizin-0.7.3-force-local-tree-sitter-c.patch    |  22 +++++
 .../rizin-0.7.3-tree-sitter-underlinking.patch     |  31 +++++++
 dev-util/rizin/rizin-0.7.3-r2.ebuild               | 101 +++++++++++++++++++++
 profiles/arch/amd64/x32/package.mask               |   4 +
 4 files changed, 158 insertions(+)

diff --git a/dev-util/rizin/files/rizin-0.7.3-force-local-tree-sitter-c.patch 
b/dev-util/rizin/files/rizin-0.7.3-force-local-tree-sitter-c.patch
new file mode 100644
index 000000000000..952ed430e72b
--- /dev/null
+++ b/dev-util/rizin/files/rizin-0.7.3-force-local-tree-sitter-c.patch
@@ -0,0 +1,22 @@
+From 1f8d7a37dc91ce41706ca7ee564cf3c48acf79d1 Mon Sep 17 00:00:00 2001
+From: John Helmert III <[email protected]>
+Date: Sat, 14 Dec 2024 20:11:09 -0800
+Subject: [PATCH] librz/type: force tree-sitter-c subproject
+
+rizin depends on its fork of tree-sitter-c.
+
+Signed-off-by: John Helmert III <[email protected]>
+--- a/librz/type/meson.build
++++ b/librz/type/meson.build
+@@ -18,7 +18,7 @@ if r.returncode() == 1 and get_option('subprojects_check')
+   error('Subprojects are not updated. Please run `git clean -dxff 
subprojects/` to delete all local subprojects directories. If you want to 
compile against current subprojects then set option `subprojects_check=false`.')
+ endif
+ 
+-tree_sitter_c_dep = dependency('tree-sitter-c')
++tree_sitter_c_dep = 
subproject('tree-sitter-c').get_variable('tree_sitter_c_dep')
+ 
+ rz_type_inc = [
+   platform_inc,
+-- 
+2.45.2
+

diff --git a/dev-util/rizin/files/rizin-0.7.3-tree-sitter-underlinking.patch 
b/dev-util/rizin/files/rizin-0.7.3-tree-sitter-underlinking.patch
new file mode 100644
index 000000000000..72a8b14a26bf
--- /dev/null
+++ b/dev-util/rizin/files/rizin-0.7.3-tree-sitter-underlinking.patch
@@ -0,0 +1,31 @@
+From 2d5a70879b8e0b7b2bbd9ce48b2bb459dc22203a Mon Sep 17 00:00:00 2001
+From: ajakk <[email protected]>
+Date: Tue, 3 Sep 2024 08:46:24 -0500
+Subject: [PATCH] librz: link to tree-sitter directly (#4603)
+
+tree-sitter symbols are included in this library, so we need to
+specify the dependency to avoid linking failures due to missing
+tree-sitter symbols.
+
+See-Also: https://bugs.gentoo.org/928301
+
+Signed-off-by: John Helmert III <[email protected]>
+---
+ librz/type/meson.build | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/librz/type/meson.build b/librz/type/meson.build
+index 06d6807bc3..7c58e82486 100644
+--- a/librz/type/meson.build
++++ b/librz/type/meson.build
+@@ -31,6 +31,7 @@ rz_type = library('rz_type', rz_type_sources,
+   include_directories: rz_type_inc,
+   dependencies: [
+     rz_util_dep,
++    tree_sitter_dep,
+     tree_sitter_c_dep,
+     lrt
+   ],
+-- 
+2.45.2
+

diff --git a/dev-util/rizin/rizin-0.7.3-r2.ebuild 
b/dev-util/rizin/rizin-0.7.3-r2.ebuild
new file mode 100644
index 000000000000..c86058324b43
--- /dev/null
+++ b/dev-util/rizin/rizin-0.7.3-r2.ebuild
@@ -0,0 +1,101 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..13} )
+
+# This is the commit that the CI for the release commit used
+BINS_COMMIT="1203a9a2f51e32337c8434d9f4f7c4543552e271"
+
+inherit meson python-any-r1
+
+DESCRIPTION="reverse engineering framework for binary analysis"
+HOMEPAGE="https://rizin.re/";
+
+SRC_URI="mirror+https://github.com/rizinorg/rizin/releases/download/v${PV}/rizin-src-v${PV}.tar.xz
+       test? ( 
https://github.com/rizinorg/rizin-testbins/archive/${BINS_COMMIT}.tar.gz -> 
rizin-testbins-${BINS_COMMIT}.tar.gz )"
+S="${WORKDIR}/${PN}-v${PV}"
+
+LICENSE="Apache-2.0 BSD LGPL-3 MIT"
+SLOT="0/${PV}"
+KEYWORDS="~amd64 ~arm64 ~x86"
+IUSE="test"
+
+# Need to audit licenses of the binaries used for testing
+RESTRICT="test? ( fetch ) !test? ( test )"
+
+# TODO: unbundle dev-libs/blake3
+RDEPEND="
+       app-arch/lz4:0=
+       app-arch/xz-utils
+       app-arch/zstd:=
+       >=dev-libs/capstone-5:0=
+       dev-libs/libmspack
+       dev-libs/libzip:0=
+       dev-libs/openssl:0=
+       dev-libs/libpcre2:0=[jit]
+       >=dev-libs/tree-sitter-0.19.0:=
+       dev-libs/xxhash
+       sys-apps/file
+       sys-libs/zlib:0=
+"
+DEPEND="${RDEPEND}"
+BDEPEND="${PYTHON_DEPS}"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-0.4.0-never-rebuild-parser.patch"
+       "${FILESDIR}/${PN}-0.7.3-force-local-tree-sitter-c.patch"
+       "${FILESDIR}/${PN}-0.7.3-tree-sitter-underlinking.patch"
+)
+
+src_prepare() {
+       default
+
+       local py_to_mangle=(
+               librz/core/cmd_descs/cmd_descs_generate.py
+               sys/clang-format.py
+               test/fuzz/scripts/fuzz_rz_asm.py
+               test/scripts/gdbserver.py
+       )
+
+       python_fix_shebang "${py_to_mangle[@]}"
+
+       # https://github.com/rizinorg/rizin/issues/3459
+       sed -ie '/dyld_chained_ptr_arm64e_auth/d' test/unit/test_bin_mach0.c || 
die
+
+       if use test; then
+               cp -r "${WORKDIR}/rizin-testbins-${BINS_COMMIT}" 
"${S}/test/bins" || die
+               cp -r "${WORKDIR}/rizin-testbins-${BINS_COMMIT}" "${S}" || die
+       fi
+}
+
+src_configure() {
+       local emesonargs=(
+               -Dcli=enabled
+               -Duse_sys_capstone=enabled
+               -Duse_sys_libmspack=enabled
+               -Duse_sys_libzip=enabled
+               -Duse_sys_libzstd=enabled
+               -Duse_sys_lz4=enabled
+               -Duse_sys_lzma=enabled
+               -Duse_sys_magic=enabled
+               -Duse_sys_openssl=enabled
+               -Duse_sys_pcre2=enabled
+               -Duse_sys_tree_sitter=enabled
+               -Duse_sys_xxhash=enabled
+               -Duse_sys_zlib=enabled
+
+               $(meson_use test enable_tests)
+               $(meson_use test enable_rz_test)
+       )
+       meson_src_configure
+}
+
+src_test() {
+       # We can select running either unit or integration tests, or all of
+       # them by not passing --suite. According to upstream, integration
+       # tests are more fragile and unit tests are sufficient for testing
+       # packaging, so only run those.
+       meson_src_test --suite unit
+}

diff --git a/profiles/arch/amd64/x32/package.mask 
b/profiles/arch/amd64/x32/package.mask
index debf27f701f1..07483bc989a5 100644
--- a/profiles/arch/amd64/x32/package.mask
+++ b/profiles/arch/amd64/x32/package.mask
@@ -1,6 +1,10 @@
 # Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
+# John Helmert III <[email protected]> (2024-12-14)
+# Requires libpcre2[jit] which is now masked on x32
+dev-util/rizin
+
 # Ben Kohler <[email protected]> (2024-05-27)
 # Requires libpcre2[jit] which is now masked on x32
 mail-filter/rspamd

Reply via email to