Annotate

util/dependencies.lua @ 408:eb1a0960cefb

Friendlier messages on missing dependencies
author Matthew Wild <mwild1@gmail.com>
date Tue, 25 Nov 2008 02:20:23 +0000
child 409:2269e9cbe153
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
408
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local fatal;
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil; end end
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 local function missingdep(name, sources, msg)
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 print("Prosody was unable to find "..tostring(name));
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 print("This package can be obtained in the following ways:");
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 print("");
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 for k,v in pairs(sources) do
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 print("", k, v);
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 end
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 print(msg or (name.." is required for Prosody to run, so we will now exit."));
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 end
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 local lxp = softreq "lxp"
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 if not lxp then
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 missingdep("luaexpat", { ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-expat0"; ["luarocks"] = "luarocks install luaexpat"; });
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 fatal = true;
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 end
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 local socket = softreq "socket"
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 if not socket then
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 missingdep("luasocket", { ["Ubuntu 8.04 (Hardy)"] = "sudo apt-get install liblua5.1-socket2"; ["luarocks"] = "luarocks install luasocket"; });
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 fatal = true;
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 end
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 local ssl = softreq "ssl"
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 if not ssl then
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 missingdep("LuaSec", { ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/" }, "SSL/TLS support will not be available");
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 end
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 if fatal then os.exit(1); end