Software /
code /
prosody
Comparison
util/dependencies.lua @ 10906:a1fed82c44b9
util.dependencies: Use util.human.io.table to replace custom layout code
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 04 Jun 2020 17:30:44 +0100 |
parent | 10535:29c1a3bf1d29 |
child | 10963:80733851be8b |
comparison
equal
deleted
inserted
replaced
10905:709255e332d8 | 10906:a1fed82c44b9 |
---|---|
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 local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end | 9 local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end |
10 local platform_table = require "util.human.io".table({ { width = 15, align = "right" }, { width = "100%" } }); | |
10 | 11 |
11 -- Required to be able to find packages installed with luarocks | 12 -- Required to be able to find packages installed with luarocks |
12 if not softreq "luarocks.loader" then -- LuaRocks 2.x | 13 if not softreq "luarocks.loader" then -- LuaRocks 2.x |
13 softreq "luarocks.require"; -- LuaRocks <1.x | 14 softreq "luarocks.require"; -- LuaRocks <1.x |
14 end | 15 end |
18 print(""); | 19 print(""); |
19 print("**************************"); | 20 print("**************************"); |
20 print("Prosody was unable to find "..tostring(name)); | 21 print("Prosody was unable to find "..tostring(name)); |
21 print("This package can be obtained in the following ways:"); | 22 print("This package can be obtained in the following ways:"); |
22 print(""); | 23 print(""); |
23 local longest_platform = 0; | 24 for _, row in ipairs(sources) do |
24 for platform in pairs(sources) do | 25 print(platform_table(row)); |
25 longest_platform = math.max(longest_platform, #platform); | |
26 end | |
27 for platform, source in pairs(sources) do | |
28 print("", platform..":"..(" "):rep(4+longest_platform-#platform)..source); | |
29 end | 26 end |
30 print(""); | 27 print(""); |
31 print(msg or (name.." is required for Prosody to run, so we will now exit.")); | 28 print(msg or (name.." is required for Prosody to run, so we will now exit.")); |
32 print("More help can be found on our website, at https://prosody.im/doc/depends"); | 29 print("More help can be found on our website, at https://prosody.im/doc/depends"); |
33 print("**************************"); | 30 print("**************************"); |
47 | 44 |
48 local lxp, err = softreq "lxp" | 45 local lxp, err = softreq "lxp" |
49 | 46 |
50 if not lxp then | 47 if not lxp then |
51 missingdep("luaexpat", { | 48 missingdep("luaexpat", { |
52 ["Debian/Ubuntu"] = "sudo apt-get install lua-expat"; | 49 { "Debian/Ubuntu", "sudo apt-get install lua-expat" }; |
53 ["luarocks"] = "luarocks install luaexpat"; | 50 { "luarocks", "luarocks install luaexpat" }; |
54 ["Source"] = "http://matthewwild.co.uk/projects/luaexpat/"; | 51 { "Source", "http://matthewwild.co.uk/projects/luaexpat/" }; |
55 }, nil, err); | 52 }, nil, err); |
56 fatal = true; | 53 fatal = true; |
57 end | 54 end |
58 | 55 |
59 local socket, err = softreq "socket" | 56 local socket, err = softreq "socket" |
60 | 57 |
61 if not socket then | 58 if not socket then |
62 missingdep("luasocket", { | 59 missingdep("luasocket", { |
63 ["Debian/Ubuntu"] = "sudo apt-get install lua-socket"; | 60 { "Debian/Ubuntu", "sudo apt-get install lua-socket" }; |
64 ["luarocks"] = "luarocks install luasocket"; | 61 { "luarocks", "luarocks install luasocket" }; |
65 ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/"; | 62 { "Source", "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/" }; |
66 }, nil, err); | 63 }, nil, err); |
67 fatal = true; | 64 fatal = true; |
68 elseif not socket.tcp4 then | 65 elseif not socket.tcp4 then |
69 -- COMPAT LuaSocket before being IP-version agnostic | 66 -- COMPAT LuaSocket before being IP-version agnostic |
70 socket.tcp4 = socket.tcp; | 67 socket.tcp4 = socket.tcp; |
72 end | 69 end |
73 | 70 |
74 local lfs, err = softreq "lfs" | 71 local lfs, err = softreq "lfs" |
75 if not lfs then | 72 if not lfs then |
76 missingdep("luafilesystem", { | 73 missingdep("luafilesystem", { |
77 ["luarocks"] = "luarocks install luafilesystem"; | 74 { "luarocks", "luarocks install luafilesystem" }; |
78 ["Debian/Ubuntu"] = "sudo apt-get install lua-filesystem"; | 75 { "Debian/Ubuntu", "sudo apt-get install lua-filesystem" }; |
79 ["Source"] = "http://www.keplerproject.org/luafilesystem/"; | 76 { "Source", "http://www.keplerproject.org/luafilesystem/" }; |
80 }, nil, err); | 77 }, nil, err); |
81 fatal = true; | 78 fatal = true; |
82 end | 79 end |
83 | 80 |
84 local ssl, err = softreq "ssl" | 81 local ssl, err = softreq "ssl" |
85 | 82 |
86 if not ssl then | 83 if not ssl then |
87 missingdep("LuaSec", { | 84 missingdep("LuaSec", { |
88 ["Debian/Ubuntu"] = "sudo apt-get install lua-sec"; | 85 { "Debian/Ubuntu", "sudo apt-get install lua-sec" }; |
89 ["luarocks"] = "luarocks install luasec"; | 86 { "luarocks", "luarocks install luasec" }; |
90 ["Source"] = "https://github.com/brunoos/luasec"; | 87 { "Source", "https://github.com/brunoos/luasec" }; |
91 }, "SSL/TLS support will not be available", err); | 88 }, "SSL/TLS support will not be available", err); |
92 end | 89 end |
93 | 90 |
94 local bit, err = softreq"util.bitcompat"; | 91 local bit, err = softreq"util.bitcompat"; |
95 | 92 |
96 if not bit then | 93 if not bit then |
97 missingdep("lua-bitops", { | 94 missingdep("lua-bitops", { |
98 ["Debian/Ubuntu"] = "sudo apt-get install lua-bitop"; | 95 { "Debian/Ubuntu", "sudo apt-get install lua-bitop" }; |
99 ["luarocks"] = "luarocks install luabitop"; | 96 { "luarocks", "luarocks install luabitop" }; |
100 ["Source"] = "http://bitop.luajit.org/"; | 97 { "Source", "http://bitop.luajit.org/" }; |
101 }, "WebSocket support will not be available", err); | 98 }, "WebSocket support will not be available", err); |
102 end | 99 end |
103 | 100 |
104 local encodings, err = softreq "util.encodings" | 101 local encodings, err = softreq "util.encodings" |
105 if not encodings then | 102 if not encodings then |
106 if err:match("module '[^']*' not found") then | 103 if err:match("module '[^']*' not found") then |
107 missingdep("util.encodings", { | 104 missingdep("util.encodings", { |
108 ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/"; | 105 { "Windows", "Make sure you have encodings.dll from the Prosody distribution in util/" }; |
109 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so"; | 106 { "GNU/Linux", "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so" }; |
110 }); | 107 }); |
111 else | 108 else |
112 print "***********************************" | 109 print "***********************************" |
113 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn"); | 110 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn"); |
114 print "" | 111 print "" |
121 | 118 |
122 local hashes, err = softreq "util.hashes" | 119 local hashes, err = softreq "util.hashes" |
123 if not hashes then | 120 if not hashes then |
124 if err:match("module '[^']*' not found") then | 121 if err:match("module '[^']*' not found") then |
125 missingdep("util.hashes", { | 122 missingdep("util.hashes", { |
126 ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/"; | 123 { "Windows", "Make sure you have hashes.dll from the Prosody distribution in util/" }; |
127 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so"; | 124 { "GNU/Linux", "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so" }; |
128 }); | 125 }); |
129 else | 126 else |
130 print "***********************************" | 127 print "***********************************" |
131 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)"); | 128 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)"); |
132 print "" | 129 print "" |