44.1. lua-5.5.1
Lightweight programming language designed for extending applications
| Version | 5.5.1, 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), 104 of 127 in build order |
| Licence | MIT |
| Homepage | https://www.lua.org/ |
| Build time | 0.2 SBU |
| Installed size | 966.9 KiB in 15 files |
| Recipe | ports/core/lang/lua/kpkgbuild |
About
Lua is a small embeddable scripting language. This port is the system Lua: the lua interpreter, luac, and liblua.so with its headers directly in /usr/include. On the desktop’s own path, wireplumber, PipeWire’s session manager, runs its policy scripts in it (see Audio); wireshark, weechat, gnuplot, sc-im, tio and celestia embed it too.
Software that cannot move to this series uses lua54, installed beside it under versioned names.
Upstream’s makefile builds only a static library and installs no pkg-config file. The recipe links a shared library from that archive itself and writes lua.pc.
Sources
lua-5.5.1.tar.gz(389.3 KiB)
sha2561c4b4068d67061f2a2231ad2b5422e77acea1487ea9890f6320af614f4373dce
upstream: https://www.lua.org/ftp/lua-5.5.1.tar.gz
archive copy: sources-3/lang--lua-5.5.1.tar.gz
Dependencies
Depends on: readline.
Required by (8): celestia, gnuplot, lxi-tools, sc-im, tio, weechat, wireplumber, wireshark.
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/<version>and/usr/lib/lua/<version>, where this tree installs Lua modules.
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 lua'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/lang/lua.
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/lua
echo '1c4b4068d67061f2a2231ad2b5422e77acea1487ea9890f6320af614f4373dce lua-5.5.1.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/lua
SRC=$SRC_ROOT/lua-5.5.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf lua-5.5.1.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 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_2 -DLUA_COMPAT_5_1 -fPIC" MYLDFLAGS="$LDFLAGS" \
linux-readline
cd src
cc -shared $LDFLAGS -ldl -Wl,-soname,liblua.so.${_majorver} -o liblua.so.$version -Wl,-whole-archive liblua.a -Wl,-no-whole-archive
ln -s liblua.so.$version liblua.so.${_majorver}
ln -s liblua.so.$version liblua.so
cd ..
make INSTALL_TOP=$PKG/usr \
TO_LIB="liblua.so liblua.so.$_majorver liblua.so.$version" \
INSTALL_DATA="cp -d" \
INSTALL_MAN=$PKG/usr/share/man/man1 install
install -d $PKG/usr/lib/pkgconfig
cat > $PKG/usr/lib/pkgconfig/lua.pc << EOF
V=$_majorver
R=$version
EOF
cat >> $PKG/usr/lib/pkgconfig/lua.pc << "EOF"
prefix=/usr
INSTALL_BIN=${prefix}/bin
INSTALL_INC=${prefix}/include
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
Name: Lua
Description: An Extensible Extension Language
Version: ${R}
Requires:
Libs: -L${libdir} -llua -lm -ldl
Cflags: -I${includedir}
EOF
ln -s lua.pc $PKG/usr/lib/pkgconfig/lua$_majorver.pc
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. The language standard then comes from the tree’sCFLAGS, which name-std=gnu11.MYCFLAGS="$CFLAGS -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_1 -fPIC"—MYCFLAGSis the variable upstream’s makefile leaves for the builder; its ownCFLAGSis assigned in the makefile, so the tree’s flags reach the compiler only through here.-fPICis needed because the shared library is linked from the objects ofliblua.a; the tree’sCFLAGScarry it as well. The twoLUA_COMPAT_macros are tested by none of this release’s sources, whose compatibility switches areLUA_COMPAT_GLOBAL,LUA_COMPAT_MATHLIBandLUA_COMPAT_APIINTCASTS, so they change nothing in the build.MYLDFLAGS="$LDFLAGS"— Passes the tree’s linker flags into the link lines ofluaandluac.linux-readline— Builds for Linux withLUA_USE_LINUXandLUA_USE_READLINE, linking readline into theluainterpreter for line editing and history at its prompt.liblua.sois linked fromliblua.aand does not link readline.-Wl,-soname,liblua.so.${_majorver}— Gives the shared library the sonameliblua.so.<series>, so a program linked against it records the series, not the full version.-Wl,-whole-archive— Puts every object ofliblua.ainto the shared library, not only the ones something references.INSTALL_TOP=$PKG/usr— Installs under/usrin the package, rather than upstream’s/usr/local.TO_LIB="liblua.so liblua.so.$_majorver liblua.so.$version"— Hasmake installinstall the shared library and its two links in place ofliblua.a, so the static archive is not installed.INSTALL_DATA="cp -d"— Copies the two links as links; upstream’sinstall -m 0644would copy the library three times.INSTALL_MAN=$PKG/usr/share/man/man1— Putslua.1andluac.1wheremanlooks, rather than upstream’s$(INSTALL_TOP)/man/man1.
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/lua, 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 lua-5.5.1-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/lua, and runs the triggers its paths call for.
Contents
Installed programs: lua, luac.
Installed libraries: liblua.so.
Installed directories: /usr/lib/lua/5.5, /usr/share/licenses/lua, /usr/share/lua/5.5.
Short descriptions
lua |
Lua interpreter |
luac |
Lua compiler |
lua.pc |
An Extensible Extension Language |
Notes
lua.pc is written by two here-documents, and the split matters. The first is unquoted and expands only V and R, the version series and the full version. The second is quoted, so every ${prefix}, ${libdir} and ${V} in it reaches the file literally, as the pkg-config variables they are. Written as one quoted here-document, the V= and R= lines would hold the literal text $_majorver and $version, Version: would expand to $version, and every consumer that asks for a minimum version would be told Lua is absent: tio, for one, asks meson for lua with version: '>=5.1'.
lua$_majorver.pc is a link to lua.pc. lua54 installs lua5.4.pc, and a consumer that names its Lua by version finds this one only through the link: wireplumber is built with -Dsystem-lua-version set to this series and asks pkg-config for lua-X.Y, then luaX.Y. A consumer that tries versioned names before plain lua would otherwise settle on 5.4.
Lua’s headers in /usr/include are this series’. A program that bundles its own Lua, or a 5.4 module, must put its own include directory first; see A bundled header shadowed by the system’s.