diff options
author | Paul Ouellette <oue.paul18@gmail.com> | 2019-11-15 14:08:29 -0500 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2019-11-15 16:08:29 -0300 |
commit | 9446ac85d8bf085d2a6f0a02a6a432e14dddac61 (patch) | |
tree | c5e04878fabfa42beee0a891c0ac59c0a97137bb | |
parent | 3a3f2cbaa50d353f4c26b39f59c015a20f28c4ae (diff) | |
download | luarocks-9446ac85d8bf085d2a6f0a02a6a432e14dddac61.tar.gz luarocks-9446ac85d8bf085d2a6f0a02a6a432e14dddac61.tar.bz2 luarocks-9446ac85d8bf085d2a6f0a02a6a432e14dddac61.zip |
Support make --no-doc (#1092)
* Support make --no-doc
* Add test for make --no-doc
-rw-r--r-- | spec/make_spec.lua | 16 | ||||
-rw-r--r-- | src/luarocks/cmd/build.lua | 20 | ||||
-rw-r--r-- | src/luarocks/cmd/install.lua | 14 | ||||
-rw-r--r-- | src/luarocks/cmd/make.lua | 11 | ||||
-rw-r--r-- | src/luarocks/util.lua | 17 |
5 files changed, 48 insertions, 30 deletions
diff --git a/spec/make_spec.lua b/spec/make_spec.lua index 0fc5cd93..5ec99fa7 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua | |||
@@ -49,6 +49,22 @@ describe("LuaRocks make tests #integration", function() | |||
49 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec")) | 49 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec")) |
50 | end) | 50 | end) |
51 | 51 | ||
52 | it("LuaRocks make --no-doc", function() | ||
53 | finally(function() | ||
54 | lfs.chdir(testing_paths.testrun_dir) | ||
55 | test_env.remove_dir("luasocket-3.0rc1-2") | ||
56 | os.remove("luasocket-3.0rc1-2.src.rock") | ||
57 | end) | ||
58 | |||
59 | assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2")) | ||
60 | assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock")) | ||
61 | lfs.chdir("luasocket-3.0rc1-2/luasocket-3.0-rc1/") | ||
62 | assert.is_true(run.luarocks_bool("make --no-doc luasocket-3.0rc1-2.rockspec")) | ||
63 | |||
64 | assert.is_true(run.luarocks_bool("show luasocket")) | ||
65 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket/3.0rc1-2/doc")) | ||
66 | end) | ||
67 | |||
52 | describe("LuaRocks making rockspecs (using lxsh)", function() | 68 | describe("LuaRocks making rockspecs (using lxsh)", function() |
53 | --download lxsh and unpack it | 69 | --download lxsh and unpack it |
54 | before_each(function() | 70 | before_each(function() |
diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index ea47cbb0..1819d0da 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua | |||
@@ -3,7 +3,6 @@ | |||
3 | -- Builds a rock, compiling its C parts if any. | 3 | -- Builds a rock, compiling its C parts if any. |
4 | local cmd_build = {} | 4 | local cmd_build = {} |
5 | 5 | ||
6 | local dir = require("luarocks.dir") | ||
7 | local pack = require("luarocks.pack") | 6 | local pack = require("luarocks.pack") |
8 | local path = require("luarocks.path") | 7 | local path = require("luarocks.path") |
9 | local util = require("luarocks.util") | 8 | local util = require("luarocks.util") |
@@ -29,8 +28,7 @@ function cmd_build.add_to_parser(parser) | |||
29 | cmd:argument("version", "Rock version.") | 28 | cmd:argument("version", "Rock version.") |
30 | :args("?") | 29 | :args("?") |
31 | 30 | ||
32 | cmd:flag("--only-deps", "Installs only the dependencies of the rock.") | 31 | cmd:flag("--only-deps", "Install only the dependencies of the rock.") |
33 | cmd:flag("--no-doc", "Installs the rock without its documentation.") | ||
34 | cmd:option("--branch", "Override the `source.branch` field in the loaded ".. | 32 | cmd:option("--branch", "Override the `source.branch` field in the loaded ".. |
35 | "rockspec. Allows to specify a different branch to fetch. Particularly ".. | 33 | "rockspec. Allows to specify a different branch to fetch. Particularly ".. |
36 | 'for "dev" rocks.') | 34 | 'for "dev" rocks.') |
@@ -104,18 +102,6 @@ local function do_build(ns_name, version, opts) | |||
104 | return build_rock(url, opts) | 102 | return build_rock(url, opts) |
105 | end | 103 | end |
106 | 104 | ||
107 | local function remove_doc_dir(name, version) | ||
108 | local install_dir = path.install_dir(name, version) | ||
109 | for _, f in ipairs(fs.list_dir(install_dir)) do | ||
110 | local doc_dirs = { "doc", "docs" } | ||
111 | for _, d in ipairs(doc_dirs) do | ||
112 | if f == d then | ||
113 | fs.delete(dir.path(install_dir, f)) | ||
114 | end | ||
115 | end | ||
116 | end | ||
117 | end | ||
118 | |||
119 | --- Driver function for "build" command. | 105 | --- Driver function for "build" command. |
120 | -- If a package name is given, forwards the request to "search" and, | 106 | -- If a package name is given, forwards the request to "search" and, |
121 | -- if returned a result, installs the matching rock. | 107 | -- if returned a result, installs the matching rock. |
@@ -148,7 +134,7 @@ function cmd_build.command(args) | |||
148 | opts.build_only_deps = false | 134 | opts.build_only_deps = false |
149 | local name, version, errcode = do_build(name, args.version, opts) | 135 | local name, version, errcode = do_build(name, args.version, opts) |
150 | if name and args.no_doc then | 136 | if name and args.no_doc then |
151 | remove_doc_dir(name, version) | 137 | util.remove_doc_dir(name, version) |
152 | end | 138 | end |
153 | return name, version, errcode | 139 | return name, version, errcode |
154 | end) | 140 | end) |
@@ -165,7 +151,7 @@ function cmd_build.command(args) | |||
165 | name, version = ok, err | 151 | name, version = ok, err |
166 | 152 | ||
167 | if args.no_doc then | 153 | if args.no_doc then |
168 | remove_doc_dir(name, version) | 154 | util.remove_doc_dir(name, version) |
169 | end | 155 | end |
170 | 156 | ||
171 | if opts.build_only_deps then | 157 | if opts.build_only_deps then |
diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index be4b0104..b4c87f7c 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua | |||
@@ -31,8 +31,8 @@ function install.add_to_parser(parser) | |||
31 | "previously installed versions if it would break dependencies.") | 31 | "previously installed versions if it would break dependencies.") |
32 | cmd:flag("--force-fast", "Like --force, but performs a forced removal ".. | 32 | cmd:flag("--force-fast", "Like --force, but performs a forced removal ".. |
33 | "without reporting dependency issues.") | 33 | "without reporting dependency issues.") |
34 | cmd:flag("--only-deps", "Installs only the dependencies of the rock.") | 34 | cmd:flag("--only-deps", "Install only the dependencies of the rock.") |
35 | cmd:flag("--no-doc", "Installs the rock without its documentation.") | 35 | cmd:flag("--no-doc", "Install the rock without its documentation.") |
36 | cmd:flag("--verify", "Verify signature of the rockspec or src.rock being ".. | 36 | cmd:flag("--verify", "Verify signature of the rockspec or src.rock being ".. |
37 | "built. If the rockspec or src.rock is being downloaded, LuaRocks will ".. | 37 | "built. If the rockspec or src.rock is being downloaded, LuaRocks will ".. |
38 | "attempt to download the signature as well. Otherwise, the signature ".. | 38 | "attempt to download the signature as well. Otherwise, the signature ".. |
@@ -190,15 +190,7 @@ local function install_rock_file(filename, opts) | |||
190 | if not name then return nil, version end | 190 | if not name then return nil, version end |
191 | 191 | ||
192 | if opts.no_doc then | 192 | if opts.no_doc then |
193 | local install_dir = path.install_dir(name, version) | 193 | util.remove_doc_dir(name, version) |
194 | for _, f in ipairs(fs.list_dir(install_dir)) do | ||
195 | local doc_dirs = { "doc", "docs" } | ||
196 | for _, d in ipairs(doc_dirs) do | ||
197 | if f == d then | ||
198 | fs.delete(dir.path(install_dir, f)) | ||
199 | end | ||
200 | end | ||
201 | end | ||
202 | end | 194 | end |
203 | 195 | ||
204 | if (not opts.keep) and not cfg.keep_other_versions then | 196 | if (not opts.keep) and not cfg.keep_other_versions then |
diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.lua index 3ff5c277..0a1f99f0 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.lua | |||
@@ -17,6 +17,7 @@ local writer = require("luarocks.manif.writer") | |||
17 | local cmd = require("luarocks.cmd") | 17 | local cmd = require("luarocks.cmd") |
18 | 18 | ||
19 | function make.cmd_options(parser) | 19 | function make.cmd_options(parser) |
20 | parser:flag("--no-doc", "Install the rock without its documentation.") | ||
20 | parser:flag("--pack-binary-rock", "Do not install rock. Instead, produce a ".. | 21 | parser:flag("--pack-binary-rock", "Do not install rock. Instead, produce a ".. |
21 | ".rock file with the contents of compilation in the current directory.") | 22 | ".rock file with the contents of compilation in the current directory.") |
22 | parser:flag("--keep", "Do not remove previously installed versions of the ".. | 23 | parser:flag("--keep", "Do not remove previously installed versions of the ".. |
@@ -101,7 +102,11 @@ function make.command(args) | |||
101 | 102 | ||
102 | if args.pack_binary_rock then | 103 | if args.pack_binary_rock then |
103 | return pack.pack_binary_rock(name, rockspec.version, args.sign, function() | 104 | return pack.pack_binary_rock(name, rockspec.version, args.sign, function() |
104 | return build.build_rockspec(rockspec, opts) | 105 | local name, version = build.build_rockspec(rockspec, opts) |
106 | if name and args.no_doc then | ||
107 | util.remove_doc_dir(name, version) | ||
108 | end | ||
109 | return name, version | ||
105 | end) | 110 | end) |
106 | else | 111 | else |
107 | local ok, err = fs.check_command_permissions(args) | 112 | local ok, err = fs.check_command_permissions(args) |
@@ -110,6 +115,10 @@ function make.command(args) | |||
110 | if not ok then return nil, err end | 115 | if not ok then return nil, err end |
111 | local name, version = ok, err | 116 | local name, version = ok, err |
112 | 117 | ||
118 | if args.no_doc then | ||
119 | util.remove_doc_dir(name, version) | ||
120 | end | ||
121 | |||
113 | if (not args.keep) and not cfg.keep_other_versions then | 122 | if (not args.keep) and not cfg.keep_other_versions then |
114 | local ok, err = remove.remove_other_versions(name, version, args.force, args.force_fast) | 123 | local ok, err = remove.remove_other_versions(name, version, args.force, args.force_fast) |
115 | if not ok then util.printerr(err) end | 124 | if not ok then util.printerr(err) end |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 13ddf895..05b2566b 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -628,5 +628,20 @@ function util.get_rocks_provided(rockspec) | |||
628 | return rocks_provided | 628 | return rocks_provided |
629 | end | 629 | end |
630 | 630 | ||
631 | return util | 631 | function util.remove_doc_dir(name, version) |
632 | local path = require("luarocks.path") | ||
633 | local fs = require("luarocks.fs") | ||
634 | local dir = require("luarocks.dir") | ||
635 | |||
636 | local install_dir = path.install_dir(name, version) | ||
637 | for _, f in ipairs(fs.list_dir(install_dir)) do | ||
638 | local doc_dirs = { "doc", "docs" } | ||
639 | for _, d in ipairs(doc_dirs) do | ||
640 | if f == d then | ||
641 | fs.delete(dir.path(install_dir, f)) | ||
642 | end | ||
643 | end | ||
644 | end | ||
645 | end | ||
632 | 646 | ||
647 | return util | ||