Software /
code /
prosody
Annotate
util/dependencies.lua @ 519:cccd610a0ef9
Insert copyright/license headers
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 03 Dec 2008 14:39:07 +0000 |
parent | 449:c0a4a1e63d70 |
child | 526:b1d90f7d074a |
rev | line source |
---|---|
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
1 -- Prosody IM v0.1 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
2 -- Copyright (C) 2008 Matthew Wild |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
3 -- Copyright (C) 2008 Waqas Hussain |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
4 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
5 -- This program is free software; you can redistribute it and/or |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
6 -- modify it under the terms of the GNU General Public License |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
7 -- as published by the Free Software Foundation; either version 2 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
8 -- of the License, or (at your option) any later version. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
9 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
10 -- This program is distributed in the hope that it will be useful, |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
13 -- GNU General Public License for more details. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
14 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
15 -- You should have received a copy of the GNU General Public License |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
16 -- along with this program; if not, write to the Free Software |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
18 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
19 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
20 |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 local fatal; |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 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
|
24 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 local function missingdep(name, sources, msg) |
409
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
26 print(""); |
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
27 print("**************************"); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 print("Prosody was unable to find "..tostring(name)); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 print("This package can be obtained in the following ways:"); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 print(""); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 for k,v in pairs(sources) do |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 print("", k, v); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 end |
410
5ce6801ad2e4
Trivial whitespace fix in the missing dependency message
Matthew Wild <mwild1@gmail.com>
parents:
409
diff
changeset
|
34 print(""); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 print(msg or (name.." is required for Prosody to run, so we will now exit.")); |
409
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
36 print("More help can be found on our website, at http://.../doc/depends"); |
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
37 print("**************************"); |
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
38 print(""); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 local lxp = softreq "lxp" |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 if not lxp then |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 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
|
45 fatal = true; |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 local socket = softreq "socket" |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 if not socket then |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 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
|
52 fatal = true; |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 local ssl = softreq "ssl" |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 if not ssl then |
413
4b61529d0884
Refuse to run without SSL/TLS unless run_without_ssl is set in config
Matthew Wild <mwild1@gmail.com>
parents:
410
diff
changeset
|
58 if config.get("*", "core", "run_without_ssl") then |
4b61529d0884
Refuse to run without SSL/TLS unless run_without_ssl is set in config
Matthew Wild <mwild1@gmail.com>
parents:
410
diff
changeset
|
59 log("warn", "Running without SSL support because run_without_ssl is defined in the config"); |
4b61529d0884
Refuse to run without SSL/TLS unless run_without_ssl is set in config
Matthew Wild <mwild1@gmail.com>
parents:
410
diff
changeset
|
60 else |
4b61529d0884
Refuse to run without SSL/TLS unless run_without_ssl is set in config
Matthew Wild <mwild1@gmail.com>
parents:
410
diff
changeset
|
61 missingdep("LuaSec", { ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/" }, "SSL/TLS support will not be available"); |
4b61529d0884
Refuse to run without SSL/TLS unless run_without_ssl is set in config
Matthew Wild <mwild1@gmail.com>
parents:
410
diff
changeset
|
62 end |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 |
409
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
65 |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 if fatal then os.exit(1); end |