Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/luajit-rocks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Collobert <locronan@fb.com>2016-02-02 22:50:44 +0300
committerRonan Collobert <locronan@fb.com>2016-02-02 22:50:44 +0300
commitc6a2f33a7333e2c26c75f88f6bb6ac7e183dc355 (patch)
tree14aab6381760a976217388996236aaf2b618f873
parent512de5ece972e4390994f6545b2cb503c1f5d3a0 (diff)
parentf52070e5743fa91a18538410a4f4a7037012bc35 (diff)
Merge commit 'f52070e5743fa91a18538410a4f4a7037012bc35'
-rw-r--r--luarocks/appveyor.yml4
-rwxr-xr-xluarocks/configure6
-rw-r--r--luarocks/install.bat153
-rwxr-xr-xluarocks/makedist31
-rw-r--r--luarocks/rockspec2
-rw-r--r--luarocks/src/luarocks/cfg.lua10
-rw-r--r--luarocks/src/luarocks/command_line.lua5
-rw-r--r--luarocks/src/luarocks/deps.lua53
-rw-r--r--luarocks/src/luarocks/fs/lua.lua23
-rw-r--r--luarocks/src/luarocks/fs/unix.lua8
-rw-r--r--luarocks/src/luarocks/fs/win32.lua18
-rwxr-xr-xluarocks/test/testing.sh1
12 files changed, 266 insertions, 48 deletions
diff --git a/luarocks/appveyor.yml b/luarocks/appveyor.yml
index d7fc7cc..3f54135 100644
--- a/luarocks/appveyor.yml
+++ b/luarocks/appveyor.yml
@@ -1,9 +1,9 @@
-version: 2.2.1.{build}-test
+version: 2.3.0.{build}-test
shallow_clone: true
environment:
- LUAROCKS_VER: 2.2.1
+ LUAROCKS_VER: 2.3.0
matrix:
- LUA_VER: 5.1.5
diff --git a/luarocks/configure b/luarocks/configure
index 8b99b2a..75ba403 100755
--- a/luarocks/configure
+++ b/luarocks/configure
@@ -71,7 +71,11 @@ EOF
# Helper functions
find_program() {
- command -v "$1" 2>/dev/null
+ prog=`command -v "$1" 2>/dev/null`
+ if [ -n "$prog" ]
+ then
+ dirname "$prog"
+ fi
}
die() {
diff --git a/luarocks/install.bat b/luarocks/install.bat
index e362b31..5acfea6 100644
--- a/luarocks/install.bat
+++ b/luarocks/install.bat
@@ -6,8 +6,9 @@ local vars = {}
vars.PREFIX = nil
-vars.VERSION = "2.2"
+vars.VERSION = "2.3"
vars.SYSCONFDIR = nil
+vars.SYSCONFFORCE = nil
vars.CONFBACKUPDIR = nil
vars.SYSCONFFILENAME = nil
vars.CONFIG_FILE = nil
@@ -29,11 +30,13 @@ vars.LUA_SHORTV = nil -- "51"
vars.LUA_LIB_NAMES = "lua5.1.lib lua51.lib lua5.1.dll lua51.dll liblua.dll.a"
vars.LUA_RUNTIME = nil
vars.UNAME_M = nil
+vars.COMPILER_ENV_CMD = nil
local FORCE = false
local FORCE_CONFIG = false
local INSTALL_LUA = false
local USE_MINGW = false
+local USE_MSVC_MANUAL = false
local REGISTRY = true
local NOADMIN = false
local PROMPT = true
@@ -166,7 +169,14 @@ Configuring the Lua interpreter:
(/LUA, /INC, /LIB, /BIN cannot be used with /L)
Compiler configuration:
-/MW Use mingw as build system instead of MSVC
+ By default the installer will try to determine the
+ Microsoft toolchain to use. And will automatically use
+ a setup command to initialize that toolchain when
+ LuaRocks is run. If it cannot find it, it will default
+ to the /MSVC switch.
+/MSVC Use MS toolchain, without a setup command (tools must
+ be in your path)
+/MW Use mingw as build system (tools must be in your path)
Other options:
/FORCECONFIG Use a single config location. Do not use the
@@ -199,6 +209,7 @@ local function parse_options(args)
vars.PREFIX = option.value
elseif name == "/CONFIG" then
vars.SYSCONFDIR = option.value
+ vars.SYSCONFFORCE = true
elseif name == "/TREE" then
vars.TREE_ROOT = option.value
elseif name == "/SCRIPTS" then
@@ -213,6 +224,8 @@ local function parse_options(args)
INSTALL_LUA = true
elseif name == "/MW" then
USE_MINGW = true
+ elseif name == "/MSVC" then
+ USE_MSVC_MANUAL = true
elseif name == "/LUA" then
vars.LUA_PREFIX = option.value
elseif name == "/LIB" then
@@ -266,6 +279,9 @@ local function check_flags()
die("Bad argument: /LV must either be 5.1, 5.2, or 5.3")
end
end
+ if USE_MSVC_MANUAL and USE_MINGW then
+ die("Cannot combine option /MSVC and /MW")
+ end
end
-- ***********************************************************
@@ -408,6 +424,117 @@ local function get_architecture()
return proc
end
+-- get a string value from windows registry.
+local function get_registry(key, value)
+ local keys = {key}
+ local key64, replaced = key:gsub("(%u+\\Software\\)", "\1Wow6432Node\\", 1)
+
+ if replaced == 1 then
+ keys = {key64, key}
+ end
+
+ for _, k in ipairs(keys) do
+ local h = io.popen('reg query "'..k..'" /v '..value..' 2>NUL')
+ local output = h:read("*a")
+ h:close()
+
+ local v = output:match("REG_SZ%s+([^\n]+)")
+ if v then
+ return v
+ end
+ end
+ return nil
+end
+
+local function get_visual_studio_directory()
+ assert(type(vars.LUA_RUNTIME)=="string", "requires vars.LUA_RUNTIME to be set before calling this function.")
+ local major, minor = vars.LUA_RUNTIME:match('VCR%u*(%d+)(%d)$') -- MSVCR<x><y> or VCRUNTIME<x><y>
+ if not major then
+ print(S[[ Cannot auto-detect Visual Studio version from $LUA_RUNTIME]])
+ return nil
+ end
+ local keys = {
+ "HKLM\\Software\\Microsoft\\VisualStudio\\%d.%d\\Setup\\VC",
+ "HKLM\\Software\\Microsoft\\VCExpress\\%d.%d\\Setup\\VS"
+ }
+ for _, key in ipairs(keys) do
+ local versionedkey = key:format(major, minor)
+ local vcdir = get_registry(versionedkey, "ProductDir")
+ print(" checking: "..versionedkey)
+ if vcdir then
+ print(" Found: "..vcdir)
+ return vcdir
+ end
+ end
+ return nil
+end
+
+local function get_windows_sdk_directory()
+ assert(type(vars.LUA_RUNTIME) == "string", "requires vars.LUA_RUNTIME to be set before calling this function.")
+ -- Only v7.1 and v6.1 shipped with compilers
+ -- Other versions requires a separate installation of Visual Studio.
+ -- see https://github.com/keplerproject/luarocks/pull/443#issuecomment-152792516
+ local wsdks = {
+ ["MSVCR100"] = "v7.1", -- shipped with Visual Studio 2010 compilers.
+ ["MSVCR100D"] = "v7.1", -- shipped with Visual Studio 2010 compilers.
+ ["MSVCR90"] = "v6.1", -- shipped with Visual Studio 2008 compilers.
+ ["MSVCR90D"] = "v6.1", -- shipped with Visual Studio 2008 compilers.
+ }
+ local wsdkver = wsdks[vars.LUA_RUNTIME]
+ if not wsdkver then
+ print(S[[ Cannot auto-detect Windows SDK version from $LUA_RUNTIME]])
+ return nil
+ end
+
+ local key = "HKLM\\Software\\Microsoft\\Microsoft SDKs\\Windows\\"..wsdkver
+ print(" checking: "..key)
+ local dir = get_registry(key, "InstallationFolder")
+ if dir then
+ print(" Found: "..dir)
+ return dir
+ end
+ print(" No SDK found")
+ return nil
+end
+
+-- returns the batch command to setup msvc compiler path.
+-- or an empty string (eg. "") if not found
+local function get_msvc_env_setup_cmd()
+ print(S[[Looking for Microsoft toolchain matching runtime $LUA_RUNTIME and architecture $UNAME_M]])
+
+ assert(type(vars.UNAME_M) == "string", "requires vars.UNAME_M to be set before calling this function.")
+ local x64 = vars.UNAME_M=="x86_64"
+
+ -- 1. try visual studio command line tools
+ local vcdir = get_visual_studio_directory()
+ if vcdir then
+ -- 1.1. try vcvarsall.bat
+ local vcvarsall = vcdir .. 'vcvarsall.bat'
+ if exists(vcvarsall) then
+ return ('call "%s"%s'):format(vcvarsall, x64 and ' amd64' or '')
+ end
+
+ -- 1.2. try vcvars32.bat / vcvars64.bat
+ local relative_path = x64 and "bin\\amd64\\vcvars64.bat" or "bin\\vcvars32.bat"
+ local full_path = vcdir .. relative_path
+ if exists(full_path) then
+ return ('call "%s"'):format(full_path)
+ end
+ end
+
+ -- 2. try for Windows SDKs command line tools.
+ local wsdkdir = get_windows_sdk_directory()
+ if wsdkdir then
+ local setenv = wsdkdir.."Bin\\SetEnv.cmd"
+ if exists(setenv) then
+ return ('call "%s" /%s'):format(setenv, x64 and "x64" or "x86")
+ end
+ end
+
+ -- finally, we can't detect more, just don't setup the msvc compiler in luarocks.bat.
+ return ""
+end
+
local function look_for_lua_install ()
print("Looking for Lua interpreter")
local directories
@@ -650,9 +777,11 @@ vars.SYSCONFFILENAME = S"config-$LUA_VERSION.lua"
vars.CONFIG_FILE = vars.SYSCONFDIR.."\\"..vars.SYSCONFFILENAME
if SELFCONTAINED then
vars.SYSCONFDIR = vars.PREFIX
+ vars.SYSCONFFORCE = true
vars.TREE_ROOT = vars.PREFIX..[[\systree]]
REGISTRY = false
end
+vars.COMPILER_ENV_CMD = (USE_MINGW and "") or (USE_MSVC_MANUAL and "") or get_msvc_env_setup_cmd()
print(S[[
@@ -671,11 +800,20 @@ Lua interpreter : $LUA_BINDIR\$LUA_INTERPRETER
includes : $LUA_INCDIR
architecture: $UNAME_M
binary link : $LUA_LIBNAME with runtime $LUA_RUNTIME.dll
-
]])
+if USE_MINGW then
+ print("Compiler : MinGW (make sure it is in your path before using LuaRocks)")
+else
+ if vars.COMPILER_ENV_CMD == "" then
+ print("Compiler : Microsoft (make sure it is in your path before using LuaRocks)")
+ else
+ print(S[[Compiler : Microsoft, using; $COMPILER_ENV_CMD]])
+ end
+end
+
if PROMPT then
- print("Press <ENTER> to start installing, or press <CTRL>+<C> to abort. Use install /? for installation options.")
+ print("\nPress <ENTER> to start installing, or press <CTRL>+<C> to abort. Use install /? for installation options.")
io.read()
end
@@ -758,7 +896,8 @@ for _, c in ipairs{"luarocks", "luarocks-admin"} do
local f = io.open(vars.BINDIR.."\\"..c..".bat", "w")
f:write(S[[
@ECHO OFF
-SETLOCAL
+SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
+$COMPILER_ENV_CMD
SET "LUA_PATH=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH%"
IF NOT "%LUA_PATH_5_2%"=="" (
SET "LUA_PATH_5_2=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH_5_2%"
@@ -835,7 +974,6 @@ else
end
f:write(S[=[
site_config.LUAROCKS_UNAME_M=[[$UNAME_M]]
-site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]
site_config.LUAROCKS_ROCKS_TREE=[[$TREE_ROOT]]
site_config.LUAROCKS_PREFIX=[[$PREFIX]]
site_config.LUAROCKS_DOWNLOADER=[[wget]]
@@ -844,6 +982,9 @@ site_config.LUAROCKS_MD5CHECKER=[[md5sum]]
if FORCE_CONFIG then
f:write("site_config.LUAROCKS_FORCE_CONFIG=true\n")
end
+if vars.SYSCONFFORCE then -- only write this value when explcitly given, otherwise rely on defaults
+ f:write(S("site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]\n"))
+end
f:write("return site_config\n")
f:close()
print(S([[Created LuaRocks site-config file: $LUADIR\luarocks\]]..site_config..[[.lua]]))
diff --git a/luarocks/makedist b/luarocks/makedist
index 1a9ca99..fb41b98 100755
--- a/luarocks/makedist
+++ b/luarocks/makedist
@@ -16,13 +16,40 @@ make clean || exit 1
grep -q "\"$1\"" rockspec || {
echo
- echo "Version in rockspec is incorrect. Please fix it."
+ echo "version in rockspec is incorrect. Please fix it."
exit 1
}
grep -q "program_version = \"$1\"" src/luarocks/cfg.lua || {
echo
- echo "Version in src/luarocks/cfg.lua is incorrect. Please fix it."
+ echo "program_version in src/luarocks/cfg.lua is incorrect. Please fix it."
+ exit 1
+}
+
+grep -q "version: $1\\." appveyor.yml || {
+ echo
+ echo "version in appveyor.yml is incorrect. Please fix it."
+ exit 1
+}
+
+grep -q "LUAROCKS_VER: $1" appveyor.yml || {
+ echo
+ echo "LUAROCKS_VER in appveyor.yml is incorrect. Please fix it."
+ exit 1
+}
+
+# e.g. if $1 is "2.3.0", $program_series is "2.3"
+program_series=${1%.*}
+
+grep -q "program_series = \"$program_series\"" src/luarocks/cfg.lua || {
+ echo
+ echo "program_series in src/luarocks/cfg.lua is incorrect. Please fix it."
+ exit 1
+}
+
+grep -q "vars.VERSION = \"$program_series\"" install.bat || {
+ echo
+ echo "vars.VERSION in install.bat is incorrect. Please fix it."
exit 1
}
diff --git a/luarocks/rockspec b/luarocks/rockspec
index bb7645f..60c55e9 100644
--- a/luarocks/rockspec
+++ b/luarocks/rockspec
@@ -1,5 +1,5 @@
package = "LuaRocks"
-local VER = "scm"
+local VER = "2.3.0"
version = VER .. "-1"
source = {
diff --git a/luarocks/src/luarocks/cfg.lua b/luarocks/src/luarocks/cfg.lua
index 21bb5d0..b7a3cbd 100644
--- a/luarocks/src/luarocks/cfg.lua
+++ b/luarocks/src/luarocks/cfg.lua
@@ -32,8 +32,8 @@ if not ok then
site_config = {}
end
-cfg.program_version = "scm"
-cfg.program_series = "2.2"
+cfg.program_version = "2.3.0"
+cfg.program_series = "2.3"
cfg.major_version = (cfg.program_version:match("([^.]%.[^.])")) or cfg.program_series
cfg.variables = {}
cfg.rocks_trees = {}
@@ -149,7 +149,7 @@ 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
+sys_config_dir = site_config.LUAROCKS_SYSCONFDIR or site_config.LUAROCKS_PREFIX
if cfg.platforms.windows then
cfg.home = os.getenv("APPDATA") or "c:"
sys_config_dir = sys_config_dir or "c:/luarocks"
@@ -664,7 +664,7 @@ function cfg.init_package_paths()
end
function cfg.which_config()
- return {
+ local ret = {
system = {
file = sys_config_file or sys_config_file_default,
ok = sys_config_ok,
@@ -674,6 +674,8 @@ function cfg.which_config()
ok = home_config_ok,
}
}
+ ret.nearest = (ret.user.ok and ret.user.file) or ret.system.file
+ return ret
end
cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch
diff --git a/luarocks/src/luarocks/command_line.lua b/luarocks/src/luarocks/command_line.lua
index dbf64b9..e1c9f49 100644
--- a/luarocks/src/luarocks/command_line.lua
+++ b/luarocks/src/luarocks/command_line.lua
@@ -31,12 +31,17 @@ end
local function replace_tree(flags, args, tree)
tree = dir.normalize(tree)
flags["tree"] = tree
+ local added = false
for i = 1, #args do
if args[i]:match("%-%-tree=") then
args[i] = "--tree="..tree
+ added = true
break
end
end
+ if not added then
+ args[#args + 1] = "--tree="..tree
+ end
path.use_tree(tree)
end
diff --git a/luarocks/src/luarocks/deps.lua b/luarocks/src/luarocks/deps.lua
index 0e3265b..eb01075 100644
--- a/luarocks/src/luarocks/deps.lua
+++ b/luarocks/src/luarocks/deps.lua
@@ -545,10 +545,11 @@ function deps.check_external_deps(rockspec, mode)
subdirs = cfg.runtime_external_deps_subdirs
end
if rockspec.external_dependencies then
- for name, files in pairs(rockspec.external_dependencies) do
+ for name, ext_files in util.sortedpairs(rockspec.external_dependencies) do
local ok = true
- local failed_file = nil
- local failed_dirname = nil
+ local failed_files = {program = {}, header = {}, library = {}}
+ local failed_dirname
+ local failed_testfile
for _, extdir in ipairs(cfg.external_deps_dirs) do
ok = true
local prefix = vars[name.."_DIR"]
@@ -577,7 +578,7 @@ function deps.check_external_deps(rockspec, mode)
end
prefix = prefix.prefix
end
- for dirname, dirdata in pairs(dirs) do
+ for dirname, dirdata in util.sortedpairs(dirs) do
local paths
local path_var_value = vars[name.."_"..dirname]
if path_var_value then
@@ -591,7 +592,7 @@ function deps.check_external_deps(rockspec, mode)
paths = { dir.path(prefix, dirdata.subdir) }
end
dirdata.dir = paths[1]
- local file = files[dirdata.testfile]
+ local file = ext_files[dirdata.testfile]
if file then
local files = {}
if not file:match("%.") then
@@ -606,19 +607,23 @@ function deps.check_external_deps(rockspec, mode)
table.insert(files, file)
end
local found = false
- failed_file = nil
- for _, f in pairs(files) do
-
+ for _, f in ipairs(files) do
+
-- small convenience hack
if f:match("%.so$") or f:match("%.dylib$") or f:match("%.dll$") then
f = f:gsub("%.[^.]+$", "."..cfg.external_lib_extension)
end
-
+
+ local pattern
+ if f:match("%*") then
+ pattern = f:gsub("%.", "%%."):gsub("%*", ".*")
+ f = "matching "..f
+ end
+
for _, d in ipairs(paths) do
- if f:match("%*") then
- local replaced = f:gsub("%.", "%%."):gsub("%*", ".*")
+ if pattern then
for entry in fs.dir(d) do
- if entry:match(replaced) then
+ if entry:match(pattern) then
found = true
break
end
@@ -629,21 +634,18 @@ function deps.check_external_deps(rockspec, mode)
if found then
dirdata.dir = d
break
+ else
+ table.insert(failed_files[dirdata.testfile], f.." in "..d)
end
end
if found then
break
- else
- if failed_file then
- failed_file = failed_file .. ", or " .. f
- else
- failed_file = f
- end
end
end
if not found then
ok = false
failed_dirname = dirname
+ failed_testfile = dirdata.testfile
break
end
end
@@ -657,7 +659,20 @@ function deps.check_external_deps(rockspec, mode)
end
end
if not ok then
- return nil, "Could not find expected file "..failed_file.." for "..name.." -- you may have to install "..name.." in your system and/or pass "..name.."_DIR or "..name.."_"..failed_dirname.." to the luarocks command. Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local", "dependency"
+ local lines = {"Could not find "..failed_testfile.." file for "..name}
+
+ local failed_paths = {}
+ for _, failed_file in ipairs(failed_files[failed_testfile]) do
+ if not failed_paths[failed_file] then
+ failed_paths[failed_file] = true
+ table.insert(lines, " No file "..failed_file)
+ end
+ end
+
+ table.insert(lines, "You may have to install "..name.." in your system and/or pass "..name.."_DIR or "..name.."_"..failed_dirname.." to the luarocks command.")
+ table.insert(lines, "Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local")
+
+ return nil, table.concat(lines, "\n"), "dependency"
end
end
end
diff --git a/luarocks/src/luarocks/fs/lua.lua b/luarocks/src/luarocks/fs/lua.lua
index 73ae269..a444f01 100644
--- a/luarocks/src/luarocks/fs/lua.lua
+++ b/luarocks/src/luarocks/fs/lua.lua
@@ -134,10 +134,10 @@ function fs_lua.is_tool_available(tool_cmd, tool_name, arg)
arg = arg or "--version"
assert(type(arg) == "string")
- if not fs.execute_quiet(tool_cmd, arg) then
+ if not fs.execute_quiet(fs.Q(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())
+ "(or you may want to edit the 'variables.%s' value in file '%s')"
+ return nil, msg:format(tool_cmd, tool_name, tool_name:upper(), cfg.which_config().nearest)
else
return true
end
@@ -833,10 +833,19 @@ function fs_lua.check_command_permissions(flags)
break
end
end
- local root_parent = dir.dir_name(root_dir)
- if ok and not fs.exists(root_dir) and not fs.is_writable(root_parent) then
- ok = false
- err = root_dir.." does not exist and your user does not have write permissions in " .. root_parent
+ if ok and not fs.exists(root_dir) then
+ local root = fs.root_of(root_dir)
+ local parent = root_dir
+ repeat
+ parent = dir.dir_name(parent)
+ if parent == "" then
+ parent = root
+ end
+ until parent == root or fs.exists(parent)
+ if not fs.is_writable(parent) then
+ ok = false
+ err = root_dir.." does not exist and your user does not have write permissions in " .. parent
+ end
end
if ok then
return true
diff --git a/luarocks/src/luarocks/fs/unix.lua b/luarocks/src/luarocks/fs/unix.lua
index 6ad5a67..8eb3386 100644
--- a/luarocks/src/luarocks/fs/unix.lua
+++ b/luarocks/src/luarocks/fs/unix.lua
@@ -36,6 +36,14 @@ function unix.absolute_name(pathname, relative_to)
end
end
+--- Return the root directory for the given path.
+-- In Unix, root is always "/".
+-- @param pathname string: pathname to use.
+-- @return string: The root of the given pathname.
+function unix.root_of(_)
+ return "/"
+end
+
--- Create a wrapper to make a script executable from the command-line.
-- @param file string: Pathname of script to be made executable.
-- @param dest string: Directory where to put the wrapper.
diff --git a/luarocks/src/luarocks/fs/win32.lua b/luarocks/src/luarocks/fs/win32.lua
index 32766e5..0c8cc9e 100644
--- a/luarocks/src/luarocks/fs/win32.lua
+++ b/luarocks/src/luarocks/fs/win32.lua
@@ -18,7 +18,6 @@ local _popen, _execute = io.popen, os.execute
io.popen = function(cmd, ...) return _popen(_prefix..cmd, ...) end
os.execute = function(cmd, ...) return _execute(_prefix..cmd, ...) end
-
--- Annotate command string for quiet execution.
-- @param cmd string: A command-line string.
-- @return string: The command-line, with silencing annotation.
@@ -26,6 +25,7 @@ function win32.quiet(cmd)
return cmd.." 2> NUL 1> NUL"
end
+local drive_letter = "[%.a-zA-Z]?:?[\\/]"
local win_escape_chars = {
["%"] = "%%",
@@ -47,7 +47,7 @@ end
function win32.Q(arg)
assert(type(arg) == "string")
-- Quote DIR for Windows
- if arg:match("^[%.a-zA-Z]?:?[\\/]") then
+ if arg:match("^"..drive_letter) then
arg = arg:gsub("/", "\\")
end
if arg == "\\" then
@@ -68,7 +68,7 @@ end
function win32.Qb(arg)
assert(type(arg) == "string")
-- Quote DIR for Windows
- if arg:match("^[%.a-zA-Z]?:?[\\/]") then
+ if arg:match("^"..drive_letter) then
arg = arg:gsub("/", "\\")
end
if arg == "\\" then
@@ -92,15 +92,21 @@ function win32.absolute_name(pathname, relative_to)
assert(type(relative_to) == "string" or not relative_to)
relative_to = relative_to or fs.current_dir()
- -- FIXME I'm not sure this first \\ should be there at all.
- -- What are the Windows rules for drive letters?
- if pathname:match("^[\\.a-zA-Z]?:?[\\/]") then
+ if pathname:match("^"..drive_letter) then
return pathname
else
return relative_to .. "/" .. pathname
end
end
+--- Return the root directory for the given path.
+-- For example, for "c:\hello", returns "c:\"
+-- @param pathname string: pathname to use.
+-- @return string: The root of the given pathname.
+function win32.root_of(pathname)
+ return (fs.absolute_name(pathname):match("^("..drive_letter..")"))
+end
+
--- Create a wrapper to make a script executable from the command-line.
-- @param file string: Pathname of script to be made executable.
-- @param dest string: Directory where to put the wrapper.
diff --git a/luarocks/test/testing.sh b/luarocks/test/testing.sh
index 26bdde5..70bd68b 100755
--- a/luarocks/test/testing.sh
+++ b/luarocks/test/testing.sh
@@ -244,6 +244,7 @@ mkdir -p "$testing_server"
get "$luarocks_repo/validate-args-1.5.4-1.rockspec"
get "$luarocks_repo/luasec-0.5-2.rockspec"
get "$luarocks_repo/luabitop-1.0.2-1.rockspec"
+ get "$luarocks_repo/luabitop-1.0.2-1.src.rock"
get "$luarocks_repo/lpty-1.0.1-1.src.rock"
get "$luarocks_repo/cprint-${verrev_cprint}.src.rock"
get "$luarocks_repo/cprint-${verrev_cprint}.rockspec"