diff options
-rw-r--r-- | spec/quick/build.q | 40 | ||||
-rw-r--r-- | spec/quick/install.q | 42 | ||||
-rw-r--r-- | src/luarocks/cmd/build.lua | 15 | ||||
-rw-r--r-- | src/luarocks/cmd/install.lua | 8 | ||||
-rw-r--r-- | src/luarocks/cmd/make.lua | 3 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 4 |
6 files changed, 109 insertions, 3 deletions
diff --git a/spec/quick/build.q b/spec/quick/build.q index c6ca433c..a1731da2 100644 --- a/spec/quick/build.q +++ b/spec/quick/build.q | |||
@@ -120,3 +120,43 @@ failed to force the lock | |||
120 | -------------------------------------------------------------------------------- | 120 | -------------------------------------------------------------------------------- |
121 | 121 | ||
122 | NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec | 122 | NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec |
123 | |||
124 | |||
125 | |||
126 | ================================================================================ | ||
127 | TEST: luarocks build: do not rebuild when already installed | ||
128 | |||
129 | FILE: a_rock-1.0-1.rockspec | ||
130 | -------------------------------------------------------------------------------- | ||
131 | rockspec_format = "3.0" | ||
132 | package = "a_rock" | ||
133 | version = "1.0-1" | ||
134 | source = { | ||
135 | url = "file://%{url(%{fixtures_dir})}/a_rock.lua" | ||
136 | } | ||
137 | description = { | ||
138 | summary = "An example rockspec", | ||
139 | } | ||
140 | dependencies = { | ||
141 | "lua >= 5.1" | ||
142 | } | ||
143 | build = { | ||
144 | modules = { | ||
145 | build = "a_rock.lua" | ||
146 | }, | ||
147 | } | ||
148 | -------------------------------------------------------------------------------- | ||
149 | RUN: luarocks build a_rock-1.0-1.rockspec | ||
150 | |||
151 | RUN: luarocks show a_rock | ||
152 | STDOUT: | ||
153 | -------------------------------------------------------------------------------- | ||
154 | a_rock 1.0 | ||
155 | -------------------------------------------------------------------------------- | ||
156 | |||
157 | RUN: luarocks build a_rock-1.0-1.rockspec | ||
158 | STDOUT: | ||
159 | -------------------------------------------------------------------------------- | ||
160 | a_rock 1.0-1 is already installed | ||
161 | Use --force to reinstall | ||
162 | -------------------------------------------------------------------------------- | ||
diff --git a/spec/quick/install.q b/spec/quick/install.q index ab576605..503aaacc 100644 --- a/spec/quick/install.q +++ b/spec/quick/install.q | |||
@@ -373,3 +373,45 @@ RUN: luarocks install myrock-1.0-2.all.rock --no-doc | |||
373 | 373 | ||
374 | EXISTS: %{testing_sys_tree}/share/lua/%{LUA_VERSION}/sailor/blank-app/.htaccess | 374 | EXISTS: %{testing_sys_tree}/share/lua/%{LUA_VERSION}/sailor/blank-app/.htaccess |
375 | NOT_EXISTS: %{testing_sys_tree}/share/lua/%{LUA_VERSION}/sailor/blank-app/.htaccess~ | 375 | NOT_EXISTS: %{testing_sys_tree}/share/lua/%{LUA_VERSION}/sailor/blank-app/.htaccess~ |
376 | |||
377 | |||
378 | |||
379 | ================================================================================ | ||
380 | TEST: do not reinstall when already installed | ||
381 | |||
382 | FILE: myrock-1.0-1.rockspec | ||
383 | -------------------------------------------------------------------------------- | ||
384 | rockspec_format = "3.0" | ||
385 | package = "myrock" | ||
386 | version = "1.0-1" | ||
387 | source = { | ||
388 | url = "file://%{url(tmpdir)}/rock.lua" | ||
389 | } | ||
390 | build = { | ||
391 | modules = { rock = "rock.lua" } | ||
392 | } | ||
393 | -------------------------------------------------------------------------------- | ||
394 | |||
395 | FILE: rock.lua | ||
396 | -------------------------------------------------------------------------------- | ||
397 | return "hello" | ||
398 | -------------------------------------------------------------------------------- | ||
399 | |||
400 | RUN: luarocks build myrock-1.0-1.rockspec | ||
401 | RUN: luarocks pack myrock | ||
402 | RUN: luarocks remove myrock | ||
403 | |||
404 | RUN: luarocks install ./myrock-1.0-1.all.rock | ||
405 | |||
406 | RUN: luarocks show myrock | ||
407 | STDOUT: | ||
408 | -------------------------------------------------------------------------------- | ||
409 | myrock 1.0 | ||
410 | -------------------------------------------------------------------------------- | ||
411 | |||
412 | RUN: luarocks install ./myrock-1.0-1.all.rock | ||
413 | STDOUT: | ||
414 | -------------------------------------------------------------------------------- | ||
415 | myrock 1.0-1 is already installed | ||
416 | Use --force to reinstall | ||
417 | -------------------------------------------------------------------------------- | ||
diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index 16c0aff2..c73ceebe 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua | |||
@@ -16,6 +16,7 @@ local writer = require("luarocks.manif.writer") | |||
16 | local search = require("luarocks.search") | 16 | local search = require("luarocks.search") |
17 | local make = require("luarocks.cmd.make") | 17 | local make = require("luarocks.cmd.make") |
18 | local cmd = require("luarocks.cmd") | 18 | local cmd = require("luarocks.cmd") |
19 | local repos = require("luarocks.repos") | ||
19 | 20 | ||
20 | function cmd_build.add_to_parser(parser) | 21 | function cmd_build.add_to_parser(parser) |
21 | local cmd = parser:command("build", "Build and install a rock, compiling its C parts if any.\n".. -- luacheck: ignore 431 | 22 | local cmd = parser:command("build", "Build and install a rock, compiling its C parts if any.\n".. -- luacheck: ignore 431 |
@@ -93,6 +94,15 @@ local function do_build(name, namespace, version, opts) | |||
93 | end | 94 | end |
94 | end | 95 | end |
95 | 96 | ||
97 | name, version = path.parse_name(url) | ||
98 | if name and repos.is_installed(name, version) then | ||
99 | if (not opts.force) and (not opts.force_fast) then | ||
100 | util.printout(name .. " " .. version .. " is already installed in " .. path.root_dir(cfg.root_dir)) | ||
101 | util.printout("Use --force to reinstall.") | ||
102 | return name, version, "skip" | ||
103 | end | ||
104 | end | ||
105 | |||
96 | if url:match("%.rockspec$") then | 106 | if url:match("%.rockspec$") then |
97 | local rockspec, err = fetch.load_rockspec(url, nil, opts.verify) | 107 | local rockspec, err = fetch.load_rockspec(url, nil, opts.verify) |
98 | if not rockspec then | 108 | if not rockspec then |
@@ -151,10 +161,13 @@ function cmd_build.command(args) | |||
151 | return nil, err, cmd.errorcodes.PERMISSIONDENIED | 161 | return nil, err, cmd.errorcodes.PERMISSIONDENIED |
152 | end | 162 | end |
153 | 163 | ||
154 | local name, version = do_build(args.rock, args.namespace, args.version, opts) | 164 | local name, version, skip = do_build(args.rock, args.namespace, args.version, opts) |
155 | if not name then | 165 | if not name then |
156 | return nil, version | 166 | return nil, version |
157 | end | 167 | end |
168 | if skip == "skip" then | ||
169 | return name, version | ||
170 | end | ||
158 | 171 | ||
159 | if args.no_doc then | 172 | if args.no_doc then |
160 | util.remove_doc_dir(name, version) | 173 | util.remove_doc_dir(name, version) |
diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index b4f15cb8..e221f611 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua | |||
@@ -28,7 +28,8 @@ function install.add_to_parser(parser) | |||
28 | "rock after building a new one. This behavior can be made permanent by ".. | 28 | "rock after building a new one. This behavior can be made permanent by ".. |
29 | "setting keep_other_versions=true in the configuration file.") | 29 | "setting keep_other_versions=true in the configuration file.") |
30 | cmd:flag("--force", "If --keep is not specified, force removal of ".. | 30 | cmd:flag("--force", "If --keep is not specified, force removal of ".. |
31 | "previously installed versions if it would break dependencies.") | 31 | "previously installed versions if it would break dependencies. ".. |
32 | "If rock is already installed, reinstall it anyway.") | ||
32 | cmd:flag("--force-fast", "Like --force, but performs a forced removal ".. | 33 | cmd:flag("--force-fast", "Like --force, but performs a forced removal ".. |
33 | "without reporting dependency issues.") | 34 | "without reporting dependency issues.") |
34 | cmd:flag("--only-deps --deps-only", "Install only the dependencies of the rock.") | 35 | cmd:flag("--only-deps --deps-only", "Install only the dependencies of the rock.") |
@@ -84,6 +85,11 @@ function install.install_binary_rock(rock_file, opts) | |||
84 | return nil, "Incompatible architecture "..arch, "arch" | 85 | return nil, "Incompatible architecture "..arch, "arch" |
85 | end | 86 | end |
86 | if repos.is_installed(name, version) then | 87 | if repos.is_installed(name, version) then |
88 | if (not opts.force) and (not opts.force_fast) then | ||
89 | util.printout(name .. " " .. version .. " is already installed in " .. path.root_dir(cfg.root_dir)) | ||
90 | util.printout("Use --force to reinstall.") | ||
91 | return name, version | ||
92 | end | ||
87 | repos.delete_version(name, version, opts.deps_mode) | 93 | repos.delete_version(name, version, opts.deps_mode) |
88 | end | 94 | end |
89 | 95 | ||
diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.lua index 8147b5df..b75a9043 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.lua | |||
@@ -25,7 +25,8 @@ function make.cmd_options(parser) | |||
25 | "rock after building a new one. This behavior can be made permanent by ".. | 25 | "rock after building a new one. This behavior can be made permanent by ".. |
26 | "setting keep_other_versions=true in the configuration file.") | 26 | "setting keep_other_versions=true in the configuration file.") |
27 | parser:flag("--force", "If --keep is not specified, force removal of ".. | 27 | parser:flag("--force", "If --keep is not specified, force removal of ".. |
28 | "previously installed versions if it would break dependencies.") | 28 | "previously installed versions if it would break dependencies. ".. |
29 | "If rock is already installed, reinstall it anyway.") | ||
29 | parser:flag("--force-fast", "Like --force, but performs a forced removal ".. | 30 | parser:flag("--force-fast", "Like --force, but performs a forced removal ".. |
30 | "without reporting dependency issues.") | 31 | "without reporting dependency issues.") |
31 | parser:flag("--verify", "Verify signature of the rockspec or src.rock being ".. | 32 | parser:flag("--verify", "Verify signature of the rockspec or src.rock being ".. |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 71695701..55c64b72 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -1161,6 +1161,9 @@ end | |||
1161 | function fs_lua.check_command_permissions(args) | 1161 | function fs_lua.check_command_permissions(args) |
1162 | local ok = true | 1162 | local ok = true |
1163 | local err = "" | 1163 | local err = "" |
1164 | if args._command_permissions_checked then | ||
1165 | return true | ||
1166 | end | ||
1164 | for _, directory in ipairs { cfg.rocks_dir, cfg.deploy_lua_dir, cfg.deploy_bin_dir, cfg.deploy_lua_dir } do | 1167 | for _, directory in ipairs { cfg.rocks_dir, cfg.deploy_lua_dir, cfg.deploy_bin_dir, cfg.deploy_lua_dir } do |
1165 | if fs.exists(directory) then | 1168 | if fs.exists(directory) then |
1166 | if not fs.is_writable(directory) then | 1169 | if not fs.is_writable(directory) then |
@@ -1185,6 +1188,7 @@ function fs_lua.check_command_permissions(args) | |||
1185 | end | 1188 | end |
1186 | end | 1189 | end |
1187 | if ok then | 1190 | if ok then |
1191 | args._command_permissions_checked = true | ||
1188 | return true | 1192 | return true |
1189 | else | 1193 | else |
1190 | if args["local"] or cfg.local_by_default then | 1194 | if args["local"] or cfg.local_by_default then |