Insert copyright/license headers
[prosody.git] / util / dependencies.lua
1 -- Prosody IM v0.1
2 -- Copyright (C) 2008 Matthew Wild
3 -- Copyright (C) 2008 Waqas Hussain
4 -- 
5 -- This program is free software; you can redistribute it and/or
6 -- modify it under the terms of the GNU General Public License
7 -- as published by the Free Software Foundation; either version 2
8 -- of the License, or (at your option) any later version.
9 -- 
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 -- GNU General Public License for more details.
14 -- 
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 --
19
20
21 local fatal;
22
23 local function softreq(...) local ok, lib =  pcall(require, ...); if ok then return lib; else return nil; end end
24
25 local function missingdep(name, sources, msg)
26         print("");
27         print("**************************");
28         print("Prosody was unable to find "..tostring(name));
29         print("This package can be obtained in the following ways:");
30         print("");
31         for k,v in pairs(sources) do
32                 print("", k, v);
33         end
34         print("");
35         print(msg or (name.." is required for Prosody to run, so we will now exit."));
36         print("More help can be found on our website, at http://.../doc/depends");
37         print("**************************");
38         print("");
39 end
40
41 local lxp = softreq "lxp"
42
43 if not lxp then
44         missingdep("luaexpat", { ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-expat0"; ["luarocks"] = "luarocks install luaexpat"; });
45         fatal = true;
46 end
47
48 local socket = softreq "socket"
49
50 if not socket then
51         missingdep("luasocket", { ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-socket2"; ["luarocks"] = "luarocks install luasocket"; });
52         fatal = true;
53 end
54         
55 local ssl = softreq "ssl"
56
57 if not ssl then
58         if config.get("*", "core", "run_without_ssl") then
59                 log("warn", "Running without SSL support because run_without_ssl is defined in the config");
60         else
61                 missingdep("LuaSec", { ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/" }, "SSL/TLS support will not be available");
62         end
63 end
64
65
66 if fatal then os.exit(1); end