aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rwxr-xr-xconfigure10
-rw-r--r--src/luarocks/cfg.lua27
-rw-r--r--src/luarocks/fs/unix/tools.lua2
-rw-r--r--src/luarocks/persist.lua67
-rw-r--r--src/luarocks/upload.lua4
-rw-r--r--src/luarocks/upload/api.lua3
-rwxr-xr-xtest/testing.sh43
8 files changed, 96 insertions, 61 deletions
diff --git a/.travis.yml b/.travis.yml
index cf2b1e6b..54778583 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,5 +6,6 @@ env:
6 matrix: 6 matrix:
7 - LUA_VER=5.1.5 7 - LUA_VER=5.1.5
8 - LUA_VER=5.2.3 8 - LUA_VER=5.2.3
9 - LUA_VER=5.3.0
9 10
10script: cd test && ./testing.sh --travis --lua $LUA_VER 11script: cd test && ./testing.sh --travis --lua $LUA_VER
diff --git a/configure b/configure
index b1fa834a..33e52d9a 100755
--- a/configure
+++ b/configure
@@ -262,17 +262,17 @@ search_interpreter() {
262 find_lua="$LUA_BINDIR" 262 find_lua="$LUA_BINDIR"
263 elif [ "$LUA_DIR_SET" = "yes" ] 263 elif [ "$LUA_DIR_SET" = "yes" ]
264 then 264 then
265 if [ -f "$LUA_DIR/bin/lua$suffix" ] 265 if [ -f "$LUA_DIR/bin/lua$LUA_SUFFIX" ]
266 then 266 then
267 find_lua="$LUA_DIR/bin" 267 find_lua="$LUA_DIR/bin"
268 fi 268 fi
269 else 269 else
270 find_lua=`find_program lua$suffix` 270 find_lua=`find_program lua$LUA_SUFFIX`
271 fi 271 fi
272 if [ -n "$find_lua" ] 272 if [ -n "$find_lua" -a -x "$find_lua/lua$LUA_SUFFIX" ]
273 then 273 then
274 echo "Lua interpreter: $find_lua/lua$suffix..." 274 echo "Lua interpreter found: $find_lua/lua$LUA_SUFFIX..."
275 detect_lua_version "$find_lua/lua$suffix" 275 detect_lua_version "$find_lua/lua$LUA_SUFFIX"
276 return 0 276 return 0
277 fi 277 fi
278 return 1 278 return 1
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 09640ca2..25bd1553 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -44,6 +44,7 @@ cfg.errorcodes = setmetatable({
44 OK = 0, 44 OK = 0,
45 UNSPECIFIED = 1, 45 UNSPECIFIED = 1,
46 PERMISSIONDENIED = 2, 46 PERMISSIONDENIED = 2,
47 CONFIGFILE = 3,
47 CRASH = 99 48 CRASH = 99
48},{ 49},{
49 __index = function(t, key) 50 __index = function(t, key)
@@ -145,28 +146,29 @@ cfg.variables = {}
145cfg.rocks_trees = {} 146cfg.rocks_trees = {}
146 147
147sys_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"
148local err 149local err, errcode
149sys_config_ok, err = persist.load_into_table(sys_config_file, cfg) 150sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg)
150 151
151if not sys_config_ok then 152if (not sys_config_ok) and errcode ~= "run" then
152 sys_config_file = sys_config_dir.."/config.lua" 153 sys_config_file = sys_config_dir.."/config.lua"
153 sys_config_ok, err = persist.load_into_table(sys_config_file, cfg) 154 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg)
154end 155end
155if err and sys_config_ok == nil then 156if (not sys_config_ok) and errcode ~= "open" then
156 io.stderr:write(err.."\n") 157 io.stderr:write(err.."\n")
158 os.exit(cfg.errorcodes.CONFIGFILE)
157end 159end
158 160
159if not site_config.LUAROCKS_FORCE_CONFIG then 161if not site_config.LUAROCKS_FORCE_CONFIG then
160 local home_overrides, err 162 local home_overrides, err, errcode
161 home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG") 163 home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG")
162 if home_config_file then 164 if home_config_file then
163 home_overrides, err = persist.load_into_table(home_config_file, { home = cfg.home, lua_version = cfg.lua_version }) 165 home_overrides, err, errcode = persist.load_into_table(home_config_file, { home = cfg.home, lua_version = cfg.lua_version })
164 else 166 else
165 home_config_file = home_config_dir.."/config-"..cfg.lua_version..".lua" 167 home_config_file = home_config_dir.."/config-"..cfg.lua_version..".lua"
166 home_overrides, err = persist.load_into_table(home_config_file, { home = cfg.home, lua_version = cfg.lua_version }) 168 home_overrides, err, errcode = persist.load_into_table(home_config_file, { home = cfg.home, lua_version = cfg.lua_version })
167 if not home_overrides then 169 if (not home_overrides) and (not errcode == "run") then
168 home_config_file = home_config_dir.."/config.lua" 170 home_config_file = home_config_dir.."/config.lua"
169 home_overrides, err = persist.load_into_table(home_config_file, { home = cfg.home, lua_version = cfg.lua_version }) 171 home_overrides, err, errcode = persist.load_into_table(home_config_file, { home = cfg.home, lua_version = cfg.lua_version })
170 end 172 end
171 end 173 end
172 if home_overrides then 174 if home_overrides then
@@ -178,10 +180,11 @@ if not site_config.LUAROCKS_FORCE_CONFIG then
178 cfg.rocks_servers = nil 180 cfg.rocks_servers = nil
179 end 181 end
180 util.deep_merge(cfg, home_overrides) 182 util.deep_merge(cfg, home_overrides)
181 else -- nil or false 183 else
182 home_config_ok = home_overrides 184 home_config_ok = home_overrides
183 if err and home_config_ok == nil then 185 if errcode ~= "open" then
184 io.stderr:write(err.."\n") 186 io.stderr:write(err.."\n")
187 os.exit(cfg.errorcodes.CONFIGFILE)
185 end 188 end
186 end 189 end
187end 190end
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua
index 8db1f0e5..43174749 100644
--- a/src/luarocks/fs/unix/tools.lua
+++ b/src/luarocks/fs/unix/tools.lua
@@ -12,7 +12,7 @@ local dir_stack = {}
12local vars = cfg.variables 12local vars = cfg.variables
13 13
14local function command_at(directory, cmd) 14local function command_at(directory, cmd)
15 return "cd " .. fs.Q(directory) .. " && " .. cmd 15 return "cd " .. fs.Q(fs.absolute_name(directory)) .. " && " .. cmd
16end 16end
17 17
18--- Obtain current directory. 18--- Obtain current directory.
diff --git a/src/luarocks/persist.lua b/src/luarocks/persist.lua
index 9d601a43..39e1e71c 100644
--- a/src/luarocks/persist.lua
+++ b/src/luarocks/persist.lua
@@ -9,18 +9,52 @@ package.loaded["luarocks.persist"] = persist
9 9
10local util = require("luarocks.util") 10local util = require("luarocks.util")
11 11
12local function run_file(filename, env)
13 local fd, err, errno = io.open(filename)
14 if not fd then
15 return nil, err, "open"
16 end
17 local str, err = fd:read("*a")
18 fd:close()
19 if not str then
20 return nil, err, "open"
21 end
22 str = str:gsub("^#![^\n]*\n", "")
23 local chunk, ran
24 if _VERSION == "Lua 5.1" then -- Lua 5.1
25 chunk, err = loadstring(str, filename)
26 if chunk then
27 setfenv(chunk, env)
28 ran, err = pcall(chunk)
29 end
30 else -- Lua 5.2
31 chunk, err = loadfile(filename, "t", env)
32 if chunk then
33 ran, err = pcall(chunk)
34 end
35 end
36 if not chunk then
37 return nil, "Error loading file: "..err, "load"
38 end
39 if not ran then
40 return nil, "Error running file: "..err, "run"
41 end
42 return true, err
43end
44
12--- Load a Lua file containing assignments, storing them in a table. 45--- Load a Lua file containing assignments, storing them in a table.
13-- The global environment is not propagated to the loaded file. 46-- The global environment is not propagated to the loaded file.
14-- @param filename string: the name of the file. 47-- @param filename string: the name of the file.
15-- @param tbl table or nil: if given, this table is used to store 48-- @param tbl table or nil: if given, this table is used to store
16-- loaded values. 49-- loaded values.
17-- @return table or (nil, string): a table with the file's assignments 50-- @return table or (nil, string, string): a table with the file's assignments
18-- as fields, or nil and a message in case of errors. 51-- as fields, or nil, an error message and an error code ("load" or "run")
52-- in case of errors.
19function persist.load_into_table(filename, tbl) 53function persist.load_into_table(filename, tbl)
20 assert(type(filename) == "string") 54 assert(type(filename) == "string")
21 assert(type(tbl) == "table" or not tbl) 55 assert(type(tbl) == "table" or not tbl)
22 56
23 local result, chunk, ran, err 57 local result, ok, err
24 result = tbl or {} 58 result = tbl or {}
25 local globals = {} 59 local globals = {}
26 local globals_mt = { 60 local globals_mt = {
@@ -31,28 +65,13 @@ function persist.load_into_table(filename, tbl)
31 } 65 }
32 local save_mt = getmetatable(result) 66 local save_mt = getmetatable(result)
33 setmetatable(result, globals_mt) 67 setmetatable(result, globals_mt)
34 if _VERSION == "Lua 5.1" then -- Lua 5.1
35 chunk, err = loadfile(filename)
36 if chunk then
37 setfenv(chunk, result)
38 ran, err = pcall(chunk)
39 end
40 else -- Lua 5.2
41 chunk, err = loadfile(filename, "t", result)
42 if chunk then
43 ran, err = pcall(chunk)
44 end
45 end
46 setmetatable(result, save_mt)
47 68
48 if not chunk then 69 ok, err, errcode = run_file(filename, result)
49 if err:sub(1,5) ~= filename:sub(1,5) then 70
50 return false, err 71 setmetatable(result, save_mt)
51 end 72
52 return nil, "Error loading file: "..err 73 if not ok then
53 end 74 return nil, err, errcode
54 if not ran then
55 return nil, "Error running file: "..err
56 end 75 end
57 return result, globals 76 return result, globals
58end 77end
diff --git a/src/luarocks/upload.lua b/src/luarocks/upload.lua
index d87313a4..19ddee8d 100644
--- a/src/luarocks/upload.lua
+++ b/src/luarocks/upload.lua
@@ -54,7 +54,7 @@ function upload.run(...)
54 end 54 end
55 55
56 local rock_fname 56 local rock_fname
57 if not flags["skip-pack"] then 57 if not flags["skip-pack"] and not rockspec.version:match("^scm") then
58 util.printout("Packing " .. tostring(rockspec.package)) 58 util.printout("Packing " .. tostring(rockspec.package))
59 rock_fname, err = pack.pack_source_rock(fname) 59 rock_fname, err = pack.pack_source_rock(fname)
60 if not rock_fname then 60 if not rock_fname then
@@ -77,7 +77,7 @@ function upload.run(...)
77 77
78 if rock_fname then 78 if rock_fname then
79 util.printout(("Sending " .. tostring(rock_fname) .. " ...")) 79 util.printout(("Sending " .. tostring(rock_fname) .. " ..."))
80 res, err = api:method("upload_rock/" .. tostring(res.version.id), nil, { 80 res, err = api:method("upload_rock/" .. ("%d"):format(res.version.id), nil, {
81 rock_file = multipart.new_file(rock_fname) 81 rock_file = multipart.new_file(rock_fname)
82 }) 82 })
83 if not res then return nil, err end 83 if not res then return nil, err end
diff --git a/src/luarocks/upload/api.lua b/src/luarocks/upload/api.lua
index c5883355..97c3598e 100644
--- a/src/luarocks/upload/api.lua
+++ b/src/luarocks/upload/api.lua
@@ -156,6 +156,9 @@ function Api:request(url, params, post_params)
156 curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " 156 curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." "
157 end 157 end
158 ok = fs.execute_string(curl_cmd..fs.Q(url).." -o "..fs.Q(tmpfile)) 158 ok = fs.execute_string(curl_cmd..fs.Q(url).." -o "..fs.Q(tmpfile))
159 if not ok then
160 return nil, "API failure: " .. tostring(url)
161 end
159 else 162 else
160 local ok, err = fs.download(url, tmpfile) 163 local ok, err = fs.download(url, tmpfile)
161 if not ok then 164 if not ok then
diff --git a/test/testing.sh b/test/testing.sh
index 9a8fd412..4b159892 100755
--- a/test/testing.sh
+++ b/test/testing.sh
@@ -32,6 +32,7 @@ fi
32 32
33testing_dir="$PWD" 33testing_dir="$PWD"
34 34
35testing_lrprefix="$testing_dir/testing_lrprefix-$luaversion"
35testing_tree="$testing_dir/testing-$luaversion" 36testing_tree="$testing_dir/testing-$luaversion"
36testing_sys_tree="$testing_dir/testing_sys-$luaversion" 37testing_sys_tree="$testing_dir/testing_sys-$luaversion"
37testing_tree_copy="$testing_dir/testing_copy-$luaversion" 38testing_tree_copy="$testing_dir/testing_copy-$luaversion"
@@ -51,6 +52,7 @@ fi
51rm -f luacov.report.out 52rm -f luacov.report.out
52rm -rf /tmp/luarocks_testing 53rm -rf /tmp/luarocks_testing
53mkdir /tmp/luarocks_testing 54mkdir /tmp/luarocks_testing
55rm -rf "$testing_lrprefix"
54rm -rf "$testing_tree" 56rm -rf "$testing_tree"
55rm -rf "$testing_sys_tree" 57rm -rf "$testing_sys_tree"
56rm -rf "$testing_tree_copy" 58rm -rf "$testing_tree_copy"
@@ -171,10 +173,10 @@ verrev_luasocket=${version_luasocket}-1
171srcdir_luasocket=luasocket-3.0-rc1 173srcdir_luasocket=luasocket-3.0-rc1
172 174
173version_cprint=0.1 175version_cprint=0.1
174verrev_cprint=0.1-1 176verrev_cprint=0.1-2
175 177
176version_luacov=0.5 178version_luacov=0.7
177verrev_luacov=0.5-1 179verrev_luacov=${version_luacov}-1
178version_lxsh=0.8.6 180version_lxsh=0.8.6
179version_validate_args=1.5.4 181version_validate_args=1.5.4
180verrev_validate_args=1.5.4-1 182verrev_validate_args=1.5.4-1
@@ -183,7 +185,7 @@ verrev_lxsh=${version_lxsh}-2
183luasec=luasec 185luasec=luasec
184 186
185cd .. 187cd ..
186./configure --with-lua="$luadir" 188./configure --with-lua="$luadir" --prefix="$testing_lrprefix"
187make clean 189make clean
188make src/luarocks/site_config.lua 190make src/luarocks/site_config.lua
189make dev 191make dev
@@ -217,8 +219,7 @@ luarocks_admin_nocov="run_lua --nocov luarocks-admin"
217mkdir -p "$testing_server" 219mkdir -p "$testing_server"
218( 220(
219 cd "$testing_server" 221 cd "$testing_server"
220 luarocks_repo="http://luarocks.org/repositories/rocks" 222 luarocks_repo="http://rocks.moonscript.org"
221 luarocks_scm_repo="http://luarocks.org/repositories/rocks-scm"
222 get() { [ -e `basename "$1"` ] || wget -c "$1"; } 223 get() { [ -e `basename "$1"` ] || wget -c "$1"; }
223 get "$luarocks_repo/luacov-${verrev_luacov}.src.rock" 224 get "$luarocks_repo/luacov-${verrev_luacov}.src.rock"
224 get "$luarocks_repo/luacov-${verrev_luacov}.rockspec" 225 get "$luarocks_repo/luacov-${verrev_luacov}.rockspec"
@@ -226,11 +227,11 @@ mkdir -p "$testing_server"
226 get "$luarocks_repo/lualogging-1.3.0-1.src.rock" 227 get "$luarocks_repo/lualogging-1.3.0-1.src.rock"
227 get "$luarocks_repo/luasocket-${verrev_luasocket}.src.rock" 228 get "$luarocks_repo/luasocket-${verrev_luasocket}.src.rock"
228 get "$luarocks_repo/luasocket-${verrev_luasocket}.rockspec" 229 get "$luarocks_repo/luasocket-${verrev_luasocket}.rockspec"
229 get "$luarocks_repo/luafilesystem-1.6.2-1.src.rock" 230 get "$luarocks_repo/luafilesystem-1.6.3-1.src.rock"
230 get "$luarocks_repo/stdlib-35-1.src.rock" 231 get "$luarocks_repo/stdlib-41.0.0-1.src.rock"
231 get "$luarocks_repo/luarepl-0.4-1.src.rock" 232 get "$luarocks_repo/luarepl-0.4-1.src.rock"
232 get "$luarocks_repo/validate-args-1.5.4-1.rockspec" 233 get "$luarocks_repo/validate-args-1.5.4-1.rockspec"
233 get "$luarocks_scm_repo/luasec-scm-1.rockspec" 234 get "$luarocks_repo/luasec-0.5-2.rockspec"
234 get "$luarocks_repo/luabitop-1.0.2-1.rockspec" 235 get "$luarocks_repo/luabitop-1.0.2-1.rockspec"
235 get "$luarocks_repo/lpty-1.0.1-1.src.rock" 236 get "$luarocks_repo/lpty-1.0.1-1.src.rock"
236 get "$luarocks_repo/cprint-${verrev_cprint}.src.rock" 237 get "$luarocks_repo/cprint-${verrev_cprint}.src.rock"
@@ -238,14 +239,16 @@ mkdir -p "$testing_server"
238 get "$luarocks_repo/wsapi-1.6-1.src.rock" 239 get "$luarocks_repo/wsapi-1.6-1.src.rock"
239 get "$luarocks_repo/lxsh-${verrev_lxsh}.src.rock" 240 get "$luarocks_repo/lxsh-${verrev_lxsh}.src.rock"
240 get "$luarocks_repo/abelhas-1.0-1.rockspec" 241 get "$luarocks_repo/abelhas-1.0-1.rockspec"
241 get "$luarocks_repo/lzlib-0.4.work3-1.src.rock" 242 get "$luarocks_repo/lzlib-0.4.1.53-1.src.rock"
242 get "$luarocks_repo/lpeg-0.12-1.src.rock" 243 get "$luarocks_repo/lpeg-0.12-1.src.rock"
243 get "$luarocks_repo/luaposix-31-1.src.rock" 244 get "$luarocks_repo/luaposix-33.2.1-1.src.rock"
244 get "$luarocks_repo/md5-1.2-1.src.rock" 245 get "$luarocks_repo/md5-1.2-1.src.rock"
245 get "$luarocks_repo/lrandom-20120430.51-1.src.rock" 246 get "$luarocks_repo/lmathx-20120430.51-1.src.rock"
246 get "$luarocks_repo/lrandom-20120430.52-1.src.rock" 247 get "$luarocks_repo/lmathx-20120430.52-1.src.rock"
247 get "$luarocks_repo/lrandom-20120430.51-1.rockspec" 248 get "$luarocks_repo/lmathx-20120430.51-1.rockspec"
248 get "$luarocks_repo/lrandom-20120430.52-1.rockspec" 249 get "$luarocks_repo/lmathx-20120430.52-1.rockspec"
250 get "$luarocks_repo/lmathx-20140620-1.rockspec"
251 get "$luarocks_repo/lmathx-20140620-1.rockspec"
249) 252)
250$luarocks_admin_nocov make_manifest "$testing_server" 253$luarocks_admin_nocov make_manifest "$testing_server"
251 254
@@ -322,6 +325,8 @@ fail_unknown_command() { $luarocks unknown_command; }
322 325
323test_empty_list() { $luarocks list; } 326test_empty_list() { $luarocks list; }
324 327
328fail_bad_sysconfig() { local err=0; local scdir="$testing_lrprefix/etc/luarocks/"; mkdir -p "$scdir"; local sysconfig="$scdir/config.lua"; echo "aoeui" > "$sysconfig"; echo $sysconfig; $luarocks list; err=$?; rm "$sysconfig"; return "$err"; }
329
325fail_build_noarg() { $luarocks build; } 330fail_build_noarg() { $luarocks build; }
326fail_download_noarg() { $luarocks download; } 331fail_download_noarg() { $luarocks download; }
327fail_install_noarg() { $luarocks install; } 332fail_install_noarg() { $luarocks install; }
@@ -353,7 +358,7 @@ test_build_https() { need_luasocket; $luarocks download --rockspec validate-args
353test_build_supported_platforms() { $luarocks build lpty; } 358test_build_supported_platforms() { $luarocks build lpty; }
354fail_build_missing_external() { $luarocks build "$testing_dir/testfiles/missing_external-0.1-1.rockspec" INEXISTENT_INCDIR="/invalid/dir"; } 359fail_build_missing_external() { $luarocks build "$testing_dir/testfiles/missing_external-0.1-1.rockspec" INEXISTENT_INCDIR="/invalid/dir"; }
355 360
356test_build_deps_partial_match() { $luarocks build lrandom; } 361test_build_deps_partial_match() { $luarocks build lmathx; }
357test_build_show_downloads() { export LUAROCKS_CONFIG="$testing_dir/testing_config_show_downloads.lua" && $luarocks build alien; export LUAROCKS_CONFIG="$testing_dir/testing_config.lua"; } 362test_build_show_downloads() { export LUAROCKS_CONFIG="$testing_dir/testing_config_show_downloads.lua" && $luarocks build alien; export LUAROCKS_CONFIG="$testing_dir/testing_config.lua"; }
358 363
359test_download_all() { $luarocks download --all validate-args && rm validate-args-*; } 364test_download_all() { $luarocks download --all validate-args && rm validate-args-*; }
@@ -491,7 +496,11 @@ run_with_full_environment() {
491 echo "===========================================" 496 echo "==========================================="
492 echo "Running with full environment" 497 echo "Running with full environment"
493 echo "===========================================" 498 echo "==========================================="
494 build_environment luacov luafilesystem luasocket luabitop luaposix md5 lzlib 499
500 local bitop=
501 [ "$luaversion" = "5.1.5" ] && bitop=luabitop
502
503 build_environment luacov luafilesystem luasocket $bitop luaposix md5 lzlib
495 run_tests $1 504 run_tests $1
496} 505}
497 506