aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.setup.inc10
-rw-r--r--appveyor.yml2
-rw-r--r--install.bat20
-rw-r--r--src/luarocks/build/cmake.lua5
-rw-r--r--src/luarocks/cfg.lua28
-rw-r--r--src/luarocks/fetch/cvs.lua8
-rw-r--r--src/luarocks/fetch/git.lua5
-rw-r--r--src/luarocks/fetch/hg.lua7
-rw-r--r--src/luarocks/fetch/svn.lua5
-rw-r--r--src/luarocks/fs/lua.lua21
10 files changed, 81 insertions, 30 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)/
7BIN_FILES = luarocks luarocks-admin 7BIN_FILES = luarocks luarocks-admin
8LUAROCKS_FILES = fs/unix/tools.lua fs/unix.lua fs/win32/tools.lua fs/win32.lua \ 8LUAROCKS_FILES = fs/unix/tools.lua fs/unix.lua fs/win32/tools.lua fs/win32.lua \
9fs/lua.lua persist.lua list.lua require.lua repos.lua dir.lua make_manifest.lua \ 9fs/lua.lua persist.lua list.lua require.lua repos.lua dir.lua make_manifest.lua \
10command_line.lua install.lua build/command.lua build/cmake.lua build/make.lua \ 10command_line.lua config_cmd.lua install.lua build/command.lua build/cmake.lua \
11build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua tools/patch.lua \ 11build/make.lua build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua \
12fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua make.lua \ 12tools/patch.lua fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua \
13remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua show.lua \ 13make.lua remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua \
14manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ 14show.lua manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \
15help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \ 15help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \
16admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \ 16admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \
17purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \ 17purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \
diff --git a/appveyor.yml b/appveyor.yml
index 436c341b..140308ce 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -12,7 +12,7 @@ environment:
12 - LUA_VER: 5.1.5 12 - LUA_VER: 5.1.5
13 - LUA_VER: 5.2.4 13 - LUA_VER: 5.2.4
14 - LUA_VER: 5.3.0 14 - LUA_VER: 5.3.0
15 - LJ_VER: 2.0.3 15 - LJ_VER: 2.0.4
16 - LJ_VER: 2.1 16 - LJ_VER: 2.1
17 17
18init: 18init:
diff --git a/install.bat b/install.bat
index ffde28db..d83dfbf1 100644
--- a/install.bat
+++ b/install.bat
@@ -90,7 +90,7 @@ local function mkdir (dir)
90 return exec([[.\win32\tools\mkdir -p "]]..dir..[[" >NUL]]) 90 return exec([[.\win32\tools\mkdir -p "]]..dir..[[" >NUL]])
91end 91end
92 92
93-- does the current user have admin priviledges ( = elevated) 93-- does the current user have admin privileges ( = elevated)
94local function permission() 94local function permission()
95 return exec("net session >NUL 2>&1") -- fails if not admin 95 return exec("net session >NUL 2>&1") -- fails if not admin
96end 96end
@@ -175,7 +175,7 @@ Other options:
175/F Remove installation directory if it already exists. 175/F Remove installation directory if it already exists.
176/NOREG Do not load registry info to register '.rockspec' 176/NOREG Do not load registry info to register '.rockspec'
177 extension with LuaRocks commands (right-click). 177 extension with LuaRocks commands (right-click).
178/NOADMIN The installer requires admin priviledges. If not 178/NOADMIN The installer requires admin privileges. If not
179 available it will elevate a new process. Use this 179 available it will elevate a new process. Use this
180 switch to prevent elevation, but make sure the 180 switch to prevent elevation, but make sure the
181 destination paths are all accessible for the current 181 destination paths are all accessible for the current
@@ -319,7 +319,7 @@ local function look_for_interpreter (directory)
319 return true 319 return true
320 end 320 end
321 end 321 end
322 print(" No Lua interpreter found") 322 --print(" No Lua interpreter found")
323 return false 323 return false
324end 324end
325 325
@@ -550,12 +550,12 @@ check_flags()
550 550
551if not permission() then 551if not permission() then
552 if not NOADMIN then 552 if not NOADMIN then
553 -- must elevate the process with admin priviledges 553 -- must elevate the process with admin privileges
554 if not exec("PowerShell /? >NUL 2>&1") then 554 if not exec("PowerShell /? >NUL 2>&1") then
555 -- powershell is not available, so error out 555 -- powershell is not available, so error out
556 die("No administrative priviledges detected and cannot auto-elevate. Please run with admin priviledges or use the /NOADMIN switch") 556 die("No administrative privileges detected and cannot auto-elevate. Please run with admin privileges or use the /NOADMIN switch")
557 end 557 end
558 print("Need admin priviledges, now elevating a new process to continue installing...") 558 print("Need admin privileges, now elevating a new process to continue installing...")
559 local runner = os.getenv("TEMP").."\\".."LuaRocks_Installer.bat" 559 local runner = os.getenv("TEMP").."\\".."LuaRocks_Installer.bat"
560 local f = io.open(runner, "w") 560 local f = io.open(runner, "w")
561 f:write("@echo off\n") 561 f:write("@echo off\n")
@@ -567,13 +567,13 @@ if not permission() then
567 f:close() 567 f:close()
568 -- run the created temp batch file in elevated mode 568 -- run the created temp batch file in elevated mode
569 exec("PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('"..runner.."', '', '', 'runas')\n") 569 exec("PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('"..runner.."', '', '', 'runas')\n")
570 print("Now exiting unpriviledged installer") 570 print("Now exiting unprivileged installer")
571 os.exit() -- exit here, the newly created elevated process will do the installing 571 os.exit() -- exit here, the newly created elevated process will do the installing
572 else 572 else
573 print("Attempting to install without admin priviledges...") 573 print("Attempting to install without admin privileges...")
574 end 574 end
575else 575else
576 print("Admin priviledges available for installing") 576 print("Admin privileges available for installing")
577end 577end
578 578
579vars.PREFIX = vars.PREFIX or os.getenv("PROGRAMFILES")..[[\LuaRocks]] 579vars.PREFIX = vars.PREFIX or os.getenv("PROGRAMFILES")..[[\LuaRocks]]
@@ -755,7 +755,7 @@ ECHO ECHO Press any key to close this window... >> "%TMPFILE%"
755ECHO PAUSE ^> NUL >> "%TMPFILE%" 755ECHO PAUSE ^> NUL >> "%TMPFILE%"
756ECHO DEL "%TMPFILE%" >> "%TMPFILE%" 756ECHO DEL "%TMPFILE%" >> "%TMPFILE%"
757 757
758ECHO Now retrying as a priviledged user... 758ECHO Now retrying as a privileged user...
759PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('%TMPFILE%', '', '', 'runas') 759PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('%TMPFILE%', '', '', 'runas')
760 760
761:EXITLR 761:EXITLR
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)
23 23
24 util.variable_substitutions(variables, rockspec.variables) 24 util.variable_substitutions(variables, rockspec.variables)
25 25
26 if not fs.execute_quiet(rockspec.variables.CMAKE, "--help") then 26 local ok, err_msg = fs.is_tool_available(rockspec.variables.CMAKE, "CMake")
27 return nil, "'"..rockspec.variables.CMAKE.."' program not found. Is cmake installed? You may want to edit variables.CMAKE" 27 if not ok then
28 return nil, err_msg
28 end 29 end
29 30
30 -- If inline cmake is present create CMakeLists.txt from it. 31 -- If inline cmake is present create CMakeLists.txt from it.
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 52b8c089..73a8ecb2 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -145,13 +145,28 @@ end
145cfg.variables = {} 145cfg.variables = {}
146cfg.rocks_trees = {} 146cfg.rocks_trees = {}
147 147
148-- The global environment in the config files;
149local env_for_config_file
150env_for_config_file = {
151 home = cfg.home,
152 lua_version = cfg.lua_version,
153 platform = util.make_shallow_copy(detected),
154 processor = proc,
155 os_getenv = os.getenv,
156 dump_env = function()
157 -- debug function, calling it from a config file will show all
158 -- available globals to that config file
159 print(util.show_table(env_for_config_file, "global environment"))
160 end,
161}
162
148sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" 163sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua"
149do 164do
150 local err, errcode 165 local err, errcode
151 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) 166 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file)
152 if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file 167 if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file
153 sys_config_file = sys_config_dir.."/config.lua" 168 sys_config_file = sys_config_dir.."/config.lua"
154 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) 169 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file)
155 end 170 end
156 if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error 171 if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error
157 io.stderr:write(err.."\n") 172 io.stderr:write(err.."\n")
@@ -159,13 +174,6 @@ do
159 end 174 end
160end 175end
161 176
162local env_for_config_file = {
163 home = cfg.home,
164 lua_version = cfg.lua_version,
165 platform = util.make_shallow_copy(detected),
166 processor = proc,
167}
168
169if not site_config.LUAROCKS_FORCE_CONFIG then 177if not site_config.LUAROCKS_FORCE_CONFIG then
170 178
171 local home_overrides, err, errcode 179 local home_overrides, err, errcode
@@ -309,7 +317,7 @@ local defaults = {
309} 317}
310 318
311if detected.windows then 319if detected.windows then
312 local full_prefix = site_config.LUAROCKS_PREFIX.."\\"..cfg.major_version 320 local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])).."\\"..cfg.major_version
313 extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" 321 extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua"
314 322
315 home_config_file = home_config_file and home_config_file:gsub("\\","/") 323 home_config_file = home_config_file and home_config_file:gsub("\\","/")
diff --git a/src/luarocks/fetch/cvs.lua b/src/luarocks/fetch/cvs.lua
index cc9fd655..ccf928c4 100644
--- a/src/luarocks/fetch/cvs.lua
+++ b/src/luarocks/fetch/cvs.lua
@@ -20,9 +20,15 @@ function cvs.get_sources(rockspec, extract, dest_dir)
20 assert(type(rockspec) == "table") 20 assert(type(rockspec) == "table")
21 assert(type(dest_dir) == "string" or not dest_dir) 21 assert(type(dest_dir) == "string" or not dest_dir)
22 22
23 local cvs_cmd = rockspec.variables.CVS
24 local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS")
25 if not ok then
26 return nil, err_msg
27 end
28
23 local name_version = rockspec.name .. "-" .. rockspec.version 29 local name_version = rockspec.name .. "-" .. rockspec.version
24 local module = rockspec.source.module or dir.base_name(rockspec.source.url) 30 local module = rockspec.source.module or dir.base_name(rockspec.source.url)
25 local command = {rockspec.variables.CVS, "-d"..rockspec.source.pathname, "export", module} 31 local command = {cvs_cmd, "-d"..rockspec.source.pathname, "export", module}
26 if rockspec.source.tag then 32 if rockspec.source.tag then
27 table.insert(command, 4, "-r") 33 table.insert(command, 4, "-r")
28 table.insert(command, 5, rockspec.source.tag) 34 table.insert(command, 5, rockspec.source.tag)
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua
index 53fd4445..e540d696 100644
--- a/src/luarocks/fetch/git.lua
+++ b/src/luarocks/fetch/git.lua
@@ -40,6 +40,11 @@ function git.get_sources(rockspec, extract, dest_dir, depth)
40 -- Strip off .git from base name if present 40 -- Strip off .git from base name if present
41 module = module:gsub("%.git$", "") 41 module = module:gsub("%.git$", "")
42 42
43 local ok, err_msg = fs.is_tool_available(git_cmd, "Git")
44 if not ok then
45 return nil, err_msg
46 end
47
43 local store_dir 48 local store_dir
44 if not dest_dir then 49 if not dest_dir then
45 store_dir = fs.make_temp_dir(name_version) 50 store_dir = fs.make_temp_dir(name_version)
diff --git a/src/luarocks/fetch/hg.lua b/src/luarocks/fetch/hg.lua
index e736a071..518130b4 100644
--- a/src/luarocks/fetch/hg.lua
+++ b/src/luarocks/fetch/hg.lua
@@ -21,9 +21,14 @@ function hg.get_sources(rockspec, extract, dest_dir)
21 assert(type(dest_dir) == "string" or not dest_dir) 21 assert(type(dest_dir) == "string" or not dest_dir)
22 22
23 local hg_cmd = rockspec.variables.HG 23 local hg_cmd = rockspec.variables.HG
24 local ok, err_msg = fs.is_tool_available(hg_cmd, "Mercurial")
25 if not ok then
26 return nil, err_msg
27 end
28
24 local name_version = rockspec.name .. "-" .. rockspec.version 29 local name_version = rockspec.name .. "-" .. rockspec.version
25 -- Strip off special hg:// protocol type 30 -- Strip off special hg:// protocol type
26 local url = rockspec.source.url:gsub("^hg://", "") 31 local url = rockspec.source.url:gsub("^hg://", "")
27 32
28 local module = dir.base_name(url) 33 local module = dir.base_name(url)
29 34
diff --git a/src/luarocks/fetch/svn.lua b/src/luarocks/fetch/svn.lua
index abeacf9a..755e5e32 100644
--- a/src/luarocks/fetch/svn.lua
+++ b/src/luarocks/fetch/svn.lua
@@ -21,6 +21,11 @@ function svn.get_sources(rockspec, extract, dest_dir)
21 assert(type(dest_dir) == "string" or not dest_dir) 21 assert(type(dest_dir) == "string" or not dest_dir)
22 22
23 local svn_cmd = rockspec.variables.SVN 23 local svn_cmd = rockspec.variables.SVN
24 local ok, err_msg = fs.is_tool_available(svn_cmd, "--version", "Subversion")
25 if not ok then
26 return nil, err_msg
27 end
28
24 local name_version = rockspec.name .. "-" .. rockspec.version 29 local name_version = rockspec.name .. "-" .. rockspec.version
25 local module = rockspec.source.module or dir.base_name(rockspec.source.url) 30 local module = rockspec.source.module or dir.base_name(rockspec.source.url)
26 local url = rockspec.source.url:gsub("^svn://", "") 31 local url = rockspec.source.url:gsub("^svn://", "")
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, ...)
122 end 122 end
123end 123end
124 124
125--- Checks if the given tool is available.
126-- The tool is executed using a flag, usually just to ask its version.
127-- @param tool_cmd string: The command to be used to check the tool's presence (e.g. hg in case of Mercurial)
128-- @param tool_name string: The actual name of the tool (e.g. Mercurial)
129-- @param arg string: The flag to pass to the tool. '--version' by default.
130function fs_lua.is_tool_available(tool_cmd, tool_name, arg)
131 assert(type(tool_cmd) == "string")
132 assert(type(tool_name) == "string")
133
134 arg = arg or "--version"
135 assert(type(arg) == "string")
136
137 if not fs.execute_quiet(tool_cmd, arg) then
138 local msg = "'%s' program not found. Make sure %s is installed and is available in your PATH " ..
139 "(or you may want to edit the 'variables.%s' value in file 'config.lua')"
140 return nil, msg:format(tool_cmd, tool_name, tool_cmd:upper())
141 else
142 return true
143 end
144end
145
125--- Check the MD5 checksum for a file. 146--- Check the MD5 checksum for a file.
126-- @param file string: The file to be checked. 147-- @param file string: The file to be checked.
127-- @param md5sum string: The string with the expected MD5 checksum. 148-- @param md5sum string: The string with the expected MD5 checksum.