diff --git a/lang/lua/luaexpat/Makefile b/lang/lua/luaexpat/Makefile index ef16eb81b2d75d..e5cad11aff1e6b 100644 --- a/lang/lua/luaexpat/Makefile +++ b/lang/lua/luaexpat/Makefile @@ -1,4 +1,4 @@ -# +# # Copyright (C) 2009 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luaexpat PKG_VERSION:=1.5.2 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE_PROTO:=git PKG_SOURCE_VERSION:=$(PKG_VERSION) @@ -22,19 +22,46 @@ PKG_CPE_ID:=cpe:/a:matthewwild:luaexpat include $(INCLUDE_DIR)/package.mk -define Package/luaexpat +define Package/luaexpat/default SUBMENU:=Lua SECTION:=lang CATEGORY:=Languages TITLE:=LuaExpat URL:=https://lunarmodules.github.io/luaexpat/ MAINTAINER:=W. Michael Petullo +endef + +define Package/luaexpat + $(Package/luaexpat/default) DEPENDS:=+lua +libexpat + VARIANT:=lua-51 + DEFAULT_VARIANT:=1 endef -define Package/luaexpat/description +define Package/luaexpat5.4 + $(Package/luaexpat/default) + TITLE+= (Lua 5.4) + DEPENDS:=+lua5.4 +libexpat + VARIANT:=lua-54 +endef + +define Package/luaexpat/default/description LuaExpat is a SAX XML parser based on the Expat library. endef +Package/luaexpat/description = $(Package/luaexpat/default/description) +Package/luaexpat5.4/description = $(Package/luaexpat/default/description) + +ifeq ($(BUILD_VARIANT),lua-51) + LUA_INCDIR:=$(STAGING_DIR)/usr/include + LUA_LIBNAME:=lua + LUA_INSTALL_DIR:=/usr/lib/lua +endif + +ifeq ($(BUILD_VARIANT),lua-54) + LUA_INCDIR:=$(STAGING_DIR)/usr/include/lua5.4 + LUA_LIBNAME:=lua5.4 + LUA_INSTALL_DIR:=/usr/lib/lua/5.4 +endif define Build/Configure endef @@ -43,10 +70,10 @@ define Build/Compile $(CP) files/compat-5.1r5 $(PKG_BUILD_DIR)/compat-5.1r5 $(MAKE) -C $(PKG_BUILD_DIR) \ EXPAT_INC="-I$(STAGING_DIR)/usr/include/" \ - LUA_INC="-I$(STAGING_DIR)/usr/include/" \ + LUA_INC="-I$(LUA_INCDIR)" \ LUA_LIBDIR="$(STAGING_DIR)/usr/lib/" \ COMPAT_DIR="$(PKG_BUILD_DIR)/compat-5.1r5" \ - LDFLAGS="-shared $(TARGET_LDFLAGS)" \ + LDFLAGS="-shared $(TARGET_LDFLAGS) -l$(LUA_LIBNAME)" \ CC="$(TARGET_CC) $(TARGET_CFLAGS) $(FPIC) -std=c99" \ LD="$(TARGET_CROSS)ld -shared" endef @@ -58,4 +85,12 @@ define Package/luaexpat/install $(INSTALL_DATA) $(PKG_BUILD_DIR)/src/lxp/lom.lua $(1)/usr/lib/lua/lxp endef +define Package/luaexpat5.4/install + $(INSTALL_DIR) $(1)/usr/lib/lua/5.4 + $(INSTALL_DATA) $(PKG_BUILD_DIR)/src/lxp.so $(1)/usr/lib/lua/5.4/lxp.so + $(INSTALL_DIR) $(1)/usr/lib/lua/5.4/lxp + $(INSTALL_DATA) $(PKG_BUILD_DIR)/src/lxp/lom.lua $(1)/usr/lib/lua/5.4/lxp +endef + $(eval $(call BuildPackage,luaexpat)) +$(eval $(call BuildPackage,luaexpat5.4)) diff --git a/lang/lua/luafilesystem/Makefile b/lang/lua/luafilesystem/Makefile index bfd56146af520a..99098828f54902 100644 --- a/lang/lua/luafilesystem/Makefile +++ b/lang/lua/luafilesystem/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luafilesystem PKG_VERSION:=1.9.0 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_LICENSE:=MIT PKG_MIRROR_HASH:=a64d8299c7c875bd2183f82f9a71f6fcc7610ee7377add0b6069fea3d7355073 @@ -19,43 +19,70 @@ PKG_SOURCE_PROTO:=git include $(INCLUDE_DIR)/package.mk -define Package/luafilesystem +define Package/luafilesystem/default SUBMENU:=Lua SECTION:=lang CATEGORY:=Languages TITLE:=LuaFileSystem URL:=https://lunarmodules.github.io/luafilesystem/ MAINTAINER:=W. Michael Petullo +endef + +define Package/luafilesystem + $(Package/luafilesystem/default) DEPENDS:=+liblua + VARIANT:=lua-51 + DEFAULT_VARIANT:=1 +endef + +define Package/luafilesystem5.4 + $(Package/luafilesystem/default) + TITLE+= (Lua 5.4) + DEPENDS:=+liblua5.4 + VARIANT:=lua-54 endef -define Package/luafilesystem/description +define Package/luafilesystem/default/description This package contains the LuaFileSystem library, a set of portable functions for directory creation, listing and deletion and for file locking. endef +Package/luafilesystem/description = $(Package/luafilesystem/default/description) +Package/luafilesystem5.4/description = $(Package/luafilesystem/default/description) + +ifeq ($(BUILD_VARIANT),lua-51) + LUA_VERSION:=5.1 + LUA_LIBNAME:=lua + LUA_INCDIR:=$(STAGING_DIR)/usr/include + LUA_INSTALL_DIR:=/usr/lib/lua +endif + +ifeq ($(BUILD_VARIANT),lua-54) + LUA_VERSION:=5.4 + LUA_LIBNAME:=lua5.4 + LUA_INCDIR:=$(STAGING_DIR)/usr/include/lua5.4 + LUA_INSTALL_DIR:=/usr/lib/lua/5.4 +endif define Build/Configure endef -TARGET_CFLAGS += $(FPIC) $(TARGET_CPPFLAGS) - -TARGET_LDFLAGS += -llua +TARGET_CFLAGS += $(FPIC) $(TARGET_CPPFLAGS) -I$(LUA_INCDIR) define Build/Compile $(MAKE) -C $(PKG_BUILD_DIR) \ $(TARGET_CONFIGURE_OPTS) \ CFLAGS="$(TARGET_CFLAGS) -std=gnu99" \ - LDFLAGS="$(TARGET_LDFLAGS)" + LDFLAGS="$(TARGET_LDFLAGS) -l$(LUA_LIBNAME)" $(TARGET_CROSS)ar r $(PKG_BUILD_DIR)/src/luafilesystem.a $(PKG_BUILD_DIR)/src/lfs.o endef define Build/InstallDev $(INSTALL_DIR) $(STAGING_DIR)/usr/include - $(INSTALL_DIR) $(STAGING_DIR)/usr/lib/lua + $(INSTALL_DIR) $(STAGING_DIR)$(LUA_INSTALL_DIR) $(INSTALL_DATA) $(PKG_BUILD_DIR)/src/lfs.h $(STAGING_DIR)/usr/include - $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/lfs.so $(STAGING_DIR)/usr/lib/lua - $(INSTALL_DATA) $(PKG_BUILD_DIR)/src/luafilesystem.a $(STAGING_DIR)/usr/lib/lua + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/lfs.so $(STAGING_DIR)$(LUA_INSTALL_DIR) + $(INSTALL_DATA) $(PKG_BUILD_DIR)/src/luafilesystem.a $(STAGING_DIR)$(LUA_INSTALL_DIR) endef define Package/luafilesystem/install @@ -63,4 +90,10 @@ define Package/luafilesystem/install $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/lfs.so $(1)/usr/lib/lua/lfs.so endef +define Package/luafilesystem5.4/install + $(INSTALL_DIR) $(1)/usr/lib/lua/5.4 + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/lfs.so $(1)/usr/lib/lua/5.4/lfs.so +endef + $(eval $(call BuildPackage,luafilesystem)) +$(eval $(call BuildPackage,luafilesystem5.4)) diff --git a/lang/lua/luasec/Makefile b/lang/lua/luasec/Makefile index 9d60604c6b3080..6da10db2c06cf4 100644 --- a/lang/lua/luasec/Makefile +++ b/lang/lua/luasec/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luasec PKG_VERSION:=1.3.2 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/brunoos/luasec/tar.gz/v$(PKG_VERSION)? @@ -24,31 +24,58 @@ PKG_INSTALL:=1 include $(INCLUDE_DIR)/package.mk -define Package/luasec +define Package/luasec/default SUBMENU:=Lua SECTION:=lang CATEGORY:=Languages TITLE:=LuaSec URL:=https://github.com/brunoos/luasec +endef + +define Package/luasec + $(Package/luasec/default) DEPENDS:=+lua +libopenssl +luasocket + VARIANT:=lua-51 + DEFAULT_VARIANT:=1 +endef + +define Package/luasec5.4 + $(Package/luasec/default) + TITLE+= (Lua 5.4) + DEPENDS:=+lua5.4 +libopenssl +luasocket5.4 + VARIANT:=lua-54 endef -define Package/luasec/description +define Package/luasec/default/description LuaSec is a binding for OpenSSL library to provide TLS/SSL communication. endef +Package/luasec/description = $(Package/luasec/default/description) +Package/luasec5.4/description = $(Package/luasec/default/description) + +ifeq ($(BUILD_VARIANT),lua-51) + LUA_INCDIR:=$(STAGING_DIR)/usr/include + LUA_LIBNAME:=lua + LUA_INSTALL_DIR:=/usr/lib/lua +endif + +ifeq ($(BUILD_VARIANT),lua-54) + LUA_INCDIR:=$(STAGING_DIR)/usr/include/lua5.4 + LUA_LIBNAME:=lua5.4 + LUA_INSTALL_DIR:=/usr/lib/lua/5.4 +endif define Build/Configure endef -TARGET_CFLAGS += $(FPIC) -TARGET_LDFLAGS += $(FPIC) +TARGET_CFLAGS += $(FPIC) -I$(LUA_INCDIR) +TARGET_LDFLAGS += $(FPIC) -l$(LUA_LIBNAME) MAKE_FLAGS += \ LD="$(TARGET_CC)" \ INC_PATH="" \ LIB_PATH="" \ - LUACPATH="$(PKG_INSTALL_DIR)/usr/lib/lua" \ - LUAPATH="$(PKG_INSTALL_DIR)/usr/lib/lua" + LUACPATH="$(PKG_INSTALL_DIR)$(LUA_INSTALL_DIR)" \ + LUAPATH="$(PKG_INSTALL_DIR)$(LUA_INSTALL_DIR)" define Build/Compile $(call Build/Compile/Default,linux) @@ -62,4 +89,13 @@ define Package/luasec/install $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/lua/ssl/https.lua $(1)/usr/lib/lua/ssl/ endef +define Package/luasec5.4/install + $(INSTALL_DIR) $(1)/usr/lib/lua/5.4 + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/lua/5.4/ssl.so $(1)/usr/lib/lua/5.4/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/lua/5.4/ssl.lua $(1)/usr/lib/lua/5.4/ + $(INSTALL_DIR) $(1)/usr/lib/lua/5.4/ssl + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/lua/5.4/ssl/https.lua $(1)/usr/lib/lua/5.4/ssl/ +endef + $(eval $(call BuildPackage,luasec)) +$(eval $(call BuildPackage,luasec5.4)) diff --git a/lang/lua/luasocket/Makefile b/lang/lua/luasocket/Makefile index 973192ec78d692..41455ffff19e30 100644 --- a/lang/lua/luasocket/Makefile +++ b/lang/lua/luasocket/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luasocket PKG_VERSION:=3.1.0 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE_PROTO:=git PKG_SOURCE_VERSION:=v$(PKG_VERSION) @@ -44,6 +44,13 @@ define Package/luasocket5.3 VARIANT:=lua-53 endef +define Package/luasocket5.4 + $(Package/luasocket/default) + TITLE:=LuaSocket 5.4 + DEPENDS:=+liblua5.4 + VARIANT:=lua-54 +endef + ifeq ($(BUILD_VARIANT),lua-51) LUA_VERSION=5.1 endif @@ -52,6 +59,10 @@ ifeq ($(BUILD_VARIANT),lua-53) LUA_VERSION=5.3 endif +ifeq ($(BUILD_VARIANT),lua-54) + LUA_VERSION=5.4 +endif + define Package/luasocket/default/description LuaSocket is the most comprehensive networking support @@ -60,6 +71,7 @@ define Package/luasocket/default/description endef Package/luasocket/description = $(Package/luasocket/default/description) Package/luasocket5.3/description = $(Package/luasocket/default/description) +Package/luasocket5.4/description = $(Package/luasocket/default/description) define Build/Configure endef @@ -95,6 +107,14 @@ define Package/luasocket5.3/install install endef +define Package/luasocket5.4/install + $(MAKE) -C $(PKG_BUILD_DIR)/src \ + DESTDIR="$(1)" \ + LUAV=$(LUA_VERSION) \ + install +endef + $(eval $(call BuildPackage,luasocket)) $(eval $(call BuildPackage,luasocket5.3)) +$(eval $(call BuildPackage,luasocket5.4)) diff --git a/net/prosody/Makefile b/net/prosody/Makefile index cc6aee54166644..236588a1e05e90 100644 --- a/net/prosody/Makefile +++ b/net/prosody/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=prosody -PKG_VERSION:=0.12.6 +PKG_VERSION:=13.0.6 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://prosody.im/downloads/source -PKG_HASH:=e06db3cfa8811d0b9fa7713a3b430189f62a1f90e6a4940771b1e16ce64e8e44 +PKG_HASH:=ec696f9cf562c3af4a04b07d3fb36a1cedcc4e69a392fddcfc524bc67d93050f PKG_MAINTAINER:=Thomas Heil PKG_LICENSE:=MIT/X11 @@ -21,7 +21,7 @@ PKG_CPE_ID:=cpe:/a:prosody:prosody PKG_INSTALL:=1 PKG_BUILD_PARALLEL:=1 -PKG_BUILD_DEPENDS:=lua/host +PKG_BUILD_DEPENDS:=lua5.4/host include $(INCLUDE_DIR)/package.mk @@ -29,23 +29,24 @@ define Package/prosody SECTION:=net CATEGORY:=Network SUBMENU:=Instant Messaging - DEPENDS:=+luafilesystem +libidn +luaexpat +luasec +libopenssl +libidn +liblua +luabitop + DEPENDS:=+libidn +libopenssl +liblua5.4 +lua5.4 \ + +luafilesystem5.4 +luaexpat5.4 +luasec5.4 +luasocket5.4 TITLE:=XMPP server URL:=https://prosody.im/ USERID:=prosody=54:prosody=54 endef define Package/prosody/description - Prosody is an exciting new server for Jabber/XMPP - written in Lua. It aims to be easy to use, and light - on resources + Prosody is a modern XMPP/Jabber communication server, written in Lua. + It aims to be easy to set up and configure, and efficient with system + resources. endef define Package/prosody/conffiles /etc/prosody/prosody.cfg.lua endef -TARGET_CFLAGS += $(FPIC) +TARGET_CFLAGS += $(FPIC) -I$(STAGING_DIR)/usr/include/lua5.4 TARGET_LDFLAGS += -shared MAKE_FLAGS += LD="$(TARGET_CC)" TARGET="../util/" @@ -54,9 +55,12 @@ define Build/Configure # this is *NOT* GNU autoconf stuff (cd $(PKG_BUILD_DIR); ./configure \ --prefix=/usr \ + --ostype=linux \ + --lua-version=5.4 \ --with-lua="$(STAGING_DIR_HOSTPKG)" \ - --with-lua-include="$(STAGING_DIR)/usr/include" \ + --with-lua-include="$(STAGING_DIR)/usr/include/lua5.4" \ --with-lua-lib="$(STAGING_DIR)/usr/lib" \ + --runwith=lua5.4 \ --idn-library=idn \ --cflags="$(TARGET_CFLAGS)" \ --ldflags="$(TARGET_LDFLAGS)" \ @@ -77,10 +81,12 @@ define Package/prosody/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/prosody{,ctl} $(1)/usr/bin/ $(INSTALL_DIR) $(1)/usr/lib/prosody $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/prosody/prosody.version $(1)/usr/lib/prosody/ + # maps the 13.x "prosody.*" requires onto the installed layout + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/loader.lua $(1)/usr/lib/prosody/ $(INSTALL_DIR) $(1)/usr/lib/prosody/core $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/core/*.lua $(1)/usr/lib/prosody/core/ - #$(INSTALL_DIR) $(1)/usr/lib/prosody/fallbacks - #$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/fallbacks/*.lua $(1)/usr/lib/prosody/fallbacks/ + $(INSTALL_DIR) $(1)/usr/lib/prosody/fallbacks + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/fallbacks/*.lua $(1)/usr/lib/prosody/fallbacks/ $(INSTALL_DIR) $(1)/usr/lib/prosody/modules $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/modules/*.lua $(1)/usr/lib/prosody/modules/ $(INSTALL_DIR) $(1)/usr/lib/prosody/modules/adhoc @@ -91,8 +97,8 @@ define Package/prosody/install $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/modules/mod_pubsub/*.lua $(1)/usr/lib/prosody/modules/mod_pubsub/ $(INSTALL_DIR) $(1)/usr/lib/prosody/modules/mod_mam $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/modules/mod_mam/*.lua $(1)/usr/lib/prosody/modules/mod_mam/ - #$(INSTALL_DIR) $(1)/usr/lib/prosody/modules/storage - #$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/modules/storage/*.lua $(1)/usr/lib/prosody/modules/storage/ + $(INSTALL_DIR) $(1)/usr/lib/prosody/modules/mod_debug_stanzas + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/modules/mod_debug_stanzas/*.lua $(1)/usr/lib/prosody/modules/mod_debug_stanzas/ $(INSTALL_DIR) $(1)/usr/lib/prosody/net $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/net/*.lua $(1)/usr/lib/prosody/net/ $(INSTALL_DIR) $(1)/usr/lib/prosody/net/http @@ -110,23 +116,6 @@ define Package/prosody/install $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/util/human/*.lua $(1)/usr/lib/prosody/util/human/ $(INSTALL_DIR) $(1)/usr/lib/prosody/util/prosodyctl $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/prosody/util/prosodyctl/*.lua $(1)/usr/lib/prosody/util/prosodyctl/ - #$(CP) $(PKG_INSTALL_DIR)/usr/lib/prosody/util/sasl/*.so $(1)/usr/lib/prosody/util/sasl/ -endef - -define Package/prosody/postinst -#!/bin/sh -[ -n "$${IPKG_INSTROOT}" ] || { - echo "Fixing lua with paxctl if needed!!!" - [ -f /sbin/paxctl ] && { - paxctl -v /usr/bin/ > /dev/null 2>&1 - [ $$? -ne 0 ] && { - cp /usr/bin/lua /tmp - paxctl -c -m /tmp/lua > /dev/null 2>&1 - cp -f /tmp/lua /usr/bin/lua - } - } - exit 0 -} endef $(eval $(call BuildPackage,prosody)) diff --git a/net/prosody/test.sh b/net/prosody/test.sh index b88ea7f1c47b2e..0527e6aee47715 100644 --- a/net/prosody/test.sh +++ b/net/prosody/test.sh @@ -1,7 +1,139 @@ #!/bin/sh +# +# Functional smoke tests for the prosody package. +# +# Everything below drives the prosody Lua stack in-process. The XMPP daemon +# itself is never started: it would block forever under QEMU emulation, and +# prosodyctl already exercises the same interpreter, util library closure, +# plugin loader and config parser. + +set -e + +PROSODY_LIB="/usr/lib/prosody" +PROSODY_DATA="/etc/prosody/data" +TEST_USER="citest" +TEST_PASS="s3cr3t-ci-passphrase" case "$1" in - prosody) - grep -qF "$2" /usr/lib/prosody/prosody.version || exit 1 - ;; +prosody) + # Verify the installed version file matches the apk version arg the + # runner passes, so a stale .apk from an earlier batch fails fast. + grep -qF "$2" "$PROSODY_LIB/prosody.version" + + # loader.lua installs the "prosody.*" -> "*" module searcher that every + # require() in 13.x goes through. It is the first thing prosodyctl looks + # for, and the package is dead on arrival if it was not installed. + test -f "$PROSODY_LIB/loader.lua" + + # `prosodyctl about` prints the version, dependency and module lists, + # exercising the Lua bootstrap end-to-end. Assert it picked up Lua 5.4: + # the wrapper falls back to /usr/bin/lua (5.1) if --runwith is lost, and + # prosody 13 refuses to run on anything older than 5.2. + prosodyctl about > /tmp/prosody-about.txt + grep -q "Lua 5.4" /tmp/prosody-about.txt + + # `prosodyctl check config` parses /etc/prosody/prosody.cfg.lua against + # the full config schema; upstream documents this as the way to validate + # a deployment before starting it. + prosodyctl check config + + # Register and remove a local account on the sample VirtualHost. This is + # the only path that drives util.datamanager storage together with the + # internal_hashed SCRAM derivation, and it must never leave the cleartext + # password on disk. + prosodyctl register "$TEST_USER" localhost "$TEST_PASS" + test -f "$PROSODY_DATA/localhost/accounts/$TEST_USER.dat" + if grep -qF "$TEST_PASS" "$PROSODY_DATA/localhost/accounts/$TEST_USER.dat"; then + echo "test.sh: cleartext password stored, internal_hashed is not hashing" >&2 + exit 1 + fi + prosodyctl unregister "$TEST_USER" localhost + test ! -f "$PROSODY_DATA/localhost/accounts/$TEST_USER.dat" + + # Exercise the compiled util/*.so extensions and the external Lua rocks + # the package depends on. These are the arch-specific artifacts, so a + # bad cross-build or a missing library shows up here and nowhere else. + lua5.4 - "$PROSODY_LIB" <<-'EOF' + local lib = ... + + package.path = lib .. "/?.lua;" .. package.path + package.cpath = lib .. "/?.so;" .. package.cpath + dofile(lib .. "/loader.lua") + + -- Every C extension must load. They are listed explicitly rather than + -- globbed so that a silently dropped .so fails instead of shrinking + -- the test. + for _, m in ipairs({ + "compat", "crypto", "encodings", "hashes", "net", "poll", + "pposix", "ringbuffer", "signal", "strbitop", "struct", + "table", "time", + }) do + local so = lib .. "/util/" .. m .. ".so" + assert(io.open(so, "r"), "missing " .. so):close() + assert(package.loadlib(so, "luaopen_prosody_util_" .. m), + "cannot load " .. so)() + end + + -- util.hashes is linked against libopenssl; check a published SHA-256 + -- vector and an HMAC rather than just that the module loads. + local hashes = require "prosody.util.hashes" + assert(hashes.sha256("abc", true) == + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") + assert(#hashes.hmac_sha256("key", "message") == 32) + assert(#hashes.pbkdf2_hmac_sha256("password", "salt", 100) == 32) + + -- util.crypto is the other libopenssl consumer; a generated Ed25519 key + -- must round-trip through sign/verify and reject a tampered message. + local crypto = require "prosody.util.crypto" + local key = crypto.generate_ed25519_keypair() + local sig = crypto.ed25519_sign(key, "hello") + assert(crypto.ed25519_verify(key, "hello", sig)) + assert(not crypto.ed25519_verify(key, "hell0", sig)) + + -- util.encodings is linked against libidn; IDNA and the stringprep + -- profiles are what JID handling is built on. + local encodings = require "prosody.util.encodings" + assert(encodings.idna.to_ascii("bücher.example") == "xn--bcher-kva.example") + assert(encodings.stringprep.nodeprep("UsEr") == "user") + assert(encodings.stringprep.nameprep("Example.COM") == "example.com") + assert(encodings.base64.decode(encodings.base64.encode("prosody")) == "prosody") + + -- util.jid layers on both of the above; a mixed-case JID must normalise + -- and split into its three parts. + local jid = require "prosody.util.jid" + assert(jid.prep("UsEr@Example.COM/Resource") == "user@example.com/Resource") + local node, host, resource = jid.split("user@example.com/phone") + assert(node == "user" and host == "example.com" and resource == "phone") + assert(jid.bare("user@example.com/phone") == "user@example.com") + + -- util.xml parses via luaexpat, so this covers the luaexpat5.4 runtime + -- dependency as well as stanza construction and serialisation. + local xml = require "prosody.util.xml" + local stanza = xml.parse( + "hi") + assert(stanza.attr.to == "user@example.com") + assert(stanza:get_child_text("body") == "hi") + + local st = require "prosody.util.stanza" + local iq = st.iq({ type = "get", id = "1" }):tag("ping", { + xmlns = "urn:xmpp:ping", + }) + assert(tostring(iq):find("urn:xmpp:ping", 1, true)) + + -- The remaining runtime dependencies are plain Lua rocks that prosody + -- require()s at startup; make sure each one is actually installed. + assert(require "lfs".attributes(lib, "mode") == "directory") + assert(require "socket".gettime() > 0) + local ssl = require "ssl" + assert(ssl.context or require "ssl.context") + + print("prosody lua stack OK") + EOF + ;; + +*) + echo "test.sh: unknown subpackage '$1' — refusing to silently pass" >&2 + echo "test.sh: update net/prosody/test.sh to cover this subpackage" >&2 + exit 1 + ;; esac