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

44.3. lua54-luasocket-3.1.0

TCP, UDP and DNS for Lua 5.4 — Prosody's transport

Version 3.1.0, 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), 106 of 127 in build order
Licence MIT
Homepage https://github.com/lunarmodules/luasocket
Build time 0.1 SBU
Installed size 269.7 KiB in 14 files
Recipe ports/core/lang/lua54-luasocket/kpkgbuild

About

LuaSocket gives Lua TCP, UDP and DNS, and on Unix also local sockets and serial lines, plus the mime module and pure-Lua helpers for HTTP, FTP, SMTP and URLs. This port builds it for lua54 alone: it is the network layer of prosody, the XMPP server, and lua54-luasec adds TLS on top of it. The C modules go to /usr/lib/lua/5.4/socket and /usr/lib/lua/5.4/mime, the Lua ones to /usr/share/lua/5.4, the two directories lua54’s interpreter searches.

LuaSocket has no configure step. Its makefile defaults to Lua 5.1 and a /usr/local prefix, and every setting is a make variable, so the recipe passes them all on the command line. A make VAR=value argument overrides even a plain assignment in the makefile, such as CFLAGS_linux; an exported variable overrides only the ?= defaults.

Why it is in KDOS

The comment above the 4 ports from lua54-luasocket to lua54-luafilesystem in script/phases/30_foundation/packages.txt:

The four modules Prosody will not start without: a transport, TLS over it, an XML parser (XMPP is XML on the wire) and stat/mkdir/readdir.

Sources

Dependencies

Depends on: lua54.

Required by (2): lua54-luasec, prosody.

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-luasocket'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/lang/lua54-luasocket.

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-luasocket
echo 'bf033aeb9e62bcaa8d007df68c119c966418e8c9ef7e4f2d7e96bddeca9cca6e  lua54-luasocket-3.1.0.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-luasocket
SRC=$SRC_ROOT/lua54-luasocket-3.1.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf lua54-luasocket-3.1.0.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 _lv and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

make PLAT=linux LUAV=$_lv \
     LUAPREFIX_linux=/usr \
     LUAINC_linux_base=/usr/include \
     CFLAGS_linux="$CFLAGS -I/usr/include/lua$_lv -DLUASOCKET_NODEBUG" \
     MYLDFLAGS="$LDFLAGS"
make install-unix DESTDIR=$PKG PLAT=linux LUAV=$_lv \
     LUAPREFIX_linux=/usr \
     prefix=/usr

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/lua54-luasocket, 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-luasocket-3.1.0-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-luasocket, and runs the triggers its paths call for.

Contents

Installed directories: /usr/lib/lua/5.4/mime, /usr/lib/lua/5.4/socket, /usr/share/licenses/lua54-luasocket, /usr/share/lua/5.4/socket.