From 478fc5517c686c080797f840cc000cc9828ffcb4 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Thu, 20 Oct 2016 23:22:44 +0300 Subject: Remove some unused locals and imports --- src/luarocks/build.lua | 2 +- src/luarocks/command_line.lua | 1 - src/luarocks/deps.lua | 1 - src/luarocks/manif.lua | 3 +-- src/luarocks/path_cmd.lua | 3 --- src/luarocks/remove.lua | 1 - 6 files changed, 2 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index f52fb7a8..20d094b1 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -203,7 +203,7 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m end if not minimal_mode then - local _, source_dir + local source_dir if need_to_fetch then ok, source_dir, errcode = fetch.fetch_sources(rockspec, true) if not ok then diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 858e871f..ecf3a61b 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -2,7 +2,6 @@ --- Functions for command-line scripts. local command_line = {} -local pack = function(...) return {...}, select("#", ...) end local unpack = unpack or table.unpack local util = require("luarocks.util") diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index f8deff3c..756ba6bd 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua @@ -691,7 +691,6 @@ function deps.scan_deps(results, missing, manifest, name, version, deps_mode) local fetch = require("luarocks.fetch") - local err if results[name] then return results, missing end diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 1b75452b..2d983a85 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua @@ -55,7 +55,6 @@ end function manif.make_rock_manifest(name, version) local install_dir = path.install_dir(name, version) - local rock_manifest = path.rock_manifest_file(name, version) local tree = {} for _, file in ipairs(fs.find(install_dir)) do local full_path = dir.path(install_dir, file) @@ -80,7 +79,7 @@ function manif.make_rock_manifest(name, version) last[last_name] = sum end end - rock_manifest = { rock_manifest=tree } + local rock_manifest = { rock_manifest=tree } manif.rock_manifest_cache[name.."/"..version] = rock_manifest save_table(install_dir, "rock_manifest", rock_manifest ) end diff --git a/src/luarocks/path_cmd.lua b/src/luarocks/path_cmd.lua index 15fb9ca2..eba85d46 100644 --- a/src/luarocks/path_cmd.lua +++ b/src/luarocks/path_cmd.lua @@ -4,7 +4,6 @@ local path_cmd = {} local util = require("luarocks.util") -local deps = require("luarocks.deps") local cfg = require("luarocks.cfg") util.add_run_function(path_cmd) @@ -35,8 +34,6 @@ And on Windows: --- Driver function for "path" command. -- @return boolean This function always succeeds. function path_cmd.command(flags) - local deps_mode = deps.get_deps_mode(flags) - local lr_path, lr_cpath, lr_bin = cfg.package_paths(flags["tree"]) local path_sep = cfg.export_path_separator diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index 82c9818b..54756388 100644 --- a/src/luarocks/remove.lua +++ b/src/luarocks/remove.lua @@ -11,7 +11,6 @@ local repos = require("luarocks.repos") local path = require("luarocks.path") local util = require("luarocks.util") local cfg = require("luarocks.cfg") -local manif = require("luarocks.manif") local fs = require("luarocks.fs") util.add_run_function(remove) -- cgit v1.2.3-55-g6feb From cc76ce062f587b8a2ce6f34ca7ad57c585b82117 Mon Sep 17 00:00:00 2001 From: Hisham Date: Tue, 25 Oct 2016 16:43:18 -0200 Subject: Check rockspec_version before running type check. --- src/luarocks/fetch.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 824a3731..76f366cd 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -197,18 +197,18 @@ function fetch.load_local_rockspec(filename, quick) end local globals = err + if rockspec.rockspec_format then + if deps.compare_versions(rockspec.rockspec_format, type_check.rockspec_format) then + return nil, "Rockspec format "..rockspec.rockspec_format.." is not supported, please upgrade LuaRocks." + end + end + if not quick then local ok, err = type_check.type_check_rockspec(rockspec, globals) if not ok then return nil, filename..": "..err end end - - if rockspec.rockspec_format then - if deps.compare_versions(rockspec.rockspec_format, type_check.rockspec_format) then - return nil, "Rockspec format "..rockspec.rockspec_format.." is not supported, please upgrade LuaRocks." - end - end util.platform_overrides(rockspec.build) util.platform_overrides(rockspec.dependencies) -- cgit v1.2.3-55-g6feb From e5f6a46679192893782a58e17ccd3d371964ae6f Mon Sep 17 00:00:00 2001 From: Hisham Date: Tue, 25 Oct 2016 18:18:06 -0200 Subject: Add link_lua_explicitly option. Remove explicit reference to cygwin, and make option available for custom environments. --- src/luarocks/build/builtin.lua | 2 +- src/luarocks/cfg.lua | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 6719be81..c36aa96f 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -164,7 +164,7 @@ function builtin.run(rockspec) add_flags(extras, "-Wl,-rpath,%s:", libdirs) end add_flags(extras, "-l%s", libraries) - if cfg.is_platform("cygwin") then + if cfg.link_lua_explicitly then add_flags(extras, "-l%s", {"lua"}) end return execute(variables.LD.." "..variables.LIBFLAG, "-o", library, "-L"..variables.LUA_LIBDIR, unpack(extras)) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 33176161..9200dd26 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -315,6 +315,7 @@ local defaults = { arch = "unknown", lib_extension = "unknown", obj_extension = "unknown", + link_lua_explicitly = false, rocks_servers = { { @@ -527,6 +528,7 @@ if cfg.platforms.cygwin then defaults.variables.CC = "echo -llua | xargs gcc" defaults.variables.LD = "echo -llua | xargs gcc" defaults.variables.LIBFLAG = "-shared" + defaults.link_lua_explicitly = true end if cfg.platforms.msys then -- cgit v1.2.3-55-g6feb From a9c34fc0c92a5931eb73d867d18fbad410683ea0 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Wed, 26 Oct 2016 16:22:10 +0300 Subject: Treat rock name arguments in case insensitive way Internally package names are lowercased, however, rockspec may contain a name with uppercase letters, which will be displayed by `luarocks show`. Some commands, like `luarocks search`, `luarocks install` and `luarocks build`, support this and convert input name to lowercase before passing it to interanl functions. Do the same thing in other commands accepting rock names. --- src/luarocks/doc.lua | 2 ++ src/luarocks/download.lua | 2 +- src/luarocks/lint.lua | 2 +- src/luarocks/new_version.lua | 2 +- src/luarocks/pack.lua | 2 +- src/luarocks/remove.lua | 1 + src/luarocks/show.lua | 2 +- src/luarocks/unpack.lua | 2 +- 8 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/luarocks/doc.lua b/src/luarocks/doc.lua index 15460b31..423ebe02 100644 --- a/src/luarocks/doc.lua +++ b/src/luarocks/doc.lua @@ -63,6 +63,8 @@ function doc.command(flags, name, version) return nil, "Argument missing. "..util.see_help("doc") end + name = name:lower() + local iname, iversion, repo = search.pick_installed_rock(name, version, flags["tree"]) if not iname then util.printout(name..(version and " "..version or "").." is not installed. Looking for it in the rocks servers...") diff --git a/src/luarocks/download.lua b/src/luarocks/download.lua index 18573ae4..e434cdbb 100644 --- a/src/luarocks/download.lua +++ b/src/luarocks/download.lua @@ -102,7 +102,7 @@ function download.command(flags, name, version) arch = flags["arch"] end - local dl, err = download.download(arch, name, version, flags["all"]) + local dl, err = download.download(arch, name:lower(), version, flags["all"]) return dl and true, err end diff --git a/src/luarocks/lint.lua b/src/luarocks/lint.lua index d5cc48d0..0fd81a20 100644 --- a/src/luarocks/lint.lua +++ b/src/luarocks/lint.lua @@ -26,7 +26,7 @@ function lint.command(flags, input) local filename = input if not input:match(".rockspec$") then local err - filename, err = download.download("rockspec", input) + filename, err = download.download("rockspec", input:lower()) if not filename then return nil, err end diff --git a/src/luarocks/new_version.lua b/src/luarocks/new_version.lua index 8fc00a86..91f7607c 100644 --- a/src/luarocks/new_version.lua +++ b/src/luarocks/new_version.lua @@ -141,7 +141,7 @@ function new_version.command(flags, input, version, url) return nil, err end else - filename, err = download.download("rockspec", input) + filename, err = download.download("rockspec", input:lower()) if not filename then return nil, err end diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index 932ff0d5..35bbe838 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua @@ -184,7 +184,7 @@ function pack.command(flags, arg, version) if arg:match(".*%.rockspec") then file, err = pack.pack_source_rock(arg) else - file, err = do_pack_binary_rock(arg, version, flags["tree"]) + file, err = do_pack_binary_rock(arg:lower(), version, flags["tree"]) end if err then return nil, err diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index 54756388..601eedcf 100644 --- a/src/luarocks/remove.lua +++ b/src/luarocks/remove.lua @@ -155,6 +155,7 @@ function remove.command(flags, name, version) end local results = {} + name = name:lower() search.manifest_search(results, cfg.rocks_dir, search.make_query(name, version)) if not results[name] then return nil, "Could not find rock '"..name..(version and " "..version or "").."' in "..path.rocks_tree_to_string(cfg.root_dir) diff --git a/src/luarocks/show.lua b/src/luarocks/show.lua index 88f9512d..85c7edcb 100644 --- a/src/luarocks/show.lua +++ b/src/luarocks/show.lua @@ -78,7 +78,7 @@ function show.command(flags, name, version) end local repo, repo_url - name, version, repo, repo_url = search.pick_installed_rock(name, version, flags["tree"]) + name, version, repo, repo_url = search.pick_installed_rock(name:lower(), version, flags["tree"]) if not name then return nil, version end diff --git a/src/luarocks/unpack.lua b/src/luarocks/unpack.lua index c3dc9a4c..0922f9b9 100644 --- a/src/luarocks/unpack.lua +++ b/src/luarocks/unpack.lua @@ -159,7 +159,7 @@ function unpack.command(flags, name, version) return run_unpacker(name, flags["force"]) else local search = require("luarocks.search") - return search.act_on_src_or_rockspec(run_unpacker, name, version) + return search.act_on_src_or_rockspec(run_unpacker, name:lower(), version) end end -- cgit v1.2.3-55-g6feb From f7ae6213f430798ec86883f9ab9917b156e1758d Mon Sep 17 00:00:00 2001 From: Hisham Date: Wed, 26 Oct 2016 15:28:23 -0200 Subject: Support user-defined platforms array. Let the user set their own custom platform entries, but also provide fallbacks to make sure things work. --- src/luarocks/cfg.lua | 87 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 9200dd26..1141acf6 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -131,24 +131,27 @@ else -- Fall back to Unix in unknown systems. end --- Set order for platform overrides +-- Set order for platform overrides. +-- More general platform identifiers should be listed first, +-- more specific ones later. local platform_order = { -- Unixes - unix = 1, - bsd = 2, - solaris = 3, - netbsd = 4, - openbsd = 5, - freebsd = 6, - linux = 7, - macosx = 8, - cygwin = 9, - msys = 10, - haiku = 11, + "unix", + "bsd", + "solaris", + "netbsd", + "openbsd", + "freebsd", + "linux", + "macosx", + "cygwin", + "msys", + "haiku", -- Windows - win32 = 12, - mingw32 = 13, - windows = 14 } + "win32", + "mingw32", + "windows", +} -- Path configuration: local sys_config_file, home_config_file @@ -274,26 +277,50 @@ if not next(cfg.rocks_trees) then end end - -- update platforms list; keyed -> array do - local lst = {} -- use temp array to not confuse `pairs` in loop - for plat in pairs(cfg.platforms) do - if cfg.platforms[plat] then -- entries set to 'false' skipped - if not platform_order[plat] then - local pl = "" - for k,_ in pairs(platform_order) do pl = pl .. ", " .. k end - io.stderr:write("Bad platform given; "..tostring(plat)..". Valid entries are: "..pl:sub(3,-1) ..".\n") - os.exit(cfg.errorcodes.CONFIGFILE) + -- if explicitly given by user, + if cfg.platforms[1] then + local is_windows = cfg.platforms.windows + -- Clear auto-detected values + for k, _ in pairs(cfg.platforms) do + if type(k) == "string" then + cfg.platforms[k] = nil + end + end + -- and set the ones given by the user. + for _, plat in ipairs(cfg.platforms) do + cfg.platforms[plat] = true + end + -- If no major platform family was set by the user, + if not (cfg.platforms.unix or cfg.platforms.windows) then + -- set some fallback defaults in case the user provides an incomplete configuration. + -- LuaRocks expects a set of defaults to be available. + -- This is used for setting defaults here only; the platform overrides + -- will use only the user's list. + if is_windows then + cfg.platforms.windows = true + table.insert(cfg.platforms, "windows") + else + cfg.platforms.unix = true + table.insert(cfg.platforms, "unix") + end + end + else + -- Sort detected platform defaults + local order = {} + for i, v in ipairs(platform_order) do + order[v] = i + end + local entries = {} + for k, v in pairs(cfg.platforms) do + if type(k) == "string" and v == true then + table.insert(entries, k) end - table.insert(lst, plat) - else - cfg.platforms[plat] = nil end + table.sort(entries, function(a, b) return order[a] < order[b] end) + util.deep_merge(cfg.platforms, entries) end - -- platform overrides depent on the order, so set priorities - table.sort(lst, function(key1, key2) return platform_order[key1] < platform_order[key2] end) - util.deep_merge(cfg.platforms, lst) end -- Configure defaults: -- cgit v1.2.3-55-g6feb