From ec31f30bcc8dfd48c1248f3897fd051bfd12474a Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 25 Jun 2015 15:22:37 +0200 Subject: `detected` was only retained in `cfg` through multiple copies, removed by directly operating on `cfg.platform` --- src/luarocks/cfg.lua | 92 +++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 8321e9b9..ff18e0a3 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -35,6 +35,9 @@ end cfg.program_version = "scm" cfg.program_series = "2.2" cfg.major_version = (cfg.program_version:match("([^.]%.[^.])")) or cfg.program_series +cfg.variables = {} +cfg.rocks_trees = {} +cfg.platform = {} local persist = require("luarocks.persist") @@ -68,57 +71,55 @@ end -- System detection: -local detected = {} -local system,proc - -- A proper installation of LuaRocks will hardcode the system -- and proc values with site_config.LUAROCKS_UNAME_S and site_config.LUAROCKS_UNAME_M, -- so that this detection does not run every time. When it is -- performed, we use the Unix way to identify the system, -- even on Windows (assuming UnxUtils or Cygwin). -system = site_config.LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") -proc = site_config.LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") +local system = site_config.LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") +local proc = site_config.LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") if proc:match("i[%d]86") then - proc = "x86" + cfg.target_cpu = "x86" elseif proc:match("amd64") or proc:match("x86_64") then - proc = "x86_64" + cfg.target_cpu = "x86_64" elseif proc:match("Power Macintosh") then - proc = "powerpc" + cfg.target_cpu = "powerpc" + else + cfg.target_cpu = proc end -cfg.target_cpu = proc if system == "FreeBSD" then - detected.unix = true - detected.freebsd = true - detected.bsd = true + cfg.platform.unix = true + cfg.platform.freebsd = true + cfg.platform.bsd = true elseif system == "OpenBSD" then - detected.unix = true - detected.openbsd = true - detected.bsd = true + cfg.platform.unix = true + cfg.platform.openbsd = true + cfg.platform.bsd = true elseif system == "NetBSD" then - detected.unix = true - detected.netbsd = true - detected.bsd = true + cfg.platform.unix = true + cfg.platform.netbsd = true + cfg.platform.bsd = true elseif system == "Darwin" then - detected.unix = true - detected.macosx = true - detected.bsd = true + cfg.platform.unix = true + cfg.platform.macosx = true + cfg.platform.bsd = true elseif system == "Linux" then - detected.unix = true - detected.linux = true + cfg.platform.unix = true + cfg.platform.linux = true elseif system == "SunOS" then - detected.unix = true - detected.solaris = true + cfg.platform.unix = true + cfg.platform.solaris = true elseif system and system:match("^CYGWIN") then - detected.unix = true - detected.cygwin = true + cfg.platform.unix = true + cfg.platform.cygwin = true elseif system and system:match("^Windows") then - detected.windows = true + cfg.platform.windows = true elseif system and system:match("^MINGW") then - detected.windows = true - detected.mingw32 = true + cfg.platform.windows = true + cfg.platform.mingw32 = true else - detected.unix = true + cfg.platform.unix = true -- Fall back to Unix in unknown systems. end @@ -129,7 +130,7 @@ local sys_config_dir, home_config_dir local sys_config_ok, home_config_ok = false, false local extra_luarocks_module_dir sys_config_dir = site_config.LUAROCKS_SYSCONFDIR -if detected.windows then +if cfg.platform.windows then cfg.home = os.getenv("APPDATA") or "c:" sys_config_dir = sys_config_dir or "c:/luarocks" home_config_dir = cfg.home.."/luarocks" @@ -141,16 +142,13 @@ else cfg.home_tree = (os.getenv("USER") ~= "root") and cfg.home.."/.luarocks/" end -cfg.variables = {} -cfg.rocks_trees = {} - -- Create global environment for the config files; local env_for_config_file = function() local e e = { home = cfg.home, lua_version = cfg.lua_version, - platform = util.make_shallow_copy(detected), + platform = util.make_shallow_copy(cfg.platform), processor = cfg.target_cpu, -- remains for compat reasons target_cpu = cfg.target_cpu, -- replaces `processor` os_getenv = os.getenv, @@ -328,7 +326,7 @@ local defaults = { rocks_provided = {} } -if detected.windows then +if cfg.platform.windows then local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])).."\\"..cfg.major_version extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" @@ -388,7 +386,7 @@ if detected.windows then defaults.web_browser = "start" end -if detected.mingw32 then +if cfg.platform.mingw32 then defaults.platforms = { "win32", "mingw32", "windows" } defaults.obj_extension = "o" defaults.cmake_generator = "MinGW Makefiles" @@ -413,7 +411,7 @@ if detected.mingw32 then end -if detected.unix then +if cfg.platform.unix then defaults.lib_extension = "so" defaults.external_lib_extension = "so" defaults.obj_extension = "o" @@ -450,7 +448,7 @@ if detected.unix then defaults.web_browser = "xdg-open" end -if detected.cygwin then +if cfg.platform.cygwin then defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds defaults.arch = "cygwin-"..cfg.target_cpu defaults.platforms = {"unix", "cygwin"} @@ -460,12 +458,12 @@ if detected.cygwin then defaults.variables.LIBFLAG = "-shared" end -if detected.bsd then +if cfg.platform.bsd then defaults.variables.MAKE = "gmake" defaults.variables.STATFLAG = "-f '%OLp'" end -if detected.macosx then +if cfg.platform.macosx then defaults.variables.MAKE = "make" defaults.external_lib_extension = "dylib" defaults.arch = "macosx-"..cfg.target_cpu @@ -487,12 +485,12 @@ if detected.macosx then defaults.web_browser = "open" end -if detected.linux then +if cfg.platform.linux then defaults.arch = "linux-"..cfg.target_cpu defaults.platforms = {"unix", "linux"} end -if detected.freebsd then +if cfg.platform.freebsd then defaults.arch = "freebsd-"..cfg.target_cpu defaults.platforms = {"unix", "bsd", "freebsd"} defaults.gcc_rpath = false @@ -500,17 +498,17 @@ if detected.freebsd then defaults.variables.LD = "cc" end -if detected.openbsd then +if cfg.platform.openbsd then defaults.arch = "openbsd-"..cfg.target_cpu defaults.platforms = {"unix", "bsd", "openbsd"} end -if detected.netbsd then +if cfg.platform.netbsd then defaults.arch = "netbsd-"..cfg.target_cpu defaults.platforms = {"unix", "bsd", "netbsd"} end -if detected.solaris then +if cfg.platform.solaris then defaults.arch = "solaris-"..cfg.target_cpu defaults.platforms = {"unix", "solaris"} defaults.variables.MAKE = "gmake" -- cgit v1.2.3-55-g6feb From 554836ba3575576e2ef463cdb87a2177f38bf24d Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 25 Jun 2015 16:47:34 +0200 Subject: refactored the loading of the config files in a more structural manner, removing duplicate code and error handling. --- src/luarocks/cfg.lua | 84 ++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index ff18e0a3..6ff2fcf0 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -124,8 +124,8 @@ else end -- Path configuration: - local sys_config_file, home_config_file +local sys_config_file_default, home_config_file_default local sys_config_dir, home_config_dir local sys_config_ok, home_config_ok = false, false local extra_luarocks_module_dir @@ -173,49 +173,55 @@ local merge_overrides = function(overrides) util.deep_merge(cfg, overrides) end -sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" -do - local err, errcode - sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file()) - if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file - sys_config_file = sys_config_dir.."/config.lua" - sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file()) - end - if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error - io.stderr:write(err.."\n") - os.exit(cfg.errorcodes.CONFIGFILE) - end - if sys_config_ok then - merge_overrides(sys_config_ok) +-- load config file from a list until first succesful one. Info is +-- added to `cfg` module table, returns filepath of succesfully loaded +-- file or nil if it failed +local load_config_file = function(list) + for _, filepath in ipairs(list) do + local result, err, errcode = persist.load_into_table(filepath, env_for_config_file()) + if (not result) and errcode ~= "open" then + -- errcode is either "load" or "run"; bad config file, so error out + io.stderr:write(err.."\n") + os.exit(cfg.errorcodes.CONFIGFILE) + end + if result then + -- succes in loading and running, merge contents and exit + merge_overrides(result) + return filepath + end end + return nil -- nothing was loaded +end + + +-- Load system configuration file +do + sys_config_file_default = sys_config_dir.."/config.lua" + sys_config_file = load_config_file({ + site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua", + sys_config_file_default, + }) + sys_config_ok = (sys_config_file ~= nil) end +-- Load user configuration file (if allowed) if not site_config.LUAROCKS_FORCE_CONFIG then + + home_config_file_default = home_config_dir.."/config.lua" + local list = { + os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG"), + home_config_dir.."/config-"..cfg.lua_version..".lua", + home_config_file_default, + } + -- first entry might be a silent nil, check and remove if so + if not list[1] then table.remove(list, 1) end + + home_config_file = load_config_file(list) + home_config_ok = (home_config_file ~= nil) - local home_overrides, err, errcode - home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG") - if home_config_file then - home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file()) - else - home_config_file = home_config_dir.."/config-"..cfg.lua_version..".lua" - home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file()) - if (not home_overrides) and (not errcode == "run") then - home_config_file = home_config_dir.."/config.lua" - home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file()) - end - end - if home_overrides then - home_config_ok = true - merge_overrides(home_overrides) - else - home_config_ok = home_overrides - if errcode ~= "open" then - io.stderr:write(err.."\n") - os.exit(cfg.errorcodes.CONFIGFILE) - end - end end + if not next(cfg.rocks_trees) then if cfg.home_tree then table.insert(cfg.rocks_trees, { name = "user", root = cfg.home_tree } ) @@ -610,11 +616,11 @@ end function cfg.which_config() return { system = { - file = sys_config_file, + file = sys_config_file or sys_config_file_default, ok = sys_config_ok, }, user = { - file = home_config_file, + file = home_config_file or home_config_file_default, ok = home_config_ok, } } -- cgit v1.2.3-55-g6feb From d065a9588324e96731df651d855286b2b8475a74 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 25 Jun 2015 22:04:57 +0200 Subject: integrated cfg.platform and cfg.platforms --- src/luarocks/cfg.lua | 94 ++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 6ff2fcf0..8368ee7e 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -37,7 +37,7 @@ cfg.program_series = "2.2" cfg.major_version = (cfg.program_version:match("([^.]%.[^.])")) or cfg.program_series cfg.variables = {} cfg.rocks_trees = {} -cfg.platform = {} +cfg.platforms = {} local persist = require("luarocks.persist") @@ -89,37 +89,39 @@ elseif proc:match("Power Macintosh") then end if system == "FreeBSD" then - cfg.platform.unix = true - cfg.platform.freebsd = true - cfg.platform.bsd = true + cfg.platforms.unix = true + cfg.platforms.freebsd = true + cfg.platforms.bsd = true elseif system == "OpenBSD" then - cfg.platform.unix = true - cfg.platform.openbsd = true - cfg.platform.bsd = true + cfg.platforms.unix = true + cfg.platforms.openbsd = true + cfg.platforms.bsd = true elseif system == "NetBSD" then - cfg.platform.unix = true - cfg.platform.netbsd = true - cfg.platform.bsd = true + cfg.platforms.unix = true + cfg.platforms.netbsd = true + cfg.platforms.bsd = true elseif system == "Darwin" then - cfg.platform.unix = true - cfg.platform.macosx = true - cfg.platform.bsd = true + cfg.platforms.unix = true + cfg.platforms.macosx = true + cfg.platforms.bsd = true elseif system == "Linux" then - cfg.platform.unix = true - cfg.platform.linux = true + cfg.platforms.unix = true + cfg.platforms.linux = true elseif system == "SunOS" then - cfg.platform.unix = true - cfg.platform.solaris = true + cfg.platforms.unix = true + cfg.platforms.solaris = true elseif system and system:match("^CYGWIN") then - cfg.platform.unix = true - cfg.platform.cygwin = true + cfg.platforms.unix = true + cfg.platforms.cygwin = true elseif system and system:match("^Windows") then - cfg.platform.windows = true + cfg.platforms.windows = true + cfg.platforms.win32 = true elseif system and system:match("^MINGW") then - cfg.platform.windows = true - cfg.platform.mingw32 = true + cfg.platforms.windows = true + cfg.platforms.mingw32 = true + cfg.platforms.win32 = true else - cfg.platform.unix = true + cfg.platforms.unix = true -- Fall back to Unix in unknown systems. end @@ -130,7 +132,7 @@ local sys_config_dir, home_config_dir local sys_config_ok, home_config_ok = false, false local extra_luarocks_module_dir sys_config_dir = site_config.LUAROCKS_SYSCONFDIR -if cfg.platform.windows then +if cfg.platforms.windows then cfg.home = os.getenv("APPDATA") or "c:" sys_config_dir = sys_config_dir or "c:/luarocks" home_config_dir = cfg.home.."/luarocks" @@ -148,7 +150,7 @@ local env_for_config_file = function() e = { home = cfg.home, lua_version = cfg.lua_version, - platform = util.make_shallow_copy(cfg.platform), + platforms = util.make_shallow_copy(cfg.platforms), processor = cfg.target_cpu, -- remains for compat reasons target_cpu = cfg.target_cpu, -- replaces `processor` os_getenv = os.getenv, @@ -231,8 +233,15 @@ if not next(cfg.rocks_trees) then end end --- Configure defaults: +-- update platforms list; keyed -> array +do + local lst = {} -- use temp array to not confuse `pairs` in loop + for plat in pairs(cfg.platforms) do table.insert(lst, plat) end + util.deep_merge(cfg.platforms, lst) +end + +-- Configure defaults: local defaults = { local_by_default = false, @@ -332,14 +341,13 @@ local defaults = { rocks_provided = {} } -if cfg.platform.windows then +if cfg.platforms.windows then local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])).."\\"..cfg.major_version extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" home_config_file = home_config_file and home_config_file:gsub("\\","/") defaults.fs_use_modules = false defaults.arch = "win32-"..cfg.target_cpu - defaults.platforms = {"win32", "windows" } defaults.lib_extension = "dll" defaults.external_lib_extension = "dll" defaults.obj_extension = "obj" @@ -392,8 +400,7 @@ if cfg.platform.windows then defaults.web_browser = "start" end -if cfg.platform.mingw32 then - defaults.platforms = { "win32", "mingw32", "windows" } +if cfg.platforms.mingw32 then defaults.obj_extension = "o" defaults.cmake_generator = "MinGW Makefiles" defaults.variables.MAKE = "mingw32-make" @@ -417,7 +424,7 @@ if cfg.platform.mingw32 then end -if cfg.platform.unix then +if cfg.platforms.unix then defaults.lib_extension = "so" defaults.external_lib_extension = "so" defaults.obj_extension = "o" @@ -427,7 +434,6 @@ if cfg.platform.unix then defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR or "/usr/local/lib" defaults.variables.CFLAGS = "-O2" defaults.cmake_generator = "Unix Makefiles" - defaults.platforms = { "unix" } defaults.variables.CC = "gcc" defaults.variables.LD = "gcc" defaults.gcc_rpath = true @@ -454,26 +460,24 @@ if cfg.platform.unix then defaults.web_browser = "xdg-open" end -if cfg.platform.cygwin then +if cfg.platforms.cygwin then defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds defaults.arch = "cygwin-"..cfg.target_cpu - defaults.platforms = {"unix", "cygwin"} defaults.cmake_generator = "Unix Makefiles" defaults.variables.CC = "echo -llua | xargs gcc" defaults.variables.LD = "echo -llua | xargs gcc" defaults.variables.LIBFLAG = "-shared" end -if cfg.platform.bsd then +if cfg.platforms.bsd then defaults.variables.MAKE = "gmake" defaults.variables.STATFLAG = "-f '%OLp'" end -if cfg.platform.macosx then +if cfg.platforms.macosx then defaults.variables.MAKE = "make" defaults.external_lib_extension = "dylib" defaults.arch = "macosx-"..cfg.target_cpu - defaults.platforms = {"unix", "bsd", "macosx"} defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" defaults.variables.STAT = "/usr/bin/stat" defaults.variables.STATFLAG = "-f '%A'" @@ -491,32 +495,28 @@ if cfg.platform.macosx then defaults.web_browser = "open" end -if cfg.platform.linux then +if cfg.platforms.linux then defaults.arch = "linux-"..cfg.target_cpu - defaults.platforms = {"unix", "linux"} end -if cfg.platform.freebsd then +if cfg.platforms.freebsd then defaults.arch = "freebsd-"..cfg.target_cpu - defaults.platforms = {"unix", "bsd", "freebsd"} defaults.gcc_rpath = false defaults.variables.CC = "cc" defaults.variables.LD = "cc" end -if cfg.platform.openbsd then +if cfg.platforms.openbsd then defaults.arch = "openbsd-"..cfg.target_cpu - defaults.platforms = {"unix", "bsd", "openbsd"} end -if cfg.platform.netbsd then +if cfg.platforms.netbsd then defaults.arch = "netbsd-"..cfg.target_cpu - defaults.platforms = {"unix", "bsd", "netbsd"} end -if cfg.platform.solaris then +if cfg.platforms.solaris then defaults.arch = "solaris-"..cfg.target_cpu - defaults.platforms = {"unix", "solaris"} + --defaults.platforms = {"unix", "solaris"} defaults.variables.MAKE = "gmake" end -- cgit v1.2.3-55-g6feb From 253ed468542853878cd01166ec3b08e624499409 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Fri, 26 Jun 2015 09:58:45 +0200 Subject: added correct order for platform overrides --- src/luarocks/cfg.lua | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 8368ee7e..704c7daf 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -125,6 +125,24 @@ else -- Fall back to Unix in unknown systems. end +-- Set order for platform overrides +local platform_order = { + -- Unixes + unix = 1, + bsd = 2, + solaris = 3, + netbsd = 4, + openbsd = 5, + freebsd = 6, + linux = 7, + macosx = 8, + cygwin = 9, + -- Windows + win32 = 10, + mingw32 = 11, + windows = 12 } + + -- Path configuration: local sys_config_file, home_config_file local sys_config_file_default, home_config_file_default @@ -237,7 +255,15 @@ 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 table.insert(lst, plat) end + for plat in pairs(cfg.platforms) do + if cfg.platforms[plat] then -- entries set to 'false' skipped + table.insert(lst, plat) + else + cfg.platforms[plat] = nil + end + 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 -- cgit v1.2.3-55-g6feb From 5f7763b0a51db4d95fdf0b019a52c0683c83845e Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Fri, 26 Jun 2015 10:08:41 +0200 Subject: added error message in case of a bad platform value --- src/luarocks/cfg.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 704c7daf..f5d7fb5e 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -257,6 +257,12 @@ 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) + end table.insert(lst, plat) else cfg.platforms[plat] = nil -- cgit v1.2.3-55-g6feb From 02eff158f095ed95cf3c889fb0e9c2efd06beeb9 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 30 Jun 2015 12:44:41 +0200 Subject: prefer versioned config files and directories over non-versioned ones --- install.bat | 8 +- src/luarocks/cfg.lua | 230 +++++++++++++++++++++++++++++---------------------- 2 files changed, 137 insertions(+), 101 deletions(-) diff --git a/install.bat b/install.bat index d83dfbf1..8c2983a7 100644 --- a/install.bat +++ b/install.bat @@ -360,7 +360,7 @@ local function look_for_headers (directory) die(S"lua.h not found in $LUA_INCDIR") end - for _, e in ipairs{ [[\]], [[\include\]]} do + for _, e in ipairs{ S([[\include\lua\$LUA_VERSION]]), S([[\include\$LUA_VERSION]]), [[\]], [[\include\]]} do print(" checking for "..directory..e.."\\lua.h") if exists(directory..e.."\\lua.h") then vars.LUA_INCDIR = directory..e @@ -811,7 +811,7 @@ else end f:write(S[=[ site_config.LUAROCKS_UNAME_M=[[$UNAME_M]] -site_config.LUAROCKS_SYSCONFIG=[[$SYSCONFDIR\config.lua]] +site_config.LUAROCKS_SYSCONFIG=[[$SYSCONFDIR\config-$LUA_VERSION.lua]] site_config.LUAROCKS_ROCKS_TREE=[[$TREE_ROOT]] site_config.LUAROCKS_PREFIX=[[$PREFIX]] site_config.LUAROCKS_DOWNLOADER=[[wget]] @@ -832,12 +832,12 @@ f:close() print(S[[Created LuaRocks site-config file: $LUADIR\luarocks\site_config.lua]]) -- create config file -vars.CONFIG_FILE = vars.SYSCONFDIR.."\\config.lua" +vars.CONFIG_FILE = vars.SYSCONFDIR..S"\\config-$LUA_VERSION.lua" if not exists(vars.SYSCONFDIR) then mkdir(vars.SYSCONFDIR) end if exists(vars.CONFIG_FILE) then - local nname = backup(vars.CONFIG_FILE, "config.bak") + local nname = backup(vars.CONFIG_FILE, S"config-$LUA_VERSION.bak") print("***************") print(S"*** WARNING *** LuaRocks config file already exists: '$CONFIG_FILE'. The old file has been renamed to '"..nname.."'") print("***************") diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 8321e9b9..31b3211a 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -35,6 +35,9 @@ end cfg.program_version = "scm" cfg.program_series = "2.2" cfg.major_version = (cfg.program_version:match("([^.]%.[^.])")) or cfg.program_series +cfg.variables = {} +cfg.rocks_trees = {} +cfg.platforms = {} local persist = require("luarocks.persist") @@ -68,68 +71,86 @@ end -- System detection: -local detected = {} -local system,proc - -- A proper installation of LuaRocks will hardcode the system -- and proc values with site_config.LUAROCKS_UNAME_S and site_config.LUAROCKS_UNAME_M, -- so that this detection does not run every time. When it is -- performed, we use the Unix way to identify the system, -- even on Windows (assuming UnxUtils or Cygwin). -system = site_config.LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") -proc = site_config.LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") +local system = site_config.LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") +local proc = site_config.LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") if proc:match("i[%d]86") then - proc = "x86" + cfg.target_cpu = "x86" elseif proc:match("amd64") or proc:match("x86_64") then - proc = "x86_64" + cfg.target_cpu = "x86_64" elseif proc:match("Power Macintosh") then - proc = "powerpc" + cfg.target_cpu = "powerpc" + else + cfg.target_cpu = proc end -cfg.target_cpu = proc if system == "FreeBSD" then - detected.unix = true - detected.freebsd = true - detected.bsd = true + cfg.platforms.unix = true + cfg.platforms.freebsd = true + cfg.platforms.bsd = true elseif system == "OpenBSD" then - detected.unix = true - detected.openbsd = true - detected.bsd = true + cfg.platforms.unix = true + cfg.platforms.openbsd = true + cfg.platforms.bsd = true elseif system == "NetBSD" then - detected.unix = true - detected.netbsd = true - detected.bsd = true + cfg.platforms.unix = true + cfg.platforms.netbsd = true + cfg.platforms.bsd = true elseif system == "Darwin" then - detected.unix = true - detected.macosx = true - detected.bsd = true + cfg.platforms.unix = true + cfg.platforms.macosx = true + cfg.platforms.bsd = true elseif system == "Linux" then - detected.unix = true - detected.linux = true + cfg.platforms.unix = true + cfg.platforms.linux = true elseif system == "SunOS" then - detected.unix = true - detected.solaris = true + cfg.platforms.unix = true + cfg.platforms.solaris = true elseif system and system:match("^CYGWIN") then - detected.unix = true - detected.cygwin = true + cfg.platforms.unix = true + cfg.platforms.cygwin = true elseif system and system:match("^Windows") then - detected.windows = true + cfg.platforms.windows = true + cfg.platforms.win32 = true elseif system and system:match("^MINGW") then - detected.windows = true - detected.mingw32 = true + cfg.platforms.windows = true + cfg.platforms.mingw32 = true + cfg.platforms.win32 = true else - detected.unix = true + cfg.platforms.unix = true -- Fall back to Unix in unknown systems. end --- Path configuration: +-- Set order for platform overrides +local platform_order = { + -- Unixes + unix = 1, + bsd = 2, + solaris = 3, + netbsd = 4, + openbsd = 5, + freebsd = 6, + linux = 7, + macosx = 8, + cygwin = 9, + -- Windows + win32 = 10, + mingw32 = 11, + windows = 12 } + +-- Path configuration: local sys_config_file, home_config_file +local sys_config_file_default, home_config_file_default local sys_config_dir, home_config_dir local sys_config_ok, home_config_ok = false, false local extra_luarocks_module_dir sys_config_dir = site_config.LUAROCKS_SYSCONFDIR -if detected.windows then +if cfg.platforms.windows then cfg.home = os.getenv("APPDATA") or "c:" sys_config_dir = sys_config_dir or "c:/luarocks" home_config_dir = cfg.home.."/luarocks" @@ -141,16 +162,13 @@ else cfg.home_tree = (os.getenv("USER") ~= "root") and cfg.home.."/.luarocks/" end -cfg.variables = {} -cfg.rocks_trees = {} - -- Create global environment for the config files; local env_for_config_file = function() local e e = { home = cfg.home, lua_version = cfg.lua_version, - platform = util.make_shallow_copy(detected), + platforms = util.make_shallow_copy(cfg.platforms), processor = cfg.target_cpu, -- remains for compat reasons target_cpu = cfg.target_cpu, -- replaces `processor` os_getenv = os.getenv, @@ -175,49 +193,55 @@ local merge_overrides = function(overrides) util.deep_merge(cfg, overrides) end -sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" -do - local err, errcode - sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file()) - if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file - sys_config_file = sys_config_dir.."/config.lua" - sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file()) - end - if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error - io.stderr:write(err.."\n") - os.exit(cfg.errorcodes.CONFIGFILE) - end - if sys_config_ok then - merge_overrides(sys_config_ok) +-- load config file from a list until first succesful one. Info is +-- added to `cfg` module table, returns filepath of succesfully loaded +-- file or nil if it failed +local load_config_file = function(list) + for _, filepath in ipairs(list) do + local result, err, errcode = persist.load_into_table(filepath, env_for_config_file()) + if (not result) and errcode ~= "open" then + -- errcode is either "load" or "run"; bad config file, so error out + io.stderr:write(err.."\n") + os.exit(cfg.errorcodes.CONFIGFILE) + end + if result then + -- succes in loading and running, merge contents and exit + merge_overrides(result) + return filepath + end end + return nil -- nothing was loaded +end + + +-- Load system configuration file +do + sys_config_file_default = sys_config_dir.."/config-"..cfg.lua_version..".lua" + sys_config_file = load_config_file({ + site_config.LUAROCKS_SYSCONFIG or sys_config_file_default, + sys_config_dir.."/config.lua", + }) + sys_config_ok = (sys_config_file ~= nil) end +-- Load user configuration file (if allowed) if not site_config.LUAROCKS_FORCE_CONFIG then + + home_config_file_default = home_config_dir.."/config-"..cfg.lua_version..".lua" + local list = { + os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG"), + home_config_file_default, + home_config_dir.."/config.lua", + } + -- first entry might be a silent nil, check and remove if so + if not list[1] then table.remove(list, 1) end + + home_config_file = load_config_file(list) + home_config_ok = (home_config_file ~= nil) - local home_overrides, err, errcode - home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG") - if home_config_file then - home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file()) - else - home_config_file = home_config_dir.."/config-"..cfg.lua_version..".lua" - home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file()) - if (not home_overrides) and (not errcode == "run") then - home_config_file = home_config_dir.."/config.lua" - home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file()) - end - end - if home_overrides then - home_config_ok = true - merge_overrides(home_overrides) - else - home_config_ok = home_overrides - if errcode ~= "open" then - io.stderr:write(err.."\n") - os.exit(cfg.errorcodes.CONFIGFILE) - end - end end + if not next(cfg.rocks_trees) then if cfg.home_tree then table.insert(cfg.rocks_trees, { name = "user", root = cfg.home_tree } ) @@ -227,8 +251,29 @@ if not next(cfg.rocks_trees) then end end --- Configure defaults: +-- 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) + end + table.insert(lst, plat) + else + cfg.platforms[plat] = nil + end + 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: local defaults = { local_by_default = false, @@ -328,14 +373,13 @@ local defaults = { rocks_provided = {} } -if detected.windows then +if cfg.platforms.windows then local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])).."\\"..cfg.major_version extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" home_config_file = home_config_file and home_config_file:gsub("\\","/") defaults.fs_use_modules = false defaults.arch = "win32-"..cfg.target_cpu - defaults.platforms = {"win32", "windows" } defaults.lib_extension = "dll" defaults.external_lib_extension = "dll" defaults.obj_extension = "obj" @@ -388,8 +432,7 @@ if detected.windows then defaults.web_browser = "start" end -if detected.mingw32 then - defaults.platforms = { "win32", "mingw32", "windows" } +if cfg.platforms.mingw32 then defaults.obj_extension = "o" defaults.cmake_generator = "MinGW Makefiles" defaults.variables.MAKE = "mingw32-make" @@ -413,7 +456,7 @@ if detected.mingw32 then end -if detected.unix then +if cfg.platforms.unix then defaults.lib_extension = "so" defaults.external_lib_extension = "so" defaults.obj_extension = "o" @@ -423,7 +466,6 @@ if detected.unix then defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR or "/usr/local/lib" defaults.variables.CFLAGS = "-O2" defaults.cmake_generator = "Unix Makefiles" - defaults.platforms = { "unix" } defaults.variables.CC = "gcc" defaults.variables.LD = "gcc" defaults.gcc_rpath = true @@ -450,26 +492,24 @@ if detected.unix then defaults.web_browser = "xdg-open" end -if detected.cygwin then +if cfg.platforms.cygwin then defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds defaults.arch = "cygwin-"..cfg.target_cpu - defaults.platforms = {"unix", "cygwin"} defaults.cmake_generator = "Unix Makefiles" defaults.variables.CC = "echo -llua | xargs gcc" defaults.variables.LD = "echo -llua | xargs gcc" defaults.variables.LIBFLAG = "-shared" end -if detected.bsd then +if cfg.platforms.bsd then defaults.variables.MAKE = "gmake" defaults.variables.STATFLAG = "-f '%OLp'" end -if detected.macosx then +if cfg.platforms.macosx then defaults.variables.MAKE = "make" defaults.external_lib_extension = "dylib" defaults.arch = "macosx-"..cfg.target_cpu - defaults.platforms = {"unix", "bsd", "macosx"} defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" defaults.variables.STAT = "/usr/bin/stat" defaults.variables.STATFLAG = "-f '%A'" @@ -487,32 +527,28 @@ if detected.macosx then defaults.web_browser = "open" end -if detected.linux then +if cfg.platforms.linux then defaults.arch = "linux-"..cfg.target_cpu - defaults.platforms = {"unix", "linux"} end -if detected.freebsd then +if cfg.platforms.freebsd then defaults.arch = "freebsd-"..cfg.target_cpu - defaults.platforms = {"unix", "bsd", "freebsd"} defaults.gcc_rpath = false defaults.variables.CC = "cc" defaults.variables.LD = "cc" end -if detected.openbsd then +if cfg.platforms.openbsd then defaults.arch = "openbsd-"..cfg.target_cpu - defaults.platforms = {"unix", "bsd", "openbsd"} end -if detected.netbsd then +if cfg.platforms.netbsd then defaults.arch = "netbsd-"..cfg.target_cpu - defaults.platforms = {"unix", "bsd", "netbsd"} end -if detected.solaris then +if cfg.platforms.solaris then defaults.arch = "solaris-"..cfg.target_cpu - defaults.platforms = {"unix", "solaris"} + --defaults.platforms = {"unix", "solaris"} defaults.variables.MAKE = "gmake" end @@ -612,11 +648,11 @@ end function cfg.which_config() return { system = { - file = sys_config_file, + file = sys_config_file or sys_config_file_default, ok = sys_config_ok, }, user = { - file = home_config_file, + file = home_config_file or home_config_file_default, ok = home_config_ok, } } -- cgit v1.2.3-55-g6feb From c6e3556c0a883831dde10858b32ce21cacd1bd0e Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Tue, 30 Jun 2015 12:33:36 -0300 Subject: Strip known extensions --- src/luarocks/fetch.lua | 7 ++++++- test/testing.lua | 12 ++++++++++++ test/testing.sh | 13 +++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 686aadcd..e92aeddf 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -170,8 +170,13 @@ function fetch.fetch_and_unpack_rock(rock_file, dest) end function fetch.url_to_base_dir(url) + -- for extensions like foo.tar.gz, "gz" is stripped first + local known_exts = {} + for _, ext in ipairs{"zip", "git", "tgz", "tar", "gz", "bz2"} do + known_exts[ext] = "" + end local base = dir.base_name(url) - return base:gsub("%.[^.]*$", ""):gsub("%.tar$", "") + return (base:gsub("%.([^.]*)$", known_exts):gsub("%.tar", "")) end --- Back-end function that actually loads the local rockspec. diff --git a/test/testing.lua b/test/testing.lua index 50911fd4..63dead2b 100644 --- a/test/testing.lua +++ b/test/testing.lua @@ -441,5 +441,17 @@ local tests = { return run "$luarocks install luarepl" and run "$luarocks doc luarepl" end, + + -- Tests for https://github.com/keplerproject/luarocks/issues/375 + test_fetch_base_dir = function() + local fetch = require "luarocks.fetch" + + return assert("v0.3" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3.zip")) + and assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.zip")) + and assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.gz")) + and assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.bz2")) + and assert("parser.moon" == fetch.url_to_base_dir("git://github.com/Cirru/parser.moon")) + and assert("v0.3" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3")) + end } diff --git a/test/testing.sh b/test/testing.sh index 133597ee..6219a38f 100755 --- a/test/testing.sh +++ b/test/testing.sh @@ -511,6 +511,19 @@ fail_config_user_config() { LUAROCKS_CONFIG="/missing_file.lua" $luarocks config test_config_rock_trees() { $luarocks config --rock-trees; } test_config_help() { $luarocks help config; } +# Tests for https://github.com/keplerproject/luarocks/issues/375 +test_fetch_base_dir() { $lua < Date: Tue, 30 Jun 2015 12:43:28 -0300 Subject: Updates pe-parser to v0.4 --- win32/pe-parser.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/win32/pe-parser.lua b/win32/pe-parser.lua index 6b3a48c8..9cd36ffc 100644 --- a/win32/pe-parser.lua +++ b/win32/pe-parser.lua @@ -5,7 +5,7 @@ -- case of 64 bit fields (bit/flag fields). Pointer arithmetic is still done numerically, so for -- very large files this could lead to undefined results. Use with care! -- --- Version 0.3, [copyright (c) 2013-2015 Thijs Schreijer](http://www.thijsschreijer.nl) +-- Version 0.4, [copyright (c) 2013-2015 Thijs Schreijer](http://www.thijsschreijer.nl) -- @name pe-parser -- @class module @@ -532,6 +532,9 @@ function M.msvcrt(infile) if not result then result = dll:match('(MSVCRTD?)%.DLL') end + if not result then + result = dll:match('(VCRUNTIME%d*D?)%.DLL') + end -- success, found it return name + binary where it was found if result then return result, infile end end -- cgit v1.2.3-55-g6feb From 642be5cee59a20654226466f6f865e230c326751 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Wed, 1 Jul 2015 23:11:52 +0200 Subject: update displayed data to match version --- install.bat | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/install.bat b/install.bat index 8c2983a7..ec20e4dc 100644 --- a/install.bat +++ b/install.bat @@ -583,6 +583,7 @@ vars.LIBDIR = vars.FULL_PREFIX vars.LUADIR = S"$FULL_PREFIX\\lua" vars.INCDIR = S"$FULL_PREFIX\\include" vars.LUA_SHORTV = vars.LUA_VERSION:gsub("%.", "") +vars.SYSCONFFILENAME = S"config-$LUA_VERSION.lua" if INSTALL_LUA then if vars.LUA_VERSION ~= "5.1" then @@ -625,7 +626,7 @@ print(S[[ Will configure LuaRocks with the following paths: LuaRocks : $FULL_PREFIX -Config file : $SYSCONFDIR\config.lua +Config file : $SYSCONFDIR\$SYSCONFFILENAME Rocktree : $TREE_ROOT Lua interpreter : $LUA_BINDIR\$LUA_INTERPRETER @@ -811,7 +812,7 @@ else end f:write(S[=[ site_config.LUAROCKS_UNAME_M=[[$UNAME_M]] -site_config.LUAROCKS_SYSCONFIG=[[$SYSCONFDIR\config-$LUA_VERSION.lua]] +site_config.LUAROCKS_SYSCONFIG=[[$SYSCONFDIR\$SYSCONFFILENAME]] site_config.LUAROCKS_ROCKS_TREE=[[$TREE_ROOT]] site_config.LUAROCKS_PREFIX=[[$PREFIX]] site_config.LUAROCKS_DOWNLOADER=[[wget]] @@ -832,7 +833,7 @@ f:close() print(S[[Created LuaRocks site-config file: $LUADIR\luarocks\site_config.lua]]) -- create config file -vars.CONFIG_FILE = vars.SYSCONFDIR..S"\\config-$LUA_VERSION.lua" +vars.CONFIG_FILE = vars.SYSCONFDIR.."\\"..vars.SYSCONFFILENAME if not exists(vars.SYSCONFDIR) then mkdir(vars.SYSCONFDIR) end -- cgit v1.2.3-55-g6feb From e26e7a19adb663291ec87b859c26094d7d2c69fc Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 2 Jul 2015 14:58:57 +0200 Subject: also version the `site_config` file --- install.bat | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/install.bat b/install.bat index ec20e4dc..5913d3ab 100644 --- a/install.bat +++ b/install.bat @@ -794,10 +794,11 @@ print() print("Configuring LuaRocks...") -- Create a site-config file -if exists(S[[$LUADIR\luarocks\site_config.lua]]) then - exec(S[[RENAME "$LUADIR\luarocks\site_config.lua" site_config.lua.bak]]) +local site_config = S("site_config_$LUA_VERSION"):gsub("%.","_") +if exists(S([[$LUADIR\luarocks\]]..site_config..[[.lua]])) then + exec(S([[RENAME "$LUADIR\luarocks\]]..site_config..[[.lua" site_config.lua.bak]])) end -local f = io.open(vars.LUADIR.."\\luarocks\\site_config.lua", "w") +local f = io.open(vars.LUADIR.."\\luarocks\\"..site_config..".lua", "w") f:write(S[=[ local site_config = {} site_config.LUA_INCDIR=[[$LUA_INCDIR]] @@ -821,16 +822,16 @@ site_config.LUAROCKS_MD5CHECKER=[[md5sum]] if FORCE_CONFIG then f:write("site_config.LUAROCKS_FORCE_CONFIG=true\n") end -if exists(vars.LUADIR.."\\luarocks\\site_config.lua.bak") then - for line in io.lines(vars.LUADIR.."\\luarocks\\site_config.lua.bak", "r") do +if exists(vars.LUADIR.."\\luarocks\\"..site_config..".lua.bak") then + for line in io.lines(vars.LUADIR.."\\luarocks\\"..site_config..".lua.bak", "r") do f:write(line) f:write("\n") end - exec(S[[DEL /F /Q "$LUADIR\luarocks\site_config.lua.bak"]]) + exec(S([[DEL /F /Q "$LUADIR\luarocks\]]..site_config..[[.lua.bak"]])) end f:write("return site_config\n") f:close() -print(S[[Created LuaRocks site-config file: $LUADIR\luarocks\site_config.lua]]) +print(S([[Created LuaRocks site-config file: $LUADIR\luarocks\]]..site_config..[[.lua]])) -- create config file vars.CONFIG_FILE = vars.SYSCONFDIR.."\\"..vars.SYSCONFFILENAME -- cgit v1.2.3-55-g6feb From ddefaeb8e5c52a7f63e573e04f720879edfee91a Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 9 Jul 2015 09:45:30 +0200 Subject: added extra include files search paths, see https://github.com/keplerproject/luarocks/issues/403#issuecomment-119726674 updated bak files as per @ignacio see https://github.com/keplerproject/luarocks/pull/407#discussion-diff-33782733 --- install.bat | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/install.bat b/install.bat index 5913d3ab..57e3611c 100644 --- a/install.bat +++ b/install.bat @@ -8,6 +8,8 @@ local vars = {} vars.PREFIX = nil vars.VERSION = "2.2" vars.SYSCONFDIR = nil +vars.SYSCONFFILENAME = nil +vars.CONFIG_FILE = nil vars.TREE_ROOT = nil vars.TREE_BIN = nil vars.TREE_LMODULE = nil @@ -360,7 +362,14 @@ local function look_for_headers (directory) die(S"lua.h not found in $LUA_INCDIR") end - for _, e in ipairs{ S([[\include\lua\$LUA_VERSION]]), S([[\include\$LUA_VERSION]]), [[\]], [[\include\]]} do + for _, e in ipairs{ + S([[\include\lua\$LUA_VERSION]]), + S([[\include\lua$LUA_SHORTV]]), + S([[\include\lua$LUA_VERSION]]), + S([[\include\$LUA_VERSION]]), + [[\include\]], + [[\]], + } do print(" checking for "..directory..e.."\\lua.h") if exists(directory..e.."\\lua.h") then vars.LUA_INCDIR = directory..e @@ -583,7 +592,6 @@ vars.LIBDIR = vars.FULL_PREFIX vars.LUADIR = S"$FULL_PREFIX\\lua" vars.INCDIR = S"$FULL_PREFIX\\include" vars.LUA_SHORTV = vars.LUA_VERSION:gsub("%.", "") -vars.SYSCONFFILENAME = S"config-$LUA_VERSION.lua" if INSTALL_LUA then if vars.LUA_VERSION ~= "5.1" then @@ -611,6 +619,8 @@ else datapath = os.getenv("ProgramW6432") .. [[\LuaRocks]] end vars.SYSCONFDIR = vars.SYSCONFDIR or vars.PREFIX +vars.SYSCONFFILENAME = S"config-$LUA_VERSION.lua" +vars.CONFIG_FILE = vars.SYSCONFDIR.."\\"..vars.SYSCONFFILENAME vars.TREE_ROOT = vars.TREE_ROOT or datapath..[[\systree]] if SELFCONTAINED then vars.SYSCONFDIR = vars.PREFIX @@ -626,7 +636,7 @@ print(S[[ Will configure LuaRocks with the following paths: LuaRocks : $FULL_PREFIX -Config file : $SYSCONFDIR\$SYSCONFFILENAME +Config file : $CONFIG_FILE Rocktree : $TREE_ROOT Lua interpreter : $LUA_BINDIR\$LUA_INTERPRETER @@ -813,7 +823,7 @@ else end f:write(S[=[ site_config.LUAROCKS_UNAME_M=[[$UNAME_M]] -site_config.LUAROCKS_SYSCONFIG=[[$SYSCONFDIR\$SYSCONFFILENAME]] +site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]] site_config.LUAROCKS_ROCKS_TREE=[[$TREE_ROOT]] site_config.LUAROCKS_PREFIX=[[$PREFIX]] site_config.LUAROCKS_DOWNLOADER=[[wget]] @@ -834,12 +844,11 @@ f:close() print(S([[Created LuaRocks site-config file: $LUADIR\luarocks\]]..site_config..[[.lua]])) -- create config file -vars.CONFIG_FILE = vars.SYSCONFDIR.."\\"..vars.SYSCONFFILENAME if not exists(vars.SYSCONFDIR) then mkdir(vars.SYSCONFDIR) end if exists(vars.CONFIG_FILE) then - local nname = backup(vars.CONFIG_FILE, S"config-$LUA_VERSION.bak") + local nname = backup(vars.CONFIG_FILE, vars.SYSCONFFILENAME..".bak") print("***************") print(S"*** WARNING *** LuaRocks config file already exists: '$CONFIG_FILE'. The old file has been renamed to '"..nname.."'") print("***************") -- cgit v1.2.3-55-g6feb From 8f65a7b767a19ffbd76f5030ba64ca0219d5f4c7 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Fri, 10 Jul 2015 22:00:59 +0300 Subject: Fix git cloning command when using git+http protocol git+http and git+https pass '--' instead of '--depth=1' option. As '--branch' option was passed after depth, it caused the former to be interpreted as an extra argument by git. Pass '--branch' first instead. --- src/luarocks/fetch/git.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index e540d696..a635f190 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua @@ -68,7 +68,7 @@ function git.get_sources(rockspec, extract, dest_dir, depth) if git_can_clone_by_tag(git_cmd) then -- The argument to `--branch` can actually be a branch or a tag as of -- Git 1.7.10. - table.insert(command, 4, "--branch=" .. tag_or_branch) + table.insert(command, 3, "--branch=" .. tag_or_branch) end end if not fs.execute(unpack(command)) then -- cgit v1.2.3-55-g6feb From bc186fc9abce62126763912f6684c14b12150695 Mon Sep 17 00:00:00 2001 From: Peter Jas Date: Tue, 18 Aug 2015 19:18:51 +0000 Subject: ci: updates appveyor config to use VS2015. --- appveyor.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index abf15af6..d7fc7cc2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,5 @@ version: 2.2.1.{build}-test -os: -- Windows Server 2012 R2 - shallow_clone: true environment: @@ -17,8 +14,8 @@ environment: init: # Setup Lua development/build environment -# Make VS 2013 command line tools available -- call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %platform% +# Make VS 2015 command line tools available +- call "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %platform% install: # Setup Lua development/build environment -- cgit v1.2.3-55-g6feb From daa4ef448481a6ae2ae4b30ce6cf5ba85d0f18f5 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sun, 30 Aug 2015 14:49:41 -0300 Subject: Update LuaCov --- test/testing.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testing.sh b/test/testing.sh index 6219a38f..26bdde5f 100755 --- a/test/testing.sh +++ b/test/testing.sh @@ -184,7 +184,7 @@ srcdir_luasocket=luasocket-3.0-rc1 version_cprint=0.1 verrev_cprint=0.1-2 -version_luacov=0.7 +version_luacov=0.8 verrev_luacov=${version_luacov}-1 version_lxsh=0.8.6 version_validate_args=1.5.4 -- cgit v1.2.3-55-g6feb From 0d2053ea208a5326240331bf44eab52976076c32 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 17 Sep 2015 16:46:25 -0300 Subject: Fix documentation of --lua-version --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 7916749f..bd962edf 100755 --- a/configure +++ b/configure @@ -40,7 +40,7 @@ system's package manager. Default is \$PREFIX --lua-version=VERSION Use specific Lua version: 5.1, 5.2, or 5.3 - Default is "$LUA_VERSION" + Default is auto-detected. --lua-suffix=SUFFIX Versioning suffix to use in Lua filenames. Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...) --with-lua=PREFIX Use Lua from given prefix. -- cgit v1.2.3-55-g6feb From 5fa1201dd0cb5ee5e29b8ebcb57b265335bbe3e9 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 21 Sep 2015 13:32:59 -0300 Subject: We use lzlib, not lua-zlib --- src/luarocks/tools/zip.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/luarocks/tools/zip.lua b/src/luarocks/tools/zip.lua index 83a66434..101cae82 100644 --- a/src/luarocks/tools/zip.lua +++ b/src/luarocks/tools/zip.lua @@ -1,6 +1,6 @@ --- A Lua implementation of .zip file archiving (used for creating .rock files), --- using only lua-zlib. +-- using only lzlib. --module("luarocks.tools.zip", package.seeall) local zip = {} -- cgit v1.2.3-55-g6feb