diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2010-11-23 13:02:28 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2010-11-23 13:02:28 -0200 |
commit | a80e64ce3eb0e5e3abe48bc18ed2acbad8253002 (patch) | |
tree | 52219972e58ad6646863c4e23c2fb1dbb98172b9 | |
parent | 59423a667bdc69d97185886348188db6eb65ae68 (diff) | |
parent | 98ead176473c0fbd02b147adbcb089df8a56095e (diff) | |
download | luarocks-a80e64ce3eb0e5e3abe48bc18ed2acbad8253002.tar.gz luarocks-a80e64ce3eb0e5e3abe48bc18ed2acbad8253002.tar.bz2 luarocks-a80e64ce3eb0e5e3abe48bc18ed2acbad8253002.zip |
Merge branch 'master' of github.com:keplerproject/luarocks
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | rockspec | 2 | ||||
-rw-r--r-- | src/luarocks/build.lua | 9 | ||||
-rw-r--r-- | src/luarocks/cfg.lua | 11 | ||||
-rw-r--r-- | src/luarocks/fetch/git.lua | 4 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 15 | ||||
-rw-r--r-- | src/luarocks/fs/unix/tools.lua | 17 | ||||
-rw-r--r-- | src/luarocks/index.lua | 44 | ||||
-rw-r--r-- | src/luarocks/install.lua | 9 | ||||
-rw-r--r-- | src/luarocks/make.lua | 6 | ||||
-rw-r--r-- | src/luarocks/show.lua | 2 | ||||
-rw-r--r-- | src/luarocks/util.lua | 1 |
12 files changed, 89 insertions, 34 deletions
@@ -19,7 +19,8 @@ build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua tools/patch.lua \ | |||
19 | fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua make.lua path.lua \ | 19 | fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua make.lua path.lua \ |
20 | remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua show.lua \ | 20 | remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua show.lua \ |
21 | manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ | 21 | manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ |
22 | help.lua util.lua index.lua cache.lua add.lua refresh_cache.lua loader.lua | 22 | help.lua util.lua index.lua cache.lua add.lua refresh_cache.lua loader.lua \ |
23 | admin_remove.lua | ||
23 | 24 | ||
24 | CONFIG_FILE = $(SYSCONFDIR)/config.lua | 25 | CONFIG_FILE = $(SYSCONFDIR)/config.lua |
25 | 26 | ||
@@ -1,5 +1,5 @@ | |||
1 | package = "LuaRocks" | 1 | package = "LuaRocks" |
2 | local VER = "2.0.3" | 2 | local VER = "2.0.4" |
3 | local REV = "1" | 3 | local REV = "1" |
4 | version = VER.."-"..REV | 4 | version = VER.."-"..REV |
5 | 5 | ||
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 6eca0c3e..e6afde54 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -235,8 +235,9 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode) | |||
235 | license = ("(license: "..rockspec.description.license..")") | 235 | license = ("(license: "..rockspec.description.license..")") |
236 | end | 236 | end |
237 | 237 | ||
238 | local root_dir = path.root_dir(cfg.rocks_dir) | ||
238 | print() | 239 | print() |
239 | print(name.." "..version.." is now built and installed in "..cfg.root_dir.." "..license) | 240 | print(name.." "..version.." is now built and installed in "..root_dir.." "..license) |
240 | 241 | ||
241 | util.remove_scheduled_function(rollback) | 242 | util.remove_scheduled_function(rollback) |
242 | return true | 243 | return true |
@@ -278,10 +279,8 @@ function run(...) | |||
278 | end | 279 | end |
279 | assert(type(version) == "string" or not version) | 280 | assert(type(version) == "string" or not version) |
280 | 281 | ||
281 | if not flags["local"] and (fs.exists(cfg.root_dir) and not fs.is_writable(cfg.root_dir)) then | 282 | local ok, err = fs.check_command_permissions(flags) |
282 | return nil, "Your user does not have write permissions in " .. cfg.root_dir .. | 283 | if not ok then return nil, err end |
283 | " \n-- you may want to run as a privileged user or use your local tree with --local." | ||
284 | end | ||
285 | 284 | ||
286 | if name:match("%.rockspec$") then | 285 | if name:match("%.rockspec$") then |
287 | return build_rockspec(name, true) | 286 | return build_rockspec(name, true) |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 0d991849..4bb376a4 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -24,7 +24,7 @@ end | |||
24 | 24 | ||
25 | _M.config = config | 25 | _M.config = config |
26 | 26 | ||
27 | program_version = "2.0.3" | 27 | program_version = "2.0.4" |
28 | user_agent = "LuaRocks/"..program_version | 28 | user_agent = "LuaRocks/"..program_version |
29 | 29 | ||
30 | local persist = require("luarocks.persist") | 30 | local persist = require("luarocks.persist") |
@@ -64,6 +64,10 @@ if system == "FreeBSD" then | |||
64 | detected.unix = true | 64 | detected.unix = true |
65 | detected.freebsd = true | 65 | detected.freebsd = true |
66 | detected.bsd = true | 66 | detected.bsd = true |
67 | elseif system == "OpenBSD" then | ||
68 | detected.unix = true | ||
69 | detected.openbsd = true | ||
70 | detected.bsd = true | ||
67 | elseif system == "Darwin" then | 71 | elseif system == "Darwin" then |
68 | detected.unix = true | 72 | detected.unix = true |
69 | detected.macosx = true | 73 | detected.macosx = true |
@@ -289,6 +293,11 @@ if detected.freebsd then | |||
289 | defaults.variables.LIBFLAG = "-shared" | 293 | defaults.variables.LIBFLAG = "-shared" |
290 | end | 294 | end |
291 | 295 | ||
296 | if detected.openbsd then | ||
297 | defaults.arch = "openbsd-"..proc | ||
298 | defaults.platforms = {"unix", "bsd", "openbsd"} | ||
299 | end | ||
300 | |||
292 | -- Expose some more values detected by LuaRocks for use by rockspec authors. | 301 | -- Expose some more values detected by LuaRocks for use by rockspec authors. |
293 | defaults.variables.LUA = defaults.lua_interpreter | 302 | defaults.variables.LUA = defaults.lua_interpreter |
294 | defaults.variables.LIB_EXTENSION = defaults.lib_extension | 303 | defaults.variables.LIB_EXTENSION = defaults.lib_extension |
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index 6305d781..a3b763d6 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua | |||
@@ -47,8 +47,8 @@ function get_sources(rockspec, extract, dest_dir) | |||
47 | return nil, "Failed checking out tag/branch from git repository." | 47 | return nil, "Failed checking out tag/branch from git repository." |
48 | end | 48 | end |
49 | end | 49 | end |
50 | fs.delete(".git") | 50 | fs.delete(dir.path(store_dir, module, ".git")) |
51 | fs.delete(".gitignore") | 51 | fs.delete(dir.path(store_dir, module, ".gitignore")) |
52 | fs.pop_dir() | 52 | fs.pop_dir() |
53 | fs.pop_dir() | 53 | fs.pop_dir() |
54 | return module, store_dir | 54 | return module, store_dir |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 70df65be..5b3efd94 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -8,6 +8,7 @@ local fs = require("luarocks.fs") | |||
8 | local cfg = require("luarocks.cfg") | 8 | local cfg = require("luarocks.cfg") |
9 | local dir = require("luarocks.dir") | 9 | local dir = require("luarocks.dir") |
10 | local util = require("luarocks.util") | 10 | local util = require("luarocks.util") |
11 | local path = require("luarocks.path") | ||
11 | 12 | ||
12 | local socket_ok, http = pcall(require, "socket.http") | 13 | local socket_ok, http = pcall(require, "socket.http") |
13 | local _, ftp = pcall(require, "socket.ftp") | 14 | local _, ftp = pcall(require, "socket.ftp") |
@@ -615,3 +616,17 @@ function move(src, dest) | |||
615 | end | 616 | end |
616 | return true | 617 | return true |
617 | end | 618 | end |
619 | |||
620 | --- Check if user has write permissions for the command. | ||
621 | -- Assumes the configuration variables under cfg have been previously set up. | ||
622 | -- @param flags table: the flags table passed to run() drivers. | ||
623 | -- @return boolean or (boolean, string): true on success, false on failure, | ||
624 | -- plus an error message. | ||
625 | function check_command_permissions(flags) | ||
626 | local root_dir = path.root_dir(cfg.rocks_dir) | ||
627 | if not flags["local"] and not fs.is_writable(root_dir) then | ||
628 | return nil, "Your user does not have write permissions in " .. root_dir .. | ||
629 | " \n-- you may want to run as a privileged user or use your local tree with --local." | ||
630 | end | ||
631 | return true | ||
632 | end | ||
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index a67dca49..c805fb48 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -302,14 +302,14 @@ function get_md5(file, md5sum) | |||
302 | end | 302 | end |
303 | elseif cfg.md5checker == "openssl" then | 303 | elseif cfg.md5checker == "openssl" then |
304 | local pipe = io.popen("openssl md5 "..file) | 304 | local pipe = io.popen("openssl md5 "..file) |
305 | computed = pipe:read("*a") | 305 | computed = pipe:read("*l") |
306 | pipe:close() | 306 | pipe:close() |
307 | if computed then | 307 | if computed then |
308 | computed = computed:sub(-32) | 308 | computed = computed:sub(-32) |
309 | end | 309 | end |
310 | elseif cfg.md5checker == "md5" then | 310 | elseif cfg.md5checker == "md5" then |
311 | local pipe = io.popen("md5 "..file) | 311 | local pipe = io.popen("md5 "..file) |
312 | computed = pipe:read("*a") | 312 | computed = pipe:read("*l") |
313 | pipe:close() | 313 | pipe:close() |
314 | if computed then | 314 | if computed then |
315 | computed = computed:sub(-32) | 315 | computed = computed:sub(-32) |
@@ -350,7 +350,18 @@ end | |||
350 | 350 | ||
351 | function get_permissions(filename) | 351 | function get_permissions(filename) |
352 | local ret | 352 | local ret |
353 | local flag = cfg.is_platform("bsd") and "-f '%A'" or "-c '%a'" | 353 | |
354 | local flag | ||
355 | if cfg.is_platform("bsd") then | ||
356 | if cfg.is_platform("openbsd") then | ||
357 | flag = "-f '%Op'" | ||
358 | else | ||
359 | flag = "-f '%A'" | ||
360 | end | ||
361 | else | ||
362 | flag = "-c '%a'" | ||
363 | end | ||
364 | |||
354 | local pipe = io.popen("stat "..flag.." "..fs.Q(filename)) | 365 | local pipe = io.popen("stat "..flag.." "..fs.Q(filename)) |
355 | ret = pipe:read("*l") | 366 | ret = pipe:read("*l") |
356 | pipe:close() | 367 | pipe:close() |
diff --git a/src/luarocks/index.lua b/src/luarocks/index.lua index 18afd797..570db431 100644 --- a/src/luarocks/index.lua +++ b/src/luarocks/index.lua | |||
@@ -64,6 +64,7 @@ local index_package_start = [[ | |||
64 | <td class="package"> | 64 | <td class="package"> |
65 | <p><a name="$anchor"></a><b>$package</b> - $summary<br/> | 65 | <p><a name="$anchor"></a><b>$package</b> - $summary<br/> |
66 | </p><blockquote><p>$detailed<br/> | 66 | </p><blockquote><p>$detailed<br/> |
67 | $externaldependencies | ||
67 | <font size="-1"><a href="$original">latest sources</a> $homepage | License: $license</font></p> | 68 | <font size="-1"><a href="$original">latest sources</a> $homepage | License: $license</font></p> |
68 | </blockquote></a></td> | 69 | </blockquote></a></td> |
69 | <td class="version"> | 70 | <td class="version"> |
@@ -83,6 +84,34 @@ local index_footer = [[ | |||
83 | </html> | 84 | </html> |
84 | ]] | 85 | ]] |
85 | 86 | ||
87 | function format_external_dependencies(rockspec) | ||
88 | if rockspec.external_dependencies then | ||
89 | local deplist = {} | ||
90 | local listed_set = {} | ||
91 | local plats = nil | ||
92 | for name, desc in util.sortedpairs(rockspec.external_dependencies) do | ||
93 | if name ~= "platforms" then | ||
94 | table.insert(deplist, name:lower()) | ||
95 | listed_set[name] = true | ||
96 | else | ||
97 | plats = desc | ||
98 | end | ||
99 | end | ||
100 | if plats then | ||
101 | for plat, entries in util.sortedpairs(plats) do | ||
102 | for name, desc in util.sortedpairs(entries) do | ||
103 | if not listed_set[name] then | ||
104 | table.insert(deplist, name:lower() .. " (on "..plat..")") | ||
105 | end | ||
106 | end | ||
107 | end | ||
108 | end | ||
109 | return '<p><b>External dependencies:</b> ' .. table.concat(deplist, ', ').. '</p>' | ||
110 | else | ||
111 | return "" | ||
112 | end | ||
113 | end | ||
114 | |||
86 | function make_index(repo) | 115 | function make_index(repo) |
87 | if not fs.is_dir(repo) then | 116 | if not fs.is_dir(repo) then |
88 | return nil, "Cannot access repository at "..repo | 117 | return nil, "Cannot access repository at "..repo |
@@ -96,9 +125,8 @@ function make_index(repo) | |||
96 | local output = index_package_start | 125 | local output = index_package_start |
97 | for version, data in util.sortedpairs(version_list, deps.compare_versions) do | 126 | for version, data in util.sortedpairs(version_list, deps.compare_versions) do |
98 | local versions = {} | 127 | local versions = {} |
99 | local versions_order = {} | ||
100 | output = output..version..': ' | 128 | output = output..version..': ' |
101 | 129 | table.sort(data, function(a,b) return a.arch < b.arch end) | |
102 | for _, item in ipairs(data) do | 130 | for _, item in ipairs(data) do |
103 | local link = '<a href="$url">'..item.arch..'</a>' | 131 | local link = '<a href="$url">'..item.arch..'</a>' |
104 | if item.arch == 'rockspec' then | 132 | if item.arch == 'rockspec' then |
@@ -108,14 +136,9 @@ function make_index(repo) | |||
108 | else | 136 | else |
109 | link = link:gsub("$url", ("%s-%s.%s.rock"):format(package, version, item.arch)) | 137 | link = link:gsub("$url", ("%s-%s.%s.rock"):format(package, version, item.arch)) |
110 | end | 138 | end |
111 | versions[item.arch] = link | 139 | table.insert(versions, link) |
112 | table.insert(versions_order, item.arch) | ||
113 | end | ||
114 | table.sort(versions_order) | ||
115 | for i, arch in ipairs(versions_order) do | ||
116 | versions_order[i] = versions[versions_order[i]] | ||
117 | end | 140 | end |
118 | output = output .. table.concat(versions_order, ', ') .. '<br/>' | 141 | output = output .. table.concat(versions, ', ') .. '<br/>' |
119 | end | 142 | end |
120 | output = output .. index_package_end | 143 | output = output .. index_package_end |
121 | if latest_rockspec then | 144 | if latest_rockspec then |
@@ -127,7 +150,8 @@ function make_index(repo) | |||
127 | summary = rockspec.description.summary or "", | 150 | summary = rockspec.description.summary or "", |
128 | detailed = rockspec.description.detailed or "", | 151 | detailed = rockspec.description.detailed or "", |
129 | license = rockspec.description.license or "N/A", | 152 | license = rockspec.description.license or "N/A", |
130 | homepage = rockspec.description.homepage and ("| <a href="..rockspec.description.homepage..">project homepage</a>") or "" | 153 | homepage = rockspec.description.homepage and ("| <a href="..rockspec.description.homepage..">project homepage</a>") or "", |
154 | externaldependencies = format_external_dependencies(rockspec) | ||
131 | } | 155 | } |
132 | vars.detailed = vars.detailed:gsub("\n\n", "</p><p>"):gsub("%s+", " ") | 156 | vars.detailed = vars.detailed:gsub("\n\n", "</p><p>"):gsub("%s+", " ") |
133 | output = output:gsub("$(%w+)", vars) | 157 | output = output:gsub("$(%w+)", vars) |
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index f9f27ccf..016e73bb 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
@@ -84,8 +84,9 @@ function install_binary_rock(rock_file) | |||
84 | license = ("(license: "..rockspec.description.license..")") | 84 | license = ("(license: "..rockspec.description.license..")") |
85 | end | 85 | end |
86 | 86 | ||
87 | local root_dir = path.root_dir(cfg.rocks_dir) | ||
87 | print() | 88 | print() |
88 | print(name.." "..version.." is now installed in "..cfg.root_dir.." "..license) | 89 | print(name.." "..version.." is now installed in "..root_dir.." "..license) |
89 | 90 | ||
90 | util.remove_scheduled_function(rollback) | 91 | util.remove_scheduled_function(rollback) |
91 | return true | 92 | return true |
@@ -107,10 +108,8 @@ function run(...) | |||
107 | return nil, "Argument missing, see help." | 108 | return nil, "Argument missing, see help." |
108 | end | 109 | end |
109 | 110 | ||
110 | if not flags["local"] and (fs.exists(cfg.root_dir) and not fs.is_writable(cfg.root_dir)) then | 111 | local ok, err = fs.check_command_permissions(flags) |
111 | return nil, "Your user does not have write permissions in " .. cfg.root_dir .. | 112 | if not ok then return nil, err end |
112 | " \n-- you may want to run as a privileged user or use your local tree with --local." | ||
113 | end | ||
114 | 113 | ||
115 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then | 114 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then |
116 | local build = require("luarocks.build") | 115 | local build = require("luarocks.build") |
diff --git a/src/luarocks/make.lua b/src/luarocks/make.lua index ec3772ac..4af5a16c 100644 --- a/src/luarocks/make.lua +++ b/src/luarocks/make.lua | |||
@@ -32,10 +32,8 @@ function run(...) | |||
32 | local flags, rockspec = util.parse_flags(...) | 32 | local flags, rockspec = util.parse_flags(...) |
33 | assert(type(rockspec) == "string" or not rockspec) | 33 | assert(type(rockspec) == "string" or not rockspec) |
34 | 34 | ||
35 | if not flags["local"] and not fs.is_writable(cfg.root_dir) then | 35 | local ok, err = fs.check_command_permissions(flags) |
36 | return nil, "Your user does not have write permissions in " .. cfg.root_dir .. | 36 | if not ok then return nil, err end |
37 | " \n-- you may want to run as a privileged user or use your local tree with --local." | ||
38 | end | ||
39 | 37 | ||
40 | if not rockspec then | 38 | if not rockspec then |
41 | local files = fs.list_dir(fs.current_dir()) | 39 | local files = fs.list_dir(fs.current_dir()) |
diff --git a/src/luarocks/show.lua b/src/luarocks/show.lua index 82568d13..34837c19 100644 --- a/src/luarocks/show.lua +++ b/src/luarocks/show.lua | |||
@@ -83,7 +83,7 @@ function run(...) | |||
83 | --question: what do we do about multiple versions? This should | 83 | --question: what do we do about multiple versions? This should |
84 | --give us the latest version on the last repo (which is usually the global one) | 84 | --give us the latest version on the last repo (which is usually the global one) |
85 | for vs, repos in util.sortedpairs(versions, deps.compare_versions) do | 85 | for vs, repos in util.sortedpairs(versions, deps.compare_versions) do |
86 | version = vs | 86 | if not version then version = vs end |
87 | for _, rp in ipairs(repos) do repo_url = rp.repo end | 87 | for _, rp in ipairs(repos) do repo_url = rp.repo end |
88 | end | 88 | end |
89 | 89 | ||
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index ed70b2ba..10fc1e36 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -362,4 +362,3 @@ function show_table(t, name, indent) | |||
362 | addtocart(t, name, indent) | 362 | addtocart(t, name, indent) |
363 | return cart .. autoref | 363 | return cart .. autoref |
364 | end | 364 | end |
365 | |||