SHA256
1
0
forked from lua/lua-lgi

4 Commits
main ... main

Author SHA256 Message Date
09be02ba97 An attempt to make test suite working, but not yet. 2025-10-29 15:44:05 +01:00
1e5ed57670 Switch off building lua51 build of the package. 2025-10-24 17:43:44 +02:00
d474f4df7d Make the package buildable with LuaJIT. 2025-10-20 20:40:48 +02:00
Paulo Gomes
ad2409b5c2 Fix glib 2.86 regression
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
2025-10-08 12:44:33 +01:00
8 changed files with 250 additions and 7 deletions

View File

@@ -0,0 +1,50 @@
From 54d90bfd38c4562ddd619f1f2e14130fc68ec702 Mon Sep 17 00:00:00 2001
From: Victoria Lacroix <victoria@vtrlx.ca>
Date: Mon, 22 Sep 2025 10:02:10 -0400
Subject: [PATCH] Fix GLib 2.86 regression
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GLib 2.86 removed the GObject.TypeClass.ref() function, replacing it
with GObject.TypeClass.get()—this commit makes it so .get() is used in
GLib >= 2.86, while still preserving the old behaviour on GLib < 2.86.
---
lgi/ffi.lua | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
Index: lgi-0.9.2/lgi/ffi.lua
===================================================================
--- lgi-0.9.2.orig/lgi/ffi.lua 2025-10-29 12:16:22.502956913 +0100
+++ lgi-0.9.2/lgi/ffi.lua 2025-10-29 12:16:33.528971082 +0100
@@ -76,18 +76,27 @@
-- Creates new enum/flags table with all values from specified gtype.
function ffi.load_enum(gtype, name)
- local GObject = core.repo.GObject
+ local GLib, GObject = core.repo.GLib, core.repo.GObject
local is_flags = GObject.Type.is_a(gtype, GObject.Type.FLAGS)
local enum_component = component.create(
gtype, is_flags and enum.bitflags_mt or enum.enum_mt, name)
- local type_class = GObject.TypeClass.ref(gtype)
+ local type_class
+ -- GLib >= 2.86 deprecates GObject.TypeClass.ref() in favour of .get()
+ if GLib.check_version(2, 86, 0) then
+ type_class = GObject.TypeClass.ref(gtype)
+ else
+ type_class = GObject.TypeClass.get(gtype)
+ end
local enum_class = core.record.cast(
type_class, is_flags and GObject.FlagsClass or GObject.EnumClass)
for i = 0, enum_class.n_values - 1 do
local val = core.record.fromarray(enum_class.values, i)
enum_component[core.upcase(val.value_nick):gsub('%-', '_')] = val.value
end
- type_class:unref()
+ -- For GLib versions below 2.86, type_class was ref'd and needs to be unref'd
+ if GLib.check_version(2, 86, 0) then
+ type_class:unref()
+ end
return enum_component
end

View File

@@ -1,6 +1,5 @@
<multibuild>
<package>luajit</package>
<package>lua51</package>
<package>lua53</package>
<package>lua54</package>
</multibuild>

View File

@@ -1,3 +1,31 @@
-------------------------------------------------------------------
Wed Oct 29 12:14:44 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- An attempt to make test suite working, but not yet.
- Added patches:
- 001-Fix-GLib-2.86-regression.patch
- lua54.patch
- network_metered-property.patch
- pango-1_56_2.patch
- warnings-away.patch
-------------------------------------------------------------------
Fri Oct 24 14:48:22 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Switch off building lua51 build of the package.
-------------------------------------------------------------------
Mon Oct 20 18:40:45 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Make the package buildable with LuaJIT.
-------------------------------------------------------------------
Wed Oct 8 10:13:32 UTC 2025 - Paulo Gomes <pjbgf@linux.com>
- Add Lua54 headers to build lua-lgi:luajit.
- Fix GLib 2.86 regression (boo#1250526)
Refer to https://github.com/lgi-devs/lgi/issues/346
-------------------------------------------------------------------
Wed Jan 25 11:52:07 UTC 2023 - Michal Suchanek <msuchanek@suse.de>

View File

@@ -26,13 +26,27 @@ License: MIT
Group: Development/Languages/Other
URL: https://github.com/pavouk/lgi
Source0: https://github.com/pavouk/%{mod_name}/archive/%{version}.tar.gz#/%{mod_name}-%{version}.tar.gz
Patch: lua54.patch
Patch0: lua54.patch
# PATCH-FIX-UPSTREAM 001-Fix-GLib-2.86-regression.patch boo#1250526
Patch1: 001-Fix-GLib-2.86-regression.patch
# PATCH-FIX-UPSTREAM warnings-away.patch bsc#[0-9]+ mcepl@suse.com
# remove warnings from deprecated calls
Patch2: warnings-away.patch
# PATCH-FIX-UPSTREAM pango-1_56_2.patch gh#lgi-devs/lgi!342 mcepl@suse.com
# update to use pango 1.56.2
Patch3: pango-1_56_2.patch
# PATCH-FIX-UPSTREAM network_metered-property.patch gh#lgi-devs/lgi!215 mcepl@suse.com
# support for network_metered property
Patch4: network_metered-property.patch
BuildRequires: lua-macros
BuildRequires: %{flavor}-devel
BuildRequires: pkgconfig
BuildRequires: pkgconfig(gmodule-2.0)
BuildRequires: pkgconfig(gobject-introspection-1.0) >= 0.10.8
BuildRequires: pkgconfig(libffi)
BuildRequires: pkgconfig(pango)
BuildRequires: pkgconfig(gtk4)
BuildRequires: pkgconfig(cairo)
Requires: %{flavor}
%lua_provides
%if "%{flavor}" == ""
@@ -50,6 +64,7 @@ directly from Lua.
%package doc
Summary: Lua bindings to GObject libraries - documentation and samples
Group: Documentation/Other
BuildArch: noarch
%description doc
Dynamic Lua binding to any library which is introspectable
@@ -59,6 +74,8 @@ directly from Lua.
%prep
%autosetup -n %{mod_name}-%{version} -p1
find . -name \*.lua -exec sed -i -e 's,# *\! *%{_bindir}/.*lua,#!%{_bindir}/lua,' '{}' +;
%build
make %{?_smp_mflags} V=1 \
LUA_CFLAGS=" -I%{lua_incdir}" \
@@ -70,6 +87,9 @@ make %{?_smp_mflags} V=1 \
LUA_LIBDIR=%{lua_archdir} \
LUA_SHAREDIR=%{lua_noarchdir}
%check
make check || true
%files
%if 0%{?suse_version} >= 1500
%license LICENSE

View File

@@ -1,8 +1,12 @@
diff --git a/lgi/callable.c b/lgi/callable.c
index e96d3af..3234b64 100644
--- a/lgi/callable.c
+++ b/lgi/callable.c
@@ -1355,7 +1355,10 @@ closure_callback (ffi_cif *cif, void *ret, void **args, void *closure_arg)
---
lgi/callable.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: lgi-0.9.2/lgi/callable.c
===================================================================
--- lgi-0.9.2.orig/lgi/callable.c 2017-10-09 20:55:55.000000000 +0200
+++ lgi-0.9.2/lgi/callable.c 2025-10-29 12:16:31.099371249 +0100
@@ -1233,7 +1233,10 @@
}
else
{

View File

@@ -0,0 +1,36 @@
From 05c909b3b9eaf64ac5b37459d9cf101922dc854c Mon Sep 17 00:00:00 2001
From: Uli Schlachter <psychon@znc.in>
Date: Fri, 8 Feb 2019 13:03:16 +0100
Subject: [PATCH] Fix GObject warning in tests
The subclass test caused the following warning:
(lua5.2:14980): GLib-GObject-CRITICAL **: 13:02:03.551: Object class
LgiTestFakeMonitor1 doesn't implement property 'network-metered' from
interface 'GNetworkMonitor'
This new property was added in Gio 2.46. The fix here is to implement
that property. That should not cause problems with older versions of
Gio, because there the extra property would just be ignored.
Signed-off-by: Uli Schlachter <psychon@znc.in>
---
tests/gobject.lua | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tests/gobject.lua b/tests/gobject.lua
index 2eb2b142..82a21b89 100644
--- a/tests/gobject.lua
+++ b/tests/gobject.lua
@@ -282,6 +282,11 @@ function gobject.subclass_prop_inherit()
'LgiTestFakeMonitor1NetworkAvailable',
'Whether the network is available.',
false, { GObject.ParamFlags.READABLE })
+ FakeMonitor._property.network_metered =
+ GObject.ParamSpecBoolean('network-metered',
+ 'LgiTestFakeMonitor1NetworkMetered',
+ 'Whether the network is metered.',
+ false, { GObject.ParamFlags.READABLE })
FakeMonitor._property.connectivity =
GObject.ParamSpecEnum('connectivity',
'LgiTestFakeMonitor1Connectivity',

27
pango-1_56_2.patch Normal file
View File

@@ -0,0 +1,27 @@
From 86b60ff99ad267619e117a8a65cc569612cbdcaa Mon Sep 17 00:00:00 2001
From: Chris Hofstaedtler <zeha@debian.org>
Date: Wed, 16 Jul 2025 00:00:36 +0200
Subject: [PATCH] Adapt to new pango bindings
See:
https://gitlab.gnome.org/GNOME/pango/-/merge_requests/829
https://github.com/fwupd/fwupd/commit/d0d3eff666d2a6d9c09346ea050eed1c78271f0a
https://bugs.debian.org/1101238
---
tests/pango.lua | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Index: lgi-0.9.2/tests/pango.lua
===================================================================
--- lgi-0.9.2.orig/tests/pango.lua 2025-10-29 12:16:22.516482739 +0100
+++ lgi-0.9.2/tests/pango.lua 2025-10-29 12:16:39.467334765 +0100
@@ -35,8 +35,7 @@
local offset = items[i].offset
local length = items[i].length
local analysis = items[i].analysis
- local pgs = Pango.GlyphString()
- Pango.shape(string.sub(s,1+offset), length, analysis, pgs)
+ pgs = Pango.shape(string.sub(s,1+offset), length, analysis)
-- Pull out individual glyphs with pgs.glyphs
local glyphs = pgs.glyphs
check(type(glyphs) == 'table')

79
warnings-away.patch Normal file
View File

@@ -0,0 +1,79 @@
---
lgi/marshal.c | 2 +-
lgi/object.c | 46 +++++++++++++++++++++-------------------------
2 files changed, 22 insertions(+), 26 deletions(-)
Index: lgi-0.9.2/lgi/marshal.c
===================================================================
--- lgi-0.9.2.orig/lgi/marshal.c 2017-10-09 20:55:55.000000000 +0200
+++ lgi-0.9.2/lgi/marshal.c 2025-10-13 00:39:03.948391950 +0200
@@ -325,7 +325,7 @@
*out_array = (gpointer *) lua_tolstring (L, narg, &size);
if (transfer != GI_TRANSFER_NOTHING)
- *out_array = g_memdup (*out_array, size);
+ *out_array = g_memdup2 (*out_array, size);
*out_size = size;
}
Index: lgi-0.9.2/lgi/object.c
===================================================================
--- lgi-0.9.2.orig/lgi/object.c 2017-10-09 20:55:55.000000000 +0200
+++ lgi-0.9.2/lgi/object.c 2025-10-13 00:42:11.527589269 +0200
@@ -545,35 +545,31 @@
lua_toboolean (L, 3));
else
{
- /* Normally Lua code uses GObject.Object.new(), which maps
- directly to g_object_newv(), but for some reason GOI < 1.0 does
- not export this method in the typelib. */
-
- /* Get GType - 1st argument. */
- GParameter *params;
- size_t size, i;
- GIBaseInfo *gparam_info;
+ /* Create new object from properties passed in the table. */
GType gtype = lgi_type_get_gtype (L, 1);
luaL_checktype (L, 2, LUA_TTABLE);
+ int n_props = 0;
+ lua_pushnil(L);
+ while (lua_next(L, 2) != 0) {
+ n_props++;
+ lua_pop(L, 1);
+ }
- /* Find BaseInfo of GParameter. */
- gparam_info = g_irepository_find_by_name (NULL, "GObject", "Parameter");
- *lgi_guard_create (L, (GDestroyNotify) g_base_info_unref) = gparam_info;
-
- /* Prepare array of GParameter structures. */
- size = lua_objlen (L, 2);
- params = g_newa (GParameter, size);
- for (i = 0; i < size; ++i)
- {
- lua_pushnumber (L, i + 1);
- lua_gettable (L, 2);
- lgi_type_get_repotype (L, G_TYPE_INVALID, gparam_info);
- lgi_record_2c (L, -2, &params[i], TRUE, FALSE, FALSE, FALSE);
- lua_pop (L, 1);
- }
+ const char *names[n_props];
+ GValue values[n_props];
+ int i = 0;
+ lua_pushnil(L);
+ while (lua_next(L, 2) != 0) {
+ names[i] = lua_tostring(L, -2);
+ GParamSpec *pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(g_type_class_peek(gtype)), names[i]);
+ g_value_init(&values[i], G_PARAM_SPEC_VALUE_TYPE(pspec));
+ GITypeInfo* ti = g_irepository_find_by_gtype(NULL, G_PARAM_SPEC_VALUE_TYPE(pspec));
+ lgi_marshal_2c(L, ti, NULL, GI_TRANSFER_NOTHING, &values[i], -1, 0, NULL, NULL);
+ i++;
+ lua_pop(L, 1);
+ }
- /* Create the object and return it. */
- return lgi_object_2lua (L, g_object_newv (gtype, size, params),
+ return lgi_object_2lua (L, g_object_new_with_properties (gtype, n_props, names, values),
TRUE, FALSE);
}
}