diff options
-rwxr-xr-x | src/bin/luarocks | 2 | ||||
-rw-r--r-- | src/luarocks/download.lua (renamed from src/luarocks/get_rockspec.lua) | 40 |
2 files changed, 23 insertions, 19 deletions
diff --git a/src/bin/luarocks b/src/bin/luarocks index 2e2ac422..80b53dee 100755 --- a/src/bin/luarocks +++ b/src/bin/luarocks | |||
@@ -15,6 +15,6 @@ commands.search = require("luarocks.search") | |||
15 | commands.list = require("luarocks.list") | 15 | commands.list = require("luarocks.list") |
16 | commands.remove = require("luarocks.remove") | 16 | commands.remove = require("luarocks.remove") |
17 | commands.make = require("luarocks.make") | 17 | commands.make = require("luarocks.make") |
18 | commands.get_rockspec = require("luarocks.get_rockspec") | 18 | commands.download = require("luarocks.download") |
19 | 19 | ||
20 | command_line.run_command(...) | 20 | command_line.run_command(...) |
diff --git a/src/luarocks/get_rockspec.lua b/src/luarocks/download.lua index 77fb6d21..5dc393d6 100644 --- a/src/luarocks/get_rockspec.lua +++ b/src/luarocks/download.lua | |||
@@ -1,29 +1,28 @@ | |||
1 | 1 | ||
2 | --- Module implementing the luarocks "get_rockspec" command. | 2 | --- Module implementing the luarocks "download" command. |
3 | -- Download a rockspec from the repository. | 3 | -- Download a rock from the repository. |
4 | module("luarocks.get_rockspec", package.seeall) | 4 | module("luarocks.download", package.seeall) |
5 | 5 | ||
6 | local util = require("luarocks.util") | 6 | local util = require("luarocks.util") |
7 | local path = require("luarocks.path") | 7 | local path = require("luarocks.path") |
8 | local fetch = require("luarocks.fetch") | 8 | local fetch = require("luarocks.fetch") |
9 | local search = require("luarocks.search") | 9 | local search = require("luarocks.search") |
10 | 10 | ||
11 | help_summary = "Download a specific rockspec file from a rocks server." | 11 | help_summary = "Download a specific rock file from a rocks server." |
12 | help_arguments = "[--all] [<name> [<version>]]" | 12 | help_arguments = "[--all] [--source] [--arch=<arch>] [<name> [<version>]]" |
13 | 13 | ||
14 | help = [[ | 14 | help = [[ |
15 | --all Download multiple rockspec files if there is more than one match. | 15 | --all Download multiple rock files if there is more than one match. |
16 | --source Download .src.rock if available. | ||
17 | --arch=<arch> Download rock for a specific architecture. | ||
16 | ]] | 18 | ]] |
17 | 19 | ||
18 | local function get_rockspec(rockspec_file) | 20 | local function download(rock_file) |
19 | local rockspec = fetch.load_rockspec(rockspec_file, ".") | 21 | local rock = fetch.fetch_url(rock_file) |
20 | if not rockspec then | 22 | return rock ~= nil |
21 | return nil, "Failed loading rockspec "..rockspec_file | ||
22 | end | ||
23 | return true | ||
24 | end | 23 | end |
25 | 24 | ||
26 | --- Driver function for the "get_rockspec" command. | 25 | --- Driver function for the "download" command. |
27 | -- @param name string: a rock name. | 26 | -- @param name string: a rock name. |
28 | -- @param version string or nil: if the name of a package is given, a | 27 | -- @param version string or nil: if the name of a package is given, a |
29 | -- version may also be passed. | 28 | -- version may also be passed. |
@@ -39,17 +38,22 @@ function run(...) | |||
39 | if not name then name, version = "", "" end | 38 | if not name then name, version = "", "" end |
40 | 39 | ||
41 | local query = search.make_query(name, version) | 40 | local query = search.make_query(name, version) |
42 | query.arch = "rockspec" | 41 | if flags["source"] then |
42 | query.arch = "src" | ||
43 | elseif flags["rockspec"] then | ||
44 | query.arch = "rockspec" | ||
45 | elseif flags["arch"] then | ||
46 | query.arch = flags["arch"] | ||
47 | end | ||
43 | local results, err | 48 | local results, err |
44 | if flags["all"] then | 49 | if flags["all"] then |
45 | if name == "" then query.exact_name = false end | 50 | if name == "" then query.exact_name = false end |
46 | results, err = search.search_repos(query) | 51 | results, err = search.search_repos(query) |
47 | print(results, err) | ||
48 | else | 52 | else |
49 | results, err = search.find_suitable_rock(query) | 53 | results, err = search.find_suitable_rock(query) |
50 | end | 54 | end |
51 | if type(results) == "string" then | 55 | if type(results) == "string" then |
52 | return get_rockspec(results) | 56 | return download(results) |
53 | elseif type(results) == "table" and next(results) then | 57 | elseif type(results) == "table" and next(results) then |
54 | if flags["all"] then | 58 | if flags["all"] then |
55 | local all_ok = true | 59 | local all_ok = true |
@@ -58,7 +62,7 @@ function run(...) | |||
58 | for version, versions in pairs(result) do | 62 | for version, versions in pairs(result) do |
59 | for _,items in pairs(versions) do | 63 | for _,items in pairs(versions) do |
60 | local filename = path.make_url(items.repo, name, version, items.arch) | 64 | local filename = path.make_url(items.repo, name, version, items.arch) |
61 | local ok, err = get_rockspec(filename) | 65 | local ok, err = download(filename) |
62 | if not ok then | 66 | if not ok then |
63 | all_ok = false | 67 | all_ok = false |
64 | any_err = any_err .. "\n" .. err | 68 | any_err = any_err .. "\n" .. err |
@@ -76,6 +80,6 @@ function run(...) | |||
76 | return nil, "Please narrow your query or use --all." | 80 | return nil, "Please narrow your query or use --all." |
77 | end | 81 | end |
78 | else | 82 | else |
79 | return nil, "Could not find a result named "..name.."." | 83 | return nil, "Could not find a result named "..name..(version and " "..version or "").."." |
80 | end | 84 | end |
81 | end | 85 | end |