util.dependencies: Add LuaFileSystem as a hard dependency
[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", { ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-expat0"; ["luarocks"] = "luarocks install luaexpat"; });
34         fatal = true;
35 end
36
37 local socket = softreq "socket"
38
39 if not socket then
40         missingdep("luasocket", { ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-socket2"; ["luarocks"] = "luarocks install luasocket"; });
41         fatal = true;
42 end
43         
44 local lfs, err = softreq "lfs"
45 if not lfs then
46         missingdep("luafilesystem", { ["luarocks"] = "luarocks install luafilesystem";
47                                         ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-luafilesystem0";
48                                         ["Source"] = "http://www.keplerproject.org/luafilesystem/";
49                                 });
50         fatal = true;
51 end
52
53 local ssl = softreq "ssl"
54
55 if not ssl then
56         if config.get("*", "core", "run_without_ssl") then
57                 log("warn", "Running without SSL support because run_without_ssl is defined in the config");
58         else
59                 missingdep("LuaSec", { ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/" }, "SSL/TLS support will not be available");
60         end
61 end
62
63 local encodings, err = softreq "util.encodings"
64 if not encodings then
65         if err:match("not found") then
66                 missingdep("util.encodings", { ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/";
67                                         ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so";
68                                 });
69         else
70                 print "***********************************"
71                 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn");
72                 print ""
73                 print("The full error was:");
74                 print(err)
75                 print "***********************************"
76         end
77         fatal = true;
78 end
79
80 local hashes, err = softreq "util.hashes"
81 if not hashes then
82         if err:match("not found") then
83                 missingdep("util.hashes", { ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/";
84                                         ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so";
85                                 });
86         else
87                 print "***********************************"
88                 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)");
89                 print ""
90                 print("The full error was:");
91                 print(err)
92                 print "***********************************"
93         end
94         fatal = true;
95 end
96
97 if fatal then os.exit(1); end