From e56c3f6125d16690d81244ca9b74f4e5ed6413b3 Mon Sep 17 00:00:00 2001 From: zyppe <210hcl@gmail.com> Date: Wed, 28 Feb 2024 21:05:43 +0800 Subject: [PATCH] Initialize for lua53 --- .gitignore | 1 + .lua53.metadata | 1 + baselibs.conf | 1 + lua-build-system.patch | 156 ++++++++++++++++++++ lua53.changes | 322 +++++++++++++++++++++++++++++++++++++++++ lua53.spec | 241 ++++++++++++++++++++++++++++++ 6 files changed, 722 insertions(+) create mode 100644 .gitignore create mode 100644 .lua53.metadata create mode 100644 baselibs.conf create mode 100644 lua-build-system.patch create mode 100644 lua53.changes create mode 100644 lua53.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6832ec4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lua-5.3.6.tar.gz diff --git a/.lua53.metadata b/.lua53.metadata new file mode 100644 index 0000000..0fea05a --- /dev/null +++ b/.lua53.metadata @@ -0,0 +1 @@ +b8081e12a3d0b52b67cd369f27d02ba0adb679884000376ff30a0e82c45ec20d lua-5.3.6.tar.gz diff --git a/baselibs.conf b/baselibs.conf new file mode 100644 index 0000000..7b78e58 --- /dev/null +++ b/baselibs.conf @@ -0,0 +1 @@ +liblua5_3-5 diff --git a/lua-build-system.patch b/lua-build-system.patch new file mode 100644 index 0000000..0894883 --- /dev/null +++ b/lua-build-system.patch @@ -0,0 +1,156 @@ +From: Enrico Tassi +Date: Sun, 1 Mar 2015 16:13:52 +0100 +Subject: build system + +--- + Makefile | 25 ++++++++++++++----------- + src/Makefile | 21 ++++++++++++--------- + src/luaconf.h | 2 +- + 3 files changed, 27 insertions(+), 21 deletions(-) + +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,8 @@ + # Makefile for installing Lua + # See doc/readme.html for installation and customization instructions. + ++export LIBTOOL=libtool --quiet ++ + # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + + # Your platform. See PLATS for possible values. +@@ -10,19 +12,20 @@ PLAT= none + # 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 + # LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h. +-INSTALL_TOP= /usr/local ++INSTALL_TOP= /usr + INSTALL_BIN= $(INSTALL_TOP)/bin +-INSTALL_INC= $(INSTALL_TOP)/include +-INSTALL_LIB= $(INSTALL_TOP)/lib +-INSTALL_MAN= $(INSTALL_TOP)/man/man1 ++INSTALL_INC= $(INSTALL_TOP)/include/lua$(V)/ ++INSTALL_LIB= $(INSTALL_TOP)/lib/ ++INSTALL_MAN= $(INSTALL_TOP)/share/man/man1 + INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V +-INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V ++INSTALL_CMOD= $(INSTALL_LIB)/lua/$V + + # How to install. If your install program does not support "-p", then + # you may have to run ranlib on the installed liblua.a. + INSTALL= install -p + INSTALL_EXEC= $(INSTALL) -m 0755 + INSTALL_DATA= $(INSTALL) -m 0644 ++INSTALL_LIBTOOL= $(LIBTOOL) --mode=install install -m 0644 + # + # If you don't have "install" you can use "cp" instead. + # INSTALL= cp -p +@@ -39,10 +42,10 @@ RM= rm -f + PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris + + # What to install. +-TO_BIN= lua luac ++TO_BIN= lua$(V) luac$(V) + TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp +-TO_LIB= liblua.a +-TO_MAN= lua.1 luac.1 ++TO_LIB= liblua$(V).la ++TO_MAN= lua$(V).1 luac$(V).1 + + # Lua version and release. + V= 5.3 +@@ -52,16 +55,16 @@ R= $V.6 + all: $(PLAT) + + $(PLATS) clean: +- cd src && $(MAKE) $@ ++ cd src && $(MAKE) $@ V=$(V) + + test: dummy +- src/lua -v ++ $(LIBTOOL) --mode=execute -dlopen src/liblua$(V).la src/lua$(V) -v + + install: dummy + cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) + cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) + cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) +- cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) ++ cd src && $(INSTALL_LIBTOOL) $(TO_LIB) $(INSTALL_LIB) + cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN) + + uninstall: +--- a/src/Makefile ++++ b/src/Makefile +@@ -7,7 +7,7 @@ + PLAT= none + + CC= gcc -std=gnu99 +-CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) ++CFLAGS= -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) + LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) + LIBS= -lm $(SYSLIBS) $(MYLIBS) + +@@ -20,15 +20,19 @@ SYSLDFLAGS= + SYSLIBS= + + MYCFLAGS= ++MYCXXFLAGS= + MYLDFLAGS= +-MYLIBS= ++MYLIBS=-ldl + MYOBJS= + ++%.o : %.c ++ $(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) -c $< -o $@ ++ + # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= + + PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris + +-LUA_A= liblua.a ++LUA_A= liblua$(V).la + CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \ + lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \ + ltm.o lundump.o lvm.o lzio.o +@@ -36,10 +40,10 @@ LIB_O= lauxlib.o lbaselib.o lbitlib.o lc + lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o + BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS) + +-LUA_T= lua ++LUA_T= lua$(V) + LUA_O= lua.o + +-LUAC_T= luac ++LUAC_T= luac$(V) + LUAC_O= luac.o + + ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) +@@ -56,14 +60,13 @@ o: $(ALL_O) + a: $(ALL_A) + + $(LUA_A): $(BASE_O) +- $(AR) $@ $(BASE_O) +- $(RANLIB) $@ ++ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -lm -ldl $(BASE_O:.o=.lo) -rpath /usr/lib -version-info 8:0:3 -o liblua$(V).la + + $(LUA_T): $(LUA_O) $(LUA_A) +- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) ++ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LIBS) -static liblua$(V).la -Wl,-E lua.lo -o $@ + + $(LUAC_T): $(LUAC_O) $(LUA_A) +- $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) ++ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -static liblua$(V).la luac.lo -o $@ + + clean: + $(RM) $(ALL_T) $(ALL_O) +--- a/src/luaconf.h ++++ b/src/luaconf.h +@@ -200,7 +200,7 @@ + + #else /* }{ */ + +-#define LUA_ROOT "/usr/local/" ++#define LUA_ROOT "/usr/" + #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" + #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" + #define LUA_PATH_DEFAULT \ diff --git a/lua53.changes b/lua53.changes new file mode 100644 index 0000000..33fc220 --- /dev/null +++ b/lua53.changes @@ -0,0 +1,322 @@ +* Tue Jun 1 2021 mcepl@suse.com +- Sync with Factory (5.3.6), includes fixes for + - Long brackets with a huge number of '=' overflow some + internal buffer arithmetic. + - bsc#1123043 CVE-2019-6706 Fix free-after-use bug in + lua_upvaluejoin function of lapi.c +- Remove upstreamed patches: + - CVE-2019-6706-use-after-free-lua_upvaluejoin.patch +* Fri Sep 25 2020 callumjfarmer13@gmail.com +- Update to version 5.3.6: + * Fixes bugs found in Lua 5.3.5 and Lua 5.4.0 + * Lua 5.3 is now EOL +- Removed upstream-bugs.patch: new release (no bugs found yet) +- Removed upstream-bugs-backport-lua54.patch: new release (no bugs found yet) +* Wed Aug 19 2020 callumjfarmer13@gmail.com +- Added upstream-bugs.patch: upstream bug patches + * Patches 2,3,4 +- Added upstream-bugs-backport-lua54.patch: bugs discovered in lua54 + * Patch 10: CVE-2020-24371, boo#1175449 + * Patch 11: CVE-2020-24370, boo#1175448 + * Patch 13 +- Add RISC-V to list of 64-bit architectures +* Fri Aug 2 2019 mliska@suse.cz +- Use FAT LTO objects in order to provide proper static library. +* Tue Mar 12 2019 mcepl@suse.com +- Update to 5.3.5: + (it is really problematic to find ANY documentation of changes + between minor versions; the best we have is + https://www.lua.org/bugs.html) + - Long brackets with a huge number of '=' overflow some + internal buffer arithmetic. + - Small build tweaks. +* Tue Jul 25 2017 tchvatal@suse.com +- Provide symbol for pkgconfig +* Mon Jul 24 2017 dimstar@opensuse.org +- Add INSTALL_LMOD and INSTALL_CMOD variables to lua53.pc: this is + queried for example by rrdtool's buildsystem. +* Thu Jul 20 2017 tchvatal@suse.com +- Properly set includedir in the .pc file +* Mon Jul 10 2017 tchvatal@suse.com +- Require lua macros rather than bundling them with lua itself +* Fri Jul 7 2017 tchvatal@suse.com +- Add patch lua-build-system.patch for all the builsystem changes +- Drop patches merged to the above: + * lua-5.3.3-prefix.patch + * lua-5.3.3-shared.patch +- Drop not really needed lua-5.3.3-visible.patch +- Version update to lua 5.3.4 containing various bugfixes +- Rename to lua53 +* Tue Jun 13 2017 jengelh@inai.de +- Let package description adhere to guidelines: trim redundant + or biased wording and strip future goals. +* Thu Jun 16 2016 i@marguerite.su +- update version 5.3.3 + * bugfix release +- changes in 5.3.2 + * metatable may access its own deallocated field when it has a + self reference in __newindex + * label between local definitions can mix-up their initializations + * gmatch iterator fails when called from a coroutine different + from the one that created it +- split lua-suse.diff to 3 reasonable patches + * add lua-5.3.3-prefix.patch + * add lua-5.3.3-shared.patch + * add lua-5.3.3-visible.patch +* Fri Jul 31 2015 jengelh@inai.de +- Update RPM group classification +* Thu Jul 30 2015 dimstar@opensuse.org +- Provide Lua(API) = 5.3, so that packages installing files to + /usr/share/lua/5.3 can properly depend on the right lua branch. +- Provide Lua(devel) = 5.3 by lua-devel and conflict with other + packages providing Lua(devel) (e.g lua51-devel, lua52-devel...). +* Mon Jul 13 2015 i@marguerite.su +- macros.lua installs to lua-devel +- build with LUA_COMPAT_MODULE to compatible w/ old module system +* Fri Jul 10 2015 i@marguerite.su +- update version 5.3.1 + * integers (64-bit by default) + * official support for 32-bit numbers + * bitwise operators + * basic utf-8 support + * functions for packing and unpacking values + * see http://www.lua.org/manual/5.3/readme.html#changes +* Sun Mar 15 2015 mpluskal@suse.com +- Update to 5.2.4 + * Compiler can optimize away overflow check in table.unpack. + * Ephemeron table can wrongly collect entry with strong key. + * Chunk with too many lines may crash Lua. +* Wed Sep 17 2014 i@marguerite.su +- the %%dir is still needed. +* Fri Sep 12 2014 pgajdos@suse.com +- fix update-alternatives +* Wed Sep 10 2014 pgajdos@suse.com +- fix /etc/rpm/macros.lua perms +* Mon Mar 31 2014 pgajdos@suse.com +- updated to 5.2.3: + * yieldable pcall and metamethods + * new lexical scheme for globals + * ephemeron tables + * new library for bitwise operations + * light C functions + * emergency garbage collector + * goto statement + * finalizers for tables +* Mon Sep 9 2013 pgajdos@suse.com +- updated to 5.2.2: bugfix release, fixed: + * Stack overflow in vararg functions with many fixed parameters + called with few arguments. + * Garbage collector can trigger too many times in recursive loops. + * Wrong assert when reporting concatenation errors (manifests only + when Lua is compiled in debug mode). + * Wrong error message in some short-cut expressions. + * luac listings choke on long strings. + * see http://www.lua.org/bugs.html for details +* Tue Feb 19 2013 pgajdos@suse.com +- fix visibility of global variables [bnc#803791] + * modified lua-suse.diff +- added LUA_SO target as dependency to LUAC_T and LUA_T to fix + parallel build + * modified lua-suse.diff +- added regresion check for this error into %%check +* Tue Feb 5 2013 coolo@suse.com +- update alternatives need to be %%ghosts +* Thu Nov 15 2012 pgajdos@suse.com +- export luaU_dump in order to fix linking of luac binary +* Tue Oct 9 2012 crrodriguez@opensuse.org +- Tweak lua-suse.diff again: + * LUA_IFUNC must be defined as upstream but without "extern", + revert the previous mod. + * LUA_API must be defined as visibility default +* Thu Aug 16 2012 crrodriguez@opensuse.org +- Even after the previous update, third party modules/libraries + would not work because LUA_CDIR constant is wrong in x86_64 +* Wed Aug 15 2012 crrodriguez@opensuse.org +- devel package must require libluaver = %%{version} +* Wed Aug 15 2012 crrodriguez@opensuse.org +- Broken lua-suse patch breaks loading third party modules + or scripts +* Mon Jun 18 2012 pgajdos@suse.com +- updated to 5.2.1: + * main thread predefined in the registry + * bugfixes +* Thu Mar 29 2012 joop.boonen@opensuse.org +- Correction in Provides and Obsolete for lua-libs +- Passed the spec file through spec-cleaner +* Wed Jan 18 2012 dimstar@opensuse.org +- Require liblua5_2 from the -devel package: Otherwise the .so file + is a dangling symlink and apps will use the static lib. +- Update baselibs.conf to reference liblua5_2 instead of liblua5_1. +* Fri Jan 6 2012 dmueller@suse.de +- readd lua.pc for building rpm +* Wed Dec 21 2011 pgajdos@suse.com +- raise update-alternatives priority to 15 (lua51 have 10, lua50 + have 5) +* Wed Dec 21 2011 pgajdos@suse.com +- updated to 5.2.0: + * Main changes + yieldable pcall and metamethods + new lexical scheme for globals + ephemeron tables + new library for bitwise operations + light C functions + emergency garbage collector + [goto] statement + finalizers for tables + * Language + no more fenv for threads or functions + tables honor the [__len] metamethod + hex and [\z] escapes in strings + support for hexadecimal floats + order metamethods work for different types + no more verification of opcode consistency + hook event "tail return" replaced by "tail call" + empty statement + [break] statement may appear in the middle of a block + * Libraries + arguments for function called through [xpcall] + optional 'mode' argument to load and loadfile (to control binary x text) + optional 'env' argument to load and loadfile (environment for loaded chunk) + [loadlib] may load libraries with global names (RTLD_GLOBAL) + new function [package.searchpath] + modules receive their paths when loaded + optional base in [math.log] + optional separator in [string.rep] + [file:write] returns file + closing a pipe returns exit status + [os.exit] may close state + new metamethods [__pairs] and __ipairs + new option 'isrunning' for [collectgarbage] and lua_gc + frontier patterns + [\0] in patterns + new option [*L] for io.read + options for [io.lines] + [debug.getlocal] can access function varargs + * C API + new functions: lua_absindex, lua_arith, lua_compare, lua_copy, lua_len, + lua_rawgetp, lua_rawsetp, lua_upvalueid, lua_upvaluejoin, + lua_version, luaL_checkversion, luaL_setmetatable, + luaL_testudata, luaL_tolstring + [lua_pushstring] and pushlstring return string + [nparams] and isvararg available in debug API + new lua_Unsigned + * Implementation + max constants per function raised to 2^26 + generational mode for garbage collection (experimental) + NaN trick (experimental) + internal (immutable) version of ctypes + simpler implementation for string buffers + parser uses much less C-stack space (no more auto arrays) + * Lua standalone interpreter + new [-E] option to avoid environment variables + handling of non-string error messages +* Tue Oct 4 2011 uli@suse.com +- cross-build fix: use %%__cc macro +* Mon Jun 28 2010 jengelh@medozas.de +- use %%_smp_mflags +* Mon Jun 14 2010 pgajdos@suse.cz +- removed -L/usr/lib from Libs: in etc/lua.pc [bnc#613497] +- used upstream bugfix patch from http://www.lua.org/download.html +* Sat Apr 24 2010 coolo@novell.com +- buildrequire pkg-config to fix provides +* Tue Mar 23 2010 pgajdos@suse.cz +- modified LUA_PATH_DEFAULT [bnc#589441]: search modules under + /usr/%%{_lib}/lua/%%{major_version} too +* Sat Dec 12 2009 jengelh@medozas.de +- add baselibs.conf as a source +- package documentation as noarch +* Sun Dec 6 2009 jengelh@medozas.de +- enable parallel building +* Tue Nov 3 2009 coolo@novell.com +- updated patches to apply with fuzz=0 +* Wed Sep 16 2009 dmueller@suse.de +- add baselibs.conf +* Mon Jun 8 2009 pgajdos@suse.cz +- package owns /usr/{lib,share}/lua directories from now +- emoved unneeded root.patch +* Thu Sep 11 2008 pgajdos@suse.cz +- updated to 5.1.4: bugfix release +* Wed Jun 11 2008 jfunk@funktronics.ca +- Set LUA_ROOT to /usr and fix INSTALL_CMOD for lib64 +- Add RPM macros file +- Allows for lua- packages like python, perl, and ruby +* Fri Mar 28 2008 coolo@suse.de +- hint the solver about the package rename +* Wed Mar 26 2008 coolo@suse.de +- do not package/provide the shared lib twice / follow shared lib + policy +* Tue Feb 19 2008 pgajdos@suse.cz +- created -doc package +- updated to version 5.1.3, bug fix release. Fixed bugs: + * wrong error message in some concatenations + * too many variables in an assignment may cause a C stack + overflow + * an error in a module loaded through the '-l' option shows no + traceback + * gsub may go wild when wrongly called without its third + argument and with a large subject + * table.remove removes last element of a table when given + an out-of-bound index + * lua_setfenv may crash if called over an invalid object + * stand-alone interpreter shows incorrect error message when + the "message" is a coroutine. + * debug.sethook/gethook may overflow the thread's stack +* Tue Jul 24 2007 pgajdos@suse.cz +- using /sbin/ldconfig in specfile +- updated to version 5.1.2, fixes some bugs: + * count hook may be called without being set + * code generated for "-nil", "-true", and "-false" is wrong + * recursive coroutines may overflow C stack + * wrong error message in some concatenations + * very small numbers all collide in the hash function +* Mon Nov 27 2006 mrueckert@suse.de +- package liblua.so as symlink. +* Thu Nov 16 2006 mrueckert@suse.de +- the core package now uses update alternatives to allow installation + of 5.0.x and 5.1.x +- devel packages will conflict now +* Tue Nov 14 2006 mrueckert@suse.de +- ARGH dont copy and paste!: + lua-libs should not depend on lua. another run on (#217875) +* Tue Nov 14 2006 mrueckert@suse.de +- really fix the file pattern (#217875) +* Thu Nov 9 2006 mrueckert@suse.de +- splitted out lua-libs so we can install at least both libs + in parallel. (#217875) +* Thu Oct 19 2006 dmueller@suse.de +- fix wrong prefix in lua.pc +- link liblua with -lm to satisfy unresolved symbols +* Thu Oct 19 2006 mjancar@suse.cz +- include lua.pc +* Wed Oct 18 2006 mjancar@suse.cz +- update to 5.1.1 + Language: + * new module system. + * new semantics for control variables of fors. + * new semantics for setn/getn. + * new syntax/semantics for varargs. + * new long strings and comments. + * new `mod' operator (`%%') + * new length operator #t + * metatables for all types + API: + * new functions: lua_createtable, lua_get(set)field, lua_push(to)integer. + * user supplies memory allocator (lua_open becomes lua_newstate). + * luaopen_* functionst must be called through Lua. + Implementation: + * new configuration scheme via luaconf.h. + * incremental garbage collection. + * better handling of end-of-line in the lexer. + * fully reentrant parser (new Lua function `load') + * better support for 64-bit machines. + * native loadlib support for Mac OS X. + * standard distribution in only one library (lualib.a merged into lua.a) +* Wed Jan 25 2006 mls@suse.de +- converted neededforbuild to BuildRequires +* Sat Jan 14 2006 schwab@suse.de +- Don't strip binaries. +- Fix shared library linking. +* Thu Sep 8 2005 anicka@suse.cz +- enable dynamic loading capability (#106845) +* Fri Apr 23 2004 mcihar@suse.cz +- initial packaging diff --git a/lua53.spec b/lua53.spec new file mode 100644 index 0000000..14a8a5b --- /dev/null +++ b/lua53.spec @@ -0,0 +1,241 @@ +# +# spec file for package lua53 +# +# Copyright (c) 2022-2023 ZhuningOS +# + + +%define major_version 5.3 +%define libname liblua5_3-5 +Name: lua53 +Version: 5.3.6 +Release: 3.6.1 +Summary: Small Embeddable Language with Procedural Syntax +License: MIT +Group: Development/Languages/Other +Url: http://www.lua.org +Source: http://www.lua.org/ftp/lua-%{version}.tar.gz +Source99: baselibs.conf +# PATCH-FIX-SUSE tweak the buildsystem to produce what is needed for SUSE +Patch0: lua-build-system.patch +BuildRequires: libtool +BuildRequires: lua-macros +BuildRequires: pkgconfig +BuildRequires: readline-devel +Requires(post): update-alternatives +Requires(postun): update-alternatives +Provides: lua = %{version} +Obsoletes: lua < %{version} +Provides: Lua(API) = %{major_version} + +%description +Lua is a programming language originally designed for extending +applications, but is also frequently used as a general-purpose, +stand-alone language. + +Lua combines procedural syntax (similar to Pascal) with +data description constructs based on associative arrays and extensible +semantics. Lua is dynamically typed, interpreted from byte codes, and +has automatic memory management, making it suitable for configuration, +scripting, and rapid prototyping. Lua is implemented as a small library +of C functions, written in ANSI C. + +%package devel +Summary: Development files for lua +Group: Development/Libraries/C and C++ +Requires: %{libname} = %{version} +Requires: %{name} = %{version} +Requires: lua-macros +Requires(post): update-alternatives +Requires(postun): update-alternatives +Provides: lua-devel = %{version} +Provides: Lua(devel) = %{major_version} +Provides: pkgconfig(lua) = %{version} + +%description devel +Lua is a programming language originally designed for extending +applications, but is also frequently used as a general-purpose, +stand-alone language. + +This package contains files needed for embedding lua into your +application. + +%package -n %{libname} +Summary: The Lua integration library +# Compat as libtool changes the soname +Group: System/Libraries +%ifarch aarch64 x86_64 ppc64 ppc64le s390x riscv64 +Provides: liblua.so.5.3()(64bit) +%else +Provides: liblua.so.5.3 +%endif +Provides: liblua5_3 = %{version}-%{release} +Obsoletes: liblua5_3 < %{version}-%{release} +Provides: %{name}-libs = %{version} +Obsoletes: %{name}-libs < %{version} + +%description -n %{libname} +Lua is a programming language originally designed for extending +applications, but is also frequently used as a general-purpose, +stand-alone language. + +Lua combines procedural syntax (similar to Pascal) with +data description constructs based on associative arrays and extensible +semantics. Lua is dynamically typed, interpreted from byte codes, and +has automatic memory management, making it suitable for configuration, +scripting, and rapid prototyping. Lua is implemented as a small library +of C functions, written in ANSI C. + +%package doc +Summary: Documentation for Lua, a small embeddable language +Group: Documentation/HTML +BuildArch: noarch + +%description doc +Lua is a programming language originally designed for extending +applications, but is also frequently used as a general-purpose, +stand-alone language. + +Lua combines procedural syntax (similar to Pascal) with +data description constructs based on associative arrays and extensible +semantics. Lua is dynamically typed, interpreted from byte codes, and +has automatic memory management, making it suitable for configuration, +scripting, and rapid prototyping. Lua is implemented as a small library +of C functions, written in ANSI C. + +%prep +%setup -q -n lua-%{version} +%autopatch -p1 + +# manpage +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 + +%build +%global _lto_cflags %{_lto_cflags} -ffat-lto-objects +sed -i -e "s@lib/lua/@%{_lib}/lua/@g" src/luaconf.h +export LIBTOOL="libtool --quiet" +make %{?_smp_mflags} -C src \ + CC="cc" \ + MYCFLAGS="%{optflags} -std=gnu99 -D_GNU_SOURCE -fPIC -DLUA_USE_LINUX -DLUA_COMPAT_MODULE" \ + MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" \ + V=%{major_version} \ + all + +%install +make install \ + V=%{major_version} \ + INSTALL_TOP="%{buildroot}%{_prefix}" \ + INSTALL_LIB="%{buildroot}%{_libdir}" + +find %{buildroot} -type f -name "*.la" -delete -print + +# create pkg-config file +cat > lua%{major_version}.pc <<-EOF +prefix=%{_prefix} +exec_prefix=%{_prefix} +libdir=%{_libdir} +includedir=%{_prefix}/include/lua%{major_version} +INSTALL_LMOD=%{_datadir}/lua/%{major_version} +INSTALL_CMOD=%{_libdir}/lua/%{major_version} + +Name: Lua %{major_version} +Description: An Extensible Extension Language +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 + +# 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 + +%check +cd src +LD_LIBRARY_PATH=`pwd` ./lua%{major_version} -e 'print(0)' > /dev/null + +%post -n %{libname} -p /sbin/ldconfig +%postun -n %{libname} -p /sbin/ldconfig + +%post +%{_sbindir}/update-alternatives --install \ + %{_bindir}/lua lua %{_bindir}/lua%{major_version} 53 \ + --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 53 \ + --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 + +%files +%doc README +%dir %{_libdir}/lua +%dir %{_libdir}/lua/%{major_version} +%dir %{_datadir}/lua +%dir %{_datadir}/lua/%{major_version} +%{_bindir}/lua%{major_version} +%{_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} + +%files -n %{libname} +%{_libdir}/liblua%{major_version}.so.* +%{_libdir}/liblua.so.* + +%files devel +%dir %{_includedir}/lua%{major_version} +%{_includedir}/lua%{major_version}/lauxlib.h +%{_includedir}/lua%{major_version}/lua.h +%{_includedir}/lua%{major_version}/lua.hpp +%{_includedir}/lua%{major_version}/luaconf.h +%{_includedir}/lua%{major_version}/lualib.h +%{_libdir}/liblua%{major_version}.a +%{_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/* + +%changelog