diff options
author | Fabio Mascarenhas <mascarenhas@lambda-2.local> | 2010-03-20 15:05:42 -0300 |
---|---|---|
committer | Fabio Mascarenhas <mascarenhas@lambda-2.local> | 2010-03-20 15:05:42 -0300 |
commit | ebda93002751a729e9e6f24ac22c3a2ff5e6b09a (patch) | |
tree | b55342b111df22a5586488ee3ad96841629d285d | |
parent | acb4296d3cdd3b5017c3c39e04ecc12c55e49ed5 (diff) | |
download | luarocks-ebda93002751a729e9e6f24ac22c3a2ff5e6b09a.tar.gz luarocks-ebda93002751a729e9e6f24ac22c3a2ff5e6b09a.tar.bz2 luarocks-ebda93002751a729e9e6f24ac22c3a2ff5e6b09a.zip |
synchronizing with the svn repo
-rw-r--r-- | src/luarocks/add.lua | 3 | ||||
-rw-r--r-- | src/luarocks/build/builtin.lua | 19 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 27 | ||||
-rw-r--r-- | src/luarocks/manif.lua | 10 | ||||
-rw-r--r-- | src/luarocks/refresh_cache.lua | 4 | ||||
-rw-r--r-- | src/luarocks/util.lua | 4 |
6 files changed, 46 insertions, 21 deletions
diff --git a/src/luarocks/add.lua b/src/luarocks/add.lua index 2211a27a..56021bb4 100644 --- a/src/luarocks/add.lua +++ b/src/luarocks/add.lua | |||
@@ -93,9 +93,6 @@ function run(...) | |||
93 | if not server then | 93 | if not server then |
94 | return nil, "No server specified with --to and no default configured with upload_server." | 94 | return nil, "No server specified with --to and no default configured with upload_server." |
95 | end | 95 | end |
96 | if cfg.upload_aliases then | ||
97 | server = cfg.upload_aliases[server] or server | ||
98 | end | ||
99 | return add_file_to_server(not flags["no-refresh"], file, server, cfg.upload_servers and cfg.upload_servers[server]) | 96 | return add_file_to_server(not flags["no-refresh"], file, server, cfg.upload_servers and cfg.upload_servers[server]) |
100 | end | 97 | end |
101 | 98 | ||
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index b6f42eab..3473abcb 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
@@ -166,6 +166,7 @@ function run(rockspec) | |||
166 | end | 166 | end |
167 | 167 | ||
168 | local ok = true | 168 | local ok = true |
169 | local err = "Build error" | ||
169 | local built_modules = {} | 170 | local built_modules = {} |
170 | local luadir = path.lua_dir(rockspec.name, rockspec.version) | 171 | local luadir = path.lua_dir(rockspec.name, rockspec.version) |
171 | local libdir = path.lib_dir(rockspec.name, rockspec.version) | 172 | local libdir = path.lib_dir(rockspec.name, rockspec.version) |
@@ -219,7 +220,10 @@ function run(rockspec) | |||
219 | object = source.."."..cfg.obj_extension | 220 | object = source.."."..cfg.obj_extension |
220 | end | 221 | end |
221 | ok = compile_object(object, source, info.defines, info.incdirs) | 222 | ok = compile_object(object, source, info.defines, info.incdirs) |
222 | if not ok then break end | 223 | if not ok then |
224 | err = "Failed compiling object "..object | ||
225 | break | ||
226 | end | ||
223 | table.insert(objects, object) | 227 | table.insert(objects, object) |
224 | end | 228 | end |
225 | if not ok then break end | 229 | if not ok then break end |
@@ -230,22 +234,29 @@ function run(rockspec) | |||
230 | local dest = dir.path(libdir, moddir) | 234 | local dest = dir.path(libdir, moddir) |
231 | built_modules[module_name] = dest | 235 | built_modules[module_name] = dest |
232 | ok = compile_library(module_name, objects, info.libraries, info.libdirs, name) | 236 | ok = compile_library(module_name, objects, info.libraries, info.libdirs, name) |
233 | if not ok then break end | 237 | if not ok then |
238 | err = "Failed compiling module "..module_name | ||
239 | break | ||
240 | end | ||
234 | end | 241 | end |
235 | end | 242 | end |
236 | for name, dest in pairs(built_modules) do | 243 | for name, dest in pairs(built_modules) do |
237 | fs.make_dir(dest) | 244 | fs.make_dir(dest) |
238 | ok = fs.copy(name, dest) | 245 | ok = fs.copy(name, dest) |
239 | if not ok then break end | 246 | if not ok then |
247 | err = "Failed installing "..name.." in "..dest | ||
248 | break | ||
249 | end | ||
240 | end | 250 | end |
241 | if ok then | 251 | if ok then |
242 | if fs.is_dir("lua") then | 252 | if fs.is_dir("lua") then |
243 | ok = fs.copy_contents("lua", luadir) | 253 | ok = fs.copy_contents("lua", luadir) |
254 | if not ok then err = "Failed copying contents of 'lua' directory." end | ||
244 | end | 255 | end |
245 | end | 256 | end |
246 | if ok then | 257 | if ok then |
247 | return true | 258 | return true |
248 | else | 259 | else |
249 | return nil, "Build error" | 260 | return nil, err |
250 | end | 261 | end |
251 | end | 262 | end |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index ad6d263b..0e11520b 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -7,8 +7,10 @@ local fs = require("luarocks.fs") | |||
7 | 7 | ||
8 | local cfg = require("luarocks.cfg") | 8 | local cfg = require("luarocks.cfg") |
9 | local dir = require("luarocks.dir") | 9 | local dir = require("luarocks.dir") |
10 | local util = require("luarocks.util") | ||
10 | 11 | ||
11 | local socket_ok, http = pcall(require, "socket.http") | 12 | local socket_ok, http = pcall(require, "socket.http") |
13 | local _, ftp = pcall(require, "socket.ftp") | ||
12 | local zip_ok, lrzip = pcall(require, "luarocks.tools.zip") | 14 | local zip_ok, lrzip = pcall(require, "luarocks.tools.zip") |
13 | local unzip_ok, luazip = pcall(require, "zip"); _G.zip = nil | 15 | local unzip_ok, luazip = pcall(require, "zip"); _G.zip = nil |
14 | local lfs_ok, lfs = pcall(require, "lfs") | 16 | local lfs_ok, lfs = pcall(require, "lfs") |
@@ -178,6 +180,10 @@ function make_dir(directory) | |||
178 | if directory:sub(2, 2) == ":" then | 180 | if directory:sub(2, 2) == ":" then |
179 | path = directory:sub(1, 2) | 181 | path = directory:sub(1, 2) |
180 | directory = directory:sub(4) | 182 | directory = directory:sub(4) |
183 | else | ||
184 | if directory:match("^/") then | ||
185 | path = "" | ||
186 | end | ||
181 | end | 187 | end |
182 | for d in directory:gmatch("([^"..dir.separator.."]+)"..dir.separator.."*") do | 188 | for d in directory:gmatch("([^"..dir.separator.."]+)"..dir.separator.."*") do |
183 | path = path and path .. dir.separator .. d or d | 189 | path = path and path .. dir.separator .. d or d |
@@ -503,14 +509,25 @@ function download(url, filename) | |||
503 | 509 | ||
504 | filename = dir.path(fs.current_dir(), filename or dir.base_name(url)) | 510 | filename = dir.path(fs.current_dir(), filename or dir.base_name(url)) |
505 | 511 | ||
506 | local res, status, headers, line = http.request(url) | 512 | local content, err |
507 | if not res then return false, status end | 513 | if util.starts_with(url, "http:") then |
508 | if status ~= 200 then | 514 | local res, status, headers, line = http.request(url) |
509 | return false, "Failed downloading: " .. line | 515 | if not res then |
516 | err = status | ||
517 | elseif status ~= 200 then | ||
518 | err = line | ||
519 | else | ||
520 | content = res | ||
521 | end | ||
522 | elseif util.starts_with(url, "ftp:") then | ||
523 | content, err = ftp.get(url) | ||
524 | end | ||
525 | if not content then | ||
526 | return false, "Failed downloading: " .. err | ||
510 | end | 527 | end |
511 | local file = io.open(filename, "wb") | 528 | local file = io.open(filename, "wb") |
512 | if not file then return false end | 529 | if not file then return false end |
513 | file:write(res) | 530 | file:write(content) |
514 | file:close() | 531 | file:close() |
515 | return true | 532 | return true |
516 | end | 533 | end |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 7f0a4ea0..39351497 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -300,10 +300,6 @@ function update_manifest(name, version, repo) | |||
300 | return save_table(repo, "manifest", manifest) | 300 | return save_table(repo, "manifest", manifest) |
301 | end | 301 | end |
302 | 302 | ||
303 | local function starts_with(s, prefix) | ||
304 | return s:sub(1,#prefix) == prefix | ||
305 | end | ||
306 | |||
307 | local function find_providers(file, root) | 303 | local function find_providers(file, root) |
308 | assert(type(file) == "string") | 304 | assert(type(file) == "string") |
309 | root = root or cfg.root_dir | 305 | root = root or cfg.root_dir |
@@ -317,13 +313,13 @@ local function find_providers(file, root) | |||
317 | local deploy_lib = path.deploy_lib_dir(root) | 313 | local deploy_lib = path.deploy_lib_dir(root) |
318 | local key, manifest_tbl | 314 | local key, manifest_tbl |
319 | 315 | ||
320 | if starts_with(file, deploy_lua) then | 316 | if util.starts_with(file, deploy_lua) then |
321 | manifest_tbl = manifest.modules | 317 | manifest_tbl = manifest.modules |
322 | key = path.path_to_module(file:sub(#deploy_lua+1):gsub("\\", "/")) | 318 | key = path.path_to_module(file:sub(#deploy_lua+1):gsub("\\", "/")) |
323 | elseif starts_with(file, deploy_lib) then | 319 | elseif util.starts_with(file, deploy_lib) then |
324 | manifest_tbl = manifest.modules | 320 | manifest_tbl = manifest.modules |
325 | key = path.path_to_module(file:sub(#deploy_lib+1):gsub("\\", "/")) | 321 | key = path.path_to_module(file:sub(#deploy_lib+1):gsub("\\", "/")) |
326 | elseif starts_with(file, deploy_bin) then | 322 | elseif util.starts_with(file, deploy_bin) then |
327 | manifest_tbl = manifest.commands | 323 | manifest_tbl = manifest.commands |
328 | key = file:sub(#deploy_bin+1):gsub("^[\\/]*", "") | 324 | key = file:sub(#deploy_bin+1):gsub("^[\\/]*", "") |
329 | else | 325 | else |
diff --git a/src/luarocks/refresh_cache.lua b/src/luarocks/refresh_cache.lua index 5cf87380..92852f2a 100644 --- a/src/luarocks/refresh_cache.lua +++ b/src/luarocks/refresh_cache.lua | |||
@@ -20,8 +20,8 @@ function run(...) | |||
20 | if not server then | 20 | if not server then |
21 | return nil, "No server specified with --from and no default configured with upload_server." | 21 | return nil, "No server specified with --from and no default configured with upload_server." |
22 | end | 22 | end |
23 | if cfg.upload_aliases then | 23 | if cfg.upload_servers and cfg.upload_servers[server] and cfg.upload_servers[server].http then |
24 | server = cfg.upload_aliases[server] or server | 24 | server = "http://"..cfg.upload_servers[server].http |
25 | end | 25 | end |
26 | local ok, err = cache.refresh_local_cache(server, cfg.upload_user, cfg.upload_password) | 26 | local ok, err = cache.refresh_local_cache(server, cfg.upload_user, cfg.upload_password) |
27 | if not ok then | 27 | if not ok then |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index fdf87786..7074e97b 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -239,6 +239,10 @@ function sortedpairs(tbl, sort_function) | |||
239 | return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end) | 239 | return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end) |
240 | end | 240 | end |
241 | 241 | ||
242 | function starts_with(s, prefix) | ||
243 | return s:sub(1,#prefix) == prefix | ||
244 | end | ||
245 | |||
242 | --[[ | 246 | --[[ |
243 | Author: Julio Manuel Fernandez-Diaz | 247 | Author: Julio Manuel Fernandez-Diaz |
244 | Date: January 12, 2007 | 248 | Date: January 12, 2007 |