From 587c2382b0d7940927a0f6b7b87809eca890f9b7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 19 Jun 2019 19:16:09 +0200 Subject: util.dependencies: Increase Lua version to warn about to 5.4 No significant problems have been encountered with Lua 5.3 itself, so apart from some odd problems in LuaExpat it seems about time to declare it ready. --- util/dependencies.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/dependencies.lua') diff --git a/util/dependencies.lua b/util/dependencies.lua index 7c7b938e..84e2dd5c 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -140,7 +140,7 @@ local function check_dependencies() end local function log_warnings() - if _VERSION > "Lua 5.2" then + if _VERSION > "Lua 5.3" then prosody.log("warn", "Support for %s is experimental, please report any issues", _VERSION); end local ssl = softreq"ssl"; -- cgit v1.2.3 From 2848e38b7e8a03b26b0aaab6e363403a19298abd Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 9 Nov 2019 13:58:25 +0100 Subject: util.dependencies: Avoid missing bitop false positive on Lua 5.4 --- util/dependencies.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/dependencies.lua') diff --git a/util/dependencies.lua b/util/dependencies.lua index 84e2dd5c..22b66d7c 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -90,7 +90,7 @@ local function check_dependencies() }, "SSL/TLS support will not be available"); end - local bit = _G.bit32 or softreq"bit"; + local bit = softreq"util.bitcompat"; if not bit then missingdep("lua-bitops", { -- cgit v1.2.3 From f8e36355eef43f02211b3e7cdb501c3ed3d36b8d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 23 Dec 2019 21:15:01 +0100 Subject: util.dependencies: Pass require error to error formatting function For future use there. Silences luacheck warnings about unused 'err' --- util/dependencies.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'util/dependencies.lua') diff --git a/util/dependencies.lua b/util/dependencies.lua index 22b66d7c..ede8c6ac 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -13,7 +13,8 @@ if not softreq "luarocks.loader" then -- LuaRocks 2.x softreq "luarocks.require"; -- LuaRocks <1.x end -local function missingdep(name, sources, msg) +local function missingdep(name, sources, msg, err) -- luacheck: ignore err + -- TODO print something about the underlying error, useful for debugging print(""); print("**************************"); print("Prosody was unable to find "..tostring(name)); @@ -44,25 +45,25 @@ local function check_dependencies() local fatal; - local lxp = softreq "lxp" + local lxp, err = softreq "lxp" if not lxp then missingdep("luaexpat", { ["Debian/Ubuntu"] = "sudo apt-get install lua-expat"; ["luarocks"] = "luarocks install luaexpat"; ["Source"] = "http://matthewwild.co.uk/projects/luaexpat/"; - }); + }, nil, err); fatal = true; end - local socket = softreq "socket" + local socket, err = softreq "socket" if not socket then missingdep("luasocket", { ["Debian/Ubuntu"] = "sudo apt-get install lua-socket"; ["luarocks"] = "luarocks install luasocket"; ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/"; - }); + }, nil, err); fatal = true; elseif not socket.tcp4 then -- COMPAT LuaSocket before being IP-version agnostic @@ -76,28 +77,28 @@ local function check_dependencies() ["luarocks"] = "luarocks install luafilesystem"; ["Debian/Ubuntu"] = "sudo apt-get install lua-filesystem"; ["Source"] = "http://www.keplerproject.org/luafilesystem/"; - }); + }, nil, err); fatal = true; end - local ssl = softreq "ssl" + local ssl, err = softreq "ssl" if not ssl then missingdep("LuaSec", { ["Debian/Ubuntu"] = "sudo apt-get install lua-sec"; ["luarocks"] = "luarocks install luasec"; ["Source"] = "https://github.com/brunoos/luasec"; - }, "SSL/TLS support will not be available"); + }, "SSL/TLS support will not be available", err); end - local bit = softreq"util.bitcompat"; + local bit, err = softreq"util.bitcompat"; if not bit then missingdep("lua-bitops", { ["Debian/Ubuntu"] = "sudo apt-get install lua-bitop"; ["luarocks"] = "luarocks install luabitop"; ["Source"] = "http://bitop.luajit.org/"; - }, "WebSocket support will not be available"); + }, "WebSocket support will not be available", err); end local encodings, err = softreq "util.encodings" -- cgit v1.2.3 From bec20ff0b44be3bfc34fbb282b43e52cf178cd3d Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 4 Jun 2020 17:30:44 +0100 Subject: util.dependencies: Use util.human.io.table to replace custom layout code --- util/dependencies.lua | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'util/dependencies.lua') diff --git a/util/dependencies.lua b/util/dependencies.lua index ede8c6ac..b53e385b 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -7,6 +7,7 @@ -- local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end +local platform_table = require "util.human.io".table({ { width = 15, align = "right" }, { width = "100%" } }); -- Required to be able to find packages installed with luarocks if not softreq "luarocks.loader" then -- LuaRocks 2.x @@ -20,12 +21,8 @@ local function missingdep(name, sources, msg, err) -- luacheck: ignore err print("Prosody was unable to find "..tostring(name)); print("This package can be obtained in the following ways:"); print(""); - local longest_platform = 0; - for platform in pairs(sources) do - longest_platform = math.max(longest_platform, #platform); - end - for platform, source in pairs(sources) do - print("", platform..":"..(" "):rep(4+longest_platform-#platform)..source); + for _, row in ipairs(sources) do + print(platform_table(row)); end print(""); print(msg or (name.." is required for Prosody to run, so we will now exit.")); @@ -49,9 +46,9 @@ local function check_dependencies() if not lxp then missingdep("luaexpat", { - ["Debian/Ubuntu"] = "sudo apt-get install lua-expat"; - ["luarocks"] = "luarocks install luaexpat"; - ["Source"] = "http://matthewwild.co.uk/projects/luaexpat/"; + { "Debian/Ubuntu", "sudo apt-get install lua-expat" }; + { "luarocks", "luarocks install luaexpat" }; + { "Source", "http://matthewwild.co.uk/projects/luaexpat/" }; }, nil, err); fatal = true; end @@ -60,9 +57,9 @@ local function check_dependencies() if not socket then missingdep("luasocket", { - ["Debian/Ubuntu"] = "sudo apt-get install lua-socket"; - ["luarocks"] = "luarocks install luasocket"; - ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/"; + { "Debian/Ubuntu", "sudo apt-get install lua-socket" }; + { "luarocks", "luarocks install luasocket" }; + { "Source", "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/" }; }, nil, err); fatal = true; elseif not socket.tcp4 then @@ -74,9 +71,9 @@ local function check_dependencies() local lfs, err = softreq "lfs" if not lfs then missingdep("luafilesystem", { - ["luarocks"] = "luarocks install luafilesystem"; - ["Debian/Ubuntu"] = "sudo apt-get install lua-filesystem"; - ["Source"] = "http://www.keplerproject.org/luafilesystem/"; + { "luarocks", "luarocks install luafilesystem" }; + { "Debian/Ubuntu", "sudo apt-get install lua-filesystem" }; + { "Source", "http://www.keplerproject.org/luafilesystem/" }; }, nil, err); fatal = true; end @@ -85,9 +82,9 @@ local function check_dependencies() if not ssl then missingdep("LuaSec", { - ["Debian/Ubuntu"] = "sudo apt-get install lua-sec"; - ["luarocks"] = "luarocks install luasec"; - ["Source"] = "https://github.com/brunoos/luasec"; + { "Debian/Ubuntu", "sudo apt-get install lua-sec" }; + { "luarocks", "luarocks install luasec" }; + { "Source", "https://github.com/brunoos/luasec" }; }, "SSL/TLS support will not be available", err); end @@ -95,9 +92,9 @@ local function check_dependencies() if not bit then missingdep("lua-bitops", { - ["Debian/Ubuntu"] = "sudo apt-get install lua-bitop"; - ["luarocks"] = "luarocks install luabitop"; - ["Source"] = "http://bitop.luajit.org/"; + { "Debian/Ubuntu", "sudo apt-get install lua-bitop" }; + { "luarocks", "luarocks install luabitop" }; + { "Source", "http://bitop.luajit.org/" }; }, "WebSocket support will not be available", err); end @@ -105,8 +102,8 @@ local function check_dependencies() if not encodings then if err:match("module '[^']*' not found") then missingdep("util.encodings", { - ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/"; - ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so"; + { "Windows", "Make sure you have encodings.dll from the Prosody distribution in util/" }; + { "GNU/Linux", "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so" }; }); else print "***********************************" @@ -123,8 +120,8 @@ local function check_dependencies() if not hashes then if err:match("module '[^']*' not found") then missingdep("util.hashes", { - ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/"; - ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so"; + { "Windows", "Make sure you have hashes.dll from the Prosody distribution in util/" }; + { "GNU/Linux", "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so" }; }); else print "***********************************" -- cgit v1.2.3 From 57253b7f87f70ed3e9711c931b03aa650b128d72 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 25 Jun 2020 17:26:21 +0200 Subject: util.dependencies: Add awareness of luaunbound --- util/dependencies.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'util/dependencies.lua') diff --git a/util/dependencies.lua b/util/dependencies.lua index b53e385b..b76f7ab1 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -98,6 +98,14 @@ local function check_dependencies() }, "WebSocket support will not be available", err); end + local unbound, err = softreq"lunbound"; + if not unbound then + missingdep("lua-unbound", { + { "luarocks", "luarocks install luaunbound" }; + { "Source", "https://www.zash.se/luaunbound.html" }; + }, "Old DNS resolver library will be used", err); + end + local encodings, err = softreq "util.encodings" if not encodings then if err:match("module '[^']*' not found") then -- cgit v1.2.3 From c98a6d205e85ef1a580cd95301af9f3deddd3777 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 25 Jun 2020 17:41:07 +0200 Subject: util.dependencies: Prefer net.unbound over net.adns --- util/dependencies.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'util/dependencies.lua') diff --git a/util/dependencies.lua b/util/dependencies.lua index b76f7ab1..56a04736 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -104,6 +104,11 @@ local function check_dependencies() { "luarocks", "luarocks install luaunbound" }; { "Source", "https://www.zash.se/luaunbound.html" }; }, "Old DNS resolver library will be used", err); + else + package.preload["net.adns"] = function () + local ub = require "net.unbound"; + return ub; + end end local encodings, err = softreq "util.encodings" -- cgit v1.2.3 From 8c73ea0b2286fed2d1a91333c8d92dab247fd568 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 27 Jun 2020 14:25:57 +0200 Subject: util.dependencies: Tone down lua-unbound dependency for now At least until packages are available Wording from MattJ --- util/dependencies.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'util/dependencies.lua') diff --git a/util/dependencies.lua b/util/dependencies.lua index 56a04736..d2f87661 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -100,10 +100,12 @@ local function check_dependencies() local unbound, err = softreq"lunbound"; if not unbound then + --[[ TODO Re-enable once packages are available missingdep("lua-unbound", { { "luarocks", "luarocks install luaunbound" }; { "Source", "https://www.zash.se/luaunbound.html" }; }, "Old DNS resolver library will be used", err); + --]] else package.preload["net.adns"] = function () local ub = require "net.unbound"; -- cgit v1.2.3 From fb6356059181107d3d285088abe05dc20d4e8e8f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 28 Jun 2020 02:15:25 +0200 Subject: util.dependencies: Quiet luacheck --- util/dependencies.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'util/dependencies.lua') diff --git a/util/dependencies.lua b/util/dependencies.lua index d2f87661..c117bfc2 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -98,8 +98,8 @@ local function check_dependencies() }, "WebSocket support will not be available", err); end - local unbound, err = softreq"lunbound"; - if not unbound then + local unbound, err = softreq"lunbound"; -- luacheck: ignore 211/err + if not unbound then -- luacheck: ignore 542 --[[ TODO Re-enable once packages are available missingdep("lua-unbound", { { "luarocks", "luarocks install luaunbound" }; -- cgit v1.2.3