2017-07-10 11:32:00 +00:00
|
|
|
# RPM macros for Lua
|
|
|
|
|
|
|
|
# The major.minor version of Lua
|
2025-10-11 18:43:45 +02:00
|
|
|
%lua_version %{lua:
|
|
|
|
local f = io.popen("lua -e 'print(_VERSION)'")
|
|
|
|
local output = f:read("*a")
|
|
|
|
f:close()
|
|
|
|
local ver = output:match("Lua (%d%.%d)")
|
|
|
|
print(ver)
|
|
|
|
}
|
|
|
|
%lua_version_nodots %{lua:
|
|
|
|
local ver = rpm.expand("%{lua_version}")
|
|
|
|
local nodots = ver:gsub("%.", "")
|
|
|
|
print(nodots)
|
|
|
|
}
|
2017-07-10 11:32:00 +00:00
|
|
|
# compiled modules should go here
|
2025-10-14 14:32:29 +02:00
|
|
|
%lua_archdir %{lua:
|
|
|
|
local handle = io.popen("pkgconf --variable=INSTALL_CMOD lua 2>/dev/null")
|
|
|
|
local result = handle:read("*a")
|
|
|
|
handle:close()
|
|
|
|
result = result:gsub("^%s*(.-)%s*$", "%1")
|
|
|
|
print(result)
|
|
|
|
}
|
2017-07-10 11:32:00 +00:00
|
|
|
# pure Lua modules should go here
|
2025-10-14 14:32:29 +02:00
|
|
|
%lua_noarchdir %{lua:
|
2025-10-11 18:43:45 +02:00
|
|
|
local output = ""
|
2025-10-14 14:32:29 +02:00
|
|
|
local f = io.popen("pkgconf --variable=INSTALL_LMOD lua 2>/dev/null")
|
2025-10-11 18:43:45 +02:00
|
|
|
if f ~= nil then
|
|
|
|
output = f:read("*a"):gsub("^%s*(.-)%s*$", "%1")
|
|
|
|
f:close()
|
|
|
|
end
|
|
|
|
if output:len() > 0 then
|
|
|
|
print(output)
|
|
|
|
return
|
2025-10-10 12:56:20 +02:00
|
|
|
end
|
2025-10-11 18:43:45 +02:00
|
|
|
print(rpm.expand("%{_datadir}/lua/%{lua_version}"))
|
|
|
|
}
|
2017-07-11 08:24:39 +00:00
|
|
|
# lua includes folder
|
2025-10-14 14:32:29 +02:00
|
|
|
%lua_incdir %{lua:
|
|
|
|
local handle = io.popen("pkgconf --variable=includedir lua 2>/dev/null")
|
|
|
|
local result = handle:read("*a")
|
|
|
|
handle:close()
|
|
|
|
result = result:gsub("^%s*(.-)%s*$", "%1")
|
|
|
|
print(result)
|
|
|
|
}
|
|
|
|
%lua_version_default %{lua:
|
2022-11-30 13:46:45 +00:00
|
|
|
local result = 5.4
|
|
|
|
local ver = rpm.expand("%{?suse_version}")
|
|
|
|
if #ver > 0 then
|
|
|
|
ver = tonumber(ver)
|
|
|
|
if ver < 1500 then
|
|
|
|
result = 5.1
|
2025-10-13 22:24:05 +02:00
|
|
|
elseif ver < 1600 then
|
2022-11-30 13:46:45 +00:00
|
|
|
result = 5.3
|
|
|
|
end
|
|
|
|
end
|
|
|
|
print(result)
|
|
|
|
}
|
2025-10-13 22:24:05 +02:00
|
|
|
# Define a conditional that evaluates true when building for the default Lua version
|
2025-10-14 14:32:29 +02:00
|
|
|
%lua_version_default_nodots %{lua:
|
|
|
|
local ver = rpm.expand("%{lua_version_default}")
|
|
|
|
local nodots = ver:gsub("%.", "")
|
|
|
|
print(nodots)
|
|
|
|
}
|
2021-01-28 14:21:31 +00:00
|
|
|
# Lua default version
|
2025-10-11 18:43:45 +02:00
|
|
|
# This REQUIRES macro %{mod_name} to be defined.
|
2021-02-26 14:30:52 +00:00
|
|
|
# -e: Exclude lua prefix
|
2021-06-11 10:24:56 +00:00
|
|
|
# -n: Specify name
|
2025-10-13 22:24:05 +02:00
|
|
|
%lua_provides(en:) %{lua:
|
|
|
|
local mod_name = rpm.expand("%{?mod_name}")
|
|
|
|
if 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
|
|
|
|
]])
|
|
|
|
}
|
2022-09-02 15:13:59 +00:00
|
|
|
# LuaRocks
|
|
|
|
%luarocks_build \
|
|
|
|
luarocks --lua-version "%{lua_version}" \\\
|
2025-10-13 22:24:05 +02:00
|
|
|
make --deps-mode none
|
2022-09-02 15:13:59 +00:00
|
|
|
%luarocks_install \
|
|
|
|
luarocks --lua-version="%{lua_version}" --tree="%{buildroot}%{_prefix}" \\\
|
|
|
|
install --deps-mode=none --no-manifest
|
|
|
|
%luarocks_treedir %{_prefix}/lib/luarocks/rocks-%{lua_version}
|