From ebda93002751a729e9e6f24ac22c3a2ff5e6b09a Mon Sep 17 00:00:00 2001 From: Fabio Mascarenhas Date: Sat, 20 Mar 2010 15:05:42 -0300 Subject: synchronizing with the svn repo --- src/luarocks/add.lua | 3 --- src/luarocks/build/builtin.lua | 19 +++++++++++++++---- src/luarocks/fs/lua.lua | 27 ++++++++++++++++++++++----- src/luarocks/manif.lua | 10 +++------- src/luarocks/refresh_cache.lua | 4 ++-- 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(...) if not server then return nil, "No server specified with --to and no default configured with upload_server." end - if cfg.upload_aliases then - server = cfg.upload_aliases[server] or server - end return add_file_to_server(not flags["no-refresh"], file, server, cfg.upload_servers and cfg.upload_servers[server]) end 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) end local ok = true + local err = "Build error" local built_modules = {} local luadir = path.lua_dir(rockspec.name, rockspec.version) local libdir = path.lib_dir(rockspec.name, rockspec.version) @@ -219,7 +220,10 @@ function run(rockspec) object = source.."."..cfg.obj_extension end ok = compile_object(object, source, info.defines, info.incdirs) - if not ok then break end + if not ok then + err = "Failed compiling object "..object + break + end table.insert(objects, object) end if not ok then break end @@ -230,22 +234,29 @@ function run(rockspec) local dest = dir.path(libdir, moddir) built_modules[module_name] = dest ok = compile_library(module_name, objects, info.libraries, info.libdirs, name) - if not ok then break end + if not ok then + err = "Failed compiling module "..module_name + break + end end end for name, dest in pairs(built_modules) do fs.make_dir(dest) ok = fs.copy(name, dest) - if not ok then break end + if not ok then + err = "Failed installing "..name.." in "..dest + break + end end if ok then if fs.is_dir("lua") then ok = fs.copy_contents("lua", luadir) + if not ok then err = "Failed copying contents of 'lua' directory." end end end if ok then return true else - return nil, "Build error" + return nil, err end 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") local cfg = require("luarocks.cfg") local dir = require("luarocks.dir") +local util = require("luarocks.util") local socket_ok, http = pcall(require, "socket.http") +local _, ftp = pcall(require, "socket.ftp") local zip_ok, lrzip = pcall(require, "luarocks.tools.zip") local unzip_ok, luazip = pcall(require, "zip"); _G.zip = nil local lfs_ok, lfs = pcall(require, "lfs") @@ -178,6 +180,10 @@ function make_dir(directory) if directory:sub(2, 2) == ":" then path = directory:sub(1, 2) directory = directory:sub(4) + else + if directory:match("^/") then + path = "" + end end for d in directory:gmatch("([^"..dir.separator.."]+)"..dir.separator.."*") do path = path and path .. dir.separator .. d or d @@ -503,14 +509,25 @@ function download(url, filename) filename = dir.path(fs.current_dir(), filename or dir.base_name(url)) - local res, status, headers, line = http.request(url) - if not res then return false, status end - if status ~= 200 then - return false, "Failed downloading: " .. line + local content, err + if util.starts_with(url, "http:") then + local res, status, headers, line = http.request(url) + if not res then + err = status + elseif status ~= 200 then + err = line + else + content = res + end + elseif util.starts_with(url, "ftp:") then + content, err = ftp.get(url) + end + if not content then + return false, "Failed downloading: " .. err end local file = io.open(filename, "wb") if not file then return false end - file:write(res) + file:write(content) file:close() return true 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) return save_table(repo, "manifest", manifest) end -local function starts_with(s, prefix) - return s:sub(1,#prefix) == prefix -end - local function find_providers(file, root) assert(type(file) == "string") root = root or cfg.root_dir @@ -317,13 +313,13 @@ local function find_providers(file, root) local deploy_lib = path.deploy_lib_dir(root) local key, manifest_tbl - if starts_with(file, deploy_lua) then + if util.starts_with(file, deploy_lua) then manifest_tbl = manifest.modules key = path.path_to_module(file:sub(#deploy_lua+1):gsub("\\", "/")) - elseif starts_with(file, deploy_lib) then + elseif util.starts_with(file, deploy_lib) then manifest_tbl = manifest.modules key = path.path_to_module(file:sub(#deploy_lib+1):gsub("\\", "/")) - elseif starts_with(file, deploy_bin) then + elseif util.starts_with(file, deploy_bin) then manifest_tbl = manifest.commands key = file:sub(#deploy_bin+1):gsub("^[\\/]*", "") 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(...) if not server then return nil, "No server specified with --from and no default configured with upload_server." end - if cfg.upload_aliases then - server = cfg.upload_aliases[server] or server + if cfg.upload_servers and cfg.upload_servers[server] and cfg.upload_servers[server].http then + server = "http://"..cfg.upload_servers[server].http end local ok, err = cache.refresh_local_cache(server, cfg.upload_user, cfg.upload_password) 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) return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end) end +function starts_with(s, prefix) + return s:sub(1,#prefix) == prefix +end + --[[ Author: Julio Manuel Fernandez-Diaz Date: January 12, 2007 -- cgit v1.2.3-55-g6feb