2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
9 module("dependencies", package.seeall)
11 function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end
13 function missingdep(name, sources, msg)
15 print("**************************");
16 print("Prosody was unable to find "..tostring(name));
17 print("This package can be obtained in the following ways:");
19 local longest_platform = 0;
20 for platform in pairs(sources) do
21 longest_platform = math.max(longest_platform, #platform);
23 for platform, source in pairs(sources) do
24 print("", platform..":"..(" "):rep(4+longest_platform-#platform)..source);
27 print(msg or (name.." is required for Prosody to run, so we will now exit."));
28 print("More help can be found on our website, at http://prosody.im/doc/depends");
29 print("**************************");
33 function check_dependencies()
36 local lxp = softreq "lxp"
39 missingdep("luaexpat", {
40 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-expat0";
41 ["luarocks"] = "luarocks install luaexpat";
42 ["Source"] = "http://www.keplerproject.org/luaexpat/";
47 local socket = softreq "socket"
50 missingdep("luasocket", {
51 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-socket2";
52 ["luarocks"] = "luarocks install luasocket";
53 ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/";
58 local lfs, err = softreq "lfs"
60 missingdep("luafilesystem", {
61 ["luarocks"] = "luarocks install luafilesystem";
62 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-filesystem0";
63 ["Source"] = "http://www.keplerproject.org/luafilesystem/";
68 local ssl = softreq "ssl"
71 if config.get("*", "core", "run_without_ssl") then
72 log("warn", "Running without SSL support because run_without_ssl is defined in the config");
74 missingdep("LuaSec", {
75 ["Debian/Ubuntu"] = "http://prosody.im/download/start#debian_and_ubuntu";
76 ["luarocks"] = "luarocks install luasec";
77 ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/";
78 }, "SSL/TLS support will not be available");
81 local major, minor, veryminor, patched = ssl._VERSION:match("(%d+)%.(%d+)%.?(%d*)(M?)");
82 if not major or ((tonumber(major) == 0 and (tonumber(minor) or 0) <= 3 and (tonumber(veryminor) or 0) <= 2) and patched ~= "M") then
83 log("error", "This version of LuaSec contains a known bug that causes disconnects, see http://prosody.im/doc/depends");
87 local encodings, err = softreq "util.encodings"
89 if err:match("not found") then
90 missingdep("util.encodings", { ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/";
91 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so";
94 print "***********************************"
95 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn");
97 print("The full error was:");
99 print "***********************************"
104 local hashes, err = softreq "util.hashes"
106 if err:match("not found") then
107 missingdep("util.hashes", { ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/";
108 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so";
111 print "***********************************"
112 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)");
114 print("The full error was:");
116 print "***********************************"