diff options
-rw-r--r-- | Makefile | 9 | ||||
-rwxr-xr-x | configure | 6 | ||||
-rw-r--r-- | install.bat | 12 | ||||
-rw-r--r-- | rockspec | 2 | ||||
-rw-r--r-- | src/luarocks/add.lua | 11 | ||||
-rw-r--r-- | src/luarocks/admin_remove.lua | 2 | ||||
-rw-r--r-- | src/luarocks/build.lua | 12 | ||||
-rw-r--r-- | src/luarocks/cfg.lua | 39 | ||||
-rw-r--r-- | src/luarocks/fs/unix.lua | 6 | ||||
-rw-r--r-- | src/luarocks/fs/win32.lua | 6 | ||||
-rw-r--r-- | src/luarocks/fs/win32/tools.lua | 2 | ||||
-rw-r--r-- | src/luarocks/install.lua | 3 | ||||
-rw-r--r-- | src/luarocks/make_manifest.lua | 2 | ||||
-rw-r--r-- | src/luarocks/manif.lua | 102 | ||||
-rw-r--r-- | src/luarocks/path.lua | 26 | ||||
-rw-r--r-- | src/luarocks/purge.lua | 2 | ||||
-rw-r--r-- | src/luarocks/repos.lua | 20 | ||||
-rw-r--r-- | src/luarocks/tools/patch.lua | 2 | ||||
-rw-r--r-- | src/luarocks/unpack.lua | 4 | ||||
-rw-r--r-- | src/luarocks/util.lua | 9 |
20 files changed, 217 insertions, 60 deletions
@@ -24,7 +24,14 @@ admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua purge. | |||
24 | 24 | ||
25 | CONFIG_FILE = $(SYSCONFDIR)/config-$(LUA_VERSION).lua | 25 | CONFIG_FILE = $(SYSCONFDIR)/config-$(LUA_VERSION).lua |
26 | 26 | ||
27 | all: built | 27 | all: |
28 | @echo "- Type 'make build' and 'make install':" | ||
29 | @echo " to install to $(PREFIX) as usual." | ||
30 | @echo "- Type 'make bootstrap':" | ||
31 | @echo " to install LuaRocks in $(PREFIX) as a rock." | ||
32 | @echo | ||
33 | |||
34 | build: built | ||
28 | 35 | ||
29 | src/luarocks/site_config.lua: config.unix | 36 | src/luarocks/site_config.lua: config.unix |
30 | rm -f src/luarocks/site_config.lua | 37 | rm -f src/luarocks/site_config.lua |
@@ -436,5 +436,9 @@ echo "Using Lua from: $LUA_DIR" | |||
436 | make clean > /dev/null 2> /dev/null | 436 | make clean > /dev/null 2> /dev/null |
437 | 437 | ||
438 | echo | 438 | echo |
439 | echo "Done. You can now run 'make' to build." | 439 | echo "Done configuring." |
440 | echo "- Type 'make build' and 'make install':" | ||
441 | echo " to install to $PREFIX as usual." | ||
442 | echo "- Type 'make bootstrap':" | ||
443 | echo " to install LuaRocks in $PREFIX as a rock." | ||
440 | echo | 444 | echo |
diff --git a/install.bat b/install.bat index d5e32957..15f26070 100644 --- a/install.bat +++ b/install.bat | |||
@@ -5,7 +5,7 @@ rem=rem --[[ | |||
5 | local vars = {} | 5 | local vars = {} |
6 | 6 | ||
7 | vars.PREFIX = [[C:\LuaRocks]] | 7 | vars.PREFIX = [[C:\LuaRocks]] |
8 | vars.VERSION = "2.0" | 8 | vars.VERSION = "2.1" |
9 | vars.SYSCONFDIR = [[C:\LuaRocks]] | 9 | vars.SYSCONFDIR = [[C:\LuaRocks]] |
10 | vars.ROCKS_TREE = [[C:\LuaRocks]] | 10 | vars.ROCKS_TREE = [[C:\LuaRocks]] |
11 | vars.SCRIPTS_DIR = nil | 11 | vars.SCRIPTS_DIR = nil |
@@ -340,9 +340,13 @@ local function look_for_lua_install () | |||
340 | look_for_link_libraries(vars.LUA_LIBDIR) and | 340 | look_for_link_libraries(vars.LUA_LIBDIR) and |
341 | look_for_headers(vars.LUA_INCDIR) | 341 | look_for_headers(vars.LUA_INCDIR) |
342 | then | 342 | then |
343 | if exec(S"$LUA_BINDIR\\$LUA_INTERPRETER -v 2>NUL") then | 343 | if get_runtime() then |
344 | print(" Ok") | 344 | print("Runtime check completed, now testing interpreter...") |
345 | return true | 345 | if exec(S[[$LUA_BINDIR\$LUA_INTERPRETER -v 2>NUL]]) then |
346 | print(" Ok") | ||
347 | return true | ||
348 | end | ||
349 | print(" Interpreter returned an error, not ok") | ||
346 | end | 350 | end |
347 | end | 351 | end |
348 | return false | 352 | return false |
@@ -1,5 +1,5 @@ | |||
1 | package = "LuaRocks" | 1 | package = "LuaRocks" |
2 | local VER = "2.0.13" | 2 | local VER = "2.1.0" |
3 | local REV = "1" | 3 | local REV = "1" |
4 | version = VER.."-"..REV | 4 | version = VER.."-"..REV |
5 | 5 | ||
diff --git a/src/luarocks/add.lua b/src/luarocks/add.lua index 30db9a48..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") | 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 | ||
@@ -76,6 +76,11 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
76 | login_url = login_url .. "/" | 76 | login_url = login_url .. "/" |
77 | end | 77 | end |
78 | 78 | ||
79 | table.insert(files, "index.html") | ||
80 | table.insert(files, "manifest") | ||
81 | table.insert(files, "manifest-5.1") | ||
82 | table.insert(files, "manifest-5.2") | ||
83 | |||
79 | -- TODO abstract away explicit 'curl' call | 84 | -- TODO abstract away explicit 'curl' call |
80 | 85 | ||
81 | local cmd | 86 | local cmd |
@@ -84,9 +89,9 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
84 | cmd = cfg.variables.RSYNC.." --exclude=.git -Oavz -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/" | 89 | cmd = cfg.variables.RSYNC.." --exclude=.git -Oavz -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/" |
85 | elseif upload_server and upload_server.sftp then | 90 | elseif upload_server and upload_server.sftp then |
86 | local part1, part2 = upload_server.sftp:match("^([^/]*)/(.*)$") | 91 | local part1, part2 = upload_server.sftp:match("^([^/]*)/(.*)$") |
87 | cmd = cfg.variables.SCP.." manifest index.html "..table.concat(files, " ").." "..user.."@"..part1..":/"..part2 | 92 | cmd = cfg.variables.SCP.." "..table.concat(files, " ").." "..user.."@"..part1..":/"..part2 |
88 | else | 93 | else |
89 | cmd = cfg.variables.CURL.." "..login_info.." -T '{manifest,index.html,"..table.concat(files, ",").."}' "..login_url | 94 | cmd = cfg.variables.CURL.." "..login_info.." -T '{"..table.concat(files, ",").."}' "..login_url |
90 | end | 95 | end |
91 | 96 | ||
92 | util.printout(cmd) | 97 | util.printout(cmd) |
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/build.lua b/src/luarocks/build.lua index 83abbf8d..71b3cb89 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -111,8 +111,9 @@ end | |||
111 | -- @param minimal_mode boolean: true if there's no need to fetch, | 111 | -- @param minimal_mode boolean: true if there's no need to fetch, |
112 | -- unpack or change dir (this is used by "luarocks make"). Implies | 112 | -- unpack or change dir (this is used by "luarocks make"). Implies |
113 | -- need_to_fetch = false. | 113 | -- need_to_fetch = false. |
114 | -- @param deps_mode: string: Which trees to check dependencies for: | 114 | -- @param deps_mode string: Dependency mode: "one" for the current default tree, |
115 | -- "none", "one", "order" or "all". | 115 | -- "all" for all trees, "order" for all trees with priority >= the current default, |
116 | -- "none" for no trees. | ||
116 | -- @return boolean or (nil, string, [string]): True if succeeded or | 117 | -- @return boolean or (nil, string, [string]): True if succeeded or |
117 | -- nil and an error message followed by an error code. | 118 | -- nil and an error message followed by an error code. |
118 | function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_mode) | 119 | function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_mode) |
@@ -196,6 +197,10 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_mode) | |||
196 | build.type = "builtin" | 197 | build.type = "builtin" |
197 | end | 198 | end |
198 | 199 | ||
200 | if cfg.accepted_build_types and util.array_contains(cfg.accepted_build_types, build.type) then | ||
201 | return nil, "This rockspec uses the '"..build.type.."' build type, which is blocked by the 'accepted_build_types' setting in your LuaRocks configuration." | ||
202 | end | ||
203 | |||
199 | local build_type | 204 | local build_type |
200 | ok, build_type = pcall(require, "luarocks.build." .. build.type) | 205 | ok, build_type = pcall(require, "luarocks.build." .. build.type) |
201 | if not ok or not type(build_type) == "table" then | 206 | if not ok or not type(build_type) == "table" then |
@@ -275,7 +280,8 @@ end | |||
275 | -- @param need_to_fetch boolean: true if sources need to be fetched, | 280 | -- @param need_to_fetch boolean: true if sources need to be fetched, |
276 | -- false if the rockspec was obtained from inside a source rock. | 281 | -- false if the rockspec was obtained from inside a source rock. |
277 | -- @param deps_mode: string: Which trees to check dependencies for: | 282 | -- @param deps_mode: string: Which trees to check dependencies for: |
278 | -- "none", "one", "order" or "all". | 283 | -- "one" for the current default tree, "all" for all trees, |
284 | -- "order" for all trees with priority >= the current default, "none" for no trees. | ||
279 | -- @return boolean or (nil, string, [string]): True if build was successful, | 285 | -- @return boolean or (nil, string, [string]): True if build was successful, |
280 | -- or false and an error message and an optional error code. | 286 | -- or false and an error message and an optional error code. |
281 | function build_rock(rock_file, need_to_fetch, deps_mode) | 287 | function build_rock(rock_file, need_to_fetch, deps_mode) |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index f3cbe1fb..5d918b13 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -30,7 +30,7 @@ end | |||
30 | 30 | ||
31 | _M.site_config = site_config | 31 | _M.site_config = site_config |
32 | 32 | ||
33 | program_version = "2.0.13" | 33 | program_version = "2.1.0" |
34 | 34 | ||
35 | local persist = require("luarocks.persist") | 35 | local persist = require("luarocks.persist") |
36 | 36 | ||
@@ -137,13 +137,13 @@ if not site_config.LUAROCKS_FORCE_CONFIG then | |||
137 | local home_overrides, err | 137 | local home_overrides, err |
138 | home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG") | 138 | home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG") |
139 | if home_config_file then | 139 | if home_config_file then |
140 | home_overrides, err = persist.load_into_table(home_config_file, { home = home }) | 140 | home_overrides, err = persist.load_into_table(home_config_file, { home = home, lua_version = lua_version }) |
141 | else | 141 | else |
142 | home_config_file = home_config_dir.."/config-"..lua_version..".lua" | 142 | home_config_file = home_config_dir.."/config-"..lua_version..".lua" |
143 | home_overrides, err = persist.load_into_table(home_config_file, { home = home }) | 143 | home_overrides, err = persist.load_into_table(home_config_file, { home = home, lua_version = lua_version }) |
144 | if not home_overrides then | 144 | if not home_overrides then |
145 | home_config_file = home_config_dir.."/config.lua" | 145 | home_config_file = home_config_dir.."/config.lua" |
146 | home_overrides, err = persist.load_into_table(home_config_file, { home = home }) | 146 | home_overrides, err = persist.load_into_table(home_config_file, { home = home, lua_version = lua_version }) |
147 | end | 147 | end |
148 | end | 148 | end |
149 | if home_overrides then | 149 | if home_overrides then |
@@ -182,6 +182,7 @@ local defaults = { | |||
182 | use_extensions = false, | 182 | use_extensions = false, |
183 | accept_unknown_fields = false, | 183 | accept_unknown_fields = false, |
184 | fs_use_modules = true, | 184 | fs_use_modules = true, |
185 | hooks_enabled = true, | ||
185 | deps_mode = "one", | 186 | deps_mode = "one", |
186 | 187 | ||
187 | lua_modules_path = "/share/lua/"..lua_version, | 188 | lua_modules_path = "/share/lua/"..lua_version, |
@@ -305,7 +306,7 @@ if detected.windows then | |||
305 | end | 306 | end |
306 | 307 | ||
307 | if detected.mingw32 then | 308 | if detected.mingw32 then |
308 | defaults.platforms = { "win32", "mingw32" } | 309 | defaults.platforms = { "win32", "mingw32", "windows" } |
309 | defaults.obj_extension = "o" | 310 | defaults.obj_extension = "o" |
310 | defaults.cmake_generator = "MinGW Makefiles" | 311 | defaults.cmake_generator = "MinGW Makefiles" |
311 | defaults.variables.MAKE = "mingw32-make" | 312 | defaults.variables.MAKE = "mingw32-make" |
@@ -442,15 +443,25 @@ local cfg_mt = { | |||
442 | } | 443 | } |
443 | setmetatable(_M, cfg_mt) | 444 | setmetatable(_M, cfg_mt) |
444 | 445 | ||
445 | for _,tree in ipairs(rocks_trees) do | 446 | function package_paths() |
446 | if type(tree) == "string" then | 447 | local new_path, new_cpath = {}, {} |
447 | package.path = tree..lua_modules_path.."/?.lua;"..tree..lua_modules_path.."/?/init.lua;"..package.path | 448 | for _,tree in ipairs(rocks_trees) do |
448 | package.cpath = tree..lib_modules_path.."/?."..lib_extension..";"..package.cpath | 449 | if type(tree) == "string" then |
449 | else | 450 | table.insert(new_path, 1, tree..lua_modules_path.."/?.lua;"..tree..lua_modules_path.."/?/init.lua") |
450 | package.path = (tree.lua_dir or tree.root..lua_modules_path).."/?.lua;".. | 451 | table.insert(new_cpath, 1, tree..lib_modules_path.."/?."..lib_extension) |
451 | (tree.lua_dir or tree.root..lua_modules_path).."/?/init.lua;"..package.path | 452 | else |
452 | package.cpath = (tree.lib_dir or tree.root..lib_modules_path).."/?."..lib_extension..";"..package.cpath | 453 | table.insert(new_path, 1, (tree.lua_dir or tree.root..lua_modules_path).."/?.lua;".. |
453 | end | 454 | (tree.lua_dir or tree.root..lua_modules_path).."/?/init.lua") |
455 | table.insert(new_cpath, 1, (tree.lib_dir or tree.root..lib_modules_path).."/?."..lib_extension) | ||
456 | end | ||
457 | end | ||
458 | return table.concat(new_path, ";"), table.concat(new_cpath, ";") | ||
459 | end | ||
460 | |||
461 | do | ||
462 | local new_path, new_cpath = package_paths() | ||
463 | package.path = new_path..";"..package.path | ||
464 | package.cpath = new_cpath..";"..package.cpath | ||
454 | end | 465 | end |
455 | 466 | ||
456 | function which_config() | 467 | function which_config() |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index cfd20c70..cccbbd33 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
@@ -43,9 +43,11 @@ end | |||
43 | --- Create a wrapper to make a script executable from the command-line. | 43 | --- Create a wrapper to make a script executable from the command-line. |
44 | -- @param file string: Pathname of script to be made executable. | 44 | -- @param file string: Pathname of script to be made executable. |
45 | -- @param dest string: Directory where to put the wrapper. | 45 | -- @param dest string: Directory where to put the wrapper. |
46 | -- @param name string: rock name to be used in loader context. | ||
47 | -- @param version string: rock version to be used in loader context. | ||
46 | -- @return boolean or (nil, string): True if succeeded, or nil and | 48 | -- @return boolean or (nil, string): True if succeeded, or nil and |
47 | -- an error message. | 49 | -- an error message. |
48 | function wrap_script(file, dest) | 50 | function wrap_script(file, dest, name, version) |
49 | assert(type(file) == "string") | 51 | assert(type(file) == "string") |
50 | assert(type(dest) == "string") | 52 | assert(type(dest) == "string") |
51 | 53 | ||
@@ -59,7 +61,7 @@ function wrap_script(file, dest) | |||
59 | wrapper:write('LUA_PATH="'..package.path..';$LUA_PATH"\n') | 61 | wrapper:write('LUA_PATH="'..package.path..';$LUA_PATH"\n') |
60 | wrapper:write('LUA_CPATH="'..package.cpath..';$LUA_CPATH"\n') | 62 | wrapper:write('LUA_CPATH="'..package.cpath..';$LUA_CPATH"\n') |
61 | wrapper:write('export LUA_PATH LUA_CPATH\n') | 63 | wrapper:write('export LUA_PATH LUA_CPATH\n') |
62 | wrapper:write('exec "'..dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)..'" -lluarocks.loader "'..file..'" "$@"\n') | 64 | wrapper:write('exec "'..dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)..'" -lluarocks.loader -e\'luarocks.loader.add_context([['..name..']],[['..version..']])\' "'..file..'" "$@"\n') |
63 | wrapper:close() | 65 | wrapper:close() |
64 | if fs.chmod(wrapname, "0755") then | 66 | if fs.chmod(wrapname, "0755") then |
65 | return true | 67 | return true |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 2c78d9b6..2b5bb955 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
@@ -52,9 +52,11 @@ end | |||
52 | --- Create a wrapper to make a script executable from the command-line. | 52 | --- Create a wrapper to make a script executable from the command-line. |
53 | -- @param file string: Pathname of script to be made executable. | 53 | -- @param file string: Pathname of script to be made executable. |
54 | -- @param dest string: Directory where to put the wrapper. | 54 | -- @param dest string: Directory where to put the wrapper. |
55 | -- @param name string: rock name to be used in loader context. | ||
56 | -- @param version string: rock version to be used in loader context. | ||
55 | -- @return boolean or (nil, string): True if succeeded, or nil and | 57 | -- @return boolean or (nil, string): True if succeeded, or nil and |
56 | -- an error message. | 58 | -- an error message. |
57 | function wrap_script(file, dest) | 59 | function wrap_script(file, dest, name, version) |
58 | assert(type(file) == "string") | 60 | assert(type(file) == "string") |
59 | assert(type(dest) == "string") | 61 | assert(type(dest) == "string") |
60 | 62 | ||
@@ -69,7 +71,7 @@ function wrap_script(file, dest) | |||
69 | wrapper:write("setlocal\n") | 71 | wrapper:write("setlocal\n") |
70 | wrapper:write('set LUA_PATH='..package.path..";%LUA_PATH%\n") | 72 | wrapper:write('set LUA_PATH='..package.path..";%LUA_PATH%\n") |
71 | wrapper:write('set LUA_CPATH='..package.cpath..";%LUA_CPATH%\n") | 73 | wrapper:write('set LUA_CPATH='..package.cpath..";%LUA_CPATH%\n") |
72 | wrapper:write('"'..dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)..'" -lluarocks.loader "'..file..'" %*\n') | 74 | wrapper:write('"'..dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)..'" -lluarocks.loader -e\'luarocks.loader.add_context([['..name..']],[['..version..']])\' "'..file..'" %*\n') |
73 | wrapper:write("endlocal\n") | 75 | wrapper:write("endlocal\n") |
74 | wrapper:close() | 76 | wrapper:close() |
75 | return true | 77 | return true |
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index 033f71be..1af1dd91 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua | |||
@@ -146,7 +146,7 @@ end | |||
146 | -- plus an error message. | 146 | -- plus an error message. |
147 | function copy_contents(src, dest) | 147 | function copy_contents(src, dest) |
148 | assert(src and dest) | 148 | assert(src and dest) |
149 | if fs.execute_string(fs.quiet(vars.CP.." -a "..src.."\\*.* "..fs.Q(dest))) then | 149 | if fs.execute_string(fs.quiet(vars.CP.." -dR "..src.."\\*.* "..fs.Q(dest))) then |
150 | return true | 150 | return true |
151 | else | 151 | else |
152 | return false, "Failed copying "..src.." to "..dest | 152 | return false, "Failed copying "..src.." to "..dest |
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index c2a54482..3960dcb8 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
@@ -24,7 +24,8 @@ or a filename of a locally available rock. | |||
24 | --- Install a binary rock. | 24 | --- Install a binary rock. |
25 | -- @param rock_file string: local or remote filename of a rock. | 25 | -- @param rock_file string: local or remote filename of a rock. |
26 | -- @param deps_mode: string: Which trees to check dependencies for: | 26 | -- @param deps_mode: string: Which trees to check dependencies for: |
27 | -- "none", "one", "order" or "all". | 27 | -- "one" for the current default tree, "all" for all trees, |
28 | -- "order" for all trees with priority >= the current default, "none" for no trees. | ||
28 | -- @return boolean or (nil, string, [string]): True if succeeded or | 29 | -- @return boolean or (nil, string, [string]): True if succeeded or |
29 | -- nil and an error message and an optional error code. | 30 | -- nil and an error message and an optional error code. |
30 | function install_binary_rock(rock_file, deps_mode) | 31 | function install_binary_rock(rock_file, deps_mode) |
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 414c3262..c17da71e 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -81,6 +81,16 @@ function make_rock_manifest(name, version) | |||
81 | save_table(install_dir, "rock_manifest", rock_manifest ) | 81 | save_table(install_dir, "rock_manifest", rock_manifest ) |
82 | end | 82 | end |
83 | 83 | ||
84 | local function fetch_manifest_from(repo_url, filename) | ||
85 | local url = dir.path(repo_url, filename) | ||
86 | local name = repo_url:gsub("[/:]","_") | ||
87 | local file, err, errcode = fetch.fetch_url_at_temp_dir(url, "luarocks-manifest-"..name) | ||
88 | if not file then | ||
89 | return nil, "Failed fetching manifest for "..repo_url..(err and " - "..err or ""), errcode | ||
90 | end | ||
91 | return file | ||
92 | end | ||
93 | |||
84 | --- Load a local or remote manifest describing a repository. | 94 | --- Load a local or remote manifest describing a repository. |
85 | -- All functions that use manifest tables assume they were obtained | 95 | -- All functions that use manifest tables assume they were obtained |
86 | -- through either this function or load_local_manifest. | 96 | -- through either this function or load_local_manifest. |
@@ -94,15 +104,23 @@ function load_manifest(repo_url) | |||
94 | return manif_core.manifest_cache[repo_url] | 104 | return manif_core.manifest_cache[repo_url] |
95 | end | 105 | end |
96 | 106 | ||
107 | local vmanifest = "manifest-"..cfg.lua_version | ||
108 | |||
97 | local protocol, pathname = dir.split_url(repo_url) | 109 | local protocol, pathname = dir.split_url(repo_url) |
98 | if protocol == "file" then | 110 | if protocol == "file" then |
99 | pathname = dir.path(pathname, "manifest") | 111 | local file = dir.path(pathname, vmanifest) |
112 | if fs.exists(file) then | ||
113 | pathname = file | ||
114 | else | ||
115 | pathname = dir.path(pathname, "manifest") | ||
116 | end | ||
100 | else | 117 | else |
101 | local url = dir.path(repo_url, "manifest") | 118 | local file, err = fetch_manifest_from(repo_url, vmanifest) |
102 | local name = repo_url:gsub("[/:]","_") | ||
103 | local file, err, errcode = fetch.fetch_url_at_temp_dir(url, "luarocks-manifest-"..name) | ||
104 | if not file then | 119 | if not file then |
105 | return nil, "Failed fetching manifest for "..repo_url..(err and " - "..err or ""), errcode | 120 | file, err = fetch_manifest_from(repo_url, "manifest") |
121 | end | ||
122 | if not file then | ||
123 | return nil, err | ||
106 | end | 124 | end |
107 | pathname = file | 125 | pathname = file |
108 | end | 126 | end |
@@ -185,11 +203,21 @@ end | |||
185 | -- and any dependency inconsistencies or missing dependencies are reported to | 203 | -- and any dependency inconsistencies or missing dependencies are reported to |
186 | -- standard error. | 204 | -- standard error. |
187 | -- @param manifest table: a manifest table. | 205 | -- @param manifest table: a manifest table. |
188 | local function update_dependencies(manifest, deps_mode) | 206 | -- @param deps_mode string: Dependency mode: "one" for the current default tree, |
207 | -- "all" for all trees, "order" for all trees with priority >= the current default, | ||
208 | -- "none" for no trees. | ||
209 | -- @param repodir string: directory of repository being scanned | ||
210 | -- @param filter_lua string or nil: filter by Lua version | ||
211 | -- @param cache table: temporary rockspec cache table | ||
212 | local function update_dependencies(manifest, deps_mode, repodir, filter_lua, cache) | ||
189 | assert(type(manifest) == "table") | 213 | assert(type(manifest) == "table") |
190 | assert(type(deps_mode) == "string") | 214 | assert(type(deps_mode) == "string") |
191 | 215 | ||
216 | cache = cache or {} | ||
217 | local lua_version = filter_lua and deps.parse_version(filter_lua) | ||
218 | |||
192 | for pkg, versions in pairs(manifest.repository) do | 219 | for pkg, versions in pairs(manifest.repository) do |
220 | local to_remove = {} | ||
193 | for version, repositories in pairs(versions) do | 221 | for version, repositories in pairs(versions) do |
194 | local current = pkg.." "..version | 222 | local current = pkg.." "..version |
195 | for _, repo in ipairs(repositories) do | 223 | for _, repo in ipairs(repositories) do |
@@ -206,9 +234,36 @@ local function update_dependencies(manifest, deps_mode) | |||
206 | end | 234 | end |
207 | end | 235 | end |
208 | end | 236 | end |
237 | elseif filter_lua and repo.arch == "rockspec" then | ||
238 | local pathname = dir.path(repodir, pkg.."-"..version..".rockspec") | ||
239 | local rockspec, err = cache[pathname] | ||
240 | if not rockspec then | ||
241 | rockspec, err = fetch.load_local_rockspec(pathname) | ||
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 | ||
251 | end | ||
252 | end | ||
253 | else | ||
254 | util.printerr("Error loading rockspec for "..pkg.." "..version..": "..err) | ||
255 | end | ||
209 | end | 256 | end |
210 | end | 257 | end |
211 | end | 258 | end |
259 | if next(to_remove) then | ||
260 | for _, incompat in ipairs(to_remove) do | ||
261 | manifest.repository[pkg][incompat] = nil | ||
262 | end | ||
263 | if not next(manifest.repository[pkg]) then | ||
264 | manifest.repository[pkg] = nil | ||
265 | end | ||
266 | end | ||
212 | end | 267 | end |
213 | end | 268 | end |
214 | 269 | ||
@@ -216,8 +271,14 @@ end | |||
216 | -- @param results table: The search results as returned by search.disk_search. | 271 | -- @param results table: The search results as returned by search.disk_search. |
217 | -- @param manifest table: A manifest table (must contain repository, modules, commands tables). | 272 | -- @param manifest table: A manifest table (must contain repository, modules, commands tables). |
218 | -- It will be altered to include the search results. | 273 | -- It will be altered to include the search results. |
274 | -- @param deps_mode string: Dependency mode: "one" for the current default tree, | ||
275 | -- "all" for all trees, "order" for all trees with priority >= the current default, | ||
276 | -- "none" for no trees. | ||
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 | ||
219 | -- @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. |
220 | local function store_results(results, manifest, deps_mode) | 281 | local function store_results(results, manifest, deps_mode, repo, filter_lua, cache) |
221 | assert(type(results) == "table") | 282 | assert(type(results) == "table") |
222 | assert(type(manifest) == "table") | 283 | assert(type(manifest) == "table") |
223 | assert(type(deps_mode) == "string") | 284 | assert(type(deps_mode) == "string") |
@@ -243,7 +304,7 @@ local function store_results(results, manifest, deps_mode) | |||
243 | end | 304 | end |
244 | manifest.repository[name] = pkgtable | 305 | manifest.repository[name] = pkgtable |
245 | end | 306 | end |
246 | update_dependencies(manifest, deps_mode) | 307 | update_dependencies(manifest, deps_mode, repo, filter_lua, cache) |
247 | sort_package_matching_table(manifest.modules) | 308 | sort_package_matching_table(manifest.modules) |
248 | sort_package_matching_table(manifest.commands) | 309 | sort_package_matching_table(manifest.commands) |
249 | return true | 310 | return true |
@@ -253,9 +314,13 @@ end | |||
253 | -- A file called 'manifest' will be written in the root of the given | 314 | -- A file called 'manifest' will be written in the root of the given |
254 | -- repository directory. | 315 | -- repository directory. |
255 | -- @param repo A local repository directory. | 316 | -- @param repo A local repository directory. |
317 | -- @param deps_mode string: Dependency mode: "one" for the current default tree, | ||
318 | -- "all" for all trees, "order" for all trees with priority >= the current default, | ||
319 | -- "none" for the default dependency mode from the configuration. | ||
320 | -- @param versioned boolean: if versioned versions of the manifest should be created. | ||
256 | -- @return boolean or (nil, string): True if manifest was generated, | 321 | -- @return boolean or (nil, string): True if manifest was generated, |
257 | -- or nil and an error message. | 322 | -- or nil and an error message. |
258 | function make_manifest(repo, deps_mode) | 323 | function make_manifest(repo, deps_mode, versioned) |
259 | assert(type(repo) == "string") | 324 | assert(type(repo) == "string") |
260 | assert(type(deps_mode) == "string") | 325 | assert(type(deps_mode) == "string") |
261 | 326 | ||
@@ -270,11 +335,21 @@ function make_manifest(repo, deps_mode) | |||
270 | query.arch = "any" | 335 | query.arch = "any" |
271 | local results = search.disk_search(repo, query) | 336 | local results = search.disk_search(repo, query) |
272 | local manifest = { repository = {}, modules = {}, commands = {} } | 337 | local manifest = { repository = {}, modules = {}, commands = {} } |
338 | |||
273 | manif_core.manifest_cache[repo] = manifest | 339 | manif_core.manifest_cache[repo] = manifest |
274 | 340 | ||
275 | local ok, err = store_results(results, manifest, deps_mode) | 341 | local cache = {} |
342 | local ok, err = store_results(results, manifest, deps_mode, repo, nil, cache) | ||
276 | if not ok then return nil, err end | 343 | if not ok then return nil, err end |
277 | 344 | ||
345 | if versioned then | ||
346 | for _, luaver in ipairs({"5.1", "5.2"}) do | ||
347 | local vmanifest = { repository = {}, modules = {}, commands = {} } | ||
348 | local ok, err = store_results(results, vmanifest, deps_mode, repo, luaver, cache) | ||
349 | save_table(repo, "manifest-"..luaver, vmanifest) | ||
350 | end | ||
351 | end | ||
352 | |||
278 | return save_table(repo, "manifest", manifest) | 353 | return save_table(repo, "manifest", manifest) |
279 | end | 354 | end |
280 | 355 | ||
@@ -286,6 +361,9 @@ end | |||
286 | -- @param version string: Version of a package from the repository. | 361 | -- @param version string: Version of a package from the repository. |
287 | -- @param repo string or nil: Pathname of a local repository. If not given, | 362 | -- @param repo string or nil: Pathname of a local repository. If not given, |
288 | -- the default local repository configured as cfg.rocks_dir is used. | 363 | -- the default local repository configured as cfg.rocks_dir is used. |
364 | -- @param deps_mode string: Dependency mode: "one" for the current default tree, | ||
365 | -- "all" for all trees, "order" for all trees with priority >= the current default, | ||
366 | -- "none" for using the default dependency mode from the configuration. | ||
289 | -- @return boolean or (nil, string): True if manifest was generated, | 367 | -- @return boolean or (nil, string): True if manifest was generated, |
290 | -- or nil and an error message. | 368 | -- or nil and an error message. |
291 | function update_manifest(name, version, repo, deps_mode) | 369 | function update_manifest(name, version, repo, deps_mode) |
@@ -313,7 +391,7 @@ function update_manifest(name, version, repo, deps_mode) | |||
313 | 391 | ||
314 | local results = {[name] = {[version] = {{arch = "installed", repo = repo}}}} | 392 | local results = {[name] = {[version] = {{arch = "installed", repo = repo}}}} |
315 | 393 | ||
316 | local ok, err = store_results(results, manifest, deps_mode) | 394 | local ok, err = store_results(results, manifest, deps_mode, repo) |
317 | if not ok then return nil, err end | 395 | if not ok then return nil, err end |
318 | 396 | ||
319 | return save_table(repo, "manifest", manifest) | 397 | return save_table(repo, "manifest", manifest) |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index 5e380992..7af81c07 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -313,6 +313,13 @@ function use_tree(tree) | |||
313 | cfg.deploy_lib_dir = deploy_lib_dir(tree) | 313 | cfg.deploy_lib_dir = deploy_lib_dir(tree) |
314 | end | 314 | end |
315 | 315 | ||
316 | --- Apply a given function to the active rocks trees based on chosen dependency mode. | ||
317 | -- @param deps_mode string: Dependency mode: "one" for the current default tree, | ||
318 | -- "all" for all trees, "order" for all trees with priority >= the current default, | ||
319 | -- "none" for no trees (this function becomes a nop). | ||
320 | -- @param fn function: function to be applied, with the tree dir (string) as the first | ||
321 | -- argument and the remaining varargs of map_trees as the following arguments. | ||
322 | -- @return a table with all results of invocations of fn collected. | ||
316 | function map_trees(deps_mode, fn, ...) | 323 | function map_trees(deps_mode, fn, ...) |
317 | local result = {} | 324 | local result = {} |
318 | if deps_mode == "one" then | 325 | if deps_mode == "one" then |
@@ -382,13 +389,28 @@ end | |||
382 | function run(...) | 389 | function run(...) |
383 | local flags = util.parse_flags(...) | 390 | local flags = util.parse_flags(...) |
384 | local deps_mode = deps.get_deps_mode(flags) | 391 | local deps_mode = deps.get_deps_mode(flags) |
392 | |||
393 | local lr_path, lr_cpath = cfg.package_paths() | ||
394 | local bin_dirs = map_trees(deps_mode, deploy_bin_dir) | ||
395 | |||
396 | if flags["lr-path"] then | ||
397 | util.printout(util.remove_path_dupes(lr_path, ';')) | ||
398 | return true | ||
399 | elseif flags["lr-cpath"] then | ||
400 | util.printout(util.remove_path_dupes(lr_cpath, ';')) | ||
401 | return true | ||
402 | elseif flags["lr-bin"] then | ||
403 | local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) | ||
404 | util.printout(util.remove_path_dupes(lr_bin, ';')) | ||
405 | return true | ||
406 | end | ||
385 | 407 | ||
386 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';'))) | 408 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';'))) |
387 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';'))) | 409 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';'))) |
388 | if flags["bin"] then | 410 | if flags["bin"] then |
389 | local bin_dirs = map_trees(deps_mode, deploy_bin_dir) | ||
390 | table.insert(bin_dirs, 1, os.getenv("PATH")) | 411 | table.insert(bin_dirs, 1, os.getenv("PATH")) |
391 | util.printout(cfg.export_path:format(util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator))) | 412 | local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) |
413 | util.printout(cfg.export_path:format(lr_bin)) | ||
392 | end | 414 | end |
393 | return true | 415 | return true |
394 | end | 416 | end |
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 |
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index dc1b63c8..b7e64d42 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
@@ -131,6 +131,11 @@ function run_hook(rockspec, hook_name) | |||
131 | if not hooks then | 131 | if not hooks then |
132 | return true | 132 | return true |
133 | end | 133 | end |
134 | |||
135 | if cfg.hooks_enabled == false then | ||
136 | return nil, "This rockspec contains hooks, which are blocked by the 'hooks_enabled' setting in your LuaRocks configuration." | ||
137 | end | ||
138 | |||
134 | if not hooks.substituted_variables then | 139 | if not hooks.substituted_variables then |
135 | util.variable_substitutions(hooks, rockspec.variables) | 140 | util.variable_substitutions(hooks, rockspec.variables) |
136 | hooks.substituted_variables = true | 141 | hooks.substituted_variables = true |
@@ -145,7 +150,7 @@ function run_hook(rockspec, hook_name) | |||
145 | return true | 150 | return true |
146 | end | 151 | end |
147 | 152 | ||
148 | local function install_binary(source, target) | 153 | local function install_binary(source, target, name, version) |
149 | assert(type(source) == "string") | 154 | assert(type(source) == "string") |
150 | assert(type(target) == "string") | 155 | assert(type(target) == "string") |
151 | 156 | ||
@@ -155,7 +160,7 @@ local function install_binary(source, target) | |||
155 | file = io.open(source) | 160 | file = io.open(source) |
156 | end | 161 | end |
157 | if match or (file and file:read():match("^#!.*lua.*")) then | 162 | if match or (file and file:read():match("^#!.*lua.*")) then |
158 | ok, err = fs.wrap_script(source, target) | 163 | ok, err = fs.wrap_script(source, target, name, version) |
159 | else | 164 | else |
160 | ok, err = fs.copy_binary(source, target) | 165 | ok, err = fs.copy_binary(source, target) |
161 | end | 166 | end |
@@ -195,7 +200,8 @@ function deploy_files(name, version, wrap_bin_scripts) | |||
195 | assert(type(version) == "string") | 200 | assert(type(version) == "string") |
196 | assert(type(wrap_bin_scripts) == "boolean") | 201 | assert(type(wrap_bin_scripts) == "boolean") |
197 | 202 | ||
198 | local function deploy_file_tree(file_tree, source_dir, deploy_dir, move_fn) | 203 | local function deploy_file_tree(file_tree, path_fn, deploy_dir, move_fn) |
204 | local source_dir = path_fn(name, version) | ||
199 | if not move_fn then | 205 | if not move_fn then |
200 | move_fn = fs.move | 206 | move_fn = fs.move |
201 | end | 207 | end |
@@ -215,7 +221,7 @@ function deploy_files(name, version, wrap_bin_scripts) | |||
215 | end | 221 | end |
216 | end | 222 | end |
217 | fs.make_dir(dir.dir_name(target)) | 223 | fs.make_dir(dir.dir_name(target)) |
218 | ok, err = move_fn(source, target) | 224 | ok, err = move_fn(source, target, name, version) |
219 | fs.remove_dir_tree_if_empty(dir.dir_name(source)) | 225 | fs.remove_dir_tree_if_empty(dir.dir_name(source)) |
220 | if not ok then return nil, err end | 226 | if not ok then return nil, err end |
221 | return true | 227 | return true |
@@ -228,13 +234,13 @@ function deploy_files(name, version, wrap_bin_scripts) | |||
228 | local ok, err = true | 234 | local ok, err = true |
229 | if rock_manifest.bin then | 235 | if rock_manifest.bin then |
230 | local move_bin_fn = wrap_bin_scripts and install_binary or fs.copy_binary | 236 | local move_bin_fn = wrap_bin_scripts and install_binary or fs.copy_binary |
231 | ok, err = deploy_file_tree(rock_manifest.bin, path.bin_dir(name, version), cfg.deploy_bin_dir, move_bin_fn) | 237 | ok, err = deploy_file_tree(rock_manifest.bin, path.bin_dir, cfg.deploy_bin_dir, move_bin_fn) |
232 | end | 238 | end |
233 | if ok and rock_manifest.lua then | 239 | if ok and rock_manifest.lua then |
234 | ok, err = deploy_file_tree(rock_manifest.lua, path.lua_dir(name, version), cfg.deploy_lua_dir) | 240 | ok, err = deploy_file_tree(rock_manifest.lua, path.lua_dir, cfg.deploy_lua_dir) |
235 | end | 241 | end |
236 | if ok and rock_manifest.lib then | 242 | if ok and rock_manifest.lib then |
237 | ok, err = deploy_file_tree(rock_manifest.lib, path.lib_dir(name, version), cfg.deploy_lib_dir) | 243 | ok, err = deploy_file_tree(rock_manifest.lib, path.lib_dir, cfg.deploy_lib_dir) |
238 | end | 244 | end |
239 | return ok, err | 245 | return ok, err |
240 | end | 246 | end |
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index 04154219..baaacfc1 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua | |||
@@ -95,7 +95,7 @@ local function string_as_file(s) | |||
95 | eof = false, | 95 | eof = false, |
96 | read = function(self, n) | 96 | read = function(self, n) |
97 | if self.eof then return nil end | 97 | if self.eof then return nil end |
98 | local chunk = self.str:sub(self.at, self.at+n) | 98 | local chunk = self.str:sub(self.at, self.at + n - 1) |
99 | self.at = self.at + n | 99 | self.at = self.at + n |
100 | if self.at > self.len then | 100 | if self.at > self.len then |
101 | self.eof = true | 101 | self.eof = true |
diff --git a/src/luarocks/unpack.lua b/src/luarocks/unpack.lua index 1db66bbb..67153812 100644 --- a/src/luarocks/unpack.lua +++ b/src/luarocks/unpack.lua | |||
@@ -26,7 +26,7 @@ In the latter case, the app version may be given as a second argument. | |||
26 | local function unpack_rockspec(rockspec_file, dir_name) | 26 | local function unpack_rockspec(rockspec_file, dir_name) |
27 | assert(type(rockspec_file) == "string") | 27 | assert(type(rockspec_file) == "string") |
28 | assert(type(dir_name) == "string") | 28 | assert(type(dir_name) == "string") |
29 | 29 | ||
30 | local rockspec, err = fetch.load_rockspec(rockspec_file) | 30 | local rockspec, err = fetch.load_rockspec(rockspec_file) |
31 | if not rockspec then | 31 | if not rockspec then |
32 | return nil, "Failed loading rockspec "..rockspec_file..": "..err | 32 | return nil, "Failed loading rockspec "..rockspec_file..": "..err |
@@ -52,7 +52,7 @@ end | |||
52 | local function unpack_rock(rock_file, dir_name, kind) | 52 | local function unpack_rock(rock_file, dir_name, kind) |
53 | assert(type(rock_file) == "string") | 53 | assert(type(rock_file) == "string") |
54 | assert(type(dir_name) == "string") | 54 | assert(type(dir_name) == "string") |
55 | 55 | ||
56 | local ok, err, errcode = fetch.fetch_and_unpack_rock(rock_file, dir_name) | 56 | local ok, err, errcode = fetch.fetch_and_unpack_rock(rock_file, dir_name) |
57 | if not ok then | 57 | if not ok then |
58 | return nil, "Failed unzipping rock "..rock_file, errcode | 58 | return nil, "Failed unzipping rock "..rock_file, errcode |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index c5095675..b2428f62 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -461,3 +461,12 @@ function show_table(t, name, indent) | |||
461 | addtocart(t, name, indent) | 461 | addtocart(t, name, indent) |
462 | return cart .. autoref | 462 | return cart .. autoref |
463 | end | 463 | end |
464 | |||
465 | function array_contains(tbl, value) | ||
466 | for _, v in ipairs(tbl) do | ||
467 | if v == value then | ||
468 | return true | ||
469 | end | ||
470 | end | ||
471 | return false | ||
472 | end | ||