diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2014-02-08 18:27:28 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2014-02-08 18:27:28 -0200 |
| commit | 330ee40e3168cc060c6c806ec1ed90c8fb73a3ff (patch) | |
| tree | c33cdfcc1a20b28a256e3c6501a307e93509dd5e | |
| parent | 0033902ed5bbcd310cfbd2301ba861a43e2233a8 (diff) | |
| download | luarocks-330ee40e3168cc060c6c806ec1ed90c8fb73a3ff.tar.gz luarocks-330ee40e3168cc060c6c806ec1ed90c8fb73a3ff.tar.bz2 luarocks-330ee40e3168cc060c6c806ec1ed90c8fb73a3ff.zip | |
Install default doc files if the rockspec does not include any.
| -rw-r--r-- | src/luarocks/build.lua | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 0e58e2e5..4e433f74 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
| @@ -128,6 +128,24 @@ function apply_patches(rockspec) | |||
| 128 | return true | 128 | return true |
| 129 | end | 129 | end |
| 130 | 130 | ||
| 131 | local function install_default_docs(name, version) | ||
| 132 | local patterns = { "readme", "license", "copying" } | ||
| 133 | local dest = dir.path(path.install_dir(name, version), "doc") | ||
| 134 | local has_dir = false | ||
| 135 | for name in fs.dir() do | ||
| 136 | for _, pattern in ipairs(patterns) do | ||
| 137 | if name:lower():match("^"..pattern) then | ||
| 138 | if not has_dir then | ||
| 139 | fs.make_dir(dest) | ||
| 140 | has_dir = true | ||
| 141 | end | ||
| 142 | fs.copy(name, dest) | ||
| 143 | break | ||
| 144 | end | ||
| 145 | end | ||
| 146 | end | ||
| 147 | end | ||
| 148 | |||
| 131 | --- Build and install a rock given a rockspec. | 149 | --- Build and install a rock given a rockspec. |
| 132 | -- @param rockspec_file string: local or remote filename of a rockspec. | 150 | -- @param rockspec_file string: local or remote filename of a rockspec. |
| 133 | -- @param need_to_fetch boolean: true if sources need to be fetched, | 151 | -- @param need_to_fetch boolean: true if sources need to be fetched, |
| @@ -255,18 +273,24 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_mode) | |||
| 255 | copying_default = true | 273 | copying_default = true |
| 256 | end | 274 | end |
| 257 | 275 | ||
| 276 | local any_docs = false | ||
| 258 | for _, copy_dir in pairs(copy_directories) do | 277 | for _, copy_dir in pairs(copy_directories) do |
| 259 | if fs.is_dir(copy_dir) then | 278 | if fs.is_dir(copy_dir) then |
| 260 | local dest = dir.path(path.install_dir(name, version), copy_dir) | 279 | local dest = dir.path(path.install_dir(name, version), copy_dir) |
| 261 | fs.make_dir(dest) | 280 | fs.make_dir(dest) |
| 262 | fs.copy_contents(copy_dir, dest) | 281 | fs.copy_contents(copy_dir, dest) |
| 282 | any_docs = true | ||
| 263 | else | 283 | else |
| 264 | if not copying_default then | 284 | if not copying_default then |
| 265 | return nil, "Directory '"..copy_dir.."' not found" | 285 | return nil, "Directory '"..copy_dir.."' not found" |
| 266 | end | 286 | end |
| 267 | end | 287 | end |
| 268 | end | 288 | end |
| 269 | 289 | ||
| 290 | if not any_docs then | ||
| 291 | install_default_docs(name, version) | ||
| 292 | end | ||
| 293 | |||
| 270 | for _, d in pairs(dirs) do | 294 | for _, d in pairs(dirs) do |
| 271 | fs.remove_dir_if_empty(d.name) | 295 | fs.remove_dir_if_empty(d.name) |
| 272 | end | 296 | end |
