User:Daurnimator/Lua package guidelines

From ArchWiki
Arch package guidelines

32-bitCLRCMakeCrossDKMSEclipseElectronFontFree PascalGNOMEGoHaskellJavaKDEKernelLispMesonMinGWNode.jsNonfreeOCamlPerlPHPPythonRRubyRustShellVCSWebWine

This document covers standards and guidelines on writing PKGBUILDs for Lua software.

Lua software can generally be split into two types: software that embeds Lua (usually applications) and Lua modules (to be used from Lua applications).

Package naming

For Lua modules, the pkgbase should be lua-modulename. Modules should be built for all upstream supported Lua versions greater than 5.1 and published as a split package. The individual packages should be named luaversion-modulename where version is 51, 52 or empty for 5.3.

Installation methods

Rockspec

For modules that have an upstream-supported rockspec file, use luarocks for building the package. This is preferred, as it means that the dependency will be seen by luarocks.

For modules without a rockspec file, consider creating one for them.

Template PKGBUILD

Comment: TODO: luarocks build fetches from internet; how to use already downloaded files? (luarocks make doesn't apply patches or verify checksums)
makedepends=('luarocks'
             # https://github.com/luarocks/luarocks/issues/1275
             'lua51'
             'lua52'
             'lua53'
             'lua')

build() {
  local _version
  for _version in 5.1 5.2 5.3 5.4; do
    mkdir -p "$_version/"
    luarocks make --pack-binary-rock --lua-version="$_version" --deps-mode=none \
      CFLAGS="$CPPFLAGS $CFLAGS -fPIC" \
      LIBFLAG="$LDFLAGS -shared" \
      foo-"$pkgver"-0.rockspec
    mv foo-"$pkgver"-0.*.rock "$_version/"
  done
}

package_lua51-foo() {
  pkgdesc="$pkgdesc for Lua 5.1"

  luarocks install --lua-version=5.1 --tree="$pkgdir/usr/" --deps-mode=none 5.1/*.rock --no-manifest
}

package_lua52-foo() {
  pkgdesc="$pkgdesc for Lua 5.2"

  luarocks install --lua-version=5.2 --tree="$pkgdir/usr/" --deps-mode=none 5.2/*.rock --no-manifest
}

package_lua53-foo() {
  pkgdesc="$pkgdesc for Lua 5.3"

  luarocks install --lua-version=5.3 --tree="$pkgdir/usr/" --deps-mode=none 5.3/*.rock --no-manifest
}

package_lua-foo() {
  pkgdesc="$pkgdesc for Lua 5.4"

  luarocks install --lua-version=5.4 --tree="$pkgdir/usr/" --deps-mode=none 5.4/*.rock --no-manifest
}

Bindings built as part of a larger package

  • Make sure that you compile Lua bindings for all Lua versions supported.
  • Create a split package so that Lua bindings can be installed independently from the library itself.