diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-06-18 18:01:19 +0200 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-06-18 18:01:19 +0200 |
| commit | 998d012a7228099990a88454150e843559074e0c (patch) | |
| tree | b7e8dad14f4bcd684d67fd4d631218341f3054ef /src | |
| parent | 4792618d8882eb36c9e9d05efac8b1ae336f00cb (diff) | |
| download | luarocks-998d012a7228099990a88454150e843559074e0c.tar.gz luarocks-998d012a7228099990a88454150e843559074e0c.tar.bz2 luarocks-998d012a7228099990a88454150e843559074e0c.zip | |
fix: use same environment table for the system config file as well.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cfg.lua | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 87fb1dda..6ce2ff24 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -145,28 +145,7 @@ end | |||
| 145 | cfg.variables = {} | 145 | cfg.variables = {} |
| 146 | cfg.rocks_trees = {} | 146 | cfg.rocks_trees = {} |
| 147 | 147 | ||
| 148 | -- some extras for the global environment in the config files; | 148 | -- The global environment in the config files; |
| 149 | cfg.os_getenv = os.getenv | ||
| 150 | cfg.__dump_env = function() | ||
| 151 | -- debug function, calling it from a config file will show all | ||
| 152 | -- available globals to that config file | ||
| 153 | print(util.show_table(cfg, "global environment")) | ||
| 154 | end | ||
| 155 | |||
| 156 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" | ||
| 157 | do | ||
| 158 | local err, errcode | ||
| 159 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) | ||
| 160 | if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file | ||
| 161 | sys_config_file = sys_config_dir.."/config.lua" | ||
| 162 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) | ||
| 163 | end | ||
| 164 | if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error | ||
| 165 | io.stderr:write(err.."\n") | ||
| 166 | os.exit(cfg.errorcodes.CONFIGFILE) | ||
| 167 | end | ||
| 168 | end | ||
| 169 | |||
| 170 | local env_for_config_file | 149 | local env_for_config_file |
| 171 | env_for_config_file = { | 150 | env_for_config_file = { |
| 172 | home = cfg.home, | 151 | home = cfg.home, |
| @@ -174,13 +153,27 @@ env_for_config_file = { | |||
| 174 | platform = util.make_shallow_copy(detected), | 153 | platform = util.make_shallow_copy(detected), |
| 175 | processor = proc, | 154 | processor = proc, |
| 176 | os_getenv = os.getenv, | 155 | os_getenv = os.getenv, |
| 177 | __dump_env = function() | 156 | dump_env = function() |
| 178 | -- debug function, calling it from a config file will show all | 157 | -- debug function, calling it from a config file will show all |
| 179 | -- available globals to that config file | 158 | -- available globals to that config file |
| 180 | print(util.show_table(env_for_config_file, "global environment")) | 159 | print(util.show_table(env_for_config_file, "global environment")) |
| 181 | end, | 160 | end, |
| 182 | } | 161 | } |
| 183 | 162 | ||
| 163 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" | ||
| 164 | do | ||
| 165 | local err, errcode | ||
| 166 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file) | ||
| 167 | if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file | ||
| 168 | sys_config_file = sys_config_dir.."/config.lua" | ||
| 169 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file) | ||
| 170 | end | ||
| 171 | if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error | ||
| 172 | io.stderr:write(err.."\n") | ||
| 173 | os.exit(cfg.errorcodes.CONFIGFILE) | ||
| 174 | end | ||
| 175 | end | ||
| 176 | |||
| 184 | if not site_config.LUAROCKS_FORCE_CONFIG then | 177 | if not site_config.LUAROCKS_FORCE_CONFIG then |
| 185 | 178 | ||
| 186 | local home_overrides, err, errcode | 179 | local home_overrides, err, errcode |
