diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2011-10-11 00:45:35 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-10-11 00:45:35 -0300 |
| commit | 3ad2f62adce549504375b6b7d8fb03190297ae6b (patch) | |
| tree | 59f29f52998216228a71720b55aa8633f9b1ee98 /src | |
| parent | bffc55e6f74fd3fc1d74c79bf12443c249491248 (diff) | |
| download | luarocks-3ad2f62adce549504375b6b7d8fb03190297ae6b.tar.gz luarocks-3ad2f62adce549504375b6b7d8fb03190297ae6b.tar.bz2 luarocks-3ad2f62adce549504375b6b7d8fb03190297ae6b.zip | |
New flag: --only-sources-from. Restrict domains from which sources can be downloaded.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/command_line.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/fetch.lua | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index dfb28e99..41c1c278 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
| @@ -130,6 +130,10 @@ function run_command(...) | |||
| 130 | end | 130 | end |
| 131 | cfg.rocks_servers = { flags["only-from"] } | 131 | cfg.rocks_servers = { flags["only-from"] } |
| 132 | end | 132 | end |
| 133 | |||
| 134 | if flags["only-sources-from"] then | ||
| 135 | cfg.only_sources_from = flags["only-sources-from"] | ||
| 136 | end | ||
| 133 | 137 | ||
| 134 | if command ~= "help" then | 138 | if command ~= "help" then |
| 135 | for k, v in pairs(cmdline_vars) do | 139 | for k, v in pairs(cmdline_vars) do |
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 3f96e523..874dc33f 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua | |||
| @@ -9,6 +9,7 @@ local path = require("luarocks.path") | |||
| 9 | local deps = require("luarocks.deps") | 9 | local deps = require("luarocks.deps") |
| 10 | local persist = require("luarocks.persist") | 10 | local persist = require("luarocks.persist") |
| 11 | local util = require("luarocks.util") | 11 | local util = require("luarocks.util") |
| 12 | local cfg = require("luarocks.cfg") | ||
| 12 | 13 | ||
| 13 | --- Fetch a local or remote file. | 14 | --- Fetch a local or remote file. |
| 14 | -- Make a remote or local URL/pathname local, fetching the file if necessary. | 15 | -- Make a remote or local URL/pathname local, fetching the file if necessary. |
| @@ -307,5 +308,15 @@ function fetch_sources(rockspec, extract, dest_dir) | |||
| 307 | end | 308 | end |
| 308 | end | 309 | end |
| 309 | 310 | ||
| 311 | if cfg.only_sources_from | ||
| 312 | and rockspec.source.pathname | ||
| 313 | and #rockspec.source.pathname > 0 then | ||
| 314 | if #cfg.only_sources_from == 0 then | ||
| 315 | return nil, "Can't download "..rockspec.source.url.." -- download from remote servers disabled" | ||
| 316 | elseif not rockspec.source.pathname:match("^"..cfg.only_sources_from) then | ||
| 317 | return nil, "Can't download "..rockspec.source.url.." -- only downloading from "..cfg.only_sources_from | ||
| 318 | end | ||
| 319 | end | ||
| 320 | |||
| 310 | return proto.get_sources(rockspec, extract, dest_dir) | 321 | return proto.get_sources(rockspec, extract, dest_dir) |
| 311 | end | 322 | end |
