From 164d61681a09b22a58d5b3074e84642ce3eedfda Mon Sep 17 00:00:00 2001
From: Blake Batson <bbatson101@gmail.com>
Date: Tue, 26 Sep 2023 13:49:35 -0400
Subject: [PATCH] dev-libs/libpeas-2.0.0 version bump

Signed-off-by: Blake Batson <bbatson101@gmail.com>
---
 dev-libs/libpeas/files/2.0.0-lua.patch | 68 +++++++++++++++++++
 dev-libs/libpeas/libpeas-2.0.0.ebuild  | 94 ++++++++++++++++++++++++++
 2 files changed, 162 insertions(+)
 create mode 100644 dev-libs/libpeas/files/2.0.0-lua.patch
 create mode 100644 dev-libs/libpeas/libpeas-2.0.0.ebuild

diff --git a/dev-libs/libpeas/files/2.0.0-lua.patch b/dev-libs/libpeas/files/2.0.0-lua.patch
new file mode 100644
index 000000000..2a50a608e
--- /dev/null
+++ b/dev-libs/libpeas/files/2.0.0-lua.patch
@@ -0,0 +1,68 @@
+diff --git a/meson.build b/meson.build
+index 0744ba1..95c09c3 100644
+--- a/meson.build
++++ b/meson.build
+@@ -138,18 +138,12 @@ if host_machine.system() == 'windows' and not python3_dep.found()
+ endif
+ 
+ pygobject_dep = dependency('pygobject-3.0', version: pygobject_req, required: false)
+-lua51_dep = dependency('lua51', version: lua_req, required: false)
+-if not lua51_dep.found()
+-  lua51_dep = dependency('lua-5.1', version: lua_req, required: false)
+-endif
+-luajit_dep = dependency('luajit', version: luajit_req, required: false)
++lua51_dep = dependency('lua', version: lua_req, required: get_option('lua51'))
++luajit_dep = dependency('luajit', version: luajit_req, required: get_option('luajit'))
+ lua_lgi_found = false
+ lua_lgi_ver = 'not found'
+-lua51_prg = find_program('lua5.1', required: false)
+-if not lua51_prg.found()
+-  lua51_prg = find_program('lua51', required: false)
+-endif
+-luajit_prg = find_program('luajit', required: false)
++lua51_prg = find_program('lua', required: get_option('lua51'))
++luajit_prg = find_program('luajit', required: get_option('luajit'))
+ xmllint_prg = find_program('xmllint', required: false)
+ generate_vapi = get_option('vapi')
+ vapigen_prg = find_program('vapigen', required: generate_vapi)
+@@ -211,6 +205,8 @@ if lua_found
+             lua51_lgi_dep = declare_dependency(version: lua_lgi_ver)
+             lua_lgi_found = true
+         endif
++    else
++        error('lua support requested but lua-lgi not found')
+     endif
+     message('lua-lgi version: ' + lua_lgi_ver)
+ endif
+@@ -394,11 +390,7 @@ endif
+ 
+ build_gjs_loader = get_option('gjs')
+ 
+-build_lua51_loader = get_option('lua51')
+-lua51_found = (luajit_dep.found() or lua51_dep.found()) and lua_lgi_found
+-if build_lua51_loader and not lua51_found
+-  error('Lua51 requested but failed to locate suitable Lua51 and LGI support')
+-endif
++build_lua51_loader = (luajit_dep.found() or lua51_dep.found()) and lua_lgi_found
+ 
+ build_python3_loader = get_option('python3')
+ python3_found = python3_dep.found() and pygobject_dep.found()
+diff --git a/meson_options.txt b/meson_options.txt
+index 48a7e8d..891bf2a 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -3,9 +3,13 @@ option('gjs',
+        description: 'Enable GJS support (requires gjs-1.0)')
+ 
+ option('lua51',
+-       type: 'boolean', value: true,
++       type: 'feature', value: 'enabled',
+        description: 'Enable Lua 5.1 support (requires lua-lgi)')
+ 
++option('luajit',
++       type: 'feature', value: 'disabled',
++       description: 'Use LuaJIT for Lua 5.1 support (requires lua-lgi)')
++
+ option('python3',
+        type: 'boolean', value: true,
+        description: 'Enable Python 3 support (requires pygobject)')
diff --git a/dev-libs/libpeas/libpeas-2.0.0.ebuild b/dev-libs/libpeas/libpeas-2.0.0.ebuild
new file mode 100644
index 000000000..35062f536
--- /dev/null
+++ b/dev-libs/libpeas/libpeas-2.0.0.ebuild
@@ -0,0 +1,94 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+LUA_COMPAT=( lua5-1 luajit )
+PYTHON_COMPAT=( python3_{10..12} )
+
+inherit gnome.org lua-single meson python-single-r1 vala virtualx xdg
+
+DESCRIPTION="A GObject plugins library"
+HOMEPAGE="https://wiki.gnome.org/Projects/Libpeas https://gitlab.gnome.org/GNOME/libpeas"
+
+LICENSE="LGPL-2.1+"
+SLOT="2"
+KEYWORDS="~alpha amd64 ~arm arm64 ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc x86 ~amd64-linux ~x86-linux"
+
+IUSE="gtk-doc lua +python vala"
+REQUIRED_USE="lua? ( ${LUA_REQUIRED_USE} )
+	python? ( ${PYTHON_REQUIRED_USE} )"
+
+RDEPEND="
+	>=dev-libs/glib-2.44:2
+	>=dev-libs/gjs-1.77.1
+	>=dev-libs/gobject-introspection-1.39:=
+	lua? (
+		${LUA_DEPS}
+		$(lua_gen_cond_dep '
+			>=dev-lua/lgi-0.9.0[${LUA_USEDEP}]
+		')
+	)
+	python? (
+		${PYTHON_DEPS}
+		$(python_gen_cond_dep '
+			>=dev-python/pygobject-3.2:3[${PYTHON_USEDEP}]
+		')
+	)
+"
+DEPEND="${RDEPEND}"
+BDEPEND="
+	dev-util/glib-utils
+	gtk-doc? (
+		>=dev-util/gtk-doc-1.11
+		>=dev-util/gi-docgen-2021.7
+		app-text/docbook-xml-dtd:4.3
+	)
+	>=sys-devel/gettext-0.19.8
+	virtual/pkgconfig
+"
+
+PATCHES=(
+	# Gentoo-specific lua tweak hack
+	"${FILESDIR}"/2.0.0-lua.patch
+)
+
+pkg_setup() {
+	use lua && lua-single_pkg_setup
+	use python && python-single-r1_pkg_setup
+}
+
+src_prepare() {
+	default
+	use vala && vala_setup
+}
+
+src_configure() {
+	local emesonargs=(
+		$(meson_feature $(usex lua '!lua_single_target_luajit' 'lua') lua51)
+		$(meson_feature $(usex lua 'lua_single_target_luajit' 'lua') luajit)
+		$(meson_use python python3)
+		# introspection was always enabled in autotools; would need readiness by consumers
+		# to USE flag it, but most need it for python plugins anyways
+		-Dintrospection=true
+		$(meson_use vala vapi)
+		$(meson_use gtk-doc gtk_doc)
+	)
+	meson_src_configure
+}
+
+src_test() {
+	virtx meson_src_test
+}
+
+src_install() {
+	meson_src_install
+
+	if use gtk-doc; then
+		mkdir -p "${ED}"/usr/share/gtk-doc/html/ || die
+		mv "${ED}"/usr/share/doc/libpeas-1.0 "${ED}"/usr/share/gtk-doc/html/ || die
+		if use gtk; then
+			mv "${ED}"/usr/share/doc/libpeas-gtk-1.0 "${ED}"/usr/share/gtk-doc/html/ || die
+		fi
+	fi
+}
-- 
2.41.0