diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2012-09-18 18:19:22 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-09-18 18:19:22 -0300 |
commit | 7134f592a0a2064fd04f0e169d7801b51504e4c6 (patch) | |
tree | 14bd7abdac8cc2b20b9287fe2a90bb24215e135b | |
parent | b1a36075e3a63167e97c124d2923ae1b10e07c29 (diff) | |
download | luarocks-7134f592a0a2064fd04f0e169d7801b51504e4c6.tar.gz luarocks-7134f592a0a2064fd04f0e169d7801b51504e4c6.tar.bz2 luarocks-7134f592a0a2064fd04f0e169d7801b51504e4c6.zip |
Add mirroring support. String-array entries in the array of
rocks_servers will be treated as a list of mirrors.
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | src/luarocks/cfg.lua | 5 | ||||
-rw-r--r-- | src/luarocks/search.lua | 19 |
3 files changed, 17 insertions, 10 deletions
@@ -136,9 +136,6 @@ write_sysconfig: built | |||
136 | if [ ! -f "$(DESTDIR)$(CONFIG_FILE)" ] ;\ | 136 | if [ ! -f "$(DESTDIR)$(CONFIG_FILE)" ] ;\ |
137 | then \ | 137 | then \ |
138 | mkdir -p `dirname "$(DESTDIR)$(CONFIG_FILE)"` ;\ | 138 | mkdir -p `dirname "$(DESTDIR)$(CONFIG_FILE)"` ;\ |
139 | echo 'rocks_servers = {' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | ||
140 | echo ' [[http://luarocks.org/repositories/rocks]]' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | ||
141 | echo '}' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | ||
142 | echo 'rocks_trees = {' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | 139 | echo 'rocks_trees = {' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ |
143 | if [ ! -n "$(FORCE_CONFIG)" ] ;\ | 140 | if [ ! -n "$(FORCE_CONFIG)" ] ;\ |
144 | then \ | 141 | then \ |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index efe5de36..263af063 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -171,7 +171,10 @@ local defaults = { | |||
171 | obj_extension = "unknown", | 171 | obj_extension = "unknown", |
172 | 172 | ||
173 | rocks_servers = { | 173 | rocks_servers = { |
174 | "http://www.luarocks.org/repositories/rocks" | 174 | { |
175 | "http://www.luarocks.org/repositories/rocks", | ||
176 | "http://luarocks.giga.puc-rio.br/" | ||
177 | } | ||
175 | }, | 178 | }, |
176 | 179 | ||
177 | lua_extension = "lua", | 180 | lua_extension = "lua", |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index 5df2bd38..9c53632a 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -194,13 +194,20 @@ function search_repos(query) | |||
194 | 194 | ||
195 | local results = {} | 195 | local results = {} |
196 | for _, repo in ipairs(cfg.rocks_servers) do | 196 | for _, repo in ipairs(cfg.rocks_servers) do |
197 | local protocol, pathname = dir.split_url(repo) | 197 | if type(repo) == "string" then |
198 | if protocol == "file" then | 198 | repo = { repo } |
199 | repo = pathname | ||
200 | end | 199 | end |
201 | local ok, err = manifest_search(results, repo, query) | 200 | for _, mirror in ipairs(repo) do |
202 | if not ok then | 201 | local protocol, pathname = dir.split_url(mirror) |
203 | util.warning("Failed searching manifest: "..err) | 202 | if protocol == "file" then |
203 | mirror = pathname | ||
204 | end | ||
205 | local ok, err = manifest_search(results, mirror, query) | ||
206 | if ok then | ||
207 | break | ||
208 | else | ||
209 | util.warning("Failed searching manifest: "..err) | ||
210 | end | ||
204 | end | 211 | end |
205 | end | 212 | end |
206 | return results | 213 | return results |