diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-06-20 09:04:54 +0200 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-06-20 09:04:54 +0200 |
| commit | 84f886f401a6ae362357ff65d9ac58e8b6ebc37d (patch) | |
| tree | cc3de872df1d648d4bceba6d7e5ca53d70524158 /src | |
| parent | fdcecd17fc27eb6c2fab9192b66bb03c3b55bf11 (diff) | |
| parent | 998d012a7228099990a88454150e843559074e0c (diff) | |
| download | luarocks-84f886f401a6ae362357ff65d9ac58e8b6ebc37d.tar.gz luarocks-84f886f401a6ae362357ff65d9ac58e8b6ebc37d.tar.bz2 luarocks-84f886f401a6ae362357ff65d9ac58e8b6ebc37d.zip | |
Merge pull request #385 from Tieske/master
Read os variables from config files
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cfg.lua | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index a02caaee..48623765 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -145,13 +145,28 @@ end | |||
| 145 | cfg.variables = {} | 145 | cfg.variables = {} |
| 146 | cfg.rocks_trees = {} | 146 | cfg.rocks_trees = {} |
| 147 | 147 | ||
| 148 | -- The global environment in the config files; | ||
| 149 | local env_for_config_file | ||
| 150 | env_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 | |||
| 148 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" | 163 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" |
| 149 | do | 164 | do |
| 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 |
| 160 | end | 175 | end |
| 161 | 176 | ||
| 162 | local 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 | |||
| 169 | if not site_config.LUAROCKS_FORCE_CONFIG then | 177 | if not site_config.LUAROCKS_FORCE_CONFIG then |
| 170 | 178 | ||
| 171 | local home_overrides, err, errcode | 179 | local home_overrides, err, errcode |
