diff options
-rw-r--r-- | GNUmakefile | 6 | ||||
-rwxr-xr-x | binary/all_in_one | 4 | ||||
-rwxr-xr-x | configure | 21 | ||||
-rw-r--r-- | install.bat | 26 | ||||
-rw-r--r-- | luarocks-dev-1.rockspec | 4 | ||||
-rw-r--r-- | spec/util/test_env.lua | 96 | ||||
-rw-r--r-- | src/luarocks/cmd.lua | 68 | ||||
-rw-r--r-- | src/luarocks/cmd/config.lua | 3 | ||||
-rw-r--r-- | src/luarocks/cmd/init.lua | 14 | ||||
-rw-r--r-- | src/luarocks/core/cfg.lua | 42 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 2 | ||||
-rw-r--r-- | src/luarocks/fs/unix.lua | 2 | ||||
-rw-r--r-- | src/luarocks/fs/win32.lua | 2 | ||||
-rw-r--r-- | src/luarocks/test/command.lua | 3 | ||||
-rw-r--r-- | src/luarocks/util.lua | 30 |
15 files changed, 189 insertions, 134 deletions
diff --git a/GNUmakefile b/GNUmakefile index cbb47996..22a1d817 100644 --- a/GNUmakefile +++ b/GNUmakefile | |||
@@ -7,8 +7,7 @@ INSTALL = install | |||
7 | INSTALL_DATA = $(INSTALL) -m 644 | 7 | INSTALL_DATA = $(INSTALL) -m 644 |
8 | BINARY_PLATFORM = unix | 8 | BINARY_PLATFORM = unix |
9 | 9 | ||
10 | SHEBANG = \#!$(LUA_BINDIR)/$(LUA_INTERPRETER) | 10 | SHEBANG = \#!$(LUA) |
11 | LUA = $(LUA_BINDIR)/$(LUA_INTERPRETER) | ||
12 | luarocksconfdir = $(sysconfdir)/luarocks | 11 | luarocksconfdir = $(sysconfdir)/luarocks |
13 | luadir = $(datarootdir)/lua/$(LUA_VERSION) | 12 | luadir = $(datarootdir)/lua/$(LUA_VERSION) |
14 | builddir = ./build | 13 | builddir = ./build |
@@ -38,12 +37,13 @@ $(builddir)/config-$(LUA_VERSION).lua: config.unix | |||
38 | ' { name = "user", root = home .. "/.luarocks" };\n'\ | 37 | ' { name = "user", root = home .. "/.luarocks" };\n'\ |
39 | "$$([ "$(rocks_tree)" != "$(HOME)/.luarocks" ] && printf ' { name = "system", root = "'"$(rocks_tree)"'" };\\n')"\ | 38 | "$$([ "$(rocks_tree)" != "$(HOME)/.luarocks" ] && printf ' { name = "system", root = "'"$(rocks_tree)"'" };\\n')"\ |
40 | '}\n'\ | 39 | '}\n'\ |
41 | "$$([ -n "$(LUA_INTERPRETER)" ] && printf 'lua_interpreter = "%s";\\n' "$(LUA_INTERPRETER)")"\ | ||
42 | 'variables = {\n'\ | 40 | 'variables = {\n'\ |
43 | "$$([ -n "$(LUA_DIR)" ] && printf ' LUA_DIR = "%s";\\n' "$(LUA_DIR)")"\ | 41 | "$$([ -n "$(LUA_DIR)" ] && printf ' LUA_DIR = "%s";\\n' "$(LUA_DIR)")"\ |
44 | "$$([ -n "$(LUA_INCDIR)" ] && printf ' LUA_INCDIR = "%s";\\n' "$(LUA_INCDIR)")"\ | 42 | "$$([ -n "$(LUA_INCDIR)" ] && printf ' LUA_INCDIR = "%s";\\n' "$(LUA_INCDIR)")"\ |
45 | "$$([ -n "$(LUA_BINDIR)" ] && printf ' LUA_BINDIR = "%s";\\n' "$(LUA_BINDIR)")"\ | 43 | "$$([ -n "$(LUA_BINDIR)" ] && printf ' LUA_BINDIR = "%s";\\n' "$(LUA_BINDIR)")"\ |
46 | "$$([ -n "$(LUA_LIBDIR)" ] && printf ' LUA_LIBDIR = "%s";\\n' "$(LUA_LIBDIR)")"\ | 44 | "$$([ -n "$(LUA_LIBDIR)" ] && printf ' LUA_LIBDIR = "%s";\\n' "$(LUA_LIBDIR)")"\ |
45 | "$$([ -n "$(LUA_VERSION)" ] && printf ' LUA_VERSION = "%s";\\n' "$(LUA_VERSION)")"\ | ||
46 | "$$([ -n "$(LUA)" ] && printf ' LUA = "%s";\\n' "$(LUA)")"\ | ||
47 | '}\n'\ | 47 | '}\n'\ |
48 | > $@ | 48 | > $@ |
49 | 49 | ||
diff --git a/binary/all_in_one b/binary/all_in_one index 9db25bf8..c3de9c2e 100755 --- a/binary/all_in_one +++ b/binary/all_in_one | |||
@@ -159,10 +159,6 @@ local function write_hardcoded_module(dir) | |||
159 | IS_BINARY = true, | 159 | IS_BINARY = true, |
160 | 160 | ||
161 | SYSCONFDIR = if_platform("unix", SYSCONFDIR), | 161 | SYSCONFDIR = if_platform("unix", SYSCONFDIR), |
162 | |||
163 | LUA_DIR = if_platform("unix", cfg.variables.LUA_DIR), | ||
164 | LUA_BINDIR = if_platform("unix", cfg.variables.LUA_BINDIR), | ||
165 | LUA_INTERPRETER = if_platform("unix", cfg.lua_interpreter), | ||
166 | } | 162 | } |
167 | 163 | ||
168 | local name = dir .. "/luarocks/core/hardcoded.lua" | 164 | local name = dir .. "/luarocks/core/hardcoded.lua" |
@@ -187,7 +187,8 @@ search_interpreter() { | |||
187 | then | 187 | then |
188 | if detect_lua_version "$lua_at/$name" | 188 | if detect_lua_version "$lua_at/$name" |
189 | then | 189 | then |
190 | echo "Lua interpreter found: $(GREEN "$lua_at/$name")" | 190 | LUA="$lua_at/$name" |
191 | echo "Lua interpreter found: $(GREEN "$LUA")" | ||
191 | if [ "$LUA_BINDIR_SET" != "yes" ] | 192 | if [ "$LUA_BINDIR_SET" != "yes" ] |
192 | then | 193 | then |
193 | LUA_BINDIR="$lua_at" | 194 | LUA_BINDIR="$lua_at" |
@@ -196,7 +197,7 @@ search_interpreter() { | |||
196 | then | 197 | then |
197 | LUA_DIR=$(dirname "$lua_at") | 198 | LUA_DIR=$(dirname "$lua_at") |
198 | fi | 199 | fi |
199 | LUA_INTERPRETER="$name" | 200 | |
200 | return 0 | 201 | return 0 |
201 | fi | 202 | fi |
202 | fi | 203 | fi |
@@ -288,8 +289,8 @@ do | |||
288 | ;; | 289 | ;; |
289 | --with-lua-interpreter) | 290 | --with-lua-interpreter) |
290 | [ -n "$value" ] || die "Missing value in flag $key." | 291 | [ -n "$value" ] || die "Missing value in flag $key." |
291 | LUA_INTERPRETER="$value" | 292 | LUA_EXE="$value" |
292 | LUA_INTERPRETER_SET=yes | 293 | LUA_EXE_SET=yes |
293 | ;; | 294 | ;; |
294 | 295 | ||
295 | # For specialized uses of LuaRocks: | 296 | # For specialized uses of LuaRocks: |
@@ -366,9 +367,9 @@ case "$LUA_VERSION" in | |||
366 | ;; | 367 | ;; |
367 | esac | 368 | esac |
368 | 369 | ||
369 | if [ "$LUA_INTERPRETER_SET" = "yes" ] | 370 | if [ "$LUA_EXE_SET" = "yes" ] |
370 | then | 371 | then |
371 | names="$LUA_INTERPRETER" | 372 | names="$LUA_EXE" |
372 | fi | 373 | fi |
373 | 374 | ||
374 | for name in $names | 375 | for name in $names |
@@ -400,8 +401,8 @@ fi | |||
400 | 401 | ||
401 | if [ "$LUA_VERSION_SET" = "yes" ] | 402 | if [ "$LUA_VERSION_SET" = "yes" ] |
402 | then | 403 | then |
403 | echo_n "Checking if $LUA_BINDIR/$LUA_INTERPRETER is Lua version $LUA_VERSION... " | 404 | echo_n "Checking if $LUA is Lua version $LUA_VERSION... " |
404 | if detect_lua_version "$LUA_BINDIR/$LUA_INTERPRETER" | 405 | if detect_lua_version "$LUA" |
405 | then | 406 | then |
406 | echo "yes" | 407 | echo "yes" |
407 | else | 408 | else |
@@ -433,7 +434,7 @@ check_incdir() { | |||
433 | "$incdir/lua-$LUA_VERSION/lua.h" \ | 434 | "$incdir/lua-$LUA_VERSION/lua.h" \ |
434 | "$incdir/lua$(echo "$LUA_VERSION" | tr -d .)/lua.h" \ | 435 | "$incdir/lua$(echo "$LUA_VERSION" | tr -d .)/lua.h" \ |
435 | "$incdir/lua.h" \ | 436 | "$incdir/lua.h" \ |
436 | $("$LUA_BINDIR/$LUA_INTERPRETER" -e 'print(jit and [['"$incdir"'/luajit-]]..jit.version:match("(%d+%.%d+)")..[[/lua.h]] or "")') | 437 | $("$LUA" -e 'print(jit and [['"$incdir"'/luajit-]]..jit.version:match("(%d+%.%d+)")..[[/lua.h]] or "")') |
437 | do | 438 | do |
438 | if [ -f "$lua_h" ] | 439 | if [ -f "$lua_h" ] |
439 | then | 440 | then |
@@ -485,7 +486,7 @@ prefix=$prefix | |||
485 | sysconfdir=$sysconfdir | 486 | sysconfdir=$sysconfdir |
486 | rocks_tree=$rocks_tree | 487 | rocks_tree=$rocks_tree |
487 | LUA_VERSION=$LUA_VERSION | 488 | LUA_VERSION=$LUA_VERSION |
488 | LUA_INTERPRETER=$LUA_INTERPRETER | 489 | LUA=$LUA |
489 | LUA_DIR=$LUA_DIR | 490 | LUA_DIR=$LUA_DIR |
490 | LUA_BINDIR=$LUA_BINDIR | 491 | LUA_BINDIR=$LUA_BINDIR |
491 | LUA_INCDIR=$LUA_INCDIR | 492 | LUA_INCDIR=$LUA_INCDIR |
diff --git a/install.bat b/install.bat index 7a5df9cd..e84f78cf 100644 --- a/install.bat +++ b/install.bat | |||
@@ -15,8 +15,9 @@ vars.TREE_ROOT = nil | |||
15 | vars.TREE_BIN = nil | 15 | vars.TREE_BIN = nil |
16 | vars.TREE_LMODULE = nil | 16 | vars.TREE_LMODULE = nil |
17 | vars.TREE_CMODULE = nil | 17 | vars.TREE_CMODULE = nil |
18 | vars.LUA_INTERPRETER = nil | 18 | vars.LUA = nil |
19 | vars.LUA_PREFIX = nil | 19 | vars.LUA_PREFIX = nil |
20 | vars.LUA_DIR = nil | ||
20 | vars.LUA_BINDIR = nil | 21 | vars.LUA_BINDIR = nil |
21 | vars.LUA_INCDIR = nil | 22 | vars.LUA_INCDIR = nil |
22 | vars.LUA_LIBDIR = nil | 23 | vars.LUA_LIBDIR = nil |
@@ -320,7 +321,7 @@ local function look_for_interpreter(directory) | |||
320 | end | 321 | end |
321 | end | 322 | end |
322 | 323 | ||
323 | vars.LUA_INTERPRETER = name | 324 | vars.LUA = full_name |
324 | vars.LUA_BINDIR = dir | 325 | vars.LUA_BINDIR = dir |
325 | return true | 326 | return true |
326 | end | 327 | end |
@@ -398,7 +399,7 @@ end | |||
398 | 399 | ||
399 | local function get_runtime() | 400 | local function get_runtime() |
400 | local f | 401 | local f |
401 | vars.LUA_RUNTIME, f = pe.msvcrt(vars.LUA_BINDIR.."\\"..vars.LUA_INTERPRETER) | 402 | vars.LUA_RUNTIME, f = pe.msvcrt(vars.LUA) |
402 | if type(vars.LUA_RUNTIME) ~= "string" then | 403 | if type(vars.LUA_RUNTIME) ~= "string" then |
403 | -- analysis failed, issue a warning | 404 | -- analysis failed, issue a warning |
404 | vars.LUA_RUNTIME = "MSVCR80" | 405 | vars.LUA_RUNTIME = "MSVCR80" |
@@ -411,9 +412,9 @@ end | |||
411 | 412 | ||
412 | local function get_architecture() | 413 | local function get_architecture() |
413 | -- detect processor arch interpreter was compiled for | 414 | -- detect processor arch interpreter was compiled for |
414 | local proc = (pe.parse(vars.LUA_BINDIR.."\\"..vars.LUA_INTERPRETER) or {}).Machine | 415 | local proc = (pe.parse(vars.LUA) or {}).Machine |
415 | if not proc then | 416 | if not proc then |
416 | die("Could not detect processor architecture used in "..vars.LUA_INTERPRETER) | 417 | die("Could not detect processor architecture used in "..vars.LUA) |
417 | end | 418 | end |
418 | print("arch: " .. proc .. " -> " .. pe.const.Machine[proc]) | 419 | print("arch: " .. proc .. " -> " .. pe.const.Machine[proc]) |
419 | proc = pe.const.Machine[proc] -- collect name from constant value | 420 | proc = pe.const.Machine[proc] -- collect name from constant value |
@@ -659,6 +660,7 @@ local function look_for_lua_install () | |||
659 | print("Headers found, checking runtime to use...") | 660 | print("Headers found, checking runtime to use...") |
660 | if get_runtime() then | 661 | if get_runtime() then |
661 | print("Runtime check completed.") | 662 | print("Runtime check completed.") |
663 | vars.LUA_DIR = directory | ||
662 | return true | 664 | return true |
663 | end | 665 | end |
664 | end | 666 | end |
@@ -862,7 +864,8 @@ vars.INCDIR = S"$PREFIX\\include" | |||
862 | vars.LUA_SHORTV = vars.LUA_VERSION:gsub("%.", "") | 864 | vars.LUA_SHORTV = vars.LUA_VERSION:gsub("%.", "") |
863 | 865 | ||
864 | if INSTALL_LUA then | 866 | if INSTALL_LUA then |
865 | vars.LUA_INTERPRETER = "lua5.1" | 867 | vars.LUA = vars.BINDIR .. "\\lua5.1.exe" |
868 | vars.LUA_DIR = vars.PREFIX | ||
866 | vars.LUA_BINDIR = vars.BINDIR | 869 | vars.LUA_BINDIR = vars.BINDIR |
867 | vars.LUA_LIBDIR = vars.LIBDIR | 870 | vars.LUA_LIBDIR = vars.LIBDIR |
868 | vars.LUA_INCDIR = vars.INCDIR | 871 | vars.LUA_INCDIR = vars.INCDIR |
@@ -876,6 +879,9 @@ else | |||
876 | vars.UNAME_M = get_architecture() -- can only do when installation was found | 879 | vars.UNAME_M = get_architecture() -- can only do when installation was found |
877 | end | 880 | end |
878 | 881 | ||
882 | assert(vars.LUA) | ||
883 | assert(vars.LUA_DIR) | ||
884 | |||
879 | -- check location of system tree | 885 | -- check location of system tree |
880 | if not vars.TREE_ROOT then | 886 | if not vars.TREE_ROOT then |
881 | -- no system tree location given, so we need to construct a default value | 887 | -- no system tree location given, so we need to construct a default value |
@@ -918,7 +924,7 @@ LuaRocks : $PREFIX | |||
918 | Config file : $CONFIG_FILE | 924 | Config file : $CONFIG_FILE |
919 | Rocktree : $TREE_ROOT | 925 | Rocktree : $TREE_ROOT |
920 | 926 | ||
921 | Lua interpreter : $LUA_BINDIR\$LUA_INTERPRETER | 927 | Lua interpreter : $LUA |
922 | binaries : $LUA_BINDIR | 928 | binaries : $LUA_BINDIR |
923 | libraries : $LUA_LIBDIR | 929 | libraries : $LUA_LIBDIR |
924 | includes : $LUA_INCDIR | 930 | includes : $LUA_INCDIR |
@@ -1031,7 +1037,7 @@ IF NOT "%LUA_PATH_5_3%"=="" ( | |||
1031 | SET "LUA_PATH_5_3=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH_5_3%" | 1037 | SET "LUA_PATH_5_3=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH_5_3%" |
1032 | ) | 1038 | ) |
1033 | SET "PATH=$BINDIR;%PATH%" | 1039 | SET "PATH=$BINDIR;%PATH%" |
1034 | "$LUA_BINDIR\$LUA_INTERPRETER" "$BINDIR\]]..c..[[.lua" %* | 1040 | "$LUA" "$BINDIR\]]..c..[[.lua" %* |
1035 | SET EXITCODE=%ERRORLEVEL% | 1041 | SET EXITCODE=%ERRORLEVEL% |
1036 | IF NOT "%EXITCODE%"=="2" GOTO EXITLR | 1042 | IF NOT "%EXITCODE%"=="2" GOTO EXITLR |
1037 | 1043 | ||
@@ -1087,10 +1093,12 @@ vars.SYSTEM = USE_MINGW and "mingw" or "windows" | |||
1087 | local f = io.open(hardcoded_lua, "w") | 1093 | local f = io.open(hardcoded_lua, "w") |
1088 | f:write(S[=[ | 1094 | f:write(S[=[ |
1089 | return { | 1095 | return { |
1096 | LUA_DIR=[[$LUA_DIR]], | ||
1090 | LUA_INCDIR=[[$LUA_INCDIR]], | 1097 | LUA_INCDIR=[[$LUA_INCDIR]], |
1091 | LUA_LIBDIR=[[$LUA_LIBDIR]], | 1098 | LUA_LIBDIR=[[$LUA_LIBDIR]], |
1092 | LUA_BINDIR=[[$LUA_BINDIR]], | 1099 | LUA_BINDIR=[[$LUA_BINDIR]], |
1093 | LUA_INTERPRETER=[[$LUA_INTERPRETER]], | 1100 | LUA_VERSION=[[$LUA_VERSION]], |
1101 | LUA=[[$LUA]], | ||
1094 | SYSTEM = [[$SYSTEM]], | 1102 | SYSTEM = [[$SYSTEM]], |
1095 | PROCESSOR = [[$UNAME_M]], | 1103 | PROCESSOR = [[$UNAME_M]], |
1096 | PREFIX = [[$PREFIX]], | 1104 | PREFIX = [[$PREFIX]], |
diff --git a/luarocks-dev-1.rockspec b/luarocks-dev-1.rockspec index 718ce338..677b07cf 100644 --- a/luarocks-dev-1.rockspec +++ b/luarocks-dev-1.rockspec | |||
@@ -28,10 +28,10 @@ test = { | |||
28 | type = "busted", | 28 | type = "busted", |
29 | platforms = { | 29 | platforms = { |
30 | windows = { | 30 | windows = { |
31 | flags = { "--exclude-tags=ssh,git,unix", "-Xhelper", "lua_dir=$(LUA_DIR)", "-Xhelper", "lua_interpreter=$(LUA)" } | 31 | flags = { "--exclude-tags=ssh,git,unix", "-Xhelper", "lua_dir=$(LUA_DIR)", "-Xhelper", "lua=$(LUA)" } |
32 | }, | 32 | }, |
33 | unix = { | 33 | unix = { |
34 | flags = { "--exclude-tags=ssh,git", "-Xhelper", "lua_dir=$(LUA_DIR)", "-Xhelper", "lua_interpreter=$(LUA)" } | 34 | flags = { "--exclude-tags=ssh,git", "-Xhelper", "lua_dir=$(LUA_DIR)", "-Xhelper", "lua=$(LUA)" } |
35 | } | 35 | } |
36 | } | 36 | } |
37 | } | 37 | } |
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index ca520459..f9f83b8c 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua | |||
@@ -22,7 +22,7 @@ ARGUMENTS | |||
22 | appveyor Add if running on Appveyor. | 22 | appveyor Add if running on Appveyor. |
23 | os=<type> Set OS ("linux", "osx", or "windows"). | 23 | os=<type> Set OS ("linux", "osx", or "windows"). |
24 | lua_dir=<path> Path of Lua installation (default "/usr/local") | 24 | lua_dir=<path> Path of Lua installation (default "/usr/local") |
25 | lua_interpreter=<lua> Name of the interpreter (default "lua") | 25 | lua=<lua> Name of the interpreter, may be full path (default "lua") |
26 | ]] | 26 | ]] |
27 | 27 | ||
28 | local function help() | 28 | local function help() |
@@ -107,7 +107,7 @@ lfs.attributes = function(f, ...) -- luacheck: ignore | |||
107 | return lfs_attributes(V(f), ...) | 107 | return lfs_attributes(V(f), ...) |
108 | end | 108 | end |
109 | 109 | ||
110 | function test_env.exists(path) | 110 | local function exists(path) |
111 | return lfs.attributes(path, "mode") ~= nil | 111 | return lfs.attributes(path, "mode") ~= nil |
112 | end | 112 | end |
113 | 113 | ||
@@ -302,8 +302,8 @@ function test_env.set_args() | |||
302 | test_env.MINGW = false | 302 | test_env.MINGW = false |
303 | elseif argument:find("^lua_dir=") then | 303 | elseif argument:find("^lua_dir=") then |
304 | test_env.LUA_DIR = argument:match("^lua_dir=(.*)$") | 304 | test_env.LUA_DIR = argument:match("^lua_dir=(.*)$") |
305 | elseif argument:find("^lua_interpreter=") then | 305 | elseif argument:find("^lua=") then |
306 | test_env.LUA_INTERPRETER = argument:match("^lua_interpreter=(.*)$") | 306 | test_env.LUA = argument:match("^lua=(.*)$") |
307 | else | 307 | else |
308 | help() | 308 | help() |
309 | end | 309 | end |
@@ -371,7 +371,7 @@ end | |||
371 | function test_env.remove_dir(path) | 371 | function test_env.remove_dir(path) |
372 | path = V(path) | 372 | path = V(path) |
373 | 373 | ||
374 | if test_env.exists(path) then | 374 | if exists(path) then |
375 | for file in lfs.dir(path) do | 375 | for file in lfs.dir(path) do |
376 | if file ~= "." and file ~= ".." then | 376 | if file ~= "." and file ~= ".." then |
377 | local full_path = path..'/'..file | 377 | local full_path = path..'/'..file |
@@ -393,7 +393,7 @@ end | |||
393 | function test_env.remove_subdirs(path, pattern) | 393 | function test_env.remove_subdirs(path, pattern) |
394 | path = V(path) | 394 | path = V(path) |
395 | 395 | ||
396 | if test_env.exists(path) then | 396 | if exists(path) then |
397 | for file in lfs.dir(path) do | 397 | for file in lfs.dir(path) do |
398 | if file ~= "." and file ~= ".." then | 398 | if file ~= "." and file ~= ".." then |
399 | local full_path = path..'/'..file | 399 | local full_path = path..'/'..file |
@@ -414,7 +414,7 @@ function test_env.remove_files(path, pattern) | |||
414 | path = V(path) | 414 | path = V(path) |
415 | 415 | ||
416 | local result_check = false | 416 | local result_check = false |
417 | if test_env.exists(path) then | 417 | if exists(path) then |
418 | for file in lfs.dir(path) do | 418 | for file in lfs.dir(path) do |
419 | if file ~= "." and file ~= ".." then | 419 | if file ~= "." and file ~= ".." then |
420 | if file:find(pattern) then | 420 | if file:find(pattern) then |
@@ -445,7 +445,7 @@ local function download_rocks(urls, save_path) | |||
445 | table.insert(fixtures, (url:gsub("^spec/fixtures", test_env.testing_paths.fixtures_dir))) | 445 | table.insert(fixtures, (url:gsub("^spec/fixtures", test_env.testing_paths.fixtures_dir))) |
446 | else | 446 | else |
447 | -- check if already downloaded | 447 | -- check if already downloaded |
448 | if not test_env.exists(save_path .. "/" .. url) then | 448 | if not exists(save_path .. "/" .. url) then |
449 | table.insert(to_download, ((luarocks_repo .. url):gsub("org//", "org/"))) | 449 | table.insert(to_download, ((luarocks_repo .. url):gsub("org//", "org/"))) |
450 | end | 450 | end |
451 | end | 451 | end |
@@ -642,8 +642,8 @@ local function reset_environment(testing_paths, md5sums) | |||
642 | end | 642 | end |
643 | 643 | ||
644 | local function found_interpreter(testing_paths, luadir, lua_bindir) | 644 | local function found_interpreter(testing_paths, luadir, lua_bindir) |
645 | local location = lua_bindir .. "/" .. testing_paths.lua_interpreter | 645 | local location = lua_bindir .. "/" .. testing_paths.lua_exe |
646 | if test_env.exists(location) then | 646 | if exists(location) then |
647 | testing_paths.lua_bindir = lua_bindir | 647 | testing_paths.lua_bindir = lua_bindir |
648 | testing_paths.luadir = luadir | 648 | testing_paths.luadir = luadir |
649 | testing_paths.lua = location | 649 | testing_paths.lua = location |
@@ -651,44 +651,57 @@ local function found_interpreter(testing_paths, luadir, lua_bindir) | |||
651 | end | 651 | end |
652 | end | 652 | end |
653 | 653 | ||
654 | local function create_paths(luaversion_full) | 654 | local function find_lua() |
655 | -- (1) LUA is a full path | ||
656 | if test_env.LUA and test_env.LUA:match("[/\\]") then | ||
655 | 657 | ||
656 | local testing_paths = {} | 658 | local lua_bindir = test_env.LUA:match("^(.-)[/\\][^/\\]*$") |
657 | local try_dirs | 659 | local luadir = test_env.LUA_DIR or lua_bindir:gsub("[/\\]bin$") |
660 | local lua = test_env.LUA | ||
658 | 661 | ||
659 | if test_env.TEST_TARGET_OS == "windows" then | 662 | return lua_bindir, luadir, lua |
660 | try_dirs = { os.getenv("ProgramFiles(x86)").."/LuaRocks" } | ||
661 | testing_paths.luarocks_tmp = os.getenv("TEMP") | ||
662 | testing_paths.lua_interpreter = "lua.exe" | ||
663 | else | ||
664 | try_dirs = { "/usr/local", "/usr" } | ||
665 | testing_paths.luarocks_tmp = "/tmp/luarocks_testing" | ||
666 | testing_paths.lua_interpreter = "lua" | ||
667 | end | 663 | end |
668 | 664 | ||
665 | -- (2) LUA is just the interpreter name | ||
666 | local lua_exe = test_env.LUA | ||
667 | or ((test_env.TEST_TARGET_OS == "windows") and "lua.exe") | ||
668 | or "lua" | ||
669 | |||
670 | -- (2.1) LUA_DIR was given | ||
669 | if test_env.LUA_DIR then | 671 | if test_env.LUA_DIR then |
670 | table.insert(try_dirs, 1, test_env.LUA_DIR) | ||
671 | end | ||
672 | 672 | ||
673 | if test_env.LUA_INTERPRETER then | 673 | local luadir = test_env.LUA_DIR |
674 | testing_paths.lua_interpreter = test_env.LUA_INTERPRETER | 674 | local lua_bindir = exists(luadir .. "/bin") |
675 | end | 675 | and luadir .. "/bin" |
676 | or luadir | ||
677 | local lua = lua_bindir .. "/" .. lua_exe | ||
676 | 678 | ||
677 | local bindir, interp = testing_paths.lua_interpreter:match("^(.-)[/\\]([^/\\]*)$") | 679 | return lua_bindir, luadir, lua |
678 | if bindir and interp then | ||
679 | testing_paths.lua_interpreter = interp | ||
680 | try_dirs = { bindir } | ||
681 | end | 680 | end |
682 | 681 | ||
683 | for _, try_dir in ipairs(try_dirs) do | 682 | -- (2.2) LUA_DIR was not given, try some default paths |
684 | if found_interpreter(testing_paths, try_dir, try_dir) | 683 | local try_dirs = (test_env.TEST_TARGET_OS == "windows") |
685 | or found_interpreter(testing_paths, try_dir, try_dir .. "/bin") | 684 | and { os.getenv("ProgramFiles(x86)").."/LuaRocks" } |
686 | then | 685 | or { "/usr/local", "/usr" } |
687 | break | 686 | |
687 | for _, luadir in ipairs(try_dirs) do | ||
688 | for _, lua_bindir in ipairs({ luadir, luadir .. "/bin" }) do | ||
689 | local lua = lua_bindir .. "/" .. lua_exe | ||
690 | if exists(lua) then | ||
691 | return lua_bindir, luadir, lua | ||
692 | end | ||
688 | end | 693 | end |
689 | end | 694 | end |
695 | end | ||
696 | |||
697 | local function create_paths(luaversion_full) | ||
690 | 698 | ||
691 | assert(testing_paths.lua, "Lua interpreter not found! Run `busted -Xhelper help` for options") | 699 | local testing_paths = {} |
700 | |||
701 | testing_paths.lua_bindir, testing_paths.luadir, testing_paths.lua = find_lua() | ||
702 | if (not testing_paths.lua) or (not exists(testing_paths.lua)) then | ||
703 | error("Lua interpreter not found! Run `busted -Xhelper help` for options") | ||
704 | end | ||
692 | 705 | ||
693 | local base_dir = lfs.currentdir() | 706 | local base_dir = lfs.currentdir() |
694 | 707 | ||
@@ -714,6 +727,12 @@ local function create_paths(luaversion_full) | |||
714 | testing_paths.testing_sys_rocks = testing_paths.testing_sys_tree .. "/lib/luarocks/rocks-" .. test_env.lua_version | 727 | testing_paths.testing_sys_rocks = testing_paths.testing_sys_tree .. "/lib/luarocks/rocks-" .. test_env.lua_version |
715 | 728 | ||
716 | if test_env.TEST_TARGET_OS == "windows" then | 729 | if test_env.TEST_TARGET_OS == "windows" then |
730 | testing_paths.luarocks_tmp = os.getenv("TEMP") | ||
731 | else | ||
732 | testing_paths.luarocks_tmp = "/tmp/luarocks_testing" | ||
733 | end | ||
734 | |||
735 | if test_env.TEST_TARGET_OS == "windows" then | ||
717 | testing_paths.win_tools = base_dir .. "/win32/tools" | 736 | testing_paths.win_tools = base_dir .. "/win32/tools" |
718 | end | 737 | end |
719 | 738 | ||
@@ -739,7 +758,7 @@ function test_env.setup_specs(extra_rocks) | |||
739 | -- if global variable about successful creation of testing environment doesn't exist, build environment | 758 | -- if global variable about successful creation of testing environment doesn't exist, build environment |
740 | if not test_env.setup_done then | 759 | if not test_env.setup_done then |
741 | if test_env.CI then | 760 | if test_env.CI then |
742 | if not test_env.exists(os.getenv("HOME") .. "/.ssh/id_rsa.pub") then | 761 | if not exists(os.getenv("HOME") .. "/.ssh/id_rsa.pub") then |
743 | execute_bool("ssh-keygen -t rsa -P \"\" -f ~/.ssh/id_rsa") | 762 | execute_bool("ssh-keygen -t rsa -P \"\" -f ~/.ssh/id_rsa") |
744 | execute_bool("cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys") | 763 | execute_bool("cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys") |
745 | execute_bool("chmod og-wx ~/.ssh/authorized_keys") | 764 | execute_bool("chmod og-wx ~/.ssh/authorized_keys") |
@@ -914,7 +933,7 @@ local function setup_luarocks() | |||
914 | ("SYSCONFDIR = %q,"):format(testing_paths.testing_lrprefix .. "/etc/luarocks"), | 933 | ("SYSCONFDIR = %q,"):format(testing_paths.testing_lrprefix .. "/etc/luarocks"), |
915 | ("LUA_DIR = %q,"):format(testing_paths.luadir), | 934 | ("LUA_DIR = %q,"):format(testing_paths.luadir), |
916 | ("LUA_BINDIR = %q,"):format(testing_paths.lua_bindir), | 935 | ("LUA_BINDIR = %q,"):format(testing_paths.lua_bindir), |
917 | ("LUA_INTERPRETER = %q,"):format(testing_paths.lua_interpreter), | 936 | ("LUA = %q,"):format(testing_paths.lua), |
918 | } | 937 | } |
919 | 938 | ||
920 | if test_env.TEST_TARGET_OS == "windows" then | 939 | if test_env.TEST_TARGET_OS == "windows" then |
@@ -1083,6 +1102,7 @@ test_env.set_args() | |||
1083 | test_env.testing_paths = create_paths(test_env.LUA_V or test_env.LUAJIT_V) | 1102 | test_env.testing_paths = create_paths(test_env.LUA_V or test_env.LUAJIT_V) |
1084 | test_env.env_variables = create_env(test_env.testing_paths) | 1103 | test_env.env_variables = create_env(test_env.testing_paths) |
1085 | test_env.run = make_run_functions() | 1104 | test_env.run = make_run_functions() |
1105 | test_env.exists = exists | ||
1086 | test_env.V = V | 1106 | test_env.V = V |
1087 | 1107 | ||
1088 | return test_env | 1108 | return test_env |
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 250e3cff..9c3d91db 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -184,7 +184,11 @@ local function die(message, exitcode) | |||
184 | os.exit(exitcode or cmd.errorcodes.UNSPECIFIED) | 184 | os.exit(exitcode or cmd.errorcodes.UNSPECIFIED) |
185 | end | 185 | end |
186 | 186 | ||
187 | local function search_lua_in_path(lua_version, verbose) | 187 | local function search_lua(lua_version, verbose, search_at) |
188 | if search_at then | ||
189 | return util.find_lua(search_at, lua_version, verbose) | ||
190 | end | ||
191 | |||
188 | local path_sep = (package.config:sub(1, 1) == "\\" and ";" or ":") | 192 | local path_sep = (package.config:sub(1, 1) == "\\" and ";" or ":") |
189 | local all_tried = {} | 193 | local all_tried = {} |
190 | for bindir in (os.getenv("PATH") or ""):gmatch("[^"..path_sep.."]+") do | 194 | for bindir in (os.getenv("PATH") or ""):gmatch("[^"..path_sep.."]+") do |
@@ -284,7 +288,7 @@ do | |||
284 | end | 288 | end |
285 | 289 | ||
286 | if lua_version then | 290 | if lua_version then |
287 | local detected = search_lua_in_path(lua_version) | 291 | local detected = search_lua(lua_version) |
288 | if detected then | 292 | if detected then |
289 | return detected | 293 | return detected |
290 | end | 294 | end |
@@ -497,6 +501,19 @@ Enabling completion for Fish: | |||
497 | return parser | 501 | return parser |
498 | end | 502 | end |
499 | 503 | ||
504 | local function get_first_arg() | ||
505 | if not arg then | ||
506 | return | ||
507 | end | ||
508 | local first_arg = arg[0] | ||
509 | local i = -1 | ||
510 | while arg[i] do | ||
511 | first_arg = arg[i] | ||
512 | i = i -1 | ||
513 | end | ||
514 | return first_arg | ||
515 | end | ||
516 | |||
500 | --- Main command-line processor. | 517 | --- Main command-line processor. |
501 | -- Parses input arguments and calls the appropriate driver function | 518 | -- Parses input arguments and calls the appropriate driver function |
502 | -- to execute the action requested on the command-line, forwarding | 519 | -- to execute the action requested on the command-line, forwarding |
@@ -610,20 +627,47 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
610 | -- try again now. | 627 | -- try again now. |
611 | local tried | 628 | local tried |
612 | if not lua_found then | 629 | if not lua_found then |
613 | if cfg.variables.LUA_DIR then | 630 | local detected |
614 | lua_found, tried = util.find_lua(cfg.variables.LUA_DIR, cfg.lua_version, args.verbose) | 631 | detected, tried = search_lua(cfg.lua_version, args.verbose, cfg.variables.LUA_DIR) |
615 | else | 632 | if detected then |
616 | lua_found, tried = search_lua_in_path(cfg.lua_version, args.verbose) | 633 | lua_found = true |
634 | cfg.variables.LUA = detected.lua | ||
635 | cfg.variables.LUA_DIR = detected.lua_dir | ||
636 | cfg.variables.LUA_BINDIR = detected.lua_bindir | ||
637 | if args.lua_dir then | ||
638 | cfg.variables.LUA_INCDIR = nil | ||
639 | cfg.variables.LUA_LIBDIR = nil | ||
640 | end | ||
617 | end | 641 | end |
618 | end | 642 | end |
619 | 643 | ||
620 | if not lua_found and args.command ~= "config" and args.command ~= "help" then | 644 | if lua_found then |
621 | util.warning(tried .. | 645 | assert(cfg.variables.LUA) |
622 | "\nModules may not install with the correct configurations. " .. | 646 | else |
623 | "You may want to configure the path prefix to your build " .. | 647 | if args.command ~= "config" and args.command ~= "help" then |
624 | "of Lua " .. cfg.lua_version .. " using\n\n" .. | 648 | util.warning(tried .. |
625 | " luarocks config --local lua_dir <your-lua-prefix>\n") | 649 | "\nModules may not install with the correct configurations. " .. |
650 | "You may want to configure the path prefix to your build " .. | ||
651 | "of Lua " .. cfg.lua_version .. " using\n\n" .. | ||
652 | " luarocks config --local lua_dir <your-lua-prefix>\n") | ||
653 | end | ||
654 | |||
655 | -- Fallback producing _some_ Lua configuration based on the running interpreter. | ||
656 | -- Most likely won't produce correct results when running from the standalone binary, | ||
657 | -- so eventually we need to drop this and outright fail if Lua is not found | ||
658 | -- or explictly configured | ||
659 | if not cfg.variables.LUA then | ||
660 | local first_arg = get_first_arg() | ||
661 | cfg.variables.LUA_DIR = dir.dir_name(fs.absolute_name(first_arg)) | ||
662 | cfg.variables.LUA_BINDIR = cfg.variables.LUA_DIR | ||
663 | local exe = fs.base_name(first_arg) | ||
664 | exe = exe:match("rocks") and ("lua" .. (cfg.arch:match("win") and ".exe" or "")) or exe | ||
665 | cfg.variables.LUA = dir.path(cfg.variables.LUA_BINDIR, exe) | ||
666 | cfg.variables.LUA_INCDIR = nil | ||
667 | cfg.variables.LUA_LIBDIR = nil | ||
668 | end | ||
626 | end | 669 | end |
670 | |||
627 | cfg.lua_found = lua_found | 671 | cfg.lua_found = lua_found |
628 | 672 | ||
629 | if cfg.project_dir then | 673 | if cfg.project_dir then |
diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua index d9b679df..7ad28777 100644 --- a/src/luarocks/cmd/config.lua +++ b/src/luarocks/cmd/config.lua | |||
@@ -18,7 +18,6 @@ Query information about the LuaRocks configuration. | |||
18 | any command-line flags passed) | 18 | any command-line flags passed) |
19 | 19 | ||
20 | Examples: | 20 | Examples: |
21 | luarocks config lua_interpreter | ||
22 | luarocks config variables.LUA_INCDIR | 21 | luarocks config variables.LUA_INCDIR |
23 | luarocks config lua_version | 22 | luarocks config lua_version |
24 | 23 | ||
@@ -300,7 +299,7 @@ function config_cmd.command(args) | |||
300 | ["variables.LUA_BINDIR"] = cfg.variables.LUA_BINDIR, | 299 | ["variables.LUA_BINDIR"] = cfg.variables.LUA_BINDIR, |
301 | ["variables.LUA_INCDIR"] = cfg.variables.LUA_INCDIR, | 300 | ["variables.LUA_INCDIR"] = cfg.variables.LUA_INCDIR, |
302 | ["variables.LUA_LIBDIR"] = cfg.variables.LUA_LIBDIR, | 301 | ["variables.LUA_LIBDIR"] = cfg.variables.LUA_LIBDIR, |
303 | ["lua_interpreter"] = cfg.lua_interpreter, | 302 | ["variables.LUA"] = cfg.variables.LUA, |
304 | } | 303 | } |
305 | if args.lua_version then | 304 | if args.lua_version then |
306 | local prefix = dir.dir_name(cfg.config_files[scope].file) | 305 | local prefix = dir.dir_name(cfg.config_files[scope].file) |
diff --git a/src/luarocks/cmd/init.lua b/src/luarocks/cmd/init.lua index efd612e4..543a720b 100644 --- a/src/luarocks/cmd/init.lua +++ b/src/luarocks/cmd/init.lua | |||
@@ -78,8 +78,7 @@ local function write_wrapper_scripts(wrapper_dir, luarocks_wrapper, lua_wrapper) | |||
78 | end | 78 | end |
79 | 79 | ||
80 | if write_lua_wrapper then | 80 | if write_lua_wrapper then |
81 | local interp = dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter) | 81 | if util.check_lua_version(cfg.variables.LUA, cfg.lua_version) then |
82 | if util.check_lua_version(interp, cfg.lua_version) then | ||
83 | util.printout("Preparing " .. lua_wrapper .. " for version " .. cfg.lua_version .. "...") | 82 | util.printout("Preparing " .. lua_wrapper .. " for version " .. cfg.lua_version .. "...") |
84 | path.use_tree(tree) | 83 | path.use_tree(tree) |
85 | fs.wrap_script(nil, lua_wrapper, "all") | 84 | fs.wrap_script(nil, lua_wrapper, "all") |
@@ -160,21 +159,12 @@ function init.command(args) | |||
160 | 159 | ||
161 | local config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) | 160 | local config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) |
162 | if config_tbl then | 161 | if config_tbl then |
163 | local globals = { | ||
164 | "lua_interpreter", | ||
165 | } | ||
166 | for _, v in ipairs(globals) do | ||
167 | if cfg[v] then | ||
168 | config_tbl[v] = cfg[v] | ||
169 | end | ||
170 | end | ||
171 | |||
172 | local varnames = { | 162 | local varnames = { |
173 | "LUA_DIR", | 163 | "LUA_DIR", |
174 | "LUA_INCDIR", | 164 | "LUA_INCDIR", |
175 | "LUA_LIBDIR", | 165 | "LUA_LIBDIR", |
176 | "LUA_BINDIR", | 166 | "LUA_BINDIR", |
177 | "LUA_INTERPRETER", | 167 | "LUA", |
178 | } | 168 | } |
179 | for _, varname in ipairs(varnames) do | 169 | for _, varname in ipairs(varnames) do |
180 | if cfg.variables[varname] then | 170 | if cfg.variables[varname] then |
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 81987cc9..2e5301c1 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
@@ -175,7 +175,6 @@ local function make_defaults(lua_version, target_cpu, platforms, home) | |||
175 | -- Configure defaults: | 175 | -- Configure defaults: |
176 | local defaults = { | 176 | local defaults = { |
177 | 177 | ||
178 | lua_interpreter = "lua", | ||
179 | local_by_default = false, | 178 | local_by_default = false, |
180 | accept_unknown_fields = false, | 179 | accept_unknown_fields = false, |
181 | fs_use_modules = true, | 180 | fs_use_modules = true, |
@@ -556,19 +555,6 @@ local function use_defaults(cfg, defaults) | |||
556 | end | 555 | end |
557 | end | 556 | end |
558 | 557 | ||
559 | local function get_first_arg() | ||
560 | if not arg then | ||
561 | return | ||
562 | end | ||
563 | local first_arg = arg[0] | ||
564 | local i = -1 | ||
565 | while arg[i] do | ||
566 | first_arg = arg[i] | ||
567 | i = i -1 | ||
568 | end | ||
569 | return first_arg | ||
570 | end | ||
571 | |||
572 | -------------------------------------------------------------------------------- | 558 | -------------------------------------------------------------------------------- |
573 | 559 | ||
574 | local cfg = {} | 560 | local cfg = {} |
@@ -580,7 +566,7 @@ local cfg = {} | |||
580 | -- * lua_version (in x.y format, e.g. "5.3") | 566 | -- * lua_version (in x.y format, e.g. "5.3") |
581 | -- * lua_bindir (e.g. "/usr/local/bin") | 567 | -- * lua_bindir (e.g. "/usr/local/bin") |
582 | -- * lua_dir (e.g. "/usr/local") | 568 | -- * lua_dir (e.g. "/usr/local") |
583 | -- * lua_interpreter (e.g. "lua-5.3") | 569 | -- * lua (e.g. "/usr/local/bin/lua-5.3") |
584 | -- * project_dir (a string with the path of the project directory | 570 | -- * project_dir (a string with the path of the project directory |
585 | -- when using per-project environments, as created with `luarocks init`) | 571 | -- when using per-project environments, as created with `luarocks init`) |
586 | -- @param warning a logging function for warnings that takes a string | 572 | -- @param warning a logging function for warnings that takes a string |
@@ -615,16 +601,15 @@ function cfg.init(detected, warning) | |||
615 | 601 | ||
616 | -- Use detected values as defaults, overridable via config files or CLI args | 602 | -- Use detected values as defaults, overridable via config files or CLI args |
617 | 603 | ||
618 | local first_arg = get_first_arg() | ||
619 | |||
620 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) | 604 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) |
621 | cfg.lua_interpreter = detected.lua_interpreter or hardcoded.LUA_INTERPRETER or (first_arg and first_arg:gsub(".*[\\/]", "")) or (is_windows and "lua.exe" or "lua") | ||
622 | cfg.project_dir = (not hardcoded.FORCE_CONFIG) and detected.project_dir | 605 | cfg.project_dir = (not hardcoded.FORCE_CONFIG) and detected.project_dir |
623 | 606 | ||
624 | do | 607 | do |
625 | local lua_bindir = detected.lua_bindir or hardcoded.LUA_BINDIR or (first_arg and first_arg:gsub("[\\/][^\\/]+$", "")) | 608 | local lua = detected.lua or hardcoded.LUA |
626 | local lua_dir = detected.lua_dir or hardcoded.LUA_DIR or (lua_bindir and lua_bindir:gsub("[\\/]bin$", "")) | 609 | local lua_bindir = detected.lua_bindir or hardcoded.LUA_BINDIR |
610 | local lua_dir = detected.lua_dir or hardcoded.LUA_DIR | ||
627 | cfg.variables = { | 611 | cfg.variables = { |
612 | LUA = lua, | ||
628 | LUA_DIR = lua_dir, | 613 | LUA_DIR = lua_dir, |
629 | LUA_BINDIR = lua_bindir, | 614 | LUA_BINDIR = lua_bindir, |
630 | LUA_LIBDIR = hardcoded.LUA_LIBDIR, | 615 | LUA_LIBDIR = hardcoded.LUA_LIBDIR, |
@@ -756,6 +741,11 @@ function cfg.init(detected, warning) | |||
756 | end | 741 | end |
757 | end | 742 | end |
758 | 743 | ||
744 | -- backwards compatibility: | ||
745 | if cfg.lua_interpreter and cfg.variables.LUA_BINDIR and not cfg.variables.LUA then | ||
746 | cfg.variables.LUA = (cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter):gsub("\\", "/") | ||
747 | end | ||
748 | |||
759 | ---------------------------------------- | 749 | ---------------------------------------- |
760 | -- Config files are loaded. | 750 | -- Config files are loaded. |
761 | -- Let's finish up the cfg table. | 751 | -- Let's finish up the cfg table. |
@@ -765,11 +755,11 @@ function cfg.init(detected, warning) | |||
765 | cfg.project_dir = detected.given_project_dir or cfg.project_dir | 755 | cfg.project_dir = detected.given_project_dir or cfg.project_dir |
766 | cfg.lua_version = detected.given_lua_version or cfg.lua_version | 756 | cfg.lua_version = detected.given_lua_version or cfg.lua_version |
767 | if detected.given_lua_dir then | 757 | if detected.given_lua_dir then |
758 | cfg.variables.LUA = detected.lua | ||
768 | cfg.variables.LUA_DIR = detected.given_lua_dir | 759 | cfg.variables.LUA_DIR = detected.given_lua_dir |
769 | cfg.variables.LUA_BINDIR = detected.lua_bindir | 760 | cfg.variables.LUA_BINDIR = detected.lua_bindir |
770 | cfg.variables.LUA_LIBDIR = nil | 761 | cfg.variables.LUA_LIBDIR = nil |
771 | cfg.variables.LUA_INCDIR = nil | 762 | cfg.variables.LUA_INCDIR = nil |
772 | cfg.lua_interpreter = detected.lua_interpreter | ||
773 | end | 763 | end |
774 | 764 | ||
775 | -- Build a default list of rocks trees if not given | 765 | -- Build a default list of rocks trees if not given |
@@ -794,9 +784,17 @@ function cfg.init(detected, warning) | |||
794 | defaults.fs_use_modules = true | 784 | defaults.fs_use_modules = true |
795 | end | 785 | end |
796 | 786 | ||
787 | -- if only cfg.variables.LUA is given in config files, | ||
788 | -- derive LUA_BINDIR and LUA_DIR from them. | ||
789 | if cfg.variables.LUA and not cfg.variables.LUA_BINDIR then | ||
790 | cfg.variables.LUA_BINDIR = cfg.variables.LUA:gsub("^(.*)[/\\][^/\\]*$") | ||
791 | if not cfg.variables.LUA_DIR then | ||
792 | cfg.variables.LUA_DIR = cfg.variables.LUA_BINDIR:gsub("[/\\]bin$", "") or cfg.variables.LUA_BINDIR | ||
793 | end | ||
794 | end | ||
795 | |||
797 | use_defaults(cfg, defaults) | 796 | use_defaults(cfg, defaults) |
798 | 797 | ||
799 | cfg.variables.LUA = cfg.variables.LUA or (cfg.variables.LUA_BINDIR and (cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter):gsub("//", "/")) | ||
800 | cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch | 798 | cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch |
801 | 799 | ||
802 | cfg.config_files = { | 800 | cfg.config_files = { |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 0805efd2..e9b4c5d8 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -1188,7 +1188,7 @@ end | |||
1188 | -- @return boolean true, if it is a Lua script, false otherwise | 1188 | -- @return boolean true, if it is a Lua script, false otherwise |
1189 | function fs_lua.is_lua(filename) | 1189 | function fs_lua.is_lua(filename) |
1190 | filename = filename:gsub([[%\]],"/") -- normalize on fw slash to prevent escaping issues | 1190 | filename = filename:gsub([[%\]],"/") -- normalize on fw slash to prevent escaping issues |
1191 | local lua = fs.Q(dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)) -- get lua interpreter configured | 1191 | local lua = fs.Q(cfg.variables.LUA) -- get lua interpreter configured |
1192 | -- execute on configured interpreter, might not be the same as the interpreter LR is run on | 1192 | -- execute on configured interpreter, might not be the same as the interpreter LR is run on |
1193 | local result = fs.execute_string(lua..[[ -e "if loadfile(']]..filename..[[') then os.exit(0) else os.exit(1) end"]]) | 1193 | local result = fs.execute_string(lua..[[ -e "if loadfile(']]..filename..[[') then os.exit(0) else os.exit(1) end"]]) |
1194 | return (result == true) | 1194 | return (result == true) |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 61569e30..f3db5b30 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
@@ -108,7 +108,7 @@ function unix.wrap_script(script, target, deps_mode, name, version, ...) | |||
108 | end | 108 | end |
109 | 109 | ||
110 | local argv = { | 110 | local argv = { |
111 | fs.Q(dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)), | 111 | fs.Q(cfg.variables["LUA"]), |
112 | "-e", | 112 | "-e", |
113 | fs.Q(table.concat(luainit, ";")), | 113 | fs.Q(table.concat(luainit, ";")), |
114 | script and fs.Q(script) or [[$([ "$*" ] || echo -i)]], | 114 | script and fs.Q(script) or [[$([ "$*" ] || echo -i)]], |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 1a35c3d4..1842ac4c 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
@@ -195,7 +195,7 @@ function win32.wrap_script(script, target, deps_mode, name, version, ...) | |||
195 | end | 195 | end |
196 | 196 | ||
197 | local argv = { | 197 | local argv = { |
198 | fs.Qb(dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)), | 198 | fs.Qb(cfg.variables["LUA"]), |
199 | "-e", | 199 | "-e", |
200 | fs.Qb(table.concat(luainit, ";")), | 200 | fs.Qb(table.concat(luainit, ";")), |
201 | script and fs.Qb(script) or "%I%", | 201 | script and fs.Qb(script) or "%I%", |
diff --git a/src/luarocks/test/command.lua b/src/luarocks/test/command.lua index 58fa22cb..afdb5cb6 100644 --- a/src/luarocks/test/command.lua +++ b/src/luarocks/test/command.lua | |||
@@ -2,7 +2,6 @@ | |||
2 | local command = {} | 2 | local command = {} |
3 | 3 | ||
4 | local fs = require("luarocks.fs") | 4 | local fs = require("luarocks.fs") |
5 | local dir = require("luarocks.dir") | ||
6 | local cfg = require("luarocks.core.cfg") | 5 | local cfg = require("luarocks.core.cfg") |
7 | 6 | ||
8 | local unpack = table.unpack or unpack | 7 | local unpack = table.unpack or unpack |
@@ -31,7 +30,7 @@ function command.run_tests(test, args) | |||
31 | if not fs.exists(test.script) then | 30 | if not fs.exists(test.script) then |
32 | return nil, "Test script " .. test.script .. " does not exist" | 31 | return nil, "Test script " .. test.script .. " does not exist" |
33 | end | 32 | end |
34 | local lua = fs.Q(dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)) -- get lua interpreter configured | 33 | local lua = fs.Q(cfg.variables["LUA"]) -- get lua interpreter configured |
35 | ok = fs.execute(lua, test.script, unpack(args)) | 34 | ok = fs.execute(lua, test.script, unpack(args)) |
36 | elseif test.command then | 35 | elseif test.command then |
37 | ok = fs.execute(test.command, unpack(args)) | 36 | ok = fs.execute(test.command, unpack(args)) |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index dd05b4ac..0a900ecc 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -434,11 +434,11 @@ do | |||
434 | return '"' .. pathname .. '"' | 434 | return '"' .. pathname .. '"' |
435 | end | 435 | end |
436 | 436 | ||
437 | function util.check_lua_version(lua_exe, luaver) | 437 | function util.check_lua_version(lua, luaver) |
438 | if not util.exists(lua_exe) then | 438 | if not util.exists(lua) then |
439 | return nil | 439 | return nil |
440 | end | 440 | end |
441 | local lv, err = util.popen_read(Q(lua_exe) .. ' -e "io.write(_VERSION:sub(5))"') | 441 | local lv, err = util.popen_read(Q(lua) .. ' -e "io.write(_VERSION:sub(5))"') |
442 | if lv == "" then | 442 | if lv == "" then |
443 | return nil | 443 | return nil |
444 | end | 444 | end |
@@ -457,8 +457,8 @@ do | |||
457 | 457 | ||
458 | local ljv | 458 | local ljv |
459 | if cfg.lua_version == "5.1" then | 459 | if cfg.lua_version == "5.1" then |
460 | -- Ignores extra version info for custom builds, e.g. "LuaJIT 2.1.0-beta3 some-other-version-info" | 460 | -- Ignores extra version info for custom builds, e.g. "LuaJIT 2.1.0-beta3 some-other-version-info" |
461 | ljv = util.popen_read(Q(cfg.variables["LUA_BINDIR"] .. "/" .. cfg.lua_interpreter) .. ' -e "io.write(tostring(jit and jit.version:gsub([[^%S+ (%S+).*]], [[%1]])))"') | 461 | ljv = util.popen_read(Q(cfg.variables.LUA) .. ' -e "io.write(tostring(jit and jit.version:gsub([[^%S+ (%S+).*]], [[%1]])))"') |
462 | if ljv == "nil" then | 462 | if ljv == "nil" then |
463 | ljv = nil | 463 | ljv = nil |
464 | end | 464 | end |
@@ -502,17 +502,17 @@ do | |||
502 | local dir_sep = package.config:sub(1, 1) | 502 | local dir_sep = package.config:sub(1, 1) |
503 | for _, d in ipairs({ prefix .. dir_sep .. "bin", prefix }) do | 503 | for _, d in ipairs({ prefix .. dir_sep .. "bin", prefix }) do |
504 | for _, name in ipairs(names) do | 504 | for _, name in ipairs(names) do |
505 | local lua_exe = d .. dir_sep .. name | 505 | local lua = d .. dir_sep .. name |
506 | local is_wrapper, err = util.lua_is_wrapper(lua_exe) | 506 | local is_wrapper, err = util.lua_is_wrapper(lua) |
507 | if is_wrapper == false then | 507 | if is_wrapper == false then |
508 | local lv = util.check_lua_version(lua_exe, luaver) | 508 | local lv = util.check_lua_version(lua, luaver) |
509 | if lv then | 509 | if lv then |
510 | return name, d, lv | 510 | return lua, d, lv |
511 | end | 511 | end |
512 | elseif is_wrapper == true or err == nil then | 512 | elseif is_wrapper == true or err == nil then |
513 | table.insert(tried, lua_exe) | 513 | table.insert(tried, lua) |
514 | else | 514 | else |
515 | table.insert(tried, string.format("%-13s (%s)", lua_exe, err)) | 515 | table.insert(tried, string.format("%-13s (%s)", lua, err)) |
516 | end | 516 | end |
517 | end | 517 | end |
518 | end | 518 | end |
@@ -525,15 +525,15 @@ do | |||
525 | end | 525 | end |
526 | 526 | ||
527 | function util.find_lua(prefix, luaver, verbose) | 527 | function util.find_lua(prefix, luaver, verbose) |
528 | local lua_interpreter, bindir | 528 | local lua, bindir |
529 | lua_interpreter, bindir, luaver = find_lua_bindir(prefix, luaver, verbose) | 529 | lua, bindir, luaver = find_lua_bindir(prefix, luaver, verbose) |
530 | if not lua_interpreter then | 530 | if not lua then |
531 | return nil, bindir | 531 | return nil, bindir |
532 | end | 532 | end |
533 | 533 | ||
534 | return { | 534 | return { |
535 | lua_version = luaver, | 535 | lua_version = luaver, |
536 | lua_interpreter = lua_interpreter, | 536 | lua = lua, |
537 | lua_dir = prefix, | 537 | lua_dir = prefix, |
538 | lua_bindir = bindir, | 538 | lua_bindir = bindir, |
539 | } | 539 | } |