2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 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 -- Required to be able to find packages installed with luarocks
14 if not softreq "luarocks.loader" then -- LuaRocks 2.x
15 softreq "luarocks.require"; -- LuaRocks <1.x
18 function missingdep(name, sources, msg)
20 print("**************************");
21 print("Prosody was unable to find "..tostring(name));
22 print("This package can be obtained in the following ways:");
24 local longest_platform = 0;
25 for platform in pairs(sources) do
26 longest_platform = math.max(longest_platform, #platform);
28 for platform, source in pairs(sources) do
29 print("", platform..":"..(" "):rep(4+longest_platform-#platform)..source);
32 print(msg or (name.." is required for Prosody to run, so we will now exit."));
33 print("More help can be found on our website, at http://prosody.im/doc/depends");
34 print("**************************");
38 -- COMPAT w/pre-0.8 Debian: The Debian config file used to use
39 -- util.ztact, which has been removed from Prosody in 0.8. This
40 -- is to log an error for people who still use it, so they can
41 -- update their configs.
42 package.preload["util.ztact"] = function ()
43 if not package.loaded["core.loggingmanager"] then
44 error("util.ztact has been removed from Prosody and you need to fix your config "
45 .."file. More information can be found at http://prosody.im/doc/packagers#ztact", 0);
47 error("module 'util.ztact' has been deprecated in Prosody 0.8.");
51 function check_dependencies()
54 local lxp = softreq "lxp"
57 missingdep("luaexpat", {
58 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-expat0";
59 ["luarocks"] = "luarocks install luaexpat";
60 ["Source"] = "http://www.keplerproject.org/luaexpat/";
65 local socket = softreq "socket"
68 missingdep("luasocket", {
69 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-socket2";
70 ["luarocks"] = "luarocks install luasocket";
71 ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/";
76 local lfs, err = softreq "lfs"
78 missingdep("luafilesystem", {
79 ["luarocks"] = "luarocks install luafilesystem";
80 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-filesystem0";
81 ["Source"] = "http://www.keplerproject.org/luafilesystem/";
86 local ssl = softreq "ssl"
89 missingdep("LuaSec", {
90 ["Debian/Ubuntu"] = "http://prosody.im/download/start#debian_and_ubuntu";
91 ["luarocks"] = "luarocks install luasec";
92 ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/";
93 }, "SSL/TLS support will not be available");
96 local encodings, err = softreq "util.encodings"
98 if err:match("not found") then
99 missingdep("util.encodings", { ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/";
100 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so";
103 print "***********************************"
104 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn");
106 print("The full error was:");
108 print "***********************************"
113 local hashes, err = softreq "util.hashes"
115 if err:match("not found") then
116 missingdep("util.hashes", { ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/";
117 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so";
120 print "***********************************"
121 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)");
123 print("The full error was:");
125 print "***********************************"
132 function log_warnings()
134 local major, minor, veryminor, patched = ssl._VERSION:match("(%d+)%.(%d+)%.?(%d*)(M?)");
135 if not major or ((tonumber(major) == 0 and (tonumber(minor) or 0) <= 3 and (tonumber(veryminor) or 0) <= 2) and patched ~= "M") then
136 log("error", "This version of LuaSec contains a known bug that causes disconnects, see http://prosody.im/doc/depends");
140 if not pcall(lxp.new, { StartDoctypeDecl = false }) then
141 log("error", "The version of LuaExpat on your system leaves Prosody "
142 .."vulnerable to denial-of-service attacks. You should upgrade to "
143 .."LuaExpat 1.1.1 or higher as soon as possible. See "
144 .."http://prosody.im/doc/depends#luaexpat for more information.");