convert the package from update-alternatives to libalternatives

And overall improve the packaging.
This commit is contained in:
2025-07-15 14:17:20 +02:00
parent 817bcac62a
commit 411bb03abb
2 changed files with 27 additions and 62 deletions

View File

@@ -10,8 +10,8 @@ Subject: build system
Index: lua-5.5.0-beta/Makefile
===================================================================
--- lua-5.5.0-beta.orig/Makefile 2025-07-11 12:05:58.289205384 +0200
+++ lua-5.5.0-beta/Makefile 2025-07-11 12:06:00.906212327 +0200
--- lua-5.5.0-beta.orig/Makefile 2025-06-26 15:04:37.000000000 +0200
+++ lua-5.5.0-beta/Makefile 2025-07-16 11:43:49.998066837 +0200
@@ -10,18 +10,18 @@
# so take care if INSTALL_TOP is not an absolute path. See the local target.
# You may want to make INSTALL_LMOD and INSTALL_CMOD consistent with
@@ -69,8 +69,8 @@ Index: lua-5.5.0-beta/Makefile
uninstall:
Index: lua-5.5.0-beta/src/Makefile
===================================================================
--- lua-5.5.0-beta.orig/src/Makefile 2025-07-11 12:05:58.289205384 +0200
+++ lua-5.5.0-beta/src/Makefile 2025-07-11 12:13:07.455546422 +0200
--- lua-5.5.0-beta.orig/src/Makefile 2025-06-26 14:57:29.000000000 +0200
+++ lua-5.5.0-beta/src/Makefile 2025-07-16 11:43:49.998317291 +0200
@@ -7,7 +7,7 @@
PLAT= guess
@@ -177,8 +177,8 @@ Index: lua-5.5.0-beta/src/Makefile
Index: lua-5.5.0-beta/src/luaconf.h
===================================================================
--- lua-5.5.0-beta.orig/src/luaconf.h 2025-07-11 12:05:58.289205384 +0200
+++ lua-5.5.0-beta/src/luaconf.h 2025-07-11 12:06:00.906620685 +0200
--- lua-5.5.0-beta.orig/src/luaconf.h 2025-06-28 12:06:32.000000000 +0200
+++ lua-5.5.0-beta/src/luaconf.h 2025-07-16 11:43:49.998518156 +0200
@@ -239,7 +239,7 @@
#else /* }{ */

View File

@@ -46,9 +46,10 @@ Patch3: main_test.patch
Patch6: shared_link.patch
# PATCH-FIX-UPSTREAM inspect errno only after failure
Patch8: execresult.patch
Requires(post): update-alternatives
Requires(postun):update-alternatives
BuildRequires: lua-interpreter
Requires: alts
Provides: lua = %{version}
Conflicts: lua
Obsoletes: lua < %{version}
Provides: Lua(API) = %{major_version}
%if "%{flavor}" == "test"
@@ -80,8 +81,7 @@ Group: Development/Libraries/C and C++
Requires: %{libname} = %{version}
Requires: %{name} = %{version}
Requires: lua-macros
Requires(post): update-alternatives
Requires(postun):update-alternatives
Conflicts: lua-devel
Provides: lua-devel = %{version}
Provides: Lua(devel) = %{major_version}
Provides: pkgconfig(lua) = %{version}
@@ -151,8 +151,10 @@ mv lua-5.5.0-tests testes
%if "%{flavor}" != "test"
cat doc/lua.1 | sed 's/TH LUA 1/TH LUA%{major_version} 1/' > doc/lua%{major_version}.1
cat doc/luac.1 | sed 's/TH LUAC 1/TH LUAC%{major_version} 1/' > doc/luac%{major_version}.1
%endif
%build
%if "%{flavor}" != "test"
sed -i -e "s@lib/lua/@%{_lib}/lua/@g" src/luaconf.h
%make_build linux -C src \
CC="cc" LIBDIR="%{_libdir}" \
@@ -185,33 +187,28 @@ Version: %{version}
Libs: -llua%{major_version} -lm
Cflags: -I\${includedir}
EOF
install -D -m 644 lua%{major_version}.pc %{buildroot}%{_libdir}/pkgconfig/lua%{major_version}.pc
# update-alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for file in lua luac ; do
touch "%{buildroot}%{_sysconfdir}/alternatives/${file}"
ln -sf "%{_sysconfdir}/alternatives/${file}" "%{buildroot}%{_bindir}/${file}"
touch "%{buildroot}%{_sysconfdir}/alternatives/${file}.1%{ext_man}"
ln -sf "%{_sysconfdir}/alternatives/${file}.1%{ext_man}" "%{buildroot}%{_mandir}/man1/${file}.1%{ext_man}"
done
# alternatives - create configuration file
mkdir -p %{buildroot}%{_datadir}/libalternatives/lua
cat > %{buildroot}%{_datadir}/libalternatives/lua/55.conf <<EOF
binary=%{_bindir}/lua5.5
binary=%{_bindir}/luac5.5
man=lua5.5
man=luac5.5
EOF
# Compat link with older unprefixed library and with soname 0 from deb/etc
ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.%{major_version}
ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.0
ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua.so.%{major_version}
# Library devel alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/liblua.so
ln -sf %{_sysconfdir}/alternatives/liblua.so %{buildroot}%{_libdir}/liblua.so
touch %{buildroot}%{_sysconfdir}/alternatives/lua.pc
ln -sf %{_sysconfdir}/alternatives/lua.pc %{buildroot}%{_libdir}/pkgconfig/lua.pc
%else
%endif
%check
%if "%{flavor}" == "test"
cd testes
pushd libs
make all LUA_DIR=%{_includedir}/lua%{major_version}
%make_build all LUA_DIR=%{_includedir}/lua%{major_version}
cp *.so ..
popd
LD_LIBRARY_PATH=%{_libdir} %{_bindir}/lua%{major_version} all.lua
@@ -220,30 +217,11 @@ LD_LIBRARY_PATH=%{_libdir} %{_bindir}/lua%{major_version} all.lua
%if "%{flavor}" != "test"
%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig
%endif
%post
%{_sbindir}/update-alternatives --install \
%{_bindir}/lua lua %{_bindir}/lua%{major_version} 55 \
--slave %{_bindir}/luac luac %{_bindir}/luac%{major_version} \
--slave %{_mandir}/man1/lua.1%{ext_man} lua.1%{ext_man} %{_mandir}/man1/lua%{major_version}.1%{ext_man} \
--slave %{_mandir}/man1/luac.1%{ext_man} luac.1%{ext_man} %{_mandir}/man1/luac%{major_version}.1%{ext_man}
%postun
if [ "$1" = 0 ] ; then
%{_sbindir}/update-alternatives --remove lua %{_bindir}/lua%{major_version}
fi
%post devel
%{_sbindir}/update-alternatives --install \
%{_libdir}/liblua.so liblua.so %{_libdir}/liblua%{major_version}.so 55 \
--slave %{_libdir}/pkgconfig/lua.pc lua.pc %{_libdir}/pkgconfig/lua%{major_version}.pc
%postun devel
if [ "$1" = 0 ] ; then
%{_sbindir}/update-alternatives --remove liblua.so %{_libdir}/liblua%{major_version}.so
fi
%if "%{flavor}" != "test"
%files
%doc README
%dir %{_libdir}/lua
%dir %{_libdir}/lua/%{major_version}
%dir %{_datadir}/lua
@@ -252,15 +230,7 @@ fi
%{_bindir}/luac%{major_version}
%{_mandir}/man1/lua%{major_version}.1%{?ext_man}
%{_mandir}/man1/luac%{major_version}.1%{?ext_man}
# alternatives
%{_bindir}/lua
%{_bindir}/luac
%{_mandir}/man1/lua.1%{?ext_man}
%{_mandir}/man1/luac.1%{?ext_man}
%ghost %{_sysconfdir}/alternatives/lua
%ghost %{_sysconfdir}/alternatives/luac
%ghost %{_sysconfdir}/alternatives/lua.1%{ext_man}
%ghost %{_sysconfdir}/alternatives/luac.1%{ext_man}
%{_datadir}/libalternatives/lua/55.conf
%files -n %{libname}
%{_libdir}/liblua%{major_version}.so.*
@@ -275,11 +245,6 @@ fi
%{_includedir}/lua%{major_version}/lualib.h
%{_libdir}/liblua%{major_version}.so
%{_libdir}/pkgconfig/lua%{major_version}.pc
# alternatives
%{_libdir}/liblua.so
%{_libdir}/pkgconfig/lua.pc
%ghost %{_sysconfdir}/alternatives/liblua.so
%ghost %{_sysconfdir}/alternatives/lua.pc
%files doc
%doc doc/*