Software /
code /
prosody
Comparison
util/dependencies.lua @ 2510:97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 28 Jan 2010 14:56:47 +0000 |
parent | 2299:b7d25e1ac716 |
child | 2513:a8aa7616b154 |
comparison
equal
deleted
inserted
replaced
2509:e8a0f2368cde | 2510:97b5ea975cb9 |
---|---|
4 -- | 4 -- |
5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 module("dependencies", package.seeall) | |
9 | 10 |
10 local fatal; | 11 function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end |
11 | 12 |
12 local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end | 13 function missingdep(name, sources, msg) |
13 | |
14 local function missingdep(name, sources, msg) | |
15 print(""); | 14 print(""); |
16 print("**************************"); | 15 print("**************************"); |
17 print("Prosody was unable to find "..tostring(name)); | 16 print("Prosody was unable to find "..tostring(name)); |
18 print("This package can be obtained in the following ways:"); | 17 print("This package can be obtained in the following ways:"); |
19 print(""); | 18 print(""); |
29 print("More help can be found on our website, at http://prosody.im/doc/depends"); | 28 print("More help can be found on our website, at http://prosody.im/doc/depends"); |
30 print("**************************"); | 29 print("**************************"); |
31 print(""); | 30 print(""); |
32 end | 31 end |
33 | 32 |
34 local lxp = softreq "lxp" | 33 function check_dependencies() |
34 local fatal; | |
35 | |
36 local lxp = softreq "lxp" | |
37 | |
38 if not lxp then | |
39 missingdep("luaexpat", { | |
40 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-expat0"; | |
41 ["luarocks"] = "luarocks install luaexpat"; | |
42 ["Source"] = "http://www.keplerproject.org/luaexpat/"; | |
43 }); | |
44 fatal = true; | |
45 end | |
46 | |
47 local socket = softreq "socket" | |
48 | |
49 if not socket then | |
50 missingdep("luasocket", { | |
51 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-socket2"; | |
52 ["luarocks"] = "luarocks install luasocket"; | |
53 ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/"; | |
54 }); | |
55 fatal = true; | |
56 end | |
57 | |
58 local lfs, err = softreq "lfs" | |
59 if not lfs then | |
60 missingdep("luafilesystem", { | |
61 ["luarocks"] = "luarocks install luafilesystem"; | |
62 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-filesystem0"; | |
63 ["Source"] = "http://www.keplerproject.org/luafilesystem/"; | |
64 }); | |
65 fatal = true; | |
66 end | |
67 | |
68 local ssl = softreq "ssl" | |
69 | |
70 if not ssl then | |
71 if config.get("*", "core", "run_without_ssl") then | |
72 log("warn", "Running without SSL support because run_without_ssl is defined in the config"); | |
73 else | |
74 missingdep("LuaSec", { | |
75 ["Debian/Ubuntu"] = "http://prosody.im/download/start#debian_and_ubuntu"; | |
76 ["luarocks"] = "luarocks install luasec"; | |
77 ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/"; | |
78 }, "SSL/TLS support will not be available"); | |
79 end | |
80 else | |
81 local major, minor, veryminor, patched = ssl._VERSION:match("(%d+)%.(%d+)%.?(%d*)(M?)"); | |
82 if not major or ((tonumber(major) == 0 and (tonumber(minor) or 0) <= 3 and (tonumber(veryminor) or 0) <= 2) and patched ~= "M") then | |
83 log("error", "This version of LuaSec contains a known bug that causes disconnects, see http://prosody.im/doc/depends"); | |
84 end | |
85 end | |
86 | |
87 local encodings, err = softreq "util.encodings" | |
88 if not encodings then | |
89 if err:match("not found") then | |
90 missingdep("util.encodings", { ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/"; | |
91 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so"; | |
92 }); | |
93 else | |
94 print "***********************************" | |
95 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn"); | |
96 print "" | |
97 print("The full error was:"); | |
98 print(err) | |
99 print "***********************************" | |
100 end | |
101 fatal = true; | |
102 end | |
35 | 103 |
36 if not lxp then | 104 local hashes, err = softreq "util.hashes" |
37 missingdep("luaexpat", { | 105 if not hashes then |
38 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-expat0"; | 106 if err:match("not found") then |
39 ["luarocks"] = "luarocks install luaexpat"; | 107 missingdep("util.hashes", { ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/"; |
40 ["Source"] = "http://www.keplerproject.org/luaexpat/"; | 108 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so"; |
41 }); | 109 }); |
42 fatal = true; | 110 else |
111 print "***********************************" | |
112 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)"); | |
113 print "" | |
114 print("The full error was:"); | |
115 print(err) | |
116 print "***********************************" | |
117 end | |
118 fatal = true; | |
119 end | |
120 return not fatal; | |
43 end | 121 end |
44 | 122 |
45 local socket = softreq "socket" | |
46 | 123 |
47 if not socket then | 124 return _M; |
48 missingdep("luasocket", { | |
49 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-socket2"; | |
50 ["luarocks"] = "luarocks install luasocket"; | |
51 ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/"; | |
52 }); | |
53 fatal = true; | |
54 end | |
55 | |
56 local lfs, err = softreq "lfs" | |
57 if not lfs then | |
58 missingdep("luafilesystem", { | |
59 ["luarocks"] = "luarocks install luafilesystem"; | |
60 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-filesystem0"; | |
61 ["Source"] = "http://www.keplerproject.org/luafilesystem/"; | |
62 }); | |
63 fatal = true; | |
64 end | |
65 | |
66 local ssl = softreq "ssl" | |
67 | |
68 if not ssl then | |
69 if config.get("*", "core", "run_without_ssl") then | |
70 log("warn", "Running without SSL support because run_without_ssl is defined in the config"); | |
71 else | |
72 missingdep("LuaSec", { | |
73 ["Debian/Ubuntu"] = "http://prosody.im/download/start#debian_and_ubuntu"; | |
74 ["luarocks"] = "luarocks install luasec"; | |
75 ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/"; | |
76 }, "SSL/TLS support will not be available"); | |
77 end | |
78 else | |
79 local major, minor, veryminor, patched = ssl._VERSION:match("(%d+)%.(%d+)%.?(%d*)(M?)"); | |
80 if not major or ((tonumber(major) == 0 and (tonumber(minor) or 0) <= 3 and (tonumber(veryminor) or 0) <= 2) and patched ~= "M") then | |
81 log("error", "This version of LuaSec contains a known bug that causes disconnects, see http://prosody.im/doc/depends"); | |
82 end | |
83 end | |
84 | |
85 local encodings, err = softreq "util.encodings" | |
86 if not encodings then | |
87 if err:match("not found") then | |
88 missingdep("util.encodings", { ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/"; | |
89 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so"; | |
90 }); | |
91 else | |
92 print "***********************************" | |
93 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn"); | |
94 print "" | |
95 print("The full error was:"); | |
96 print(err) | |
97 print "***********************************" | |
98 end | |
99 fatal = true; | |
100 end | |
101 | |
102 local hashes, err = softreq "util.hashes" | |
103 if not hashes then | |
104 if err:match("not found") then | |
105 missingdep("util.hashes", { ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/"; | |
106 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so"; | |
107 }); | |
108 else | |
109 print "***********************************" | |
110 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)"); | |
111 print "" | |
112 print("The full error was:"); | |
113 print(err) | |
114 print "***********************************" | |
115 end | |
116 fatal = true; | |
117 end | |
118 | |
119 if fatal then os.exit(1); end |