14 Commits

Author SHA256 Message Date
521e3b1dc4 fix: convert %lua_provides to pure Lua for better control
Converts the logic within the %lua_provides macro from a
multi-line string of RPM macros to native Lua code. This allows
for more robust conditional logic, especially when checking for
default Lua versions and handling provides/obsoletes.
2025-11-03 01:21:47 +01:00
d1f0f1035b One level down to copy. 2025-10-21 00:38:19 +02:00
60b20c88fb Rewrite %luarocks_install to use a shell script
install-lua-rock.sh, which is packaged as well.
2025-10-21 00:05:32 +02:00
6e7d7d058f Fix %luarocks_* macros. 2025-10-15 03:04:59 +02:00
8ee4d34fad fix: we cannot use %global in a macro file 2025-10-14 14:50:29 +02:00
c1d442702b Fix %%lua_provides. 2025-10-14 12:38:25 +02:00
d4f21b0c0c Quote %%lua_archdir macro. 2025-10-13 19:20:45 +02:00
984b4bf4f2 feat: Rework Lua version and path macros using RPM Lua blocks
The `%lua_version`, `%lua_version_nodots`, and `%lua_noarchdir`
macros have been refactored to use the RPM internal Lua
interpreter blocks (`%{lua:...}`) instead of relying solely on
shell command execution (`%()`).

This change offers several benefits:
1. Consistency: Standardizes the approach, as other macros like
   `%lua_version_default` already use RPM Lua blocks.
2. Robustness: Improves path handling by explicitly trimming
   whitespace/newlines from the `pkgconf` output in
   `%lua_noarchdir`.
3. Clarity: Simplifies the logic for extracting the version
   number and calculating the no-dots version.

The `%lua_noarchdir` logic was also improved to correctly handle
a failure of the `pkgconf` command (e.g., when the package isn't
installed) by checking for `f == nil`.

A comment was also added to `%lua_provides` to clarify the
required definition of `%mod_name`.
2025-10-12 01:17:14 +02:00
21cfcf02e2 chore: I can use a good Makefile for some testing 2025-10-11 01:29:30 +02:00
22fe4289a4 Make %{lua_noarchdir} work even without lua-devel installed. 2025-10-10 12:56:20 +02:00
db9766d6bd Make definition of variables dynamic based on pkgconf output 2025-10-10 00:44:13 +02:00
df6ced835e Run obs-git-init . 2025-10-10 00:27:10 +02:00
efd19cb701 On Factory BR lua-interpreter. 2025-08-05 16:05:45 +02:00
91f3720965 Add functional .gitignore. 2025-08-04 15:20:48 +02:00
7 changed files with 61 additions and 30 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

8
.gitignore vendored
View File

@@ -1 +1,9 @@
.osc
_scmsync.obsinfo
_buildconfig-*
_buildinfo-*.xml
lua-macros-*-build/
*.obscpio
*.osc
_build.*
.pbuild

View File

@@ -1,5 +0,0 @@
mtime: 1760999899
commit: d1f0f1035bb04d30b4b3f2362fd2a8fa757179cdb184b24e5b6d27f1245ff673
url: https://src.opensuse.org/lua/lua-macros.git
revision: d1f0f1035bb04d30b4b3f2362fd2a8fa757179cdb184b24e5b6d27f1245ff673
projectscmsync: https://src.opensuse.org/lua/_ObsPrj.git

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9dabaf8e4bc02c3a8cc74d03d2b6f464921ef2f2f0e0b010379148c1485ac786
size 864

15
install-lua-rock.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
set -ex
# 1. %{lua_version}
# 2. %{buildroot}%{_prefix}
# 3. %{buildroot}%{luarocks_treedir}/%{mod_name}
SOURCE_DIR="$3"
luarocks --lua-version="$1" --tree="$2" install --deps-mode=none --no-manifest "${*:$#}"
if [ -d "${SOURCE_DIR}" ] && [ "$(find "${SOURCE_DIR}" -type f | wc -l)" -gt 0 ]
then
mkdir -p __rocktree
mv -v "${SOURCE_DIR}"/*/* __rocktree
fi

View File

@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Nov 3 00:20:49 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Finally broke %lua_provides to be working. I got stumped by the
craziness of rpm which runs Lua interpreter with locales and
crazy reformatting of integers.
-------------------------------------------------------------------
Mon Oct 20 21:30:36 UTC 2025 - Matej Cepl <mcepl@cepl.eu>

View File

@@ -44,14 +44,14 @@ print(rpm.expand("%{_datadir}/lua/%{lua_version}"))
print(result)
}
%lua_version_default %{lua:
local result = 5.4
local result = "5.4"
local ver = rpm.expand("%{?suse_version}")
if #ver > 0 then
ver = tonumber(ver)
if ver < 1500 then
result = 5.1
result = "5.1"
elseif ver < 1600 then
result = 5.3
result = "5.3"
end
end
print(result)
@@ -63,31 +63,39 @@ print(result)
print(nodots)
}
# Lua default version
# This REQUIRES macro %{mod_name} to be defined.
# This REQUIRES macro %%{mod_name} to be defined.
# -e: Exclude lua prefix
# -n: Specify name
%lua_provides(en:) %{lua:
local mod_name = rpm.expand("%{?mod_name}")
if mod_name == "" then
print("-- Error: %{mod_name} is not defined!")
if mod_name == "" or mod_name == "%{?mod_name}" then
print("-- Error: %%{mod_name} is not defined!")
return
end
print([[
%if "%{lua_version_nodots}" == "%{lua_version_default_nodots}"
%if 0%{?-n:1}
Provides: %{-n*} = %{version}-%{release}
Obsoletes: %{-n*} < %{version}-%{release}
%else
%if 0%{?-e:1}
Provides: %{mod_name} = %{version}-%{release}
Obsoletes: %{mod_name} < %{version}-%{release}
%else
Provides: lua-%{mod_name} = %{version}-%{release}
Obsoletes: lua-%{mod_name} < %{version}-%{release}
%endif
%endif
%endif
]])
local lua_ver_nodots = rpm.expand("%{lua_version_nodots}")
local lua_ver_default_nodots = rpm.expand("%{lua_version_default_nodots}")
local flavor = rpm.expand("%{flavor}")
local version = rpm.expand("%{version}")
local release = rpm.expand("%{release}")
local provides_name
if rpm.expand("%{-n*}") ~= "" then
provides_name = rpm.expand("%{-n*}")
elseif rpm.expand("%{-e:1}") == "1" then
provides_name = mod_name
else
provides_name = "lua-" .. mod_name
end
if lua_ver_nodots == lua_ver_default_nodots then
print("Provides: " .. provides_name .. " = " .. version .. "-" .. release .. "\\n")
print("Obsoletes: " .. provides_name .. " < " .. version .. "-" .. release .. "\\n")
end
if flavor == "luajit" then
print("Obsoletes: lua51-" .. mod_name .. " <= " .. version .. "-" .. release .. "\\n")
end
}
# LuaRocks