aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2016-10-18 18:16:38 -0400
committerHisham <hisham@gobolinux.org>2016-10-18 18:16:38 -0400
commitc5376c9bd5e9a0a87557494c9e737f80357fef82 (patch)
tree9ba67fad901f440b1e504a07bda6940fb8a342b7
parent6f928845e8d167cf4caf4828a79069d9b71cffd8 (diff)
parentf83a936687d33b9b5ec9211d8b5534650b471385 (diff)
downloadluarocks-c5376c9bd5e9a0a87557494c9e737f80357fef82.tar.gz
luarocks-c5376c9bd5e9a0a87557494c9e737f80357fef82.tar.bz2
luarocks-c5376c9bd5e9a0a87557494c9e737f80357fef82.zip
Merge branch 'master' into luarocks-3
-rw-r--r--spec/install_spec.lua15
-rw-r--r--src/luarocks/build.lua4
-rw-r--r--src/luarocks/install.lua6
-rw-r--r--src/luarocks/purge.lua2
-rw-r--r--src/luarocks/remove.lua11
-rw-r--r--src/luarocks/repos.lua14
-rw-r--r--test/test_environment.lua1
7 files changed, 39 insertions, 14 deletions
diff --git a/spec/install_spec.lua b/spec/install_spec.lua
index 8857e4bd..45b3e2f9 100644
--- a/spec/install_spec.lua
+++ b/spec/install_spec.lua
@@ -18,7 +18,9 @@ local extra_rocks = {
18 "/lxsh-0.8.6-2.rockspec", 18 "/lxsh-0.8.6-2.rockspec",
19 "/say-1.2-1.src.rock", 19 "/say-1.2-1.src.rock",
20 "/say-1.0-1.src.rock", 20 "/say-1.0-1.src.rock",
21 "/wsapi-1.6-1.src.rock" 21 "/wsapi-1.6-1.src.rock",
22 "/luafilesystem-1.6.3-2.src.rock",
23 "/luafilesystem-1.6.1-1.src.rock",
22} 24}
23 25
24describe("LuaRocks install tests #blackbox #b_install", function() 26describe("LuaRocks install tests #blackbox #b_install", function()
@@ -81,6 +83,17 @@ describe("LuaRocks install tests #blackbox #b_install", function()
81 end 83 end
82 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) 84 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec"))
83 end) 85 end)
86
87 it('LuaRocks install - handle versioned modules when installing another version with --keep #268', function()
88 assert.is_true(run.luarocks_bool("install luafilesystem"))
89 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension))
90 assert.is_true(run.luarocks_bool("install luafilesystem 1.6.1 --keep"))
91 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension))
92 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_1_1-lfs."..test_env.lib_extension))
93 assert.is_true(run.luarocks_bool("install luafilesystem"))
94 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension))
95 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_1_1-lfs."..test_env.lib_extension))
96 end)
84 97
85 it("LuaRocks install only-deps of luasocket packed rock", function() 98 it("LuaRocks install only-deps of luasocket packed rock", function()
86 assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) 99 assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2"))
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua
index d7d8ed07..c43ee949 100644
--- a/src/luarocks/build.lua
+++ b/src/luarocks/build.lua
@@ -225,7 +225,7 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m
225 end 225 end
226 226
227 if repos.is_installed(name, version) then 227 if repos.is_installed(name, version) then
228 repos.delete_version(name, version) 228 repos.delete_version(name, version, deps_mode)
229 end 229 end
230 230
231 if not minimal_mode then 231 if not minimal_mode then
@@ -353,7 +353,7 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m
353 353
354 util.remove_scheduled_function(rollback) 354 util.remove_scheduled_function(rollback)
355 rollback = util.schedule_function(function() 355 rollback = util.schedule_function(function()
356 repos.delete_version(name, version) 356 repos.delete_version(name, version, deps_mode)
357 end) 357 end)
358 358
359 ok, err = repos.run_hook(rockspec, "post_install") 359 ok, err = repos.run_hook(rockspec, "post_install")
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua
index c4139fd0..6dded8ee 100644
--- a/src/luarocks/install.lua
+++ b/src/luarocks/install.lua
@@ -48,7 +48,7 @@ function install.install_binary_rock(rock_file, deps_mode)
48 return nil, "Incompatible architecture "..arch, "arch" 48 return nil, "Incompatible architecture "..arch, "arch"
49 end 49 end
50 if repos.is_installed(name, version) then 50 if repos.is_installed(name, version) then
51 repos.delete_version(name, version) 51 repos.delete_version(name, version, deps_mode)
52 end 52 end
53 53
54 local rollback = util.schedule_function(function() 54 local rollback = util.schedule_function(function()
@@ -87,7 +87,7 @@ function install.install_binary_rock(rock_file, deps_mode)
87 87
88 util.remove_scheduled_function(rollback) 88 util.remove_scheduled_function(rollback)
89 rollback = util.schedule_function(function() 89 rollback = util.schedule_function(function()
90 repos.delete_version(name, version) 90 repos.delete_version(name, version, deps_mode)
91 end) 91 end)
92 92
93 ok, err = repos.run_hook(rockspec, "post_install") 93 ok, err = repos.run_hook(rockspec, "post_install")
@@ -166,7 +166,7 @@ function install.command(flags, name, version)
166 ok, err = install.install_binary_rock(name, deps.get_deps_mode(flags)) 166 ok, err = install.install_binary_rock(name, deps.get_deps_mode(flags))
167 end 167 end
168 if not ok then return nil, err end 168 if not ok then return nil, err end
169 local name, version = ok, err 169 name, version = ok, err
170 if (not flags["only-deps"]) and (not flags["keep"]) and not cfg.keep_other_versions then 170 if (not flags["only-deps"]) and (not flags["keep"]) and not cfg.keep_other_versions then
171 local ok, err = remove.remove_other_versions(name, version, flags["force"], flags["force-fast"]) 171 local ok, err = remove.remove_other_versions(name, version, flags["force"], flags["force-fast"])
172 if not ok then util.printerr(err) end 172 if not ok then util.printerr(err) end
diff --git a/src/luarocks/purge.lua b/src/luarocks/purge.lua
index 7647a243..50f290c8 100644
--- a/src/luarocks/purge.lua
+++ b/src/luarocks/purge.lua
@@ -64,7 +64,7 @@ function purge.command(flags)
64 break 64 break
65 else 65 else
66 util.printout("Removing "..package.." "..version.."...") 66 util.printout("Removing "..package.." "..version.."...")
67 local ok, err = repos.delete_version(package, version, true) 67 local ok, err = repos.delete_version(package, version, "none", true)
68 if not ok then 68 if not ok then
69 util.printerr(err) 69 util.printerr(err)
70 end 70 end
diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua
index e2c05176..008d2616 100644
--- a/src/luarocks/remove.lua
+++ b/src/luarocks/remove.lua
@@ -60,12 +60,15 @@ end
60--- Delete given versions of a program. 60--- Delete given versions of a program.
61-- @param name string: the name of a program 61-- @param name string: the name of a program
62-- @param versions array of string: the versions to be deleted. 62-- @param versions array of string: the versions to be deleted.
63-- @param deps_mode: string: Which trees to check dependencies for:
64-- "one" for the current default tree, "all" for all trees,
65-- "order" for all trees with priority >= the current default, "none" for no trees.
63-- @return boolean or (nil, string): true on success or nil and an error message. 66-- @return boolean or (nil, string): true on success or nil and an error message.
64local function delete_versions(name, versions) 67local function delete_versions(name, versions, deps_mode)
65 68
66 for version, _ in pairs(versions) do 69 for version, _ in pairs(versions) do
67 util.printout("Removing "..name.." "..version.."...") 70 util.printout("Removing "..name.." "..version.."...")
68 local ok, err = repos.delete_version(name, version) 71 local ok, err = repos.delete_version(name, version, deps_mode)
69 if not ok then return nil, err end 72 if not ok then return nil, err end
70 end 73 end
71 74
@@ -110,9 +113,7 @@ function remove.remove_search_results(results, name, deps_mode, force, fast)
110 end 113 end
111 end 114 end
112 115
113 local ok, err = delete_versions(name, versions) 116 local ok, err = delete_versions(name, versions, deps_mode)
114 if not ok then return nil, err end
115 ok, err = writer.make_manifest(cfg.rocks_dir, deps_mode)
116 if not ok then return nil, err end 117 if not ok then return nil, err end
117 118
118 util.printout("Removal successful.") 119 util.printout("Removal successful.")
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua
index 7acb00b9..a5698b8f 100644
--- a/src/luarocks/repos.lua
+++ b/src/luarocks/repos.lua
@@ -8,6 +8,7 @@ local cfg = require("luarocks.core.cfg")
8local util = require("luarocks.util") 8local util = require("luarocks.util")
9local dir = require("luarocks.dir") 9local dir = require("luarocks.dir")
10local manif = require("luarocks.manif") 10local manif = require("luarocks.manif")
11local writer = require("luarocks.manif.writer")
11local deps = require("luarocks.deps") 12local deps = require("luarocks.deps")
12 13
13--- Get all installed versions of a package. 14--- Get all installed versions of a package.
@@ -266,13 +267,17 @@ end
266-- Version numbers are compared as exact string comparison. 267-- Version numbers are compared as exact string comparison.
267-- @param name string: name of package 268-- @param name string: name of package
268-- @param version string: package version in string format 269-- @param version string: package version in string format
270-- @param deps_mode: string: Which trees to check dependencies for:
271-- "one" for the current default tree, "all" for all trees,
272-- "order" for all trees with priority >= the current default, "none" for no trees.
269-- @param quick boolean: do not try to fix the versioned name 273-- @param quick boolean: do not try to fix the versioned name
270-- of another version that provides the same module that 274-- of another version that provides the same module that
271-- was deleted. This is used during 'purge', as every module 275-- was deleted. This is used during 'purge', as every module
272-- will be eventually deleted. 276-- will be eventually deleted.
273function repos.delete_version(name, version, quick) 277function repos.delete_version(name, version, deps_mode, quick)
274 assert(type(name) == "string") 278 assert(type(name) == "string")
275 assert(type(version) == "string") 279 assert(type(version) == "string")
280 assert(type(deps_mode) == "string")
276 281
277 local function delete_deployed_file_tree(file_tree, deploy_dir, suffix) 282 local function delete_deployed_file_tree(file_tree, deploy_dir, suffix)
278 return recurse_rock_manifest_tree(file_tree, 283 return recurse_rock_manifest_tree(file_tree,
@@ -322,7 +327,12 @@ function repos.delete_version(name, version, quick)
322 if not get_installed_versions(name) then 327 if not get_installed_versions(name) then
323 fs.delete(dir.path(cfg.rocks_dir, name)) 328 fs.delete(dir.path(cfg.rocks_dir, name))
324 end 329 end
325 return true 330
331 if quick then
332 return true
333 end
334
335 return writer.make_manifest(cfg.rocks_dir, deps_mode)
326end 336end
327 337
328return repos 338return repos
diff --git a/test/test_environment.lua b/test/test_environment.lua
index f04c22b8..f813707a 100644
--- a/test/test_environment.lua
+++ b/test/test_environment.lua
@@ -514,6 +514,7 @@ function test_env.setup_specs(extra_rocks)
514 package.path = test_env.env_variables.LUA_PATH 514 package.path = test_env.env_variables.LUA_PATH
515 515
516 test_env.platform = execute_output(test_env.testing_paths.lua .. " -e 'print(require(\"luarocks.core.cfg\").arch)'", false, test_env.env_variables) 516 test_env.platform = execute_output(test_env.testing_paths.lua .. " -e 'print(require(\"luarocks.core.cfg\").arch)'", false, test_env.env_variables)
517 test_env.lib_extension = execute_output(test_env.testing_paths.lua .. " -e 'print(require(\"luarocks.core.cfg\").lib_extension)'", false, test_env.env_variables)
517 test_env.md5sums = create_md5sums(test_env.testing_paths) 518 test_env.md5sums = create_md5sums(test_env.testing_paths)
518 test_env.setup_done = true 519 test_env.setup_done = true
519 title("RUNNING TESTS") 520 title("RUNNING TESTS")