diff options
author | Ignacio Burgueño <ignaciob@inconcertcc.com> | 2015-04-14 02:15:31 -0300 |
---|---|---|
committer | Ignacio Burgueño <ignaciob@inconcertcc.com> | 2015-04-14 02:15:31 -0300 |
commit | 0f67be5258e25d8cf68b2a50535e82dd0c757206 (patch) | |
tree | d6881bbbdf8f9adea3989106cb3a7049e2848c0d | |
parent | 0fe8556ced63d714e0cd371a8511c8dadce7874e (diff) | |
download | luarocks-0f67be5258e25d8cf68b2a50535e82dd0c757206.tar.gz luarocks-0f67be5258e25d8cf68b2a50535e82dd0c757206.tar.bz2 luarocks-0f67be5258e25d8cf68b2a50535e82dd0c757206.zip |
Adds --only-deps flag to the 'build' command.
As discussed in #287, adds a new flag (--only-deps) to the 'build'
command, so only the dependencies of a rock are installed, and not
the rock itself.
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | src/luarocks/build.lua | 33 | ||||
-rw-r--r-- | src/luarocks/util.lua | 1 | ||||
-rwxr-xr-x | test/testing.sh | 20 |
4 files changed, 46 insertions, 10 deletions
diff --git a/.travis.yml b/.travis.yml index 54778583..db762a84 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -2,6 +2,8 @@ language: c | |||
2 | 2 | ||
3 | compiler: gcc | 3 | compiler: gcc |
4 | 4 | ||
5 | sudo: false | ||
6 | |||
5 | env: | 7 | env: |
6 | matrix: | 8 | matrix: |
7 | - LUA_VER=5.1.5 | 9 | - LUA_VER=5.1.5 |
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>", |
diff --git a/test/testing.sh b/test/testing.sh index b75b51d7..78e60a76 100755 --- a/test/testing.sh +++ b/test/testing.sh | |||
@@ -249,6 +249,7 @@ mkdir -p "$testing_server" | |||
249 | get "$luarocks_repo/cprint-${verrev_cprint}.rockspec" | 249 | get "$luarocks_repo/cprint-${verrev_cprint}.rockspec" |
250 | get "$luarocks_repo/wsapi-1.6-1.src.rock" | 250 | get "$luarocks_repo/wsapi-1.6-1.src.rock" |
251 | get "$luarocks_repo/lxsh-${verrev_lxsh}.src.rock" | 251 | get "$luarocks_repo/lxsh-${verrev_lxsh}.src.rock" |
252 | get "$luarocks_repo/lxsh-${verrev_lxsh}.rockspec" | ||
252 | get "$luarocks_repo/abelhas-${verrev_abelhas}.rockspec" | 253 | get "$luarocks_repo/abelhas-${verrev_abelhas}.rockspec" |
253 | get "$luarocks_repo/lzlib-0.4.1.53-1.src.rock" | 254 | get "$luarocks_repo/lzlib-0.4.1.53-1.src.rock" |
254 | get "$luarocks_repo/lpeg-0.12-1.src.rock" | 255 | get "$luarocks_repo/lpeg-0.12-1.src.rock" |
@@ -262,6 +263,7 @@ mkdir -p "$testing_server" | |||
262 | get "$luarocks_repo/lua-path-0.2.3-1.src.rock" | 263 | get "$luarocks_repo/lua-path-0.2.3-1.src.rock" |
263 | get "$luarocks_repo/lua-cjson-2.1.0-1.src.rock" | 264 | get "$luarocks_repo/lua-cjson-2.1.0-1.src.rock" |
264 | get "$luarocks_repo/luacov-coveralls-0.1.1-1.src.rock" | 265 | get "$luarocks_repo/luacov-coveralls-0.1.1-1.src.rock" |
266 | get "$luarocks_repo/luacov-coveralls-0.1.1-1.src.rock" | ||
265 | ) | 267 | ) |
266 | $luarocks_admin_nocov make_manifest "$testing_server" | 268 | $luarocks_admin_nocov make_manifest "$testing_server" |
267 | 269 | ||
@@ -385,6 +387,24 @@ test_build_install_bin() { $luarocks build luarepl; } | |||
385 | test_build_nohttps() { need_luasocket; $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks build ./validate-args-${version_validate_args}-1.rockspec && rm ./validate-args-${version_validate_args}-1.rockspec; } | 387 | test_build_nohttps() { need_luasocket; $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks build ./validate-args-${version_validate_args}-1.rockspec && rm ./validate-args-${version_validate_args}-1.rockspec; } |
386 | test_build_https() { need_luasocket; $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks install $luasec && $luarocks build ./validate-args-${verrev_validate_args}.rockspec && rm ./validate-args-${verrev_validate_args}.rockspec; } | 388 | test_build_https() { need_luasocket; $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks install $luasec && $luarocks build ./validate-args-${verrev_validate_args}.rockspec && rm ./validate-args-${verrev_validate_args}.rockspec; } |
387 | test_build_supported_platforms() { $luarocks build lpty; } | 389 | test_build_supported_platforms() { $luarocks build lpty; } |
390 | test_build_only_deps_rockspec() { $luarocks download --rockspec lxsh ${verrev_lxsh} ; $luarocks build ./lxsh-${verrev_lxsh}.rockspec --only-deps; $luarocks show lxsh; | ||
391 | if [ $? -ne 0 ] | ||
392 | then return 0; | ||
393 | fi; | ||
394 | return 1; | ||
395 | } | ||
396 | test_build_only_deps_src_rock() { $luarocks download --source lxsh ${verrev_lxsh} ; $luarocks build ./lxsh-${verrev_lxsh}.src.rock --only-deps; $luarocks show lxsh; | ||
397 | if [ $? -ne 0 ] | ||
398 | then return 0; | ||
399 | fi; | ||
400 | return 1; | ||
401 | } | ||
402 | test_build_only_deps() { $luarocks build luasec --only-deps; $luarocks show luasec; | ||
403 | if [ $? -ne 0 ] | ||
404 | then return 0; | ||
405 | fi; | ||
406 | return 1; | ||
407 | } | ||
388 | fail_build_missing_external() { $luarocks build "$testing_dir/testfiles/missing_external-0.1-1.rockspec" INEXISTENT_INCDIR="/invalid/dir"; } | 408 | fail_build_missing_external() { $luarocks build "$testing_dir/testfiles/missing_external-0.1-1.rockspec" INEXISTENT_INCDIR="/invalid/dir"; } |
389 | fail_build_invalidpatch() { need_luasocket; $luarocks build "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; } | 409 | fail_build_invalidpatch() { need_luasocket; $luarocks build "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; } |
390 | 410 | ||