diff options
Diffstat (limited to 'src')
68 files changed, 313 insertions, 313 deletions
diff --git a/src/luarocks/admin/cache.lua b/src/luarocks/admin/cache.lua index 1fd4d55a..10b273ea 100644 --- a/src/luarocks/admin/cache.lua +++ b/src/luarocks/admin/cache.lua | |||
@@ -24,7 +24,7 @@ function cache.get_server_urls(server, upload_server) | |||
24 | elseif upload_server.http then download_url = "http://"..upload_server.http | 24 | elseif upload_server.http then download_url = "http://"..upload_server.http |
25 | elseif upload_server.ftp then download_url = "ftp://"..upload_server.ftp | 25 | elseif upload_server.ftp then download_url = "ftp://"..upload_server.ftp |
26 | end | 26 | end |
27 | 27 | ||
28 | if upload_server.ftp then login_url = "ftp://"..upload_server.ftp | 28 | if upload_server.ftp then login_url = "ftp://"..upload_server.ftp |
29 | elseif upload_server.sftp then login_url = "sftp://"..upload_server.sftp | 29 | elseif upload_server.sftp then login_url = "sftp://"..upload_server.sftp |
30 | end | 30 | end |
@@ -57,7 +57,7 @@ local function download_cache(protocol, server_path, user, password) | |||
57 | return fs.execute(cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." -e ssh "..user.."@"..srv..":"..path.."/ ./") | 57 | return fs.execute(cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." -e ssh "..user.."@"..srv..":"..path.."/ ./") |
58 | elseif protocol == "file" then | 58 | elseif protocol == "file" then |
59 | return fs.copy_contents(server_path, ".") | 59 | return fs.copy_contents(server_path, ".") |
60 | else | 60 | else |
61 | local login_info = "" | 61 | local login_info = "" |
62 | if user then login_info = " --user="..user end | 62 | if user then login_info = " --user="..user end |
63 | if password then login_info = login_info .. " --password="..password end | 63 | if password then login_info = login_info .. " --password="..password end |
@@ -74,7 +74,7 @@ function cache.refresh_local_cache(url, given_user, given_password) | |||
74 | end | 74 | end |
75 | 75 | ||
76 | fs.change_dir(local_cache) | 76 | fs.change_dir(local_cache) |
77 | 77 | ||
78 | util.printout("Refreshing cache "..local_cache.."...") | 78 | util.printout("Refreshing cache "..local_cache.."...") |
79 | 79 | ||
80 | ok = download_cache(protocol, server_path, user, password) | 80 | ok = download_cache(protocol, server_path, user, password) |
diff --git a/src/luarocks/admin/cmd/add.lua b/src/luarocks/admin/cmd/add.lua index 5011c680..aa444c50 100644 --- a/src/luarocks/admin/cmd/add.lua +++ b/src/luarocks/admin/cmd/add.lua | |||
@@ -40,23 +40,23 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do | |||
40 | assert(type(rockfiles) == "table") | 40 | assert(type(rockfiles) == "table") |
41 | assert(type(server) == "string") | 41 | assert(type(server) == "string") |
42 | assert(type(upload_server) == "table" or not upload_server) | 42 | assert(type(upload_server) == "table" or not upload_server) |
43 | 43 | ||
44 | local download_url, login_url = cache.get_server_urls(server, upload_server) | 44 | local download_url, login_url = cache.get_server_urls(server, upload_server) |
45 | local at = fs.current_dir() | 45 | local at = fs.current_dir() |
46 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url | 46 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url |
47 | 47 | ||
48 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) | 48 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) |
49 | if not local_cache then | 49 | if not local_cache then |
50 | return nil, protocol | 50 | return nil, protocol |
51 | end | 51 | end |
52 | 52 | ||
53 | if not login_url then | 53 | if not login_url then |
54 | login_url = protocol.."://"..server_path | 54 | login_url = protocol.."://"..server_path |
55 | end | 55 | end |
56 | 56 | ||
57 | local ok, err = fs.change_dir(at) | 57 | local ok, err = fs.change_dir(at) |
58 | if not ok then return nil, err end | 58 | if not ok then return nil, err end |
59 | 59 | ||
60 | local files = {} | 60 | local files = {} |
61 | for _, rockfile in ipairs(rockfiles) do | 61 | for _, rockfile in ipairs(rockfiles) do |
62 | if fs.exists(rockfile) then | 62 | if fs.exists(rockfile) then |
@@ -77,9 +77,9 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do | |||
77 | 77 | ||
78 | util.printout("Updating manifest...") | 78 | util.printout("Updating manifest...") |
79 | writer.make_manifest(local_cache, "one", true) | 79 | writer.make_manifest(local_cache, "one", true) |
80 | 80 | ||
81 | zip_manifests() | 81 | zip_manifests() |
82 | 82 | ||
83 | if fs.exists("index.html") then | 83 | if fs.exists("index.html") then |
84 | do_index = true | 84 | do_index = true |
85 | end | 85 | end |
diff --git a/src/luarocks/admin/cmd/make_manifest.lua b/src/luarocks/admin/cmd/make_manifest.lua index b4f2ca5b..18f74b5d 100644 --- a/src/luarocks/admin/cmd/make_manifest.lua +++ b/src/luarocks/admin/cmd/make_manifest.lua | |||
@@ -27,13 +27,13 @@ end | |||
27 | -- or nil and an error message. | 27 | -- or nil and an error message. |
28 | function make_manifest.command(args) | 28 | function make_manifest.command(args) |
29 | local repo = args.repository or cfg.rocks_dir | 29 | local repo = args.repository or cfg.rocks_dir |
30 | 30 | ||
31 | util.printout("Making manifest for "..repo) | 31 | util.printout("Making manifest for "..repo) |
32 | 32 | ||
33 | if repo:match("/lib/luarocks") and not args.local_tree then | 33 | if repo:match("/lib/luarocks") and not args.local_tree then |
34 | util.warning("This looks like a local rocks tree, but you did not pass --local-tree.") | 34 | util.warning("This looks like a local rocks tree, but you did not pass --local-tree.") |
35 | end | 35 | end |
36 | 36 | ||
37 | local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args.local_tree) | 37 | local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args.local_tree) |
38 | if ok and not args.local_tree then | 38 | if ok and not args.local_tree then |
39 | util.printout("Generating index.html for "..repo) | 39 | util.printout("Generating index.html for "..repo) |
diff --git a/src/luarocks/admin/cmd/refresh_cache.lua b/src/luarocks/admin/cmd/refresh_cache.lua index 81959953..f8d51893 100644 --- a/src/luarocks/admin/cmd/refresh_cache.lua +++ b/src/luarocks/admin/cmd/refresh_cache.lua | |||
@@ -18,7 +18,7 @@ function refresh_cache.command(args) | |||
18 | local server, upload_server = cache.get_upload_server(args.server) | 18 | local server, upload_server = cache.get_upload_server(args.server) |
19 | if not server then return nil, upload_server end | 19 | if not server then return nil, upload_server end |
20 | local download_url = cache.get_server_urls(server, upload_server) | 20 | local download_url = cache.get_server_urls(server, upload_server) |
21 | 21 | ||
22 | local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) | 22 | local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) |
23 | if not ok then | 23 | if not ok then |
24 | return nil, err | 24 | return nil, err |
diff --git a/src/luarocks/admin/cmd/remove.lua b/src/luarocks/admin/cmd/remove.lua index de58f7a3..5d4c5fbb 100644 --- a/src/luarocks/admin/cmd/remove.lua +++ b/src/luarocks/admin/cmd/remove.lua | |||
@@ -32,7 +32,7 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
32 | local download_url, login_url = cache.get_server_urls(server, upload_server) | 32 | local download_url, login_url = cache.get_server_urls(server, upload_server) |
33 | local at = fs.current_dir() | 33 | local at = fs.current_dir() |
34 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url | 34 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url |
35 | 35 | ||
36 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) | 36 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) |
37 | if not local_cache then | 37 | if not local_cache then |
38 | return nil, protocol | 38 | return nil, protocol |
@@ -40,10 +40,10 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
40 | if protocol ~= "rsync" then | 40 | if protocol ~= "rsync" then |
41 | return nil, "This command requires 'rsync', check your configuration." | 41 | return nil, "This command requires 'rsync', check your configuration." |
42 | end | 42 | end |
43 | 43 | ||
44 | local ok, err = fs.change_dir(at) | 44 | local ok, err = fs.change_dir(at) |
45 | if not ok then return nil, err end | 45 | if not ok then return nil, err end |
46 | 46 | ||
47 | local nr_files = 0 | 47 | local nr_files = 0 |
48 | for _, rockfile in ipairs(rockfiles) do | 48 | for _, rockfile in ipairs(rockfiles) do |
49 | local basename = dir.base_name(rockfile) | 49 | local basename = dir.base_name(rockfile) |
diff --git a/src/luarocks/admin/index.lua b/src/luarocks/admin/index.lua index 76795104..64c8c1eb 100644 --- a/src/luarocks/admin/index.lua +++ b/src/luarocks/admin/index.lua | |||
@@ -87,7 +87,7 @@ local index_footer_begin = [[ | |||
87 | <a href="manifest">manifest file</a> | 87 | <a href="manifest">manifest file</a> |
88 | ]] | 88 | ]] |
89 | local index_manifest_ver = [[ | 89 | local index_manifest_ver = [[ |
90 | • <a href="manifest-$VER">Lua $VER manifest file</a> (<a href="manifest-$VER.zip">zip</a>) | 90 | • <a href="manifest-$VER">Lua $VER manifest file</a> (<a href="manifest-$VER.zip">zip</a>) |
91 | ]] | 91 | ]] |
92 | local index_footer_end = [[ | 92 | local index_footer_end = [[ |
93 | </p> | 93 | </p> |
@@ -129,7 +129,7 @@ function index.make_index(repo) | |||
129 | end | 129 | end |
130 | local manifest = manif.load_manifest(repo) | 130 | local manifest = manif.load_manifest(repo) |
131 | local out = io.open(dir.path(repo, "index.html"), "w") | 131 | local out = io.open(dir.path(repo, "index.html"), "w") |
132 | 132 | ||
133 | out:write(index_header) | 133 | out:write(index_header) |
134 | for package, version_list in util.sortedpairs(manifest.repository) do | 134 | for package, version_list in util.sortedpairs(manifest.repository) do |
135 | local latest_rockspec = nil | 135 | local latest_rockspec = nil |
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index ae529856..0aecca3e 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -328,7 +328,7 @@ local function write_rock_dir_files(rockspec, opts) | |||
328 | local name, version = rockspec.name, rockspec.version | 328 | local name, version = rockspec.name, rockspec.version |
329 | 329 | ||
330 | fs.copy(rockspec.local_abs_filename, path.rockspec_file(name, version), "read") | 330 | fs.copy(rockspec.local_abs_filename, path.rockspec_file(name, version), "read") |
331 | 331 | ||
332 | local deplock_file = deplocks.get_abs_filename(rockspec.name) | 332 | local deplock_file = deplocks.get_abs_filename(rockspec.name) |
333 | if deplock_file then | 333 | if deplock_file then |
334 | fs.copy(deplock_file, dir.path(path.install_dir(name, version), "luarocks.lock"), "read") | 334 | fs.copy(deplock_file, dir.path(path.install_dir(name, version), "luarocks.lock"), "read") |
@@ -375,7 +375,7 @@ function build.build_rockspec(rockspec, opts) | |||
375 | if opts.pin then | 375 | if opts.pin then |
376 | deplocks.init(rockspec.name, ".") | 376 | deplocks.init(rockspec.name, ".") |
377 | end | 377 | end |
378 | 378 | ||
379 | ok, err = process_dependencies(rockspec, opts) | 379 | ok, err = process_dependencies(rockspec, opts) |
380 | if not ok then return nil, err end | 380 | if not ok then return nil, err end |
381 | 381 | ||
@@ -385,7 +385,7 @@ function build.build_rockspec(rockspec, opts) | |||
385 | deplocks.write_file() | 385 | deplocks.write_file() |
386 | end | 386 | end |
387 | return name, version | 387 | return name, version |
388 | end | 388 | end |
389 | 389 | ||
390 | local dirs, err | 390 | local dirs, err |
391 | local rollback | 391 | local rollback |
@@ -405,13 +405,13 @@ function build.build_rockspec(rockspec, opts) | |||
405 | 405 | ||
406 | ok, err = build.apply_patches(rockspec) | 406 | ok, err = build.apply_patches(rockspec) |
407 | if not ok then return nil, err end | 407 | if not ok then return nil, err end |
408 | 408 | ||
409 | ok, err = check_macosx_deployment_target(rockspec) | 409 | ok, err = check_macosx_deployment_target(rockspec) |
410 | if not ok then return nil, err end | 410 | if not ok then return nil, err end |
411 | 411 | ||
412 | ok, err = run_build_driver(rockspec, opts.no_install) | 412 | ok, err = run_build_driver(rockspec, opts.no_install) |
413 | if not ok then return nil, err end | 413 | if not ok then return nil, err end |
414 | 414 | ||
415 | if opts.no_install then | 415 | if opts.no_install then |
416 | fs.pop_dir() | 416 | fs.pop_dir() |
417 | if opts.need_to_fetch then | 417 | if opts.need_to_fetch then |
@@ -422,7 +422,7 @@ function build.build_rockspec(rockspec, opts) | |||
422 | 422 | ||
423 | ok, err = install_files(rockspec, dirs) | 423 | ok, err = install_files(rockspec, dirs) |
424 | if not ok then return nil, err end | 424 | if not ok then return nil, err end |
425 | 425 | ||
426 | for _, d in pairs(dirs) do | 426 | for _, d in pairs(dirs) do |
427 | fs.remove_dir_if_empty(d.name) | 427 | fs.remove_dir_if_empty(d.name) |
428 | end | 428 | end |
@@ -441,7 +441,7 @@ function build.build_rockspec(rockspec, opts) | |||
441 | 441 | ||
442 | ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), opts.deps_mode) | 442 | ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), opts.deps_mode) |
443 | if not ok then return nil, err end | 443 | if not ok then return nil, err end |
444 | 444 | ||
445 | util.remove_scheduled_function(rollback) | 445 | util.remove_scheduled_function(rollback) |
446 | rollback = util.schedule_function(function() | 446 | rollback = util.schedule_function(function() |
447 | repos.delete_version(name, version, opts.deps_mode) | 447 | repos.delete_version(name, version, opts.deps_mode) |
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 6241c718..98db29da 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
@@ -266,7 +266,7 @@ function builtin.run(rockspec, no_install) | |||
266 | local lib_modules = {} | 266 | local lib_modules = {} |
267 | local luadir = path.lua_dir(rockspec.name, rockspec.version) | 267 | local luadir = path.lua_dir(rockspec.name, rockspec.version) |
268 | local libdir = path.lib_dir(rockspec.name, rockspec.version) | 268 | local libdir = path.lib_dir(rockspec.name, rockspec.version) |
269 | 269 | ||
270 | if not build.modules then | 270 | if not build.modules then |
271 | if rockspec:format_is_at_least("3.0") then | 271 | if rockspec:format_is_at_least("3.0") then |
272 | local libs, incdirs, libdirs = autoextract_libs(rockspec.external_dependencies, rockspec.variables) | 272 | local libs, incdirs, libdirs = autoextract_libs(rockspec.external_dependencies, rockspec.variables) |
diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index d7ecc83c..b7a4786e 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua | |||
@@ -36,7 +36,7 @@ function cmake.run(rockspec, no_install) | |||
36 | 36 | ||
37 | -- Execute cmake with variables. | 37 | -- Execute cmake with variables. |
38 | local args = "" | 38 | local args = "" |
39 | 39 | ||
40 | -- Try to pick the best generator. With msvc and x64, CMake does not select it by default so we need to be explicit. | 40 | -- Try to pick the best generator. With msvc and x64, CMake does not select it by default so we need to be explicit. |
41 | if cfg.cmake_generator then | 41 | if cfg.cmake_generator then |
42 | args = args .. ' -G"'..cfg.cmake_generator.. '"' | 42 | args = args .. ' -G"'..cfg.cmake_generator.. '"' |
@@ -71,7 +71,7 @@ function cmake.run(rockspec, no_install) | |||
71 | return nil, "Failed installing." | 71 | return nil, "Failed installing." |
72 | end | 72 | end |
73 | end | 73 | end |
74 | 74 | ||
75 | return true | 75 | return true |
76 | end | 76 | end |
77 | 77 | ||
diff --git a/src/luarocks/build/command.lua b/src/luarocks/build/command.lua index 309c4a16..b0c4aa79 100644 --- a/src/luarocks/build/command.lua +++ b/src/luarocks/build/command.lua | |||
@@ -14,7 +14,7 @@ function command.run(rockspec, not_install) | |||
14 | assert(rockspec:type() == "rockspec") | 14 | assert(rockspec:type() == "rockspec") |
15 | 15 | ||
16 | local build = rockspec.build | 16 | local build = rockspec.build |
17 | 17 | ||
18 | util.variable_substitutions(build, rockspec.variables) | 18 | util.variable_substitutions(build, rockspec.variables) |
19 | 19 | ||
20 | local env = { | 20 | local env = { |
diff --git a/src/luarocks/build/make.lua b/src/luarocks/build/make.lua index ccab1af0..4345ddff 100644 --- a/src/luarocks/build/make.lua +++ b/src/luarocks/build/make.lua | |||
@@ -13,7 +13,7 @@ local cfg = require("luarocks.core.cfg") | |||
13 | -- configured through variables.MAKE in the config files, or | 13 | -- configured through variables.MAKE in the config files, or |
14 | -- the appropriate platform-specific default). | 14 | -- the appropriate platform-specific default). |
15 | -- @param pass boolean: If true, run make; if false, do nothing. | 15 | -- @param pass boolean: If true, run make; if false, do nothing. |
16 | -- @param target string: The make target; an empty string indicates | 16 | -- @param target string: The make target; an empty string indicates |
17 | -- the default target. | 17 | -- the default target. |
18 | -- @param variables table: A table containing string-string key-value | 18 | -- @param variables table: A table containing string-string key-value |
19 | -- pairs representing variable assignments to be passed to make. | 19 | -- pairs representing variable assignments to be passed to make. |
@@ -42,7 +42,7 @@ function make.run(rockspec, not_install) | |||
42 | assert(rockspec:type() == "rockspec") | 42 | assert(rockspec:type() == "rockspec") |
43 | 43 | ||
44 | local build = rockspec.build | 44 | local build = rockspec.build |
45 | 45 | ||
46 | if build.build_pass == nil then build.build_pass = true end | 46 | if build.build_pass == nil then build.build_pass = true end |
47 | if build.install_pass == nil then build.install_pass = true end | 47 | if build.install_pass == nil then build.install_pass = true end |
48 | build.build_variables = build.build_variables or {} | 48 | build.build_variables = build.build_variables or {} |
@@ -56,9 +56,9 @@ function make.run(rockspec, not_install) | |||
56 | build.install_target = "-f "..makefile.." "..build.install_target | 56 | build.install_target = "-f "..makefile.." "..build.install_target |
57 | end | 57 | end |
58 | 58 | ||
59 | if build.variables then | 59 | if build.variables then |
60 | for var, val in pairs(build.variables) do | 60 | for var, val in pairs(build.variables) do |
61 | build.build_variables[var] = val | 61 | build.build_variables[var] = val |
62 | build.install_variables[var] = val | 62 | build.install_variables[var] = val |
63 | end | 63 | end |
64 | end | 64 | end |
@@ -67,9 +67,9 @@ function make.run(rockspec, not_install) | |||
67 | 67 | ||
68 | util.variable_substitutions(build.build_variables, rockspec.variables) | 68 | util.variable_substitutions(build.build_variables, rockspec.variables) |
69 | util.variable_substitutions(build.install_variables, rockspec.variables) | 69 | util.variable_substitutions(build.install_variables, rockspec.variables) |
70 | 70 | ||
71 | local auto_variables = { "CC" } | 71 | local auto_variables = { "CC" } |
72 | 72 | ||
73 | for _, variable in pairs(auto_variables) do | 73 | for _, variable in pairs(auto_variables) do |
74 | if not build.build_variables[variable] then | 74 | if not build.build_variables[variable] then |
75 | build.build_variables[variable] = rockspec.variables[variable] | 75 | build.build_variables[variable] = rockspec.variables[variable] |
@@ -79,7 +79,7 @@ function make.run(rockspec, not_install) | |||
79 | end | 79 | end |
80 | end | 80 | end |
81 | 81 | ||
82 | -- backwards compatibility | 82 | -- backwards compatibility |
83 | local make_cmd = cfg.make or rockspec.variables.MAKE | 83 | local make_cmd = cfg.make or rockspec.variables.MAKE |
84 | 84 | ||
85 | local ok = make_pass(make_cmd, build.build_pass, build.build_target, build.build_variables) | 85 | local ok = make_pass(make_cmd, build.build_pass, build.build_target, build.build_variables) |
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 21f35e20..7037c734 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -63,7 +63,7 @@ do | |||
63 | end | 63 | end |
64 | 64 | ||
65 | process_tree_args = function(args, project_dir) | 65 | process_tree_args = function(args, project_dir) |
66 | 66 | ||
67 | if args.global then | 67 | if args.global then |
68 | cfg.local_by_default = false | 68 | cfg.local_by_default = false |
69 | end | 69 | end |
@@ -221,7 +221,7 @@ do | |||
221 | end | 221 | end |
222 | return nil | 222 | return nil |
223 | end | 223 | end |
224 | 224 | ||
225 | local function find_default_lua_version(args, project_dir) | 225 | local function find_default_lua_version(args, project_dir) |
226 | if hardcoded.FORCE_CONFIG then | 226 | if hardcoded.FORCE_CONFIG then |
227 | return nil | 227 | return nil |
@@ -250,7 +250,7 @@ do | |||
250 | end | 250 | end |
251 | return nil | 251 | return nil |
252 | end | 252 | end |
253 | 253 | ||
254 | local function find_version_from_config(dirname) | 254 | local function find_version_from_config(dirname) |
255 | return fun.find(util.lua_versions("descending"), function(v) | 255 | return fun.find(util.lua_versions("descending"), function(v) |
256 | if util.exists(dir.path(dirname, ".luarocks", "config-"..v..".lua")) then | 256 | if util.exists(dir.path(dirname, ".luarocks", "config-"..v..".lua")) then |
@@ -258,12 +258,12 @@ do | |||
258 | end | 258 | end |
259 | end) | 259 | end) |
260 | end | 260 | end |
261 | 261 | ||
262 | local function detect_lua_via_args(args, project_dir) | 262 | local function detect_lua_via_args(args, project_dir) |
263 | local lua_version = args.lua_version | 263 | local lua_version = args.lua_version |
264 | or find_default_lua_version(args, project_dir) | 264 | or find_default_lua_version(args, project_dir) |
265 | or (project_dir and find_version_from_config(project_dir)) | 265 | or (project_dir and find_version_from_config(project_dir)) |
266 | 266 | ||
267 | if args.lua_dir then | 267 | if args.lua_dir then |
268 | local detected, err = util.find_lua(args.lua_dir, lua_version) | 268 | local detected, err = util.find_lua(args.lua_dir, lua_version) |
269 | if not detected then | 269 | if not detected then |
@@ -274,7 +274,7 @@ do | |||
274 | end | 274 | end |
275 | return detected | 275 | return detected |
276 | end | 276 | end |
277 | 277 | ||
278 | if lua_version then | 278 | if lua_version then |
279 | local detected = search_lua_in_path(lua_version) | 279 | local detected = search_lua_in_path(lua_version) |
280 | if detected then | 280 | if detected then |
@@ -284,10 +284,10 @@ do | |||
284 | lua_version = lua_version, | 284 | lua_version = lua_version, |
285 | } | 285 | } |
286 | end | 286 | end |
287 | 287 | ||
288 | return {} | 288 | return {} |
289 | end | 289 | end |
290 | 290 | ||
291 | detect_config_via_args = function(args) | 291 | detect_config_via_args = function(args) |
292 | local project_dir, given = find_project_dir(args.project_tree) | 292 | local project_dir, given = find_project_dir(args.project_tree) |
293 | local detected = detect_lua_via_args(args, project_dir) | 293 | local detected = detect_lua_via_args(args, project_dir) |
@@ -304,15 +304,15 @@ do | |||
304 | return detected | 304 | return detected |
305 | end | 305 | end |
306 | end | 306 | end |
307 | 307 | ||
308 | init_config = function(args) | 308 | init_config = function(args) |
309 | local detected = detect_config_via_args(args) | 309 | local detected = detect_config_via_args(args) |
310 | 310 | ||
311 | local ok, err = cfg.init(detected, util.warning) | 311 | local ok, err = cfg.init(detected, util.warning) |
312 | if not ok then | 312 | if not ok then |
313 | return nil, err | 313 | return nil, err |
314 | end | 314 | end |
315 | 315 | ||
316 | return (detected.lua_dir ~= nil) | 316 | return (detected.lua_dir ~= nil) |
317 | end | 317 | end |
318 | end | 318 | end |
diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index d1fccfdd..4500bcc9 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua | |||
@@ -145,7 +145,7 @@ function cmd_build.command(args) | |||
145 | return name, version, errcode | 145 | return name, version, errcode |
146 | end) | 146 | end) |
147 | end | 147 | end |
148 | 148 | ||
149 | local ok, err = fs.check_command_permissions(args) | 149 | local ok, err = fs.check_command_permissions(args) |
150 | if not ok then | 150 | if not ok then |
151 | return nil, err, cmd.errorcodes.PERMISSIONDENIED | 151 | return nil, err, cmd.errorcodes.PERMISSIONDENIED |
diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua index ab1b9da7..6a73c7ff 100644 --- a/src/luarocks/cmd/config.lua +++ b/src/luarocks/cmd/config.lua | |||
@@ -29,7 +29,7 @@ Query information about the LuaRocks configuration. | |||
29 | * `lua_dir` is a special key as it checks for a valid Lua installation | 29 | * `lua_dir` is a special key as it checks for a valid Lua installation |
30 | (equivalent to --lua-dir) and sets several keys at once. | 30 | (equivalent to --lua-dir) and sets several keys at once. |
31 | * `lua_version` is a special key as it changes the default Lua version | 31 | * `lua_version` is a special key as it changes the default Lua version |
32 | used by LuaRocks commands (equivalent to passing --lua-version). | 32 | used by LuaRocks commands (equivalent to passing --lua-version). |
33 | 33 | ||
34 | Examples: | 34 | Examples: |
35 | luarocks config variables.OPENSSL_DIR /usr/local/openssl | 35 | luarocks config variables.OPENSSL_DIR /usr/local/openssl |
@@ -114,7 +114,7 @@ local function traverse_varstring(var, tbl, fn, missing_parent) | |||
114 | k, r = var:match("^([^[]+)(%[.*)$") | 114 | k, r = var:match("^([^[]+)(%[.*)$") |
115 | end | 115 | end |
116 | end | 116 | end |
117 | 117 | ||
118 | if k then | 118 | if k then |
119 | if not tbl[k] and missing_parent then | 119 | if not tbl[k] and missing_parent then |
120 | missing_parent(tbl, k) | 120 | missing_parent(tbl, k) |
@@ -131,7 +131,7 @@ local function traverse_varstring(var, tbl, fn, missing_parent) | |||
131 | if i then | 131 | if i then |
132 | var = tonumber(i) | 132 | var = tonumber(i) |
133 | end | 133 | end |
134 | 134 | ||
135 | return fn(tbl, var) | 135 | return fn(tbl, var) |
136 | end | 136 | end |
137 | 137 | ||
@@ -179,12 +179,12 @@ local function write_entries(keys, scope, do_unset) | |||
179 | if scope == "project" and not cfg.config_files.project then | 179 | if scope == "project" and not cfg.config_files.project then |
180 | return nil, "Current directory is not part of a project. You may want to run `luarocks init`." | 180 | return nil, "Current directory is not part of a project. You may want to run `luarocks init`." |
181 | end | 181 | end |
182 | 182 | ||
183 | local tbl, err = persist.load_config_file_if_basic(cfg.config_files[scope].file, cfg) | 183 | local tbl, err = persist.load_config_file_if_basic(cfg.config_files[scope].file, cfg) |
184 | if not tbl then | 184 | if not tbl then |
185 | return nil, err | 185 | return nil, err |
186 | end | 186 | end |
187 | 187 | ||
188 | for var, val in util.sortedpairs(keys) do | 188 | for var, val in util.sortedpairs(keys) do |
189 | traverse_varstring(var, tbl, function(t, k) | 189 | traverse_varstring(var, tbl, function(t, k) |
190 | if do_unset then | 190 | if do_unset then |
@@ -242,7 +242,7 @@ end | |||
242 | function config_cmd.command(args) | 242 | function config_cmd.command(args) |
243 | deps.check_lua_incdir(cfg.variables, args.lua_version or cfg.lua_version) | 243 | deps.check_lua_incdir(cfg.variables, args.lua_version or cfg.lua_version) |
244 | deps.check_lua_libdir(cfg.variables, args.lua_version or cfg.lua_version) | 244 | deps.check_lua_libdir(cfg.variables, args.lua_version or cfg.lua_version) |
245 | 245 | ||
246 | -- deprecated flags | 246 | -- deprecated flags |
247 | if args.lua_incdir then | 247 | if args.lua_incdir then |
248 | print(cfg.variables.LUA_INCDIR) | 248 | print(cfg.variables.LUA_INCDIR) |
@@ -287,7 +287,7 @@ function config_cmd.command(args) | |||
287 | end | 287 | end |
288 | print("Lua version will default to " .. args.value .. " in " .. prefix) | 288 | print("Lua version will default to " .. args.value .. " in " .. prefix) |
289 | end | 289 | end |
290 | 290 | ||
291 | if args.key == "lua_dir" and args.value then | 291 | if args.key == "lua_dir" and args.value then |
292 | local scope = get_scope(args) | 292 | local scope = get_scope(args) |
293 | local keys = { | 293 | local keys = { |
diff --git a/src/luarocks/cmd/doc.lua b/src/luarocks/cmd/doc.lua index 2ab7e43c..ae471230 100644 --- a/src/luarocks/cmd/doc.lua +++ b/src/luarocks/cmd/doc.lua | |||
@@ -67,7 +67,7 @@ function doc.command(args) | |||
67 | return try_to_open_homepage(args.rock, args.namespace, args.version) | 67 | return try_to_open_homepage(args.rock, args.namespace, args.version) |
68 | end | 68 | end |
69 | local name, version = iname, iversion | 69 | local name, version = iname, iversion |
70 | 70 | ||
71 | local rockspec, err = fetch.load_local_rockspec(path.rockspec_file(name, version, repo)) | 71 | local rockspec, err = fetch.load_local_rockspec(path.rockspec_file(name, version, repo)) |
72 | if not rockspec then return nil,err end | 72 | if not rockspec then return nil,err end |
73 | local descript = rockspec.description or {} | 73 | local descript = rockspec.description or {} |
@@ -77,7 +77,7 @@ function doc.command(args) | |||
77 | end | 77 | end |
78 | 78 | ||
79 | local directory = path.install_dir(name, version, repo) | 79 | local directory = path.install_dir(name, version, repo) |
80 | 80 | ||
81 | local docdir | 81 | local docdir |
82 | local directories = { "doc", "docs" } | 82 | local directories = { "doc", "docs" } |
83 | for _, d in ipairs(directories) do | 83 | for _, d in ipairs(directories) do |
@@ -101,7 +101,7 @@ function doc.command(args) | |||
101 | local htmlpatt = "%.html?$" | 101 | local htmlpatt = "%.html?$" |
102 | local extensions = { htmlpatt, "%.md$", "%.txt$", "%.textile$", "" } | 102 | local extensions = { htmlpatt, "%.md$", "%.txt$", "%.textile$", "" } |
103 | local basenames = { "index", "readme", "manual" } | 103 | local basenames = { "index", "readme", "manual" } |
104 | 104 | ||
105 | local porcelain = args.porcelain | 105 | local porcelain = args.porcelain |
106 | if #files > 0 then | 106 | if #files > 0 then |
107 | util.title("Documentation files for "..name.." "..version, porcelain) | 107 | util.title("Documentation files for "..name.." "..version, porcelain) |
@@ -116,11 +116,11 @@ function doc.command(args) | |||
116 | end | 116 | end |
117 | end | 117 | end |
118 | end | 118 | end |
119 | 119 | ||
120 | if args.list then | 120 | if args.list then |
121 | return true | 121 | return true |
122 | end | 122 | end |
123 | 123 | ||
124 | for _, extension in ipairs(extensions) do | 124 | for _, extension in ipairs(extensions) do |
125 | for _, basename in ipairs(basenames) do | 125 | for _, basename in ipairs(basenames) do |
126 | local filename = basename..extension | 126 | local filename = basename..extension |
diff --git a/src/luarocks/cmd/download.lua b/src/luarocks/cmd/download.lua index 1f844595..eae82439 100644 --- a/src/luarocks/cmd/download.lua +++ b/src/luarocks/cmd/download.lua | |||
@@ -43,7 +43,7 @@ function cmd_download.command(args) | |||
43 | elseif args.arch then | 43 | elseif args.arch then |
44 | arch = args.arch | 44 | arch = args.arch |
45 | end | 45 | end |
46 | 46 | ||
47 | local dl, err = download.download(arch, args.name, args.namespace, args.version, args.all, args.check_lua_versions) | 47 | local dl, err = download.download(arch, args.name, args.namespace, args.version, args.all, args.check_lua_versions) |
48 | return dl and true, err | 48 | return dl and true, err |
49 | end | 49 | end |
diff --git a/src/luarocks/cmd/init.lua b/src/luarocks/cmd/init.lua index 5f269e22..af88760f 100644 --- a/src/luarocks/cmd/init.lua +++ b/src/luarocks/cmd/init.lua | |||
@@ -30,7 +30,7 @@ local function write_gitignore(entries) | |||
30 | fd:close() | 30 | fd:close() |
31 | gitignore = "\n" .. gitignore .. "\n" | 31 | gitignore = "\n" .. gitignore .. "\n" |
32 | end | 32 | end |
33 | 33 | ||
34 | fd = io.open(".gitignore", gitignore and "a" or "w") | 34 | fd = io.open(".gitignore", gitignore and "a" or "w") |
35 | for _, entry in ipairs(entries) do | 35 | for _, entry in ipairs(entries) do |
36 | entry = "/" .. entry | 36 | entry = "/" .. entry |
@@ -64,7 +64,7 @@ function init.command(args) | |||
64 | if not ok then | 64 | if not ok then |
65 | return nil, err | 65 | return nil, err |
66 | end | 66 | end |
67 | 67 | ||
68 | local has_rockspec = false | 68 | local has_rockspec = false |
69 | for file in fs.dir() do | 69 | for file in fs.dir() do |
70 | if file:match("%.rockspec$") then | 70 | if file:match("%.rockspec$") then |
@@ -97,7 +97,7 @@ function init.command(args) | |||
97 | fs.delete(lua_wrapper) | 97 | fs.delete(lua_wrapper) |
98 | fs.delete(config_file) | 98 | fs.delete(config_file) |
99 | end | 99 | end |
100 | 100 | ||
101 | local config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) | 101 | local config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) |
102 | if config_tbl then | 102 | if config_tbl then |
103 | local globals = { | 103 | local globals = { |
@@ -131,7 +131,7 @@ function init.command(args) | |||
131 | else | 131 | else |
132 | util.printout("Will not attempt to overwrite " .. config_file) | 132 | util.printout("Will not attempt to overwrite " .. config_file) |
133 | end | 133 | end |
134 | 134 | ||
135 | ok, err = persist.save_default_lua_version(".luarocks", cfg.lua_version) | 135 | ok, err = persist.save_default_lua_version(".luarocks", cfg.lua_version) |
136 | if not ok then | 136 | if not ok then |
137 | util.printout("Failed setting default Lua version: " .. err) | 137 | util.printout("Failed setting default Lua version: " .. err) |
@@ -158,7 +158,7 @@ function init.command(args) | |||
158 | write_lua_wrapper = false | 158 | write_lua_wrapper = false |
159 | end | 159 | end |
160 | end | 160 | end |
161 | 161 | ||
162 | if write_lua_wrapper then | 162 | if write_lua_wrapper then |
163 | local interp = dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter) | 163 | local interp = dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter) |
164 | if util.check_lua_version(interp, cfg.lua_version) then | 164 | if util.check_lua_version(interp, cfg.lua_version) then |
diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index 760649b0..da9e1ce3 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua | |||
@@ -75,16 +75,16 @@ function install.install_binary_rock(rock_file, opts) | |||
75 | if not name then | 75 | if not name then |
76 | return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." | 76 | return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." |
77 | end | 77 | end |
78 | 78 | ||
79 | if arch ~= "all" and arch ~= cfg.arch then | 79 | if arch ~= "all" and arch ~= cfg.arch then |
80 | return nil, "Incompatible architecture "..arch, "arch" | 80 | return nil, "Incompatible architecture "..arch, "arch" |
81 | end | 81 | end |
82 | if repos.is_installed(name, version) then | 82 | if repos.is_installed(name, version) then |
83 | repos.delete_version(name, version, opts.deps_mode) | 83 | repos.delete_version(name, version, opts.deps_mode) |
84 | end | 84 | end |
85 | 85 | ||
86 | local install_dir = path.install_dir(name, version) | 86 | local install_dir = path.install_dir(name, version) |
87 | 87 | ||
88 | local rollback = util.schedule_function(function() | 88 | local rollback = util.schedule_function(function() |
89 | fs.delete(install_dir) | 89 | fs.delete(install_dir) |
90 | fs.remove_dir_if_empty(path.versions_dir(name)) | 90 | fs.remove_dir_if_empty(path.versions_dir(name)) |
@@ -139,7 +139,7 @@ end | |||
139 | -- @param rock_file string: local or remote filename of a rock. | 139 | -- @param rock_file string: local or remote filename of a rock. |
140 | -- @param opts table: installation options | 140 | -- @param opts table: installation options |
141 | -- @return (string, string) or (nil, string, [string]): Name and version of | 141 | -- @return (string, string) or (nil, string, [string]): Name and version of |
142 | -- the rock whose dependencies were installed if succeeded or nil and an error message | 142 | -- the rock whose dependencies were installed if succeeded or nil and an error message |
143 | -- followed by an error code. | 143 | -- followed by an error code. |
144 | function install.install_binary_rock_deps(rock_file, opts) | 144 | function install.install_binary_rock_deps(rock_file, opts) |
145 | assert(type(rock_file) == "string") | 145 | assert(type(rock_file) == "string") |
@@ -149,7 +149,7 @@ function install.install_binary_rock_deps(rock_file, opts) | |||
149 | if not name then | 149 | if not name then |
150 | return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." | 150 | return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." |
151 | end | 151 | end |
152 | 152 | ||
153 | if arch ~= "all" and arch ~= cfg.arch then | 153 | if arch ~= "all" and arch ~= cfg.arch then |
154 | return nil, "Incompatible architecture "..arch, "arch" | 154 | return nil, "Incompatible architecture "..arch, "arch" |
155 | end | 155 | end |
@@ -158,7 +158,7 @@ function install.install_binary_rock_deps(rock_file, opts) | |||
158 | 158 | ||
159 | local ok, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) | 159 | local ok, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) |
160 | if not ok then return nil, err, errcode end | 160 | if not ok then return nil, err, errcode end |
161 | 161 | ||
162 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) | 162 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) |
163 | if err then | 163 | if err then |
164 | return nil, "Failed loading rockspec for installed package: "..err, errcode | 164 | return nil, "Failed loading rockspec for installed package: "..err, errcode |
diff --git a/src/luarocks/cmd/lint.lua b/src/luarocks/cmd/lint.lua index 20c842ff..47a3da90 100644 --- a/src/luarocks/cmd/lint.lua +++ b/src/luarocks/cmd/lint.lua | |||
@@ -33,8 +33,8 @@ function lint.command(args) | |||
33 | end | 33 | end |
34 | 34 | ||
35 | local ok = true | 35 | local ok = true |
36 | 36 | ||
37 | -- This should have been done in the type checker, | 37 | -- This should have been done in the type checker, |
38 | -- but it would break compatibility of other commands. | 38 | -- but it would break compatibility of other commands. |
39 | -- Making 'lint' alone be stricter shouldn't be a problem, | 39 | -- Making 'lint' alone be stricter shouldn't be a problem, |
40 | -- because extra-strict checks is what lint-type commands | 40 | -- because extra-strict checks is what lint-type commands |
diff --git a/src/luarocks/cmd/list.lua b/src/luarocks/cmd/list.lua index aa815ea3..7b2682f6 100644 --- a/src/luarocks/cmd/list.lua +++ b/src/luarocks/cmd/list.lua | |||
@@ -36,13 +36,13 @@ local function check_outdated(trees, query) | |||
36 | 36 | ||
37 | local query_available = queries.new(name:lower()) | 37 | local query_available = queries.new(name:lower()) |
38 | local results_available, err = search.search_repos(query_available) | 38 | local results_available, err = search.search_repos(query_available) |
39 | 39 | ||
40 | if results_available[name] then | 40 | if results_available[name] then |
41 | local available_versions = util.keys(results_available[name]) | 41 | local available_versions = util.keys(results_available[name]) |
42 | table.sort(available_versions, vers.compare_versions) | 42 | table.sort(available_versions, vers.compare_versions) |
43 | local latest_available = available_versions[1] | 43 | local latest_available = available_versions[1] |
44 | local latest_available_repo = results_available[name][latest_available][1].repo | 44 | local latest_available_repo = results_available[name][latest_available][1].repo |
45 | 45 | ||
46 | if vers.compare_versions(latest_available, latest_installed) then | 46 | if vers.compare_versions(latest_available, latest_installed) then |
47 | table.insert(outdated, { name = name, installed = latest_installed, available = latest_available, repo = latest_available_repo }) | 47 | table.insert(outdated, { name = name, installed = latest_installed, available = latest_available, repo = latest_available_repo }) |
48 | end | 48 | end |
@@ -76,11 +76,11 @@ function list.command(args) | |||
76 | trees = { args.tree } | 76 | trees = { args.tree } |
77 | title = title .. " in " .. args.tree | 77 | title = title .. " in " .. args.tree |
78 | end | 78 | end |
79 | 79 | ||
80 | if args.outdated then | 80 | if args.outdated then |
81 | return list_outdated(trees, query, args.porcelain) | 81 | return list_outdated(trees, query, args.porcelain) |
82 | end | 82 | end |
83 | 83 | ||
84 | local results = {} | 84 | local results = {} |
85 | for _, tree in ipairs(trees) do | 85 | for _, tree in ipairs(trees) do |
86 | local ok, err, errcode = search.local_manifest_search(results, path.rocks_dir(tree), query) | 86 | local ok, err, errcode = search.local_manifest_search(results, path.rocks_dir(tree), query) |
diff --git a/src/luarocks/cmd/new_version.lua b/src/luarocks/cmd/new_version.lua index fc15ef46..49479910 100644 --- a/src/luarocks/cmd/new_version.lua +++ b/src/luarocks/cmd/new_version.lua | |||
@@ -60,7 +60,7 @@ local function try_replace(tbl, field, old, new) | |||
60 | if new_field ~= old_field then | 60 | if new_field ~= old_field then |
61 | util.printout("Guessing new '"..field.."' field as "..new_field) | 61 | util.printout("Guessing new '"..field.."' field as "..new_field) |
62 | tbl[field] = new_field | 62 | tbl[field] = new_field |
63 | return true | 63 | return true |
64 | end | 64 | end |
65 | return false | 65 | return false |
66 | end | 66 | end |
@@ -104,7 +104,7 @@ local function check_url_and_update_md5(out_rs, invalid_is_error) | |||
104 | end | 104 | end |
105 | end | 105 | end |
106 | end | 106 | end |
107 | 107 | ||
108 | local function update_source_section(out_rs, url, tag, old_ver, new_ver) | 108 | local function update_source_section(out_rs, url, tag, old_ver, new_ver) |
109 | if tag then | 109 | if tag then |
110 | out_rs.source.tag = tag | 110 | out_rs.source.tag = tag |
@@ -144,7 +144,7 @@ local function update_source_section(out_rs, url, tag, old_ver, new_ver) | |||
144 | end | 144 | end |
145 | return true | 145 | return true |
146 | end | 146 | end |
147 | 147 | ||
148 | function new_version.command(args) | 148 | function new_version.command(args) |
149 | if not args.rock then | 149 | if not args.rock then |
150 | local err | 150 | local err |
@@ -153,7 +153,7 @@ function new_version.command(args) | |||
153 | return nil, err | 153 | return nil, err |
154 | end | 154 | end |
155 | end | 155 | end |
156 | 156 | ||
157 | local filename, err | 157 | local filename, err |
158 | if args.rock:match("rockspec$") then | 158 | if args.rock:match("rockspec$") then |
159 | filename, err = fetch.fetch_url(args.rock) | 159 | filename, err = fetch.fetch_url(args.rock) |
@@ -178,7 +178,7 @@ function new_version.command(args) | |||
178 | if args.tag and not args.new_version then | 178 | if args.tag and not args.new_version then |
179 | args.new_version = args.tag:gsub("^v", "") | 179 | args.new_version = args.tag:gsub("^v", "") |
180 | end | 180 | end |
181 | 181 | ||
182 | local out_dir | 182 | local out_dir |
183 | if args.dir then | 183 | if args.dir then |
184 | out_dir = dir.normalize(args.dir) | 184 | out_dir = dir.normalize(args.dir) |
@@ -196,7 +196,7 @@ function new_version.command(args) | |||
196 | new_rev = tonumber(old_rev) + 1 | 196 | new_rev = tonumber(old_rev) + 1 |
197 | end | 197 | end |
198 | local new_rockver = new_ver:gsub("-", "") | 198 | local new_rockver = new_ver:gsub("-", "") |
199 | 199 | ||
200 | local out_rs, err = persist.load_into_table(filename) | 200 | local out_rs, err = persist.load_into_table(filename) |
201 | local out_name = out_rs.package:lower() | 201 | local out_name = out_rs.package:lower() |
202 | out_rs.version = new_rockver.."-"..new_rev | 202 | out_rs.version = new_rockver.."-"..new_rev |
@@ -207,21 +207,21 @@ function new_version.command(args) | |||
207 | if out_rs.build and out_rs.build.type == "module" then | 207 | if out_rs.build and out_rs.build.type == "module" then |
208 | out_rs.build.type = "builtin" | 208 | out_rs.build.type = "builtin" |
209 | end | 209 | end |
210 | 210 | ||
211 | local out_filename = out_name.."-"..new_rockver.."-"..new_rev..".rockspec" | 211 | local out_filename = out_name.."-"..new_rockver.."-"..new_rev..".rockspec" |
212 | if out_dir then | 212 | if out_dir then |
213 | out_filename = dir.path(out_dir, out_filename) | 213 | out_filename = dir.path(out_dir, out_filename) |
214 | fs.make_dir(out_dir) | 214 | fs.make_dir(out_dir) |
215 | end | 215 | end |
216 | persist.save_from_table(out_filename, out_rs, type_rockspec.order) | 216 | persist.save_from_table(out_filename, out_rs, type_rockspec.order) |
217 | 217 | ||
218 | util.printout("Wrote "..out_filename) | 218 | util.printout("Wrote "..out_filename) |
219 | 219 | ||
220 | local valid_out_rs, err = fetch.load_local_rockspec(out_filename) | 220 | local valid_out_rs, err = fetch.load_local_rockspec(out_filename) |
221 | if not valid_out_rs then | 221 | if not valid_out_rs then |
222 | return nil, "Failed loading generated rockspec: "..err | 222 | return nil, "Failed loading generated rockspec: "..err |
223 | end | 223 | end |
224 | 224 | ||
225 | return true | 225 | return true |
226 | end | 226 | end |
227 | 227 | ||
diff --git a/src/luarocks/cmd/path.lua b/src/luarocks/cmd/path.lua index 9d6a8217..9b6fee71 100644 --- a/src/luarocks/cmd/path.lua +++ b/src/luarocks/cmd/path.lua | |||
@@ -10,11 +10,11 @@ local fs = require("luarocks.fs") | |||
10 | function path_cmd.add_to_parser(parser) | 10 | function path_cmd.add_to_parser(parser) |
11 | local cmd = parser:command("path", [[ | 11 | local cmd = parser:command("path", [[ |
12 | Returns the package path currently configured for this installation | 12 | Returns the package path currently configured for this installation |
13 | of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH. | 13 | of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH. |
14 | 14 | ||
15 | On Unix systems, you may run: | 15 | On Unix systems, you may run: |
16 | eval `luarocks path` | 16 | eval `luarocks path` |
17 | And on Windows: | 17 | And on Windows: |
18 | luarocks path > "%temp%\_lrp.bat" && call "%temp%\_lrp.bat" && del "%temp%\_lrp.bat"]], | 18 | luarocks path > "%temp%\_lrp.bat" && call "%temp%\_lrp.bat" && del "%temp%\_lrp.bat"]], |
19 | util.see_also()) | 19 | util.see_also()) |
20 | :summary("Return the currently configured package path.") | 20 | :summary("Return the currently configured package path.") |
@@ -56,7 +56,7 @@ function path_cmd.command(args) | |||
56 | lr_cpath = lr_cpath .. ";" .. package.cpath | 56 | lr_cpath = lr_cpath .. ";" .. package.cpath |
57 | lr_bin = lr_bin .. path_sep .. clean_path | 57 | lr_bin = lr_bin .. path_sep .. clean_path |
58 | end | 58 | end |
59 | 59 | ||
60 | local lpath_var, lcpath_var = util.lua_path_variables() | 60 | local lpath_var, lcpath_var = util.lua_path_variables() |
61 | 61 | ||
62 | util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version, args.append))) | 62 | util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version, args.append))) |
diff --git a/src/luarocks/cmd/purge.lua b/src/luarocks/cmd/purge.lua index fa4be4d7..2b5873d7 100644 --- a/src/luarocks/cmd/purge.lua +++ b/src/luarocks/cmd/purge.lua | |||
@@ -42,7 +42,7 @@ function purge.command(args) | |||
42 | if type(tree) ~= "string" then | 42 | if type(tree) ~= "string" then |
43 | return nil, "The --tree argument is mandatory. "..util.see_help("purge") | 43 | return nil, "The --tree argument is mandatory. "..util.see_help("purge") |
44 | end | 44 | end |
45 | 45 | ||
46 | local results = {} | 46 | local results = {} |
47 | if not fs.is_dir(tree) then | 47 | if not fs.is_dir(tree) then |
48 | return nil, "Directory not found: "..tree | 48 | return nil, "Directory not found: "..tree |
diff --git a/src/luarocks/cmd/remove.lua b/src/luarocks/cmd/remove.lua index 46f3e4a6..17723ec9 100644 --- a/src/luarocks/cmd/remove.lua +++ b/src/luarocks/cmd/remove.lua | |||
@@ -42,10 +42,10 @@ end | |||
42 | function cmd_remove.command(args) | 42 | function cmd_remove.command(args) |
43 | local name = args.rock | 43 | local name = args.rock |
44 | local deps_mode = deps.get_deps_mode(args) | 44 | local deps_mode = deps.get_deps_mode(args) |
45 | 45 | ||
46 | local ok, err = fs.check_command_permissions(args) | 46 | local ok, err = fs.check_command_permissions(args) |
47 | if not ok then return nil, err, cmd.errorcodes.PERMISSIONDENIED end | 47 | if not ok then return nil, err, cmd.errorcodes.PERMISSIONDENIED end |
48 | 48 | ||
49 | local rock_type = name:match("%.(rock)$") or name:match("%.(rockspec)$") | 49 | local rock_type = name:match("%.(rock)$") or name:match("%.(rockspec)$") |
50 | local version = args.version | 50 | local version = args.version |
51 | local filename = name | 51 | local filename = name |
diff --git a/src/luarocks/cmd/search.lua b/src/luarocks/cmd/search.lua index 181fdacc..6cab6d80 100644 --- a/src/luarocks/cmd/search.lua +++ b/src/luarocks/cmd/search.lua | |||
@@ -63,7 +63,7 @@ function cmd_search.command(args) | |||
63 | if not args.name and not args.all then | 63 | if not args.name and not args.all then |
64 | return nil, "Enter name and version or use --all. "..util.see_help("search") | 64 | return nil, "Enter name and version or use --all. "..util.see_help("search") |
65 | end | 65 | end |
66 | 66 | ||
67 | local query = queries.new(name, args.namespace, args.version, true) | 67 | local query = queries.new(name, args.namespace, args.version, true) |
68 | local result_tree, err = search.search_repos(query) | 68 | local result_tree, err = search.search_repos(query) |
69 | local porcelain = args.porcelain | 69 | local porcelain = args.porcelain |
diff --git a/src/luarocks/cmd/show.lua b/src/luarocks/cmd/show.lua index c1c155e2..d93459fd 100644 --- a/src/luarocks/cmd/show.lua +++ b/src/luarocks/cmd/show.lua | |||
@@ -100,7 +100,7 @@ local function keys_as_string(t, sep) | |||
100 | return table.concat(keys, sep or " ") | 100 | return table.concat(keys, sep or " ") |
101 | end | 101 | end |
102 | 102 | ||
103 | local function word_wrap(line) | 103 | local function word_wrap(line) |
104 | local width = tonumber(os.getenv("COLUMNS")) or 80 | 104 | local width = tonumber(os.getenv("COLUMNS")) or 80 |
105 | if width > 80 then width = 80 end | 105 | if width > 80 then width = 80 end |
106 | if #line > width then | 106 | if #line > width then |
@@ -265,7 +265,7 @@ end | |||
265 | -- @return boolean: True if succeeded, nil on errors. | 265 | -- @return boolean: True if succeeded, nil on errors. |
266 | function show.command(args) | 266 | function show.command(args) |
267 | local query = queries.new(args.rock, args.namespace, args.version, true) | 267 | local query = queries.new(args.rock, args.namespace, args.version, true) |
268 | 268 | ||
269 | local name, version, repo, repo_url = search.pick_installed_rock(query, args.tree) | 269 | local name, version, repo, repo_url = search.pick_installed_rock(query, args.tree) |
270 | if not name then | 270 | if not name then |
271 | return nil, version | 271 | return nil, version |
diff --git a/src/luarocks/cmd/test.lua b/src/luarocks/cmd/test.lua index 7a1ffda2..21838c90 100644 --- a/src/luarocks/cmd/test.lua +++ b/src/luarocks/cmd/test.lua | |||
@@ -33,9 +33,9 @@ function cmd_test.command(args) | |||
33 | if args.rockspec and args.rockspec:match("rockspec$") then | 33 | if args.rockspec and args.rockspec:match("rockspec$") then |
34 | return test.run_test_suite(args.rockspec, args.test_type, args.args) | 34 | return test.run_test_suite(args.rockspec, args.test_type, args.args) |
35 | end | 35 | end |
36 | 36 | ||
37 | table.insert(args.args, 1, args.rockspec) | 37 | table.insert(args.args, 1, args.rockspec) |
38 | 38 | ||
39 | local rockspec, err = util.get_default_rockspec() | 39 | local rockspec, err = util.get_default_rockspec() |
40 | if not rockspec then | 40 | if not rockspec then |
41 | return nil, err | 41 | return nil, err |
diff --git a/src/luarocks/cmd/unpack.lua b/src/luarocks/cmd/unpack.lua index b9bec4a6..94da2c9f 100644 --- a/src/luarocks/cmd/unpack.lua +++ b/src/luarocks/cmd/unpack.lua | |||
@@ -32,7 +32,7 @@ end | |||
32 | -- files specified in the rockspec, and unpack them inside the directory. | 32 | -- files specified in the rockspec, and unpack them inside the directory. |
33 | -- @param rockspec_file string: The URL for a rockspec file. | 33 | -- @param rockspec_file string: The URL for a rockspec file. |
34 | -- @param dir_name string: The directory where to store and unpack files. | 34 | -- @param dir_name string: The directory where to store and unpack files. |
35 | -- @return table or (nil, string): the loaded rockspec table or | 35 | -- @return table or (nil, string): the loaded rockspec table or |
36 | -- nil and an error message. | 36 | -- nil and an error message. |
37 | local function unpack_rockspec(rockspec_file, dir_name) | 37 | local function unpack_rockspec(rockspec_file, dir_name) |
38 | assert(type(rockspec_file) == "string") | 38 | assert(type(rockspec_file) == "string") |
@@ -61,7 +61,7 @@ end | |||
61 | -- @param dir_name string: The directory where to unpack. | 61 | -- @param dir_name string: The directory where to unpack. |
62 | -- @param kind string: the kind of rock file, as in the second-level | 62 | -- @param kind string: the kind of rock file, as in the second-level |
63 | -- extension in the rock filename (eg. "src", "all", "linux-x86") | 63 | -- extension in the rock filename (eg. "src", "all", "linux-x86") |
64 | -- @return table or (nil, string): the loaded rockspec table or | 64 | -- @return table or (nil, string): the loaded rockspec table or |
65 | -- nil and an error message. | 65 | -- nil and an error message. |
66 | local function unpack_rock(rock_file, dir_name, kind) | 66 | local function unpack_rock(rock_file, dir_name, kind) |
67 | assert(type(rock_file) == "string") | 67 | assert(type(rock_file) == "string") |
@@ -102,7 +102,7 @@ end | |||
102 | -- by an error message. | 102 | -- by an error message. |
103 | local function run_unpacker(file, force) | 103 | local function run_unpacker(file, force) |
104 | assert(type(file) == "string") | 104 | assert(type(file) == "string") |
105 | 105 | ||
106 | local base_name = dir.base_name(file) | 106 | local base_name = dir.base_name(file) |
107 | local dir_name, kind, extension = base_name:match("(.*)%.([^.]+)%.(rock)$") | 107 | local dir_name, kind, extension = base_name:match("(.*)%.([^.]+)%.(rock)$") |
108 | if not extension then | 108 | if not extension then |
@@ -139,7 +139,7 @@ local function run_unpacker(file, force) | |||
139 | return nil, "Failed copying unpacked rockspec into unpacked source directory." | 139 | return nil, "Failed copying unpacked rockspec into unpacked source directory." |
140 | end | 140 | end |
141 | end | 141 | end |
142 | util.printout() | 142 | util.printout() |
143 | util.printout("Done. You may now enter directory ") | 143 | util.printout("Done. You may now enter directory ") |
144 | util.printout(dir.path(dir_name, rockspec.source.dir)) | 144 | util.printout(dir.path(dir_name, rockspec.source.dir)) |
145 | util.printout("and type 'luarocks make' to build.") | 145 | util.printout("and type 'luarocks make' to build.") |
diff --git a/src/luarocks/cmd/upload.lua b/src/luarocks/cmd/upload.lua index 6e3877ba..da51b401 100644 --- a/src/luarocks/cmd/upload.lua +++ b/src/luarocks/cmd/upload.lua | |||
@@ -53,7 +53,7 @@ function upload.command(args) | |||
53 | version = rockspec.version | 53 | version = rockspec.version |
54 | }) | 54 | }) |
55 | if not res then return nil, err end | 55 | if not res then return nil, err end |
56 | 56 | ||
57 | if not res.module then | 57 | if not res.module then |
58 | util.printout("Will create new module (" .. tostring(rockspec.package) .. ")") | 58 | util.printout("Will create new module (" .. tostring(rockspec.package) .. ")") |
59 | end | 59 | end |
@@ -87,7 +87,7 @@ function upload.command(args) | |||
87 | util.printout("Signed packed rock: "..rock_sigfname) | 87 | util.printout("Signed packed rock: "..rock_sigfname) |
88 | end | 88 | end |
89 | end | 89 | end |
90 | 90 | ||
91 | local multipart = require("luarocks.upload.multipart") | 91 | local multipart = require("luarocks.upload.multipart") |
92 | 92 | ||
93 | res, err = api:method("upload", nil, { | 93 | res, err = api:method("upload", nil, { |
@@ -95,13 +95,13 @@ function upload.command(args) | |||
95 | rockspec_sig = sigfname and multipart.new_file(sigfname), | 95 | rockspec_sig = sigfname and multipart.new_file(sigfname), |
96 | }) | 96 | }) |
97 | if not res then return nil, err end | 97 | if not res then return nil, err end |
98 | 98 | ||
99 | if res.is_new and #res.manifests == 0 then | 99 | if res.is_new and #res.manifests == 0 then |
100 | util.printerr("Warning: module not added to root manifest due to name taken.") | 100 | util.printerr("Warning: module not added to root manifest due to name taken.") |
101 | end | 101 | end |
102 | 102 | ||
103 | local module_url = res.module_url | 103 | local module_url = res.module_url |
104 | 104 | ||
105 | if rock_fname then | 105 | if rock_fname then |
106 | if (not res.version) or (not res.version.id) then | 106 | if (not res.version) or (not res.version.id) then |
107 | return nil, "Invalid response from server." | 107 | return nil, "Invalid response from server." |
@@ -113,7 +113,7 @@ function upload.command(args) | |||
113 | }) | 113 | }) |
114 | if not res then return nil, err end | 114 | if not res then return nil, err end |
115 | end | 115 | end |
116 | 116 | ||
117 | util.printout() | 117 | util.printout() |
118 | util.printout("Done: " .. tostring(module_url)) | 118 | util.printout("Done: " .. tostring(module_url)) |
119 | util.printout() | 119 | util.printout() |
diff --git a/src/luarocks/cmd/write_rockspec.lua b/src/luarocks/cmd/write_rockspec.lua index 5d5404e5..871cdd44 100644 --- a/src/luarocks/cmd/write_rockspec.lua +++ b/src/luarocks/cmd/write_rockspec.lua | |||
@@ -137,7 +137,7 @@ do | |||
137 | return url | 137 | return url |
138 | end | 138 | end |
139 | end | 139 | end |
140 | 140 | ||
141 | local function detect_scm_url(directory) | 141 | local function detect_scm_url(directory) |
142 | return detect_url_from_command("git", "config --get remote.origin.url", directory) or | 142 | return detect_url_from_command("git", "config --get remote.origin.url", directory) or |
143 | detect_url_from_command("hg", "paths default", directory) | 143 | detect_url_from_command("hg", "paths default", directory) |
@@ -230,7 +230,7 @@ local function fill_as_builtin(rockspec, libs) | |||
230 | libdirs[#libdirs+1] = "$("..upper.."_LIBDIR)" | 230 | libdirs[#libdirs+1] = "$("..upper.."_LIBDIR)" |
231 | end | 231 | end |
232 | end | 232 | end |
233 | 233 | ||
234 | rockspec.build.modules, rockspec.build.install, rockspec.build.copy_directories = builtin.autodetect_modules(libs, incdirs, libdirs) | 234 | rockspec.build.modules, rockspec.build.install, rockspec.build.copy_directories = builtin.autodetect_modules(libs, incdirs, libdirs) |
235 | end | 235 | end |
236 | 236 | ||
@@ -302,10 +302,10 @@ function write_rockspec.command(args) | |||
302 | version = version or "dev" | 302 | version = version or "dev" |
303 | 303 | ||
304 | local filename = args.output or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") | 304 | local filename = args.output or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") |
305 | 305 | ||
306 | local url = detect_url(location) | 306 | local url = detect_url(location) |
307 | local homepage = detect_homepage(url, args.homepage) | 307 | local homepage = detect_homepage(url, args.homepage) |
308 | 308 | ||
309 | local rockspec, err = rockspecs.from_persisted_table(filename, { | 309 | local rockspec, err = rockspecs.from_persisted_table(filename, { |
310 | rockspec_format = args.rockspec_format, | 310 | rockspec_format = args.rockspec_format, |
311 | package = name, | 311 | package = name, |
@@ -327,11 +327,11 @@ function write_rockspec.command(args) | |||
327 | }) | 327 | }) |
328 | assert(not err, err) | 328 | assert(not err, err) |
329 | rockspec.source.protocol = protocol | 329 | rockspec.source.protocol = protocol |
330 | 330 | ||
331 | if not next(rockspec.dependencies) then | 331 | if not next(rockspec.dependencies) then |
332 | util.warning("Please specify supported Lua versions with --lua-versions=<ver>. "..util.see_help("write_rockspec")) | 332 | util.warning("Please specify supported Lua versions with --lua-versions=<ver>. "..util.see_help("write_rockspec")) |
333 | end | 333 | end |
334 | 334 | ||
335 | local local_dir = location | 335 | local local_dir = location |
336 | 336 | ||
337 | if location:match("://") then | 337 | if location:match("://") then |
@@ -354,11 +354,11 @@ function write_rockspec.command(args) | |||
354 | local_dir = nil | 354 | local_dir = nil |
355 | end | 355 | end |
356 | end | 356 | end |
357 | 357 | ||
358 | if not local_dir then | 358 | if not local_dir then |
359 | local_dir = "." | 359 | local_dir = "." |
360 | end | 360 | end |
361 | 361 | ||
362 | local libs = nil | 362 | local libs = nil |
363 | if args.lib then | 363 | if args.lib then |
364 | libs = {} | 364 | libs = {} |
@@ -391,16 +391,16 @@ function write_rockspec.command(args) | |||
391 | util.title("Please fill in the source.license field manually or use --license.") | 391 | util.title("Please fill in the source.license field manually or use --license.") |
392 | end | 392 | end |
393 | end | 393 | end |
394 | 394 | ||
395 | fill_as_builtin(rockspec, libs) | 395 | fill_as_builtin(rockspec, libs) |
396 | 396 | ||
397 | rockspec_cleanup(rockspec) | 397 | rockspec_cleanup(rockspec) |
398 | 398 | ||
399 | persist.save_from_table(filename, rockspec, type_rockspec.order) | 399 | persist.save_from_table(filename, rockspec, type_rockspec.order) |
400 | 400 | ||
401 | util.printout() | 401 | util.printout() |
402 | util.printout("Wrote template at "..filename.." -- you should now edit and finish it.") | 402 | util.printout("Wrote template at "..filename.." -- you should now edit and finish it.") |
403 | util.printout() | 403 | util.printout() |
404 | 404 | ||
405 | return true | 405 | return true |
406 | end | 406 | end |
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index d65681c1..c19f7d3b 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
@@ -558,7 +558,7 @@ local cfg = {} | |||
558 | 558 | ||
559 | --- Initializes the LuaRocks configuration for variables, paths | 559 | --- Initializes the LuaRocks configuration for variables, paths |
560 | -- and OS detection. | 560 | -- and OS detection. |
561 | -- @param detected table containing information detected about the | 561 | -- @param detected table containing information detected about the |
562 | -- environment. All fields below are optional: | 562 | -- environment. All fields below are optional: |
563 | -- * lua_version (in x.y format, e.g. "5.3") | 563 | -- * lua_version (in x.y format, e.g. "5.3") |
564 | -- * lua_bindir (e.g. "/usr/local/bin") | 564 | -- * lua_bindir (e.g. "/usr/local/bin") |
@@ -575,7 +575,7 @@ function cfg.init(detected, warning) | |||
575 | if not hc_ok then | 575 | if not hc_ok then |
576 | hardcoded = {} | 576 | hardcoded = {} |
577 | end | 577 | end |
578 | 578 | ||
579 | local init = cfg.init | 579 | local init = cfg.init |
580 | 580 | ||
581 | ---------------------------------------- | 581 | ---------------------------------------- |
@@ -595,7 +595,7 @@ function cfg.init(detected, warning) | |||
595 | end | 595 | end |
596 | 596 | ||
597 | -- Use detected values as defaults, overridable via config files or CLI args | 597 | -- Use detected values as defaults, overridable via config files or CLI args |
598 | 598 | ||
599 | local first_arg = get_first_arg() | 599 | local first_arg = get_first_arg() |
600 | 600 | ||
601 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) | 601 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) |
@@ -778,7 +778,7 @@ function cfg.init(detected, warning) | |||
778 | and home_config_file | 778 | and home_config_file |
779 | or sys_config_file), | 779 | or sys_config_file), |
780 | } | 780 | } |
781 | 781 | ||
782 | cfg.cache = {} | 782 | cfg.cache = {} |
783 | 783 | ||
784 | ---------------------------------------- | 784 | ---------------------------------------- |
diff --git a/src/luarocks/core/dir.lua b/src/luarocks/core/dir.lua index d346ec4f..765a0e58 100644 --- a/src/luarocks/core/dir.lua +++ b/src/luarocks/core/dir.lua | |||
@@ -6,7 +6,7 @@ local require = nil | |||
6 | 6 | ||
7 | local function unquote(c) | 7 | local function unquote(c) |
8 | local first, last = c:sub(1,1), c:sub(-1) | 8 | local first, last = c:sub(1,1), c:sub(-1) |
9 | if (first == '"' and last == '"') or | 9 | if (first == '"' and last == '"') or |
10 | (first == "'" and last == "'") then | 10 | (first == "'" and last == "'") then |
11 | return c:sub(2,-2) | 11 | return c:sub(2,-2) |
12 | end | 12 | end |
@@ -40,7 +40,7 @@ end | |||
40 | -- @return string, string: the protocol, and the pathname without the protocol. | 40 | -- @return string, string: the protocol, and the pathname without the protocol. |
41 | function dir.split_url(url) | 41 | function dir.split_url(url) |
42 | assert(type(url) == "string") | 42 | assert(type(url) == "string") |
43 | 43 | ||
44 | url = unquote(url) | 44 | url = unquote(url) |
45 | local protocol, pathname = url:match("^([^:]*)://(.*)") | 45 | local protocol, pathname = url:match("^([^:]*)://(.*)") |
46 | if not protocol then | 46 | if not protocol then |
diff --git a/src/luarocks/core/manif.lua b/src/luarocks/core/manif.lua index fe0a95fa..3925f636 100644 --- a/src/luarocks/core/manif.lua +++ b/src/luarocks/core/manif.lua | |||
@@ -94,7 +94,7 @@ function manif.scan_dependencies(name, version, tree_manifests, dest) | |||
94 | if pkgdeps then | 94 | if pkgdeps then |
95 | for _, dep in ipairs(pkgdeps) do | 95 | for _, dep in ipairs(pkgdeps) do |
96 | local pkg, constraints = dep.name, dep.constraints | 96 | local pkg, constraints = dep.name, dep.constraints |
97 | 97 | ||
98 | for _, t in ipairs(tree_manifests) do | 98 | for _, t in ipairs(tree_manifests) do |
99 | local entries = t.manifest.repository[pkg] | 99 | local entries = t.manifest.repository[pkg] |
100 | if entries then | 100 | if entries then |
diff --git a/src/luarocks/core/persist.lua b/src/luarocks/core/persist.lua index 59089818..57e7b5d4 100644 --- a/src/luarocks/core/persist.lua +++ b/src/luarocks/core/persist.lua | |||
@@ -66,9 +66,9 @@ function persist.load_into_table(filename, tbl) | |||
66 | } | 66 | } |
67 | local save_mt = getmetatable(result) | 67 | local save_mt = getmetatable(result) |
68 | setmetatable(result, globals_mt) | 68 | setmetatable(result, globals_mt) |
69 | 69 | ||
70 | local ok, err, errcode = persist.run_file(filename, result) | 70 | local ok, err, errcode = persist.run_file(filename, result) |
71 | 71 | ||
72 | setmetatable(result, save_mt) | 72 | setmetatable(result, save_mt) |
73 | 73 | ||
74 | if not ok then | 74 | if not ok then |
diff --git a/src/luarocks/core/sysdetect.lua b/src/luarocks/core/sysdetect.lua index 534ab89f..7358c29f 100644 --- a/src/luarocks/core/sysdetect.lua +++ b/src/luarocks/core/sysdetect.lua | |||
@@ -15,7 +15,7 @@ end | |||
15 | local function read_int8(fd) | 15 | local function read_int8(fd) |
16 | if io.type(fd) == "closed file" then | 16 | if io.type(fd) == "closed file" then |
17 | return nil | 17 | return nil |
18 | end | 18 | end |
19 | local s = fd:read(1) | 19 | local s = fd:read(1) |
20 | if not s then | 20 | if not s then |
21 | fd:close() | 21 | fd:close() |
@@ -44,7 +44,7 @@ end | |||
44 | local function read(fd, bytes, endian) | 44 | local function read(fd, bytes, endian) |
45 | if io.type(fd) == "closed file" then | 45 | if io.type(fd) == "closed file" then |
46 | return nil | 46 | return nil |
47 | end | 47 | end |
48 | local s = fd:read(bytes) | 48 | local s = fd:read(bytes) |
49 | if not s | 49 | if not s |
50 | then fd:close() | 50 | then fd:close() |
@@ -138,7 +138,7 @@ end | |||
138 | local function detect_elf_system(fd, hdr, sections) | 138 | local function detect_elf_system(fd, hdr, sections) |
139 | local system = e_osabi[hdr.osabi] | 139 | local system = e_osabi[hdr.osabi] |
140 | local endian = hdr.endian | 140 | local endian = hdr.endian |
141 | 141 | ||
142 | if system == "sysv" then | 142 | if system == "sysv" then |
143 | local abitag = sections[".note.ABI-tag"] | 143 | local abitag = sections[".note.ABI-tag"] |
144 | if abitag then | 144 | if abitag then |
@@ -154,7 +154,7 @@ local function detect_elf_system(fd, hdr, sections) | |||
154 | elseif sections[".note.openbsd.ident"] then | 154 | elseif sections[".note.openbsd.ident"] then |
155 | return "openbsd" | 155 | return "openbsd" |
156 | end | 156 | end |
157 | 157 | ||
158 | local gnu_version_r = sections[".gnu.version_r"] | 158 | local gnu_version_r = sections[".gnu.version_r"] |
159 | if gnu_version_r then | 159 | if gnu_version_r then |
160 | 160 | ||
@@ -170,7 +170,7 @@ local function detect_elf_system(fd, hdr, sections) | |||
170 | 170 | ||
171 | fd:seek("set", dynstr + vn_file) | 171 | fd:seek("set", dynstr + vn_file) |
172 | local libname = fd:read(64):gsub("%z.*", "") | 172 | local libname = fd:read(64):gsub("%z.*", "") |
173 | 173 | ||
174 | if hdr.e_type == 0x03 and libname == "libroot.so" then | 174 | if hdr.e_type == 0x03 and libname == "libroot.so" then |
175 | return "haiku" | 175 | return "haiku" |
176 | elseif libname:match("linux") then | 176 | elseif libname:match("linux") then |
@@ -190,7 +190,7 @@ local function detect_elf_system(fd, hdr, sections) | |||
190 | end | 190 | end |
191 | end | 191 | end |
192 | end | 192 | end |
193 | 193 | ||
194 | return system | 194 | return system |
195 | end | 195 | end |
196 | 196 | ||
@@ -207,7 +207,7 @@ local function read_elf_header(fd) | |||
207 | if not hdr.osabi then | 207 | if not hdr.osabi then |
208 | return nil | 208 | return nil |
209 | end | 209 | end |
210 | 210 | ||
211 | local endian = hdr.endian | 211 | local endian = hdr.endian |
212 | fd:seek("set", 0x10) | 212 | fd:seek("set", 0x10) |
213 | hdr.e_type = read(fd, 2, endian) | 213 | hdr.e_type = read(fd, 2, endian) |
@@ -221,10 +221,10 @@ local function read_elf_header(fd) | |||
221 | if elfversion ~= 1 then | 221 | if elfversion ~= 1 then |
222 | return nil | 222 | return nil |
223 | end | 223 | end |
224 | 224 | ||
225 | local word = (hdr.bits == 1) and 4 or 8 | 225 | local word = (hdr.bits == 1) and 4 or 8 |
226 | hdr.word = word | 226 | hdr.word = word |
227 | 227 | ||
228 | hdr.e_entry = read(fd, word, endian) | 228 | hdr.e_entry = read(fd, word, endian) |
229 | hdr.e_phoff = read(fd, word, endian) | 229 | hdr.e_phoff = read(fd, word, endian) |
230 | hdr.e_shoff = read(fd, word, endian) | 230 | hdr.e_shoff = read(fd, word, endian) |
@@ -235,7 +235,7 @@ local function read_elf_header(fd) | |||
235 | hdr.e_shentsize = read(fd, 2, endian) | 235 | hdr.e_shentsize = read(fd, 2, endian) |
236 | hdr.e_shnum = read(fd, 2, endian) | 236 | hdr.e_shnum = read(fd, 2, endian) |
237 | hdr.e_shstrndx = read(fd, 2, endian) | 237 | hdr.e_shstrndx = read(fd, 2, endian) |
238 | 238 | ||
239 | return hdr, processor | 239 | return hdr, processor |
240 | end | 240 | end |
241 | 241 | ||
@@ -323,7 +323,7 @@ local function detect_pe(fd) | |||
323 | fd:seek("set", peoffset + 4) -- move to position of Machine section | 323 | fd:seek("set", peoffset + 4) -- move to position of Machine section |
324 | local machine = read(fd, 2, LITTLE) | 324 | local machine = read(fd, 2, LITTLE) |
325 | local processor = pe_machine[machine] | 325 | local processor = pe_machine[machine] |
326 | 326 | ||
327 | local rdata_pos = fd:read(736):match(".rdata%z%z............(....)") | 327 | local rdata_pos = fd:read(736):match(".rdata%z%z............(....)") |
328 | if rdata_pos then | 328 | if rdata_pos then |
329 | rdata_pos = bytes2number(rdata_pos, LITTLE) | 329 | rdata_pos = bytes2number(rdata_pos, LITTLE) |
@@ -333,7 +333,7 @@ local function detect_pe(fd) | |||
333 | system = "cygwin" | 333 | system = "cygwin" |
334 | end | 334 | end |
335 | end | 335 | end |
336 | 336 | ||
337 | return system, processor or "unknown" | 337 | return system, processor or "unknown" |
338 | end | 338 | end |
339 | 339 | ||
@@ -363,7 +363,7 @@ local cache_processor | |||
363 | function sysdetect.detect(input_file) | 363 | function sysdetect.detect(input_file) |
364 | local dirsep = package.config:sub(1,1) | 364 | local dirsep = package.config:sub(1,1) |
365 | local files | 365 | local files |
366 | 366 | ||
367 | if input_file then | 367 | if input_file then |
368 | files = { input_file } | 368 | files = { input_file } |
369 | else | 369 | else |
diff --git a/src/luarocks/core/util.lua b/src/luarocks/core/util.lua index dae8cfab..384a6eba 100644 --- a/src/luarocks/core/util.lua +++ b/src/luarocks/core/util.lua | |||
@@ -5,7 +5,7 @@ local require = nil | |||
5 | -------------------------------------------------------------------------------- | 5 | -------------------------------------------------------------------------------- |
6 | 6 | ||
7 | --- Run a process and read a its output. | 7 | --- Run a process and read a its output. |
8 | -- Equivalent to io.popen(cmd):read("*l"), except that it | 8 | -- Equivalent to io.popen(cmd):read("*l"), except that it |
9 | -- closes the fd right away. | 9 | -- closes the fd right away. |
10 | -- @param cmd string: The command to execute | 10 | -- @param cmd string: The command to execute |
11 | -- @param spec string: "*l" by default, to read a single line. | 11 | -- @param spec string: "*l" by default, to read a single line. |
@@ -63,7 +63,7 @@ function util.show_table(t, tname, top_indent) | |||
63 | local autoref -- for self references | 63 | local autoref -- for self references |
64 | 64 | ||
65 | local function is_empty_table(tbl) return next(tbl) == nil end | 65 | local function is_empty_table(tbl) return next(tbl) == nil end |
66 | 66 | ||
67 | local function basic_serialize(o) | 67 | local function basic_serialize(o) |
68 | local so = tostring(o) | 68 | local so = tostring(o) |
69 | if type(o) == "function" then | 69 | if type(o) == "function" then |
@@ -71,7 +71,7 @@ function util.show_table(t, tname, top_indent) | |||
71 | -- info.name is nil because o is not a calling level | 71 | -- info.name is nil because o is not a calling level |
72 | if info.what == "C" then | 72 | if info.what == "C" then |
73 | return ("%q"):format(so .. ", C function") | 73 | return ("%q"):format(so .. ", C function") |
74 | else | 74 | else |
75 | -- the information is defined through lines | 75 | -- the information is defined through lines |
76 | return ("%q"):format(so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source) | 76 | return ("%q"):format(so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source) |
77 | end | 77 | end |
@@ -81,14 +81,14 @@ function util.show_table(t, tname, top_indent) | |||
81 | return ("%q"):format(so) | 81 | return ("%q"):format(so) |
82 | end | 82 | end |
83 | end | 83 | end |
84 | 84 | ||
85 | local function add_to_cart(value, name, indent, saved, field) | 85 | local function add_to_cart(value, name, indent, saved, field) |
86 | indent = indent or "" | 86 | indent = indent or "" |
87 | saved = saved or {} | 87 | saved = saved or {} |
88 | field = field or name | 88 | field = field or name |
89 | 89 | ||
90 | cart = cart .. indent .. field | 90 | cart = cart .. indent .. field |
91 | 91 | ||
92 | if type(value) ~= "table" then | 92 | if type(value) ~= "table" then |
93 | cart = cart .. " = " .. basic_serialize(value) .. ";\n" | 93 | cart = cart .. " = " .. basic_serialize(value) .. ";\n" |
94 | else | 94 | else |
@@ -113,7 +113,7 @@ function util.show_table(t, tname, top_indent) | |||
113 | end | 113 | end |
114 | end | 114 | end |
115 | end | 115 | end |
116 | 116 | ||
117 | tname = tname or "__unnamed__" | 117 | tname = tname or "__unnamed__" |
118 | if type(t) ~= "table" then | 118 | if type(t) ~= "table" then |
119 | return tname .. " = " .. basic_serialize(t) | 119 | return tname .. " = " .. basic_serialize(t) |
@@ -189,7 +189,7 @@ function util.cleanup_path(list, sep, lua_version, keep_first) | |||
189 | local part = parts[i]:gsub("//", "/") | 189 | local part = parts[i]:gsub("//", "/") |
190 | if lua_version then | 190 | if lua_version then |
191 | part = part:gsub("/lua/([%d.]+)/", function(part_version) | 191 | part = part:gsub("/lua/([%d.]+)/", function(part_version) |
192 | if part_version:sub(1, #lua_version) ~= lua_version then | 192 | if part_version:sub(1, #lua_version) ~= lua_version then |
193 | return "/lua/"..lua_version.."/" | 193 | return "/lua/"..lua_version.."/" |
194 | end | 194 | end |
195 | end) | 195 | end) |
diff --git a/src/luarocks/core/vers.lua b/src/luarocks/core/vers.lua index e680f70b..e7251bb5 100644 --- a/src/luarocks/core/vers.lua +++ b/src/luarocks/core/vers.lua | |||
@@ -63,11 +63,11 @@ local version_mt = { | |||
63 | return not (v2 < v1) | 63 | return not (v2 < v1) |
64 | end, | 64 | end, |
65 | --- Return version as a string. | 65 | --- Return version as a string. |
66 | -- @param v The version table. | 66 | -- @param v The version table. |
67 | -- @return The string representation. | 67 | -- @return The string representation. |
68 | __tostring = function(v) | 68 | __tostring = function(v) |
69 | return v.string | 69 | return v.string |
70 | end, | 70 | end, |
71 | } | 71 | } |
72 | 72 | ||
73 | local version_cache = {} | 73 | local version_cache = {} |
@@ -102,7 +102,7 @@ function vers.parse_version(vstring) | |||
102 | version[i] = version[i] and version[i] + number/100000 or number | 102 | version[i] = version[i] and version[i] + number/100000 or number |
103 | i = i + 1 | 103 | i = i + 1 |
104 | end | 104 | end |
105 | 105 | ||
106 | -- trim leading and trailing spaces | 106 | -- trim leading and trailing spaces |
107 | local v = vstring:match("^%s*(.*)%s*$") | 107 | local v = vstring:match("^%s*(.*)%s*$") |
108 | version.string = v | 108 | version.string = v |
@@ -164,7 +164,7 @@ local function partial_match(version, requested) | |||
164 | if type(version) ~= "table" then version = vers.parse_version(version) end | 164 | if type(version) ~= "table" then version = vers.parse_version(version) end |
165 | if type(requested) ~= "table" then requested = vers.parse_version(requested) end | 165 | if type(requested) ~= "table" then requested = vers.parse_version(requested) end |
166 | if not version or not requested then return false end | 166 | if not version or not requested then return false end |
167 | 167 | ||
168 | for i, ri in ipairs(requested) do | 168 | for i, ri in ipairs(requested) do |
169 | local vi = version[i] or 0 | 169 | local vi = version[i] or 0 |
170 | if ri ~= vi then return false end | 170 | if ri ~= vi then return false end |
diff --git a/src/luarocks/deplocks.lua b/src/luarocks/deplocks.lua index f6449986..d62908f4 100644 --- a/src/luarocks/deplocks.lua +++ b/src/luarocks/deplocks.lua | |||
@@ -46,10 +46,10 @@ function deplocks.load(root_rock_name, dirname) | |||
46 | -- could not open, maybe file does not exist | 46 | -- could not open, maybe file does not exist |
47 | return true, nil | 47 | return true, nil |
48 | end | 48 | end |
49 | 49 | ||
50 | deplock_abs_filename = fs.absolute_name(filename) | 50 | deplock_abs_filename = fs.absolute_name(filename) |
51 | deplock_root_rock_name = root_rock_name | 51 | deplock_root_rock_name = root_rock_name |
52 | 52 | ||
53 | deptable = result | 53 | deptable = result |
54 | return true, filename | 54 | return true, filename |
55 | end | 55 | end |
@@ -58,7 +58,7 @@ function deplocks.add(depskey, name, version) | |||
58 | if deptable_mode == "locked" then | 58 | if deptable_mode == "locked" then |
59 | return | 59 | return |
60 | end | 60 | end |
61 | 61 | ||
62 | local dk = deptable[depskey] | 62 | local dk = deptable[depskey] |
63 | if not dk then | 63 | if not dk then |
64 | dk = {} | 64 | dk = {} |
@@ -89,7 +89,7 @@ end | |||
89 | 89 | ||
90 | -- a table-like interface to deplocks | 90 | -- a table-like interface to deplocks |
91 | function deplocks.proxy(depskey) | 91 | function deplocks.proxy(depskey) |
92 | return setmetatable({}, { | 92 | return setmetatable({}, { |
93 | __index = function(_, k) | 93 | __index = function(_, k) |
94 | return deplocks.get(depskey, k) | 94 | return deplocks.get(depskey, k) |
95 | end, | 95 | end, |
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index f6de0db8..7e7b69e6 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -47,7 +47,7 @@ local function prepare_get_versions(deps_mode, rocks_provided, depskey, blacklis | |||
47 | end | 47 | end |
48 | versions, locations = manif.get_versions(dep, deps_mode) | 48 | versions, locations = manif.get_versions(dep, deps_mode) |
49 | end | 49 | end |
50 | 50 | ||
51 | if blacklist and blacklist[dep.name] then | 51 | if blacklist and blacklist[dep.name] then |
52 | local orig_versions = versions | 52 | local orig_versions = versions |
53 | versions = {} | 53 | versions = {} |
@@ -57,9 +57,9 @@ local function prepare_get_versions(deps_mode, rocks_provided, depskey, blacklis | |||
57 | end | 57 | end |
58 | end | 58 | end |
59 | end | 59 | end |
60 | 60 | ||
61 | local lockversion = deplocks.get(depskey, dep.name) | 61 | local lockversion = deplocks.get(depskey, dep.name) |
62 | 62 | ||
63 | return versions, locations, lockversion, provided ~= nil | 63 | return versions, locations, lockversion, provided ~= nil |
64 | end | 64 | end |
65 | end | 65 | end |
@@ -81,9 +81,9 @@ end | |||
81 | local function match_dep(dep, get_versions) | 81 | local function match_dep(dep, get_versions) |
82 | assert(type(dep) == "table") | 82 | assert(type(dep) == "table") |
83 | assert(type(get_versions) == "function") | 83 | assert(type(get_versions) == "function") |
84 | 84 | ||
85 | local versions, locations, lockversion, provided = get_versions(dep) | 85 | local versions, locations, lockversion, provided = get_versions(dep) |
86 | 86 | ||
87 | local latest_version | 87 | local latest_version |
88 | local latest_vstring | 88 | local latest_vstring |
89 | for _, vstring in ipairs(versions) do | 89 | for _, vstring in ipairs(versions) do |
@@ -95,7 +95,7 @@ local function match_dep(dep, get_versions) | |||
95 | end | 95 | end |
96 | end | 96 | end |
97 | end | 97 | end |
98 | 98 | ||
99 | if lockversion and not locations[lockversion] then | 99 | if lockversion and not locations[lockversion] then |
100 | local latest_matching_msg = "" | 100 | local latest_matching_msg = "" |
101 | if latest_vstring and latest_vstring ~= lockversion then | 101 | if latest_vstring and latest_vstring ~= lockversion then |
@@ -104,7 +104,7 @@ local function match_dep(dep, get_versions) | |||
104 | util.printout("Forcing " .. dep.name .. " to pinned version " .. lockversion .. latest_matching_msg) | 104 | util.printout("Forcing " .. dep.name .. " to pinned version " .. lockversion .. latest_matching_msg) |
105 | return nil, nil, queries.new(dep.name, dep.namespace, lockversion) | 105 | return nil, nil, queries.new(dep.name, dep.namespace, lockversion) |
106 | end | 106 | end |
107 | 107 | ||
108 | return latest_vstring, locations[latest_vstring], dep, provided | 108 | return latest_vstring, locations[latest_vstring], dep, provided |
109 | end | 109 | end |
110 | 110 | ||
@@ -113,7 +113,7 @@ local function match_all_deps(dependencies, get_versions) | |||
113 | assert(type(get_versions) == "function") | 113 | assert(type(get_versions) == "function") |
114 | 114 | ||
115 | local matched, missing, no_upgrade = {}, {}, {} | 115 | local matched, missing, no_upgrade = {}, {}, {} |
116 | 116 | ||
117 | for _, dep in ipairs(dependencies) do | 117 | for _, dep in ipairs(dependencies) do |
118 | local found, _, provided | 118 | local found, _, provided |
119 | found, _, dep, provided = match_dep(dep, get_versions) | 119 | found, _, dep, provided = match_dep(dep, get_versions) |
@@ -169,7 +169,7 @@ end | |||
169 | -- @param version string: package version. | 169 | -- @param version string: package version. |
170 | -- @param dependencies table: array of dependencies. | 170 | -- @param dependencies table: array of dependencies. |
171 | -- @param deps_mode string: Which trees to check dependencies for | 171 | -- @param deps_mode string: Which trees to check dependencies for |
172 | -- @param rocks_provided table: A table of auto-dependencies provided | 172 | -- @param rocks_provided table: A table of auto-dependencies provided |
173 | -- by this Lua implementation for the given dependency. | 173 | -- by this Lua implementation for the given dependency. |
174 | -- "one" for the current default tree, "all" for all trees, | 174 | -- "one" for the current default tree, "all" for all trees, |
175 | -- "order" for all trees with priority >= the current default, "none" for no trees. | 175 | -- "order" for all trees with priority >= the current default, "none" for no trees. |
@@ -179,7 +179,7 @@ function deps.report_missing_dependencies(name, version, dependencies, deps_mode | |||
179 | assert(type(dependencies) == "table") | 179 | assert(type(dependencies) == "table") |
180 | assert(type(deps_mode) == "string") | 180 | assert(type(deps_mode) == "string") |
181 | assert(type(rocks_provided) == "table") | 181 | assert(type(rocks_provided) == "table") |
182 | 182 | ||
183 | if deps_mode == "none" then | 183 | if deps_mode == "none" then |
184 | return | 184 | return |
185 | end | 185 | end |
@@ -270,7 +270,7 @@ local function check_supported_platforms(rockspec) | |||
270 | return nil, "This rockspec for "..rockspec.package.." does not support "..plats.." platforms." | 270 | return nil, "This rockspec for "..rockspec.package.." does not support "..plats.." platforms." |
271 | end | 271 | end |
272 | end | 272 | end |
273 | 273 | ||
274 | return true | 274 | return true |
275 | end | 275 | end |
276 | 276 | ||
@@ -295,7 +295,7 @@ function deps.fulfill_dependencies(rockspec, depskey, deps_mode, verify, deplock | |||
295 | local name = rockspec.name | 295 | local name = rockspec.name |
296 | local version = rockspec.version | 296 | local version = rockspec.version |
297 | local rocks_provided = rockspec.rocks_provided | 297 | local rocks_provided = rockspec.rocks_provided |
298 | 298 | ||
299 | local ok, filename, err = deplocks.load(name, deplock_dir or ".") | 299 | local ok, filename, err = deplocks.load(name, deplock_dir or ".") |
300 | if filename then | 300 | if filename then |
301 | util.printout("Using dependencies pinned in lockfile: " .. filename) | 301 | util.printout("Using dependencies pinned in lockfile: " .. filename) |
@@ -530,7 +530,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache) | |||
530 | local err_files = {program = {}, header = {}, library = {}} | 530 | local err_files = {program = {}, header = {}, library = {}} |
531 | 531 | ||
532 | local dirs = get_external_deps_dirs(mode) | 532 | local dirs = get_external_deps_dirs(mode) |
533 | 533 | ||
534 | local prefixes | 534 | local prefixes |
535 | if vars[name .. "_DIR"] then | 535 | if vars[name .. "_DIR"] then |
536 | prefixes = { vars[name .. "_DIR"] } | 536 | prefixes = { vars[name .. "_DIR"] } |
@@ -539,7 +539,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache) | |||
539 | else | 539 | else |
540 | prefixes = cfg.external_deps_dirs | 540 | prefixes = cfg.external_deps_dirs |
541 | end | 541 | end |
542 | 542 | ||
543 | for _, prefix in ipairs(prefixes) do | 543 | for _, prefix in ipairs(prefixes) do |
544 | prefix = resolve_prefix(prefix, dirs) | 544 | prefix = resolve_prefix(prefix, dirs) |
545 | if cfg.is_platform("mingw32") and name == "LUA" then | 545 | if cfg.is_platform("mingw32") and name == "LUA" then |
@@ -556,7 +556,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache) | |||
556 | return true | 556 | return true |
557 | end | 557 | end |
558 | end | 558 | end |
559 | 559 | ||
560 | return nil, err_dirname, err_testfile, err_files | 560 | return nil, err_dirname, err_testfile, err_files |
561 | end | 561 | end |
562 | 562 | ||
@@ -575,7 +575,7 @@ end | |||
575 | -- nil and an error message if any test failed. | 575 | -- nil and an error message if any test failed. |
576 | function deps.check_external_deps(rockspec, mode) | 576 | function deps.check_external_deps(rockspec, mode) |
577 | assert(rockspec:type() == "rockspec") | 577 | assert(rockspec:type() == "rockspec") |
578 | 578 | ||
579 | if not rockspec.external_dependencies then | 579 | if not rockspec.external_dependencies then |
580 | rockspec.external_dependencies = builtin.autodetect_external_dependencies(rockspec.build) | 580 | rockspec.external_dependencies = builtin.autodetect_external_dependencies(rockspec.build) |
581 | end | 581 | end |
@@ -587,7 +587,7 @@ function deps.check_external_deps(rockspec, mode) | |||
587 | local ok, err_dirname, err_testfile, err_files = check_external_dependency(name, ext_files, rockspec.variables, mode) | 587 | local ok, err_dirname, err_testfile, err_files = check_external_dependency(name, ext_files, rockspec.variables, mode) |
588 | if not ok then | 588 | if not ok then |
589 | local lines = {"Could not find "..err_testfile.." file for "..name} | 589 | local lines = {"Could not find "..err_testfile.." file for "..name} |
590 | 590 | ||
591 | local err_paths = {} | 591 | local err_paths = {} |
592 | for _, err_file in ipairs(err_files[err_testfile]) do | 592 | for _, err_file in ipairs(err_files[err_testfile]) do |
593 | if not err_paths[err_file] then | 593 | if not err_paths[err_file] then |
@@ -595,10 +595,10 @@ function deps.check_external_deps(rockspec, mode) | |||
595 | table.insert(lines, " No file "..err_file) | 595 | table.insert(lines, " No file "..err_file) |
596 | end | 596 | end |
597 | end | 597 | end |
598 | 598 | ||
599 | table.insert(lines, "You may have to install "..name.." in your system and/or pass "..name.."_DIR or "..name.."_"..err_dirname.." to the luarocks command.") | 599 | table.insert(lines, "You may have to install "..name.." in your system and/or pass "..name.."_DIR or "..name.."_"..err_dirname.." to the luarocks command.") |
600 | table.insert(lines, "Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local") | 600 | table.insert(lines, "Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local") |
601 | 601 | ||
602 | return nil, table.concat(lines, "\n"), "dependency" | 602 | return nil, table.concat(lines, "\n"), "dependency" |
603 | end | 603 | end |
604 | end | 604 | end |
@@ -700,7 +700,7 @@ function deps.check_lua_incdir(vars) | |||
700 | if vars.LUA_INCDIR then | 700 | if vars.LUA_INCDIR then |
701 | return lua_h_exists(vars.LUA_INCDIR, cfg.lua_version) | 701 | return lua_h_exists(vars.LUA_INCDIR, cfg.lua_version) |
702 | end | 702 | end |
703 | 703 | ||
704 | if vars.LUA_DIR then | 704 | if vars.LUA_DIR then |
705 | vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) | 705 | vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) |
706 | if vars.LUA_INCDIR then | 706 | if vars.LUA_INCDIR then |
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index da912d3e..c8b15d61 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua | |||
@@ -175,7 +175,7 @@ local function fetch_and_verify_signature_for(url, filename, tmpdir) | |||
175 | if not sig_file then | 175 | if not sig_file then |
176 | return nil, "Could not fetch signature file for verification: " .. err, errcode | 176 | return nil, "Could not fetch signature file for verification: " .. err, errcode |
177 | end | 177 | end |
178 | 178 | ||
179 | local ok, err = signing.verify_signature(filename, sig_file) | 179 | local ok, err = signing.verify_signature(filename, sig_file) |
180 | if not ok then | 180 | if not ok then |
181 | return nil, "Failed signature verification: " .. err | 181 | return nil, "Failed signature verification: " .. err |
@@ -269,7 +269,7 @@ function fetch.load_local_rockspec(rel_filename, quick) | |||
269 | if not tbl then | 269 | if not tbl then |
270 | return nil, "Could not load rockspec file "..abs_filename.." ("..err..")" | 270 | return nil, "Could not load rockspec file "..abs_filename.." ("..err..")" |
271 | end | 271 | end |
272 | 272 | ||
273 | local rockspec, err = rockspecs.from_persisted_table(abs_filename, tbl, err, quick) | 273 | local rockspec, err = rockspecs.from_persisted_table(abs_filename, tbl, err, quick) |
274 | if not rockspec then | 274 | if not rockspec then |
275 | return nil, abs_filename .. ": " .. err | 275 | return nil, abs_filename .. ": " .. err |
@@ -279,12 +279,12 @@ function fetch.load_local_rockspec(rel_filename, quick) | |||
279 | if basename ~= "rockspec" and basename ~= name_version .. ".rockspec" then | 279 | if basename ~= "rockspec" and basename ~= name_version .. ".rockspec" then |
280 | return nil, "Inconsistency between rockspec filename ("..basename..") and its contents ("..name_version..".rockspec)." | 280 | return nil, "Inconsistency between rockspec filename ("..basename..") and its contents ("..name_version..".rockspec)." |
281 | end | 281 | end |
282 | 282 | ||
283 | return rockspec | 283 | return rockspec |
284 | end | 284 | end |
285 | 285 | ||
286 | --- Load a local or remote rockspec into a table. | 286 | --- Load a local or remote rockspec into a table. |
287 | -- This is the entry point for the LuaRocks tools. | 287 | -- This is the entry point for the LuaRocks tools. |
288 | -- Only the LuaRocks runtime loader should use | 288 | -- Only the LuaRocks runtime loader should use |
289 | -- load_local_rockspec directly. | 289 | -- load_local_rockspec directly. |
290 | -- @param filename string: Local or remote filename of a rockspec. | 290 | -- @param filename string: Local or remote filename of a rockspec. |
@@ -425,7 +425,7 @@ function fetch.fetch_sources(rockspec, extract, dest_dir) | |||
425 | return nil, "Unknown protocol "..protocol | 425 | return nil, "Unknown protocol "..protocol |
426 | end | 426 | end |
427 | end | 427 | end |
428 | 428 | ||
429 | if cfg.only_sources_from | 429 | if cfg.only_sources_from |
430 | and rockspec.source.pathname | 430 | and rockspec.source.pathname |
431 | and #rockspec.source.pathname > 0 then | 431 | and #rockspec.source.pathname > 0 then |
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index 88ba4848..29892e92 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua | |||
@@ -150,7 +150,7 @@ function git.get_sources(rockspec, extract, dest_dir, depth) | |||
150 | return nil, 'Failed to fetch submodules.' | 150 | return nil, 'Failed to fetch submodules.' |
151 | end | 151 | end |
152 | end | 152 | end |
153 | 153 | ||
154 | if not rockspec.source.tag then | 154 | if not rockspec.source.tag then |
155 | rockspec.source.identifier = git_identifier(git_cmd, rockspec.version) | 155 | rockspec.source.identifier = git_identifier(git_cmd, rockspec.version) |
156 | end | 156 | end |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 83ffbd47..0e98449a 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -132,7 +132,7 @@ function fs_lua.is_tool_available(tool_cmd, tool_name, arg) | |||
132 | 132 | ||
133 | if ok then | 133 | if ok then |
134 | return true | 134 | return true |
135 | else | 135 | else |
136 | local msg = "'%s' program not found. Make sure %s is installed and is available in your PATH " .. | 136 | local msg = "'%s' program not found. Make sure %s is installed and is available in your PATH " .. |
137 | "(or you may want to edit the 'variables.%s' value in file '%s')" | 137 | "(or you may want to edit the 'variables.%s' value in file '%s')" |
138 | return nil, msg:format(tool_cmd, tool_name, tool_name:upper(), cfg.config_files.nearest) | 138 | return nil, msg:format(tool_cmd, tool_name, tool_name:upper(), cfg.config_files.nearest) |
@@ -535,7 +535,7 @@ end | |||
535 | --- Internal implementation function for fs.dir. | 535 | --- Internal implementation function for fs.dir. |
536 | -- Yields a filename on each iteration. | 536 | -- Yields a filename on each iteration. |
537 | -- @param at string: directory to list | 537 | -- @param at string: directory to list |
538 | -- @return nil or (nil and string): an error message on failure | 538 | -- @return nil or (nil and string): an error message on failure |
539 | function fs_lua.dir_iterator(at) | 539 | function fs_lua.dir_iterator(at) |
540 | local pok, iter, arg = pcall(lfs.dir, at) | 540 | local pok, iter, arg = pcall(lfs.dir, at) |
541 | if not pok then | 541 | if not pok then |
@@ -707,7 +707,7 @@ local redirect_protocols = { | |||
707 | 707 | ||
708 | local function request(url, method, http, loop_control) -- luacheck: ignore 431 | 708 | local function request(url, method, http, loop_control) -- luacheck: ignore 431 |
709 | local result = {} | 709 | local result = {} |
710 | 710 | ||
711 | if cfg.verbose then | 711 | if cfg.verbose then |
712 | print(method, url) | 712 | print(method, url) |
713 | end | 713 | end |
diff --git a/src/luarocks/fs/tools.lua b/src/luarocks/fs/tools.lua index fdb93dba..4fe8e104 100644 --- a/src/luarocks/fs/tools.lua +++ b/src/luarocks/fs/tools.lua | |||
@@ -12,7 +12,7 @@ local dir_stack = {} | |||
12 | 12 | ||
13 | do | 13 | do |
14 | local tool_cache = {} | 14 | local tool_cache = {} |
15 | 15 | ||
16 | local tool_options = { | 16 | local tool_options = { |
17 | downloader = { | 17 | downloader = { |
18 | desc = "downloader", | 18 | desc = "downloader", |
@@ -147,7 +147,7 @@ function tools.use_downloader(url, filename, cache) | |||
147 | assert(type(filename) == "string" or not filename) | 147 | assert(type(filename) == "string" or not filename) |
148 | 148 | ||
149 | filename = fs.absolute_name(filename or dir.base_name(url)) | 149 | filename = fs.absolute_name(filename or dir.base_name(url)) |
150 | 150 | ||
151 | local downloader, err = fs.which_tool("downloader") | 151 | local downloader, err = fs.which_tool("downloader") |
152 | if not downloader then | 152 | if not downloader then |
153 | return nil, err | 153 | return nil, err |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 53903f0c..d5b36127 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
@@ -76,7 +76,7 @@ function unix.wrap_script(script, target, deps_mode, name, version, ...) | |||
76 | assert(type(deps_mode) == "string") | 76 | assert(type(deps_mode) == "string") |
77 | assert(type(name) == "string" or not name) | 77 | assert(type(name) == "string" or not name) |
78 | assert(type(version) == "string" or not version) | 78 | assert(type(version) == "string" or not version) |
79 | 79 | ||
80 | local wrapper = io.open(target, "w") | 80 | local wrapper = io.open(target, "w") |
81 | if not wrapper then | 81 | if not wrapper then |
82 | return nil, "Could not open "..target.." for writing." | 82 | return nil, "Could not open "..target.." for writing." |
@@ -153,7 +153,7 @@ function unix.is_actual_binary(filename) | |||
153 | return first ~= "#!" | 153 | return first ~= "#!" |
154 | end | 154 | end |
155 | 155 | ||
156 | function unix.copy_binary(filename, dest) | 156 | function unix.copy_binary(filename, dest) |
157 | return fs.copy(filename, dest, "exec") | 157 | return fs.copy(filename, dest, "exec") |
158 | end | 158 | end |
159 | 159 | ||
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index 959ee86e..d36d407d 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -51,7 +51,7 @@ end | |||
51 | --- Copy a file. | 51 | --- Copy a file. |
52 | -- @param src string: Pathname of source | 52 | -- @param src string: Pathname of source |
53 | -- @param dest string: Pathname of destination | 53 | -- @param dest string: Pathname of destination |
54 | -- @param perm string ("read" or "exec") or nil: Permissions for destination | 54 | -- @param perm string ("read" or "exec") or nil: Permissions for destination |
55 | -- file or nil to use the source permissions | 55 | -- file or nil to use the source permissions |
56 | -- @return boolean or (boolean, string): true on success, false on failure, | 56 | -- @return boolean or (boolean, string): true on success, false on failure, |
57 | -- plus an error message. | 57 | -- plus an error message. |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 00dd0163..49de8e97 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
@@ -217,7 +217,7 @@ function win32.is_actual_binary(name) | |||
217 | return false | 217 | return false |
218 | end | 218 | end |
219 | 219 | ||
220 | function win32.copy_binary(filename, dest) | 220 | function win32.copy_binary(filename, dest) |
221 | local ok, err = fs.copy(filename, dest) | 221 | local ok, err = fs.copy(filename, dest) |
222 | if not ok then | 222 | if not ok then |
223 | return nil, err | 223 | return nil, err |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index b9eadc5b..f643bc80 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -110,7 +110,7 @@ function manif.load_manifest(repo_url, lua_version, versioned_only) | |||
110 | break | 110 | break |
111 | end | 111 | end |
112 | end | 112 | end |
113 | if not pathname then | 113 | if not pathname then |
114 | return nil, err, errcode | 114 | return nil, err, errcode |
115 | end | 115 | end |
116 | end | 116 | end |
@@ -236,7 +236,7 @@ end | |||
236 | function manif.get_versions(dep, deps_mode) | 236 | function manif.get_versions(dep, deps_mode) |
237 | assert(type(dep) == "table") | 237 | assert(type(dep) == "table") |
238 | assert(type(deps_mode) == "string") | 238 | assert(type(deps_mode) == "string") |
239 | 239 | ||
240 | local name = dep.name | 240 | local name = dep.name |
241 | local namespace = dep.namespace | 241 | local namespace = dep.namespace |
242 | 242 | ||
diff --git a/src/luarocks/manif/writer.lua b/src/luarocks/manif/writer.lua index fd891844..a435d29e 100644 --- a/src/luarocks/manif/writer.lua +++ b/src/luarocks/manif/writer.lua | |||
@@ -90,7 +90,7 @@ end | |||
90 | local function update_dependencies(manifest, deps_mode) | 90 | local function update_dependencies(manifest, deps_mode) |
91 | assert(type(manifest) == "table") | 91 | assert(type(manifest) == "table") |
92 | assert(type(deps_mode) == "string") | 92 | assert(type(deps_mode) == "string") |
93 | 93 | ||
94 | for pkg, versions in pairs(manifest.repository) do | 94 | for pkg, versions in pairs(manifest.repository) do |
95 | for version, repositories in pairs(versions) do | 95 | for version, repositories in pairs(versions) do |
96 | for _, repo in ipairs(repositories) do | 96 | for _, repo in ipairs(repositories) do |
@@ -160,7 +160,7 @@ local function filter_by_lua_version(manifest, lua_version, repodir, cache) | |||
160 | assert(type(manifest) == "table") | 160 | assert(type(manifest) == "table") |
161 | assert(type(repodir) == "string") | 161 | assert(type(repodir) == "string") |
162 | assert((not cache) or type(cache) == "table") | 162 | assert((not cache) or type(cache) == "table") |
163 | 163 | ||
164 | cache = cache or {} | 164 | cache = cache or {} |
165 | lua_version = vers.parse_version(lua_version) | 165 | lua_version = vers.parse_version(lua_version) |
166 | for pkg, versions in pairs(manifest.repository) do | 166 | for pkg, versions in pairs(manifest.repository) do |
@@ -176,7 +176,7 @@ local function filter_by_lua_version(manifest, lua_version, repodir, cache) | |||
176 | if rockspec then | 176 | if rockspec then |
177 | cache[pathname] = rockspec | 177 | cache[pathname] = rockspec |
178 | for _, dep in ipairs(rockspec.dependencies) do | 178 | for _, dep in ipairs(rockspec.dependencies) do |
179 | if dep.name == "lua" then | 179 | if dep.name == "lua" then |
180 | if not vers.match_constraints(lua_version, dep.constraints) then | 180 | if not vers.match_constraints(lua_version, dep.constraints) then |
181 | table.insert(to_remove, version) | 181 | table.insert(to_remove, version) |
182 | end | 182 | end |
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index 983aef74..34268475 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua | |||
@@ -91,13 +91,13 @@ function pack.pack_installed_rock(query, tree) | |||
91 | if not fs.exists(prefix) then | 91 | if not fs.exists(prefix) then |
92 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." | 92 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." |
93 | end | 93 | end |
94 | 94 | ||
95 | local rock_manifest, err = manif.load_rock_manifest(name, version, root) | 95 | local rock_manifest, err = manif.load_rock_manifest(name, version, root) |
96 | if not rock_manifest then return nil, err end | 96 | if not rock_manifest then return nil, err end |
97 | 97 | ||
98 | local name_version = name .. "-" .. version | 98 | local name_version = name .. "-" .. version |
99 | local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") | 99 | local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") |
100 | 100 | ||
101 | local temp_dir = fs.make_temp_dir("pack") | 101 | local temp_dir = fs.make_temp_dir("pack") |
102 | fs.copy_contents(prefix, temp_dir) | 102 | fs.copy_contents(prefix, temp_dir) |
103 | 103 | ||
@@ -111,7 +111,7 @@ function pack.pack_installed_rock(query, tree) | |||
111 | local ok, err = copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read") | 111 | local ok, err = copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read") |
112 | if not ok then return nil, "Failed copying back files: " .. err end | 112 | if not ok then return nil, "Failed copying back files: " .. err end |
113 | end | 113 | end |
114 | 114 | ||
115 | local ok, err = fs.change_dir(temp_dir) | 115 | local ok, err = fs.change_dir(temp_dir) |
116 | if not ok then return nil, err end | 116 | if not ok then return nil, err end |
117 | if not is_binary and not repos.has_binaries(name, version) then | 117 | if not is_binary and not repos.has_binaries(name, version) then |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index b3b01704..a9f04ef0 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -49,7 +49,7 @@ function path.manifest_file(tree) | |||
49 | end | 49 | end |
50 | 50 | ||
51 | --- Get the directory for all versions of a package in a tree. | 51 | --- Get the directory for all versions of a package in a tree. |
52 | -- @param name string: The package name. | 52 | -- @param name string: The package name. |
53 | -- @return string: The resulting path -- does not guarantee that | 53 | -- @return string: The resulting path -- does not guarantee that |
54 | -- @param tree string or nil: If given, specifies the local tree to use. | 54 | -- @param tree string or nil: If given, specifies the local tree to use. |
55 | -- the package (and by extension, the path) exists. | 55 | -- the package (and by extension, the path) exists. |
@@ -59,7 +59,7 @@ function path.versions_dir(name, tree) | |||
59 | end | 59 | end |
60 | 60 | ||
61 | --- Get the local installation directory (prefix) for a package. | 61 | --- Get the local installation directory (prefix) for a package. |
62 | -- @param name string: The package name. | 62 | -- @param name string: The package name. |
63 | -- @param version string: The package version. | 63 | -- @param version string: The package version. |
64 | -- @param tree string or nil: If given, specifies the local tree to use. | 64 | -- @param tree string or nil: If given, specifies the local tree to use. |
65 | -- @return string: The resulting path -- does not guarantee that | 65 | -- @return string: The resulting path -- does not guarantee that |
@@ -71,7 +71,7 @@ function path.install_dir(name, version, tree) | |||
71 | end | 71 | end |
72 | 72 | ||
73 | --- Get the local filename of the rockspec of an installed rock. | 73 | --- Get the local filename of the rockspec of an installed rock. |
74 | -- @param name string: The package name. | 74 | -- @param name string: The package name. |
75 | -- @param version string: The package version. | 75 | -- @param version string: The package version. |
76 | -- @param tree string or nil: If given, specifies the local tree to use. | 76 | -- @param tree string or nil: If given, specifies the local tree to use. |
77 | -- @return string: The resulting path -- does not guarantee that | 77 | -- @return string: The resulting path -- does not guarantee that |
@@ -83,7 +83,7 @@ function path.rockspec_file(name, version, tree) | |||
83 | end | 83 | end |
84 | 84 | ||
85 | --- Get the local filename of the rock_manifest file of an installed rock. | 85 | --- Get the local filename of the rock_manifest file of an installed rock. |
86 | -- @param name string: The package name. | 86 | -- @param name string: The package name. |
87 | -- @param version string: The package version. | 87 | -- @param version string: The package version. |
88 | -- @param tree string or nil: If given, specifies the local tree to use. | 88 | -- @param tree string or nil: If given, specifies the local tree to use. |
89 | -- @return string: The resulting path -- does not guarantee that | 89 | -- @return string: The resulting path -- does not guarantee that |
@@ -107,7 +107,7 @@ function path.rock_namespace_file(name, version, tree) | |||
107 | end | 107 | end |
108 | 108 | ||
109 | --- Get the local installation directory for C libraries of a package. | 109 | --- Get the local installation directory for C libraries of a package. |
110 | -- @param name string: The package name. | 110 | -- @param name string: The package name. |
111 | -- @param version string: The package version. | 111 | -- @param version string: The package version. |
112 | -- @param tree string or nil: If given, specifies the local tree to use. | 112 | -- @param tree string or nil: If given, specifies the local tree to use. |
113 | -- @return string: The resulting path -- does not guarantee that | 113 | -- @return string: The resulting path -- does not guarantee that |
@@ -119,7 +119,7 @@ function path.lib_dir(name, version, tree) | |||
119 | end | 119 | end |
120 | 120 | ||
121 | --- Get the local installation directory for Lua modules of a package. | 121 | --- Get the local installation directory for Lua modules of a package. |
122 | -- @param name string: The package name. | 122 | -- @param name string: The package name. |
123 | -- @param version string: The package version. | 123 | -- @param version string: The package version. |
124 | -- @param tree string or nil: If given, specifies the local tree to use. | 124 | -- @param tree string or nil: If given, specifies the local tree to use. |
125 | -- @return string: The resulting path -- does not guarantee that | 125 | -- @return string: The resulting path -- does not guarantee that |
@@ -131,7 +131,7 @@ function path.lua_dir(name, version, tree) | |||
131 | end | 131 | end |
132 | 132 | ||
133 | --- Get the local installation directory for documentation of a package. | 133 | --- Get the local installation directory for documentation of a package. |
134 | -- @param name string: The package name. | 134 | -- @param name string: The package name. |
135 | -- @param version string: The package version. | 135 | -- @param version string: The package version. |
136 | -- @param tree string or nil: If given, specifies the local tree to use. | 136 | -- @param tree string or nil: If given, specifies the local tree to use. |
137 | -- @return string: The resulting path -- does not guarantee that | 137 | -- @return string: The resulting path -- does not guarantee that |
@@ -143,7 +143,7 @@ function path.doc_dir(name, version, tree) | |||
143 | end | 143 | end |
144 | 144 | ||
145 | --- Get the local installation directory for configuration files of a package. | 145 | --- Get the local installation directory for configuration files of a package. |
146 | -- @param name string: The package name. | 146 | -- @param name string: The package name. |
147 | -- @param version string: The package version. | 147 | -- @param version string: The package version. |
148 | -- @param tree string or nil: If given, specifies the local tree to use. | 148 | -- @param tree string or nil: If given, specifies the local tree to use. |
149 | -- @return string: The resulting path -- does not guarantee that | 149 | -- @return string: The resulting path -- does not guarantee that |
@@ -156,7 +156,7 @@ end | |||
156 | 156 | ||
157 | --- Get the local installation directory for command-line scripts | 157 | --- Get the local installation directory for command-line scripts |
158 | -- of a package. | 158 | -- of a package. |
159 | -- @param name string: The package name. | 159 | -- @param name string: The package name. |
160 | -- @param version string: The package version. | 160 | -- @param version string: The package version. |
161 | -- @param tree string or nil: If given, specifies the local tree to use. | 161 | -- @param tree string or nil: If given, specifies the local tree to use. |
162 | -- @return string: The resulting path -- does not guarantee that | 162 | -- @return string: The resulting path -- does not guarantee that |
diff --git a/src/luarocks/persist.lua b/src/luarocks/persist.lua index b21323ce..02c5016c 100644 --- a/src/luarocks/persist.lua +++ b/src/luarocks/persist.lua | |||
@@ -85,7 +85,7 @@ local function write_table_key_assignment(out, k, level) | |||
85 | persist.write_value(out, k, level) | 85 | persist.write_value(out, k, level) |
86 | out:write("]") | 86 | out:write("]") |
87 | end | 87 | end |
88 | 88 | ||
89 | out:write(" = ") | 89 | out:write(" = ") |
90 | end | 90 | end |
91 | 91 | ||
diff --git a/src/luarocks/queries.lua b/src/luarocks/queries.lua index de5c9652..6df61296 100644 --- a/src/luarocks/queries.lua +++ b/src/luarocks/queries.lua | |||
@@ -55,7 +55,7 @@ function queries.new(name, namespace, version, substring, arch, operator) | |||
55 | assert(type(substring) == "boolean" or not substring) | 55 | assert(type(substring) == "boolean" or not substring) |
56 | assert(type(arch) == "string" or not arch) | 56 | assert(type(arch) == "string" or not arch) |
57 | assert(type(operator) == "string" or not operator) | 57 | assert(type(operator) == "string" or not operator) |
58 | 58 | ||
59 | operator = operator or "==" | 59 | operator = operator or "==" |
60 | 60 | ||
61 | local self = { | 61 | local self = { |
@@ -99,7 +99,7 @@ do | |||
99 | ["="] = "==", | 99 | ["="] = "==", |
100 | ["!="] = "~=" | 100 | ["!="] = "~=" |
101 | } | 101 | } |
102 | 102 | ||
103 | --- Consumes a constraint from a string, converting it to table format. | 103 | --- Consumes a constraint from a string, converting it to table format. |
104 | -- For example, a string ">= 1.0, > 2.0" is converted to a table in the | 104 | -- For example, a string ">= 1.0, > 2.0" is converted to a table in the |
105 | -- format {op = ">=", version={1,0}} and the rest, "> 2.0", is returned | 105 | -- format {op = ">=", version={1,0}} and the rest, "> 2.0", is returned |
@@ -110,20 +110,20 @@ do | |||
110 | -- input string is invalid. | 110 | -- input string is invalid. |
111 | parse_constraint = function(input) | 111 | parse_constraint = function(input) |
112 | assert(type(input) == "string") | 112 | assert(type(input) == "string") |
113 | 113 | ||
114 | local no_upgrade, op, version, rest = input:match("^(@?)([<>=~!]*)%s*([%w%.%_%-]+)[%s,]*(.*)") | 114 | local no_upgrade, op, version, rest = input:match("^(@?)([<>=~!]*)%s*([%w%.%_%-]+)[%s,]*(.*)") |
115 | local _op = operators[op] | 115 | local _op = operators[op] |
116 | version = vers.parse_version(version) | 116 | version = vers.parse_version(version) |
117 | if not _op then | 117 | if not _op then |
118 | return nil, "Encountered bad constraint operator: '"..tostring(op).."' in '"..input.."'" | 118 | return nil, "Encountered bad constraint operator: '"..tostring(op).."' in '"..input.."'" |
119 | end | 119 | end |
120 | if not version then | 120 | if not version then |
121 | return nil, "Could not parse version from constraint: '"..input.."'" | 121 | return nil, "Could not parse version from constraint: '"..input.."'" |
122 | end | 122 | end |
123 | return { op = _op, version = version, no_upgrade = no_upgrade=="@" and true or nil }, rest | 123 | return { op = _op, version = version, no_upgrade = no_upgrade=="@" and true or nil }, rest |
124 | end | 124 | end |
125 | end | 125 | end |
126 | 126 | ||
127 | --- Convert a list of constraints from string to table format. | 127 | --- Convert a list of constraints from string to table format. |
128 | -- For example, a string ">= 1.0, < 2.0" is converted to a table in the format | 128 | -- For example, a string ">= 1.0, < 2.0" is converted to a table in the format |
129 | -- {{op = ">=", version={1,0}}, {op = "<", version={2,0}}}. | 129 | -- {{op = ">=", version={1,0}}, {op = "<", version={2,0}}}. |
@@ -134,7 +134,7 @@ do | |||
134 | -- or nil if the input string is invalid. | 134 | -- or nil if the input string is invalid. |
135 | parse_constraints = function(input) | 135 | parse_constraints = function(input) |
136 | assert(type(input) == "string") | 136 | assert(type(input) == "string") |
137 | 137 | ||
138 | local constraints, oinput, constraint = {}, input | 138 | local constraints, oinput, constraint = {}, input |
139 | while #input > 0 do | 139 | while #input > 0 do |
140 | constraint, input = parse_constraint(input) | 140 | constraint, input = parse_constraint(input) |
@@ -147,26 +147,26 @@ do | |||
147 | return constraints | 147 | return constraints |
148 | end | 148 | end |
149 | end | 149 | end |
150 | 150 | ||
151 | --- Prepare a query in dependency table format. | 151 | --- Prepare a query in dependency table format. |
152 | -- @param depstr string: A dependency in string format | 152 | -- @param depstr string: A dependency in string format |
153 | -- as entered in rockspec files. | 153 | -- as entered in rockspec files. |
154 | -- @return table: A query in table format, or nil and an error message in case of errors. | 154 | -- @return table: A query in table format, or nil and an error message in case of errors. |
155 | function queries.from_dep_string(depstr) | 155 | function queries.from_dep_string(depstr) |
156 | assert(type(depstr) == "string") | 156 | assert(type(depstr) == "string") |
157 | 157 | ||
158 | local ns_name, rest = depstr:match("^%s*([a-zA-Z0-9%.%-%_]*/?[a-zA-Z0-9][a-zA-Z0-9%.%-%_]*)%s*([^/]*)") | 158 | local ns_name, rest = depstr:match("^%s*([a-zA-Z0-9%.%-%_]*/?[a-zA-Z0-9][a-zA-Z0-9%.%-%_]*)%s*([^/]*)") |
159 | if not ns_name then | 159 | if not ns_name then |
160 | return nil, "failed to extract dependency name from '"..depstr.."'" | 160 | return nil, "failed to extract dependency name from '"..depstr.."'" |
161 | end | 161 | end |
162 | 162 | ||
163 | local constraints, err = parse_constraints(rest) | 163 | local constraints, err = parse_constraints(rest) |
164 | if not constraints then | 164 | if not constraints then |
165 | return nil, err | 165 | return nil, err |
166 | end | 166 | end |
167 | 167 | ||
168 | local name, namespace = util.split_namespace(ns_name) | 168 | local name, namespace = util.split_namespace(ns_name) |
169 | 169 | ||
170 | local self = { | 170 | local self = { |
171 | name = name, | 171 | name = name, |
172 | namespace = namespace, | 172 | namespace = namespace, |
diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index aabd716f..9f816c7e 100644 --- a/src/luarocks/remove.lua +++ b/src/luarocks/remove.lua | |||
@@ -47,14 +47,14 @@ end | |||
47 | -- "one" for the current default tree, "all" for all trees, | 47 | -- "one" for the current default tree, "all" for all trees, |
48 | -- "order" for all trees with priority >= the current default, "none" for no trees. | 48 | -- "order" for all trees with priority >= the current default, "none" for no trees. |
49 | -- @return boolean or (nil, string): true on success or nil and an error message. | 49 | -- @return boolean or (nil, string): true on success or nil and an error message. |
50 | local function delete_versions(name, versions, deps_mode) | 50 | local function delete_versions(name, versions, deps_mode) |
51 | 51 | ||
52 | for version, _ in pairs(versions) do | 52 | for version, _ in pairs(versions) do |
53 | util.printout("Removing "..name.." "..version.."...") | 53 | util.printout("Removing "..name.." "..version.."...") |
54 | local ok, err = repos.delete_version(name, version, deps_mode) | 54 | local ok, err = repos.delete_version(name, version, deps_mode) |
55 | if not ok then return nil, err end | 55 | if not ok then return nil, err end |
56 | end | 56 | end |
57 | 57 | ||
58 | return true | 58 | return true |
59 | end | 59 | end |
60 | 60 | ||
@@ -63,7 +63,7 @@ function remove.remove_search_results(results, name, deps_mode, force, fast) | |||
63 | 63 | ||
64 | local version = next(versions) | 64 | local version = next(versions) |
65 | local second = next(versions, version) | 65 | local second = next(versions, version) |
66 | 66 | ||
67 | local dependents = {} | 67 | local dependents = {} |
68 | if not fast then | 68 | if not fast then |
69 | util.printout("Checking stability of dependencies in the absence of") | 69 | util.printout("Checking stability of dependencies in the absence of") |
@@ -71,7 +71,7 @@ function remove.remove_search_results(results, name, deps_mode, force, fast) | |||
71 | util.printout() | 71 | util.printout() |
72 | dependents = check_dependents(name, versions, deps_mode) | 72 | dependents = check_dependents(name, versions, deps_mode) |
73 | end | 73 | end |
74 | 74 | ||
75 | if #dependents > 0 then | 75 | if #dependents > 0 then |
76 | if force or fast then | 76 | if force or fast then |
77 | util.printerr("The following packages may be broken by this forced removal:") | 77 | util.printerr("The following packages may be broken by this forced removal:") |
@@ -95,7 +95,7 @@ function remove.remove_search_results(results, name, deps_mode, force, fast) | |||
95 | return nil, "Failed removing." | 95 | return nil, "Failed removing." |
96 | end | 96 | end |
97 | end | 97 | end |
98 | 98 | ||
99 | local ok, err = delete_versions(name, versions, deps_mode) | 99 | local ok, err = delete_versions(name, versions, deps_mode) |
100 | if not ok then return nil, err end | 100 | if not ok then return nil, err end |
101 | 101 | ||
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 4a78dfb2..4610c734 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
@@ -47,7 +47,7 @@ end | |||
47 | -- versions of a package, or nil if none is available. | 47 | -- versions of a package, or nil if none is available. |
48 | local function get_installed_versions(name) | 48 | local function get_installed_versions(name) |
49 | assert(type(name) == "string" and not name:match("/")) | 49 | assert(type(name) == "string" and not name:match("/")) |
50 | 50 | ||
51 | local dirs = fs.list_dir(path.versions_dir(name)) | 51 | local dirs = fs.list_dir(path.versions_dir(name)) |
52 | return (dirs and #dirs > 0) and dirs or nil | 52 | return (dirs and #dirs > 0) and dirs or nil |
53 | end | 53 | end |
@@ -61,7 +61,7 @@ end | |||
61 | function repos.is_installed(name, version) | 61 | function repos.is_installed(name, version) |
62 | assert(type(name) == "string" and not name:match("/")) | 62 | assert(type(name) == "string" and not name:match("/")) |
63 | assert(type(version) == "string") | 63 | assert(type(version) == "string") |
64 | 64 | ||
65 | return fs.is_dir(path.install_dir(name, version)) | 65 | return fs.is_dir(path.install_dir(name, version)) |
66 | end | 66 | end |
67 | 67 | ||
@@ -172,11 +172,11 @@ function repos.run_hook(rockspec, hook_name) | |||
172 | if not hooks then | 172 | if not hooks then |
173 | return true | 173 | return true |
174 | end | 174 | end |
175 | 175 | ||
176 | if cfg.hooks_enabled == false then | 176 | if cfg.hooks_enabled == false then |
177 | return nil, "This rockspec contains hooks, which are blocked by the 'hooks_enabled' setting in your LuaRocks configuration." | 177 | return nil, "This rockspec contains hooks, which are blocked by the 'hooks_enabled' setting in your LuaRocks configuration." |
178 | end | 178 | end |
179 | 179 | ||
180 | if not hooks.substituted_variables then | 180 | if not hooks.substituted_variables then |
181 | util.variable_substitutions(hooks, rockspec.variables) | 181 | util.variable_substitutions(hooks, rockspec.variables) |
182 | hooks.substituted_variables = true | 182 | hooks.substituted_variables = true |
@@ -269,7 +269,7 @@ local function backup_existing(should_backup, target) | |||
269 | repeat | 269 | repeat |
270 | backup = backup.."~" | 270 | backup = backup.."~" |
271 | until not fs.exists(backup) -- Slight race condition here, but shouldn't be a problem. | 271 | until not fs.exists(backup) -- Slight race condition here, but shouldn't be a problem. |
272 | 272 | ||
273 | util.warning(target.." is not tracked by this installation of LuaRocks. Moving it to "..backup) | 273 | util.warning(target.." is not tracked by this installation of LuaRocks. Moving it to "..backup) |
274 | local move_ok, move_err = os.rename(target, backup) | 274 | local move_ok, move_err = os.rename(target, backup) |
275 | if not move_ok then | 275 | if not move_ok then |
@@ -300,7 +300,7 @@ local function prepare_op_install() | |||
300 | if not ok then | 300 | if not ok then |
301 | return nil, err | 301 | return nil, err |
302 | end | 302 | end |
303 | 303 | ||
304 | local backup, err = backup_existing(op.backup, op.realdst or op.dst) | 304 | local backup, err = backup_existing(op.backup, op.realdst or op.dst) |
305 | if err then | 305 | if err then |
306 | return nil, err | 306 | return nil, err |
@@ -308,22 +308,22 @@ local function prepare_op_install() | |||
308 | if backup then | 308 | if backup then |
309 | op.backup_file = backup | 309 | op.backup_file = backup |
310 | end | 310 | end |
311 | 311 | ||
312 | ok, err = op.fn(op.src, op.dst, op.backup) | 312 | ok, err = op.fn(op.src, op.dst, op.backup) |
313 | if not ok then | 313 | if not ok then |
314 | return nil, err | 314 | return nil, err |
315 | end | 315 | end |
316 | 316 | ||
317 | rmdirs[dir.dir_name(op.src)] = true | 317 | rmdirs[dir.dir_name(op.src)] = true |
318 | return true | 318 | return true |
319 | end | 319 | end |
320 | 320 | ||
321 | local function done_op_install() | 321 | local function done_op_install() |
322 | for d, _ in pairs(rmdirs) do | 322 | for d, _ in pairs(rmdirs) do |
323 | fs.remove_dir_tree_if_empty(d) | 323 | fs.remove_dir_tree_if_empty(d) |
324 | end | 324 | end |
325 | end | 325 | end |
326 | 326 | ||
327 | return op_install, done_op_install | 327 | return op_install, done_op_install |
328 | end | 328 | end |
329 | 329 | ||
@@ -361,7 +361,7 @@ end | |||
361 | local function prepare_op_delete() | 361 | local function prepare_op_delete() |
362 | local deletes = {} | 362 | local deletes = {} |
363 | local rmdirs = {} | 363 | local rmdirs = {} |
364 | 364 | ||
365 | local function done_op_delete() | 365 | local function done_op_delete() |
366 | for _, f in ipairs(deletes) do | 366 | for _, f in ipairs(deletes) do |
367 | os.remove(f) | 367 | os.remove(f) |
@@ -377,12 +377,12 @@ local function prepare_op_delete() | |||
377 | local suffix = check_suffix(op.name, op.suffix) | 377 | local suffix = check_suffix(op.name, op.suffix) |
378 | op.name = op.name .. suffix | 378 | op.name = op.name .. suffix |
379 | end | 379 | end |
380 | 380 | ||
381 | table.insert(deletes, op.name) | 381 | table.insert(deletes, op.name) |
382 | 382 | ||
383 | rmdirs[dir.dir_name(op.name)] = true | 383 | rmdirs[dir.dir_name(op.name)] = true |
384 | end | 384 | end |
385 | 385 | ||
386 | return op_delete, done_op_delete | 386 | return op_delete, done_op_delete |
387 | end | 387 | end |
388 | 388 | ||
@@ -406,7 +406,7 @@ function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode) | |||
406 | 406 | ||
407 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) | 407 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) |
408 | if not rock_manifest then return nil, load_err end | 408 | if not rock_manifest then return nil, load_err end |
409 | 409 | ||
410 | local repo = cfg.root_dir | 410 | local repo = cfg.root_dir |
411 | local renames = {} | 411 | local renames = {} |
412 | local installs = {} | 412 | local installs = {} |
@@ -592,7 +592,7 @@ function repos.delete_version(name, version, deps_mode, quick) | |||
592 | op_delete(op) | 592 | op_delete(op) |
593 | end | 593 | end |
594 | done_op_delete() | 594 | done_op_delete() |
595 | 595 | ||
596 | if not quick then | 596 | if not quick then |
597 | for _, op in ipairs(renames) do | 597 | for _, op in ipairs(renames) do |
598 | op_rename(op) | 598 | op_rename(op) |
diff --git a/src/luarocks/results.lua b/src/luarocks/results.lua index a6ebfbf3..c14862de 100644 --- a/src/luarocks/results.lua +++ b/src/luarocks/results.lua | |||
@@ -17,11 +17,11 @@ function results.new(name, version, repo, arch, namespace) | |||
17 | assert(type(repo) == "string") | 17 | assert(type(repo) == "string") |
18 | assert(type(arch) == "string" or not arch) | 18 | assert(type(arch) == "string" or not arch) |
19 | assert(type(namespace) == "string" or not namespace) | 19 | assert(type(namespace) == "string" or not namespace) |
20 | 20 | ||
21 | if not namespace then | 21 | if not namespace then |
22 | name, namespace = util.split_namespace(name) | 22 | name, namespace = util.split_namespace(name) |
23 | end | 23 | end |
24 | 24 | ||
25 | local self = { | 25 | local self = { |
26 | name = name, | 26 | name = name, |
27 | version = version, | 27 | version = version, |
diff --git a/src/luarocks/rockspecs.lua b/src/luarocks/rockspecs.lua index f1bb6d6a..94462951 100644 --- a/src/luarocks/rockspecs.lua +++ b/src/luarocks/rockspecs.lua | |||
@@ -1,5 +1,5 @@ | |||
1 | local rockspecs = {} | 1 | local rockspecs = {} |
2 | 2 | ||
3 | local cfg = require("luarocks.core.cfg") | 3 | local cfg = require("luarocks.core.cfg") |
4 | local dir = require("luarocks.dir") | 4 | local dir = require("luarocks.dir") |
5 | local path = require("luarocks.path") | 5 | local path = require("luarocks.path") |
@@ -31,9 +31,9 @@ end | |||
31 | -- if it doesn't (or if nil is passed), this function does nothing. | 31 | -- if it doesn't (or if nil is passed), this function does nothing. |
32 | local function platform_overrides(tbl) | 32 | local function platform_overrides(tbl) |
33 | assert(type(tbl) == "table" or not tbl) | 33 | assert(type(tbl) == "table" or not tbl) |
34 | 34 | ||
35 | if not tbl then return end | 35 | if not tbl then return end |
36 | 36 | ||
37 | if tbl.platforms then | 37 | if tbl.platforms then |
38 | for platform in cfg.each_platform() do | 38 | for platform in cfg.each_platform() do |
39 | local platform_tbl = tbl.platforms[platform] | 39 | local platform_tbl = tbl.platforms[platform] |
@@ -158,4 +158,4 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick) | |||
158 | return setmetatable(rockspec, rockspec_mt) | 158 | return setmetatable(rockspec, rockspec_mt) |
159 | end | 159 | end |
160 | 160 | ||
161 | return rockspecs \ No newline at end of file | 161 | return rockspecs |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index d2bad630..8a79d990 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -61,13 +61,13 @@ function search.disk_search(repo, query, result_tree) | |||
61 | assert(type(repo) == "string") | 61 | assert(type(repo) == "string") |
62 | assert(query:type() == "query") | 62 | assert(query:type() == "query") |
63 | assert(type(result_tree) == "table" or not result_tree) | 63 | assert(type(result_tree) == "table" or not result_tree) |
64 | 64 | ||
65 | local fs = require("luarocks.fs") | 65 | local fs = require("luarocks.fs") |
66 | 66 | ||
67 | if not result_tree then | 67 | if not result_tree then |
68 | result_tree = {} | 68 | result_tree = {} |
69 | end | 69 | end |
70 | 70 | ||
71 | for name in fs.dir(repo) do | 71 | for name in fs.dir(repo) do |
72 | local pathname = dir.path(repo, name) | 72 | local pathname = dir.path(repo, name) |
73 | local rname, rversion, rarch = path.parse_name(name) | 73 | local rname, rversion, rarch = path.parse_name(name) |
@@ -231,13 +231,13 @@ function search.find_suitable_rock(query) | |||
231 | assert(query:type() == "query") | 231 | assert(query:type() == "query") |
232 | 232 | ||
233 | local rocks_provided = util.get_rocks_provided() | 233 | local rocks_provided = util.get_rocks_provided() |
234 | 234 | ||
235 | if rocks_provided[query.name] ~= nil then | 235 | if rocks_provided[query.name] ~= nil then |
236 | -- Do not install versions listed in rocks_provided. | 236 | -- Do not install versions listed in rocks_provided. |
237 | return nil, "Rock "..query.name.." "..rocks_provided[query.name].. | 237 | return nil, "Rock "..query.name.." "..rocks_provided[query.name].. |
238 | " is already provided by VM or via 'rocks_provided' in the config file.", "provided" | 238 | " is already provided by VM or via 'rocks_provided' in the config file.", "provided" |
239 | end | 239 | end |
240 | 240 | ||
241 | local result_tree = search.search_repos(query) | 241 | local result_tree = search.search_repos(query) |
242 | local first_rock = next(result_tree) | 242 | local first_rock = next(result_tree) |
243 | if not first_rock then | 243 | if not first_rock then |
@@ -270,19 +270,19 @@ function search.find_rock_checking_lua_versions(query, check_lua_versions) | |||
270 | if check_lua_versions then | 270 | if check_lua_versions then |
271 | util.printout(query.name .. " not found for Lua " .. cfg.lua_version .. ".") | 271 | util.printout(query.name .. " not found for Lua " .. cfg.lua_version .. ".") |
272 | util.printout("Checking if available for other Lua versions...") | 272 | util.printout("Checking if available for other Lua versions...") |
273 | 273 | ||
274 | -- Check if constraints are satisfiable with other Lua versions. | 274 | -- Check if constraints are satisfiable with other Lua versions. |
275 | local lua_versions = supported_lua_versions(query) | 275 | local lua_versions = supported_lua_versions(query) |
276 | 276 | ||
277 | if #lua_versions ~= 0 then | 277 | if #lua_versions ~= 0 then |
278 | -- Build a nice message in "only Lua 5.x and 5.y but not 5.z." format | 278 | -- Build a nice message in "only Lua 5.x and 5.y but not 5.z." format |
279 | for i, lua_version in ipairs(lua_versions) do | 279 | for i, lua_version in ipairs(lua_versions) do |
280 | lua_versions[i] = "Lua "..lua_version | 280 | lua_versions[i] = "Lua "..lua_version |
281 | end | 281 | end |
282 | 282 | ||
283 | local versions_message = "only "..table.concat(lua_versions, " and ").. | 283 | local versions_message = "only "..table.concat(lua_versions, " and ").. |
284 | " but not Lua "..cfg.lua_version.."." | 284 | " but not Lua "..cfg.lua_version.."." |
285 | 285 | ||
286 | if #query.constraints == 0 then | 286 | if #query.constraints == 0 then |
287 | add = query.name.." supports "..versions_message | 287 | add = query.name.." supports "..versions_message |
288 | elseif #query.constraints == 1 and query.constraints[1].op == "==" then | 288 | elseif #query.constraints == 1 and query.constraints[1].op == "==" then |
@@ -308,7 +308,7 @@ end | |||
308 | function search.print_result_tree(result_tree, porcelain) | 308 | function search.print_result_tree(result_tree, porcelain) |
309 | assert(type(result_tree) == "table") | 309 | assert(type(result_tree) == "table") |
310 | assert(type(porcelain) == "boolean" or not porcelain) | 310 | assert(type(porcelain) == "boolean" or not porcelain) |
311 | 311 | ||
312 | if porcelain then | 312 | if porcelain then |
313 | for package, versions in util.sortedpairs(result_tree) do | 313 | for package, versions in util.sortedpairs(result_tree) do |
314 | for version, repos in util.sortedpairs(versions, vers.compare_versions) do | 314 | for version, repos in util.sortedpairs(versions, vers.compare_versions) do |
@@ -320,7 +320,7 @@ function search.print_result_tree(result_tree, porcelain) | |||
320 | end | 320 | end |
321 | return | 321 | return |
322 | end | 322 | end |
323 | 323 | ||
324 | for package, versions in util.sortedpairs(result_tree) do | 324 | for package, versions in util.sortedpairs(result_tree) do |
325 | local namespaces = {} | 325 | local namespaces = {} |
326 | for version, repos in util.sortedpairs(versions, vers.compare_versions) do | 326 | for version, repos in util.sortedpairs(versions, vers.compare_versions) do |
diff --git a/src/luarocks/signing.lua b/src/luarocks/signing.lua index 2e61041e..cb91643a 100644 --- a/src/luarocks/signing.lua +++ b/src/luarocks/signing.lua | |||
@@ -22,7 +22,7 @@ function signing.sign_file(file) | |||
22 | if not gpg then | 22 | if not gpg then |
23 | return nil, err | 23 | return nil, err |
24 | end | 24 | end |
25 | 25 | ||
26 | local sigfile = file .. ".asc" | 26 | local sigfile = file .. ".asc" |
27 | if fs.execute(gpg, "--armor", "--output", sigfile, "--detach-sign", file) then | 27 | if fs.execute(gpg, "--armor", "--output", sigfile, "--detach-sign", file) then |
28 | return sigfile | 28 | return sigfile |
diff --git a/src/luarocks/test.lua b/src/luarocks/test.lua index c550c5b8..15eca234 100644 --- a/src/luarocks/test.lua +++ b/src/luarocks/test.lua | |||
@@ -22,13 +22,13 @@ local function get_test_type(rockspec) | |||
22 | if rockspec.test and rockspec.test.type then | 22 | if rockspec.test and rockspec.test.type then |
23 | return rockspec.test.type | 23 | return rockspec.test.type |
24 | end | 24 | end |
25 | 25 | ||
26 | for _, test_module in ipairs(test_modules) do | 26 | for _, test_module in ipairs(test_modules) do |
27 | if test_module.detect_type() then | 27 | if test_module.detect_type() then |
28 | return test_modules[test_module] | 28 | return test_modules[test_module] |
29 | end | 29 | end |
30 | end | 30 | end |
31 | 31 | ||
32 | return nil, "could not detect test type -- no test suite for " .. rockspec.package .. "?" | 32 | return nil, "could not detect test type -- no test suite for " .. rockspec.package .. "?" |
33 | end | 33 | end |
34 | 34 | ||
@@ -45,7 +45,7 @@ function test.run_test_suite(rockspec_arg, test_type, args) | |||
45 | assert(type(rockspec_arg) == "table") | 45 | assert(type(rockspec_arg) == "table") |
46 | rockspec = rockspec_arg | 46 | rockspec = rockspec_arg |
47 | end | 47 | end |
48 | 48 | ||
49 | if not test_type then | 49 | if not test_type then |
50 | local err | 50 | local err |
51 | test_type, err = get_test_type(rockspec, test_type) | 51 | test_type, err = get_test_type(rockspec, test_type) |
@@ -67,7 +67,7 @@ function test.run_test_suite(rockspec_arg, test_type, args) | |||
67 | if not pok then | 67 | if not pok then |
68 | return nil, "failed loading test execution module " .. mod_name | 68 | return nil, "failed loading test execution module " .. mod_name |
69 | end | 69 | end |
70 | 70 | ||
71 | return test_mod.run_tests(rockspec.test, args) | 71 | return test_mod.run_tests(rockspec.test, args) |
72 | end | 72 | end |
73 | 73 | ||
diff --git a/src/luarocks/test/command.lua b/src/luarocks/test/command.lua index 999cc325..1795c4e9 100644 --- a/src/luarocks/test/command.lua +++ b/src/luarocks/test/command.lua | |||
@@ -20,7 +20,7 @@ function command.run_tests(test, args) | |||
20 | script = "test.lua" | 20 | script = "test.lua" |
21 | } | 21 | } |
22 | end | 22 | end |
23 | 23 | ||
24 | if not test.script and not test.command then | 24 | if not test.script and not test.command then |
25 | test.script = "test.lua" | 25 | test.script = "test.lua" |
26 | end | 26 | end |
@@ -31,7 +31,7 @@ function command.run_tests(test, args) | |||
31 | table.insert(args, i, test.flags[i]) | 31 | table.insert(args, i, test.flags[i]) |
32 | end | 32 | end |
33 | end | 33 | end |
34 | 34 | ||
35 | local ok | 35 | local ok |
36 | 36 | ||
37 | if test.script then | 37 | if test.script then |
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index 829df931..b12f38fc 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua | |||
@@ -114,7 +114,7 @@ local function file_lines(f) | |||
114 | pos_beg = pos + 1 | 114 | pos_beg = pos + 1 |
115 | if #line > 0 then | 115 | if #line > 0 then |
116 | return line | 116 | return line |
117 | end | 117 | end |
118 | end | 118 | end |
119 | end | 119 | end |
120 | 120 | ||
@@ -526,7 +526,7 @@ local function patch_hunks(srcname, tgtname, hunks) | |||
526 | tgt:close() | 526 | tgt:close() |
527 | src:close() | 527 | src:close() |
528 | return true | 528 | return true |
529 | end | 529 | end |
530 | 530 | ||
531 | local function strip_dirs(filename, strip) | 531 | local function strip_dirs(filename, strip) |
532 | if strip == nil then return filename end | 532 | if strip == nil then return filename end |
@@ -616,7 +616,7 @@ local function patch_file(source, target, epoch, hunks, strip, create_delete) | |||
616 | end | 616 | end |
617 | end | 617 | end |
618 | hunklineno = 1 | 618 | hunklineno = 1 |
619 | 619 | ||
620 | -- todo \ No newline at end of file | 620 | -- todo \ No newline at end of file |
621 | end | 621 | end |
622 | -- check hunks in source file | 622 | -- check hunks in source file |
diff --git a/src/luarocks/tools/tar.lua b/src/luarocks/tools/tar.lua index a6a95252..aea2809c 100644 --- a/src/luarocks/tools/tar.lua +++ b/src/luarocks/tools/tar.lua | |||
@@ -30,7 +30,7 @@ local function octal_to_number(octal) | |||
30 | local number = 0 | 30 | local number = 0 |
31 | octal = octal:gsub("%s", "") | 31 | octal = octal:gsub("%s", "") |
32 | for i = #octal,1,-1 do | 32 | for i = #octal,1,-1 do |
33 | local digit = tonumber(octal:sub(i,i)) | 33 | local digit = tonumber(octal:sub(i,i)) |
34 | if not digit then | 34 | if not digit then |
35 | break | 35 | break |
36 | end | 36 | end |
@@ -93,7 +93,7 @@ function tar.untar(filename, destdir) | |||
93 | 93 | ||
94 | local tar_handle = io.open(filename, "rb") | 94 | local tar_handle = io.open(filename, "rb") |
95 | if not tar_handle then return nil, "Error opening file "..filename end | 95 | if not tar_handle then return nil, "Error opening file "..filename end |
96 | 96 | ||
97 | local long_name, long_link_name | 97 | local long_name, long_link_name |
98 | local ok, err | 98 | local ok, err |
99 | local make_dir = fun.memoize(fs.make_dir) | 99 | local make_dir = fun.memoize(fs.make_dir) |
diff --git a/src/luarocks/tools/zip.lua b/src/luarocks/tools/zip.lua index 37091185..7803b509 100644 --- a/src/luarocks/tools/zip.lua +++ b/src/luarocks/tools/zip.lua | |||
@@ -129,7 +129,7 @@ end | |||
129 | -- @return true if succeeded, nil in case of failure. | 129 | -- @return true if succeeded, nil in case of failure. |
130 | local function zipwriter_close_file_in_zip(self) | 130 | local function zipwriter_close_file_in_zip(self) |
131 | local zh = self.ziphandle | 131 | local zh = self.ziphandle |
132 | 132 | ||
133 | if not self.in_open_file then | 133 | if not self.in_open_file then |
134 | return nil | 134 | return nil |
135 | end | 135 | end |
@@ -152,16 +152,16 @@ local function zipwriter_close_file_in_zip(self) | |||
152 | 152 | ||
153 | -- File data | 153 | -- File data |
154 | zh:write(self.data) | 154 | zh:write(self.data) |
155 | 155 | ||
156 | -- Data descriptor | 156 | -- Data descriptor |
157 | zh:write(DATA_DESCRIPTOR_SIGNATURE) | 157 | zh:write(DATA_DESCRIPTOR_SIGNATURE) |
158 | zh:write(number_to_lestring(lfh.crc32, 4)) | 158 | zh:write(number_to_lestring(lfh.crc32, 4)) |
159 | zh:write(number_to_lestring(lfh.compressed_size, 4)) | 159 | zh:write(number_to_lestring(lfh.compressed_size, 4)) |
160 | zh:write(number_to_lestring(lfh.uncompressed_size, 4)) | 160 | zh:write(number_to_lestring(lfh.uncompressed_size, 4)) |
161 | 161 | ||
162 | table.insert(self.files, lfh) | 162 | table.insert(self.files, lfh) |
163 | self.in_open_file = false | 163 | self.in_open_file = false |
164 | 164 | ||
165 | return true | 165 | return true |
166 | end | 166 | end |
167 | 167 | ||
@@ -208,9 +208,9 @@ end | |||
208 | -- @return true if succeeded, nil in case of failure. | 208 | -- @return true if succeeded, nil in case of failure. |
209 | local function zipwriter_close(self) | 209 | local function zipwriter_close(self) |
210 | local zh = self.ziphandle | 210 | local zh = self.ziphandle |
211 | 211 | ||
212 | local central_directory_offset = zh:seek() | 212 | local central_directory_offset = zh:seek() |
213 | 213 | ||
214 | local size_of_central_directory = 0 | 214 | local size_of_central_directory = 0 |
215 | -- Central directory structure | 215 | -- Central directory structure |
216 | for _, lfh in ipairs(self.files) do | 216 | for _, lfh in ipairs(self.files) do |
@@ -234,7 +234,7 @@ local function zipwriter_close(self) | |||
234 | zh:write(lfh.file_name) | 234 | zh:write(lfh.file_name) |
235 | size_of_central_directory = size_of_central_directory + 46 + lfh.file_name_length | 235 | size_of_central_directory = size_of_central_directory + 46 + lfh.file_name_length |
236 | end | 236 | end |
237 | 237 | ||
238 | -- End of central directory record | 238 | -- End of central directory record |
239 | zh:write(END_OF_CENTRAL_DIR_SIGNATURE) -- signature | 239 | zh:write(END_OF_CENTRAL_DIR_SIGNATURE) -- signature |
240 | zh:write(number_to_lestring(0, 2)) -- number of this disk | 240 | zh:write(number_to_lestring(0, 2)) -- number of this disk |
@@ -253,16 +253,16 @@ end | |||
253 | -- @param name filename of the zipfile to be created. | 253 | -- @param name filename of the zipfile to be created. |
254 | -- @return a zip handle, or nil in case of error. | 254 | -- @return a zip handle, or nil in case of error. |
255 | function zip.new_zipwriter(name) | 255 | function zip.new_zipwriter(name) |
256 | 256 | ||
257 | local zw = {} | 257 | local zw = {} |
258 | 258 | ||
259 | zw.ziphandle = io.open(fs.absolute_name(name), "wb") | 259 | zw.ziphandle = io.open(fs.absolute_name(name), "wb") |
260 | if not zw.ziphandle then | 260 | if not zw.ziphandle then |
261 | return nil | 261 | return nil |
262 | end | 262 | end |
263 | zw.files = {} | 263 | zw.files = {} |
264 | zw.in_open_file = false | 264 | zw.in_open_file = false |
265 | 265 | ||
266 | zw.add = zipwriter_add | 266 | zw.add = zipwriter_add |
267 | zw.close = zipwriter_close | 267 | zw.close = zipwriter_close |
268 | zw.open_new_file_in_zip = zipwriter_open_new_file_in_zip | 268 | zw.open_new_file_in_zip = zipwriter_open_new_file_in_zip |
@@ -381,7 +381,7 @@ local function process_end_of_central_dir(zh) | |||
381 | return nil, "Could not find End of Central Directory signature" | 381 | return nil, "Could not find End of Central Directory signature" |
382 | end | 382 | end |
383 | end | 383 | end |
384 | 384 | ||
385 | -- number of this disk (2 bytes) | 385 | -- number of this disk (2 bytes) |
386 | -- number of the disk with the start of the central directory (2 bytes) | 386 | -- number of the disk with the start of the central directory (2 bytes) |
387 | -- total number of entries in the central directory on this disk (2 bytes) | 387 | -- total number of entries in the central directory on this disk (2 bytes) |
@@ -450,7 +450,7 @@ function zip.unzip(zipfile) | |||
450 | if not cd_entries then | 450 | if not cd_entries then |
451 | return nil, cd_offset | 451 | return nil, cd_offset |
452 | end | 452 | end |
453 | 453 | ||
454 | local ok, err = zh:seek("set", cd_offset) | 454 | local ok, err = zh:seek("set", cd_offset) |
455 | if not ok then | 455 | if not ok then |
456 | return nil, err | 456 | return nil, err |
@@ -513,7 +513,7 @@ end | |||
513 | function zip.gzip(input_filename, output_filename) | 513 | function zip.gzip(input_filename, output_filename) |
514 | assert(type(input_filename) == "string") | 514 | assert(type(input_filename) == "string") |
515 | assert(output_filename == nil or type(output_filename) == "string") | 515 | assert(output_filename == nil or type(output_filename) == "string") |
516 | 516 | ||
517 | if not output_filename then | 517 | if not output_filename then |
518 | output_filename = input_filename .. ".gz" | 518 | output_filename = input_filename .. ".gz" |
519 | end | 519 | end |
@@ -525,7 +525,7 @@ end | |||
525 | function zip.gunzip(input_filename, output_filename) | 525 | function zip.gunzip(input_filename, output_filename) |
526 | assert(type(input_filename) == "string") | 526 | assert(type(input_filename) == "string") |
527 | assert(output_filename == nil or type(output_filename) == "string") | 527 | assert(output_filename == nil or type(output_filename) == "string") |
528 | 528 | ||
529 | if not output_filename then | 529 | if not output_filename then |
530 | output_filename = input_filename:gsub("%.gz$", "") | 530 | output_filename = input_filename:gsub("%.gz$", "") |
531 | end | 531 | end |
diff --git a/src/luarocks/type/manifest.lua b/src/luarocks/type/manifest.lua index bf985ad3..043366ea 100644 --- a/src/luarocks/type/manifest.lua +++ b/src/luarocks/type/manifest.lua | |||
@@ -64,7 +64,7 @@ local manifest_formats = type_check.declare_schemas({ | |||
64 | }) | 64 | }) |
65 | 65 | ||
66 | --- Type check a manifest table. | 66 | --- Type check a manifest table. |
67 | -- Verify the correctness of elements from a | 67 | -- Verify the correctness of elements from a |
68 | -- manifest table, reporting on unknown fields and type | 68 | -- manifest table, reporting on unknown fields and type |
69 | -- mismatches. | 69 | -- mismatches. |
70 | -- @return boolean or (nil, string): true if type checking | 70 | -- @return boolean or (nil, string): true if type checking |
diff --git a/src/luarocks/type/rockspec.lua b/src/luarocks/type/rockspec.lua index 8214516e..0b4b5dcf 100644 --- a/src/luarocks/type/rockspec.lua +++ b/src/luarocks/type/rockspec.lua | |||
@@ -89,13 +89,13 @@ local rockspec_formats, versions = type_check.declare_schemas({ | |||
89 | post_install = { _type = "string" }, | 89 | post_install = { _type = "string" }, |
90 | }, | 90 | }, |
91 | }, | 91 | }, |
92 | 92 | ||
93 | ["1.1"] = { | 93 | ["1.1"] = { |
94 | deploy = { | 94 | deploy = { |
95 | wrap_bin_scripts = { _type = "boolean" }, | 95 | wrap_bin_scripts = { _type = "boolean" }, |
96 | } | 96 | } |
97 | }, | 97 | }, |
98 | 98 | ||
99 | ["3.0"] = { | 99 | ["3.0"] = { |
100 | description = { | 100 | description = { |
101 | labels = { | 101 | labels = { |
@@ -135,7 +135,7 @@ local rockspec_formats, versions = type_check.declare_schemas({ | |||
135 | } | 135 | } |
136 | }) | 136 | }) |
137 | 137 | ||
138 | type_rockspec.order = {"rockspec_format", "package", "version", | 138 | type_rockspec.order = {"rockspec_format", "package", "version", |
139 | { "source", { "url", "tag", "branch", "md5" } }, | 139 | { "source", { "url", "tag", "branch", "md5" } }, |
140 | { "description", {"summary", "detailed", "homepage", "license" } }, | 140 | { "description", {"summary", "detailed", "homepage", "license" } }, |
141 | "supported_platforms", "dependencies", "build_dependencies", "external_dependencies", | 141 | "supported_platforms", "dependencies", "build_dependencies", "external_dependencies", |
@@ -160,7 +160,7 @@ local function check_rockspec_using_version(rockspec, globals, version) | |||
160 | end | 160 | end |
161 | 161 | ||
162 | --- Type check a rockspec table. | 162 | --- Type check a rockspec table. |
163 | -- Verify the correctness of elements from a | 163 | -- Verify the correctness of elements from a |
164 | -- rockspec table, reporting on unknown fields and type | 164 | -- rockspec table, reporting on unknown fields and type |
165 | -- mismatches. | 165 | -- mismatches. |
166 | -- @return boolean or (nil, string): true if type checking | 166 | -- @return boolean or (nil, string): true if type checking |
diff --git a/src/luarocks/type_check.lua b/src/luarocks/type_check.lua index bdf8ecc8..21085ef9 100644 --- a/src/luarocks/type_check.lua +++ b/src/luarocks/type_check.lua | |||
@@ -22,7 +22,7 @@ do | |||
22 | end | 22 | end |
23 | end | 23 | end |
24 | end | 24 | end |
25 | 25 | ||
26 | local function expand_magic_platforms(tbl) | 26 | local function expand_magic_platforms(tbl) |
27 | for k,v in pairs(tbl) do | 27 | for k,v in pairs(tbl) do |
28 | if v == type_check.MAGIC_PLATFORMS then | 28 | if v == type_check.MAGIC_PLATFORMS then |
@@ -35,7 +35,7 @@ do | |||
35 | end | 35 | end |
36 | end | 36 | end |
37 | end | 37 | end |
38 | 38 | ||
39 | -- Build a table of schemas. | 39 | -- Build a table of schemas. |
40 | -- @param versions a table where each key is a version number as a string, | 40 | -- @param versions a table where each key is a version number as a string, |
41 | -- and the value is a schema specification. Schema versions are considered | 41 | -- and the value is a schema specification. Schema versions are considered |
@@ -44,7 +44,7 @@ do | |||
44 | function type_check.declare_schemas(inputs) | 44 | function type_check.declare_schemas(inputs) |
45 | local schemas = {} | 45 | local schemas = {} |
46 | local parent_version | 46 | local parent_version |
47 | 47 | ||
48 | local versions = fun.reverse_in(fun.sort_in(util.keys(inputs), vers.compare_versions)) | 48 | local versions = fun.reverse_in(fun.sort_in(util.keys(inputs), vers.compare_versions)) |
49 | 49 | ||
50 | for _, version in ipairs(versions) do | 50 | for _, version in ipairs(versions) do |
@@ -99,10 +99,10 @@ local function type_check_item(version, item, typetbl, context) | |||
99 | return nil, err | 99 | return nil, err |
100 | end | 100 | end |
101 | end | 101 | end |
102 | 102 | ||
103 | local item_type = type(item) or "nil" | 103 | local item_type = type(item) or "nil" |
104 | local expected_type = typetbl._type or "table" | 104 | local expected_type = typetbl._type or "table" |
105 | 105 | ||
106 | if expected_type == "number" then | 106 | if expected_type == "number" then |
107 | if not tonumber(item) then | 107 | if not tonumber(item) then |
108 | return nil, "Type mismatch on field "..context..": expected a number" | 108 | return nil, "Type mismatch on field "..context..": expected a number" |
@@ -148,7 +148,7 @@ end | |||
148 | -- in tbl that is correctly typed, type(tbl.x) == type(types.x)). | 148 | -- in tbl that is correctly typed, type(tbl.x) == type(types.x)). |
149 | -- If the reference table contains a field called MORE, then | 149 | -- If the reference table contains a field called MORE, then |
150 | -- unknown fields in the checked table are accepted. | 150 | -- unknown fields in the checked table are accepted. |
151 | -- If it contains a field called ANY, then its type will be | 151 | -- If it contains a field called ANY, then its type will be |
152 | -- used to check any unknown fields. If a field is prefixed | 152 | -- used to check any unknown fields. If a field is prefixed |
153 | -- with MUST_, it is mandatory; its absence from the table is | 153 | -- with MUST_, it is mandatory; its absence from the table is |
154 | -- a type error. | 154 | -- a type error. |
@@ -174,7 +174,7 @@ function type_check.type_check_table(version, tbl, typetbl, context) | |||
174 | 174 | ||
175 | for k, v in pairs(tbl) do | 175 | for k, v in pairs(tbl) do |
176 | local t = typetbl[k] or typetbl._any | 176 | local t = typetbl[k] or typetbl._any |
177 | if t then | 177 | if t then |
178 | local ok, err = type_check_item(version, v, t, mkfield(context, k)) | 178 | local ok, err = type_check_item(version, v, t, mkfield(context, k)) |
179 | if not ok then return nil, err end | 179 | if not ok then return nil, err end |
180 | elseif typetbl._more then | 180 | elseif typetbl._more then |
diff --git a/src/luarocks/upload/api.lua b/src/luarocks/upload/api.lua index a28b517a..df57fc80 100644 --- a/src/luarocks/upload/api.lua +++ b/src/luarocks/upload/api.lua | |||
@@ -120,7 +120,7 @@ function Api:request(url, params, post_params) | |||
120 | local vars = cfg.variables | 120 | local vars = cfg.variables |
121 | local json_ok, json = util.require_json() | 121 | local json_ok, json = util.require_json() |
122 | if not json_ok then return nil, "A JSON library is required for this command. "..json end | 122 | if not json_ok then return nil, "A JSON library is required for this command. "..json end |
123 | 123 | ||
124 | if fs.which_tool("downloader") == "wget" then | 124 | if fs.which_tool("downloader") == "wget" then |
125 | local curl_ok, err = fs.is_tool_available(vars.CURL, "curl") | 125 | local curl_ok, err = fs.is_tool_available(vars.CURL, "curl") |
126 | if not curl_ok then | 126 | if not curl_ok then |
@@ -135,7 +135,7 @@ function Api:request(url, params, post_params) | |||
135 | url = url .. ("?" .. encode_query_string(params)) | 135 | url = url .. ("?" .. encode_query_string(params)) |
136 | end | 136 | end |
137 | local method = "GET" | 137 | local method = "GET" |
138 | local out | 138 | local out |
139 | local tmpfile = fs.tmpname() | 139 | local tmpfile = fs.tmpname() |
140 | if post_params then | 140 | if post_params then |
141 | method = "POST" | 141 | method = "POST" |
@@ -148,7 +148,7 @@ function Api:request(url, params, post_params) | |||
148 | curl_cmd = curl_cmd .. "--form \""..k.."="..var.."\" " | 148 | curl_cmd = curl_cmd .. "--form \""..k.."="..var.."\" " |
149 | end | 149 | end |
150 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | 150 | if cfg.connection_timeout and cfg.connection_timeout > 0 then |
151 | curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " | 151 | curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " |
152 | end | 152 | end |
153 | local ok = fs.execute_string(curl_cmd..fs.Q(url).." -o "..fs.Q(tmpfile)) | 153 | local ok = fs.execute_string(curl_cmd..fs.Q(url).." -o "..fs.Q(tmpfile)) |
154 | if not ok then | 154 | if not ok then |
@@ -206,7 +206,7 @@ function Api:request(url, params, post_params) | |||
206 | if not http_ok then | 206 | if not http_ok then |
207 | return nil, "Failed loading socket library!" | 207 | return nil, "Failed loading socket library!" |
208 | end | 208 | end |
209 | 209 | ||
210 | if not self.config.key then | 210 | if not self.config.key then |
211 | return nil, "Must have API key before performing any actions." | 211 | return nil, "Must have API key before performing any actions." |
212 | end | 212 | end |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 6161a061..ae96eb6a 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -34,7 +34,7 @@ local debug = require("debug") | |||
34 | -- which can be used to remove the item later from the list. | 34 | -- which can be used to remove the item later from the list. |
35 | function util.schedule_function(f, ...) | 35 | function util.schedule_function(f, ...) |
36 | assert(type(f) == "function") | 36 | assert(type(f) == "function") |
37 | 37 | ||
38 | local item = { fn = f, args = pack(...) } | 38 | local item = { fn = f, args = pack(...) } |
39 | table.insert(scheduled_functions, item) | 39 | table.insert(scheduled_functions, item) |
40 | return item | 40 | return item |
@@ -122,12 +122,12 @@ end | |||
122 | -- exists in vars. Only string values are processed; this function | 122 | -- exists in vars. Only string values are processed; this function |
123 | -- does not scan subtables recursively. | 123 | -- does not scan subtables recursively. |
124 | -- @param tbl table: Table to have its string values modified. | 124 | -- @param tbl table: Table to have its string values modified. |
125 | -- @param vars table: Table containing string-string key-value pairs | 125 | -- @param vars table: Table containing string-string key-value pairs |
126 | -- representing variables to replace in the strings values of tbl. | 126 | -- representing variables to replace in the strings values of tbl. |
127 | function util.variable_substitutions(tbl, vars) | 127 | function util.variable_substitutions(tbl, vars) |
128 | assert(type(tbl) == "table") | 128 | assert(type(tbl) == "table") |
129 | assert(type(vars) == "table") | 129 | assert(type(vars) == "table") |
130 | 130 | ||
131 | local updated = {} | 131 | local updated = {} |
132 | for k, v in pairs(tbl) do | 132 | for k, v in pairs(tbl) do |
133 | if type(v) == "string" then | 133 | if type(v) == "string" then |
@@ -450,7 +450,7 @@ do | |||
450 | function util.get_luajit_version() | 450 | function util.get_luajit_version() |
451 | local cfg = require("luarocks.core.cfg") | 451 | local cfg = require("luarocks.core.cfg") |
452 | if cfg.cache.luajit_version_checked then | 452 | if cfg.cache.luajit_version_checked then |
453 | return cfg.cache.luajit_version | 453 | return cfg.cache.luajit_version |
454 | end | 454 | end |
455 | cfg.cache.luajit_version_checked = true | 455 | cfg.cache.luajit_version_checked = true |
456 | 456 | ||
@@ -553,9 +553,9 @@ end | |||
553 | 553 | ||
554 | function util.opts_table(type_name, valid_opts) | 554 | function util.opts_table(type_name, valid_opts) |
555 | local opts_mt = {} | 555 | local opts_mt = {} |
556 | 556 | ||
557 | opts_mt.__index = opts_mt | 557 | opts_mt.__index = opts_mt |
558 | 558 | ||
559 | function opts_mt.type() | 559 | function opts_mt.type() |
560 | return type_name | 560 | return type_name |
561 | end | 561 | end |
@@ -590,7 +590,7 @@ end | |||
590 | -- "lua" for the Lua version and, for format 3.0+, "luajit" if detected). | 590 | -- "lua" for the Lua version and, for format 3.0+, "luajit" if detected). |
591 | function util.get_rocks_provided(rockspec) | 591 | function util.get_rocks_provided(rockspec) |
592 | local cfg = require("luarocks.core.cfg") | 592 | local cfg = require("luarocks.core.cfg") |
593 | 593 | ||
594 | if not rockspec and cfg.cache.rocks_provided then | 594 | if not rockspec and cfg.cache.rocks_provided then |
595 | return cfg.cache.rocks_provided | 595 | return cfg.cache.rocks_provided |
596 | end | 596 | end |