aboutsummaryrefslogtreecommitdiff
path: root/spec/util
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-06-20 10:28:49 -0300
committerHisham Muhammad <hisham@gobolinux.org>2018-07-01 15:51:13 -0300
commit4c1c170b9d344b6c069c8e6df5798f6e0bd63966 (patch)
tree21b0061a4c41434239320db45749ec5b4086be4c /spec/util
parent50cd8ea8941d38678e8e6cf82065108dc3217d91 (diff)
downloadluarocks-4c1c170b9d344b6c069c8e6df5798f6e0bd63966.tar.gz
luarocks-4c1c170b9d344b6c069c8e6df5798f6e0bd63966.tar.bz2
luarocks-4c1c170b9d344b6c069c8e6df5798f6e0bd63966.zip
cfg, cmd: major reorganization
* `--lua-dir` flag, specifying a prefix for the Lua installation to be used. This reconfigures LuaRocks entirely, including allowing a LuaRocks which is itself running using one Lua 5.x version to manage packages for a different Lua 5.y version. The resulting configuration can be checked with `luarocks config --lua-dir=<path>`. * requiring `luarocks.core.cfg` no longer has side-effects * configuration now needs to be initialized with `cfg.init([lua_data])`, where `lua_data` is a table with the configuration of the VM: * `lua_version` - e.g. `"5.3"` * `luajit_version` - e.g. `"2.1.0-beta3"` * `lua_interpreter` - e.g. `"lua5.3"` * `lua_bindir` - e.g. `"/usr/local/bin"` * `lua_libdir` - e.g. `"/usr/local/lib"` * `lua_incdir` - e.g. `"/usr/local/include/lua-5.3"` * `cfg.init` can be called multiple times, reconfiguring the global state. This is important since `luarocks.loader` now calls it, and the `--lua-dir` command line can override the configuration and reconfigure LuaRocks. * `site_config_*` is no more: LuaRocks is no longer dependent on a properly-written site_config file. Instead, it can *optionally* use `luarocks.core.hardcoded` for hardcoded values, or detect its configuration at runtime, based on OS detection, arg[-1] or command-line flags. * reduction of moving parts in the configuration: * `cfg.platforms` is no longer a globally-visible table; instead, `cfg` provides an API of read-only functions: `is_platform`, `each_platform`, `print_platforms`. * `cfg.*_proxy` options are no longer configured via the config files, but rather via the standard `*_proxy` environment variables. * `"windows"` is now the more general platform name of the Windows family. This is technically a breaking change but I don't expect it to cause problems with real-world rockspecs. * internal code reorganization in `luarocks.cmd` module
Diffstat (limited to 'spec/util')
-rw-r--r--spec/util/test_env.lua43
1 files changed, 30 insertions, 13 deletions
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua
index 6d8a962c..1d4e98d8 100644
--- a/spec/util/test_env.lua
+++ b/spec/util/test_env.lua
@@ -40,6 +40,10 @@ function test_env.exists(path)
40 return lfs.attributes(path, "mode") ~= nil 40 return lfs.attributes(path, "mode") ~= nil
41end 41end
42 42
43function test_env.file_if_exists(path)
44 return lfs.attributes(path, "mode") and path
45end
46
43--- Quote argument for shell processing. Fixes paths on Windows. 47--- Quote argument for shell processing. Fixes paths on Windows.
44-- Adds double quotes and escapes. Based on function in fs/win32.lua. 48-- Adds double quotes and escapes. Based on function in fs/win32.lua.
45-- @param arg string: Unquoted argument. 49-- @param arg string: Unquoted argument.
@@ -251,7 +255,15 @@ function test_env.set_args()
251 end 255 end
252 end 256 end
253 end 257 end
258 print(test_env.TEST_TARGET_OS)
259 end
260
261 if test_env.TEST_TARGET_OS == "windows" then
262 test_env.lib_extension = "dll"
263 else
264 test_env.lib_extension = "so"
254 end 265 end
266
255 return true 267 return true
256end 268end
257 269
@@ -394,12 +406,8 @@ local function create_env(testing_paths)
394 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" 406 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;"
395 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" 407 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;"
396 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" 408 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;"
397 local lib_extension = "so" 409 env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?." .. test_env.lib_extension .. ";"
398 if test_env.TEST_TARGET_OS == "windows" then 410 .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?." .. test_env.lib_extension .. ";"
399 lib_extension = "dll"
400 end
401 env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?." .. lib_extension .. ";"
402 .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?." .. lib_extension .. ";"
403 env_variables.PATH = os.getenv("PATH") .. ";" .. testing_paths.testing_tree .. "/bin;" .. testing_paths.testing_sys_tree .. "/bin;" 411 env_variables.PATH = os.getenv("PATH") .. ";" .. testing_paths.testing_tree .. "/bin;" .. testing_paths.testing_sys_tree .. "/bin;"
404 412
405 return env_variables 413 return env_variables
@@ -584,8 +592,7 @@ function test_env.setup_specs(extra_rocks)
584 592
585 package.path = test_env.env_variables.LUA_PATH 593 package.path = test_env.env_variables.LUA_PATH
586 594
587 test_env.platform = execute_output(test_env.testing_paths.lua .. " -e \"print(require('luarocks.core.cfg').arch)\"", false, test_env.env_variables) 595 test_env.platform = execute_output(test_env.testing_paths.lua .. " -e \"cfg = require('luarocks.core.cfg'); cfg.init(); print(cfg.arch)\"", false, test_env.env_variables)
588 test_env.lib_extension = execute_output(test_env.testing_paths.lua .. " -e \"print(require('luarocks.core.cfg').lib_extension)\"", false, test_env.env_variables)
589 test_env.wrapper_extension = test_env.TEST_TARGET_OS == "windows" and ".bat" or "" 596 test_env.wrapper_extension = test_env.TEST_TARGET_OS == "windows" and ".bat" or ""
590 test_env.md5sums = create_md5sums(test_env.testing_paths) 597 test_env.md5sums = create_md5sums(test_env.testing_paths)
591 test_env.setup_done = true 598 test_env.setup_done = true
@@ -737,11 +744,21 @@ local function install_luarocks(install_env_vars)
737 assert(execute_bool("install.bat /LUA " .. testing_paths.luadir .. " " .. compiler_flag .. " /P " .. testing_paths.testing_lrprefix .. " /NOREG /NOADMIN /F /Q /CONFIG " .. testing_paths.testing_lrprefix .. "/etc/luarocks", false, install_env_vars)) 744 assert(execute_bool("install.bat /LUA " .. testing_paths.luadir .. " " .. compiler_flag .. " /P " .. testing_paths.testing_lrprefix .. " /NOREG /NOADMIN /F /Q /CONFIG " .. testing_paths.testing_lrprefix .. "/etc/luarocks", false, install_env_vars))
738 assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/core/site_config* " .. testing_paths.src_dir .. "/luarocks/core")) 745 assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/core/site_config* " .. testing_paths.src_dir .. "/luarocks/core"))
739 else 746 else
740 local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix 747 local incfile = test_env.file_if_exists(testing_paths.luadir .. "/include/lua.h")
741 assert(execute_bool(configure_cmd, false, install_env_vars)) 748 or test_env.file_if_exists(testing_paths.luadir .. "/include/lua/" .. test_env.lua_version .. "/lua.h")
742 assert(execute_bool("make clean", false, install_env_vars)) 749 or test_env.file_if_exists(testing_paths.luadir .. "/include/lua" .. test_env.lua_version .. "/lua.h")
743 assert(execute_bool("make src/luarocks/core/site_config_"..test_env.lua_version:gsub("%.", "_")..".lua", false, install_env_vars)) 750 local incdir = assert(incfile):gsub("/lua.h$", "")
744 assert(execute_bool("make dev", false, install_env_vars)) 751
752 local lines = {
753 "return {",
754 ("SYSCONFDIR = %q,"):format(testing_paths.testing_lrprefix .. "/etc/luarocks"),
755 ("LUA_DIR = %q,"):format(testing_paths.luadir),
756 ("LUA_INCDIR = %q,"):format(incdir),
757 ("LUA_LIBDIR = %q,"):format(testing_paths.luadir .. "/lib"),
758 ("LUA_BINDIR = %q,"):format(testing_paths.luadir .. "/bin"),
759 "}",
760 }
761 test_env.write_file("src/luarocks/core/hardcoded.lua", table.concat(lines, "\n") .. "\n")
745 end 762 end
746 print("LuaRocks installed correctly!") 763 print("LuaRocks installed correctly!")
747end 764end