util.dependencies: Fix package name of LuaFilesystem
[prosody.git] / util / dependencies.lua
1 -- Prosody IM
2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
4 -- 
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9
10 local fatal;
11
12 local function softreq(...) local ok, lib =  pcall(require, ...); if ok then return lib; else return nil, lib; end end
13
14 local function missingdep(name, sources, msg)
15         print("");
16         print("**************************");
17         print("Prosody was unable to find "..tostring(name));
18         print("This package can be obtained in the following ways:");
19         print("");
20         for k,v in pairs(sources) do
21                 print("", k, v);
22         end
23         print("");
24         print(msg or (name.." is required for Prosody to run, so we will now exit."));
25         print("More help can be found on our website, at http://prosody.im/doc/depends");
26         print("**************************");
27         print("");
28 end
29
30 local lxp = softreq "lxp"
31
32 if not lxp then
33         missingdep("luaexpat", {
34                         ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-expat0";
35                         ["luarocks"] = "luarocks install luaexpat";
36                         ["Source"] = "http://www.keplerproject.org/luaexpat/";
37                 });
38         fatal = true;
39 end
40
41 local socket = softreq "socket"
42
43 if not socket then
44         missingdep("luasocket", {
45                         ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-socket2";
46                         ["luarocks"] = "luarocks install luasocket";
47                         ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/";
48                 });
49         fatal = true;
50 end
51         
52 local lfs, err = softreq "lfs"
53 if not lfs then
54         missingdep("luafilesystem", {
55                         ["luarocks"] = "luarocks install luafilesystem";
56                         ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-filesystem0";
57                         ["Source"] = "http://www.keplerproject.org/luafilesystem/";
58                 });
59         fatal = true;
60 end
61
62 local ssl = softreq "ssl"
63
64 if not ssl then
65         if config.get("*", "core", "run_without_ssl") then
66                 log("warn", "Running without SSL support because run_without_ssl is defined in the config");
67         else
68                 missingdep("LuaSec", {
69                                 ["Debian/Ubuntu"] = "http://prosody.im/download/start#debian_and_ubuntu";
70                                 ["luarocks"] = "luarocks install luasec";
71                                 ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/";
72                         }, "SSL/TLS support will not be available");
73         end
74 else
75         local major, minor, veryminor, patched = ssl._VERSION:match("(%d+)%.(%d+)%.?(%d*)(M?)");
76         if not major or ((tonumber(major) == 0 and (tonumber(minor) or 0) <= 3 and (tonumber(veryminor) or 0) <= 2) and patched ~= "M") then
77                 log("error", "This version of LuaSec contains a known bug that causes disconnects, see http://prosody.im/doc/depends");
78         end
79 end
80
81 local encodings, err = softreq "util.encodings"
82 if not encodings then
83         if err:match("not found") then
84                 missingdep("util.encodings", { ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/";
85                                         ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so";
86                                 });
87         else
88                 print "***********************************"
89                 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn");
90                 print ""
91                 print("The full error was:");
92                 print(err)
93                 print "***********************************"
94         end
95         fatal = true;
96 end
97
98 local hashes, err = softreq "util.hashes"
99 if not hashes then
100         if err:match("not found") then
101                 missingdep("util.hashes", { ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/";
102                                         ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so";
103                                 });
104         else
105                 print "***********************************"
106                 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)");
107                 print ""
108                 print("The full error was:");
109                 print(err)
110                 print "***********************************"
111         end
112         fatal = true;
113 end
114
115 if fatal then os.exit(1); end