diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2013-06-24 19:05:59 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-06-24 19:06:41 -0300 |
commit | 694fc86a750e6a9b51c09e21ed70ee4326f85f14 (patch) | |
tree | 30b9c2c7f4a0c53d065c27b6d232c89b77499818 | |
parent | f559b586ed3b8b3bc3f42cf24babd75c907402d5 (diff) | |
download | luarocks-694fc86a750e6a9b51c09e21ed70ee4326f85f14.tar.gz luarocks-694fc86a750e6a9b51c09e21ed70ee4326f85f14.tar.bz2 luarocks-694fc86a750e6a9b51c09e21ed70ee4326f85f14.zip |
Make sure manifest-5.1 and manifest-5.2 are generated and used only when dealing with the remote server.
-rw-r--r-- | src/luarocks/add.lua | 2 | ||||
-rw-r--r-- | src/luarocks/admin_remove.lua | 2 | ||||
-rw-r--r-- | src/luarocks/make_manifest.lua | 2 | ||||
-rw-r--r-- | src/luarocks/manif.lua | 49 | ||||
-rw-r--r-- | src/luarocks/purge.lua | 2 |
5 files changed, 36 insertions, 21 deletions
diff --git a/src/luarocks/add.lua b/src/luarocks/add.lua index 33b98f5c..d7c293e5 100644 --- a/src/luarocks/add.lua +++ b/src/luarocks/add.lua | |||
@@ -65,7 +65,7 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
65 | fs.change_dir(local_cache) | 65 | fs.change_dir(local_cache) |
66 | 66 | ||
67 | util.printout("Updating manifest...") | 67 | util.printout("Updating manifest...") |
68 | manif.make_manifest(local_cache, "one", {"5.1", "5.2"}) | 68 | manif.make_manifest(local_cache, "one", true) |
69 | util.printout("Updating index.html...") | 69 | util.printout("Updating index.html...") |
70 | index.make_index(local_cache) | 70 | index.make_index(local_cache) |
71 | 71 | ||
diff --git a/src/luarocks/admin_remove.lua b/src/luarocks/admin_remove.lua index c235776f..83b57fc9 100644 --- a/src/luarocks/admin_remove.lua +++ b/src/luarocks/admin_remove.lua | |||
@@ -61,7 +61,7 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
61 | fs.change_dir(local_cache) | 61 | fs.change_dir(local_cache) |
62 | 62 | ||
63 | util.printout("Updating manifest...") | 63 | util.printout("Updating manifest...") |
64 | manif.make_manifest(local_cache, "one") | 64 | manif.make_manifest(local_cache, "one", true) |
65 | util.printout("Updating index.html...") | 65 | util.printout("Updating index.html...") |
66 | index.make_index(local_cache) | 66 | index.make_index(local_cache) |
67 | 67 | ||
diff --git a/src/luarocks/make_manifest.lua b/src/luarocks/make_manifest.lua index 845c9f8a..f793dcf2 100644 --- a/src/luarocks/make_manifest.lua +++ b/src/luarocks/make_manifest.lua | |||
@@ -28,7 +28,7 @@ function run(...) | |||
28 | 28 | ||
29 | util.printout("Making manifest for "..repo) | 29 | util.printout("Making manifest for "..repo) |
30 | 30 | ||
31 | local ok, err = manif.make_manifest(repo, deps.get_deps_mode(flags)) | 31 | local ok, err = manif.make_manifest(repo, deps.get_deps_mode(flags), true) |
32 | if ok then | 32 | if ok then |
33 | util.printout("Generating index.html for "..repo) | 33 | util.printout("Generating index.html for "..repo) |
34 | index.make_index(repo) | 34 | index.make_index(repo) |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index bdfdd9ae..c17da71e 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -108,8 +108,10 @@ function load_manifest(repo_url) | |||
108 | 108 | ||
109 | local protocol, pathname = dir.split_url(repo_url) | 109 | local protocol, pathname = dir.split_url(repo_url) |
110 | if protocol == "file" then | 110 | if protocol == "file" then |
111 | pathname = dir.path(pathname, vmanifest) | 111 | local file = dir.path(pathname, vmanifest) |
112 | if not fs.exists(pathname) then | 112 | if fs.exists(file) then |
113 | pathname = file | ||
114 | else | ||
113 | pathname = dir.path(pathname, "manifest") | 115 | pathname = dir.path(pathname, "manifest") |
114 | end | 116 | end |
115 | else | 117 | else |
@@ -206,10 +208,12 @@ end | |||
206 | -- "none" for no trees. | 208 | -- "none" for no trees. |
207 | -- @param repodir string: directory of repository being scanned | 209 | -- @param repodir string: directory of repository being scanned |
208 | -- @param filter_lua string or nil: filter by Lua version | 210 | -- @param filter_lua string or nil: filter by Lua version |
209 | local function update_dependencies(manifest, deps_mode, repodir, filter_lua) | 211 | -- @param cache table: temporary rockspec cache table |
212 | local function update_dependencies(manifest, deps_mode, repodir, filter_lua, cache) | ||
210 | assert(type(manifest) == "table") | 213 | assert(type(manifest) == "table") |
211 | assert(type(deps_mode) == "string") | 214 | assert(type(deps_mode) == "string") |
212 | 215 | ||
216 | cache = cache or {} | ||
213 | local lua_version = filter_lua and deps.parse_version(filter_lua) | 217 | local lua_version = filter_lua and deps.parse_version(filter_lua) |
214 | 218 | ||
215 | for pkg, versions in pairs(manifest.repository) do | 219 | for pkg, versions in pairs(manifest.repository) do |
@@ -231,14 +235,23 @@ local function update_dependencies(manifest, deps_mode, repodir, filter_lua) | |||
231 | end | 235 | end |
232 | end | 236 | end |
233 | elseif filter_lua and repo.arch == "rockspec" then | 237 | elseif filter_lua and repo.arch == "rockspec" then |
234 | local rockspec = fetch.load_local_rockspec(dir.path(repodir, pkg.."-"..version..".rockspec")) | 238 | local pathname = dir.path(repodir, pkg.."-"..version..".rockspec") |
235 | for _, dep in ipairs(rockspec.dependencies) do | 239 | local rockspec, err = cache[pathname] |
236 | if dep.name == "lua" then | 240 | if not rockspec then |
237 | if not deps.match_constraints(lua_version, dep.constraints) then | 241 | rockspec, err = fetch.load_local_rockspec(pathname) |
238 | table.insert(to_remove, version) | 242 | end |
243 | if rockspec then | ||
244 | cache[pathname] = rockspec | ||
245 | for _, dep in ipairs(rockspec.dependencies) do | ||
246 | if dep.name == "lua" then | ||
247 | if not deps.match_constraints(lua_version, dep.constraints) then | ||
248 | table.insert(to_remove, version) | ||
249 | end | ||
250 | break | ||
239 | end | 251 | end |
240 | break | ||
241 | end | 252 | end |
253 | else | ||
254 | util.printerr("Error loading rockspec for "..pkg.." "..version..": "..err) | ||
242 | end | 255 | end |
243 | end | 256 | end |
244 | end | 257 | end |
@@ -262,8 +275,10 @@ end | |||
262 | -- "all" for all trees, "order" for all trees with priority >= the current default, | 275 | -- "all" for all trees, "order" for all trees with priority >= the current default, |
263 | -- "none" for no trees. | 276 | -- "none" for no trees. |
264 | -- @param repo string: directory of repository | 277 | -- @param repo string: directory of repository |
278 | -- @param filter_lua string or nil: filter by Lua version | ||
279 | -- @param cache table: temporary rockspec cache table | ||
265 | -- @return boolean or (nil, string): true in case of success, or nil followed by an error message. | 280 | -- @return boolean or (nil, string): true in case of success, or nil followed by an error message. |
266 | local function store_results(results, manifest, deps_mode, repo, filter_lua) | 281 | local function store_results(results, manifest, deps_mode, repo, filter_lua, cache) |
267 | assert(type(results) == "table") | 282 | assert(type(results) == "table") |
268 | assert(type(manifest) == "table") | 283 | assert(type(manifest) == "table") |
269 | assert(type(deps_mode) == "string") | 284 | assert(type(deps_mode) == "string") |
@@ -289,7 +304,7 @@ local function store_results(results, manifest, deps_mode, repo, filter_lua) | |||
289 | end | 304 | end |
290 | manifest.repository[name] = pkgtable | 305 | manifest.repository[name] = pkgtable |
291 | end | 306 | end |
292 | update_dependencies(manifest, deps_mode, repo, filter_lua) | 307 | update_dependencies(manifest, deps_mode, repo, filter_lua, cache) |
293 | sort_package_matching_table(manifest.modules) | 308 | sort_package_matching_table(manifest.modules) |
294 | sort_package_matching_table(manifest.commands) | 309 | sort_package_matching_table(manifest.commands) |
295 | return true | 310 | return true |
@@ -302,8 +317,7 @@ end | |||
302 | -- @param deps_mode string: Dependency mode: "one" for the current default tree, | 317 | -- @param deps_mode string: Dependency mode: "one" for the current default tree, |
303 | -- "all" for all trees, "order" for all trees with priority >= the current default, | 318 | -- "all" for all trees, "order" for all trees with priority >= the current default, |
304 | -- "none" for the default dependency mode from the configuration. | 319 | -- "none" for the default dependency mode from the configuration. |
305 | -- @param versioned nil or array of string: a table of Lua versions, if versioned | 320 | -- @param versioned boolean: if versioned versions of the manifest should be created. |
306 | -- versions of the manifest should be created. | ||
307 | -- @return boolean or (nil, string): True if manifest was generated, | 321 | -- @return boolean or (nil, string): True if manifest was generated, |
308 | -- or nil and an error message. | 322 | -- or nil and an error message. |
309 | function make_manifest(repo, deps_mode, versioned) | 323 | function make_manifest(repo, deps_mode, versioned) |
@@ -324,14 +338,15 @@ function make_manifest(repo, deps_mode, versioned) | |||
324 | 338 | ||
325 | manif_core.manifest_cache[repo] = manifest | 339 | manif_core.manifest_cache[repo] = manifest |
326 | 340 | ||
327 | local ok, err = store_results(results, manifest, deps_mode, repo) | 341 | local cache = {} |
342 | local ok, err = store_results(results, manifest, deps_mode, repo, nil, cache) | ||
328 | if not ok then return nil, err end | 343 | if not ok then return nil, err end |
329 | 344 | ||
330 | if versioned then | 345 | if versioned then |
331 | for _, ver in ipairs(versioned) do | 346 | for _, luaver in ipairs({"5.1", "5.2"}) do |
332 | local vmanifest = { repository = {}, modules = {}, commands = {} } | 347 | local vmanifest = { repository = {}, modules = {}, commands = {} } |
333 | local ok, err = store_results(results, vmanifest, deps_mode, repo, ver) | 348 | local ok, err = store_results(results, vmanifest, deps_mode, repo, luaver, cache) |
334 | save_table(repo, "manifest-"..ver, vmanifest) | 349 | save_table(repo, "manifest-"..luaver, vmanifest) |
335 | end | 350 | end |
336 | end | 351 | end |
337 | 352 | ||
diff --git a/src/luarocks/purge.lua b/src/luarocks/purge.lua index 6b094061..46a023e9 100644 --- a/src/luarocks/purge.lua +++ b/src/luarocks/purge.lua | |||
@@ -44,5 +44,5 @@ function run(...) | |||
44 | end | 44 | end |
45 | end | 45 | end |
46 | end | 46 | end |
47 | return manif.make_manifest(cfg.rocks_dir, "one") | 47 | return manif.make_manifest(cfg.rocks_dir, "one", true) |
48 | end | 48 | end |