aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/cfg.lua17
-rw-r--r--src/luarocks/help.lua4
-rw-r--r--src/luarocks/persist.lua10
3 files changed, 27 insertions, 4 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 8a783237..9fce84f8 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -91,6 +91,7 @@ end
91-- Path configuration: 91-- Path configuration:
92 92
93local sys_config_file, home_config_file 93local sys_config_file, home_config_file
94local sys_config_ok, home_config_ok = false, false
94if detected.windows or detected.mingw32 then 95if detected.windows or detected.mingw32 then
95 home = os.getenv("APPDATA") or "c:" 96 home = os.getenv("APPDATA") or "c:"
96 sys_config_file = "c:/luarocks/config.lua" 97 sys_config_file = "c:/luarocks/config.lua"
@@ -106,12 +107,18 @@ end
106variables = {} 107variables = {}
107rocks_trees = {} 108rocks_trees = {}
108 109
109persist.load_into_table(site_config.LUAROCKS_SYSCONFIG or sys_config_file, _M) 110local ok, err = persist.load_into_table(site_config.LUAROCKS_SYSCONFIG or sys_config_file, _M)
111if ok then
112 sys_config_ok = true
113elseif err and ok == nil then
114 io.stderr:write(err.."\n")
115end
110 116
111if not site_config.LUAROCKS_FORCE_CONFIG then 117if not site_config.LUAROCKS_FORCE_CONFIG then
112 home_config_file = os.getenv("LUAROCKS_CONFIG") or home_config_file 118 home_config_file = os.getenv("LUAROCKS_CONFIG") or home_config_file
113 local home_overrides = persist.load_into_table(home_config_file, { home = home }) 119 local home_overrides, err = persist.load_into_table(home_config_file, { home = home })
114 if home_overrides then 120 if home_overrides then
121 home_config_ok = true
115 local util = require("luarocks.util") 122 local util = require("luarocks.util")
116 if home_overrides.rocks_trees then 123 if home_overrides.rocks_trees then
117 _M.rocks_trees = nil 124 _M.rocks_trees = nil
@@ -120,6 +127,8 @@ if not site_config.LUAROCKS_FORCE_CONFIG then
120 _M.rocks_servers = nil 127 _M.rocks_servers = nil
121 end 128 end
122 util.deep_merge(_M, home_overrides) 129 util.deep_merge(_M, home_overrides)
130 elseif err and home_overrides == nil then
131 io.stderr:write(err.."\n")
123 end 132 end
124end 133end
125 134
@@ -404,6 +413,10 @@ for _,tree in ipairs(rocks_trees) do
404 end 413 end
405end 414end
406 415
416function which_config()
417 return sys_config_file, sys_config_ok, home_config_file, home_config_ok
418end
419
407--- Check if platform was detected 420--- Check if platform was detected
408-- @param query string: The platform name to check. 421-- @param query string: The platform name to check.
409-- @return boolean: true if LuaRocks is currently running on queried platform. 422-- @return boolean: true if LuaRocks is currently running on queried platform.
diff --git a/src/luarocks/help.lua b/src/luarocks/help.lua
index 718580ce..6272d213 100644
--- a/src/luarocks/help.lua
+++ b/src/luarocks/help.lua
@@ -25,9 +25,13 @@ function run(...)
25 local flags, command = util.parse_flags(...) 25 local flags, command = util.parse_flags(...)
26 26
27 if not command then 27 if not command then
28 local sys_file, sys_ok, home_file, home_ok = cfg.which_config()
28 util.printout([[ 29 util.printout([[
29LuaRocks ]]..cfg.program_version..[[, a module deployment system for Lua 30LuaRocks ]]..cfg.program_version..[[, a module deployment system for Lua
30 31
32Using system configuration file: ]]..sys_file .. " (" .. (sys_ok and "ok" or "failed") ..[[)
33and user configuration file: ]]..home_file .. " (" .. (home_ok and "ok" or "failed") ..[[)
34
31]]..program_name..[[ - ]]..program_description..[[ 35]]..program_name..[[ - ]]..program_description..[[
32 36
33usage: ]]..program_name..[[ [--from=<server> | --only-from=<server>] [--to=<tree>] [VAR=VALUE]... <command> [<argument>] 37usage: ]]..program_name..[[ [--from=<server> | --only-from=<server>] [--to=<tree>] [VAR=VALUE]... <command> [<argument>]
diff --git a/src/luarocks/persist.lua b/src/luarocks/persist.lua
index 91c28a32..6d411e0f 100644
--- a/src/luarocks/persist.lua
+++ b/src/luarocks/persist.lua
@@ -20,11 +20,17 @@ function load_into_table(filename, tbl)
20 20
21 local chunk, err = loadfile(filename) 21 local chunk, err = loadfile(filename)
22 if not chunk then 22 if not chunk then
23 return nil, err 23 if err:sub(1,5) ~= filename:sub(1,5) then
24 return false, err
25 end
26 return nil, "Error loading file: "..err
24 end 27 end
25 local result = tbl or {} 28 local result = tbl or {}
26 setfenv(chunk, result) 29 setfenv(chunk, result)
27 chunk() 30 local ok, err = pcall(chunk)
31 if not ok then
32 return nil, "Error running file: "..err
33 end
28 return result 34 return result
29end 35end
30 36