aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2020-02-07 10:42:50 +0100
committerGitHub <noreply@github.com>2020-02-07 10:42:50 +0100
commit1a7f921e4cf1d4023340a8ba4dde17cb3e6bd311 (patch)
tree1c56d34fe38719bd41815c914c53294e5e4bb3e0
parent201ac63c7692355b07b83034c1813c000ec70e84 (diff)
downloadluarocks-1a7f921e4cf1d4023340a8ba4dde17cb3e6bd311.tar.gz
luarocks-1a7f921e4cf1d4023340a8ba4dde17cb3e6bd311.tar.bz2
luarocks-1a7f921e4cf1d4023340a8ba4dde17cb3e6bd311.zip
fix downgrades of rocks containing directories (#1151)
Fixes #1141
-rw-r--r--spec/build_spec.lua8
-rw-r--r--spec/test_spec.lua18
-rw-r--r--src/luarocks/repos.lua6
3 files changed, 17 insertions, 15 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua
index 14837d89..e498509f 100644
--- a/spec/build_spec.lua
+++ b/spec/build_spec.lua
@@ -25,6 +25,8 @@ local extra_rocks = {
25 "/stdlib-41.0.0-1.src.rock", 25 "/stdlib-41.0.0-1.src.rock",
26 "/validate-args-1.5.4-1.rockspec", 26 "/validate-args-1.5.4-1.rockspec",
27 "spec/fixtures/a_rock-1.0-1.src.rock", 27 "spec/fixtures/a_rock-1.0-1.src.rock",
28 "/busted-2.0.0-1.rockspec",
29 "/busted-2.0.rc13-0.rockspec",
28} 30}
29 31
30local c_module_source = [[ 32local c_module_source = [[
@@ -290,6 +292,12 @@ describe("LuaRocks build #integration", function()
290 end) 292 end)
291 end 293 end
292 294
295 it("downgrades directories correctly", function()
296 assert(run.luarocks_bool("build --nodeps busted 2.0.0" ))
297 assert(run.luarocks_bool("build --nodeps busted 2.0.rc13" ))
298 assert(run.luarocks_bool("build --nodeps busted 2.0.0" ))
299 end)
300
293 it("only deps", function() 301 it("only deps", function()
294 local rockspec = testing_paths.fixtures_dir .. "/build_only_deps-0.1-1.rockspec" 302 local rockspec = testing_paths.fixtures_dir .. "/build_only_deps-0.1-1.rockspec"
295 303
diff --git a/spec/test_spec.lua b/spec/test_spec.lua
index ca1d5917..ddb64b0e 100644
--- a/spec/test_spec.lua
+++ b/spec/test_spec.lua
@@ -8,13 +8,13 @@ local write_file = test_env.write_file
8test_env.unload_luarocks() 8test_env.unload_luarocks()
9 9
10local extra_rocks = { 10local extra_rocks = {
11 "/busted-2.0.rc12-1.rockspec", 11 "/busted-2.0.0-1.rockspec",
12 "/lua_cliargs-3.0-1.src.rock", 12 "/lua_cliargs-3.0-1.src.rock",
13 "/luafilesystem-1.7.0-2.src.rock", 13 "/luafilesystem-1.7.0-2.src.rock",
14 "/luasystem-0.2.1-0.src.rock", 14 "/luasystem-0.2.1-0.src.rock",
15 "/dkjson-2.5-2.src.rock", 15 "/dkjson-2.5-2.src.rock",
16 "/say-1.3-1.rockspec", 16 "/say-1.3-1.rockspec",
17 "/luassert-1.7.10-0.rockspec", 17 "/luassert-1.8.0-0.rockspec",
18 "/lua-term-0.7-1.rockspec", 18 "/lua-term-0.7-1.rockspec",
19 "/penlight-1.5.4-1.rockspec", 19 "/penlight-1.5.4-1.rockspec",
20 "/mediator_lua-1.1.2-0.rockspec", 20 "/mediator_lua-1.1.2-0.rockspec",
@@ -40,16 +40,10 @@ describe("luarocks test #integration", function()
40 40
41 lazy_setup(function() 41 lazy_setup(function()
42 -- Try to cache rocks from the host system to speed up test 42 -- Try to cache rocks from the host system to speed up test
43 os.execute("luarocks pack busted") 43 for _, r in ipairs(extra_rocks) do
44 os.execute("luarocks pack lua_cliargs") 44 local n, v = r:match("^/(.*)%-([^%-]+)%-%d+%.[^%-]+$")
45 os.execute("luarocks pack luafilesystem") 45 os.execute("luarocks pack " .. n .. " " .. v)
46 os.execute("luarocks pack dkjson") 46 end
47 os.execute("luarocks pack luasystem")
48 os.execute("luarocks pack say")
49 os.execute("luarocks pack luassert")
50 os.execute("luarocks pack lua-term")
51 os.execute("luarocks pack penlight")
52 os.execute("luarocks pack mediator_lua")
53 if test_env.TEST_TARGET_OS == "windows" then 47 if test_env.TEST_TARGET_OS == "windows" then
54 os.execute("move *.rock " .. testing_paths.testing_server) 48 os.execute("move *.rock " .. testing_paths.testing_server)
55 else 49 else
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua
index e9dddc7c..b2a7d81a 100644
--- a/src/luarocks/repos.lua
+++ b/src/luarocks/repos.lua
@@ -272,7 +272,7 @@ local function backup_existing(should_backup, target)
272 until not fs.exists(backup) -- Slight race condition here, but shouldn't be a problem. 272 until not fs.exists(backup) -- Slight race condition here, but shouldn't be a problem.
273 273
274 util.warning(target.." is not tracked by this installation of LuaRocks. Moving it to "..backup) 274 util.warning(target.." is not tracked by this installation of LuaRocks. Moving it to "..backup)
275 local move_ok, move_err = fs.move(target, backup) 275 local move_ok, move_err = os.rename(target, backup)
276 if not move_ok then 276 if not move_ok then
277 return nil, move_err 277 return nil, move_err
278 end 278 end
@@ -331,7 +331,7 @@ end
331local function rollback_install(op) 331local function rollback_install(op)
332 fs.delete(op.dst) 332 fs.delete(op.dst)
333 if op.backup_file then 333 if op.backup_file then
334 fs.move(op.backup_file, op.dst) 334 os.rename(op.backup_file, op.dst)
335 end 335 end
336 fs.remove_dir_tree_if_empty(dir.dir_name(op.dst)) 336 fs.remove_dir_tree_if_empty(dir.dir_name(op.dst))
337 return true 337 return true
@@ -347,7 +347,7 @@ local function op_rename(op)
347 if fs.exists(op.src) then 347 if fs.exists(op.src) then
348 fs.make_dir(dir.dir_name(op.dst)) 348 fs.make_dir(dir.dir_name(op.dst))
349 fs.delete(op.dst) 349 fs.delete(op.dst)
350 local ok, err = fs.move(op.src, op.dst) 350 local ok, err = os.rename(op.src, op.dst)
351 fs.remove_dir_tree_if_empty(dir.dir_name(op.src)) 351 fs.remove_dir_tree_if_empty(dir.dir_name(op.src))
352 return ok, err 352 return ok, err
353 else 353 else