Software /
code /
prosody
Annotate
util/dependencies.lua @ 2009:3f9cce29c57d
mod_console: Added help text for config:reload().
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 18 Oct 2009 18:01:13 +0500 |
parent | 1523:841d61be198f |
child | 2146:5c54097ef84a |
child | 2156:a6608ccab383 |
rev | line source |
---|---|
1523
841d61be198f
Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
1 -- Prosody IM |
760
90ce865eebd8
Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents:
759
diff
changeset
|
2 -- Copyright (C) 2008-2009 Matthew Wild |
90ce865eebd8
Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents:
759
diff
changeset
|
3 -- Copyright (C) 2008-2009 Waqas Hussain |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
4 -- |
758 | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
7 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
8 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
9 |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 local fatal; |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
839
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
12 local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 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
|
15 print(""); |
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
16 print("**************************"); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 print("Prosody was unable to find "..tostring(name)); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 print("This package can be obtained in the following ways:"); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 print(""); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 for k,v in pairs(sources) do |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 print("", k, v); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 end |
410
5ce6801ad2e4
Trivial whitespace fix in the missing dependency message
Matthew Wild <mwild1@gmail.com>
parents:
409
diff
changeset
|
23 print(""); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 print(msg or (name.." is required for Prosody to run, so we will now exit.")); |
526 | 25 print("More help can be found on our website, at http://prosody.im/doc/depends"); |
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 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 local lxp = softreq "lxp" |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 if not lxp then |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 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
|
34 fatal = true; |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 local socket = softreq "socket" |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 if not socket then |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 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
|
41 fatal = true; |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 local ssl = softreq "ssl" |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 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
|
50 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
|
51 end |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 |
839
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
54 local encodings, err = softreq "util.encodings" |
742
b9f59372eb4e
util.dependencies: Show useful messages when our own libraries are not found, too
Matthew Wild <mwild1@gmail.com>
parents:
615
diff
changeset
|
55 if not encodings then |
839
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
56 if err:match("not found") then |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
57 missingdep("util.encodings", { ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/"; |
742
b9f59372eb4e
util.dependencies: Show useful messages when our own libraries are not found, too
Matthew Wild <mwild1@gmail.com>
parents:
615
diff
changeset
|
58 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so"; |
b9f59372eb4e
util.dependencies: Show useful messages when our own libraries are not found, too
Matthew Wild <mwild1@gmail.com>
parents:
615
diff
changeset
|
59 }); |
839
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
60 else |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
61 print "***********************************" |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
62 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn"); |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
63 print "" |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
64 print("The full error was:"); |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
65 print(err) |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
66 print "***********************************" |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
67 end |
743
99ef95e119ad
util.dependencies: Not finding our own libraries is fatal
Matthew Wild <mwild1@gmail.com>
parents:
742
diff
changeset
|
68 fatal = true; |
742
b9f59372eb4e
util.dependencies: Show useful messages when our own libraries are not found, too
Matthew Wild <mwild1@gmail.com>
parents:
615
diff
changeset
|
69 end |
b9f59372eb4e
util.dependencies: Show useful messages when our own libraries are not found, too
Matthew Wild <mwild1@gmail.com>
parents:
615
diff
changeset
|
70 |
839
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
71 local hashes, err = softreq "util.hashes" |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
72 if not hashes then |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
73 if err:match("not found") then |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
74 missingdep("util.hashes", { ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/"; |
742
b9f59372eb4e
util.dependencies: Show useful messages when our own libraries are not found, too
Matthew Wild <mwild1@gmail.com>
parents:
615
diff
changeset
|
75 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so"; |
b9f59372eb4e
util.dependencies: Show useful messages when our own libraries are not found, too
Matthew Wild <mwild1@gmail.com>
parents:
615
diff
changeset
|
76 }); |
839
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
77 else |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
78 print "***********************************" |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
79 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)"); |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
80 print "" |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
81 print("The full error was:"); |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
82 print(err) |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
83 print "***********************************" |
c45b5072f773
Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents:
760
diff
changeset
|
84 end |
743
99ef95e119ad
util.dependencies: Not finding our own libraries is fatal
Matthew Wild <mwild1@gmail.com>
parents:
742
diff
changeset
|
85 fatal = true; |
742
b9f59372eb4e
util.dependencies: Show useful messages when our own libraries are not found, too
Matthew Wild <mwild1@gmail.com>
parents:
615
diff
changeset
|
86 end |
409
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
87 |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 if fatal then os.exit(1); end |