forked from pool/lua-macros
Compare commits
1 Commits
| Author | SHA256 | Date | |
|---|---|---|---|
|
adf544bb37
|
@@ -1,15 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,9 +1,3 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Oct 20 21:30:36 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
|
||||
|
||||
- Rewrite %luarocks_install to use a shell script
|
||||
install-lua-rock.sh, which is packaged as well.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 14 23:16:09 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ License: MIT
|
||||
Group: Development/Languages/Other
|
||||
URL: https://www.lua.org
|
||||
Source0: macros.lua
|
||||
Source1: install-lua-rock.sh
|
||||
%if 0%{?suse_version} > 1600
|
||||
Requires: lua-interpreter
|
||||
%elif 0%{?suse_version} >= 1500
|
||||
@@ -47,11 +46,9 @@ cp -p %{SOURCE0} .
|
||||
:
|
||||
|
||||
%install
|
||||
install -Dm644 %{SOURCE0} %{buildroot}%{_rpmmacrodir}/macros.lua
|
||||
install -Dm755 %{SOURCE1} %{buildroot}%{_rpmconfigdir}/install-lua-rock.sh
|
||||
install -Dm644 macros.lua %{buildroot}%{_rpmmacrodir}/macros.lua
|
||||
|
||||
%files
|
||||
%{_rpmmacrodir}/macros.lua
|
||||
%{_rpmconfigdir}/install-lua-rock.sh
|
||||
|
||||
%changelog
|
||||
|
||||
64
macros.lua
64
macros.lua
@@ -6,12 +6,12 @@ local f = io.popen("lua -e 'print(_VERSION)'")
|
||||
local output = f:read("*a")
|
||||
f:close()
|
||||
local ver = output:match("Lua (%d%.%d)")
|
||||
print(ver)
|
||||
print(ver:gsub("^%s*(.-)%s*$", "%1"))
|
||||
}
|
||||
%lua_version_nodots %{lua:
|
||||
local ver = rpm.expand("%{lua_version}")
|
||||
local nodots = ver:gsub("%.", "")
|
||||
print(nodots)
|
||||
print(nodots:gsub("^%s*(.-)%s*$", "%1"))
|
||||
}
|
||||
# compiled modules should go here
|
||||
%lua_archdir %{lua:
|
||||
@@ -64,30 +64,47 @@ print(result)
|
||||
}
|
||||
# Lua default version
|
||||
# This REQUIRES macro %{mod_name} to be defined.
|
||||
# -e: Exclude lua prefix
|
||||
# -n: Specify name
|
||||
%lua_provides(en:) %{lua:
|
||||
# Optionally you can define macro `lua_provides_type`, which can
|
||||
# have two different values:
|
||||
# 'exclude-prefix' which excludes lua prefix, or
|
||||
# anything else which is used as the provided symbol
|
||||
%lua_provides %{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
|
||||
]])
|
||||
|
||||
local current_ver = rpm.expand("%{lua_version_nodots}"):gsub("^%s*(.-)%s*$", "%1")
|
||||
local default_ver = rpm.expand("%{lua_version_default_nodots}"):gsub("^%s*(.-)%s*$", "%1")
|
||||
|
||||
local output = ""
|
||||
|
||||
-- Check if we are building for the default Lua version
|
||||
if current_ver == default_ver then
|
||||
|
||||
local package_type = rpm.expand("%{?lua_provides_type}"):gsub("^%s*(.-)%s*$", "%1")
|
||||
local package_name = mod_name
|
||||
|
||||
-- Check for type defined externally (e.g., via --define 'lua_provides_type package-name')
|
||||
if package_type == "exclude-prefix" then
|
||||
-- Use name without "lua-" prefix
|
||||
package_name = mod_name
|
||||
elseif package_type ~= "" then
|
||||
-- Use custom name defined by package_type
|
||||
package_name = package_type
|
||||
else
|
||||
-- Default: Use 'lua-' prefix
|
||||
package_name = "lua-" .. mod_name
|
||||
end
|
||||
|
||||
local version = rpm.expand("%{version}")
|
||||
local release = rpm.expand("%{release}")
|
||||
|
||||
output = "Provides: " .. package_name .. " = " .. version .. "-" .. release .. " Obsoletes: " .. package_name .. " < " .. version .. "-" .. release
|
||||
end
|
||||
|
||||
print(output)
|
||||
}
|
||||
|
||||
# LuaRocks
|
||||
@@ -97,4 +114,7 @@ luarocks --lua-version "%{lua_version}" make --deps-mode none --pack-binary-rock
|
||||
%luarocks_treedir %{_prefix}/lib/luarocks/rocks-%{lua_version}
|
||||
|
||||
%luarocks_install \
|
||||
%{_rpmconfigdir}/install-lua-rock.sh "%{lua_version}" "%{buildroot}%{_prefix}" "%{buildroot}%{luarocks_treedir}/%{mod_name}"
|
||||
/bin/sh -c 'luarocks --lua-version="%{lua_version}" --tree="%{buildroot}%{_prefix}" install --deps-mode=none --no-manifest "$@" && \
|
||||
source_dir="%{buildroot}%{luarocks_treedir}/%{mod_name}/%{rock_version}" && \
|
||||
[ -d "${source_dir}" ] && [ "$(ls -A "${source_dir}" | wc -l)" -gt 0 ] && \
|
||||
mv -v "${source_dir}" __rocktree' --
|
||||
|
||||
Reference in New Issue
Block a user