44.2. lua54-5.4.9
Lua 5.4, installed beside Lua 5.5 for software that requires 5.4
| Version | 5.4.9, release 1 |
| Shelf | lang — Language implementations, plus the modules of any language that has no module shelf of its own |
| Phase | 30_foundation (Build Foundation), 105 of 127 in build order |
| Licence | MIT |
| Homepage | https://www.lua.org/ |
| Build time | 0.3 SBU |
| Installed size | 1.4 MiB in 15 files |
| Recipe | ports/core/lang/lua54/kpkgbuild |
About
This port is Lua 5.4, installed beside the system lua rather than in place of it. It exists for software that runs on 5.4 and not on the newer series: prosody, the XMPP server, together with the four modules it needs, lua54-luasocket, lua54-luasec, lua54-luaexpat and lua54-luafilesystem. libinput, vlc, darktable, fastfetch, lite-xl, grafx2 and crawl-tiles build against it as well. The recipe’s series = 5.4 keeps the version checker from offering a release past 5.4.
The two installs are kept apart by name. Every path this one writes carries the version: the programs are lua5.4 and luac5.4, the headers are in /usr/include/lua5.4, the libraries are liblua5.4.so and liblua5.4.a, the pkg-config file is lua5.4.pc, and the manual pages are lua5.4.1 and luac5.4.1. Nothing here writes a path the lua port writes, so kpkg sees no conflict and neither package shadows the other; see A second version beside the first.
Why it is in KDOS
The comment above it in script/phases/30_foundation/packages.txt:
5.4 BESIDE 5.5, not instead of it. Prosody 13 supports 5.2 through 5.4 and will not load on 5.5; every path this installs is versioned, so neither package can shadow the other.
Sources
lua54-5.4.9.tar.gz(364.7 KiB)
sha2562335b6c582a52654f94612bf10d2f4672805d05329aa6568b1d8cd9e5c6fb8e6
upstream: https://www.lua.org/ftp/lua-5.4.9.tar.gz
archive copy: sources-3/lang--lua54-5.4.9.tar.gz
Dependencies
Depends on: readline.
Required by (12): crawl-tiles, darktable, fastfetch, grafx2, libinput, lite-xl, lua54-luaexpat, lua54-luafilesystem, lua54-luasec, lua54-luasocket, prosody, vlc.
Patches
build.sh applies these; kpkg applies nothing by itself.
lua-root-usr.patch— ChangesLUA_ROOTinsrc/luaconf.hfrom/usr/local/to/usr/, so the defaultpackage.pathandpackage.cpathsearch/usr/share/lua/5.4and/usr/lib/lua/5.4, where thelua54-*modules install.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/30_foundation/phase.env && kpkg install lua54'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/lang/lua54.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/lang/lua54
echo '2335b6c582a52654f94612bf10d2f4672805d05329aa6568b1d8cd9e5c6fb8e6 lua54-5.4.9.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/lua54
SRC=$SRC_ROOT/lua54-5.4.9
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf lua54-5.4.9.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _majorver, series and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i $PORT_SRC/lua-root-usr.patch
make CC=cc MYCFLAGS="$CFLAGS -DLUA_COMPAT_5_3 -fPIC" MYLDFLAGS="$LDFLAGS" linux-readline
cd src
cc -shared $LDFLAGS -ldl -Wl,-soname,liblua${_majorver}.so.${_majorver} \
-o liblua${_majorver}.so.$version \
-Wl,-whole-archive liblua.a -Wl,-no-whole-archive
cd ..
install -Dm755 src/lua $PKG/usr/bin/lua$_majorver
install -Dm755 src/luac $PKG/usr/bin/luac$_majorver
install -Dm644 doc/lua.1 $PKG/usr/share/man/man1/lua$_majorver.1
install -Dm644 doc/luac.1 $PKG/usr/share/man/man1/luac$_majorver.1
install -d $PKG/usr/include/lua$_majorver
install -m644 src/lua.h src/luaconf.h src/lualib.h src/lauxlib.h src/lua.hpp \
$PKG/usr/include/lua$_majorver/
install -Dm755 src/liblua${_majorver}.so.$version \
$PKG/usr/lib/liblua${_majorver}.so.$version
ln -s liblua${_majorver}.so.$version $PKG/usr/lib/liblua${_majorver}.so.${_majorver}
ln -s liblua${_majorver}.so.$version $PKG/usr/lib/liblua${_majorver}.so
install -Dm644 src/liblua.a $PKG/usr/lib/liblua${_majorver}.a
install -d $PKG/usr/lib/lua/$_majorver $PKG/usr/share/lua/$_majorver
install -d $PKG/usr/lib/pkgconfig
cat > $PKG/usr/lib/pkgconfig/lua$_majorver.pc << EOF
V=$_majorver
R=$version
EOF
cat >> $PKG/usr/lib/pkgconfig/lua5.4.pc << "EOF"
prefix=/usr
INSTALL_BIN=${prefix}/bin
INSTALL_INC=${prefix}/include/lua${V}
INSTALL_LIB=${prefix}/lib
INSTALL_MAN=${prefix}/share/man/man1
INSTALL_LMOD=${prefix}/share/lua/${V}
INSTALL_CMOD=${prefix}/lib/lua/${V}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/lua${V}
Name: Lua
Description: An Extensible Extension Language
Version: ${R}
Requires:
Libs: -L${libdir} -llua${V} -lm -ldl
Cflags: -I${includedir}
EOF
install -Dm644 "$SRC/src/lua.h" "$PKG/usr/share/licenses/$name/lua.h"
The switches, and why each is set:
CC=cc— Replaces upstream’sCC= gcc -std=gnu99, so the language standard comes from the tree’sCFLAGS, which name-std=gnu11.MYCFLAGS="$CFLAGS -DLUA_COMPAT_5_3 -fPIC"—MYCFLAGSis how the tree’s flags reach upstream’s makefile, which assigns its ownCFLAGS.LUA_COMPAT_5_3turns on the 5.3 compatibility set inluaconf.h: the deprecated mathematical functions, the integer-cast API macros such asluaL_checkint, the emulation of__lethrough__lt, and the old API names such aslua_strlen. Upstream’s ownCFLAGSline defines it too, so here it restates the default.-fPICis needed because the shared library is linked from the objects ofliblua.a; the tree’sCFLAGScarry it as well.MYLDFLAGS="$LDFLAGS"— Passes the tree’s linker flags into the link lines ofluaandluac.linux-readline— Builds for Linux with readline linked into the interpreter,lua5.4, for line editing and history at its prompt;linuxis an alias oflinux-noreadline, the build without it.liblua5.4.sois linked fromliblua.aand does not link readline.-Wl,-soname,liblua${_majorver}.so.${_majorver}— Gives the shared library the sonameliblua5.4.so.5.4, distinct from the lua port’sliblua.so.<series>.-Wl,-whole-archive— Puts every object ofliblua.ainto the shared library, not only the ones something references.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/lua54, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf lua54-5.4.9-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/lua54, and runs the triggers its paths call for.
Contents
Installed programs: lua5.4, luac5.4.
Installed libraries: liblua5.4.a, liblua5.4.so.
Installed directories: /usr/include/lua5.4, /usr/share/licenses/lua54.
Short descriptions
lua5.4 |
Lua interpreter |
luac5.4 |
Lua compiler |
lua5.4.pc |
An Extensible Extension Language |
Notes
Upstream’s make install is not used: it would write lua, luac and unversioned headers, the lua port’s own paths. Each file is installed by hand under its versioned name instead, and the module directories /usr/lib/lua/5.4 and /usr/share/lua/5.4 are created empty for the modules to fill.
lua5.4.pc is written by two here-documents, for the reason the lua port gives: the first expands only V and R, and the second, quoted, keeps every ${prefix}, ${libdir} and ${V} for pkg-config to expand. Its Cflags name /usr/include/lua5.4 and its Libs name -llua5.4. A consumer that takes the headers from /usr/include instead gets the lua port’s newer ones; see A bundled header shadowed by the system’s.