diff options
| -rw-r--r-- | src/luarocks/fs/tools.lua | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/luarocks/fs/tools.lua b/src/luarocks/fs/tools.lua index b7d03759..b20d577d 100644 --- a/src/luarocks/fs/tools.lua +++ b/src/luarocks/fs/tools.lua | |||
| @@ -13,10 +13,15 @@ local dir_stack = {} | |||
| 13 | do | 13 | do |
| 14 | local tool_cache = {} | 14 | local tool_cache = {} |
| 15 | 15 | ||
| 16 | local function wget_is_compatible() | ||
| 17 | -- busybox wget is incompatible and does not support -V | ||
| 18 | return fs.execute_quiet(vars.WGET .. " -V") | ||
| 19 | end | ||
| 20 | |||
| 16 | local tool_options = { | 21 | local tool_options = { |
| 17 | downloader = { | 22 | downloader = { |
| 18 | desc = "downloader", | 23 | desc = "downloader", |
| 19 | { var = "WGET", name = "wget" }, | 24 | { var = "WGET", name = "wget", check_compat = wget_is_compatible }, |
| 20 | { var = "CURL", name = "curl" }, | 25 | { var = "CURL", name = "curl" }, |
| 21 | }, | 26 | }, |
| 22 | md5checker = { | 27 | md5checker = { |
| @@ -27,13 +32,23 @@ do | |||
| 27 | }, | 32 | }, |
| 28 | } | 33 | } |
| 29 | 34 | ||
| 35 | local function is_available(opt) | ||
| 36 | if not fs.is_tool_available(vars[opt.var], opt.name) then | ||
| 37 | return false | ||
| 38 | end | ||
| 39 | if opt.check_compat then | ||
| 40 | return opt.check_compat() | ||
| 41 | end | ||
| 42 | return true | ||
| 43 | end | ||
| 44 | |||
| 30 | function tools.which_tool(tooltype) | 45 | function tools.which_tool(tooltype) |
| 31 | local tool = tool_cache[tooltype] | 46 | local tool = tool_cache[tooltype] |
| 32 | local names = {} | 47 | local names = {} |
| 33 | if not tool then | 48 | if not tool then |
| 34 | for _, opt in ipairs(tool_options[tooltype]) do | 49 | for _, opt in ipairs(tool_options[tooltype]) do |
| 35 | table.insert(names, opt.name) | 50 | table.insert(names, opt.name) |
| 36 | if fs.is_tool_available(vars[opt.var], opt.name) then | 51 | if is_available(opt) then |
| 37 | tool = opt | 52 | tool = opt |
| 38 | tool_cache[tooltype] = opt | 53 | tool_cache[tooltype] = opt |
| 39 | break | 54 | break |
