Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

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

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.

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:

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.