5 Commits

Author SHA256 Message Date
4381bcc53d Enable building with Lua 5.5.
- Remove fix_test.patch, which incorrectly workaround unset LUA_PATH
  variable.
- Add lua55-build.patch to fix compatibility problems with Lua 5.5.
2026-01-29 21:17:30 +01:00
9965f470eb Enable lua55 build 2026-01-21 21:42:19 +01:00
9e805e8aa8 Switch off building lua51 build of the package. 2025-10-24 16:47:39 +02:00
b37964147f Make the package buildable with LuaJIT. 2025-10-15 01:17:06 +02:00
128dca291a Add luajit version to _multibuild 2025-10-06 10:46:49 +02:00
7 changed files with 143 additions and 18 deletions

1
.gitattributes vendored
View File

@@ -21,3 +21,4 @@
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*.changes merge=merge-changes

9
.gitignore vendored
View File

@@ -1 +1,10 @@
.osc
*.obscpio
*.osc
_build.*
.pbuild
lua*-cosmo-*-build/
*.obscpio
*.osc
_build.*
.pbuild

View File

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

View File

@@ -1,8 +0,0 @@
diff -rub cosmo-16.06.04/tests/test_cosmo.lua cosmo-patched/tests/test_cosmo.lua
--- cosmo-16.06.04/tests/test_cosmo.lua 2016-06-04 12:59:21.000000000 -0600
+++ cosmo-patched/tests/test_cosmo.lua 2022-09-11 08:25:40.964576115 -0600
@@ -1,3 +1,4 @@
+package.path = "../src/?.lua;" .. package.path
local cosmo = require"cosmo"
local grammar = require"cosmo.grammar"

View File

@@ -1,3 +1,22 @@
-------------------------------------------------------------------
Thu Jan 29 19:18:41 UTC 2026 - Matej Cepl <mcepl@cepl.eu>
- Enable building with Lua 5.5.
- Remove fix_test.patch, which incorrectly workaround unset
LUA_PATH variable.
- Add lua55-build.patch to fix compatibility problems with Lua
5.5.
-------------------------------------------------------------------
Fri Oct 24 14:47:39 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Switch off building lua51 build of the package.
-------------------------------------------------------------------
Tue Oct 14 23:11:41 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Make the package buildable with LuaJIT.
-------------------------------------------------------------------
Mon Apr 1 01:48:59 UTC 2024 - Gordon Leung <pirateclip@protonmail.com>

View File

@@ -15,7 +15,6 @@
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define flavor @BUILD_FLAVOR@
%define mod_name cosmo
%define rock_version 16.06.04-1
@@ -23,10 +22,9 @@ Version: 16.06.04
Release: 0
Summary: A “safe templates” engine for Lua
License: MIT
Group: Development/Languages/Other
URL: https://github.com/mascarenhas/cosmo
Source: cosmo-%{version}.tar.zst
Patch0: fix_test.patch
Patch0: lua55-build.patch
BuildRequires: %{flavor}-devel
BuildRequires: %{flavor}-lpeg
BuildRequires: %{flavor}-luarocks
@@ -34,6 +32,7 @@ BuildRequires: lua-macros
BuildRequires: zstd
Requires: %{flavor}
Requires: %{flavor}-lpeg
BuildArch: noarch
%lua_provides
%if "%{flavor}" == ""
Name: lua-%{mod_name}
@@ -41,7 +40,6 @@ ExclusiveArch: do_not_build
%else
Name: %{flavor}-%{mod_name}
%endif
BuildArch: noarch
%description
Cosmo is a "safe templates" engine. It allows you to fill nested
@@ -54,19 +52,18 @@ engines, without the downside of allowing arbitrary code in the templates.
sed -i -e '/lpeg >=/d' "rockspec/%{mod_name}-%{rock_version}.rockspec"
%build
%luarocks_build "rockspec/%{mod_name}-%{rock_version}.rockspec"
%{luarocks_build} rockspec/%{mod_name}-%{rock_version}.rockspec
%install
%luarocks_install *.rock
%{luarocks_install} %{mod_name}-%{rock_version}.*.rock
%check
export LUA_PATH="%{buildroot}%{lua_noarchdir}/?.lua;%{buildroot}%{lua_noarchdir}/?/init.lua;;"
cd tests
lua test_cosmo.lua
%files
%license %{luarocks_treedir}/%{mod_name}/%{rock_version}/doc/cosmo.md
%docdir %{luarocks_treedir}/%{mod_name}/%{rock_version}/doc
%doc README __rocktree/*
%{lua_noarchdir}
%{luarocks_treedir}/%{mod_name}
%changelog

106
lua55-build.patch Normal file
View File

@@ -0,0 +1,106 @@
---
src/cosmo.lua | 13 ++++++++-----
src/cosmo/fill.lua | 22 +++++++++++++---------
2 files changed, 21 insertions(+), 14 deletions(-)
Index: cosmo-16.06.04/src/cosmo.lua
===================================================================
--- cosmo-16.06.04.orig/src/cosmo.lua 2016-06-04 20:59:21.000000000 +0200
+++ cosmo-16.06.04/src/cosmo.lua 2026-01-29 20:34:37.397380423 +0100
@@ -63,10 +63,11 @@
end
$if_args[===[
check_selector(selector_name, selector)
- for e, literal in wrap(selector), $args, true do
+ for e_val, literal in wrap(selector), $args, true do
if literal then
- insert(out, tostring(e))
+ insert(out, tostring(e_val))
else
+ local e = e_val
if type(e) ~= "table" then
e = prepare_env({ it = tostring(e) }, env)
else
@@ -78,7 +79,8 @@
]===],
[===[
if type(selector) == 'table' then
- for _, e in ipairs(selector) do
+ for _, e_val in ipairs(selector) do
+ local e = e_val
if type(e) ~= "table" then
e = prepare_env({ it = tostring(e) }, env)
else
@@ -88,10 +90,11 @@
end
else
check_selector(selector_name, selector)
- for e, literal in wrap(selector), nil, true do
+ for e_val, literal in wrap(selector), nil, true do
if literal then
- insert(out, tostring(e))
+ insert(out, tostring(e_val))
else
+ local e = e_val
if type(e) ~= "table" then
e = prepare_env({ it = tostring(e) }, env)
else
Index: cosmo-16.06.04/src/cosmo/fill.lua
===================================================================
--- cosmo-16.06.04.orig/src/cosmo/fill.lua 2016-06-04 20:59:21.000000000 +0200
+++ cosmo-16.06.04/src/cosmo/fill.lua 2026-01-29 20:19:31.069205449 +0100
@@ -79,6 +79,7 @@
end
else
if args and args ~= "" and args ~= "{}" then
+ local proc_e
check_selector(selector_name, selector)
args = loadstring("local env = (...); return " .. args)(env)
for e, literal in coroutine.wrap(selector), args, true do
@@ -86,22 +87,24 @@
insert(out, tostring(e))
else
if type(e) ~= "table" then
- e = prepare_env({ it = tostring(e) }, env)
+ proc_e = prepare_env({ it = tostring(e) }, env)
else
- e = prepare_env(e, env)
+ proc_e = prepare_env(e, env)
end
- interpreter.template({ env = e, out = out, opts = opts }, subtemplates[e.self._template or 1] or default)
+ interpreter.template({ env = proc_e, out = out, opts = opts },
+ subtemplates[proc_e.self._template or 1] or default)
end
end
else
if type(selector) == 'table' then
for _, e in ipairs(selector) do
if type(e) ~= "table" then
- e = prepare_env({ it = tostring(e) }, env)
+ proc_e = prepare_env({ it = tostring(e) }, env)
else
- e = prepare_env(e, env)
+ proc_e = prepare_env(e, env)
end
- interpreter.template({ env = e, out = out, opts = opts }, subtemplates[e.self._template or 1] or default)
+ interpreter.template({ env = proc_e, out = out, opts = opts },
+ subtemplates[proc_e.self._template or 1] or default)
end
else
check_selector(selector_name, selector)
@@ -110,11 +113,12 @@
insert(out, tostring(e))
else
if type(e) ~= "table" then
- e = prepare_env({ it = tostring(e) }, env)
+ proc_e = prepare_env({ it = tostring(e) }, env)
else
- e = prepare_env(e, env)
+ proc_e = prepare_env(e, env)
end
- interpreter.template({ env = e, out = out, opts = opts }, subtemplates[e.self._template or 1] or default)
+ interpreter.template({ env = proc_e, out = out, opts = opts },
+ subtemplates[proc_e.self._template or 1] or default)
end
end
end