User:Daurnimator/Lua package guidelines

From ArchWiki
Jump to navigation Jump to search
Package creation guidelines

CLRCrossEclipseElectronFree PascalGNOMEGoHaskellJavaKDEKernelLispMinGWNode.jsNonfreeOCamlPerlPHPPythonRRubyRustVCSWebWine

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)
build() {
  mkdir -p 5.1 5.2 5.3

  # Build for 5.1
  (cd 5.1; luarocks build --pack-binary-rock --lua-version=5.1 --deps-mode=none ../"foo-$pkgver-1.rockspec")
  # Build for 5.2
  (cd 5.2; luarocks build --pack-binary-rock --lua-version=5.2 --deps-mode=none ../"foo-$pkgver-1.rockspec")
  # Build for 5.3
  (cd 5.3; luarocks build --pack-binary-rock --lua-version=5.3 --deps-mode=none ../"foo-$pkgver-1.rockspec")
}

package_lua51-foo {
  pkgdesc='Foo for Lua 5.1'

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

  # remove luarocks-created root manifest
  rm "$pkgdir/usr/lib/luarocks/rocks-5.1/manifest"
}

package_lua52-foo {
  pkgdesc='Foo for Lua 5.2'

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

  # remove luarocks-created root manifest
  rm "$pkgdir/usr/lib/luarocks/rocks-5.2/manifest"
}

package_lua-foo {
  pkgdesc='Foo for Lua 5.3'

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

  # remove luarocks-created root manifest
  rm "$pkgdir/usr/lib/luarocks/rocks-5.3/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.