diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2012-10-17 00:03:59 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-10-17 00:03:59 -0300 |
commit | 330ef7b69185a0e8a13edf6c2a401bd775567022 (patch) | |
tree | 7df3dbef475b16d51b0d0351f779da6f88f498aa /src | |
parent | d61ba8874d1e98892d12852852877ed7bf101383 (diff) | |
parent | 5c17b07c4d70d459d512cb10db233bbf847a44c1 (diff) | |
download | luarocks-330ef7b69185a0e8a13edf6c2a401bd775567022.tar.gz luarocks-330ef7b69185a0e8a13edf6c2a401bd775567022.tar.bz2 luarocks-330ef7b69185a0e8a13edf6c2a401bd775567022.zip |
Merge branch 'master' into multitree
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/cfg.lua | 3 | ||||
-rw-r--r-- | src/luarocks/download.lua | 2 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 10 | ||||
-rw-r--r-- | src/luarocks/fs/unix/tools.lua | 4 | ||||
-rw-r--r-- | src/luarocks/fs/win32/tools.lua | 4 | ||||
-rw-r--r-- | src/luarocks/repos.lua | 16 | ||||
-rw-r--r-- | src/luarocks/search.lua | 18 |
7 files changed, 18 insertions, 39 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index acf35793..136ea6be 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -26,7 +26,6 @@ _M.site_config = site_config | |||
26 | 26 | ||
27 | lua_version = _VERSION:sub(5) | 27 | lua_version = _VERSION:sub(5) |
28 | program_version = "2.0.11" | 28 | program_version = "2.0.11" |
29 | user_agent = "LuaRocks/"..program_version | ||
30 | 29 | ||
31 | local persist = require("luarocks.persist") | 30 | local persist = require("luarocks.persist") |
32 | 31 | ||
@@ -439,6 +438,8 @@ function which_config() | |||
439 | return sys_config_file, sys_config_ok, home_config_file, home_config_ok | 438 | return sys_config_file, sys_config_ok, home_config_file, home_config_ok |
440 | end | 439 | end |
441 | 440 | ||
441 | user_agent = "LuaRocks/"..program_version.." "..arch | ||
442 | |||
442 | --- Check if platform was detected | 443 | --- Check if platform was detected |
443 | -- @param query string: The platform name to check. | 444 | -- @param query string: The platform name to check. |
444 | -- @return boolean: true if LuaRocks is currently running on queried platform. | 445 | -- @return boolean: true if LuaRocks is currently running on queried platform. |
diff --git a/src/luarocks/download.lua b/src/luarocks/download.lua index 474e4d39..ae835bf2 100644 --- a/src/luarocks/download.lua +++ b/src/luarocks/download.lua | |||
@@ -24,7 +24,7 @@ function download(arch, name, version, all) | |||
24 | if arch then query.arch = arch end | 24 | if arch then query.arch = arch end |
25 | if all then | 25 | if all then |
26 | if name == "" then query.exact_name = false end | 26 | if name == "" then query.exact_name = false end |
27 | results, err = search.search_repos(query) | 27 | results = search.search_repos(query) |
28 | else | 28 | else |
29 | results, err = search.find_suitable_rock(query) | 29 | results, err = search.find_suitable_rock(query) |
30 | end | 30 | end |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index cd199fbb..d6795773 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -496,7 +496,15 @@ local function http_request(url, http, loop_control) | |||
496 | proxy = "http://" .. proxy | 496 | proxy = "http://" .. proxy |
497 | end | 497 | end |
498 | 498 | ||
499 | local res, status, headers, err = http.request { url = url, proxy = proxy, redirect = false, sink = ltn12.sink.table(result) } | 499 | local res, status, headers, err = http.request { |
500 | url = url, | ||
501 | proxy = proxy, | ||
502 | redirect = false, | ||
503 | sink = ltn12.sink.table(result), | ||
504 | headers = { | ||
505 | ["user-agent"] = cfg.user_agent.." via LuaSocket" | ||
506 | }, | ||
507 | } | ||
500 | if not res then | 508 | if not res then |
501 | return nil, status | 509 | return nil, status |
502 | elseif status == 301 or status == 302 then | 510 | elseif status == 301 or status == 302 then |
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index 7e29fc0a..3b853be7 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -237,7 +237,7 @@ function download(url, filename) | |||
237 | assert(type(filename) == "string" or not filename) | 237 | assert(type(filename) == "string" or not filename) |
238 | 238 | ||
239 | if cfg.downloader == "wget" then | 239 | if cfg.downloader == "wget" then |
240 | local wget_cmd = vars.WGET.." --no-check-certificate --no-cache --user-agent="..cfg.user_agent.." --quiet --continue " | 240 | local wget_cmd = vars.WGET.." --no-check-certificate --no-cache --user-agent='"..cfg.user_agent.." via wget' --quiet --continue " |
241 | if filename then | 241 | if filename then |
242 | return fs.execute(wget_cmd.." --output-document ", filename, url) | 242 | return fs.execute(wget_cmd.." --output-document ", filename, url) |
243 | else | 243 | else |
@@ -245,7 +245,7 @@ function download(url, filename) | |||
245 | end | 245 | end |
246 | elseif cfg.downloader == "curl" then | 246 | elseif cfg.downloader == "curl" then |
247 | filename = filename or dir.base_name(url) | 247 | filename = filename or dir.base_name(url) |
248 | return fs.execute_string(vars.CURL.." -L --user-agent "..cfg.user_agent.." "..fs.Q(url).." 2> /dev/null 1> "..fs.Q(filename)) | 248 | return fs.execute_string(vars.CURL.." -L --user-agent '"..cfg.user_agent.." via curl' "..fs.Q(url).." 2> /dev/null 1> "..fs.Q(filename)) |
249 | end | 249 | end |
250 | end | 250 | end |
251 | 251 | ||
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index 48eca64b..3e7ebd32 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua | |||
@@ -246,7 +246,7 @@ function download(url, filename) | |||
246 | assert(type(filename) == "string" or not filename) | 246 | assert(type(filename) == "string" or not filename) |
247 | 247 | ||
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.." --quiet --continue " | 249 | local wget_cmd = vars.WGET.." --no-check-certificate --no-cache --user-agent=\""..cfg.user_agent.." via wget\" --quiet --continue " |
250 | if filename then | 250 | if filename then |
251 | return fs.execute(wget_cmd.." --output-document ", filename, url) | 251 | return fs.execute(wget_cmd.." --output-document ", filename, url) |
252 | else | 252 | else |
@@ -254,7 +254,7 @@ function download(url, filename) | |||
254 | end | 254 | end |
255 | elseif cfg.downloader == "curl" then | 255 | elseif cfg.downloader == "curl" then |
256 | filename = filename or dir.base_name(url) | 256 | filename = filename or dir.base_name(url) |
257 | return fs.execute_string(vars.CURL.." -L --user-agent "..cfg.user_agent.." "..fs.Q(url).." 2> NUL 1> "..fs.Q(filename)) | 257 | return fs.execute_string(vars.CURL.." -L --user-agent \""..cfg.user_agent.." via curl\" "..fs.Q(url).." 2> NUL 1> "..fs.Q(filename)) |
258 | end | 258 | end |
259 | end | 259 | end |
260 | 260 | ||
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 3a337e7c..dc1b63c8 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
@@ -53,22 +53,6 @@ local function recurse_rock_manifest_tree(file_tree, action) | |||
53 | return do_recurse_rock_manifest_tree(file_tree, "", "") | 53 | return do_recurse_rock_manifest_tree(file_tree, "", "") |
54 | end | 54 | end |
55 | 55 | ||
56 | local function store_package_data(result, name, sub, prefix) | ||
57 | assert(type(result) == "table") | ||
58 | assert(type(name) == "string") | ||
59 | assert(type(sub) == "table" or type(sub) == "string") | ||
60 | assert(type(prefix) == "string") | ||
61 | |||
62 | if type(sub) == "table" then | ||
63 | for sname, ssub in pairs(sub) do | ||
64 | store_package_data(result, sname, ssub, prefix..name.."/") | ||
65 | end | ||
66 | elseif type(sub) == "string" then | ||
67 | local pathname = prefix..name | ||
68 | result[path.path_to_module(pathname)] = pathname | ||
69 | end | ||
70 | end | ||
71 | |||
72 | local function store_package_data(result, name, file_tree) | 56 | local function store_package_data(result, name, file_tree) |
73 | if not file_tree then return end | 57 | if not file_tree then return end |
74 | return recurse_rock_manifest_tree(file_tree, | 58 | return recurse_rock_manifest_tree(file_tree, |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index ec0fa69c..692004ae 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -185,10 +185,9 @@ end | |||
185 | 185 | ||
186 | --- Search on all configured rocks servers. | 186 | --- Search on all configured rocks servers. |
187 | -- @param query table: A dependency query. | 187 | -- @param query table: A dependency query. |
188 | -- @return table or (nil, string): A table where keys are package names | 188 | -- @return table: A table where keys are package names |
189 | -- and values are tables matching version strings to an array of | 189 | -- and values are tables matching version strings to an array of |
190 | -- rocks servers; if no results are found, an empty table is returned. | 190 | -- rocks servers; if no results are found, an empty table is returned. |
191 | -- In case of errors, nil and and error message are returned. | ||
192 | function search_repos(query) | 191 | function search_repos(query) |
193 | assert(type(query) == "table") | 192 | assert(type(query) == "table") |
194 | 193 | ||
@@ -269,10 +268,7 @@ end | |||
269 | function find_suitable_rock(query) | 268 | function find_suitable_rock(query) |
270 | assert(type(query) == "table") | 269 | assert(type(query) == "table") |
271 | 270 | ||
272 | local results, err = search_repos(query) | 271 | local results = search_repos(query) |
273 | if not results then | ||
274 | return nil, err | ||
275 | end | ||
276 | local first = next(results) | 272 | local first = next(results) |
277 | if not first then | 273 | if not first then |
278 | return nil, "No results matching query were found." | 274 | return nil, "No results matching query were found." |
@@ -349,13 +345,6 @@ function act_on_src_or_rockspec(action, name, version, ...) | |||
349 | local results, err = find_suitable_rock(query) | 345 | local results, err = find_suitable_rock(query) |
350 | if type(results) == "string" then | 346 | if type(results) == "string" then |
351 | return action(results, ...) | 347 | return action(results, ...) |
352 | elseif type(results) == "table" and next(results) then | ||
353 | util.printout("Multiple search results were returned.") | ||
354 | util.printout() | ||
355 | util.printout("Search results:") | ||
356 | util.printout("---------------") | ||
357 | print_results(results) | ||
358 | return nil, "Please narrow your query." | ||
359 | else | 348 | else |
360 | return nil, "Could not find a result named "..name..(version and " "..version or "").."." | 349 | return nil, "Could not find a result named "..name..(version and " "..version or "").."." |
361 | end | 350 | end |
@@ -380,9 +369,6 @@ function run(...) | |||
380 | local query = make_query(name:lower(), version) | 369 | local query = make_query(name:lower(), version) |
381 | query.exact_name = false | 370 | query.exact_name = false |
382 | local results, err = search_repos(query) | 371 | local results, err = search_repos(query) |
383 | if not results then | ||
384 | return nil, err | ||
385 | end | ||
386 | util.printout() | 372 | util.printout() |
387 | util.printout("Search results:") | 373 | util.printout("Search results:") |
388 | util.printout("===============") | 374 | util.printout("===============") |