From 8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 16 Mar 2021 13:36:26 -0300 Subject: editorconfig: trim trailing whitespace --- src/luarocks/admin/cache.lua | 6 ++--- src/luarocks/admin/cmd/add.lua | 14 +++++------ src/luarocks/admin/cmd/make_manifest.lua | 6 ++--- src/luarocks/admin/cmd/refresh_cache.lua | 2 +- src/luarocks/admin/cmd/remove.lua | 6 ++--- src/luarocks/admin/index.lua | 4 ++-- src/luarocks/build.lua | 16 ++++++------- src/luarocks/build/builtin.lua | 2 +- src/luarocks/build/cmake.lua | 4 ++-- src/luarocks/build/command.lua | 2 +- src/luarocks/build/make.lua | 14 +++++------ src/luarocks/cmd.lua | 22 +++++++++--------- src/luarocks/cmd/build.lua | 2 +- src/luarocks/cmd/config.lua | 14 +++++------ src/luarocks/cmd/doc.lua | 10 ++++---- src/luarocks/cmd/download.lua | 2 +- src/luarocks/cmd/init.lua | 10 ++++---- src/luarocks/cmd/install.lua | 12 +++++----- src/luarocks/cmd/lint.lua | 4 ++-- src/luarocks/cmd/list.lua | 8 +++---- src/luarocks/cmd/new_version.lua | 18 +++++++------- src/luarocks/cmd/path.lua | 8 +++---- src/luarocks/cmd/purge.lua | 2 +- src/luarocks/cmd/remove.lua | 4 ++-- src/luarocks/cmd/search.lua | 2 +- src/luarocks/cmd/show.lua | 4 ++-- src/luarocks/cmd/test.lua | 4 ++-- src/luarocks/cmd/unpack.lua | 8 +++---- src/luarocks/cmd/upload.lua | 12 +++++----- src/luarocks/cmd/write_rockspec.lua | 26 ++++++++++----------- src/luarocks/core/cfg.lua | 8 +++---- src/luarocks/core/dir.lua | 4 ++-- src/luarocks/core/manif.lua | 2 +- src/luarocks/core/persist.lua | 4 ++-- src/luarocks/core/sysdetect.lua | 26 ++++++++++----------- src/luarocks/core/util.lua | 16 ++++++------- src/luarocks/core/vers.lua | 8 +++---- src/luarocks/deplocks.lua | 8 +++---- src/luarocks/deps.lua | 40 ++++++++++++++++---------------- src/luarocks/fetch.lua | 10 ++++---- src/luarocks/fetch/git.lua | 2 +- src/luarocks/fs/lua.lua | 6 ++--- src/luarocks/fs/tools.lua | 4 ++-- src/luarocks/fs/unix.lua | 4 ++-- src/luarocks/fs/unix/tools.lua | 2 +- src/luarocks/fs/win32.lua | 2 +- src/luarocks/manif.lua | 4 ++-- src/luarocks/manif/writer.lua | 6 ++--- src/luarocks/pack.lua | 6 ++--- src/luarocks/path.lua | 18 +++++++------- src/luarocks/persist.lua | 2 +- src/luarocks/queries.lua | 22 +++++++++--------- src/luarocks/remove.lua | 10 ++++---- src/luarocks/repos.lua | 32 ++++++++++++------------- src/luarocks/results.lua | 4 ++-- src/luarocks/rockspecs.lua | 8 +++---- src/luarocks/search.lua | 22 +++++++++--------- src/luarocks/signing.lua | 2 +- src/luarocks/test.lua | 8 +++---- src/luarocks/test/command.lua | 4 ++-- src/luarocks/tools/patch.lua | 6 ++--- src/luarocks/tools/tar.lua | 4 ++-- src/luarocks/tools/zip.lua | 28 +++++++++++----------- src/luarocks/type/manifest.lua | 2 +- src/luarocks/type/rockspec.lua | 8 +++---- src/luarocks/type_check.lua | 14 +++++------ src/luarocks/upload/api.lua | 8 +++---- src/luarocks/util.lua | 14 +++++------ 68 files changed, 313 insertions(+), 313 deletions(-) (limited to 'src') 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) elseif upload_server.http then download_url = "http://"..upload_server.http elseif upload_server.ftp then download_url = "ftp://"..upload_server.ftp end - + if upload_server.ftp then login_url = "ftp://"..upload_server.ftp elseif upload_server.sftp then login_url = "sftp://"..upload_server.sftp end @@ -57,7 +57,7 @@ local function download_cache(protocol, server_path, user, password) return fs.execute(cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." -e ssh "..user.."@"..srv..":"..path.."/ ./") elseif protocol == "file" then return fs.copy_contents(server_path, ".") - else + else local login_info = "" if user then login_info = " --user="..user end if password then login_info = login_info .. " --password="..password end @@ -74,7 +74,7 @@ function cache.refresh_local_cache(url, given_user, given_password) end fs.change_dir(local_cache) - + util.printout("Refreshing cache "..local_cache.."...") 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 assert(type(rockfiles) == "table") assert(type(server) == "string") assert(type(upload_server) == "table" or not upload_server) - + local download_url, login_url = cache.get_server_urls(server, upload_server) local at = fs.current_dir() local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url - + local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) if not local_cache then return nil, protocol end - + if not login_url then login_url = protocol.."://"..server_path end - + local ok, err = fs.change_dir(at) if not ok then return nil, err end - + local files = {} for _, rockfile in ipairs(rockfiles) do if fs.exists(rockfile) then @@ -77,9 +77,9 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do util.printout("Updating manifest...") writer.make_manifest(local_cache, "one", true) - + zip_manifests() - + if fs.exists("index.html") then do_index = true 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 -- or nil and an error message. function make_manifest.command(args) local repo = args.repository or cfg.rocks_dir - + util.printout("Making manifest for "..repo) - + if repo:match("/lib/luarocks") and not args.local_tree then util.warning("This looks like a local rocks tree, but you did not pass --local-tree.") end - + local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args.local_tree) if ok and not args.local_tree then 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) local server, upload_server = cache.get_upload_server(args.server) if not server then return nil, upload_server end local download_url = cache.get_server_urls(server, upload_server) - + local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) if not ok then 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 local download_url, login_url = cache.get_server_urls(server, upload_server) local at = fs.current_dir() local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url - + local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) if not local_cache then return nil, protocol @@ -40,10 +40,10 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve if protocol ~= "rsync" then return nil, "This command requires 'rsync', check your configuration." end - + local ok, err = fs.change_dir(at) if not ok then return nil, err end - + local nr_files = 0 for _, rockfile in ipairs(rockfiles) do 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 = [[ manifest file ]] local index_manifest_ver = [[ -• Lua $VER manifest file (zip) +• Lua $VER manifest file (zip) ]] local index_footer_end = [[

@@ -129,7 +129,7 @@ function index.make_index(repo) end local manifest = manif.load_manifest(repo) local out = io.open(dir.path(repo, "index.html"), "w") - + out:write(index_header) for package, version_list in util.sortedpairs(manifest.repository) do 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) local name, version = rockspec.name, rockspec.version fs.copy(rockspec.local_abs_filename, path.rockspec_file(name, version), "read") - + local deplock_file = deplocks.get_abs_filename(rockspec.name) if deplock_file then fs.copy(deplock_file, dir.path(path.install_dir(name, version), "luarocks.lock"), "read") @@ -375,7 +375,7 @@ function build.build_rockspec(rockspec, opts) if opts.pin then deplocks.init(rockspec.name, ".") end - + ok, err = process_dependencies(rockspec, opts) if not ok then return nil, err end @@ -385,7 +385,7 @@ function build.build_rockspec(rockspec, opts) deplocks.write_file() end return name, version - end + end local dirs, err local rollback @@ -405,13 +405,13 @@ function build.build_rockspec(rockspec, opts) ok, err = build.apply_patches(rockspec) if not ok then return nil, err end - + ok, err = check_macosx_deployment_target(rockspec) if not ok then return nil, err end - + ok, err = run_build_driver(rockspec, opts.no_install) if not ok then return nil, err end - + if opts.no_install then fs.pop_dir() if opts.need_to_fetch then @@ -422,7 +422,7 @@ function build.build_rockspec(rockspec, opts) ok, err = install_files(rockspec, dirs) if not ok then return nil, err end - + for _, d in pairs(dirs) do fs.remove_dir_if_empty(d.name) end @@ -441,7 +441,7 @@ function build.build_rockspec(rockspec, opts) ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), opts.deps_mode) if not ok then return nil, err end - + util.remove_scheduled_function(rollback) rollback = util.schedule_function(function() 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) local lib_modules = {} local luadir = path.lua_dir(rockspec.name, rockspec.version) local libdir = path.lib_dir(rockspec.name, rockspec.version) - + if not build.modules then if rockspec:format_is_at_least("3.0") then 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) -- Execute cmake with variables. local args = "" - + -- Try to pick the best generator. With msvc and x64, CMake does not select it by default so we need to be explicit. if cfg.cmake_generator then args = args .. ' -G"'..cfg.cmake_generator.. '"' @@ -71,7 +71,7 @@ function cmake.run(rockspec, no_install) return nil, "Failed installing." end end - + return true end 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) assert(rockspec:type() == "rockspec") local build = rockspec.build - + util.variable_substitutions(build, rockspec.variables) 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") -- configured through variables.MAKE in the config files, or -- the appropriate platform-specific default). -- @param pass boolean: If true, run make; if false, do nothing. --- @param target string: The make target; an empty string indicates +-- @param target string: The make target; an empty string indicates -- the default target. -- @param variables table: A table containing string-string key-value -- pairs representing variable assignments to be passed to make. @@ -42,7 +42,7 @@ function make.run(rockspec, not_install) assert(rockspec:type() == "rockspec") local build = rockspec.build - + if build.build_pass == nil then build.build_pass = true end if build.install_pass == nil then build.install_pass = true end build.build_variables = build.build_variables or {} @@ -56,9 +56,9 @@ function make.run(rockspec, not_install) build.install_target = "-f "..makefile.." "..build.install_target end - if build.variables then + if build.variables then for var, val in pairs(build.variables) do - build.build_variables[var] = val + build.build_variables[var] = val build.install_variables[var] = val end end @@ -67,9 +67,9 @@ function make.run(rockspec, not_install) util.variable_substitutions(build.build_variables, rockspec.variables) util.variable_substitutions(build.install_variables, rockspec.variables) - + local auto_variables = { "CC" } - + for _, variable in pairs(auto_variables) do if not build.build_variables[variable] then build.build_variables[variable] = rockspec.variables[variable] @@ -79,7 +79,7 @@ function make.run(rockspec, not_install) end end - -- backwards compatibility + -- backwards compatibility local make_cmd = cfg.make or rockspec.variables.MAKE 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 end process_tree_args = function(args, project_dir) - + if args.global then cfg.local_by_default = false end @@ -221,7 +221,7 @@ do end return nil end - + local function find_default_lua_version(args, project_dir) if hardcoded.FORCE_CONFIG then return nil @@ -250,7 +250,7 @@ do end return nil end - + local function find_version_from_config(dirname) return fun.find(util.lua_versions("descending"), function(v) if util.exists(dir.path(dirname, ".luarocks", "config-"..v..".lua")) then @@ -258,12 +258,12 @@ do end end) end - + local function detect_lua_via_args(args, project_dir) local lua_version = args.lua_version or find_default_lua_version(args, project_dir) or (project_dir and find_version_from_config(project_dir)) - + if args.lua_dir then local detected, err = util.find_lua(args.lua_dir, lua_version) if not detected then @@ -274,7 +274,7 @@ do end return detected end - + if lua_version then local detected = search_lua_in_path(lua_version) if detected then @@ -284,10 +284,10 @@ do lua_version = lua_version, } end - + return {} end - + detect_config_via_args = function(args) local project_dir, given = find_project_dir(args.project_tree) local detected = detect_lua_via_args(args, project_dir) @@ -304,15 +304,15 @@ do return detected end end - + init_config = function(args) local detected = detect_config_via_args(args) - + local ok, err = cfg.init(detected, util.warning) if not ok then return nil, err end - + return (detected.lua_dir ~= nil) end 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) return name, version, errcode end) end - + local ok, err = fs.check_command_permissions(args) if not ok then 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. * `lua_dir` is a special key as it checks for a valid Lua installation (equivalent to --lua-dir) and sets several keys at once. * `lua_version` is a special key as it changes the default Lua version - used by LuaRocks commands (equivalent to passing --lua-version). + used by LuaRocks commands (equivalent to passing --lua-version). Examples: luarocks config variables.OPENSSL_DIR /usr/local/openssl @@ -114,7 +114,7 @@ local function traverse_varstring(var, tbl, fn, missing_parent) k, r = var:match("^([^[]+)(%[.*)$") end end - + if k then if not tbl[k] and missing_parent then missing_parent(tbl, k) @@ -131,7 +131,7 @@ local function traverse_varstring(var, tbl, fn, missing_parent) if i then var = tonumber(i) end - + return fn(tbl, var) end @@ -179,12 +179,12 @@ local function write_entries(keys, scope, do_unset) if scope == "project" and not cfg.config_files.project then return nil, "Current directory is not part of a project. You may want to run `luarocks init`." end - + local tbl, err = persist.load_config_file_if_basic(cfg.config_files[scope].file, cfg) if not tbl then return nil, err end - + for var, val in util.sortedpairs(keys) do traverse_varstring(var, tbl, function(t, k) if do_unset then @@ -242,7 +242,7 @@ end function config_cmd.command(args) deps.check_lua_incdir(cfg.variables, args.lua_version or cfg.lua_version) deps.check_lua_libdir(cfg.variables, args.lua_version or cfg.lua_version) - + -- deprecated flags if args.lua_incdir then print(cfg.variables.LUA_INCDIR) @@ -287,7 +287,7 @@ function config_cmd.command(args) end print("Lua version will default to " .. args.value .. " in " .. prefix) end - + if args.key == "lua_dir" and args.value then local scope = get_scope(args) 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) return try_to_open_homepage(args.rock, args.namespace, args.version) end local name, version = iname, iversion - + local rockspec, err = fetch.load_local_rockspec(path.rockspec_file(name, version, repo)) if not rockspec then return nil,err end local descript = rockspec.description or {} @@ -77,7 +77,7 @@ function doc.command(args) end local directory = path.install_dir(name, version, repo) - + local docdir local directories = { "doc", "docs" } for _, d in ipairs(directories) do @@ -101,7 +101,7 @@ function doc.command(args) local htmlpatt = "%.html?$" local extensions = { htmlpatt, "%.md$", "%.txt$", "%.textile$", "" } local basenames = { "index", "readme", "manual" } - + local porcelain = args.porcelain if #files > 0 then util.title("Documentation files for "..name.." "..version, porcelain) @@ -116,11 +116,11 @@ function doc.command(args) end end end - + if args.list then return true end - + for _, extension in ipairs(extensions) do for _, basename in ipairs(basenames) do 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) elseif args.arch then arch = args.arch end - + local dl, err = download.download(arch, args.name, args.namespace, args.version, args.all, args.check_lua_versions) return dl and true, err 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) fd:close() gitignore = "\n" .. gitignore .. "\n" end - + fd = io.open(".gitignore", gitignore and "a" or "w") for _, entry in ipairs(entries) do entry = "/" .. entry @@ -64,7 +64,7 @@ function init.command(args) if not ok then return nil, err end - + local has_rockspec = false for file in fs.dir() do if file:match("%.rockspec$") then @@ -97,7 +97,7 @@ function init.command(args) fs.delete(lua_wrapper) fs.delete(config_file) end - + local config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) if config_tbl then local globals = { @@ -131,7 +131,7 @@ function init.command(args) else util.printout("Will not attempt to overwrite " .. config_file) end - + ok, err = persist.save_default_lua_version(".luarocks", cfg.lua_version) if not ok then util.printout("Failed setting default Lua version: " .. err) @@ -158,7 +158,7 @@ function init.command(args) write_lua_wrapper = false end end - + if write_lua_wrapper then local interp = dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter) 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) if not name then return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." end - + if arch ~= "all" and arch ~= cfg.arch then return nil, "Incompatible architecture "..arch, "arch" end if repos.is_installed(name, version) then repos.delete_version(name, version, opts.deps_mode) end - + local install_dir = path.install_dir(name, version) - + local rollback = util.schedule_function(function() fs.delete(install_dir) fs.remove_dir_if_empty(path.versions_dir(name)) @@ -139,7 +139,7 @@ end -- @param rock_file string: local or remote filename of a rock. -- @param opts table: installation options -- @return (string, string) or (nil, string, [string]): Name and version of --- the rock whose dependencies were installed if succeeded or nil and an error message +-- the rock whose dependencies were installed if succeeded or nil and an error message -- followed by an error code. function install.install_binary_rock_deps(rock_file, opts) assert(type(rock_file) == "string") @@ -149,7 +149,7 @@ function install.install_binary_rock_deps(rock_file, opts) if not name then return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." end - + if arch ~= "all" and arch ~= cfg.arch then return nil, "Incompatible architecture "..arch, "arch" end @@ -158,7 +158,7 @@ function install.install_binary_rock_deps(rock_file, opts) local ok, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) if not ok then return nil, err, errcode end - + local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) if err then 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) end local ok = true - - -- This should have been done in the type checker, + + -- This should have been done in the type checker, -- but it would break compatibility of other commands. -- Making 'lint' alone be stricter shouldn't be a problem, -- 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) local query_available = queries.new(name:lower()) local results_available, err = search.search_repos(query_available) - + if results_available[name] then local available_versions = util.keys(results_available[name]) table.sort(available_versions, vers.compare_versions) local latest_available = available_versions[1] local latest_available_repo = results_available[name][latest_available][1].repo - + if vers.compare_versions(latest_available, latest_installed) then table.insert(outdated, { name = name, installed = latest_installed, available = latest_available, repo = latest_available_repo }) end @@ -76,11 +76,11 @@ function list.command(args) trees = { args.tree } title = title .. " in " .. args.tree end - + if args.outdated then return list_outdated(trees, query, args.porcelain) end - + local results = {} for _, tree in ipairs(trees) do 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) if new_field ~= old_field then util.printout("Guessing new '"..field.."' field as "..new_field) tbl[field] = new_field - return true + return true end return false end @@ -104,7 +104,7 @@ local function check_url_and_update_md5(out_rs, invalid_is_error) end end end - + local function update_source_section(out_rs, url, tag, old_ver, new_ver) if tag then out_rs.source.tag = tag @@ -144,7 +144,7 @@ local function update_source_section(out_rs, url, tag, old_ver, new_ver) end return true end - + function new_version.command(args) if not args.rock then local err @@ -153,7 +153,7 @@ function new_version.command(args) return nil, err end end - + local filename, err if args.rock:match("rockspec$") then filename, err = fetch.fetch_url(args.rock) @@ -178,7 +178,7 @@ function new_version.command(args) if args.tag and not args.new_version then args.new_version = args.tag:gsub("^v", "") end - + local out_dir if args.dir then out_dir = dir.normalize(args.dir) @@ -196,7 +196,7 @@ function new_version.command(args) new_rev = tonumber(old_rev) + 1 end local new_rockver = new_ver:gsub("-", "") - + local out_rs, err = persist.load_into_table(filename) local out_name = out_rs.package:lower() out_rs.version = new_rockver.."-"..new_rev @@ -207,21 +207,21 @@ function new_version.command(args) if out_rs.build and out_rs.build.type == "module" then out_rs.build.type = "builtin" end - + local out_filename = out_name.."-"..new_rockver.."-"..new_rev..".rockspec" if out_dir then out_filename = dir.path(out_dir, out_filename) fs.make_dir(out_dir) end persist.save_from_table(out_filename, out_rs, type_rockspec.order) - + util.printout("Wrote "..out_filename) local valid_out_rs, err = fetch.load_local_rockspec(out_filename) if not valid_out_rs then return nil, "Failed loading generated rockspec: "..err end - + return true end 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") function path_cmd.add_to_parser(parser) local cmd = parser:command("path", [[ Returns the package path currently configured for this installation -of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH. +of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH. -On Unix systems, you may run: +On Unix systems, you may run: eval `luarocks path` -And on Windows: +And on Windows: luarocks path > "%temp%\_lrp.bat" && call "%temp%\_lrp.bat" && del "%temp%\_lrp.bat"]], util.see_also()) :summary("Return the currently configured package path.") @@ -56,7 +56,7 @@ function path_cmd.command(args) lr_cpath = lr_cpath .. ";" .. package.cpath lr_bin = lr_bin .. path_sep .. clean_path end - + local lpath_var, lcpath_var = util.lua_path_variables() 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) if type(tree) ~= "string" then return nil, "The --tree argument is mandatory. "..util.see_help("purge") end - + local results = {} if not fs.is_dir(tree) then 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 function cmd_remove.command(args) local name = args.rock local deps_mode = deps.get_deps_mode(args) - + local ok, err = fs.check_command_permissions(args) if not ok then return nil, err, cmd.errorcodes.PERMISSIONDENIED end - + local rock_type = name:match("%.(rock)$") or name:match("%.(rockspec)$") local version = args.version 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) if not args.name and not args.all then return nil, "Enter name and version or use --all. "..util.see_help("search") end - + local query = queries.new(name, args.namespace, args.version, true) local result_tree, err = search.search_repos(query) 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) return table.concat(keys, sep or " ") end -local function word_wrap(line) +local function word_wrap(line) local width = tonumber(os.getenv("COLUMNS")) or 80 if width > 80 then width = 80 end if #line > width then @@ -265,7 +265,7 @@ end -- @return boolean: True if succeeded, nil on errors. function show.command(args) local query = queries.new(args.rock, args.namespace, args.version, true) - + local name, version, repo, repo_url = search.pick_installed_rock(query, args.tree) if not name then 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) if args.rockspec and args.rockspec:match("rockspec$") then return test.run_test_suite(args.rockspec, args.test_type, args.args) end - + table.insert(args.args, 1, args.rockspec) - + local rockspec, err = util.get_default_rockspec() if not rockspec then 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 -- files specified in the rockspec, and unpack them inside the directory. -- @param rockspec_file string: The URL for a rockspec file. -- @param dir_name string: The directory where to store and unpack files. --- @return table or (nil, string): the loaded rockspec table or +-- @return table or (nil, string): the loaded rockspec table or -- nil and an error message. local function unpack_rockspec(rockspec_file, dir_name) assert(type(rockspec_file) == "string") @@ -61,7 +61,7 @@ end -- @param dir_name string: The directory where to unpack. -- @param kind string: the kind of rock file, as in the second-level -- extension in the rock filename (eg. "src", "all", "linux-x86") --- @return table or (nil, string): the loaded rockspec table or +-- @return table or (nil, string): the loaded rockspec table or -- nil and an error message. local function unpack_rock(rock_file, dir_name, kind) assert(type(rock_file) == "string") @@ -102,7 +102,7 @@ end -- by an error message. local function run_unpacker(file, force) assert(type(file) == "string") - + local base_name = dir.base_name(file) local dir_name, kind, extension = base_name:match("(.*)%.([^.]+)%.(rock)$") if not extension then @@ -139,7 +139,7 @@ local function run_unpacker(file, force) return nil, "Failed copying unpacked rockspec into unpacked source directory." end end - util.printout() + util.printout() util.printout("Done. You may now enter directory ") util.printout(dir.path(dir_name, rockspec.source.dir)) 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) version = rockspec.version }) if not res then return nil, err end - + if not res.module then util.printout("Will create new module (" .. tostring(rockspec.package) .. ")") end @@ -87,7 +87,7 @@ function upload.command(args) util.printout("Signed packed rock: "..rock_sigfname) end end - + local multipart = require("luarocks.upload.multipart") res, err = api:method("upload", nil, { @@ -95,13 +95,13 @@ function upload.command(args) rockspec_sig = sigfname and multipart.new_file(sigfname), }) if not res then return nil, err end - + if res.is_new and #res.manifests == 0 then util.printerr("Warning: module not added to root manifest due to name taken.") end - + local module_url = res.module_url - + if rock_fname then if (not res.version) or (not res.version.id) then return nil, "Invalid response from server." @@ -113,7 +113,7 @@ function upload.command(args) }) if not res then return nil, err end end - + util.printout() util.printout("Done: " .. tostring(module_url)) 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 return url end end - + local function detect_scm_url(directory) return detect_url_from_command("git", "config --get remote.origin.url", directory) or detect_url_from_command("hg", "paths default", directory) @@ -230,7 +230,7 @@ local function fill_as_builtin(rockspec, libs) libdirs[#libdirs+1] = "$("..upper.."_LIBDIR)" end end - + rockspec.build.modules, rockspec.build.install, rockspec.build.copy_directories = builtin.autodetect_modules(libs, incdirs, libdirs) end @@ -302,10 +302,10 @@ function write_rockspec.command(args) version = version or "dev" local filename = args.output or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") - + local url = detect_url(location) local homepage = detect_homepage(url, args.homepage) - + local rockspec, err = rockspecs.from_persisted_table(filename, { rockspec_format = args.rockspec_format, package = name, @@ -327,11 +327,11 @@ function write_rockspec.command(args) }) assert(not err, err) rockspec.source.protocol = protocol - + if not next(rockspec.dependencies) then util.warning("Please specify supported Lua versions with --lua-versions=. "..util.see_help("write_rockspec")) end - + local local_dir = location if location:match("://") then @@ -354,11 +354,11 @@ function write_rockspec.command(args) local_dir = nil end end - + if not local_dir then local_dir = "." end - + local libs = nil if args.lib then libs = {} @@ -391,16 +391,16 @@ function write_rockspec.command(args) util.title("Please fill in the source.license field manually or use --license.") end end - + fill_as_builtin(rockspec, libs) - + rockspec_cleanup(rockspec) - + persist.save_from_table(filename, rockspec, type_rockspec.order) - util.printout() + util.printout() util.printout("Wrote template at "..filename.." -- you should now edit and finish it.") - util.printout() + util.printout() return true 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 = {} --- Initializes the LuaRocks configuration for variables, paths -- and OS detection. --- @param detected table containing information detected about the +-- @param detected table containing information detected about the -- environment. All fields below are optional: -- * lua_version (in x.y format, e.g. "5.3") -- * lua_bindir (e.g. "/usr/local/bin") @@ -575,7 +575,7 @@ function cfg.init(detected, warning) if not hc_ok then hardcoded = {} end - + local init = cfg.init ---------------------------------------- @@ -595,7 +595,7 @@ function cfg.init(detected, warning) end -- Use detected values as defaults, overridable via config files or CLI args - + local first_arg = get_first_arg() cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) @@ -778,7 +778,7 @@ function cfg.init(detected, warning) and home_config_file or sys_config_file), } - + cfg.cache = {} ---------------------------------------- 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 local function unquote(c) local first, last = c:sub(1,1), c:sub(-1) - if (first == '"' and last == '"') or + if (first == '"' and last == '"') or (first == "'" and last == "'") then return c:sub(2,-2) end @@ -40,7 +40,7 @@ end -- @return string, string: the protocol, and the pathname without the protocol. function dir.split_url(url) assert(type(url) == "string") - + url = unquote(url) local protocol, pathname = url:match("^([^:]*)://(.*)") 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) if pkgdeps then for _, dep in ipairs(pkgdeps) do local pkg, constraints = dep.name, dep.constraints - + for _, t in ipairs(tree_manifests) do local entries = t.manifest.repository[pkg] 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) } local save_mt = getmetatable(result) setmetatable(result, globals_mt) - + local ok, err, errcode = persist.run_file(filename, result) - + setmetatable(result, save_mt) 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 local function read_int8(fd) if io.type(fd) == "closed file" then return nil - end + end local s = fd:read(1) if not s then fd:close() @@ -44,7 +44,7 @@ end local function read(fd, bytes, endian) if io.type(fd) == "closed file" then return nil - end + end local s = fd:read(bytes) if not s then fd:close() @@ -138,7 +138,7 @@ end local function detect_elf_system(fd, hdr, sections) local system = e_osabi[hdr.osabi] local endian = hdr.endian - + if system == "sysv" then local abitag = sections[".note.ABI-tag"] if abitag then @@ -154,7 +154,7 @@ local function detect_elf_system(fd, hdr, sections) elseif sections[".note.openbsd.ident"] then return "openbsd" end - + local gnu_version_r = sections[".gnu.version_r"] if gnu_version_r then @@ -170,7 +170,7 @@ local function detect_elf_system(fd, hdr, sections) fd:seek("set", dynstr + vn_file) local libname = fd:read(64):gsub("%z.*", "") - + if hdr.e_type == 0x03 and libname == "libroot.so" then return "haiku" elseif libname:match("linux") then @@ -190,7 +190,7 @@ local function detect_elf_system(fd, hdr, sections) end end end - + return system end @@ -207,7 +207,7 @@ local function read_elf_header(fd) if not hdr.osabi then return nil end - + local endian = hdr.endian fd:seek("set", 0x10) hdr.e_type = read(fd, 2, endian) @@ -221,10 +221,10 @@ local function read_elf_header(fd) if elfversion ~= 1 then return nil end - + local word = (hdr.bits == 1) and 4 or 8 hdr.word = word - + hdr.e_entry = read(fd, word, endian) hdr.e_phoff = read(fd, word, endian) hdr.e_shoff = read(fd, word, endian) @@ -235,7 +235,7 @@ local function read_elf_header(fd) hdr.e_shentsize = read(fd, 2, endian) hdr.e_shnum = read(fd, 2, endian) hdr.e_shstrndx = read(fd, 2, endian) - + return hdr, processor end @@ -323,7 +323,7 @@ local function detect_pe(fd) fd:seek("set", peoffset + 4) -- move to position of Machine section local machine = read(fd, 2, LITTLE) local processor = pe_machine[machine] - + local rdata_pos = fd:read(736):match(".rdata%z%z............(....)") if rdata_pos then rdata_pos = bytes2number(rdata_pos, LITTLE) @@ -333,7 +333,7 @@ local function detect_pe(fd) system = "cygwin" end end - + return system, processor or "unknown" end @@ -363,7 +363,7 @@ local cache_processor function sysdetect.detect(input_file) local dirsep = package.config:sub(1,1) local files - + if input_file then files = { input_file } 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 -------------------------------------------------------------------------------- --- Run a process and read a its output. --- Equivalent to io.popen(cmd):read("*l"), except that it +-- Equivalent to io.popen(cmd):read("*l"), except that it -- closes the fd right away. -- @param cmd string: The command to execute -- @param spec string: "*l" by default, to read a single line. @@ -63,7 +63,7 @@ function util.show_table(t, tname, top_indent) local autoref -- for self references local function is_empty_table(tbl) return next(tbl) == nil end - + local function basic_serialize(o) local so = tostring(o) if type(o) == "function" then @@ -71,7 +71,7 @@ function util.show_table(t, tname, top_indent) -- info.name is nil because o is not a calling level if info.what == "C" then return ("%q"):format(so .. ", C function") - else + else -- the information is defined through lines return ("%q"):format(so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source) end @@ -81,14 +81,14 @@ function util.show_table(t, tname, top_indent) return ("%q"):format(so) end end - + local function add_to_cart(value, name, indent, saved, field) indent = indent or "" saved = saved or {} field = field or name - + cart = cart .. indent .. field - + if type(value) ~= "table" then cart = cart .. " = " .. basic_serialize(value) .. ";\n" else @@ -113,7 +113,7 @@ function util.show_table(t, tname, top_indent) end end end - + tname = tname or "__unnamed__" if type(t) ~= "table" then return tname .. " = " .. basic_serialize(t) @@ -189,7 +189,7 @@ function util.cleanup_path(list, sep, lua_version, keep_first) local part = parts[i]:gsub("//", "/") if lua_version then part = part:gsub("/lua/([%d.]+)/", function(part_version) - if part_version:sub(1, #lua_version) ~= lua_version then + if part_version:sub(1, #lua_version) ~= lua_version then return "/lua/"..lua_version.."/" end 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 = { return not (v2 < v1) end, --- Return version as a string. - -- @param v The version table. + -- @param v The version table. -- @return The string representation. __tostring = function(v) return v.string - end, + end, } local version_cache = {} @@ -102,7 +102,7 @@ function vers.parse_version(vstring) version[i] = version[i] and version[i] + number/100000 or number i = i + 1 end - + -- trim leading and trailing spaces local v = vstring:match("^%s*(.*)%s*$") version.string = v @@ -164,7 +164,7 @@ local function partial_match(version, requested) if type(version) ~= "table" then version = vers.parse_version(version) end if type(requested) ~= "table" then requested = vers.parse_version(requested) end if not version or not requested then return false end - + for i, ri in ipairs(requested) do local vi = version[i] or 0 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) -- could not open, maybe file does not exist return true, nil end - + deplock_abs_filename = fs.absolute_name(filename) deplock_root_rock_name = root_rock_name - + deptable = result return true, filename end @@ -58,7 +58,7 @@ function deplocks.add(depskey, name, version) if deptable_mode == "locked" then return end - + local dk = deptable[depskey] if not dk then dk = {} @@ -89,7 +89,7 @@ end -- a table-like interface to deplocks function deplocks.proxy(depskey) - return setmetatable({}, { + return setmetatable({}, { __index = function(_, k) return deplocks.get(depskey, k) 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 end versions, locations = manif.get_versions(dep, deps_mode) end - + if blacklist and blacklist[dep.name] then local orig_versions = versions versions = {} @@ -57,9 +57,9 @@ local function prepare_get_versions(deps_mode, rocks_provided, depskey, blacklis end end end - + local lockversion = deplocks.get(depskey, dep.name) - + return versions, locations, lockversion, provided ~= nil end end @@ -81,9 +81,9 @@ end local function match_dep(dep, get_versions) assert(type(dep) == "table") assert(type(get_versions) == "function") - + local versions, locations, lockversion, provided = get_versions(dep) - + local latest_version local latest_vstring for _, vstring in ipairs(versions) do @@ -95,7 +95,7 @@ local function match_dep(dep, get_versions) end end end - + if lockversion and not locations[lockversion] then local latest_matching_msg = "" if latest_vstring and latest_vstring ~= lockversion then @@ -104,7 +104,7 @@ local function match_dep(dep, get_versions) util.printout("Forcing " .. dep.name .. " to pinned version " .. lockversion .. latest_matching_msg) return nil, nil, queries.new(dep.name, dep.namespace, lockversion) end - + return latest_vstring, locations[latest_vstring], dep, provided end @@ -113,7 +113,7 @@ local function match_all_deps(dependencies, get_versions) assert(type(get_versions) == "function") local matched, missing, no_upgrade = {}, {}, {} - + for _, dep in ipairs(dependencies) do local found, _, provided found, _, dep, provided = match_dep(dep, get_versions) @@ -169,7 +169,7 @@ end -- @param version string: package version. -- @param dependencies table: array of dependencies. -- @param deps_mode string: Which trees to check dependencies for --- @param rocks_provided table: A table of auto-dependencies provided +-- @param rocks_provided table: A table of auto-dependencies provided -- by this Lua implementation for the given dependency. -- "one" for the current default tree, "all" for all trees, -- "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 assert(type(dependencies) == "table") assert(type(deps_mode) == "string") assert(type(rocks_provided) == "table") - + if deps_mode == "none" then return end @@ -270,7 +270,7 @@ local function check_supported_platforms(rockspec) return nil, "This rockspec for "..rockspec.package.." does not support "..plats.." platforms." end end - + return true end @@ -295,7 +295,7 @@ function deps.fulfill_dependencies(rockspec, depskey, deps_mode, verify, deplock local name = rockspec.name local version = rockspec.version local rocks_provided = rockspec.rocks_provided - + local ok, filename, err = deplocks.load(name, deplock_dir or ".") if filename then util.printout("Using dependencies pinned in lockfile: " .. filename) @@ -530,7 +530,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache) local err_files = {program = {}, header = {}, library = {}} local dirs = get_external_deps_dirs(mode) - + local prefixes if vars[name .. "_DIR"] then prefixes = { vars[name .. "_DIR"] } @@ -539,7 +539,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache) else prefixes = cfg.external_deps_dirs end - + for _, prefix in ipairs(prefixes) do prefix = resolve_prefix(prefix, dirs) if cfg.is_platform("mingw32") and name == "LUA" then @@ -556,7 +556,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache) return true end end - + return nil, err_dirname, err_testfile, err_files end @@ -575,7 +575,7 @@ end -- nil and an error message if any test failed. function deps.check_external_deps(rockspec, mode) assert(rockspec:type() == "rockspec") - + if not rockspec.external_dependencies then rockspec.external_dependencies = builtin.autodetect_external_dependencies(rockspec.build) end @@ -587,7 +587,7 @@ function deps.check_external_deps(rockspec, mode) local ok, err_dirname, err_testfile, err_files = check_external_dependency(name, ext_files, rockspec.variables, mode) if not ok then local lines = {"Could not find "..err_testfile.." file for "..name} - + local err_paths = {} for _, err_file in ipairs(err_files[err_testfile]) do if not err_paths[err_file] then @@ -595,10 +595,10 @@ function deps.check_external_deps(rockspec, mode) table.insert(lines, " No file "..err_file) end end - + 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.") table.insert(lines, "Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local") - + return nil, table.concat(lines, "\n"), "dependency" end end @@ -700,7 +700,7 @@ function deps.check_lua_incdir(vars) if vars.LUA_INCDIR then return lua_h_exists(vars.LUA_INCDIR, cfg.lua_version) end - + if vars.LUA_DIR then vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) 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) if not sig_file then return nil, "Could not fetch signature file for verification: " .. err, errcode end - + local ok, err = signing.verify_signature(filename, sig_file) if not ok then return nil, "Failed signature verification: " .. err @@ -269,7 +269,7 @@ function fetch.load_local_rockspec(rel_filename, quick) if not tbl then return nil, "Could not load rockspec file "..abs_filename.." ("..err..")" end - + local rockspec, err = rockspecs.from_persisted_table(abs_filename, tbl, err, quick) if not rockspec then return nil, abs_filename .. ": " .. err @@ -279,12 +279,12 @@ function fetch.load_local_rockspec(rel_filename, quick) if basename ~= "rockspec" and basename ~= name_version .. ".rockspec" then return nil, "Inconsistency between rockspec filename ("..basename..") and its contents ("..name_version..".rockspec)." end - + return rockspec end --- Load a local or remote rockspec into a table. --- This is the entry point for the LuaRocks tools. +-- This is the entry point for the LuaRocks tools. -- Only the LuaRocks runtime loader should use -- load_local_rockspec directly. -- @param filename string: Local or remote filename of a rockspec. @@ -425,7 +425,7 @@ function fetch.fetch_sources(rockspec, extract, dest_dir) return nil, "Unknown protocol "..protocol end end - + if cfg.only_sources_from and rockspec.source.pathname 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) return nil, 'Failed to fetch submodules.' end end - + if not rockspec.source.tag then rockspec.source.identifier = git_identifier(git_cmd, rockspec.version) 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) if ok then return true - else + else local msg = "'%s' program not found. Make sure %s is installed and is available in your PATH " .. "(or you may want to edit the 'variables.%s' value in file '%s')" return nil, msg:format(tool_cmd, tool_name, tool_name:upper(), cfg.config_files.nearest) @@ -535,7 +535,7 @@ end --- Internal implementation function for fs.dir. -- Yields a filename on each iteration. -- @param at string: directory to list --- @return nil or (nil and string): an error message on failure +-- @return nil or (nil and string): an error message on failure function fs_lua.dir_iterator(at) local pok, iter, arg = pcall(lfs.dir, at) if not pok then @@ -707,7 +707,7 @@ local redirect_protocols = { local function request(url, method, http, loop_control) -- luacheck: ignore 431 local result = {} - + if cfg.verbose then print(method, url) 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 = {} do local tool_cache = {} - + local tool_options = { downloader = { desc = "downloader", @@ -147,7 +147,7 @@ function tools.use_downloader(url, filename, cache) assert(type(filename) == "string" or not filename) filename = fs.absolute_name(filename or dir.base_name(url)) - + local downloader, err = fs.which_tool("downloader") if not downloader then 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, ...) assert(type(deps_mode) == "string") assert(type(name) == "string" or not name) assert(type(version) == "string" or not version) - + local wrapper = io.open(target, "w") if not wrapper then return nil, "Could not open "..target.." for writing." @@ -153,7 +153,7 @@ function unix.is_actual_binary(filename) return first ~= "#!" end -function unix.copy_binary(filename, dest) +function unix.copy_binary(filename, dest) return fs.copy(filename, dest, "exec") end 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 --- Copy a file. -- @param src string: Pathname of source -- @param dest string: Pathname of destination --- @param perm string ("read" or "exec") or nil: Permissions for destination +-- @param perm string ("read" or "exec") or nil: Permissions for destination -- file or nil to use the source permissions -- @return boolean or (boolean, string): true on success, false on failure, -- 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) return false end -function win32.copy_binary(filename, dest) +function win32.copy_binary(filename, dest) local ok, err = fs.copy(filename, dest) if not ok then 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) break end end - if not pathname then + if not pathname then return nil, err, errcode end end @@ -236,7 +236,7 @@ end function manif.get_versions(dep, deps_mode) assert(type(dep) == "table") assert(type(deps_mode) == "string") - + local name = dep.name local namespace = dep.namespace 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 local function update_dependencies(manifest, deps_mode) assert(type(manifest) == "table") assert(type(deps_mode) == "string") - + for pkg, versions in pairs(manifest.repository) do for version, repositories in pairs(versions) do for _, repo in ipairs(repositories) do @@ -160,7 +160,7 @@ local function filter_by_lua_version(manifest, lua_version, repodir, cache) assert(type(manifest) == "table") assert(type(repodir) == "string") assert((not cache) or type(cache) == "table") - + cache = cache or {} lua_version = vers.parse_version(lua_version) for pkg, versions in pairs(manifest.repository) do @@ -176,7 +176,7 @@ local function filter_by_lua_version(manifest, lua_version, repodir, cache) if rockspec then cache[pathname] = rockspec for _, dep in ipairs(rockspec.dependencies) do - if dep.name == "lua" then + if dep.name == "lua" then if not vers.match_constraints(lua_version, dep.constraints) then table.insert(to_remove, version) 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) if not fs.exists(prefix) then return nil, "'"..name.." "..version.."' does not seem to be an installed rock." end - + local rock_manifest, err = manif.load_rock_manifest(name, version, root) if not rock_manifest then return nil, err end local name_version = name .. "-" .. version local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") - + local temp_dir = fs.make_temp_dir("pack") fs.copy_contents(prefix, temp_dir) @@ -111,7 +111,7 @@ function pack.pack_installed_rock(query, tree) local ok, err = copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read") if not ok then return nil, "Failed copying back files: " .. err end end - + local ok, err = fs.change_dir(temp_dir) if not ok then return nil, err end 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) end --- Get the directory for all versions of a package in a tree. --- @param name string: The package name. +-- @param name string: The package name. -- @return string: The resulting path -- does not guarantee that -- @param tree string or nil: If given, specifies the local tree to use. -- the package (and by extension, the path) exists. @@ -59,7 +59,7 @@ function path.versions_dir(name, tree) end --- Get the local installation directory (prefix) for a package. --- @param name string: The package name. +-- @param name string: The package name. -- @param version string: The package version. -- @param tree string or nil: If given, specifies the local tree to use. -- @return string: The resulting path -- does not guarantee that @@ -71,7 +71,7 @@ function path.install_dir(name, version, tree) end --- Get the local filename of the rockspec of an installed rock. --- @param name string: The package name. +-- @param name string: The package name. -- @param version string: The package version. -- @param tree string or nil: If given, specifies the local tree to use. -- @return string: The resulting path -- does not guarantee that @@ -83,7 +83,7 @@ function path.rockspec_file(name, version, tree) end --- Get the local filename of the rock_manifest file of an installed rock. --- @param name string: The package name. +-- @param name string: The package name. -- @param version string: The package version. -- @param tree string or nil: If given, specifies the local tree to use. -- @return string: The resulting path -- does not guarantee that @@ -107,7 +107,7 @@ function path.rock_namespace_file(name, version, tree) end --- Get the local installation directory for C libraries of a package. --- @param name string: The package name. +-- @param name string: The package name. -- @param version string: The package version. -- @param tree string or nil: If given, specifies the local tree to use. -- @return string: The resulting path -- does not guarantee that @@ -119,7 +119,7 @@ function path.lib_dir(name, version, tree) end --- Get the local installation directory for Lua modules of a package. --- @param name string: The package name. +-- @param name string: The package name. -- @param version string: The package version. -- @param tree string or nil: If given, specifies the local tree to use. -- @return string: The resulting path -- does not guarantee that @@ -131,7 +131,7 @@ function path.lua_dir(name, version, tree) end --- Get the local installation directory for documentation of a package. --- @param name string: The package name. +-- @param name string: The package name. -- @param version string: The package version. -- @param tree string or nil: If given, specifies the local tree to use. -- @return string: The resulting path -- does not guarantee that @@ -143,7 +143,7 @@ function path.doc_dir(name, version, tree) end --- Get the local installation directory for configuration files of a package. --- @param name string: The package name. +-- @param name string: The package name. -- @param version string: The package version. -- @param tree string or nil: If given, specifies the local tree to use. -- @return string: The resulting path -- does not guarantee that @@ -156,7 +156,7 @@ end --- Get the local installation directory for command-line scripts -- of a package. --- @param name string: The package name. +-- @param name string: The package name. -- @param version string: The package version. -- @param tree string or nil: If given, specifies the local tree to use. -- @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) persist.write_value(out, k, level) out:write("]") end - + out:write(" = ") end 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) assert(type(substring) == "boolean" or not substring) assert(type(arch) == "string" or not arch) assert(type(operator) == "string" or not operator) - + operator = operator or "==" local self = { @@ -99,7 +99,7 @@ do ["="] = "==", ["!="] = "~=" } - + --- Consumes a constraint from a string, converting it to table format. -- For example, a string ">= 1.0, > 2.0" is converted to a table in the -- format {op = ">=", version={1,0}} and the rest, "> 2.0", is returned @@ -110,20 +110,20 @@ do -- input string is invalid. parse_constraint = function(input) assert(type(input) == "string") - + local no_upgrade, op, version, rest = input:match("^(@?)([<>=~!]*)%s*([%w%.%_%-]+)[%s,]*(.*)") local _op = operators[op] version = vers.parse_version(version) if not _op then return nil, "Encountered bad constraint operator: '"..tostring(op).."' in '"..input.."'" end - if not version then + if not version then return nil, "Could not parse version from constraint: '"..input.."'" end return { op = _op, version = version, no_upgrade = no_upgrade=="@" and true or nil }, rest end end - + --- Convert a list of constraints from string to table format. -- For example, a string ">= 1.0, < 2.0" is converted to a table in the format -- {{op = ">=", version={1,0}}, {op = "<", version={2,0}}}. @@ -134,7 +134,7 @@ do -- or nil if the input string is invalid. parse_constraints = function(input) assert(type(input) == "string") - + local constraints, oinput, constraint = {}, input while #input > 0 do constraint, input = parse_constraint(input) @@ -147,26 +147,26 @@ do return constraints end end - + --- Prepare a query in dependency table format. -- @param depstr string: A dependency in string format -- as entered in rockspec files. -- @return table: A query in table format, or nil and an error message in case of errors. function queries.from_dep_string(depstr) assert(type(depstr) == "string") - + local ns_name, rest = depstr:match("^%s*([a-zA-Z0-9%.%-%_]*/?[a-zA-Z0-9][a-zA-Z0-9%.%-%_]*)%s*([^/]*)") if not ns_name then return nil, "failed to extract dependency name from '"..depstr.."'" end - + local constraints, err = parse_constraints(rest) if not constraints then return nil, err end - + local name, namespace = util.split_namespace(ns_name) - + local self = { name = name, 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 -- "one" for the current default tree, "all" for all trees, -- "order" for all trees with priority >= the current default, "none" for no trees. -- @return boolean or (nil, string): true on success or nil and an error message. -local function delete_versions(name, versions, deps_mode) +local function delete_versions(name, versions, deps_mode) for version, _ in pairs(versions) do util.printout("Removing "..name.." "..version.."...") local ok, err = repos.delete_version(name, version, deps_mode) if not ok then return nil, err end end - + return true end @@ -63,7 +63,7 @@ function remove.remove_search_results(results, name, deps_mode, force, fast) local version = next(versions) local second = next(versions, version) - + local dependents = {} if not fast then 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) util.printout() dependents = check_dependents(name, versions, deps_mode) end - + if #dependents > 0 then if force or fast then 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) return nil, "Failed removing." end end - + local ok, err = delete_versions(name, versions, deps_mode) if not ok then return nil, err end 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 -- versions of a package, or nil if none is available. local function get_installed_versions(name) assert(type(name) == "string" and not name:match("/")) - + local dirs = fs.list_dir(path.versions_dir(name)) return (dirs and #dirs > 0) and dirs or nil end @@ -61,7 +61,7 @@ end function repos.is_installed(name, version) assert(type(name) == "string" and not name:match("/")) assert(type(version) == "string") - + return fs.is_dir(path.install_dir(name, version)) end @@ -172,11 +172,11 @@ function repos.run_hook(rockspec, hook_name) if not hooks then return true end - + if cfg.hooks_enabled == false then return nil, "This rockspec contains hooks, which are blocked by the 'hooks_enabled' setting in your LuaRocks configuration." end - + if not hooks.substituted_variables then util.variable_substitutions(hooks, rockspec.variables) hooks.substituted_variables = true @@ -269,7 +269,7 @@ local function backup_existing(should_backup, target) repeat backup = backup.."~" until not fs.exists(backup) -- Slight race condition here, but shouldn't be a problem. - + util.warning(target.." is not tracked by this installation of LuaRocks. Moving it to "..backup) local move_ok, move_err = os.rename(target, backup) if not move_ok then @@ -300,7 +300,7 @@ local function prepare_op_install() if not ok then return nil, err end - + local backup, err = backup_existing(op.backup, op.realdst or op.dst) if err then return nil, err @@ -308,22 +308,22 @@ local function prepare_op_install() if backup then op.backup_file = backup end - + ok, err = op.fn(op.src, op.dst, op.backup) if not ok then return nil, err end - + rmdirs[dir.dir_name(op.src)] = true return true end - + local function done_op_install() for d, _ in pairs(rmdirs) do fs.remove_dir_tree_if_empty(d) end end - + return op_install, done_op_install end @@ -361,7 +361,7 @@ end local function prepare_op_delete() local deletes = {} local rmdirs = {} - + local function done_op_delete() for _, f in ipairs(deletes) do os.remove(f) @@ -377,12 +377,12 @@ local function prepare_op_delete() local suffix = check_suffix(op.name, op.suffix) op.name = op.name .. suffix end - + table.insert(deletes, op.name) - + rmdirs[dir.dir_name(op.name)] = true end - + return op_delete, done_op_delete end @@ -406,7 +406,7 @@ function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode) local rock_manifest, load_err = manif.load_rock_manifest(name, version) if not rock_manifest then return nil, load_err end - + local repo = cfg.root_dir local renames = {} local installs = {} @@ -592,7 +592,7 @@ function repos.delete_version(name, version, deps_mode, quick) op_delete(op) end done_op_delete() - + if not quick then for _, op in ipairs(renames) do 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) assert(type(repo) == "string") assert(type(arch) == "string" or not arch) assert(type(namespace) == "string" or not namespace) - + if not namespace then name, namespace = util.split_namespace(name) end - + local self = { name = name, 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 @@ local rockspecs = {} - + local cfg = require("luarocks.core.cfg") local dir = require("luarocks.dir") local path = require("luarocks.path") @@ -31,9 +31,9 @@ end -- if it doesn't (or if nil is passed), this function does nothing. local function platform_overrides(tbl) assert(type(tbl) == "table" or not tbl) - + if not tbl then return end - + if tbl.platforms then for platform in cfg.each_platform() do local platform_tbl = tbl.platforms[platform] @@ -158,4 +158,4 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick) return setmetatable(rockspec, rockspec_mt) end -return rockspecs \ No newline at end of file +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) assert(type(repo) == "string") assert(query:type() == "query") assert(type(result_tree) == "table" or not result_tree) - + local fs = require("luarocks.fs") - + if not result_tree then result_tree = {} end - + for name in fs.dir(repo) do local pathname = dir.path(repo, name) local rname, rversion, rarch = path.parse_name(name) @@ -231,13 +231,13 @@ function search.find_suitable_rock(query) assert(query:type() == "query") local rocks_provided = util.get_rocks_provided() - + if rocks_provided[query.name] ~= nil then -- Do not install versions listed in rocks_provided. return nil, "Rock "..query.name.." "..rocks_provided[query.name].. " is already provided by VM or via 'rocks_provided' in the config file.", "provided" end - + local result_tree = search.search_repos(query) local first_rock = next(result_tree) if not first_rock then @@ -270,19 +270,19 @@ function search.find_rock_checking_lua_versions(query, check_lua_versions) if check_lua_versions then util.printout(query.name .. " not found for Lua " .. cfg.lua_version .. ".") util.printout("Checking if available for other Lua versions...") - + -- Check if constraints are satisfiable with other Lua versions. local lua_versions = supported_lua_versions(query) - + if #lua_versions ~= 0 then -- Build a nice message in "only Lua 5.x and 5.y but not 5.z." format for i, lua_version in ipairs(lua_versions) do lua_versions[i] = "Lua "..lua_version end - + local versions_message = "only "..table.concat(lua_versions, " and ").. " but not Lua "..cfg.lua_version.."." - + if #query.constraints == 0 then add = query.name.." supports "..versions_message elseif #query.constraints == 1 and query.constraints[1].op == "==" then @@ -308,7 +308,7 @@ end function search.print_result_tree(result_tree, porcelain) assert(type(result_tree) == "table") assert(type(porcelain) == "boolean" or not porcelain) - + if porcelain then for package, versions in util.sortedpairs(result_tree) do for version, repos in util.sortedpairs(versions, vers.compare_versions) do @@ -320,7 +320,7 @@ function search.print_result_tree(result_tree, porcelain) end return end - + for package, versions in util.sortedpairs(result_tree) do local namespaces = {} 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) if not gpg then return nil, err end - + local sigfile = file .. ".asc" if fs.execute(gpg, "--armor", "--output", sigfile, "--detach-sign", file) then 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) if rockspec.test and rockspec.test.type then return rockspec.test.type end - + for _, test_module in ipairs(test_modules) do if test_module.detect_type() then return test_modules[test_module] end end - + return nil, "could not detect test type -- no test suite for " .. rockspec.package .. "?" end @@ -45,7 +45,7 @@ function test.run_test_suite(rockspec_arg, test_type, args) assert(type(rockspec_arg) == "table") rockspec = rockspec_arg end - + if not test_type then local err test_type, err = get_test_type(rockspec, test_type) @@ -67,7 +67,7 @@ function test.run_test_suite(rockspec_arg, test_type, args) if not pok then return nil, "failed loading test execution module " .. mod_name end - + return test_mod.run_tests(rockspec.test, args) end 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) script = "test.lua" } end - + if not test.script and not test.command then test.script = "test.lua" end @@ -31,7 +31,7 @@ function command.run_tests(test, args) table.insert(args, i, test.flags[i]) end end - + local ok 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) pos_beg = pos + 1 if #line > 0 then return line - end + end end end @@ -526,7 +526,7 @@ local function patch_hunks(srcname, tgtname, hunks) tgt:close() src:close() return true -end +end local function strip_dirs(filename, strip) if strip == nil then return filename end @@ -616,7 +616,7 @@ local function patch_file(source, target, epoch, hunks, strip, create_delete) end end hunklineno = 1 - + -- todo \ No newline at end of file end -- 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) local number = 0 octal = octal:gsub("%s", "") for i = #octal,1,-1 do - local digit = tonumber(octal:sub(i,i)) + local digit = tonumber(octal:sub(i,i)) if not digit then break end @@ -93,7 +93,7 @@ function tar.untar(filename, destdir) local tar_handle = io.open(filename, "rb") if not tar_handle then return nil, "Error opening file "..filename end - + local long_name, long_link_name local ok, err 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 -- @return true if succeeded, nil in case of failure. local function zipwriter_close_file_in_zip(self) local zh = self.ziphandle - + if not self.in_open_file then return nil end @@ -152,16 +152,16 @@ local function zipwriter_close_file_in_zip(self) -- File data zh:write(self.data) - + -- Data descriptor zh:write(DATA_DESCRIPTOR_SIGNATURE) zh:write(number_to_lestring(lfh.crc32, 4)) zh:write(number_to_lestring(lfh.compressed_size, 4)) zh:write(number_to_lestring(lfh.uncompressed_size, 4)) - + table.insert(self.files, lfh) self.in_open_file = false - + return true end @@ -208,9 +208,9 @@ end -- @return true if succeeded, nil in case of failure. local function zipwriter_close(self) local zh = self.ziphandle - + local central_directory_offset = zh:seek() - + local size_of_central_directory = 0 -- Central directory structure for _, lfh in ipairs(self.files) do @@ -234,7 +234,7 @@ local function zipwriter_close(self) zh:write(lfh.file_name) size_of_central_directory = size_of_central_directory + 46 + lfh.file_name_length end - + -- End of central directory record zh:write(END_OF_CENTRAL_DIR_SIGNATURE) -- signature zh:write(number_to_lestring(0, 2)) -- number of this disk @@ -253,16 +253,16 @@ end -- @param name filename of the zipfile to be created. -- @return a zip handle, or nil in case of error. function zip.new_zipwriter(name) - + local zw = {} - + zw.ziphandle = io.open(fs.absolute_name(name), "wb") if not zw.ziphandle then return nil end zw.files = {} zw.in_open_file = false - + zw.add = zipwriter_add zw.close = zipwriter_close zw.open_new_file_in_zip = zipwriter_open_new_file_in_zip @@ -381,7 +381,7 @@ local function process_end_of_central_dir(zh) return nil, "Could not find End of Central Directory signature" end end - + -- number of this disk (2 bytes) -- number of the disk with the start of the central directory (2 bytes) -- total number of entries in the central directory on this disk (2 bytes) @@ -450,7 +450,7 @@ function zip.unzip(zipfile) if not cd_entries then return nil, cd_offset end - + local ok, err = zh:seek("set", cd_offset) if not ok then return nil, err @@ -513,7 +513,7 @@ end function zip.gzip(input_filename, output_filename) assert(type(input_filename) == "string") assert(output_filename == nil or type(output_filename) == "string") - + if not output_filename then output_filename = input_filename .. ".gz" end @@ -525,7 +525,7 @@ end function zip.gunzip(input_filename, output_filename) assert(type(input_filename) == "string") assert(output_filename == nil or type(output_filename) == "string") - + if not output_filename then output_filename = input_filename:gsub("%.gz$", "") 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({ }) --- Type check a manifest table. --- Verify the correctness of elements from a +-- Verify the correctness of elements from a -- manifest table, reporting on unknown fields and type -- mismatches. -- @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({ post_install = { _type = "string" }, }, }, - + ["1.1"] = { deploy = { wrap_bin_scripts = { _type = "boolean" }, } }, - + ["3.0"] = { description = { labels = { @@ -135,7 +135,7 @@ local rockspec_formats, versions = type_check.declare_schemas({ } }) -type_rockspec.order = {"rockspec_format", "package", "version", +type_rockspec.order = {"rockspec_format", "package", "version", { "source", { "url", "tag", "branch", "md5" } }, { "description", {"summary", "detailed", "homepage", "license" } }, "supported_platforms", "dependencies", "build_dependencies", "external_dependencies", @@ -160,7 +160,7 @@ local function check_rockspec_using_version(rockspec, globals, version) end --- Type check a rockspec table. --- Verify the correctness of elements from a +-- Verify the correctness of elements from a -- rockspec table, reporting on unknown fields and type -- mismatches. -- @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 end end end - + local function expand_magic_platforms(tbl) for k,v in pairs(tbl) do if v == type_check.MAGIC_PLATFORMS then @@ -35,7 +35,7 @@ do end end end - + -- Build a table of schemas. -- @param versions a table where each key is a version number as a string, -- and the value is a schema specification. Schema versions are considered @@ -44,7 +44,7 @@ do function type_check.declare_schemas(inputs) local schemas = {} local parent_version - + local versions = fun.reverse_in(fun.sort_in(util.keys(inputs), vers.compare_versions)) for _, version in ipairs(versions) do @@ -99,10 +99,10 @@ local function type_check_item(version, item, typetbl, context) return nil, err end end - + local item_type = type(item) or "nil" local expected_type = typetbl._type or "table" - + if expected_type == "number" then if not tonumber(item) then return nil, "Type mismatch on field "..context..": expected a number" @@ -148,7 +148,7 @@ end -- in tbl that is correctly typed, type(tbl.x) == type(types.x)). -- If the reference table contains a field called MORE, then -- unknown fields in the checked table are accepted. --- If it contains a field called ANY, then its type will be +-- If it contains a field called ANY, then its type will be -- used to check any unknown fields. If a field is prefixed -- with MUST_, it is mandatory; its absence from the table is -- a type error. @@ -174,7 +174,7 @@ function type_check.type_check_table(version, tbl, typetbl, context) for k, v in pairs(tbl) do local t = typetbl[k] or typetbl._any - if t then + if t then local ok, err = type_check_item(version, v, t, mkfield(context, k)) if not ok then return nil, err end 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) local vars = cfg.variables local json_ok, json = util.require_json() if not json_ok then return nil, "A JSON library is required for this command. "..json end - + if fs.which_tool("downloader") == "wget" then local curl_ok, err = fs.is_tool_available(vars.CURL, "curl") if not curl_ok then @@ -135,7 +135,7 @@ function Api:request(url, params, post_params) url = url .. ("?" .. encode_query_string(params)) end local method = "GET" - local out + local out local tmpfile = fs.tmpname() if post_params then method = "POST" @@ -148,7 +148,7 @@ function Api:request(url, params, post_params) curl_cmd = curl_cmd .. "--form \""..k.."="..var.."\" " end if cfg.connection_timeout and cfg.connection_timeout > 0 then - curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " + curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " end local ok = fs.execute_string(curl_cmd..fs.Q(url).." -o "..fs.Q(tmpfile)) if not ok then @@ -206,7 +206,7 @@ function Api:request(url, params, post_params) if not http_ok then return nil, "Failed loading socket library!" end - + if not self.config.key then return nil, "Must have API key before performing any actions." 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") -- which can be used to remove the item later from the list. function util.schedule_function(f, ...) assert(type(f) == "function") - + local item = { fn = f, args = pack(...) } table.insert(scheduled_functions, item) return item @@ -122,12 +122,12 @@ end -- exists in vars. Only string values are processed; this function -- does not scan subtables recursively. -- @param tbl table: Table to have its string values modified. --- @param vars table: Table containing string-string key-value pairs +-- @param vars table: Table containing string-string key-value pairs -- representing variables to replace in the strings values of tbl. function util.variable_substitutions(tbl, vars) assert(type(tbl) == "table") assert(type(vars) == "table") - + local updated = {} for k, v in pairs(tbl) do if type(v) == "string" then @@ -450,7 +450,7 @@ do function util.get_luajit_version() local cfg = require("luarocks.core.cfg") if cfg.cache.luajit_version_checked then - return cfg.cache.luajit_version + return cfg.cache.luajit_version end cfg.cache.luajit_version_checked = true @@ -553,9 +553,9 @@ end function util.opts_table(type_name, valid_opts) local opts_mt = {} - + opts_mt.__index = opts_mt - + function opts_mt.type() return type_name end @@ -590,7 +590,7 @@ end -- "lua" for the Lua version and, for format 3.0+, "luajit" if detected). function util.get_rocks_provided(rockspec) local cfg = require("luarocks.core.cfg") - + if not rockspec and cfg.cache.rocks_provided then return cfg.cache.rocks_provided end -- cgit v1.2.3-55-g6feb