aboutsummaryrefslogtreecommitdiffstats
path: root/util/dependencies.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util/dependencies.lua')
-rw-r--r--util/dependencies.lua86
1 files changed, 50 insertions, 36 deletions
diff --git a/util/dependencies.lua b/util/dependencies.lua
index 24975567..f6ba7621 100644
--- a/util/dependencies.lua
+++ b/util/dependencies.lua
@@ -7,24 +7,22 @@
--
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
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));
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."));
@@ -44,25 +42,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/";
- });
+ { "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/";
- });
+ { "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
@@ -73,39 +71,53 @@ 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
- 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");
+ { "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
- local bit = softreq"bit" or softreq"bit32";
+ 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");
+ { "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
+
+ local unbound, err = softreq"lunbound"; -- luacheck: ignore 211/err
+ if not unbound then
+ missingdep("lua-unbound", {
+ { "Debian/Ubuntu", "sudo apt-get install 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";
+ return ub;
+ end
end
local encodings, err = softreq "util.encodings"
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 "***********************************"
@@ -122,8 +134,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 "***********************************"
@@ -140,8 +152,10 @@ local function check_dependencies()
end
local function log_warnings()
- if _VERSION > "Lua 5.2" then
+ if _VERSION > "Lua 5.4" then
prosody.log("warn", "Support for %s is experimental, please report any issues", _VERSION);
+ elseif _VERSION < "Lua 5.2" then
+ prosody.log("warn", "%s has several issues and support is being phased out, consider upgrading", _VERSION);
end
local ssl = softreq"ssl";
if ssl then