diff options
Diffstat (limited to 'src/luarocks/cfg.lua')
-rw-r--r-- | src/luarocks/cfg.lua | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 2758ce0f..881db683 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -9,7 +9,10 @@ local rawset, next, table, pairs, print, require, io, os, setmetatable, pcall, i | |||
9 | -- file format documentation</a> for details. | 9 | -- file format documentation</a> for details. |
10 | module("luarocks.cfg") | 10 | module("luarocks.cfg") |
11 | 11 | ||
12 | program_version = "2.0" | 12 | -- Load site-local global configurations |
13 | local config = require("luarocks.config") | ||
14 | |||
15 | program_version = "2.0.1" | ||
13 | user_agent = "LuaRocks/"..program_version | 16 | user_agent = "LuaRocks/"..program_version |
14 | 17 | ||
15 | local persist = require("luarocks.persist") | 18 | local persist = require("luarocks.persist") |
@@ -31,12 +34,12 @@ local detected = {} | |||
31 | local system,proc | 34 | local system,proc |
32 | 35 | ||
33 | -- A proper installation of LuaRocks will hardcode the system | 36 | -- A proper installation of LuaRocks will hardcode the system |
34 | -- and proc values with LUAROCKS_UNAME_S and LUAROCKS_UNAME_M, | 37 | -- and proc values with config.LUAROCKS_UNAME_S and config.LUAROCKS_UNAME_M, |
35 | -- so that this detection does not run every time. When it is | 38 | -- so that this detection does not run every time. When it is |
36 | -- performed, we use the Unix way to identify the system, | 39 | -- performed, we use the Unix way to identify the system, |
37 | -- even on Windows (assuming UnxUtils or Cygwin). | 40 | -- even on Windows (assuming UnxUtils or Cygwin). |
38 | system = LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") | 41 | system = config.LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") |
39 | proc = LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") | 42 | proc = config.LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") |
40 | if proc:match("i[%d]86") then | 43 | if proc:match("i[%d]86") then |
41 | proc = "x86" | 44 | proc = "x86" |
42 | elseif proc:match("amd64") or proc:match("x86_64") then | 45 | elseif proc:match("amd64") or proc:match("x86_64") then |
@@ -82,9 +85,9 @@ end | |||
82 | variables = {} | 85 | variables = {} |
83 | rocks_trees = {} | 86 | rocks_trees = {} |
84 | 87 | ||
85 | persist.load_into_table(LUAROCKS_SYSCONFIG or sys_config_file, _M) | 88 | persist.load_into_table(config.LUAROCKS_SYSCONFIG or sys_config_file, _M) |
86 | 89 | ||
87 | if not LUAROCKS_FORCE_CONFIG then | 90 | if not config.LUAROCKS_FORCE_CONFIG then |
88 | home_config_file = os.getenv("LUAROCKS_CONFIG") or home_config_file | 91 | home_config_file = os.getenv("LUAROCKS_CONFIG") or home_config_file |
89 | local home_overrides = persist.load_into_table(home_config_file, { home = home }) | 92 | local home_overrides = persist.load_into_table(home_config_file, { home = home }) |
90 | if home_overrides then | 93 | if home_overrides then |
@@ -97,14 +100,14 @@ if not next(rocks_trees) then | |||
97 | if home_tree then | 100 | if home_tree then |
98 | table.insert(rocks_trees, home_tree) | 101 | table.insert(rocks_trees, home_tree) |
99 | end | 102 | end |
100 | if LUAROCKS_ROCKS_TREE then | 103 | if config.LUAROCKS_ROCKS_TREE then |
101 | table.insert(rocks_trees, LUAROCKS_ROCKS_TREE) | 104 | table.insert(rocks_trees, config.LUAROCKS_ROCKS_TREE) |
102 | end | 105 | end |
103 | end | 106 | end |
104 | 107 | ||
105 | -- Configure defaults: | 108 | -- Configure defaults: |
106 | 109 | ||
107 | local root = LUAROCKS_ROCKS_TREE or home_tree | 110 | local root = config.LUAROCKS_ROCKS_TREE or home_tree |
108 | local defaults = { | 111 | local defaults = { |
109 | root_dir = root, | 112 | root_dir = root, |
110 | rocks_dir = root.."/lib/luarocks/rocks", | 113 | rocks_dir = root.."/lib/luarocks/rocks", |
@@ -123,9 +126,9 @@ local defaults = { | |||
123 | }, | 126 | }, |
124 | 127 | ||
125 | lua_extension = "lua", | 128 | lua_extension = "lua", |
126 | lua_interpreter = LUA_INTERPRETER or "lua", | 129 | lua_interpreter = config.LUA_INTERPRETER or "lua", |
127 | downloader = LUAROCKS_DOWNLOADER or "wget", | 130 | downloader = config.LUAROCKS_DOWNLOADER or "wget", |
128 | md5checker = LUAROCKS_MD5CHECKER or "md5sum", | 131 | md5checker = config.LUAROCKS_MD5CHECKER or "md5sum", |
129 | 132 | ||
130 | variables = {}, | 133 | variables = {}, |
131 | 134 | ||
@@ -149,9 +152,9 @@ if detected.windows then | |||
149 | defaults.external_lib_extension = "dll" | 152 | defaults.external_lib_extension = "dll" |
150 | defaults.obj_extension = "obj" | 153 | defaults.obj_extension = "obj" |
151 | defaults.external_deps_dirs = { "c:/external/" } | 154 | defaults.external_deps_dirs = { "c:/external/" } |
152 | defaults.variables.LUA_BINDIR = LUA_BINDIR and LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" | 155 | defaults.variables.LUA_BINDIR = config.LUA_BINDIR and config.LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" |
153 | defaults.variables.LUA_INCDIR = LUA_INCDIR and LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" | 156 | defaults.variables.LUA_INCDIR = config.LUA_INCDIR and config.LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" |
154 | defaults.variables.LUA_LIBDIR = LUA_LIBDIR and LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" | 157 | defaults.variables.LUA_LIBDIR = config.LUA_LIBDIR and config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" |
155 | defaults.cmake_generator = "MinGW Makefiles" | 158 | defaults.cmake_generator = "MinGW Makefiles" |
156 | defaults.make = "nmake" -- TODO: Split Windows flavors between mingw and msvc | 159 | defaults.make = "nmake" -- TODO: Split Windows flavors between mingw and msvc |
157 | defaults.makefile = "Makefile.win" | 160 | defaults.makefile = "Makefile.win" |
@@ -178,9 +181,9 @@ if detected.unix then | |||
178 | defaults.external_lib_extension = "so" | 181 | defaults.external_lib_extension = "so" |
179 | defaults.obj_extension = "o" | 182 | defaults.obj_extension = "o" |
180 | defaults.external_deps_dirs = { "/usr/local", "/usr" } | 183 | defaults.external_deps_dirs = { "/usr/local", "/usr" } |
181 | defaults.variables.LUA_BINDIR = LUA_BINDIR or "/usr/local/bin" | 184 | defaults.variables.LUA_BINDIR = config.LUA_BINDIR or "/usr/local/bin" |
182 | defaults.variables.LUA_INCDIR = LUA_INCDIR or "/usr/local/include" | 185 | defaults.variables.LUA_INCDIR = config.LUA_INCDIR or "/usr/local/include" |
183 | defaults.variables.LUA_LIBDIR = LUA_LIBDIR or "/usr/local/lib" | 186 | defaults.variables.LUA_LIBDIR = config.LUA_LIBDIR or "/usr/local/lib" |
184 | defaults.variables.CFLAGS = "-O2" | 187 | defaults.variables.CFLAGS = "-O2" |
185 | defaults.cmake_generator = "Unix Makefiles" | 188 | defaults.cmake_generator = "Unix Makefiles" |
186 | defaults.make = "make" | 189 | defaults.make = "make" |
@@ -245,7 +248,7 @@ end | |||
245 | defaults.variables.LUA = defaults.lua_interpreter | 248 | defaults.variables.LUA = defaults.lua_interpreter |
246 | defaults.variables.LIB_EXTENSION = defaults.lib_extension | 249 | defaults.variables.LIB_EXTENSION = defaults.lib_extension |
247 | defaults.variables.OBJ_EXTENSION = defaults.obj_extension | 250 | defaults.variables.OBJ_EXTENSION = defaults.obj_extension |
248 | defaults.variables.LUAROCKS_PREFIX = LUAROCKS_PREFIX | 251 | defaults.variables.LUAROCKS_PREFIX = config.LUAROCKS_PREFIX |
249 | 252 | ||
250 | -- Use defaults: | 253 | -- Use defaults: |
251 | 254 | ||