From f0aa57e5149233c106f2a791694ae80dbfc62d3d Mon Sep 17 00:00:00 2001 From: Philipp Janda Date: Mon, 25 May 2015 13:29:28 +0200 Subject: Add config_cmd.lua to Makefile.setup.inc. Without config_cmd.lua in the list of LuaRocks files to install the installation is broken and throws an error when trying to display the usage message. --- Makefile.setup.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile.setup.inc b/Makefile.setup.inc index 0384a097..c228e78c 100644 --- a/Makefile.setup.inc +++ b/Makefile.setup.inc @@ -7,11 +7,11 @@ LUADIR ?= $(PREFIX)/share/lua/$(LUA_VERSION)/ BIN_FILES = luarocks luarocks-admin LUAROCKS_FILES = fs/unix/tools.lua fs/unix.lua fs/win32/tools.lua fs/win32.lua \ fs/lua.lua persist.lua list.lua require.lua repos.lua dir.lua make_manifest.lua \ -command_line.lua install.lua build/command.lua build/cmake.lua build/make.lua \ -build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua tools/patch.lua \ -fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua make.lua \ -remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua show.lua \ -manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ +command_line.lua config_cmd.lua install.lua build/command.lua build/cmake.lua \ +build/make.lua build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua \ +tools/patch.lua fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua \ +make.lua remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua \ +show.lua manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \ admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \ purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \ -- cgit v1.2.3-55-g6feb From baf7ffa63ab48b73bd328f9a9153a7f2cfecbc25 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 26 May 2015 08:24:54 +0200 Subject: remove excess line (windows installer) --- install.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.bat b/install.bat index ffde28db..d81a25a7 100644 --- a/install.bat +++ b/install.bat @@ -319,7 +319,7 @@ local function look_for_interpreter (directory) return true end end - print(" No Lua interpreter found") + --print(" No Lua interpreter found") return false end -- cgit v1.2.3-55-g6feb From 0ecc7438dc34649148b001275483e0c109859ba4 Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Mon, 8 Jun 2015 13:05:15 -0300 Subject: Use LuaJIT 2.0.4 on AppVeyor's test matrix --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 436c341b..140308ce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,7 +12,7 @@ environment: - LUA_VER: 5.1.5 - LUA_VER: 5.2.4 - LUA_VER: 5.3.0 - - LJ_VER: 2.0.3 + - LJ_VER: 2.0.4 - LJ_VER: 2.1 init: -- cgit v1.2.3-55-g6feb From e1dd6375822d800984e1d3d821899a315bc1b222 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 16 Jun 2015 19:31:01 +0200 Subject: added 2 functions to the global environment of the config-file loader sandbox; `os_getenv()` and `__dump_env()` --- src/luarocks/cfg.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 20aa4a21..6d6a911d 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -145,6 +145,14 @@ end cfg.variables = {} cfg.rocks_trees = {} +-- some extras for the global enviornment in the config files; +cfg.os_getenv = os.getenv +cfg.__dump_env = function() + -- debug function, calling it from a config file will show all + -- available globals to that config file + print(util.show_table(cfg, "global environment")) +end + sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" do local err, errcode @@ -159,11 +167,18 @@ do end end -local env_for_config_file = { +local env_for_config_file +env_for_config_file = { home = cfg.home, lua_version = cfg.lua_version, platform = util.make_shallow_copy(detected), processor = proc, + os_getenv = os.getenv, + __dump_env = function() + -- debug function, calling it from a config file will show all + -- available globals to that config file + print(util.show_table(env_for_config_file, "global environment")) + end, } if not site_config.LUAROCKS_FORCE_CONFIG then -- cgit v1.2.3-55-g6feb From 4792618d8882eb36c9e9d05efac8b1ae336f00cb Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Wed, 17 Jun 2015 11:01:48 +0200 Subject: fixed typo --- src/luarocks/cfg.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 6d6a911d..87fb1dda 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -145,7 +145,7 @@ end cfg.variables = {} cfg.rocks_trees = {} --- some extras for the global enviornment in the config files; +-- some extras for the global environment in the config files; cfg.os_getenv = os.getenv cfg.__dump_env = function() -- debug function, calling it from a config file will show all -- cgit v1.2.3-55-g6feb From 83449f223ce59695bbd628abb0fb6c418a713c0f Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Wed, 17 Jun 2015 13:00:29 -0300 Subject: Checks if git is installed When sources are to be fetched using git, check beforehand it is available in the path instead of causing an error. It will show the message: `Error: 'git' program not found. Is git installed? You may want to edit variables.GIT` and exit. refs #381 --- src/luarocks/fetch/git.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index 53fd4445..bea53fc8 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua @@ -40,6 +40,10 @@ function git.get_sources(rockspec, extract, dest_dir, depth) -- Strip off .git from base name if present module = module:gsub("%.git$", "") + if not fs.execute_quiet(git_cmd, "--version") then + return nil, "'"..git_cmd.."' program not found. Is git installed? You may want to edit variables.GIT" + end + local store_dir if not dest_dir then store_dir = fs.make_temp_dir(name_version) -- cgit v1.2.3-55-g6feb From 8d030a06ed62aef4cf0b4648b54b712069a0d3ad Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Thu, 18 Jun 2015 12:26:38 -0300 Subject: Checks if tool is installed (svn, cvs, hg) --- src/luarocks/fetch/cvs.lua | 7 ++++++- src/luarocks/fetch/hg.lua | 6 +++++- src/luarocks/fetch/svn.lua | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/luarocks/fetch/cvs.lua b/src/luarocks/fetch/cvs.lua index cc9fd655..fad1ca0d 100644 --- a/src/luarocks/fetch/cvs.lua +++ b/src/luarocks/fetch/cvs.lua @@ -20,9 +20,14 @@ function cvs.get_sources(rockspec, extract, dest_dir) assert(type(rockspec) == "table") assert(type(dest_dir) == "string" or not dest_dir) + local cvs_cmd = rockspec.variables.CVS + if not fs.execute_quiet(cvs_cmd, "--version") then + return nil, "'"..cvs_cmd.."' program not found. Is CVS installed? You may want to edit variables.CVS" + end + local name_version = rockspec.name .. "-" .. rockspec.version local module = rockspec.source.module or dir.base_name(rockspec.source.url) - local command = {rockspec.variables.CVS, "-d"..rockspec.source.pathname, "export", module} + local command = {cvs_cmd, "-d"..rockspec.source.pathname, "export", module} if rockspec.source.tag then table.insert(command, 4, "-r") table.insert(command, 5, rockspec.source.tag) diff --git a/src/luarocks/fetch/hg.lua b/src/luarocks/fetch/hg.lua index e736a071..055e3bbe 100644 --- a/src/luarocks/fetch/hg.lua +++ b/src/luarocks/fetch/hg.lua @@ -21,9 +21,13 @@ function hg.get_sources(rockspec, extract, dest_dir) assert(type(dest_dir) == "string" or not dest_dir) local hg_cmd = rockspec.variables.HG + if not fs.execute_quiet(hg_cmd, "--version") then + return nil, "'"..hg_cmd.."' program not found. Is Mercurial installed? You may want to edit variables.HG" + end + local name_version = rockspec.name .. "-" .. rockspec.version -- Strip off special hg:// protocol type - local url = rockspec.source.url:gsub("^hg://", "") + local url = rockspec.source.url:gsub("^hg://", "") local module = dir.base_name(url) diff --git a/src/luarocks/fetch/svn.lua b/src/luarocks/fetch/svn.lua index abeacf9a..8fe582f6 100644 --- a/src/luarocks/fetch/svn.lua +++ b/src/luarocks/fetch/svn.lua @@ -21,6 +21,10 @@ function svn.get_sources(rockspec, extract, dest_dir) assert(type(dest_dir) == "string" or not dest_dir) local svn_cmd = rockspec.variables.SVN + if not fs.execute_quiet(svn_cmd, "--version") then + return nil, "'"..svn_cmd.."' program not found. Is Subversion installed? You may want to edit variables.SVN" + end + local name_version = rockspec.name .. "-" .. rockspec.version local module = rockspec.source.module or dir.base_name(rockspec.source.url) local url = rockspec.source.url:gsub("^svn://", "") -- cgit v1.2.3-55-g6feb From 998d012a7228099990a88454150e843559074e0c Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 18 Jun 2015 18:01:19 +0200 Subject: fix: use same environment table for the system config file as well. --- src/luarocks/cfg.lua | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 87fb1dda..6ce2ff24 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -145,28 +145,7 @@ end cfg.variables = {} cfg.rocks_trees = {} --- some extras for the global environment in the config files; -cfg.os_getenv = os.getenv -cfg.__dump_env = function() - -- debug function, calling it from a config file will show all - -- available globals to that config file - print(util.show_table(cfg, "global environment")) -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, cfg) - 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, cfg) - 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 -end - +-- The global environment in the config files; local env_for_config_file env_for_config_file = { home = cfg.home, @@ -174,13 +153,27 @@ env_for_config_file = { platform = util.make_shallow_copy(detected), processor = proc, os_getenv = os.getenv, - __dump_env = function() + dump_env = function() -- debug function, calling it from a config file will show all -- available globals to that config file print(util.show_table(env_for_config_file, "global environment")) 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 +end + if not site_config.LUAROCKS_FORCE_CONFIG then local home_overrides, err, errcode -- cgit v1.2.3-55-g6feb From c9b7f0bc5453251730c73040904a17a8fd32eef3 Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Thu, 18 Jun 2015 16:29:25 -0300 Subject: Factors the code to check for a tool. Changes 'not found' message wording. Adds the function fs.is_tool_available to check if a given tool (git, hg, cmake, etc) is available. --- src/luarocks/build/cmake.lua | 5 +++-- src/luarocks/fetch/cvs.lua | 5 +++-- src/luarocks/fetch/git.lua | 5 +++-- src/luarocks/fetch/hg.lua | 5 +++-- src/luarocks/fetch/svn.lua | 5 +++-- src/luarocks/fs/lua.lua | 21 +++++++++++++++++++++ 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index e5b29147..c8f5a669 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua @@ -23,8 +23,9 @@ function cmake.run(rockspec) util.variable_substitutions(variables, rockspec.variables) - if not fs.execute_quiet(rockspec.variables.CMAKE, "--help") then - return nil, "'"..rockspec.variables.CMAKE.."' program not found. Is cmake installed? You may want to edit variables.CMAKE" + local ok, err_msg = fs.is_tool_available(rockspec.variables.CMAKE, "CMake") + if not ok then + return nil, err_msg end -- If inline cmake is present create CMakeLists.txt from it. diff --git a/src/luarocks/fetch/cvs.lua b/src/luarocks/fetch/cvs.lua index fad1ca0d..ccf928c4 100644 --- a/src/luarocks/fetch/cvs.lua +++ b/src/luarocks/fetch/cvs.lua @@ -21,8 +21,9 @@ function cvs.get_sources(rockspec, extract, dest_dir) assert(type(dest_dir) == "string" or not dest_dir) local cvs_cmd = rockspec.variables.CVS - if not fs.execute_quiet(cvs_cmd, "--version") then - return nil, "'"..cvs_cmd.."' program not found. Is CVS installed? You may want to edit variables.CVS" + local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS") + if not ok then + return nil, err_msg end local name_version = rockspec.name .. "-" .. rockspec.version diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index bea53fc8..e540d696 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua @@ -40,8 +40,9 @@ function git.get_sources(rockspec, extract, dest_dir, depth) -- Strip off .git from base name if present module = module:gsub("%.git$", "") - if not fs.execute_quiet(git_cmd, "--version") then - return nil, "'"..git_cmd.."' program not found. Is git installed? You may want to edit variables.GIT" + local ok, err_msg = fs.is_tool_available(git_cmd, "Git") + if not ok then + return nil, err_msg end local store_dir diff --git a/src/luarocks/fetch/hg.lua b/src/luarocks/fetch/hg.lua index 055e3bbe..518130b4 100644 --- a/src/luarocks/fetch/hg.lua +++ b/src/luarocks/fetch/hg.lua @@ -21,8 +21,9 @@ function hg.get_sources(rockspec, extract, dest_dir) assert(type(dest_dir) == "string" or not dest_dir) local hg_cmd = rockspec.variables.HG - if not fs.execute_quiet(hg_cmd, "--version") then - return nil, "'"..hg_cmd.."' program not found. Is Mercurial installed? You may want to edit variables.HG" + local ok, err_msg = fs.is_tool_available(hg_cmd, "Mercurial") + if not ok then + return nil, err_msg end local name_version = rockspec.name .. "-" .. rockspec.version diff --git a/src/luarocks/fetch/svn.lua b/src/luarocks/fetch/svn.lua index 8fe582f6..755e5e32 100644 --- a/src/luarocks/fetch/svn.lua +++ b/src/luarocks/fetch/svn.lua @@ -21,8 +21,9 @@ function svn.get_sources(rockspec, extract, dest_dir) assert(type(dest_dir) == "string" or not dest_dir) local svn_cmd = rockspec.variables.SVN - if not fs.execute_quiet(svn_cmd, "--version") then - return nil, "'"..svn_cmd.."' program not found. Is Subversion installed? You may want to edit variables.SVN" + local ok, err_msg = fs.is_tool_available(svn_cmd, "--version", "Subversion") + if not ok then + return nil, err_msg end local name_version = rockspec.name .. "-" .. rockspec.version diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index c0f6c1c6..73ae2698 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -122,6 +122,27 @@ function fs_lua.execute_quiet(command, ...) end end +--- Checks if the given tool is available. +-- The tool is executed using a flag, usually just to ask its version. +-- @param tool_cmd string: The command to be used to check the tool's presence (e.g. hg in case of Mercurial) +-- @param tool_name string: The actual name of the tool (e.g. Mercurial) +-- @param arg string: The flag to pass to the tool. '--version' by default. +function fs_lua.is_tool_available(tool_cmd, tool_name, arg) + assert(type(tool_cmd) == "string") + assert(type(tool_name) == "string") + + arg = arg or "--version" + assert(type(arg) == "string") + + if not fs.execute_quiet(tool_cmd, arg) then + 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 'config.lua')" + return nil, msg:format(tool_cmd, tool_name, tool_cmd:upper()) + else + return true + end +end + --- Check the MD5 checksum for a file. -- @param file string: The file to be checked. -- @param md5sum string: The string with the expected MD5 checksum. -- cgit v1.2.3-55-g6feb From fdcecd17fc27eb6c2fab9192b66bb03c3b55bf11 Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Fri, 19 Jun 2015 15:33:11 -0300 Subject: Allows luarocks.cfg to be used without being installed. This allows to address the issue #386 --- src/luarocks/cfg.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 20aa4a21..a02caaee 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -310,7 +310,7 @@ local defaults = { } if detected.windows then - local full_prefix = site_config.LUAROCKS_PREFIX.."\\"..cfg.major_version + 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("\\","/") -- cgit v1.2.3-55-g6feb From d5fa171ad16c7c454e6e2ee63e8ae396b6d64e7e Mon Sep 17 00:00:00 2001 From: Kyle McLamb Date: Sat, 20 Jun 2015 04:54:47 -0700 Subject: fix typo --- install.bat | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/install.bat b/install.bat index d81a25a7..d83dfbf1 100644 --- a/install.bat +++ b/install.bat @@ -90,7 +90,7 @@ local function mkdir (dir) return exec([[.\win32\tools\mkdir -p "]]..dir..[[" >NUL]]) end --- does the current user have admin priviledges ( = elevated) +-- does the current user have admin privileges ( = elevated) local function permission() return exec("net session >NUL 2>&1") -- fails if not admin end @@ -175,7 +175,7 @@ Other options: /F Remove installation directory if it already exists. /NOREG Do not load registry info to register '.rockspec' extension with LuaRocks commands (right-click). -/NOADMIN The installer requires admin priviledges. If not +/NOADMIN The installer requires admin privileges. If not available it will elevate a new process. Use this switch to prevent elevation, but make sure the destination paths are all accessible for the current @@ -550,12 +550,12 @@ check_flags() if not permission() then if not NOADMIN then - -- must elevate the process with admin priviledges + -- must elevate the process with admin privileges if not exec("PowerShell /? >NUL 2>&1") then -- powershell is not available, so error out - die("No administrative priviledges detected and cannot auto-elevate. Please run with admin priviledges or use the /NOADMIN switch") + die("No administrative privileges detected and cannot auto-elevate. Please run with admin privileges or use the /NOADMIN switch") end - print("Need admin priviledges, now elevating a new process to continue installing...") + print("Need admin privileges, now elevating a new process to continue installing...") local runner = os.getenv("TEMP").."\\".."LuaRocks_Installer.bat" local f = io.open(runner, "w") f:write("@echo off\n") @@ -567,13 +567,13 @@ if not permission() then f:close() -- run the created temp batch file in elevated mode exec("PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('"..runner.."', '', '', 'runas')\n") - print("Now exiting unpriviledged installer") + print("Now exiting unprivileged installer") os.exit() -- exit here, the newly created elevated process will do the installing else - print("Attempting to install without admin priviledges...") + print("Attempting to install without admin privileges...") end else - print("Admin priviledges available for installing") + print("Admin privileges available for installing") end vars.PREFIX = vars.PREFIX or os.getenv("PROGRAMFILES")..[[\LuaRocks]] @@ -755,7 +755,7 @@ ECHO ECHO Press any key to close this window... >> "%TMPFILE%" ECHO PAUSE ^> NUL >> "%TMPFILE%" ECHO DEL "%TMPFILE%" >> "%TMPFILE%" -ECHO Now retrying as a priviledged user... +ECHO Now retrying as a privileged user... PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('%TMPFILE%', '', '', 'runas') :EXITLR -- cgit v1.2.3-55-g6feb