diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2015-04-18 14:35:39 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-04-18 14:35:39 -0300 |
| commit | cda43ce50660aa55aeb2c4d2d8e724f17fa7f863 (patch) | |
| tree | c0101d344da23143e27c5897f8e5898197d4e22c /src | |
| parent | 022c87d98ee1605e98d880f461297b0934a90719 (diff) | |
| parent | b6b67547ef5801502f1b63ec62c04923ceb77cef (diff) | |
| download | luarocks-cda43ce50660aa55aeb2c4d2d8e724f17fa7f863.tar.gz luarocks-cda43ce50660aa55aeb2c4d2d8e724f17fa7f863.tar.bz2 luarocks-cda43ce50660aa55aeb2c4d2d8e724f17fa7f863.zip | |
Merge branch 'master' of https://github.com/keplerproject/luarocks
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/build.lua | 36 | ||||
| -rw-r--r-- | src/luarocks/fetch/git_https.lua | 7 | ||||
| -rw-r--r-- | src/luarocks/install.lua | 49 | ||||
| -rw-r--r-- | src/luarocks/util.lua | 1 |
4 files changed, 79 insertions, 14 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 96191b11..977be344 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,25 @@ 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 | local install_fun = build_only_deps and install.install_binary_rock_deps or install.install_binary_rock |
| 382 | return install_fun(name, deps_mode) | ||
| 372 | elseif name:match("%.rock$") then | 383 | elseif name:match("%.rock$") then |
| 373 | return build.build_rock(name, true, deps_mode) | 384 | return build.build_rock(name, true, deps_mode, build_only_deps) |
| 374 | elseif not name:match(dir.separator) then | 385 | elseif not name:match(dir.separator) then |
| 375 | local search = require("luarocks.search") | 386 | 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)) | 387 | 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 | 388 | end |
| 378 | return nil, "Don't know what to do with "..name | 389 | return nil, "Don't know what to do with "..name |
| 379 | end | 390 | end |
| @@ -398,9 +409,12 @@ function build.run(...) | |||
| 398 | else | 409 | else |
| 399 | local ok, err = fs.check_command_permissions(flags) | 410 | local ok, err = fs.check_command_permissions(flags) |
| 400 | if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end | 411 | if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end |
| 401 | ok, err = do_build(name, version, deps.get_deps_mode(flags)) | 412 | ok, err = do_build(name, version, deps.get_deps_mode(flags), flags["only-deps"]) |
| 402 | if not ok then return nil, err end | 413 | if not ok then return nil, err end |
| 403 | local name, version = ok, err | 414 | local name, version = ok, err |
| 415 | if flags["only-deps"] then | ||
| 416 | return name, version | ||
| 417 | end | ||
| 404 | if (not flags["keep"]) and not cfg.keep_other_versions then | 418 | if (not flags["keep"]) and not cfg.keep_other_versions then |
| 405 | local ok, err = remove.remove_other_versions(name, version, flags["force"]) | 419 | local ok, err = remove.remove_other_versions(name, version, flags["force"]) |
| 406 | if not ok then util.printerr(err) end | 420 | if not ok then util.printerr(err) end |
diff --git a/src/luarocks/fetch/git_https.lua b/src/luarocks/fetch/git_https.lua new file mode 100644 index 00000000..67f8ad6c --- /dev/null +++ b/src/luarocks/fetch/git_https.lua | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | --- Fetch back-end for retrieving sources from Git repositories | ||
| 2 | -- that use https:// transport. For example, for fetching a repository | ||
| 3 | -- that requires the following command line: | ||
| 4 | -- `git clone https://example.com/foo.git` | ||
| 5 | -- you can use this in the rockspec: | ||
| 6 | -- source = { url = "git+https://example.com/foo.git" } | ||
| 7 | return require "luarocks.fetch.git_http" | ||
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index 7678c0cc..6d457fc2 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
| @@ -26,6 +26,8 @@ or a filename of a locally available rock. | |||
| 26 | rock after installing a new one. This behavior can | 26 | rock after installing a new one. This behavior can |
| 27 | be made permanent by setting keep_other_versions=true | 27 | be made permanent by setting keep_other_versions=true |
| 28 | in the configuration file. | 28 | in the configuration file. |
| 29 | |||
| 30 | --only-deps Installs only the dependencies of the rock. | ||
| 29 | ]]..util.deps_mode_help() | 31 | ]]..util.deps_mode_help() |
| 30 | 32 | ||
| 31 | 33 | ||
| @@ -109,6 +111,43 @@ function install.install_binary_rock(rock_file, deps_mode) | |||
| 109 | return name, version | 111 | return name, version |
| 110 | end | 112 | end |
| 111 | 113 | ||
| 114 | --- Installs the dependencies of a binary rock. | ||
| 115 | -- @param rock_file string: local or remote filename of a rock. | ||
| 116 | -- @param deps_mode: string: Which trees to check dependencies for: | ||
| 117 | -- "one" for the current default tree, "all" for all trees, | ||
| 118 | -- "order" for all trees with priority >= the current default, "none" for no trees. | ||
| 119 | -- @return (string, string) or (nil, string, [string]): Name and version of | ||
| 120 | -- the rock whose dependencies were installed if succeeded or nil and an error message | ||
| 121 | -- followed by an error code. | ||
| 122 | function install.install_binary_rock_deps(rock_file, deps_mode) | ||
| 123 | assert(type(rock_file) == "string") | ||
| 124 | |||
| 125 | local name, version, arch = path.parse_name(rock_file) | ||
| 126 | if not name then | ||
| 127 | return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." | ||
| 128 | end | ||
| 129 | |||
| 130 | if arch ~= "all" and arch ~= cfg.arch then | ||
| 131 | return nil, "Incompatible architecture "..arch, "arch" | ||
| 132 | end | ||
| 133 | |||
| 134 | local ok, err, errcode = fetch.fetch_and_unpack_rock(rock_file, path.install_dir(name, version)) | ||
| 135 | if not ok then return nil, err, errcode end | ||
| 136 | |||
| 137 | local rockspec, err, errcode = fetch.load_rockspec(path.rockspec_file(name, version)) | ||
| 138 | if err then | ||
| 139 | return nil, "Failed loading rockspec for installed package: "..err, errcode | ||
| 140 | end | ||
| 141 | |||
| 142 | ok, err, errcode = deps.fulfill_dependencies(rockspec, deps_mode) | ||
| 143 | if err then return nil, err, errcode end | ||
| 144 | |||
| 145 | util.printout() | ||
| 146 | util.printout("Succesfully installed dependencies for " ..name.." "..version) | ||
| 147 | |||
| 148 | return name, version | ||
| 149 | end | ||
| 150 | |||
| 112 | --- Driver function for the "install" command. | 151 | --- Driver function for the "install" command. |
| 113 | -- @param name string: name of a binary rock. If an URL or pathname | 152 | -- @param name string: name of a binary rock. If an URL or pathname |
| 114 | -- to a binary rock is given, fetches and installs it. If a rockspec or a | 153 | -- to a binary rock is given, fetches and installs it. If a rockspec or a |
| @@ -131,12 +170,16 @@ function install.run(...) | |||
| 131 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then | 170 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then |
| 132 | util.printout("Using "..name.."... switching to 'build' mode") | 171 | util.printout("Using "..name.."... switching to 'build' mode") |
| 133 | local build = require("luarocks.build") | 172 | local build = require("luarocks.build") |
| 134 | return build.run(name, util.forward_flags(flags, "local", "keep", "deps-mode")) | 173 | return build.run(name, util.forward_flags(flags, "local", "keep", "deps-mode", "only-deps")) |
| 135 | elseif name:match("%.rock$") then | 174 | elseif name:match("%.rock$") then |
| 136 | ok, err = install.install_binary_rock(name, deps.get_deps_mode(flags)) | 175 | if flags["only-deps"] then |
| 176 | ok, err = install.install_binary_rock_deps(name, deps.get_deps_mode(flags)) | ||
| 177 | else | ||
| 178 | ok, err = install.install_binary_rock(name, deps.get_deps_mode(flags)) | ||
| 179 | end | ||
| 137 | if not ok then return nil, err end | 180 | if not ok then return nil, err end |
| 138 | local name, version = ok, err | 181 | local name, version = ok, err |
| 139 | if (not flags["keep"]) and not cfg.keep_other_versions then | 182 | if (not flags["only-deps"]) and (not flags["keep"]) and not cfg.keep_other_versions then |
| 140 | local ok, err = remove.remove_other_versions(name, version, flags["force"]) | 183 | local ok, err = remove.remove_other_versions(name, version, flags["force"]) |
| 141 | if not ok then util.printerr(err) end | 184 | if not ok then util.printerr(err) end |
| 142 | end | 185 | 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>", |
