Completely switched to new hashes library from the old md5 library
[prosody.git] / util / dependencies.lua
1 local fatal;
2
3 local function softreq(...) local ok, lib =  pcall(require, ...); if ok then return lib; else return nil; end end
4
5 local function missingdep(name, sources, msg)
6         print("");
7         print("**************************");
8         print("Prosody was unable to find "..tostring(name));
9         print("This package can be obtained in the following ways:");
10         print("");
11         for k,v in pairs(sources) do
12                 print("", k, v);
13         end
14         print("");
15         print(msg or (name.." is required for Prosody to run, so we will now exit."));
16         print("More help can be found on our website, at http://.../doc/depends");
17         print("**************************");
18         print("");
19 end
20
21 local lxp = softreq "lxp"
22
23 if not lxp then
24         missingdep("luaexpat", { ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-expat0"; ["luarocks"] = "luarocks install luaexpat"; });
25         fatal = true;
26 end
27
28 local socket = softreq "socket"
29
30 if not socket then
31         missingdep("luasocket", { ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-socket2"; ["luarocks"] = "luarocks install luasocket"; });
32         fatal = true;
33 end
34         
35 local ssl = softreq "ssl"
36
37 if not ssl then
38         if config.get("*", "core", "run_without_ssl") then
39                 log("warn", "Running without SSL support because run_without_ssl is defined in the config");
40         else
41                 missingdep("LuaSec", { ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/" }, "SSL/TLS support will not be available");
42         end
43 end
44
45
46 if fatal then os.exit(1); end