diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/build.lua | 33 | ||||
-rw-r--r-- | src/luarocks/util.lua | 1 |
2 files changed, 24 insertions, 10 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 96191b11..70a53e14 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -37,6 +37,8 @@ or the name of a rock to be fetched from a repository. | |||
37 | rockspec. Allows to specify a different branch to | 37 | rockspec. Allows to specify a different branch to |
38 | fetch. Particularly for SCM rocks. | 38 | fetch. Particularly for SCM rocks. |
39 | 39 | ||
40 | --only-deps Installs only the dependencies of the rock. | ||
41 | |||
40 | ]]..util.deps_mode_help() | 42 | ]]..util.deps_mode_help() |
41 | 43 | ||
42 | --- Install files to a given location. | 44 | --- Install files to a given location. |
@@ -157,9 +159,10 @@ end | |||
157 | -- @param deps_mode string: Dependency mode: "one" for the current default tree, | 159 | -- @param deps_mode string: Dependency mode: "one" for the current default tree, |
158 | -- "all" for all trees, "order" for all trees with priority >= the current default, | 160 | -- "all" for all trees, "order" for all trees with priority >= the current default, |
159 | -- "none" for no trees. | 161 | -- "none" for no trees. |
162 | -- @param build_only_deps boolean: true to build the listed dependencies only. | ||
160 | -- @return (string, string) or (nil, string, [string]): Name and version of | 163 | -- @return (string, string) or (nil, string, [string]): Name and version of |
161 | -- installed rock if succeeded or nil and an error message followed by an error code. | 164 | -- installed rock if succeeded or nil and an error message followed by an error code. |
162 | function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_mode) | 165 | function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_mode, build_only_deps) |
163 | assert(type(rockspec_file) == "string") | 166 | assert(type(rockspec_file) == "string") |
164 | assert(type(need_to_fetch) == "boolean") | 167 | assert(type(need_to_fetch) == "boolean") |
165 | 168 | ||
@@ -181,13 +184,19 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m | |||
181 | end | 184 | end |
182 | end | 185 | end |
183 | 186 | ||
187 | local name, version = rockspec.name, rockspec.version | ||
188 | if build_only_deps then | ||
189 | util.printout("Stopping after installing dependencies for " ..name.." "..version) | ||
190 | util.printout() | ||
191 | return name, version | ||
192 | end | ||
193 | |||
184 | local ok | 194 | local ok |
185 | ok, err, errcode = deps.check_external_deps(rockspec, "build") | 195 | ok, err, errcode = deps.check_external_deps(rockspec, "build") |
186 | if err then | 196 | if err then |
187 | return nil, err, errcode | 197 | return nil, err, errcode |
188 | end | 198 | end |
189 | 199 | ||
190 | local name, version = rockspec.name, rockspec.version | ||
191 | if repos.is_installed(name, version) then | 200 | if repos.is_installed(name, version) then |
192 | repos.delete_version(name, version) | 201 | repos.delete_version(name, version) |
193 | end | 202 | end |
@@ -341,9 +350,10 @@ end | |||
341 | -- @param deps_mode: string: Which trees to check dependencies for: | 350 | -- @param deps_mode: string: Which trees to check dependencies for: |
342 | -- "one" for the current default tree, "all" for all trees, | 351 | -- "one" for the current default tree, "all" for all trees, |
343 | -- "order" for all trees with priority >= the current default, "none" for no trees. | 352 | -- "order" for all trees with priority >= the current default, "none" for no trees. |
353 | -- @param build_only_deps boolean: true to build the listed dependencies only. | ||
344 | -- @return boolean or (nil, string, [string]): True if build was successful, | 354 | -- @return boolean or (nil, string, [string]): True if build was successful, |
345 | -- or false and an error message and an optional error code. | 355 | -- or false and an error message and an optional error code. |
346 | function build.build_rock(rock_file, need_to_fetch, deps_mode) | 356 | function build.build_rock(rock_file, need_to_fetch, deps_mode, build_only_deps) |
347 | assert(type(rock_file) == "string") | 357 | assert(type(rock_file) == "string") |
348 | assert(type(need_to_fetch) == "boolean") | 358 | assert(type(need_to_fetch) == "boolean") |
349 | 359 | ||
@@ -356,24 +366,24 @@ function build.build_rock(rock_file, need_to_fetch, deps_mode) | |||
356 | local rockspec_file = path.rockspec_name_from_rock(rock_file) | 366 | local rockspec_file = path.rockspec_name_from_rock(rock_file) |
357 | ok, err = fs.change_dir(unpack_dir) | 367 | ok, err = fs.change_dir(unpack_dir) |
358 | if not ok then return nil, err end | 368 | if not ok then return nil, err end |
359 | ok, err, errcode = build.build_rockspec(rockspec_file, need_to_fetch, false, deps_mode) | 369 | ok, err, errcode = build.build_rockspec(rockspec_file, need_to_fetch, false, deps_mode, build_only_deps) |
360 | fs.pop_dir() | 370 | fs.pop_dir() |
361 | return ok, err, errcode | 371 | return ok, err, errcode |
362 | end | 372 | end |
363 | 373 | ||
364 | local function do_build(name, version, deps_mode) | 374 | local function do_build(name, version, deps_mode, build_only_deps) |
365 | if name:match("%.rockspec$") then | 375 | if name:match("%.rockspec$") then |
366 | return build.build_rockspec(name, true, false, deps_mode) | 376 | return build.build_rockspec(name, true, false, deps_mode, build_only_deps) |
367 | elseif name:match("%.src%.rock$") then | 377 | elseif name:match("%.src%.rock$") then |
368 | return build.build_rock(name, false, deps_mode) | 378 | return build.build_rock(name, false, deps_mode, build_only_deps) |
369 | elseif name:match("%.all%.rock$") then | 379 | elseif name:match("%.all%.rock$") then |
370 | local install = require("luarocks.install") | 380 | local install = require("luarocks.install") |
371 | return install.install_binary_rock(name, deps_mode) | 381 | return install.install_binary_rock(name, deps_mode) |
372 | elseif name:match("%.rock$") then | 382 | elseif name:match("%.rock$") then |
373 | return build.build_rock(name, true, deps_mode) | 383 | return build.build_rock(name, true, deps_mode, build_only_deps) |
374 | elseif not name:match(dir.separator) then | 384 | elseif not name:match(dir.separator) then |
375 | local search = require("luarocks.search") | 385 | local search = require("luarocks.search") |
376 | return search.act_on_src_or_rockspec(build.run, name:lower(), version, deps.deps_mode_to_flag(deps_mode)) | 386 | return search.act_on_src_or_rockspec(build.run, name:lower(), version, deps.deps_mode_to_flag(deps_mode), build_only_deps and "--only-deps") |
377 | end | 387 | end |
378 | return nil, "Don't know what to do with "..name | 388 | return nil, "Don't know what to do with "..name |
379 | end | 389 | end |
@@ -398,9 +408,12 @@ function build.run(...) | |||
398 | else | 408 | else |
399 | local ok, err = fs.check_command_permissions(flags) | 409 | local ok, err = fs.check_command_permissions(flags) |
400 | if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end | 410 | if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end |
401 | ok, err = do_build(name, version, deps.get_deps_mode(flags)) | 411 | ok, err = do_build(name, version, deps.get_deps_mode(flags), flags["only-deps"]) |
402 | if not ok then return nil, err end | 412 | if not ok then return nil, err end |
403 | local name, version = ok, err | 413 | local name, version = ok, err |
414 | if flags["only-deps"] then | ||
415 | return name, version | ||
416 | end | ||
404 | if (not flags["keep"]) and not cfg.keep_other_versions then | 417 | if (not flags["keep"]) and not cfg.keep_other_versions then |
405 | local ok, err = remove.remove_other_versions(name, version, flags["force"]) | 418 | local ok, err = remove.remove_other_versions(name, version, flags["force"]) |
406 | if not ok then util.printerr(err) end | 419 | if not ok then util.printerr(err) end |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 366a7ace..682c99e9 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -102,6 +102,7 @@ local supported_flags = { | |||
102 | ["no-refresh"] = true, | 102 | ["no-refresh"] = true, |
103 | ["nodeps"] = true, | 103 | ["nodeps"] = true, |
104 | ["old-versions"] = true, | 104 | ["old-versions"] = true, |
105 | ["only-deps"] = true, | ||
105 | ["only-from"] = "<server>", | 106 | ["only-from"] = "<server>", |
106 | ["only-server"] = "<server>", | 107 | ["only-server"] = "<server>", |
107 | ["only-sources"] = "<url>", | 108 | ["only-sources"] = "<url>", |