Annotate

util/dependencies.lua @ 2332:7772dde4010b

mod_posix: Catch SIGINT
author Matthew Wild <mwild1@gmail.com>
date Mon, 07 Dec 2009 18:38:35 +0000
parent 2299:b7d25e1ac716
child 2510:97b5ea975cb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 743
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 743
diff changeset
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("");
2146
5c54097ef84a util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
20 local longest_platform = 0;
5c54097ef84a util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
21 for platform in pairs(sources) do
5c54097ef84a util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
22 longest_platform = math.max(longest_platform, #platform);
5c54097ef84a util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
23 end
5c54097ef84a util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
24 for platform, source in pairs(sources) do
5c54097ef84a util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
25 print("", platform..":"..(" "):rep(4+longest_platform-#platform)..source);
408
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 end
410
5ce6801ad2e4 Trivial whitespace fix in the missing dependency message
Matthew Wild <mwild1@gmail.com>
parents: 409
diff changeset
27 print("");
408
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 print(msg or (name.." is required for Prosody to run, so we will now exit."));
526
b1d90f7d074a Fill blank with URL
Matthew Wild <mwild1@gmail.com>
parents: 519
diff changeset
29 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
30 print("**************************");
2269e9cbe153 Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents: 408
diff changeset
31 print("");
408
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 end
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 local lxp = softreq "lxp"
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 if not lxp then
2157
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
37 missingdep("luaexpat", {
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
38 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-expat0";
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
39 ["luarocks"] = "luarocks install luaexpat";
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
40 ["Source"] = "http://www.keplerproject.org/luaexpat/";
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
41 });
408
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 fatal = true;
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 end
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 local socket = softreq "socket"
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 if not socket then
2157
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
48 missingdep("luasocket", {
2158
575d5db7f14f util.dependencies: Missed a Debian/
Matthew Wild <mwild1@gmail.com>
parents: 2157
diff changeset
49 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-socket2";
2157
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
50 ["luarocks"] = "luarocks install luasocket";
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
51 ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/";
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
52 });
408
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 fatal = true;
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 end
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55
2156
a6608ccab383 util.dependencies: Add LuaFileSystem as a hard dependency
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
56 local lfs, err = softreq "lfs"
a6608ccab383 util.dependencies: Add LuaFileSystem as a hard dependency
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
57 if not lfs then
2157
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
58 missingdep("luafilesystem", {
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
59 ["luarocks"] = "luarocks install luafilesystem";
2298
508d9dc70bb4 util.dependencies: Fix package name of LuaFilesystem
Matthew Wild <mwild1@gmail.com>
parents: 2169
diff changeset
60 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-filesystem0";
2157
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
61 ["Source"] = "http://www.keplerproject.org/luafilesystem/";
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
62 });
2156
a6608ccab383 util.dependencies: Add LuaFileSystem as a hard dependency
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
63 fatal = true;
a6608ccab383 util.dependencies: Add LuaFileSystem as a hard dependency
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
64 end
a6608ccab383 util.dependencies: Add LuaFileSystem as a hard dependency
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
65
408
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 local ssl = softreq "ssl"
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 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
69 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
70 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
71 else
2157
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
72 missingdep("LuaSec", {
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
73 ["Debian/Ubuntu"] = "http://prosody.im/download/start#debian_and_ubuntu";
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
74 ["luarocks"] = "luarocks install luasec";
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
75 ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/";
7cb0aa497326 util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents: 2156
diff changeset
76 }, "SSL/TLS support will not be available");
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
77 end
2169
c06fdb6b57bd util.dependencies: Log an error if the current version of LuaSec installed contains The Bug (thanks Remko)
Matthew Wild <mwild1@gmail.com>
parents: 2158
diff changeset
78 else
c06fdb6b57bd util.dependencies: Log an error if the current version of LuaSec installed contains The Bug (thanks Remko)
Matthew Wild <mwild1@gmail.com>
parents: 2158
diff changeset
79 local major, minor, veryminor, patched = ssl._VERSION:match("(%d+)%.(%d+)%.?(%d*)(M?)");
c06fdb6b57bd util.dependencies: Log an error if the current version of LuaSec installed contains The Bug (thanks Remko)
Matthew Wild <mwild1@gmail.com>
parents: 2158
diff changeset
80 if not major or ((tonumber(major) == 0 and (tonumber(minor) or 0) <= 3 and (tonumber(veryminor) or 0) <= 2) and patched ~= "M") then
c06fdb6b57bd util.dependencies: Log an error if the current version of LuaSec installed contains The Bug (thanks Remko)
Matthew Wild <mwild1@gmail.com>
parents: 2158
diff changeset
81 log("error", "This version of LuaSec contains a known bug that causes disconnects, see http://prosody.im/doc/depends");
c06fdb6b57bd util.dependencies: Log an error if the current version of LuaSec installed contains The Bug (thanks Remko)
Matthew Wild <mwild1@gmail.com>
parents: 2158
diff changeset
82 end
408
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 end
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84
839
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
85 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
86 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
87 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
88 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
89 ["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
90 });
839
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
91 else
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
92 print "***********************************"
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
93 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
94 print ""
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
95 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
96 print(err)
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
97 print "***********************************"
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
98 end
743
99ef95e119ad util.dependencies: Not finding our own libraries is fatal
Matthew Wild <mwild1@gmail.com>
parents: 742
diff changeset
99 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
100 end
b9f59372eb4e util.dependencies: Show useful messages when our own libraries are not found, too
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
101
839
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
102 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
103 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
104 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
105 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
106 ["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
107 });
839
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
108 else
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
109 print "***********************************"
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
110 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
111 print ""
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
112 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
113 print(err)
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
114 print "***********************************"
c45b5072f773 Better handling of found, but unloadable, core libraries (eg. undefined symbols)
Matthew Wild <mwild1@gmail.com>
parents: 760
diff changeset
115 end
743
99ef95e119ad util.dependencies: Not finding our own libraries is fatal
Matthew Wild <mwild1@gmail.com>
parents: 742
diff changeset
116 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
117 end
409
2269e9cbe153 Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents: 408
diff changeset
118
408
eb1a0960cefb Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119 if fatal then os.exit(1); end