diff options
Diffstat (limited to '')
-rw-r--r-- | src/luarocks/cfg.lua | 1 | ||||
-rw-r--r-- | src/luarocks/command_line.lua | 9 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 3 | ||||
-rw-r--r-- | src/luarocks/fs/unix/tools.lua | 17 | ||||
-rw-r--r-- | src/luarocks/fs/win32/tools.lua | 15 | ||||
-rw-r--r-- | src/luarocks/help.lua | 5 |
6 files changed, 40 insertions, 10 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 97b6a09e..693cdbdb 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -227,6 +227,7 @@ local defaults = { | |||
227 | lua_interpreter = site_config.LUA_INTERPRETER or "lua", | 227 | lua_interpreter = site_config.LUA_INTERPRETER or "lua", |
228 | downloader = site_config.LUAROCKS_DOWNLOADER or "wget", | 228 | downloader = site_config.LUAROCKS_DOWNLOADER or "wget", |
229 | md5checker = site_config.LUAROCKS_MD5CHECKER or "md5sum", | 229 | md5checker = site_config.LUAROCKS_MD5CHECKER or "md5sum", |
230 | connection_timeout = 30, -- 0 = no timeout | ||
230 | 231 | ||
231 | variables = { | 232 | variables = { |
232 | MAKE = "make", | 233 | MAKE = "make", |
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 3cde4c41..cc2e1683 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
@@ -83,6 +83,15 @@ function command_line.run_command(...) | |||
83 | fs.verbose() | 83 | fs.verbose() |
84 | end | 84 | end |
85 | 85 | ||
86 | if flags["timeout"] then -- setting it in the config file will kick-in earlier in the process | ||
87 | local timeout = tonumber(flags["timeout"]) | ||
88 | if timeout then | ||
89 | cfg.connection_timeout = timeout | ||
90 | else | ||
91 | die "Argument error: --timeout expects a numeric argument." | ||
92 | end | ||
93 | end | ||
94 | |||
86 | if flags["version"] then | 95 | if flags["version"] then |
87 | util.printout(program.." "..cfg.program_version) | 96 | util.printout(program.." "..cfg.program_version) |
88 | util.printout(program_description) | 97 | util.printout(program_description) |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index cd705eef..f18deac3 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -551,6 +551,9 @@ local function request(url, method, http, loop_control) | |||
551 | io.write(method.." "..url.." ...\n") | 551 | io.write(method.." "..url.." ...\n") |
552 | end | 552 | end |
553 | local dots = 0 | 553 | local dots = 0 |
554 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | ||
555 | http.TIMEOUT = cfg.connection_timeout | ||
556 | end | ||
554 | local res, status, headers, err = http.request { | 557 | local res, status, headers, err = http.request { |
555 | url = url, | 558 | url = url, |
556 | proxy = proxy, | 559 | proxy = proxy, |
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index d381b8d9..f8f39eca 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -246,20 +246,27 @@ function tools.download(url, filename, cache) | |||
246 | 246 | ||
247 | local ok | 247 | local ok |
248 | if cfg.downloader == "wget" then | 248 | if cfg.downloader == "wget" then |
249 | local wget_cmd = vars.WGET.." --no-check-certificate --no-cache --user-agent='"..cfg.user_agent.." via wget' --quiet " | 249 | local wget_cmd = fs.Q(vars.WGET).." --no-check-certificate --no-cache --user-agent='"..cfg.user_agent.." via wget' --quiet " |
250 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | ||
251 | wget_cmd = wget_cmd .. "--timeout="..tonumber(cfg.connection_timeout).." --tries=1 " | ||
252 | end | ||
250 | if cache then | 253 | if cache then |
251 | -- --timestamping is incompatible with --output-document, | 254 | -- --timestamping is incompatible with --output-document, |
252 | -- but that's not a problem for our use cases. | 255 | -- but that's not a problem for our use cases. |
253 | fs.change_dir(dir.dir_name(filename)) | 256 | fs.change_dir(dir.dir_name(filename)) |
254 | ok = fs.execute(wget_cmd.." --timestamping ", url) | 257 | ok = fs.execute_quiet(wget_cmd.." --timestamping ", url) |
255 | fs.pop_dir() | 258 | fs.pop_dir() |
256 | elseif filename then | 259 | elseif filename then |
257 | ok = fs.execute(wget_cmd.." --output-document "..fs.Q(filename), url) | 260 | ok = fs.execute_quiet(wget_cmd.." --output-document ", filename, url) |
258 | else | 261 | else |
259 | ok = fs.execute(wget_cmd, url) | 262 | ok = fs.execute_quiet(wget_cmd, url) |
260 | end | 263 | end |
261 | elseif cfg.downloader == "curl" then | 264 | elseif cfg.downloader == "curl" then |
262 | ok = fs.execute_string(vars.CURL.." -f -L --user-agent '"..cfg.user_agent.." via curl' "..fs.Q(url).." 2> /dev/null 1> "..fs.Q(filename)) | 265 | local curl_cmd = fs.Q(vars.CURL).." -f -k -L --user-agent '"..cfg.user_agent.." via curl' " |
266 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | ||
267 | curl_cmd = curl_cmd .. "--connect-timeout="..tonumber(cfg.connection_timeout).." " | ||
268 | end | ||
269 | ok = fs.execute_string(curl_cmd..fs.Q(url).." 2> /dev/null 1> "..fs.Q(filename)) | ||
263 | end | 270 | end |
264 | if ok then | 271 | if ok then |
265 | return true, filename | 272 | return true, filename |
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index bd7ba086..21d846b9 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua | |||
@@ -257,19 +257,26 @@ function tools.download(url, filename, cache) | |||
257 | local ok | 257 | local ok |
258 | if cfg.downloader == "wget" then | 258 | if cfg.downloader == "wget" then |
259 | local wget_cmd = fs.Q(vars.WGET).." --no-check-certificate --no-cache --user-agent=\""..cfg.user_agent.." via wget\" --quiet " | 259 | local wget_cmd = fs.Q(vars.WGET).." --no-check-certificate --no-cache --user-agent=\""..cfg.user_agent.." via wget\" --quiet " |
260 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | ||
261 | wget_cmd = wget_cmd .. "--timeout="..tonumber(cfg.connection_timeout).." --tries=1 " | ||
262 | end | ||
260 | if cache then | 263 | if cache then |
261 | -- --timestamping is incompatible with --output-document, | 264 | -- --timestamping is incompatible with --output-document, |
262 | -- but that's not a problem for our use cases. | 265 | -- but that's not a problem for our use cases. |
263 | fs.change_dir(dir.dir_name(filename)) | 266 | fs.change_dir(dir.dir_name(filename)) |
264 | ok = fs.execute(wget_cmd.." --timestamping "..fs.Q(url).." 2> NUL 1> NUL") | 267 | ok = fs.execute_quiet(wget_cmd.." --timestamping ", url) |
265 | fs.pop_dir() | 268 | fs.pop_dir() |
266 | elseif filename then | 269 | elseif filename then |
267 | ok = fs.execute(wget_cmd.." --output-document "..fs.Q(filename).." "..fs.Q(url).." 2> NUL 1> NUL") | 270 | ok = fs.execute_quiet(wget_cmd.." --output-document ", filename, url) |
268 | else | 271 | else |
269 | ok = fs.execute(wget_cmd..fs.Q(url).." 2> NUL 1> NUL") | 272 | ok = fs.execute_quiet(wget_cmd, url) |
270 | end | 273 | end |
271 | elseif cfg.downloader == "curl" then | 274 | elseif cfg.downloader == "curl" then |
272 | ok = fs.execute_string(fs.Q(vars.CURL).." -f -L --user-agent \""..cfg.user_agent.." via curl\" "..fs.Q(url).." 2> NUL 1> "..fs.Q(filename)) | 275 | local curl_cmd = vars.CURL.." -f -k -L --user-agent \""..cfg.user_agent.." via curl\" " |
276 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | ||
277 | curl_cmd = curl_cmd .. "--connect-timeout="..tonumber(cfg.connection_timeout).." " | ||
278 | end | ||
279 | ok = fs.execute_string(curl_cmd..fs.Q(url).." 2> NUL 1> "..fs.Q(filename)) | ||
273 | end | 280 | end |
274 | if ok then | 281 | if ok then |
275 | return true, filename | 282 | return true, filename |
diff --git a/src/luarocks/help.lua b/src/luarocks/help.lua index 3e428a4a..0a155509 100644 --- a/src/luarocks/help.lua +++ b/src/luarocks/help.lua | |||
@@ -66,7 +66,10 @@ function help.run(...) | |||
66 | --tree=<tree> Which tree to operate on. | 66 | --tree=<tree> Which tree to operate on. |
67 | --local Use the tree in the user's home directory. | 67 | --local Use the tree in the user's home directory. |
68 | To enable it, see ']]..program..[[ help path'. | 68 | To enable it, see ']]..program..[[ help path'. |
69 | --verbose Display verbose output of commands executed.]]) | 69 | --verbose Display verbose output of commands executed. |
70 | --timeout=<seconds> Timeout on network operations, in seconds. | ||
71 | 0 means no timeout (wait forever). | ||
72 | Default is ]]..cfg.connection_timeout..[[.]]) | ||
70 | print_section("VARIABLES") | 73 | print_section("VARIABLES") |
71 | util.printout([[ | 74 | util.printout([[ |
72 | Variables from the "variables" table of the configuration file | 75 | Variables from the "variables" table of the configuration file |