Friendlier messages on missing dependencies
[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("Prosody was unable to find "..tostring(name));
7         print("This package can be obtained in the following ways:");
8         print("");
9         for k,v in pairs(sources) do
10                 print("", k, v);
11         end
12         print(msg or (name.." is required for Prosody to run, so we will now exit."));
13 end
14
15 local lxp = softreq "lxp"
16
17 if not lxp then
18         missingdep("luaexpat", { ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-expat0"; ["luarocks"] = "luarocks install luaexpat"; });
19         fatal = true;
20 end
21
22 local socket = softreq "socket"
23
24 if not socket then
25         missingdep("luasocket", { ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-socket2"; ["luarocks"] = "luarocks install luasocket"; });
26         fatal = true;
27 end
28         
29 local ssl = softreq "ssl"
30
31 if not ssl then
32         missingdep("LuaSec", { ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/" }, "SSL/TLS support will not be available");
33 end
34
35 if fatal then os.exit(1); end