diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/build.lua | 38 | ||||
-rw-r--r-- | src/luarocks/build/builtin.lua | 26 | ||||
-rw-r--r-- | src/luarocks/build/cmake.lua | 4 | ||||
-rw-r--r-- | src/luarocks/build/command.lua | 4 | ||||
-rw-r--r-- | src/luarocks/build/make.lua | 10 | ||||
-rw-r--r-- | src/luarocks/cmd/build.lua | 1 | ||||
-rw-r--r-- | src/luarocks/cmd/make.lua | 8 |
7 files changed, 57 insertions, 34 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index eee4bb99..f11edb6f 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -23,6 +23,7 @@ build.opts = util.opts_table("build.opts", { | |||
23 | verify = "boolean", | 23 | verify = "boolean", |
24 | check_lua_versions = "boolean", | 24 | check_lua_versions = "boolean", |
25 | pin = "boolean", | 25 | pin = "boolean", |
26 | no_install = "boolean" | ||
26 | }) | 27 | }) |
27 | 28 | ||
28 | do | 29 | do |
@@ -188,7 +189,7 @@ local function prepare_install_dirs(name, version) | |||
188 | return dirs | 189 | return dirs |
189 | end | 190 | end |
190 | 191 | ||
191 | local function run_build_driver(rockspec) | 192 | local function run_build_driver(rockspec, no_install) |
192 | local btype = rockspec.build.type | 193 | local btype = rockspec.build.type |
193 | if btype == "none" then | 194 | if btype == "none" then |
194 | return true | 195 | return true |
@@ -206,7 +207,7 @@ local function run_build_driver(rockspec) | |||
206 | if not pok or type(driver) ~= "table" then | 207 | if not pok or type(driver) ~= "table" then |
207 | return nil, "Failed initializing build back-end for build type '"..btype.."': "..driver | 208 | return nil, "Failed initializing build back-end for build type '"..btype.."': "..driver |
208 | end | 209 | end |
209 | local ok, err = driver.run(rockspec) | 210 | local ok, err = driver.run(rockspec, no_install) |
210 | if not ok then | 211 | if not ok then |
211 | return nil, "Build error: " .. err | 212 | return nil, "Build error: " .. err |
212 | end | 213 | end |
@@ -385,16 +386,21 @@ function build.build_rockspec(rockspec, opts) | |||
385 | return name, version | 386 | return name, version |
386 | end | 387 | end |
387 | 388 | ||
388 | if repos.is_installed(name, version) then | 389 | local dirs, err |
389 | repos.delete_version(name, version, opts.deps_mode) | 390 | local rollback |
391 | if not opts.no_install then | ||
392 | if repos.is_installed(name, version) then | ||
393 | repos.delete_version(name, version, opts.deps_mode) | ||
394 | end | ||
395 | |||
396 | dirs, err = prepare_install_dirs(name, version) | ||
397 | if not dirs then return nil, err end | ||
398 | |||
399 | rollback = util.schedule_function(function() | ||
400 | fs.delete(path.install_dir(name, version)) | ||
401 | fs.remove_dir_if_empty(path.versions_dir(name)) | ||
402 | end) | ||
390 | end | 403 | end |
391 | local dirs, err = prepare_install_dirs(name, version) | ||
392 | if not dirs then return nil, err end | ||
393 | |||
394 | local rollback = util.schedule_function(function() | ||
395 | fs.delete(path.install_dir(name, version)) | ||
396 | fs.remove_dir_if_empty(path.versions_dir(name)) | ||
397 | end) | ||
398 | 404 | ||
399 | ok, err = build.apply_patches(rockspec) | 405 | ok, err = build.apply_patches(rockspec) |
400 | if not ok then return nil, err end | 406 | if not ok then return nil, err end |
@@ -402,9 +408,17 @@ function build.build_rockspec(rockspec, opts) | |||
402 | ok, err = check_macosx_deployment_target(rockspec) | 408 | ok, err = check_macosx_deployment_target(rockspec) |
403 | if not ok then return nil, err end | 409 | if not ok then return nil, err end |
404 | 410 | ||
405 | ok, err = run_build_driver(rockspec) | 411 | ok, err = run_build_driver(rockspec, opts.no_install) |
406 | if not ok then return nil, err end | 412 | if not ok then return nil, err end |
407 | 413 | ||
414 | if opts.no_install then | ||
415 | fs.pop_dir() | ||
416 | if opts.need_to_fetch then | ||
417 | fs.pop_dir() | ||
418 | end | ||
419 | return name, version | ||
420 | end | ||
421 | |||
408 | ok, err = install_files(rockspec, dirs) | 422 | ok, err = install_files(rockspec, dirs) |
409 | if not ok then return nil, err end | 423 | if not ok then return nil, err end |
410 | 424 | ||
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index fb4431cd..70651ce8 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
@@ -149,7 +149,7 @@ end | |||
149 | -- @param rockspec table: the loaded rockspec. | 149 | -- @param rockspec table: the loaded rockspec. |
150 | -- @return boolean or (nil, string): true if no errors occurred, | 150 | -- @return boolean or (nil, string): true if no errors occurred, |
151 | -- nil and an error message otherwise. | 151 | -- nil and an error message otherwise. |
152 | function builtin.run(rockspec) | 152 | function builtin.run(rockspec, no_install) |
153 | assert(rockspec:type() == "rockspec") | 153 | assert(rockspec:type() == "rockspec") |
154 | local compile_object, compile_library, compile_static_library | 154 | local compile_object, compile_library, compile_static_library |
155 | 155 | ||
@@ -344,19 +344,21 @@ function builtin.run(rockspec) | |||
344 | ]] | 344 | ]] |
345 | end | 345 | end |
346 | end | 346 | end |
347 | for _, mods in ipairs({{ tbl = lua_modules, perms = "read" }, { tbl = lib_modules, perms = "exec" }}) do | 347 | if not no_install then |
348 | for name, dest in pairs(mods.tbl) do | 348 | for _, mods in ipairs({{ tbl = lua_modules, perms = "read" }, { tbl = lib_modules, perms = "exec" }}) do |
349 | fs.make_dir(dir.dir_name(dest)) | 349 | for name, dest in pairs(mods.tbl) do |
350 | ok, err = fs.copy(name, dest, mods.perms) | 350 | fs.make_dir(dir.dir_name(dest)) |
351 | if not ok then | 351 | ok, err = fs.copy(name, dest, mods.perms) |
352 | return nil, "Failed installing "..name.." in "..dest..": "..err | 352 | if not ok then |
353 | return nil, "Failed installing "..name.." in "..dest..": "..err | ||
354 | end | ||
353 | end | 355 | end |
354 | end | 356 | end |
355 | end | 357 | if fs.is_dir("lua") then |
356 | if fs.is_dir("lua") then | 358 | ok, err = fs.copy_contents("lua", luadir) |
357 | ok, err = fs.copy_contents("lua", luadir) | 359 | if not ok then |
358 | if not ok then | 360 | return nil, "Failed copying contents of 'lua' directory: "..err |
359 | return nil, "Failed copying contents of 'lua' directory: "..err | 361 | end |
360 | end | 362 | end |
361 | end | 363 | end |
362 | return true | 364 | return true |
diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index 0bf44dda..d7ecc83c 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua | |||
@@ -10,7 +10,7 @@ local cfg = require("luarocks.core.cfg") | |||
10 | -- @param rockspec table: the loaded rockspec. | 10 | -- @param rockspec table: the loaded rockspec. |
11 | -- @return boolean or (nil, string): true if no errors occurred, | 11 | -- @return boolean or (nil, string): true if no errors occurred, |
12 | -- nil and an error message otherwise. | 12 | -- nil and an error message otherwise. |
13 | function cmake.run(rockspec) | 13 | function cmake.run(rockspec, no_install) |
14 | assert(rockspec:type() == "rockspec") | 14 | assert(rockspec:type() == "rockspec") |
15 | local build = rockspec.build | 15 | local build = rockspec.build |
16 | local variables = build.variables or {} | 16 | local variables = build.variables or {} |
@@ -66,7 +66,7 @@ function cmake.run(rockspec) | |||
66 | return nil, "Failed building." | 66 | return nil, "Failed building." |
67 | end | 67 | end |
68 | end | 68 | end |
69 | if do_install then | 69 | if do_install and not no_install then |
70 | if not fs.execute_string(rockspec.variables.CMAKE.." --build build.luarocks --target install --config Release") then | 70 | if not fs.execute_string(rockspec.variables.CMAKE.." --build build.luarocks --target install --config Release") then |
71 | return nil, "Failed installing." | 71 | return nil, "Failed installing." |
72 | end | 72 | end |
diff --git a/src/luarocks/build/command.lua b/src/luarocks/build/command.lua index 755a39d2..309c4a16 100644 --- a/src/luarocks/build/command.lua +++ b/src/luarocks/build/command.lua | |||
@@ -10,7 +10,7 @@ local cfg = require("luarocks.core.cfg") | |||
10 | -- @param rockspec table: the loaded rockspec. | 10 | -- @param rockspec table: the loaded rockspec. |
11 | -- @return boolean or (nil, string): true if no errors occurred, | 11 | -- @return boolean or (nil, string): true if no errors occurred, |
12 | -- nil and an error message otherwise. | 12 | -- nil and an error message otherwise. |
13 | function command.run(rockspec) | 13 | function command.run(rockspec, not_install) |
14 | assert(rockspec:type() == "rockspec") | 14 | assert(rockspec:type() == "rockspec") |
15 | 15 | ||
16 | local build = rockspec.build | 16 | local build = rockspec.build |
@@ -29,7 +29,7 @@ function command.run(rockspec) | |||
29 | return nil, "Failed building." | 29 | return nil, "Failed building." |
30 | end | 30 | end |
31 | end | 31 | end |
32 | if build.install_command then | 32 | if build.install_command and not not_install then |
33 | util.printout(build.install_command) | 33 | util.printout(build.install_command) |
34 | if not fs.execute_env(env, build.install_command) then | 34 | if not fs.execute_env(env, build.install_command) then |
35 | return nil, "Failed installing." | 35 | return nil, "Failed installing." |
diff --git a/src/luarocks/build/make.lua b/src/luarocks/build/make.lua index 5df3050d..ccab1af0 100644 --- a/src/luarocks/build/make.lua +++ b/src/luarocks/build/make.lua | |||
@@ -38,7 +38,7 @@ end | |||
38 | -- @param rockspec table: the loaded rockspec. | 38 | -- @param rockspec table: the loaded rockspec. |
39 | -- @return boolean or (nil, string): true if no errors occurred, | 39 | -- @return boolean or (nil, string): true if no errors occurred, |
40 | -- nil and an error message otherwise. | 40 | -- nil and an error message otherwise. |
41 | function make.run(rockspec) | 41 | function make.run(rockspec, not_install) |
42 | assert(rockspec:type() == "rockspec") | 42 | assert(rockspec:type() == "rockspec") |
43 | 43 | ||
44 | local build = rockspec.build | 44 | local build = rockspec.build |
@@ -86,9 +86,11 @@ function make.run(rockspec) | |||
86 | if not ok then | 86 | if not ok then |
87 | return nil, "Failed building." | 87 | return nil, "Failed building." |
88 | end | 88 | end |
89 | ok = make_pass(make_cmd, build.install_pass, build.install_target, build.install_variables) | 89 | if not not_install then |
90 | if not ok then | 90 | ok = make_pass(make_cmd, build.install_pass, build.install_target, build.install_variables) |
91 | return nil, "Failed installing." | 91 | if not ok then |
92 | return nil, "Failed installing." | ||
93 | end | ||
92 | end | 94 | end |
93 | return true | 95 | return true |
94 | end | 96 | end |
diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index bc2b9bb6..31622f35 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua | |||
@@ -129,6 +129,7 @@ function cmd_build.command(args) | |||
129 | verify = not not args.verify, | 129 | verify = not not args.verify, |
130 | check_lua_versions = not not args.check_lua_versions, | 130 | check_lua_versions = not not args.check_lua_versions, |
131 | pin = not not args.pin, | 131 | pin = not not args.pin, |
132 | no_install = false | ||
132 | }) | 133 | }) |
133 | 134 | ||
134 | if args.sign and not args.pack_binary_rock then | 135 | if args.sign and not args.pack_binary_rock then |
diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.lua index 60a0f11e..78647b63 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.lua | |||
@@ -18,6 +18,7 @@ local writer = require("luarocks.manif.writer") | |||
18 | local cmd = require("luarocks.cmd") | 18 | local cmd = require("luarocks.cmd") |
19 | 19 | ||
20 | function make.cmd_options(parser) | 20 | function make.cmd_options(parser) |
21 | parser:flag("--no-install", "Do not install the rock.") | ||
21 | parser:flag("--no-doc", "Install the rock without its documentation.") | 22 | parser:flag("--no-doc", "Install the rock without its documentation.") |
22 | parser:flag("--pack-binary-rock", "Do not install rock. Instead, produce a ".. | 23 | parser:flag("--pack-binary-rock", "Do not install rock. Instead, produce a ".. |
23 | ".rock file with the contents of compilation in the current directory.") | 24 | ".rock file with the contents of compilation in the current directory.") |
@@ -104,14 +105,17 @@ function make.command(args) | |||
104 | branch = args.branch, | 105 | branch = args.branch, |
105 | verify = not not args.verify, | 106 | verify = not not args.verify, |
106 | check_lua_versions = not not args.check_lua_versions, | 107 | check_lua_versions = not not args.check_lua_versions, |
107 | pin = not not args.pin | 108 | pin = not not args.pin, |
109 | no_install = not not args.no_install | ||
108 | }) | 110 | }) |
109 | 111 | ||
110 | if args.sign and not args.pack_binary_rock then | 112 | if args.sign and not args.pack_binary_rock then |
111 | return nil, "In the make command, --sign is meant to be used only with --pack-binary-rock" | 113 | return nil, "In the make command, --sign is meant to be used only with --pack-binary-rock" |
112 | end | 114 | end |
113 | 115 | ||
114 | if args.pack_binary_rock then | 116 | if args.no_install then |
117 | return build.build_rockspec(rockspec, opts) | ||
118 | elseif args.pack_binary_rock then | ||
115 | return pack.pack_binary_rock(name, namespace, rockspec.version, args.sign, function() | 119 | return pack.pack_binary_rock(name, namespace, rockspec.version, args.sign, function() |
116 | local name, version = build.build_rockspec(rockspec, opts) | 120 | local name, version = build.build_rockspec(rockspec, opts) |
117 | if name and args.no_doc then | 121 | if name and args.no_doc then |