aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/add.lua11
-rw-r--r--src/luarocks/admin_remove.lua6
-rw-r--r--src/luarocks/cache.lua2
-rw-r--r--src/luarocks/cfg.lua1
-rw-r--r--src/luarocks/deps.lua35
-rw-r--r--src/luarocks/dir.lua7
-rw-r--r--src/luarocks/fs/unix/tools.lua2
-rw-r--r--src/luarocks/help.lua1
-rw-r--r--src/luarocks/index.lua19
-rw-r--r--src/luarocks/manif.lua53
-rw-r--r--src/luarocks/persist.lua2
-rw-r--r--src/luarocks/unpack.lua3
-rw-r--r--src/luarocks/util.lua9
13 files changed, 104 insertions, 47 deletions
diff --git a/src/luarocks/add.lua b/src/luarocks/add.lua
index 54991291..f1142d2a 100644
--- a/src/luarocks/add.lua
+++ b/src/luarocks/add.lua
@@ -68,6 +68,9 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server)
68 68
69 util.printout("Updating manifest...") 69 util.printout("Updating manifest...")
70 manif.make_manifest(local_cache, "one", true) 70 manif.make_manifest(local_cache, "one", true)
71
72 manif.zip_manifests()
73
71 util.printout("Updating index.html...") 74 util.printout("Updating index.html...")
72 index.make_index(local_cache) 75 index.make_index(local_cache)
73 76
@@ -80,15 +83,17 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server)
80 83
81 table.insert(files, "index.html") 84 table.insert(files, "index.html")
82 table.insert(files, "manifest") 85 table.insert(files, "manifest")
83 table.insert(files, "manifest-5.1") 86 for ver in util.lua_versions() do
84 table.insert(files, "manifest-5.2") 87 table.insert(files, "manifest-"..ver)
88 table.insert(files, "manifest-"..ver..".zip")
89 end
85 90
86 -- TODO abstract away explicit 'curl' call 91 -- TODO abstract away explicit 'curl' call
87 92
88 local cmd 93 local cmd
89 if protocol == "rsync" then 94 if protocol == "rsync" then
90 local srv, path = server_path:match("([^/]+)(/.+)") 95 local srv, path = server_path:match("([^/]+)(/.+)")
91 cmd = cfg.variables.RSYNC.." --exclude=.git -Oavz -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/" 96 cmd = cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/"
92 elseif upload_server and upload_server.sftp then 97 elseif upload_server and upload_server.sftp then
93 local part1, part2 = upload_server.sftp:match("^([^/]*)/(.*)$") 98 local part1, part2 = upload_server.sftp:match("^([^/]*)/(.*)$")
94 cmd = cfg.variables.SCP.." "..table.concat(files, " ").." "..user.."@"..part1..":/"..part2 99 cmd = cfg.variables.SCP.." "..table.concat(files, " ").." "..user.."@"..part1..":/"..part2
diff --git a/src/luarocks/admin_remove.lua b/src/luarocks/admin_remove.lua
index 31325a30..d429ce59 100644
--- a/src/luarocks/admin_remove.lua
+++ b/src/luarocks/admin_remove.lua
@@ -13,10 +13,10 @@ local fs = require("luarocks.fs")
13local cache = require("luarocks.cache") 13local cache = require("luarocks.cache")
14 14
15help_summary = "Remove a rock or rockspec from a rocks server." 15help_summary = "Remove a rock or rockspec from a rocks server."
16help_arguments = "[--from=<server>] [--no-refresh] {<rockspec>|<rock>...}" 16help_arguments = "[--server=<server>] [--no-refresh] {<rockspec>|<rock>...}"
17help = [[ 17help = [[
18Arguments are local files, which may be rockspecs or rocks. 18Arguments are local files, which may be rockspecs or rocks.
19The flag --from indicates which server to use. 19The flag --server indicates which server to use.
20If not given, the default server set in the upload_server variable 20If not given, the default server set in the upload_server variable
21from the configuration file is used instead. 21from the configuration file is used instead.
22The flag --no-refresh indicates the local cache should not be refreshed 22The flag --no-refresh indicates the local cache should not be refreshed
@@ -68,7 +68,7 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve
68 index.make_index(local_cache) 68 index.make_index(local_cache)
69 69
70 local srv, path = server_path:match("([^/]+)(/.+)") 70 local srv, path = server_path:match("([^/]+)(/.+)")
71 local cmd = "rsync -Oavz --delete -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/" 71 local cmd = cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." --delete -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/"
72 72
73 util.printout(cmd) 73 util.printout(cmd)
74 fs.execute(cmd) 74 fs.execute(cmd)
diff --git a/src/luarocks/cache.lua b/src/luarocks/cache.lua
index 6ea6e82a..a3dfe8b1 100644
--- a/src/luarocks/cache.lua
+++ b/src/luarocks/cache.lua
@@ -74,7 +74,7 @@ function refresh_local_cache(server, url, user, password)
74 local ok = false 74 local ok = false
75 if protocol == "rsync" then 75 if protocol == "rsync" then
76 local srv, path = server_path:match("([^/]+)(/.+)") 76 local srv, path = server_path:match("([^/]+)(/.+)")
77 ok = fs.execute(cfg.variables.RSYNC.." -avz -e ssh "..user.."@"..srv..":"..path.."/ "..local_cache.."/") 77 ok = fs.execute(cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." -e ssh "..user.."@"..srv..":"..path.."/ "..local_cache.."/")
78 else 78 else
79 local login_info = "" 79 local login_info = ""
80 if user then login_info = " --user="..user end 80 if user then login_info = " --user="..user end
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 62c69597..8e26bb46 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -250,6 +250,7 @@ local defaults = {
250 CMAKE = "cmake", 250 CMAKE = "cmake",
251 SEVENZ = "7z", 251 SEVENZ = "7z",
252 252
253 RSYNCFLAGS = "--exclude=.git -Ocavz",
253 STATFLAG = "-c '%a'", 254 STATFLAG = "-c '%a'",
254 }, 255 },
255 256
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
index e0b8a42d..f24dc507 100644
--- a/src/luarocks/deps.lua
+++ b/src/luarocks/deps.lua
@@ -360,6 +360,11 @@ local function match_dep(dep, blacklist, deps_mode)
360 end 360 end
361end 361end
362 362
363local whitelist = {}
364if cfg.lua_version == "5.2" then
365 whitelist["bit32"] = true
366end
367
363--- Attempt to match dependencies of a rockspec to installed rocks. 368--- Attempt to match dependencies of a rockspec to installed rocks.
364-- @param rockspec table: The rockspec loaded as a table. 369-- @param rockspec table: The rockspec loaded as a table.
365-- @param blacklist table or nil: Program versions to not use as valid matches. 370-- @param blacklist table or nil: Program versions to not use as valid matches.
@@ -367,24 +372,28 @@ end
367-- are program versions and values are 'true'. 372-- are program versions and values are 'true'.
368-- @return table, table: A table where keys are dependencies parsed 373-- @return table, table: A table where keys are dependencies parsed
369-- in table format and values are tables containing fields 'name' and 374-- in table format and values are tables containing fields 'name' and
370-- version' representing matches, and a table of missing dependencies 375-- version' representing matches; a table of missing dependencies
371-- parsed as tables. 376-- parsed as tables; and a table of "no-upgrade" missing dependencies
377-- (to be used in plugin modules so that a plugin does not force upgrade of
378-- its parent application).
372function match_deps(rockspec, blacklist, deps_mode) 379function match_deps(rockspec, blacklist, deps_mode)
373 assert(type(rockspec) == "table") 380 assert(type(rockspec) == "table")
374 assert(type(blacklist) == "table" or not blacklist) 381 assert(type(blacklist) == "table" or not blacklist)
375 local matched, missing, no_upgrade = {}, {}, {} 382 local matched, missing, no_upgrade = {}, {}, {}
376 383
377 for _, dep in ipairs(rockspec.dependencies) do 384 for _, dep in ipairs(rockspec.dependencies) do
378 local found = match_dep(dep, blacklist and blacklist[dep.name] or nil, deps_mode) 385 if not whitelist[dep.name] then
379 if found then 386 local found = match_dep(dep, blacklist and blacklist[dep.name] or nil, deps_mode)
380 if dep.name ~= "lua" then 387 if found then
381 matched[dep] = found 388 if dep.name ~= "lua" then
382 end 389 matched[dep] = found
383 else 390 end
384 if dep.constraints[1] and dep.constraints[1].no_upgrade then
385 no_upgrade[dep.name] = dep
386 else 391 else
387 missing[dep.name] = dep 392 if dep.constraints[1] and dep.constraints[1].no_upgrade then
393 no_upgrade[dep.name] = dep
394 else
395 missing[dep.name] = dep
396 end
388 end 397 end
389 end 398 end
390 end 399 end
@@ -441,7 +450,7 @@ function fulfill_dependencies(rockspec, deps_mode)
441 end 450 end
442 end 451 end
443 452
444 local matched, missing, no_upgrade = match_deps(rockspec, nil, deps_mode) 453 local _, missing, no_upgrade = match_deps(rockspec, nil, deps_mode)
445 454
446 if next(no_upgrade) then 455 if next(no_upgrade) then
447 util.printerr("Missing dependencies for "..rockspec.name.." "..rockspec.version..":") 456 util.printerr("Missing dependencies for "..rockspec.name.." "..rockspec.version..":")
diff --git a/src/luarocks/dir.lua b/src/luarocks/dir.lua
index b496c962..3c7465bb 100644
--- a/src/luarocks/dir.lua
+++ b/src/luarocks/dir.lua
@@ -17,13 +17,12 @@ end
17 17
18--- Strip the name off a path+filename. 18--- Strip the name off a path+filename.
19-- @param pathname string: A path+name, such as "/a/b/c". 19-- @param pathname string: A path+name, such as "/a/b/c".
20-- @return string: The filename without its path, such as "/a/b/". 20-- @return string: The filename without its path, such as "/a/b".
21-- For entries such as "/a/b/", "/a/" is returned. If there are 21-- For entries such as "/a/b/", "/a" is returned. If there are
22-- no directory separators in input, "" is returned. 22-- no directory separators in input, "" is returned.
23function dir_name(pathname) 23function dir_name(pathname)
24 assert(type(pathname) == "string") 24 assert(type(pathname) == "string")
25 25 return (pathname:gsub("/*$", ""):match("(.*)[/]+[^/]*")) or ""
26 return (pathname:gsub("/*$", ""):match("(.*/)[^/]*")) or ""
27end 26end
28 27
29--- Describe a path in a cross-platform way. 28--- Describe a path in a cross-platform way.
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua
index 64992b91..9e4acf73 100644
--- a/src/luarocks/fs/unix/tools.lua
+++ b/src/luarocks/fs/unix/tools.lua
@@ -206,7 +206,7 @@ end
206-- @return boolean: true on success, false on failure. 206-- @return boolean: true on success, false on failure.
207function unzip(zipfile) 207function unzip(zipfile)
208 assert(zipfile) 208 assert(zipfile)
209 return fs.execute(vars.UNZIP, zipfile) 209 return fs.execute_string(fs.quiet(vars.UNZIP.." "..fs.Q(zipfile)))
210end 210end
211 211
212--- Test is file/directory exists 212--- Test is file/directory exists
diff --git a/src/luarocks/help.lua b/src/luarocks/help.lua
index 2944dfd8..d9be46fc 100644
--- a/src/luarocks/help.lua
+++ b/src/luarocks/help.lua
@@ -80,6 +80,7 @@ function run(...)
80 util.printout("\t", command.help_summary) 80 util.printout("\t", command.help_summary)
81 end 81 end
82 print_section("CONFIGURATION") 82 print_section("CONFIGURATION")
83 util.printout("\tLua version: " .. cfg.lua_version)
83 util.printout("\tSystem configuration file: ".. sys_file .. " (" .. get_status(sys_ok) ..")") 84 util.printout("\tSystem configuration file: ".. sys_file .. " (" .. get_status(sys_ok) ..")")
84 if home_file then 85 if home_file then
85 util.printout("\tUser configuration file: ".. home_file .. " (" .. get_status(home_ok) ..")\n") 86 util.printout("\tUser configuration file: ".. home_file .. " (" .. get_status(home_ok) ..")\n")
diff --git a/src/luarocks/index.lua b/src/luarocks/index.lua
index 6147a4d2..e0785d9c 100644
--- a/src/luarocks/index.lua
+++ b/src/luarocks/index.lua
@@ -66,7 +66,7 @@ Lua modules available from this location for use with <a href="http://www.luaroc
66<table class="main"> 66<table class="main">
67]] 67]]
68 68
69local index_package_start = [[ 69local index_package_begin = [[
70<td class="package"> 70<td class="package">
71<p><a name="$anchor"></a><a href="#$anchor" class="pkg"><b>$package</b></a> - $summary<br/> 71<p><a name="$anchor"></a><a href="#$anchor" class="pkg"><b>$package</b></a> - $summary<br/>
72</p><blockquote><p>$detailed<br/> 72</p><blockquote><p>$detailed<br/>
@@ -81,10 +81,15 @@ local index_package_end = [[
81<tr><td colspan="2" class="spacer"></td></tr> 81<tr><td colspan="2" class="spacer"></td></tr>
82]] 82]]
83 83
84local index_footer = [[ 84local index_footer_begin = [[
85</table> 85</table>
86<p class="manifest"> 86<p class="manifest">
87<a href="manifest">manifest file</a> &bull; <a href="manifest-5.1">Lua 5.1 manifest file</a> &bull; <a href="manifest-5.2">Lua 5.2 manifest file</a> 87<a href="manifest">manifest file</a>
88]]
89local index_manifest_ver = [[
90&bull; <a href="manifest-$VER">Lua $VER manifest file</a> (<a href="manifest-$VER.zip">zip</a>)
91]]
92local index_footer_end = [[
88</p> 93</p>
89</body> 94</body>
90</html> 95</html>
@@ -128,7 +133,7 @@ function make_index(repo)
128 out:write(index_header) 133 out:write(index_header)
129 for package, version_list in util.sortedpairs(manifest.repository) do 134 for package, version_list in util.sortedpairs(manifest.repository) do
130 local latest_rockspec = nil 135 local latest_rockspec = nil
131 local output = index_package_start 136 local output = index_package_begin
132 for version, data in util.sortedpairs(version_list, deps.compare_versions) do 137 for version, data in util.sortedpairs(version_list, deps.compare_versions) do
133 local versions = {} 138 local versions = {}
134 output = output..version..':&nbsp;' 139 output = output..version..':&nbsp;'
@@ -170,6 +175,10 @@ function make_index(repo)
170 end 175 end
171 out:write(output) 176 out:write(output)
172 end 177 end
173 out:write(index_footer) 178 out:write(index_footer_begin)
179 for ver in util.lua_versions() do
180 out:write((index_manifest_ver:gsub("$VER", ver)))
181 end
182 out:write(index_footer_end)
174 out:close() 183 out:close()
175end 184end
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua
index d0bd5e04..03377d52 100644
--- a/src/luarocks/manif.lua
+++ b/src/luarocks/manif.lua
@@ -103,26 +103,40 @@ function load_manifest(repo_url)
103 if manif_core.manifest_cache[repo_url] then 103 if manif_core.manifest_cache[repo_url] then
104 return manif_core.manifest_cache[repo_url] 104 return manif_core.manifest_cache[repo_url]
105 end 105 end
106 106
107 local vmanifest = "manifest-"..cfg.lua_version 107 local filenames = {
108 108 "manifest-"..cfg.lua_version..".zip",
109 local protocol, pathname = dir.split_url(repo_url) 109 "manifest-"..cfg.lua_version,
110 "manifest",
111 }
112
113 local protocol, repodir = dir.split_url(repo_url)
114 local pathname
110 if protocol == "file" then 115 if protocol == "file" then
111 local file = dir.path(pathname, vmanifest) 116 for _, filename in ipairs(filenames) do
112 if fs.exists(file) then 117 pathname = dir.path(repodir, filename)
113 pathname = file 118 if fs.exists(pathname) then
114 else 119 break
115 pathname = dir.path(pathname, "manifest") 120 end
116 end 121 end
117 else 122 else
118 local file, err = fetch_manifest_from(repo_url, vmanifest) 123 local err
119 if not file then 124 for _, filename in ipairs(filenames) do
120 file, err = fetch_manifest_from(repo_url, "manifest") 125 pathname, err = fetch_manifest_from(repo_url, filename)
126 if pathname then
127 break
128 end
121 end 129 end
122 if not file then 130 if not pathname then
123 return nil, err 131 return nil, err
124 end 132 end
125 pathname = file 133 end
134 if pathname:match(".*%.zip$") then
135 local dir = dir.dir_name(pathname)
136 fs.change_dir(dir)
137 fs.unzip(pathname)
138 fs.pop_dir()
139 pathname = pathname:match("(.*)%.zip$")
126 end 140 end
127 return manif_core.manifest_loader(pathname, repo_url) 141 return manif_core.manifest_loader(pathname, repo_url)
128end 142end
@@ -343,7 +357,7 @@ function make_manifest(repo, deps_mode, versioned)
343 if not ok then return nil, err end 357 if not ok then return nil, err end
344 358
345 if versioned then 359 if versioned then
346 for _, luaver in ipairs({"5.1", "5.2"}) do 360 for luaver in util.lua_versions() do
347 local vmanifest = { repository = {}, modules = {}, commands = {} } 361 local vmanifest = { repository = {}, modules = {}, commands = {} }
348 local ok, err = store_results(results, vmanifest, deps_mode, repo, luaver, cache) 362 local ok, err = store_results(results, vmanifest, deps_mode, repo, luaver, cache)
349 save_table(repo, "manifest-"..luaver, vmanifest) 363 save_table(repo, "manifest-"..luaver, vmanifest)
@@ -397,6 +411,15 @@ function update_manifest(name, version, repo, deps_mode)
397 return save_table(repo, "manifest", manifest) 411 return save_table(repo, "manifest", manifest)
398end 412end
399 413
414function zip_manifests()
415 for ver in util.lua_versions() do
416 local file = "manifest-"..ver
417 local zip = file..".zip"
418 fs.delete(dir.path(fs.current_dir(), zip))
419 fs.zip(zip, file)
420 end
421end
422
400local function find_providers(file, root) 423local function find_providers(file, root)
401 assert(type(file) == "string") 424 assert(type(file) == "string")
402 root = root or cfg.root_dir 425 root = root or cfg.root_dir
diff --git a/src/luarocks/persist.lua b/src/luarocks/persist.lua
index 208aee02..376a242a 100644
--- a/src/luarocks/persist.lua
+++ b/src/luarocks/persist.lua
@@ -20,7 +20,7 @@ function load_into_table(filename, tbl)
20 20
21 local result, chunk, ran, err 21 local result, chunk, ran, err
22 local result = tbl or {} 22 local result = tbl or {}
23 if setfenv then -- Lua 5.1 23 if _VERSION == "Lua 5.1" then -- Lua 5.1
24 chunk, err = loadfile(filename) 24 chunk, err = loadfile(filename)
25 if chunk then 25 if chunk then
26 setfenv(chunk, result) 26 setfenv(chunk, result)
diff --git a/src/luarocks/unpack.lua b/src/luarocks/unpack.lua
index 2e6166ca..70c116fd 100644
--- a/src/luarocks/unpack.lua
+++ b/src/luarocks/unpack.lua
@@ -37,10 +37,11 @@ local function unpack_rockspec(rockspec_file, dir_name)
37 if not ok then 37 if not ok then
38 return nil, sources_dir 38 return nil, sources_dir
39 end 39 end
40 ok, err = fs.change_dir(dir_name) 40 ok, err = fs.change_dir(sources_dir)
41 if not ok then return nil, err end 41 if not ok then return nil, err end
42 build.apply_patches(rockspec) 42 build.apply_patches(rockspec)
43 fs.pop_dir() 43 fs.pop_dir()
44 fs.pop_dir()
44 return rockspec 45 return rockspec
45end 46end
46 47
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index ba20acfa..e3260359 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -319,6 +319,15 @@ function sortedpairs(tbl, sort_function)
319 return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end) 319 return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end)
320end 320end
321 321
322function lua_versions()
323 local versions = { "5.1", "5.2" }
324 local i = 0
325 return function()
326 i = i + 1
327 return versions[i]
328 end
329end
330
322function starts_with(s, prefix) 331function starts_with(s, prefix)
323 return s:sub(1,#prefix) == prefix 332 return s:sub(1,#prefix) == prefix
324end 333end