aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--install.bat5
-rw-r--r--rockspec3
-rwxr-xr-xsrc/bin/luarocks1
-rw-r--r--src/luarocks/build.lua2
-rw-r--r--src/luarocks/cfg.lua34
-rw-r--r--src/luarocks/config_cmd.lua58
-rw-r--r--src/luarocks/fetch.lua3
-rw-r--r--src/luarocks/fs.lua3
-rw-r--r--src/luarocks/fs/win32.lua1
-rw-r--r--src/luarocks/help.lua12
-rw-r--r--src/luarocks/util.lua6
-rwxr-xr-xtest/testing.sh16
12 files changed, 116 insertions, 28 deletions
diff --git a/install.bat b/install.bat
index 52d21355..ffde28db 100644
--- a/install.bat
+++ b/install.bat
@@ -729,7 +729,8 @@ IF NOT "%LUA_PATH_5_3%"=="" (
729) 729)
730SET "PATH=$BINDIR;%PATH%" 730SET "PATH=$BINDIR;%PATH%"
731"$LUA_BINDIR\$LUA_INTERPRETER" "$BINDIR\]]..c..[[.lua" %* 731"$LUA_BINDIR\$LUA_INTERPRETER" "$BINDIR\]]..c..[[.lua" %*
732IF NOT "%ERRORLEVEL%"=="2" GOTO EXITLR 732SET EXITCODE=%ERRORLEVEL%
733IF NOT "%EXITCODE%"=="2" GOTO EXITLR
733 734
734REM Permission denied error, try and auto elevate... 735REM Permission denied error, try and auto elevate...
735REM already an admin? (checking to prevent loops) 736REM already an admin? (checking to prevent loops)
@@ -758,7 +759,7 @@ ECHO Now retrying as a priviledged user...
758PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('%TMPFILE%', '', '', 'runas') 759PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('%TMPFILE%', '', '', 'runas')
759 760
760:EXITLR 761:EXITLR
761ENDLOCAL 762exit /b %EXITCODE%
762]]) 763]])
763 f:close() 764 f:close()
764 print(S"Created LuaRocks command: $BINDIR\\"..c..".bat") 765 print(S"Created LuaRocks command: $BINDIR\\"..c..".bat")
diff --git a/rockspec b/rockspec
index 5b0ffc9c..bb7645f9 100644
--- a/rockspec
+++ b/rockspec
@@ -1,5 +1,6 @@
1package = "LuaRocks" 1package = "LuaRocks"
2local VER = "scm-1" 2local VER = "scm"
3version = VER .. "-1"
3 4
4source = { 5source = {
5 url = "--this rockspec is used by `make bootstrap` only--", 6 url = "--this rockspec is used by `make bootstrap` only--",
diff --git a/src/bin/luarocks b/src/bin/luarocks
index d2f3c220..be6c2b81 100755
--- a/src/bin/luarocks
+++ b/src/bin/luarocks
@@ -27,6 +27,7 @@ commands = {
27 purge = "luarocks.purge", 27 purge = "luarocks.purge",
28 doc = "luarocks.doc", 28 doc = "luarocks.doc",
29 upload = "luarocks.upload", 29 upload = "luarocks.upload",
30 config = "luarocks.config_cmd",
30} 31}
31 32
32command_line.run_command(...) 33command_line.run_command(...)
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua
index 977be344..68f20264 100644
--- a/src/luarocks/build.lua
+++ b/src/luarocks/build.lua
@@ -132,7 +132,7 @@ function build.apply_patches(rockspec)
132end 132end
133 133
134local function install_default_docs(name, version) 134local function install_default_docs(name, version)
135 local patterns = { "readme", "license", "copying" } 135 local patterns = { "readme", "license", "copying", ".*%.md" }
136 local dest = dir.path(path.install_dir(name, version), "doc") 136 local dest = dir.path(path.install_dir(name, version), "doc")
137 local has_dir = false 137 local has_dir = false
138 for file in fs.dir() do 138 for file in fs.dir() do
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 49ce5188..20aa4a21 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -146,16 +146,17 @@ cfg.variables = {}
146cfg.rocks_trees = {} 146cfg.rocks_trees = {}
147 147
148sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" 148sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua"
149local err, errcode 149do
150sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) 150 local err, errcode
151
152if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file
153 sys_config_file = sys_config_dir.."/config.lua"
154 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) 151 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg)
155end 152 if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file
156if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error 153 sys_config_file = sys_config_dir.."/config.lua"
157 io.stderr:write(err.."\n") 154 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg)
158 os.exit(cfg.errorcodes.CONFIGFILE) 155 end
156 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")
158 os.exit(cfg.errorcodes.CONFIGFILE)
159 end
159end 160end
160 161
161local env_for_config_file = { 162local env_for_config_file = {
@@ -228,7 +229,7 @@ local defaults = {
228 229
229 rocks_servers = { 230 rocks_servers = {
230 { 231 {
231 "https://rocks.moonscript.org", 232 "https://luarocks.org",
232 "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/", 233 "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/",
233 "http://luafr.org/moonrocks/", 234 "http://luafr.org/moonrocks/",
234 "http://luarocks.logiceditor.com/rocks", 235 "http://luarocks.logiceditor.com/rocks",
@@ -237,7 +238,7 @@ local defaults = {
237 disabled_servers = {}, 238 disabled_servers = {},
238 239
239 upload = { 240 upload = {
240 server = "https://rocks.moonscript.org", 241 server = "https://luarocks.org",
241 tool_version = "1.0.0", 242 tool_version = "1.0.0",
242 api_version = "1", 243 api_version = "1",
243 }, 244 },
@@ -590,7 +591,16 @@ function cfg.init_package_paths()
590end 591end
591 592
592function cfg.which_config() 593function cfg.which_config()
593 return sys_config_file, sys_config_ok, home_config_file, home_config_ok 594 return {
595 system = {
596 file = sys_config_file,
597 ok = sys_config_ok,
598 },
599 user = {
600 file = home_config_file,
601 ok = home_config_ok,
602 }
603 }
594end 604end
595 605
596cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch 606cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch
diff --git a/src/luarocks/config_cmd.lua b/src/luarocks/config_cmd.lua
new file mode 100644
index 00000000..c066cfec
--- /dev/null
+++ b/src/luarocks/config_cmd.lua
@@ -0,0 +1,58 @@
1--- Module implementing the LuaRocks "config" command.
2-- Queries information about the LuaRocks configuration.
3local config_cmd = {}
4
5local cfg = require("luarocks.cfg")
6local util = require("luarocks.util")
7local dir = require("luarocks.dir")
8
9local function config_file(conf)
10 print(dir.normalize(conf.file))
11 if conf.ok then
12 return true
13 else
14 return nil, "file not found"
15 end
16end
17
18--- Driver function for "config" command.
19-- @return boolean: True if succeeded, nil on errors.
20function config_cmd.run(...)
21 local flags = util.parse_flags(...)
22
23 if flags["lua-incdir"] then
24 print(cfg.variables.LUA_INCDIR)
25 return true
26 end
27 if flags["lua-libdir"] then
28 print(cfg.variables.LUA_LIBDIR)
29 return true
30 end
31 if flags["lua-ver"] then
32 print(cfg.lua_version)
33 return true
34 end
35 local conf = cfg.which_config()
36 if flags["system-config"] then
37 return config_file(conf.system)
38 end
39 if flags["user-config"] then
40 return config_file(conf.user)
41 end
42
43 if flags["rock-trees"] then
44 for _, tree in ipairs(cfg.rocks_trees) do
45 if type(tree) == "string" then
46 util.printout(dir.normalize(tree))
47 else
48 local name = tree.name and "\t"..tree.name or ""
49 util.printout(dir.normalize(tree.root)..name)
50 end
51 end
52 return true
53 end
54
55 return nil, "Please provide a flag for querying configuration values. "..util.see_help("config")
56end
57
58return config_cmd
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua
index 497ae84f..83c76c9c 100644
--- a/src/luarocks/fetch.lua
+++ b/src/luarocks/fetch.lua
@@ -193,9 +193,8 @@ function fetch.load_local_rockspec(filename, quick)
193 end 193 end
194 local globals = err 194 local globals = err
195 195
196 local ok, err = true, nil
197 if not quick then 196 if not quick then
198 ok, err = type_check.type_check_rockspec(rockspec, globals) 197 local ok, err = type_check.type_check_rockspec(rockspec, globals)
199 if not ok then 198 if not ok then
200 return nil, filename..": "..err 199 return nil, filename..": "..err
201 end 200 end
diff --git a/src/luarocks/fs.lua b/src/luarocks/fs.lua
index 72e11c09..57302c7f 100644
--- a/src/luarocks/fs.lua
+++ b/src/luarocks/fs.lua
@@ -31,7 +31,8 @@ fs.verbose = function() -- patch io.popen and os.execute to display commands
31 31
32 old_exec = os.execute 32 old_exec = os.execute
33 os.execute = function(cmd) 33 os.execute = function(cmd)
34 print("\nos.execute: ", cmd) 34 -- redact api keys if present
35 print("\nos.execute: ", (cmd:gsub("(/api/[^/]+/)([^/]+)/", function(cap, key) return cap.."<redacted>/" end)) )
35 local code = pack(old_exec(cmd)) 36 local code = pack(old_exec(cmd))
36 print("Results: "..tostring(code.n)) 37 print("Results: "..tostring(code.n))
37 for i = 1,code.n do 38 for i = 1,code.n do
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua
index 12d86d1d..32766e53 100644
--- a/src/luarocks/fs/win32.lua
+++ b/src/luarocks/fs/win32.lua
@@ -125,6 +125,7 @@ function win32.wrap_script(file, dest, name, version)
125 local ppaths = "package.path="..util.LQ(lpath..";").."..package.path; package.cpath="..util.LQ(lcpath..";").."..package.cpath" 125 local ppaths = "package.path="..util.LQ(lpath..";").."..package.path; package.cpath="..util.LQ(lcpath..";").."..package.cpath"
126 local addctx = "local k,l,_=pcall(require,"..util.LQ("luarocks.loader")..") _=k and l.add_context("..util.LQ(name)..","..util.LQ(version)..")" 126 local addctx = "local k,l,_=pcall(require,"..util.LQ("luarocks.loader")..") _=k and l.add_context("..util.LQ(name)..","..util.LQ(version)..")"
127 wrapper:write(fs.Qb(lua)..' -e '..fs.Qb(ppaths)..' -e '..fs.Qb(addctx)..' '..fs.Qb(file)..' %*\n') 127 wrapper:write(fs.Qb(lua)..' -e '..fs.Qb(ppaths)..' -e '..fs.Qb(addctx)..' '..fs.Qb(file)..' %*\n')
128 wrapper:write("exit /b %ERRORLEVEL%\n")
128 wrapper:close() 129 wrapper:close()
129 return true 130 return true
130end 131end
diff --git a/src/luarocks/help.lua b/src/luarocks/help.lua
index e6c214ff..92458b2b 100644
--- a/src/luarocks/help.lua
+++ b/src/luarocks/help.lua
@@ -31,10 +31,8 @@ end
31local function get_status(status) 31local function get_status(status)
32 if status then 32 if status then
33 return "ok" 33 return "ok"
34 elseif status == false then
35 return "not found"
36 else 34 else
37 return "failed" 35 return "not found"
38 end 36 end
39end 37end
40 38
@@ -47,7 +45,7 @@ function help.run(...)
47 local flags, command = util.parse_flags(...) 45 local flags, command = util.parse_flags(...)
48 46
49 if not command then 47 if not command then
50 local sys_file, sys_ok, home_file, home_ok = cfg.which_config() 48 local conf = cfg.which_config()
51 print_banner() 49 print_banner()
52 print_section("NAME") 50 print_section("NAME")
53 util.printout("\t"..program..[[ - ]]..program_description) 51 util.printout("\t"..program..[[ - ]]..program_description)
@@ -83,9 +81,9 @@ function help.run(...)
83 print_section("CONFIGURATION") 81 print_section("CONFIGURATION")
84 util.printout("\tLua version: " .. cfg.lua_version) 82 util.printout("\tLua version: " .. cfg.lua_version)
85 util.printout("\tConfiguration files:") 83 util.printout("\tConfiguration files:")
86 util.printout("\t\tSystem: ".. dir.normalize(sys_file) .. " (" .. get_status(sys_ok) ..")") 84 util.printout("\t\tSystem: ".. dir.normalize(conf.system.file) .. " (" .. get_status(conf.system.ok) ..")")
87 if home_file then 85 if conf.user.file then
88 util.printout("\t\tUser : ".. dir.normalize(home_file) .. " (" .. get_status(home_ok) ..")\n") 86 util.printout("\t\tUser : ".. dir.normalize(conf.user.file) .. " (" .. get_status(conf.user.ok) ..")\n")
89 else 87 else
90 util.printout("\t\tUser : disabled in this LuaRocks installation.\n") 88 util.printout("\t\tUser : disabled in this LuaRocks installation.\n")
91 end 89 end
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index 682c99e9..6a99b568 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -97,6 +97,9 @@ local supported_flags = {
97 ["lr-cpath"] = true, 97 ["lr-cpath"] = true,
98 ["lr-path"] = true, 98 ["lr-path"] = true,
99 ["lua-version"] = "<vers>", 99 ["lua-version"] = "<vers>",
100 ["lua-ver"] = true,
101 ["lua-incdir"] = true,
102 ["lua-libdir"] = true,
100 ["modules"] = true, 103 ["modules"] = true,
101 ["mversion"] = true, 104 ["mversion"] = true,
102 ["no-refresh"] = true, 105 ["no-refresh"] = true,
@@ -114,15 +117,18 @@ local supported_flags = {
114 ["quick"] = true, 117 ["quick"] = true,
115 ["rock-dir"] = true, 118 ["rock-dir"] = true,
116 ["rock-tree"] = true, 119 ["rock-tree"] = true,
120 ["rock-trees"] = true,
117 ["rockspec"] = true, 121 ["rockspec"] = true,
118 ["server"] = "<server>", 122 ["server"] = "<server>",
119 ["skip-pack"] = true, 123 ["skip-pack"] = true,
120 ["source"] = true, 124 ["source"] = true,
121 ["summary"] = "\"<text>\"", 125 ["summary"] = "\"<text>\"",
126 ["system-config"] = true,
122 ["tag"] = "<tag>", 127 ["tag"] = "<tag>",
123 ["timeout"] = "<seconds>", 128 ["timeout"] = "<seconds>",
124 ["to"] = "<path>", 129 ["to"] = "<path>",
125 ["tree"] = "<path>", 130 ["tree"] = "<path>",
131 ["user-config"] = true,
126 ["verbose"] = true, 132 ["verbose"] = true,
127 ["version"] = true, 133 ["version"] = true,
128} 134}
diff --git a/test/testing.sh b/test/testing.sh
index 0fa6fe92..8d972d4c 100755
--- a/test/testing.sh
+++ b/test/testing.sh
@@ -256,10 +256,11 @@ mkdir -p "$testing_server"
256 get "$luarocks_repo/luaposix-33.2.1-1.src.rock" 256 get "$luarocks_repo/luaposix-33.2.1-1.src.rock"
257 get "$luarocks_repo/md5-1.2-1.src.rock" 257 get "$luarocks_repo/md5-1.2-1.src.rock"
258 get "$luarocks_repo/lmathx-20120430.51-1.src.rock" 258 get "$luarocks_repo/lmathx-20120430.51-1.src.rock"
259 get "$luarocks_repo/lmathx-20120430.52-1.src.rock"
260 get "$luarocks_repo/lmathx-20120430.51-1.rockspec" 259 get "$luarocks_repo/lmathx-20120430.51-1.rockspec"
260 get "$luarocks_repo/lmathx-20120430.52-1.src.rock"
261 get "$luarocks_repo/lmathx-20120430.52-1.rockspec" 261 get "$luarocks_repo/lmathx-20120430.52-1.rockspec"
262 get "$luarocks_repo/lmathx-20140620-1.rockspec" 262 get "$luarocks_repo/lmathx-20150505-1.src.rock"
263 get "$luarocks_repo/lmathx-20150505-1.rockspec"
263 get "$luarocks_repo/lua-path-0.2.3-1.src.rock" 264 get "$luarocks_repo/lua-path-0.2.3-1.src.rock"
264 get "$luarocks_repo/lua-cjson-2.1.0-1.src.rock" 265 get "$luarocks_repo/lua-cjson-2.1.0-1.src.rock"
265 get "$luarocks_repo/luacov-coveralls-0.1.1-1.src.rock" 266 get "$luarocks_repo/luacov-coveralls-0.1.1-1.src.rock"
@@ -496,6 +497,17 @@ fail_write_rockspec_args_url() { $luarocks write_rockspec http://example.com/inv
496test_write_rockspec_http() { $luarocks write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1; } 497test_write_rockspec_http() { $luarocks write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1; }
497test_write_rockspec_basedir() { $luarocks write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1; } 498test_write_rockspec_basedir() { $luarocks write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1; }
498 499
500fail_config_noflags() { $luarocks config; }
501test_config_lua_incdir() { $luarocks config --lua-incdir; }
502test_config_lua_libdir() { $luarocks config --lua-libdir; }
503test_config_lua_ver() { $luarocks config --lua-ver; }
504fail_config_system_config() { rm -f "$testing_lrprefix/etc/luarocks/config.lua"; $luarocks config --system-config; }
505test_config_system_config() { mkdir -p "$testing_lrprefix/etc/luarocks"; touch "$testing_lrprefix/etc/luarocks/config.lua"; $luarocks config --system-config; err=$?; rm -f "$testing_lrprefix/etc/luarocks/config.lua"; return $err; }
506fail_config_system_config_invalid() { mkdir -p "$testing_lrprefix/etc/luarocks"; echo "if if if" > "$testing_lrprefix/etc/luarocks/config.lua"; $luarocks config --system-config; err=$?; rm -f "$testing_lrprefix/etc/luarocks/config.lua"; return $err; }
507test_config_user_config() { $luarocks config --user-config; }
508fail_config_user_config() { LUAROCKS_CONFIG="/missing_file.lua" $luarocks config --user-config; }
509test_config_rock_trees() { $luarocks config --rock-trees; }
510
499test_doc() { $luarocks install luarepl; $luarocks doc luarepl; } 511test_doc() { $luarocks install luarepl; $luarocks doc luarepl; }
500 512
501# Driver ######################################### 513# Driver #########################################