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>
|
Tue Oct 14 23:16:09 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ License: MIT
|
|||||||
Group: Development/Languages/Other
|
Group: Development/Languages/Other
|
||||||
URL: https://www.lua.org
|
URL: https://www.lua.org
|
||||||
Source0: macros.lua
|
Source0: macros.lua
|
||||||
Source1: install-lua-rock.sh
|
|
||||||
%if 0%{?suse_version} > 1600
|
%if 0%{?suse_version} > 1600
|
||||||
Requires: lua-interpreter
|
Requires: lua-interpreter
|
||||||
%elif 0%{?suse_version} >= 1500
|
%elif 0%{?suse_version} >= 1500
|
||||||
@@ -47,11 +46,9 @@ cp -p %{SOURCE0} .
|
|||||||
:
|
:
|
||||||
|
|
||||||
%install
|
%install
|
||||||
install -Dm644 %{SOURCE0} %{buildroot}%{_rpmmacrodir}/macros.lua
|
install -Dm644 macros.lua %{buildroot}%{_rpmmacrodir}/macros.lua
|
||||||
install -Dm755 %{SOURCE1} %{buildroot}%{_rpmconfigdir}/install-lua-rock.sh
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%{_rpmmacrodir}/macros.lua
|
%{_rpmmacrodir}/macros.lua
|
||||||
%{_rpmconfigdir}/install-lua-rock.sh
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
|||||||
64
macros.lua
64
macros.lua
@@ -6,12 +6,12 @@ local f = io.popen("lua -e 'print(_VERSION)'")
|
|||||||
local output = f:read("*a")
|
local output = f:read("*a")
|
||||||
f:close()
|
f:close()
|
||||||
local ver = output:match("Lua (%d%.%d)")
|
local ver = output:match("Lua (%d%.%d)")
|
||||||
print(ver)
|
print(ver:gsub("^%s*(.-)%s*$", "%1"))
|
||||||
}
|
}
|
||||||
%lua_version_nodots %{lua:
|
%lua_version_nodots %{lua:
|
||||||
local ver = rpm.expand("%{lua_version}")
|
local ver = rpm.expand("%{lua_version}")
|
||||||
local nodots = ver:gsub("%.", "")
|
local nodots = ver:gsub("%.", "")
|
||||||
print(nodots)
|
print(nodots:gsub("^%s*(.-)%s*$", "%1"))
|
||||||
}
|
}
|
||||||
# compiled modules should go here
|
# compiled modules should go here
|
||||||
%lua_archdir %{lua:
|
%lua_archdir %{lua:
|
||||||
@@ -64,30 +64,47 @@ print(result)
|
|||||||
}
|
}
|
||||||
# Lua default version
|
# Lua default version
|
||||||
# This REQUIRES macro %{mod_name} to be defined.
|
# This REQUIRES macro %{mod_name} to be defined.
|
||||||
# -e: Exclude lua prefix
|
# Optionally you can define macro `lua_provides_type`, which can
|
||||||
# -n: Specify name
|
# have two different values:
|
||||||
%lua_provides(en:) %{lua:
|
# '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}")
|
local mod_name = rpm.expand("%{?mod_name}")
|
||||||
if mod_name == "" then
|
if mod_name == "" then
|
||||||
print("-- Error: %{mod_name} is not defined!")
|
print("-- Error: %{mod_name} is not defined!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
print([[
|
|
||||||
%if "%{lua_version_nodots}" == "%{lua_version_default_nodots}"
|
local current_ver = rpm.expand("%{lua_version_nodots}"):gsub("^%s*(.-)%s*$", "%1")
|
||||||
%if 0%{?-n:1}
|
local default_ver = rpm.expand("%{lua_version_default_nodots}"):gsub("^%s*(.-)%s*$", "%1")
|
||||||
Provides: %{-n*} = %{version}-%{release}
|
|
||||||
Obsoletes: %{-n*} < %{version}-%{release}
|
local output = ""
|
||||||
%else
|
|
||||||
%if 0%{?-e:1}
|
-- Check if we are building for the default Lua version
|
||||||
Provides: %{mod_name} = %{version}-%{release}
|
if current_ver == default_ver then
|
||||||
Obsoletes: %{mod_name} < %{version}-%{release}
|
|
||||||
%else
|
local package_type = rpm.expand("%{?lua_provides_type}"):gsub("^%s*(.-)%s*$", "%1")
|
||||||
Provides: lua-%{mod_name} = %{version}-%{release}
|
local package_name = mod_name
|
||||||
Obsoletes: lua-%{mod_name} < %{version}-%{release}
|
|
||||||
%endif
|
-- Check for type defined externally (e.g., via --define 'lua_provides_type package-name')
|
||||||
%endif
|
if package_type == "exclude-prefix" then
|
||||||
%endif
|
-- 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
|
# 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_treedir %{_prefix}/lib/luarocks/rocks-%{lua_version}
|
||||||
|
|
||||||
%luarocks_install \
|
%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