Comparison

util/dependencies.lua @ 10535:29c1a3bf1d29

util.dependencies: Pass require error to error formatting function For future use there. Silences luacheck warnings about unused 'err'
author Kim Alvefur <zash@zash.se>
date Mon, 23 Dec 2019 21:15:01 +0100
parent 10406:a7903de619b0
child 10906:a1fed82c44b9
comparison
equal deleted inserted replaced
10534:8a42fd6702e6 10535:29c1a3bf1d29
11 -- Required to be able to find packages installed with luarocks 11 -- Required to be able to find packages installed with luarocks
12 if not softreq "luarocks.loader" then -- LuaRocks 2.x 12 if not softreq "luarocks.loader" then -- LuaRocks 2.x
13 softreq "luarocks.require"; -- LuaRocks <1.x 13 softreq "luarocks.require"; -- LuaRocks <1.x
14 end 14 end
15 15
16 local function missingdep(name, sources, msg) 16 local function missingdep(name, sources, msg, err) -- luacheck: ignore err
17 -- TODO print something about the underlying error, useful for debugging
17 print(""); 18 print("");
18 print("**************************"); 19 print("**************************");
19 print("Prosody was unable to find "..tostring(name)); 20 print("Prosody was unable to find "..tostring(name));
20 print("This package can be obtained in the following ways:"); 21 print("This package can be obtained in the following ways:");
21 print(""); 22 print("");
42 return false; 43 return false;
43 end 44 end
44 45
45 local fatal; 46 local fatal;
46 47
47 local lxp = softreq "lxp" 48 local lxp, err = softreq "lxp"
48 49
49 if not lxp then 50 if not lxp then
50 missingdep("luaexpat", { 51 missingdep("luaexpat", {
51 ["Debian/Ubuntu"] = "sudo apt-get install lua-expat"; 52 ["Debian/Ubuntu"] = "sudo apt-get install lua-expat";
52 ["luarocks"] = "luarocks install luaexpat"; 53 ["luarocks"] = "luarocks install luaexpat";
53 ["Source"] = "http://matthewwild.co.uk/projects/luaexpat/"; 54 ["Source"] = "http://matthewwild.co.uk/projects/luaexpat/";
54 }); 55 }, nil, err);
55 fatal = true; 56 fatal = true;
56 end 57 end
57 58
58 local socket = softreq "socket" 59 local socket, err = softreq "socket"
59 60
60 if not socket then 61 if not socket then
61 missingdep("luasocket", { 62 missingdep("luasocket", {
62 ["Debian/Ubuntu"] = "sudo apt-get install lua-socket"; 63 ["Debian/Ubuntu"] = "sudo apt-get install lua-socket";
63 ["luarocks"] = "luarocks install luasocket"; 64 ["luarocks"] = "luarocks install luasocket";
64 ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/"; 65 ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/";
65 }); 66 }, nil, err);
66 fatal = true; 67 fatal = true;
67 elseif not socket.tcp4 then 68 elseif not socket.tcp4 then
68 -- COMPAT LuaSocket before being IP-version agnostic 69 -- COMPAT LuaSocket before being IP-version agnostic
69 socket.tcp4 = socket.tcp; 70 socket.tcp4 = socket.tcp;
70 socket.udp4 = socket.udp; 71 socket.udp4 = socket.udp;
74 if not lfs then 75 if not lfs then
75 missingdep("luafilesystem", { 76 missingdep("luafilesystem", {
76 ["luarocks"] = "luarocks install luafilesystem"; 77 ["luarocks"] = "luarocks install luafilesystem";
77 ["Debian/Ubuntu"] = "sudo apt-get install lua-filesystem"; 78 ["Debian/Ubuntu"] = "sudo apt-get install lua-filesystem";
78 ["Source"] = "http://www.keplerproject.org/luafilesystem/"; 79 ["Source"] = "http://www.keplerproject.org/luafilesystem/";
79 }); 80 }, nil, err);
80 fatal = true; 81 fatal = true;
81 end 82 end
82 83
83 local ssl = softreq "ssl" 84 local ssl, err = softreq "ssl"
84 85
85 if not ssl then 86 if not ssl then
86 missingdep("LuaSec", { 87 missingdep("LuaSec", {
87 ["Debian/Ubuntu"] = "sudo apt-get install lua-sec"; 88 ["Debian/Ubuntu"] = "sudo apt-get install lua-sec";
88 ["luarocks"] = "luarocks install luasec"; 89 ["luarocks"] = "luarocks install luasec";
89 ["Source"] = "https://github.com/brunoos/luasec"; 90 ["Source"] = "https://github.com/brunoos/luasec";
90 }, "SSL/TLS support will not be available"); 91 }, "SSL/TLS support will not be available", err);
91 end 92 end
92 93
93 local bit = softreq"util.bitcompat"; 94 local bit, err = softreq"util.bitcompat";
94 95
95 if not bit then 96 if not bit then
96 missingdep("lua-bitops", { 97 missingdep("lua-bitops", {
97 ["Debian/Ubuntu"] = "sudo apt-get install lua-bitop"; 98 ["Debian/Ubuntu"] = "sudo apt-get install lua-bitop";
98 ["luarocks"] = "luarocks install luabitop"; 99 ["luarocks"] = "luarocks install luabitop";
99 ["Source"] = "http://bitop.luajit.org/"; 100 ["Source"] = "http://bitop.luajit.org/";
100 }, "WebSocket support will not be available"); 101 }, "WebSocket support will not be available", err);
101 end 102 end
102 103
103 local encodings, err = softreq "util.encodings" 104 local encodings, err = softreq "util.encodings"
104 if not encodings then 105 if not encodings then
105 if err:match("module '[^']*' not found") then 106 if err:match("module '[^']*' not found") then