aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Roman <george.roman.99@gmail.com>2019-01-25 13:24:30 +0200
committerHisham Muhammad <hisham@gobolinux.org>2019-02-12 19:29:40 -0200
commitb096e35e29f5406f74c5cf7bdb86eff8ebf3b526 (patch)
treec23ccb6e85fb8d5e94c12021e2c5d0ebc3b3c01a
parent28f1f87879aac1ae3d6e296b30c3c93be84741ce (diff)
downloadluarocks-b096e35e29f5406f74c5cf7bdb86eff8ebf3b526.tar.gz
luarocks-b096e35e29f5406f74c5cf7bdb86eff8ebf3b526.tar.bz2
luarocks-b096e35e29f5406f74c5cf7bdb86eff8ebf3b526.zip
Support installations without documentation
-rw-r--r--spec/install_spec.lua8
-rw-r--r--src/luarocks/cmd/build.lua23
-rw-r--r--src/luarocks/cmd/install.lua18
-rw-r--r--src/luarocks/util.lua1
4 files changed, 45 insertions, 5 deletions
diff --git a/spec/install_spec.lua b/spec/install_spec.lua
index 0555155b..77ac6225 100644
--- a/spec/install_spec.lua
+++ b/spec/install_spec.lua
@@ -23,8 +23,6 @@ local extra_rocks = {
23 "/wsapi-1.6-1.src.rock", 23 "/wsapi-1.6-1.src.rock",
24 "/luafilesystem-1.6.3-2.src.rock", 24 "/luafilesystem-1.6.3-2.src.rock",
25 "/luafilesystem-1.6.3-1.src.rock", 25 "/luafilesystem-1.6.3-1.src.rock",
26 "/luacheck-0.7.3-1.src.rock",
27 "/luacheck-0.8.0-1.src.rock",
28 "/sailor-0.5-3.src.rock", 26 "/sailor-0.5-3.src.rock",
29 "/sailor-0.5-4.src.rock", 27 "/sailor-0.5-4.src.rock",
30} 28}
@@ -82,6 +80,12 @@ describe("luarocks install #integration", function()
82 assert.is_true(run.luarocks_bool("install luasec " .. test_env.openssl_dirs)) 80 assert.is_true(run.luarocks_bool("install luasec " .. test_env.openssl_dirs))
83 assert.is_true(run.luarocks_bool("show luasocket")) 81 assert.is_true(run.luarocks_bool("show luasocket"))
84 end) 82 end)
83
84 it("installs a package without its documentation #only", function()
85 assert.is_true(run.luarocks_bool("install wsapi 1.6 --no-doc"))
86 assert.is_true(run.luarocks_bool("show wsapi 1.6"))
87 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/wsapi/1.6-1/doc"))
88 end)
85 end) 89 end)
86 90
87 describe("#namespaces", function() 91 describe("#namespaces", function()
diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua
index daccd6cc..29b1bd6e 100644
--- a/src/luarocks/cmd/build.lua
+++ b/src/luarocks/cmd/build.lua
@@ -3,6 +3,7 @@
3-- Builds a rock, compiling its C parts if any. 3-- Builds a rock, compiling its C parts if any.
4local cmd_build = {} 4local cmd_build = {}
5 5
6local dir = require("luarocks.dir")
6local pack = require("luarocks.pack") 7local pack = require("luarocks.pack")
7local path = require("luarocks.path") 8local path = require("luarocks.path")
8local util = require("luarocks.util") 9local util = require("luarocks.util")
@@ -113,6 +114,18 @@ local function do_build(ns_name, version, opts)
113 return build_rock(url, opts) 114 return build_rock(url, opts)
114end 115end
115 116
117local function remove_doc_dir(name, version)
118 local install_dir = path.install_dir(name, version)
119 for _, f in ipairs(fs.list_dir(install_dir)) do
120 local doc_dirs = { "doc", "docs" }
121 for _, d in ipairs(doc_dirs) do
122 if f == d then
123 fs.delete(dir.path(install_dir, f))
124 end
125 end
126 end
127end
128
116--- Driver function for "build" command. 129--- Driver function for "build" command.
117-- @param name string: A local or remote rockspec or rock file. 130-- @param name string: A local or remote rockspec or rock file.
118-- If a package name is given, forwards the request to "search" and, 131-- If a package name is given, forwards the request to "search" and,
@@ -143,7 +156,11 @@ function cmd_build.command(flags, name, version)
143 if flags["pack-binary-rock"] then 156 if flags["pack-binary-rock"] then
144 return pack.pack_binary_rock(name, version, function() 157 return pack.pack_binary_rock(name, version, function()
145 opts.build_only_deps = false 158 opts.build_only_deps = false
146 return do_build(name, version, opts) 159 local status, err, errcode = do_build(name, version, opts)
160 if status and flags["no-doc"] then
161 remove_doc_dir(name, version)
162 end
163 return status, err, errcode
147 end) 164 end)
148 end 165 end
149 166
@@ -156,6 +173,10 @@ function cmd_build.command(flags, name, version)
156 if not ok then return nil, err end 173 if not ok then return nil, err end
157 name, version = ok, err 174 name, version = ok, err
158 175
176 if flags["no-doc"] then
177 remove_doc_dir(name, version)
178 end
179
159 if opts.build_only_deps then 180 if opts.build_only_deps then
160 util.printout("Stopping after installing dependencies for " ..name.." "..version) 181 util.printout("Stopping after installing dependencies for " ..name.." "..version)
161 util.printout() 182 util.printout()
diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua
index 824ca248..97c693d9 100644
--- a/src/luarocks/cmd/install.lua
+++ b/src/luarocks/cmd/install.lua
@@ -29,6 +29,7 @@ or a filename of a locally available rock.
29 in the configuration file. 29 in the configuration file.
30 30
31--only-deps Installs only the dependencies of the rock. 31--only-deps Installs only the dependencies of the rock.
32--no-doc Installs the rock without its documentation.
32]]..util.deps_mode_help() 33]]..util.deps_mode_help()
33 34
34 35
@@ -154,17 +155,30 @@ local function install_rock_file_deps(filename, deps_mode)
154 return name, version 155 return name, version
155end 156end
156 157
157local function install_rock_file(filename, namespace, deps_mode, keep, force, force_fast) 158local function install_rock_file(filename, namespace, deps_mode, keep, force, force_fast, no_doc)
158 assert(type(filename) == "string") 159 assert(type(filename) == "string")
159 assert(type(namespace) == "string" or namespace == nil) 160 assert(type(namespace) == "string" or namespace == nil)
160 assert(type(deps_mode) == "string") 161 assert(type(deps_mode) == "string")
161 assert(type(keep) == "boolean" or keep == nil) 162 assert(type(keep) == "boolean" or keep == nil)
162 assert(type(force) == "boolean" or force == nil) 163 assert(type(force) == "boolean" or force == nil)
163 assert(type(force_fast) == "boolean" or force_fast == nil) 164 assert(type(force_fast) == "boolean" or force_fast == nil)
165 assert(type(no_doc) == "boolean" or no_doc == nil)
164 166
165 local name, version = install.install_binary_rock(filename, deps_mode, namespace) 167 local name, version = install.install_binary_rock(filename, deps_mode, namespace)
166 if not name then return nil, version end 168 if not name then return nil, version end
167 169
170 if no_doc then
171 local install_dir = path.install_dir(name, version)
172 for _, f in ipairs(fs.list_dir(install_dir)) do
173 local doc_dirs = { "doc", "docs" }
174 for _, d in ipairs(doc_dirs) do
175 if f == d then
176 fs.delete(dir.path(install_dir, f))
177 end
178 end
179 end
180 end
181
168 if (not keep) and not cfg.keep_other_versions then 182 if (not keep) and not cfg.keep_other_versions then
169 local ok, err = remove.remove_other_versions(name, version, force, force_fast) 183 local ok, err = remove.remove_other_versions(name, version, force, force_fast)
170 if not ok then util.printerr(err) end 184 if not ok then util.printerr(err) end
@@ -202,7 +216,7 @@ function install.command(flags, name, version)
202 if flags["only-deps"] then 216 if flags["only-deps"] then
203 return install_rock_file_deps(name, deps_mode) 217 return install_rock_file_deps(name, deps_mode)
204 else 218 else
205 return install_rock_file(name, flags["namespace"], deps_mode, flags["keep"], flags["force"], flags["force-fast"]) 219 return install_rock_file(name, flags["namespace"], deps_mode, flags["keep"], flags["force"], flags["force-fast"], flags["no-doc"])
206 end 220 end
207 else 221 else
208 local url, err = search.find_suitable_rock(queries.new(name:lower(), version)) 222 local url, err = search.find_suitable_rock(queries.new(name:lower(), version))
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index 9aef9049..7f7ad80f 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -125,6 +125,7 @@ local supported_flags = {
125 ["mversion"] = true, 125 ["mversion"] = true,
126 ["namespace"] = "<namespace>", 126 ["namespace"] = "<namespace>",
127 ["no-bin"] = true, 127 ["no-bin"] = true,
128 ["no-doc"] = true,
128 ["no-refresh"] = true, 129 ["no-refresh"] = true,
129 ["nodeps"] = true, 130 ["nodeps"] = true,
130 ["old-versions"] = true, 131 ["old-versions"] = true,