diff options
author | hisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c> | 2009-04-23 18:56:38 +0000 |
---|---|---|
committer | hisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c> | 2009-04-23 18:56:38 +0000 |
commit | 08df24ac4f1ac5ef3b5bb59629e65e4b90b2a51d (patch) | |
tree | 6de5c006b1d2c29fc98ffd7815a6d8ddee7d4917 | |
parent | 940d5b91d3372c46b690027e14af85f41c0cffd8 (diff) | |
download | luarocks-08df24ac4f1ac5ef3b5bb59629e65e4b90b2a51d.tar.gz luarocks-08df24ac4f1ac5ef3b5bb59629e65e4b90b2a51d.tar.bz2 luarocks-08df24ac4f1ac5ef3b5bb59629e65e4b90b2a51d.zip |
LuaRocks can now use itself to load its own dependencies!
git-svn-id: http://luarocks.org/svn/luarocks/trunk@13 9ca3f7c1-7366-0410-b1a3-b5c78f85698c
-rwxr-xr-x | src/bin/luarocks | 2 | ||||
-rw-r--r-- | src/luarocks.lua | 13 | ||||
-rw-r--r-- | src/luarocks/command_line.lua | 2 | ||||
-rw-r--r-- | src/luarocks/deps.lua | 9 | ||||
-rw-r--r-- | src/luarocks/dir.lua | 16 | ||||
-rw-r--r-- | src/luarocks/fetch.lua | 6 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 19 | ||||
-rw-r--r-- | src/luarocks/fs/unix.lua | 19 | ||||
-rw-r--r-- | src/luarocks/manif.lua | 2 | ||||
-rw-r--r-- | src/luarocks/path.lua | 1 | ||||
-rw-r--r-- | src/luarocks/require.lua | 6 | ||||
-rw-r--r-- | src/luarocks/search.lua | 6 | ||||
-rw-r--r-- | src/luarocks/validate.lua | 2 |
13 files changed, 42 insertions, 61 deletions
diff --git a/src/bin/luarocks b/src/bin/luarocks index 8812ecc8..ae0c2b42 100755 --- a/src/bin/luarocks +++ b/src/bin/luarocks | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/usr/bin/env lua | 1 | #!/usr/bin/lua |
2 | 2 | ||
3 | local command_line = require("luarocks.command_line") | 3 | local command_line = require("luarocks.command_line") |
4 | 4 | ||
diff --git a/src/luarocks.lua b/src/luarocks.lua index fad62e07..aef93363 100644 --- a/src/luarocks.lua +++ b/src/luarocks.lua | |||
@@ -61,17 +61,16 @@ local function add_context(name, version, manifest) | |||
61 | for _, dep in ipairs(pkgdeps) do | 61 | for _, dep in ipairs(pkgdeps) do |
62 | local package, constraints = dep.name, dep.constraints | 62 | local package, constraints = dep.name, dep.constraints |
63 | 63 | ||
64 | for _, tree in pairs(rocks_trees) do do | 64 | for _, tree in pairs(rocks_trees) do |
65 | local entries = tree.manifest.repository[package] | 65 | local entries = tree.manifest.repository[package] |
66 | if entries then | 66 | if entries then |
67 | break -- continue for | 67 | for version, packages in pairs(entries) do |
68 | end | 68 | if (not constraints) or deps.match_constraints(deps.parse_version(version), constraints) then |
69 | for version, packages in pairs(entries) do | 69 | add_context(package, version, tree.manifest) |
70 | if (not constraints) or deps.match_constraints(deps.parse_version(version), constraints) then | 70 | end |
71 | add_context(package, version, tree.manifest) | ||
72 | end | 71 | end |
73 | end | 72 | end |
74 | end end | 73 | end |
75 | end | 74 | end |
76 | end | 75 | end |
77 | 76 | ||
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 9688343e..9368e8ad 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
@@ -76,7 +76,7 @@ function run_command(...) | |||
76 | if flags["from"] == true then | 76 | if flags["from"] == true then |
77 | die("Argument error: use --from=<url>") | 77 | die("Argument error: use --from=<url>") |
78 | end | 78 | end |
79 | local protocol, path = fs.split_url(flags["from"]) | 79 | local protocol, path = dir.split_url(flags["from"]) |
80 | table.insert(cfg.rocks_servers, 1, protocol.."://"..path) | 80 | table.insert(cfg.rocks_servers, 1, protocol.."://"..path) |
81 | end | 81 | end |
82 | 82 | ||
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index d7d6e103..7ad0b23e 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -13,12 +13,8 @@ | |||
13 | -- insights on what these criteria are. | 13 | -- insights on what these criteria are. |
14 | module("luarocks.deps", package.seeall) | 14 | module("luarocks.deps", package.seeall) |
15 | 15 | ||
16 | local rep = require("luarocks.rep") | ||
17 | local search = require("luarocks.search") | ||
18 | local install = require("luarocks.install") | ||
19 | local cfg = require("luarocks.cfg") | 16 | local cfg = require("luarocks.cfg") |
20 | local manif_core = require("luarocks.manif_core") | 17 | local manif_core = require("luarocks.manif_core") |
21 | local fetch = require("luarocks.fetch") | ||
22 | local path = require("luarocks.path") | 18 | local path = require("luarocks.path") |
23 | local dir = require("luarocks.dir") | 19 | local dir = require("luarocks.dir") |
24 | 20 | ||
@@ -404,6 +400,9 @@ end | |||
404 | -- error code. | 400 | -- error code. |
405 | function fulfill_dependencies(rockspec) | 401 | function fulfill_dependencies(rockspec) |
406 | 402 | ||
403 | local search = require("luarocks.search") | ||
404 | local install = require("luarocks.install") | ||
405 | |||
407 | if rockspec.supported_platforms then | 406 | if rockspec.supported_platforms then |
408 | if not platforms_set then | 407 | if not platforms_set then |
409 | platforms_set = values_set(cfg.platforms) | 408 | platforms_set = values_set(cfg.platforms) |
@@ -588,6 +587,8 @@ function scan_deps(results, missing, manifest, name, version) | |||
588 | assert(type(name) == "string") | 587 | assert(type(name) == "string") |
589 | assert(type(version) == "string") | 588 | assert(type(version) == "string") |
590 | 589 | ||
590 | local fetch = require("luarocks.fetch") | ||
591 | |||
591 | local err | 592 | local err |
592 | if results[name] then | 593 | if results[name] then |
593 | return results, missing | 594 | return results, missing |
diff --git a/src/luarocks/dir.lua b/src/luarocks/dir.lua index 5cb3b846..38bb49d2 100644 --- a/src/luarocks/dir.lua +++ b/src/luarocks/dir.lua | |||
@@ -45,3 +45,19 @@ function path(...) | |||
45 | end | 45 | end |
46 | return table.concat(items, "/") | 46 | return table.concat(items, "/") |
47 | end | 47 | end |
48 | |||
49 | --- Split protocol and path from an URL or local pathname. | ||
50 | -- URLs should be in the "protocol://path" format. | ||
51 | -- For local pathnames, "file" is returned as the protocol. | ||
52 | -- @param url string: an URL or a local pathname. | ||
53 | -- @return string, string: the protocol, and the absolute pathname without the protocol. | ||
54 | function split_url(url) | ||
55 | assert(type(url) == "string") | ||
56 | |||
57 | local protocol, pathname = url:match("^([^:]*)://(.*)") | ||
58 | if not protocol then | ||
59 | protocol = "file" | ||
60 | pathname = url | ||
61 | end | ||
62 | return protocol, pathname | ||
63 | end | ||
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 5b2d20cb..57e641cf 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua | |||
@@ -26,7 +26,7 @@ function fetch_url(url, filename) | |||
26 | assert(type(url) == "string") | 26 | assert(type(url) == "string") |
27 | assert(type(filename) == "string" or not filename) | 27 | assert(type(filename) == "string" or not filename) |
28 | 28 | ||
29 | local protocol, pathname = fs.split_url(url) | 29 | local protocol, pathname = dir.split_url(url) |
30 | if protocol == "file" then | 30 | if protocol == "file" then |
31 | return fs.absolute_name(pathname) | 31 | return fs.absolute_name(pathname) |
32 | elseif protocol == "http" or protocol == "ftp" or protocol == "https" then | 32 | elseif protocol == "http" or protocol == "ftp" or protocol == "https" then |
@@ -57,7 +57,7 @@ function fetch_url_at_temp_dir(url, tmpname, filename) | |||
57 | assert(type(filename) == "string" or not filename) | 57 | assert(type(filename) == "string" or not filename) |
58 | filename = filename or dir.base_name(url) | 58 | filename = filename or dir.base_name(url) |
59 | 59 | ||
60 | local protocol, pathname = fs.split_url(url) | 60 | local protocol, pathname = dir.split_url(url) |
61 | if protocol == "file" then | 61 | if protocol == "file" then |
62 | return pathname, dir.dir_name(pathname) | 62 | return pathname, dir.dir_name(pathname) |
63 | else | 63 | else |
@@ -151,7 +151,7 @@ function load_local_rockspec(filename) | |||
151 | return nil, "Expected filename in format 'name-version-revision.rockspec'." | 151 | return nil, "Expected filename in format 'name-version-revision.rockspec'." |
152 | end | 152 | end |
153 | 153 | ||
154 | local protocol, pathname = fs.split_url(rockspec.source.url) | 154 | local protocol, pathname = dir.split_url(rockspec.source.url) |
155 | if protocol == "http" or protocol == "https" or protocol == "ftp" or protocol == "file" then | 155 | if protocol == "http" or protocol == "https" or protocol == "ftp" or protocol == "file" then |
156 | rockspec.source.file = rockspec.source.file or dir.base_name(rockspec.source.url) | 156 | rockspec.source.file = rockspec.source.file or dir.base_name(rockspec.source.url) |
157 | end | 157 | end |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 9f9a4b63..80a4c2fd 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -74,25 +74,6 @@ function make_temp_dir(name) | |||
74 | end | 74 | end |
75 | end | 75 | end |
76 | 76 | ||
77 | --- Split protocol and path from an URL or local pathname. | ||
78 | -- URLs should be in the "protocol://path" format. | ||
79 | -- For local pathnames, "file" is returned as the protocol. | ||
80 | -- @param url string: an URL or a local pathname. | ||
81 | -- @return string, string: the protocol, and the absolute pathname without the protocol. | ||
82 | function split_url(url) | ||
83 | assert(type(url) == "string") | ||
84 | |||
85 | local protocol, pathname = url:match("^([^:]*)://(.*)") | ||
86 | if not protocol then | ||
87 | protocol = "file" | ||
88 | pathname = url | ||
89 | end | ||
90 | if protocol == "file" then | ||
91 | pathname = fs.absolute_name(pathname) | ||
92 | end | ||
93 | return protocol, pathname | ||
94 | end | ||
95 | |||
96 | --- Run the given command, quoting its arguments. | 77 | --- Run the given command, quoting its arguments. |
97 | -- The command is executed in the current directory in the dir stack. | 78 | -- The command is executed in the current directory in the dir stack. |
98 | -- @param command string: The command to be executed. No quoting/escaping | 79 | -- @param command string: The command to be executed. No quoting/escaping |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index dba152ef..0e91eea0 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
@@ -31,25 +31,6 @@ function absolute_name(pathname, relative_to) | |||
31 | end | 31 | end |
32 | end | 32 | end |
33 | 33 | ||
34 | --- Split protocol and path from an URL or local pathname. | ||
35 | -- URLs should be in the "protocol://path" format. | ||
36 | -- For local pathnames, "file" is returned as the protocol. | ||
37 | -- @param url string: an URL or a local pathname. | ||
38 | -- @return string, string: the protocol, and the absolute pathname without the protocol. | ||
39 | function split_url(url) | ||
40 | assert(type(url) == "string") | ||
41 | |||
42 | local protocol, pathname = url:match("^([^:]*)://(.*)") | ||
43 | if not protocol then | ||
44 | protocol = "file" | ||
45 | pathname = url | ||
46 | end | ||
47 | if protocol == "file" then | ||
48 | pathname = fs.absolute_name(pathname) | ||
49 | end | ||
50 | return protocol, pathname | ||
51 | end | ||
52 | |||
53 | --- Create a wrapper to make a script executable from the command-line. | 34 | --- Create a wrapper to make a script executable from the command-line. |
54 | -- @param file string: Pathname of script to be made executable. | 35 | -- @param file string: Pathname of script to be made executable. |
55 | -- @param dest string: Directory where to put the wrapper. | 36 | -- @param dest string: Directory where to put the wrapper. |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 3e5790ae..f9c53d4f 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -26,7 +26,7 @@ function load_manifest(repo_url) | |||
26 | return manif_core.manifest_cache[repo_url] | 26 | return manif_core.manifest_cache[repo_url] |
27 | end | 27 | end |
28 | 28 | ||
29 | local protocol, pathname = fs.split_url(repo_url) | 29 | local protocol, pathname = dir.split_url(repo_url) |
30 | if protocol == "file" then | 30 | if protocol == "file" then |
31 | pathname = dir.path(pathname, "manifest") | 31 | pathname = dir.path(pathname, "manifest") |
32 | else | 32 | else |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index ae9c7fae..c9085431 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -222,3 +222,4 @@ function configure_paths(rockspec) | |||
222 | vars.DOCDIR = doc_dir(name, version) | 222 | vars.DOCDIR = doc_dir(name, version) |
223 | rockspec.variables = vars | 223 | rockspec.variables = vars |
224 | end | 224 | end |
225 | |||
diff --git a/src/luarocks/require.lua b/src/luarocks/require.lua index 21d6511a..7d083fca 100644 --- a/src/luarocks/require.lua +++ b/src/luarocks/require.lua | |||
@@ -13,7 +13,7 @@ local package, assert, ipairs, pairs, os, print, table, type, next = | |||
13 | module("luarocks.require") | 13 | module("luarocks.require") |
14 | 14 | ||
15 | local path = plain_require("luarocks.path") | 15 | local path = plain_require("luarocks.path") |
16 | local manif = plain_require("luarocks.manif_core") | 16 | local manif_core = plain_require("luarocks.manif_core") |
17 | local deps = plain_require("luarocks.deps") | 17 | local deps = plain_require("luarocks.deps") |
18 | local cfg = plain_require("luarocks.cfg") | 18 | local cfg = plain_require("luarocks.cfg") |
19 | 19 | ||
@@ -29,7 +29,7 @@ local function load_rocks_trees() | |||
29 | local trees = {} | 29 | local trees = {} |
30 | for _, tree in pairs(cfg.rocks_trees) do | 30 | for _, tree in pairs(cfg.rocks_trees) do |
31 | local rocks_dir = tree .. "/rocks/" | 31 | local rocks_dir = tree .. "/rocks/" |
32 | local manifest, err = manif.load_local_manifest(rocks_dir) | 32 | local manifest, err = manif_core.load_local_manifest(rocks_dir) |
33 | if manifest then | 33 | if manifest then |
34 | any_ok = true | 34 | any_ok = true |
35 | table.insert(trees, {rocks_dir=rocks_dir, manifest=manifest}) | 35 | table.insert(trees, {rocks_dir=rocks_dir, manifest=manifest}) |
@@ -115,7 +115,7 @@ function set_context(name, version) | |||
115 | break | 115 | break |
116 | end | 116 | end |
117 | else | 117 | else |
118 | local versions = manif.get_versions(name, tree.manifest) | 118 | local versions = manif_core.get_versions(name, tree.manifest) |
119 | for _, version in ipairs(versions) do | 119 | for _, version in ipairs(versions) do |
120 | table.insert(vtables, {version = deps.parse_version(version), manifest = tree.manifest}) | 120 | table.insert(vtables, {version = deps.parse_version(version), manifest = tree.manifest}) |
121 | end | 121 | end |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index eae3809f..20aea970 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -3,7 +3,6 @@ | |||
3 | -- Queries LuaRocks servers. | 3 | -- Queries LuaRocks servers. |
4 | module("luarocks.search", package.seeall) | 4 | module("luarocks.search", package.seeall) |
5 | 5 | ||
6 | local fs = require("luarocks.fs") | ||
7 | local dir = require("luarocks.dir") | 6 | local dir = require("luarocks.dir") |
8 | local path = require("luarocks.path") | 7 | local path = require("luarocks.path") |
9 | local manif = require("luarocks.manif") | 8 | local manif = require("luarocks.manif") |
@@ -129,6 +128,9 @@ function disk_search(repo, query, results) | |||
129 | assert(type(repo) == "string") | 128 | assert(type(repo) == "string") |
130 | assert(type(query) == "table") | 129 | assert(type(query) == "table") |
131 | assert(type(results) == "table" or not results) | 130 | assert(type(results) == "table" or not results) |
131 | |||
132 | local fs = require("luarocks.fs") | ||
133 | |||
132 | if not results then | 134 | if not results then |
133 | results = {} | 135 | results = {} |
134 | end | 136 | end |
@@ -194,7 +196,7 @@ local function search_repos(query) | |||
194 | 196 | ||
195 | local results = {} | 197 | local results = {} |
196 | for _, repo in ipairs(cfg.rocks_servers) do | 198 | for _, repo in ipairs(cfg.rocks_servers) do |
197 | local protocol, pathname = fs.split_url(repo) | 199 | local protocol, pathname = dir.split_url(repo) |
198 | if protocol == "file" then | 200 | if protocol == "file" then |
199 | repo = pathname | 201 | repo = pathname |
200 | end | 202 | end |
diff --git a/src/luarocks/validate.lua b/src/luarocks/validate.lua index 1bf001c7..36163afe 100644 --- a/src/luarocks/validate.lua +++ b/src/luarocks/validate.lua | |||
@@ -15,7 +15,7 @@ help = [[ | |||
15 | ]] | 15 | ]] |
16 | 16 | ||
17 | local function save_settings(repo) | 17 | local function save_settings(repo) |
18 | local protocol, path = fs.split_url(repo) | 18 | local protocol, path = dir.split_url(repo) |
19 | table.insert(cfg.rocks_servers, 1, protocol.."://"..path) | 19 | table.insert(cfg.rocks_servers, 1, protocol.."://"..path) |
20 | return { | 20 | return { |
21 | root_dir = cfg.root_dir, | 21 | root_dir = cfg.root_dir, |