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
lua54-luasocket-3.1.0.tar.gz(328.7 KiB)
sha256bf033aeb9e62bcaa8d007df68c119c966418e8c9ef7e4f2d7e96bddeca9cca6e
upstream: https://github.com/lunarmodules/luasocket/archive/refs/tags/v3.1.0.tar.gz
archive copy: sources-3/lang--lua54-luasocket-3.1.0.tar.gz
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:
PLAT=linux— Selects the makefile’s Linux settings, which is also its default.LUAV=$_lv— The Lua series to build for,5.4. It names the install directorieslib/lua/5.4andshare/lua/5.4.LUAPREFIX_linux=/usr— The install prefix on Linux, in place of upstream’s/usr/local. It is passed to the install step as well.LUAINC_linux_base=/usr/include— Where the Lua headers are looked for, without the version: the makefile appends/lua$(LUAV)itself. It takes effect only through upstream’s ownCFLAGS_linux, which the next switch replaces, so the include directory actually used is the one that switch names.CFLAGS_linux="$CFLAGS -I/usr/include/lua$_lv -DLUASOCKET_NODEBUG"— Replaces upstream’s compile line for Linux whole. Upstream’s line comes after anythingMYCFLAGSadds and carries its own-O2 -ggdb3, so flags passed that way could not override it. The replacement carries the tree’sCFLAGS, lua54’s header directory andLUASOCKET_NODEBUG, the define upstream’s line sets by default. The debug build it rules out adds a_DEBUGfield to the module and an elapsed-time value to what each send and receive returns. Upstream’s-fpicis not repeated, because the tree’sCFLAGScarry-fPIC.MYLDFLAGS="$LDFLAGS"— Passes the tree’s linker flags; the makefile puts them after the objects and ahead of its own-O -shared -fpic -o.install-unix— Installs everythinginstalldoes, and also the Unix-onlysocket.unixandsocket.serialmodules.prefix=/usr— The install prefix, which the makefile otherwise derives fromLUAPREFIX_linux.
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.