aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/build/builtin.lua15
-rw-r--r--src/luarocks/cache.lua15
-rw-r--r--src/luarocks/command_line.lua1
-rw-r--r--src/luarocks/fetch.lua2
-rw-r--r--src/luarocks/fs/lua.lua8
-rw-r--r--src/luarocks/help.lua2
-rw-r--r--src/luarocks/loader.lua36
-rw-r--r--src/luarocks/make.lua2
-rw-r--r--src/luarocks/path.lua19
-rw-r--r--test/testing.bat2
-rwxr-xr-xtest/testing.sh2
11 files changed, 49 insertions, 55 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua
index 00fd09ea..afd05954 100644
--- a/src/luarocks/build/builtin.lua
+++ b/src/luarocks/build/builtin.lua
@@ -174,7 +174,7 @@ function builtin.run(rockspec)
174 --TODO EXEWRAPPER 174 --TODO EXEWRAPPER
175 end 175 end
176 176
177 local ok = true 177 local ok, err
178 local built_modules = {} 178 local built_modules = {}
179 local luadir = path.lua_dir(rockspec.name, rockspec.version) 179 local luadir = path.lua_dir(rockspec.name, rockspec.version)
180 local libdir = path.lib_dir(rockspec.name, rockspec.version) 180 local libdir = path.lib_dir(rockspec.name, rockspec.version)
@@ -202,7 +202,7 @@ function builtin.run(rockspec)
202 for name, info in pairs(build.modules) do 202 for name, info in pairs(build.modules) do
203 local moddir = path.module_to_path(name) 203 local moddir = path.module_to_path(name)
204 if type(info) == "string" then 204 if type(info) == "string" then
205 local ext = info:match(".([^.]+)$") 205 local ext = info:match("%.([^.]+)$")
206 if ext == "lua" then 206 if ext == "lua" then
207 local filename = dir.base_name(info) 207 local filename = dir.base_name(info)
208 if info:match("init%.lua$") and not name:match("%.init$") then 208 if info:match("init%.lua$") and not name:match("%.init$") then
@@ -226,7 +226,7 @@ function builtin.run(rockspec)
226 if info[1] then sources = info end 226 if info[1] then sources = info end
227 if type(sources) == "string" then sources = {sources} end 227 if type(sources) == "string" then sources = {sources} end
228 for _, source in ipairs(sources) do 228 for _, source in ipairs(sources) do
229 local object = source:gsub(".[^.]*$", "."..cfg.obj_extension) 229 local object = source:gsub("%.[^.]*$", "."..cfg.obj_extension)
230 if not object then 230 if not object then
231 object = source.."."..cfg.obj_extension 231 object = source.."."..cfg.obj_extension
232 end 232 end
@@ -236,11 +236,10 @@ function builtin.run(rockspec)
236 end 236 end
237 table.insert(objects, object) 237 table.insert(objects, object)
238 end 238 end
239 if not ok then break end
240 local module_name = name:match("([^.]*)$").."."..util.matchquote(cfg.lib_extension) 239 local module_name = name:match("([^.]*)$").."."..util.matchquote(cfg.lib_extension)
241 if moddir ~= "" then 240 if moddir ~= "" then
242 module_name = dir.path(moddir, module_name) 241 module_name = dir.path(moddir, module_name)
243 local ok, err = fs.make_dir(moddir) 242 ok, err = fs.make_dir(moddir)
244 if not ok then return nil, err end 243 if not ok then return nil, err end
245 end 244 end
246 built_modules[module_name] = dir.path(libdir, module_name) 245 built_modules[module_name] = dir.path(libdir, module_name)
@@ -252,13 +251,13 @@ function builtin.run(rockspec)
252 end 251 end
253 for name, dest in pairs(built_modules) do 252 for name, dest in pairs(built_modules) do
254 fs.make_dir(dir.dir_name(dest)) 253 fs.make_dir(dir.dir_name(dest))
255 ok = fs.copy(name, dest) 254 ok, err = fs.copy(name, dest)
256 if not ok then 255 if not ok then
257 return nil, "Failed installing "..name.." in "..dest 256 return nil, "Failed installing "..name.." in "..dest..": "..err
258 end 257 end
259 end 258 end
260 if fs.is_dir("lua") then 259 if fs.is_dir("lua") then
261 local ok, err = fs.copy_contents("lua", luadir) 260 ok, err = fs.copy_contents("lua", luadir)
262 if not ok then 261 if not ok then
263 return nil, "Failed copying contents of 'lua' directory: "..err 262 return nil, "Failed copying contents of 'lua' directory: "..err
264 end 263 end
diff --git a/src/luarocks/cache.lua b/src/luarocks/cache.lua
index dbea8405..fb6344d8 100644
--- a/src/luarocks/cache.lua
+++ b/src/luarocks/cache.lua
@@ -45,25 +45,12 @@ function cache.split_server_url(server, url, user, password)
45 user = credentials 45 user = credentials
46 end 46 end
47 end 47 end
48 local local_cache 48 local local_cache = cfg.local_cache .. "/" .. server
49 if cfg.local_cache then
50 local_cache = cfg.local_cache .. "/" .. server
51 end
52 return local_cache, protocol, server_path, user, password 49 return local_cache, protocol, server_path, user, password
53end 50end
54 51
55function cache.refresh_local_cache(server, url, user, password) 52function cache.refresh_local_cache(server, url, user, password)
56 local local_cache, protocol, server_path, user, password = cache.split_server_url(server, url, user, password) 53 local local_cache, protocol, server_path, user, password = cache.split_server_url(server, url, user, password)
57
58 local ok, err = fs.make_dir(cfg.local_cache)
59 if not ok then return nil, err end
60
61 local tmp_cache = false
62 if not local_cache then
63 local err
64 local_cache, err = fs.make_temp_dir("local_cache")
65 tmp_cache = true
66 end
67 local ok, err = fs.make_dir(local_cache) 54 local ok, err = fs.make_dir(local_cache)
68 if not ok then 55 if not ok then
69 return nil, "Failed creating local cache dir: "..err 56 return nil, "Failed creating local cache dir: "..err
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua
index e1c9f492..a016fc72 100644
--- a/src/luarocks/command_line.lua
+++ b/src/luarocks/command_line.lua
@@ -144,7 +144,6 @@ function command_line.run_command(...)
144 end 144 end
145 end 145 end
146 if not named then 146 if not named then
147 local fs = require("luarocks.fs")
148 local root_dir = fs.absolute_name(flags["tree"]) 147 local root_dir = fs.absolute_name(flags["tree"])
149 replace_tree(flags, args, root_dir) 148 replace_tree(flags, args, root_dir)
150 end 149 end
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua
index e92aeddf..2c028771 100644
--- a/src/luarocks/fetch.lua
+++ b/src/luarocks/fetch.lua
@@ -371,7 +371,7 @@ function fetch.fetch_sources(rockspec, extract, dest_dir)
371 local protocol = rockspec.source.protocol 371 local protocol = rockspec.source.protocol
372 local ok, proto 372 local ok, proto
373 if fetch.is_basic_protocol(protocol) then 373 if fetch.is_basic_protocol(protocol) then
374 proto = require("luarocks.fetch") 374 proto = fetch
375 else 375 else
376 ok, proto = pcall(require, "luarocks.fetch."..protocol:gsub("[+-]", "_")) 376 ok, proto = pcall(require, "luarocks.fetch."..protocol:gsub("[+-]", "_"))
377 if not ok then 377 if not ok then
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua
index a444f014..1d303c67 100644
--- a/src/luarocks/fs/lua.lua
+++ b/src/luarocks/fs/lua.lua
@@ -728,6 +728,14 @@ end
728 728
729if md5_ok then 729if md5_ok then
730 730
731-- Support the interface of lmd5 by lhf in addition to md5 by Roberto
732-- and the keplerproject.
733if not md5.sumhexa and md5.digest then
734 md5.sumhexa = function(msg)
735 return md5.digest(msg)
736 end
737end
738
731--- Get the MD5 checksum for a file. 739--- Get the MD5 checksum for a file.
732-- @param file string: The file to be computed. 740-- @param file string: The file to be computed.
733-- @return string: The MD5 checksum or nil + error 741-- @return string: The MD5 checksum or nil + error
diff --git a/src/luarocks/help.lua b/src/luarocks/help.lua
index 92458b2b..5a2681a3 100644
--- a/src/luarocks/help.lua
+++ b/src/luarocks/help.lua
@@ -111,7 +111,7 @@ function help.run(...)
111 print_section("SEE ALSO") 111 print_section("SEE ALSO")
112 util.printout("","'"..program.." help' for general options and configuration.\n") 112 util.printout("","'"..program.." help' for general options and configuration.\n")
113 else 113 else
114 return nil, "Unknown command '"..command.."'" 114 return nil, "Unknown command: "..command
115 end 115 end
116 end 116 end
117 return true 117 return true
diff --git a/src/luarocks/loader.lua b/src/luarocks/loader.lua
index 1eaa6721..26280e94 100644
--- a/src/luarocks/loader.lua
+++ b/src/luarocks/loader.lua
@@ -6,8 +6,8 @@
6-- used to load previous modules, so that the loader chooses versions 6-- used to load previous modules, so that the loader chooses versions
7-- that are declared to be compatible with the ones loaded earlier. 7-- that are declared to be compatible with the ones loaded earlier.
8local loaders = package.loaders or package.searchers 8local loaders = package.loaders or package.searchers
9local package, require, ipairs, pairs, table, type, next, tostring, error = 9local package, require, ipairs, table, type, next, tostring, error =
10 package, require, ipairs, pairs, table, type, next, tostring, error 10 package, require, ipairs, table, type, next, tostring, error
11local unpack = unpack or table.unpack 11local unpack = unpack or table.unpack
12 12
13--module("luarocks.loader") 13--module("luarocks.loader")
@@ -20,6 +20,7 @@ cfg.init_package_paths()
20local path = require("luarocks.path") 20local path = require("luarocks.path")
21local manif_core = require("luarocks.manif_core") 21local manif_core = require("luarocks.manif_core")
22local deps = require("luarocks.deps") 22local deps = require("luarocks.deps")
23local util = require("luarocks.util")
23 24
24loader.context = {} 25loader.context = {}
25 26
@@ -79,7 +80,7 @@ function loader.add_context(name, version)
79 for _, tree in ipairs(loader.rocks_trees) do 80 for _, tree in ipairs(loader.rocks_trees) do
80 local entries = tree.manifest.repository[pkg] 81 local entries = tree.manifest.repository[pkg]
81 if entries then 82 if entries then
82 for version, pkgs in pairs(entries) do 83 for version, pkgs in util.sortedpairs(entries, deps.compare_versions) do
83 if (not constraints) or deps.match_constraints(deps.parse_version(version), constraints) then 84 if (not constraints) or deps.match_constraints(deps.parse_version(version), constraints) then
84 loader.add_context(pkg, version) 85 loader.add_context(pkg, version)
85 end 86 end
@@ -125,17 +126,17 @@ end
125 126
126--- Search for a module in the rocks trees 127--- Search for a module in the rocks trees
127-- @param module string: module name (eg. "socket.core") 128-- @param module string: module name (eg. "socket.core")
128-- @param filter_module_name function(string, string, string, string, number): 129-- @param filter_file_name function(string, string, string, string, number):
129-- a function that takes the module name (eg "socket.core"), the rock name 130-- a function that takes the module file name (eg "socket/core.so"), the rock name
130-- (eg "luasocket"), the version (eg "2.0.2-1"), the path of the rocks tree 131-- (eg "luasocket"), the version (eg "2.0.2-1"), the path of the rocks tree
131-- (eg "/usr/local"), and the numeric index of the matching entry, so the 132-- (eg "/usr/local"), and the numeric index of the matching entry, so the
132-- filter function can know if the matching module was the first entry or not. 133-- filter function can know if the matching module was the first entry or not.
133-- @return string, string, string, (string or table): 134-- @return string, string, string, (string or table):
134-- * name of the rock containing the module (eg. "luasocket") 135-- * name of the rock containing the module (eg. "luasocket")
135-- * version of the rock (eg. "2.0.2-1") 136-- * version of the rock (eg. "2.0.2-1")
136-- * name of the module (eg. "socket.core", or "socket.core_2_0_2" if file is stored versioned). 137-- * return value of filter_file_name
137-- * tree of the module (string or table in `rocks_trees` format) 138-- * tree of the module (string or table in `rocks_trees` format)
138local function select_module(module, filter_module_name) 139local function select_module(module, filter_file_name)
139 --assert(type(module) == "string") 140 --assert(type(module) == "string")
140 --assert(type(filter_module_name) == "function") 141 --assert(type(filter_module_name) == "function")
141 142
@@ -149,16 +150,16 @@ local function select_module(module, filter_module_name)
149 if entries then 150 if entries then
150 for i, entry in ipairs(entries) do 151 for i, entry in ipairs(entries) do
151 local name, version = entry:match("^([^/]*)/(.*)$") 152 local name, version = entry:match("^([^/]*)/(.*)$")
152 local module_name = tree.manifest.repository[name][version][1].modules[module] 153 local file_name = tree.manifest.repository[name][version][1].modules[module]
153 if type(module_name) ~= "string" then 154 if type(file_name) ~= "string" then
154 error("Invalid data in manifest file for module "..tostring(module).." (invalid data for "..tostring(name).." "..tostring(version)..")") 155 error("Invalid data in manifest file for module "..tostring(module).." (invalid data for "..tostring(name).." "..tostring(version)..")")
155 end 156 end
156 module_name = filter_module_name(module_name, name, version, tree.tree, i) 157 file_name = filter_file_name(file_name, name, version, tree.tree, i)
157 if loader.context[name] == version then 158 if loader.context[name] == version then
158 return name, version, module_name 159 return name, version, file_name
159 end 160 end
160 version = deps.parse_version(version) 161 version = deps.parse_version(version)
161 table.insert(providers, {name = name, version = version, module_name = module_name, tree = tree}) 162 table.insert(providers, {name = name, version = version, module_name = file_name, tree = tree})
162 end 163 end
163 end 164 end
164 end 165 end
@@ -179,12 +180,11 @@ end
179-- * tree of the module (string or table in `rocks_trees` format) 180-- * tree of the module (string or table in `rocks_trees` format)
180local function pick_module(module) 181local function pick_module(module)
181 return 182 return
182 select_module(module, function(module_name, name, version, tree, i) 183 select_module(module, function(file_name, name, version, tree, i)
183 if i > 1 then 184 if i > 1 then
184 module_name = path.versioned_name(module_name, "", name, version) 185 file_name = path.versioned_name(file_name, "", name, version)
185 end 186 end
186 module_name = path.path_to_module(module_name) 187 return path.path_to_module(file_name)
187 return module_name
188 end) 188 end)
189end 189end
190 190
@@ -192,8 +192,8 @@ end
192-- @param module string: module name (eg. "socket.core") 192-- @param module string: module name (eg. "socket.core")
193-- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so") 193-- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so")
194function loader.which(module) 194function loader.which(module)
195 local name, version, module_name = select_module(module, path.which_i) 195 local _, _, file_name = select_module(module, path.which_i)
196 return module_name 196 return file_name
197end 197end
198 198
199--- Package loader for LuaRocks support. 199--- Package loader for LuaRocks support.
diff --git a/src/luarocks/make.lua b/src/luarocks/make.lua
index 1dfe6473..4f70bafe 100644
--- a/src/luarocks/make.lua
+++ b/src/luarocks/make.lua
@@ -54,7 +54,7 @@ function make.run(...)
54 54
55 if not rockspec then 55 if not rockspec then
56 for file in fs.dir() do 56 for file in fs.dir() do
57 if file:match("rockspec$") then 57 if file:match("rockspec$") and fs.is_file(file) then
58 if rockspec then 58 if rockspec then
59 return nil, "Please specify which rockspec file to use." 59 return nil, "Please specify which rockspec file to use."
60 else 60 else
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua
index fb5eec7e..bc7ab63b 100644
--- a/src/luarocks/path.lua
+++ b/src/luarocks/path.lua
@@ -342,44 +342,45 @@ end
342local is_src_extension = { [".lua"] = true, [".tl"] = true, [".tld"] = true, [".moon"] = true } 342local is_src_extension = { [".lua"] = true, [".tl"] = true, [".tld"] = true, [".moon"] = true }
343 343
344--- Return the pathname of the file that would be loaded for a module, indexed. 344--- Return the pathname of the file that would be loaded for a module, indexed.
345-- @param module_name string: module name (eg. "socket.core") 345-- @param file_name string: module file name as in manifest (eg. "socket/core.so")
346-- @param name string: name of the package (eg. "luasocket") 346-- @param name string: name of the package (eg. "luasocket")
347-- @param version string: version number (eg. "2.0.2-1") 347-- @param version string: version number (eg. "2.0.2-1")
348-- @param tree string: repository path (eg. "/usr/local") 348-- @param tree string: repository path (eg. "/usr/local")
349-- @param i number: the index, 1 if version is the current default, > 1 otherwise. 349-- @param i number: the index, 1 if version is the current default, > 1 otherwise.
350-- This is done this way for use by select_module in luarocks.loader. 350-- This is done this way for use by select_module in luarocks.loader.
351-- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so") 351-- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so")
352function path.which_i(module_name, name, version, tree, i) 352function path.which_i(file_name, name, version, tree, i)
353 local deploy_dir 353 local deploy_dir
354 local extension = module_name:match("%.[a-z]+$") 354 local extension = file_name:match("%.[a-z]+$")
355 if is_src_extension[extension] then 355 if is_src_extension[extension] then
356 deploy_dir = path.deploy_lua_dir(tree) 356 deploy_dir = path.deploy_lua_dir(tree)
357 module_name = dir.path(deploy_dir, module_name) 357 file_name = dir.path(deploy_dir, file_name)
358 else 358 else
359 deploy_dir = path.deploy_lib_dir(tree) 359 deploy_dir = path.deploy_lib_dir(tree)
360 module_name = dir.path(deploy_dir, module_name) 360 file_name = dir.path(deploy_dir, file_name)
361 end 361 end
362 if i > 1 then 362 if i > 1 then
363 module_name = path.versioned_name(module_name, deploy_dir, name, version) 363 file_name = path.versioned_name(file_name, deploy_dir, name, version)
364 end 364 end
365 return module_name 365 return file_name
366end 366end
367 367
368--- Return the pathname of the file that would be loaded for a module, 368--- Return the pathname of the file that would be loaded for a module,
369-- returning the versioned pathname if given version is not the default version 369-- returning the versioned pathname if given version is not the default version
370-- in the given manifest. 370-- in the given manifest.
371-- @param module_name string: module name (eg. "socket.core") 371-- @param module_name string: module name (eg. "socket.core")
372-- @param file_name string: module file name as in manifest (eg. "socket/core.so")
372-- @param name string: name of the package (eg. "luasocket") 373-- @param name string: name of the package (eg. "luasocket")
373-- @param version string: version number (eg. "2.0.2-1") 374-- @param version string: version number (eg. "2.0.2-1")
374-- @param tree string: repository path (eg. "/usr/local") 375-- @param tree string: repository path (eg. "/usr/local")
375-- @param manifest table: the manifest table for the tree. 376-- @param manifest table: the manifest table for the tree.
376-- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so") 377-- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so")
377function path.which(module_name, filename, name, version, tree, manifest) 378function path.which(module_name, file_name, name, version, tree, manifest)
378 local versions = manifest.modules[module_name] 379 local versions = manifest.modules[module_name]
379 assert(versions) 380 assert(versions)
380 for i, name_version in ipairs(versions) do 381 for i, name_version in ipairs(versions) do
381 if name_version == name.."/"..version then 382 if name_version == name.."/"..version then
382 return path.which_i(filename, name, version, tree, i):gsub("//", "/") 383 return path.which_i(file_name, name, version, tree, i):gsub("//", "/")
383 end 384 end
384 end 385 end
385 assert(false) 386 assert(false)
diff --git a/test/testing.bat b/test/testing.bat
index 319e12c3..7083678b 100644
--- a/test/testing.bat
+++ b/test/testing.bat
@@ -1,7 +1,7 @@
1@echo off 1@echo off
2Setlocal EnableDelayedExpansion EnableExtensions 2Setlocal EnableDelayedExpansion EnableExtensions
3 3
4if not defined LUAROCKS_REPO set LUAROCKS_REPO=http://rocks.moonscript.org 4if not defined LUAROCKS_REPO set LUAROCKS_REPO=https://luarocks.org
5 5
6appveyor DownloadFile %LUAROCKS_REPO%/stdlib-41.0.0-1.src.rock 6appveyor DownloadFile %LUAROCKS_REPO%/stdlib-41.0.0-1.src.rock
7luarocks build stdlib 7luarocks build stdlib
diff --git a/test/testing.sh b/test/testing.sh
index dc7912bf..44e78205 100755
--- a/test/testing.sh
+++ b/test/testing.sh
@@ -225,7 +225,7 @@ luarocks_admin_nocov="run_lua --nocov luarocks-admin"
225mkdir -p "$testing_server" 225mkdir -p "$testing_server"
226( 226(
227 cd "$testing_server" 227 cd "$testing_server"
228 luarocks_repo="http://rocks.moonscript.org" 228 luarocks_repo="https://luarocks.org"
229 get() { [ -e `basename "$1"` ] || wget -c "$1"; } 229 get() { [ -e `basename "$1"` ] || wget -c "$1"; }
230 get "$luarocks_repo/luacov-${verrev_luacov}.src.rock" 230 get "$luarocks_repo/luacov-${verrev_luacov}.src.rock"
231 get "$luarocks_repo/luacov-${verrev_luacov}.rockspec" 231 get "$luarocks_repo/luacov-${verrev_luacov}.rockspec"