diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/build/builtin.lua | 12 | ||||
-rw-r--r-- | src/luarocks/cfg.lua | 35 | ||||
-rw-r--r-- | src/luarocks/deps.lua | 34 | ||||
-rw-r--r-- | src/luarocks/loader.lua | 6 | ||||
-rw-r--r-- | src/luarocks/search.lua | 12 |
5 files changed, 65 insertions, 34 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 427ab7c9..f9ef4c44 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
@@ -112,9 +112,15 @@ function run(rockspec) | |||
112 | def:write("luaopen_"..name:gsub("%.", "_").."\n") | 112 | def:write("luaopen_"..name:gsub("%.", "_").."\n") |
113 | def:close() | 113 | def:close() |
114 | local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras)) | 114 | local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras)) |
115 | local manifestfile = basename..".dll.manifest" | 115 | local basedir = "" |
116 | if name:find("%.") ~= nil then | ||
117 | basedir = name:gsub("%.%w+$", "\\") | ||
118 | basedir = basedir:gsub("%.", "\\") | ||
119 | end | ||
120 | local manifestfile = basedir .. basename..".dll.manifest" | ||
121 | |||
116 | if ok and fs.exists(manifestfile) then | 122 | if ok and fs.exists(manifestfile) then |
117 | ok = execute(variables.MT, "-manifest", manifestfile, "-outputresource:"..basename..".dll;2") | 123 | ok = execute(variables.MT, "-manifest", manifestfile, "-outputresource:"..basedir..basename..".dll;2") |
118 | end | 124 | end |
119 | return ok | 125 | return ok |
120 | end | 126 | end |
@@ -250,7 +256,7 @@ function run(rockspec) | |||
250 | end | 256 | end |
251 | if fs.is_dir("lua") then | 257 | if fs.is_dir("lua") then |
252 | local ok, err = fs.copy_contents("lua", luadir) | 258 | local ok, err = fs.copy_contents("lua", luadir) |
253 | if not ok then | 259 | if not ok then |
254 | return nil, "Failed copying contents of 'lua' directory: "..err | 260 | return nil, "Failed copying contents of 'lua' directory: "..err |
255 | end | 261 | end |
256 | end | 262 | end |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 3a5294f5..2904146b 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -265,6 +265,8 @@ local defaults = { | |||
265 | lib = "lib", | 265 | lib = "lib", |
266 | include = "include" | 266 | include = "include" |
267 | }, | 267 | }, |
268 | |||
269 | rocks_provided = {} | ||
268 | } | 270 | } |
269 | 271 | ||
270 | if detected.windows then | 272 | if detected.windows then |
@@ -453,16 +455,33 @@ defaults.variables.OBJ_EXTENSION = defaults.obj_extension | |||
453 | defaults.variables.LUAROCKS_PREFIX = site_config.LUAROCKS_PREFIX | 455 | defaults.variables.LUAROCKS_PREFIX = site_config.LUAROCKS_PREFIX |
454 | defaults.variables.LUA = site_config.LUA_DIR_SET and (defaults.variables.LUA_BINDIR.."/"..defaults.lua_interpreter) or defaults.lua_interpreter | 456 | defaults.variables.LUA = site_config.LUA_DIR_SET and (defaults.variables.LUA_BINDIR.."/"..defaults.lua_interpreter) or defaults.lua_interpreter |
455 | 457 | ||
456 | -- Use defaults: | 458 | -- Add built-in modules to rocks_provided |
459 | defaults.rocks_provided["lua"] = lua_version.."-1" | ||
457 | 460 | ||
458 | -- Populate values from 'defaults.variables' in 'variables' if they were not | 461 | if lua_version >= "5.2" then |
459 | -- already set by user. | 462 | -- Lua 5.2+ |
460 | if not _M.variables then | 463 | defaults.rocks_provided["bit32"] = lua_version.."-1" |
461 | _M.variables = {} | ||
462 | end | 464 | end |
463 | for k,v in pairs(defaults.variables) do | 465 | |
464 | if not _M.variables[k] then | 466 | if package.loaded.jit then |
465 | _M.variables[k] = v | 467 | -- LuaJIT |
468 | local lj_version = package.loaded.jit.version:match("LuaJIT (.*)"):gsub("%-","") | ||
469 | --defaults.rocks_provided["luajit"] = lj_version.."-1" | ||
470 | defaults.rocks_provided["luabitop"] = lj_version.."-1" | ||
471 | end | ||
472 | |||
473 | -- Use defaults: | ||
474 | |||
475 | -- Populate some arrays with values from their 'defaults' counterparts | ||
476 | -- if they were not already set by user. | ||
477 | for _, entry in ipairs({"variables", "rocks_provided"}) do | ||
478 | if not _M[entry] then | ||
479 | _M[entry] = {} | ||
480 | end | ||
481 | for k,v in pairs(defaults[entry]) do | ||
482 | if not _M[entry][k] then | ||
483 | _M[entry][k] = v | ||
484 | end | ||
466 | end | 485 | end |
467 | end | 486 | end |
468 | 487 | ||
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 0c6bb8d5..116b4bbb 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -323,9 +323,10 @@ end | |||
323 | local function match_dep(dep, blacklist, deps_mode) | 323 | local function match_dep(dep, blacklist, deps_mode) |
324 | assert(type(dep) == "table") | 324 | assert(type(dep) == "table") |
325 | 325 | ||
326 | local versions | 326 | local versions = cfg.rocks_provided[dep.name] |
327 | if dep.name == "lua" then | 327 | if cfg.rocks_provided[dep.name] then |
328 | versions = { cfg.lua_version } | 328 | -- provided rocks have higher priority than manifest's rocks |
329 | versions = { cfg.rocks_provided[dep.name] } | ||
329 | else | 330 | else |
330 | versions = manif_core.get_versions(dep.name, deps_mode) | 331 | versions = manif_core.get_versions(dep.name, deps_mode) |
331 | end | 332 | end |
@@ -360,17 +361,12 @@ local function match_dep(dep, blacklist, deps_mode) | |||
360 | end | 361 | end |
361 | end | 362 | end |
362 | 363 | ||
363 | local whitelist = {} | ||
364 | if cfg.lua_version == "5.2" then | ||
365 | whitelist["bit32"] = true | ||
366 | end | ||
367 | |||
368 | --- Attempt to match dependencies of a rockspec to installed rocks. | 364 | --- Attempt to match dependencies of a rockspec to installed rocks. |
369 | -- @param rockspec table: The rockspec loaded as a table. | 365 | -- @param rockspec table: The rockspec loaded as a table. |
370 | -- @param blacklist table or nil: Program versions to not use as valid matches. | 366 | -- @param blacklist table or nil: Program versions to not use as valid matches. |
371 | -- Table where keys are program names and values are tables where keys | 367 | -- Table where keys are program names and values are tables where keys |
372 | -- are program versions and values are 'true'. | 368 | -- are program versions and values are 'true'. |
373 | -- @return table, table: A table where keys are dependencies parsed | 369 | -- @return table, table, table: A table where keys are dependencies parsed |
374 | -- in table format and values are tables containing fields 'name' and | 370 | -- in table format and values are tables containing fields 'name' and |
375 | -- version' representing matches; a table of missing dependencies | 371 | -- version' representing matches; a table of missing dependencies |
376 | -- parsed as tables; and a table of "no-upgrade" missing dependencies | 372 | -- parsed as tables; and a table of "no-upgrade" missing dependencies |
@@ -382,18 +378,16 @@ function match_deps(rockspec, blacklist, deps_mode) | |||
382 | local matched, missing, no_upgrade = {}, {}, {} | 378 | local matched, missing, no_upgrade = {}, {}, {} |
383 | 379 | ||
384 | for _, dep in ipairs(rockspec.dependencies) do | 380 | for _, dep in ipairs(rockspec.dependencies) do |
385 | if not whitelist[dep.name] then | 381 | local found = match_dep(dep, blacklist and blacklist[dep.name] or nil, deps_mode) |
386 | local found = match_dep(dep, blacklist and blacklist[dep.name] or nil, deps_mode) | 382 | if found then |
387 | if found then | 383 | if not cfg.rocks_provided[dep.name] then |
388 | if dep.name ~= "lua" then | 384 | matched[dep] = found |
389 | matched[dep] = found | 385 | end |
390 | end | 386 | else |
387 | if dep.constraints[1] and dep.constraints[1].no_upgrade then | ||
388 | no_upgrade[dep.name] = dep | ||
391 | else | 389 | else |
392 | if dep.constraints[1] and dep.constraints[1].no_upgrade then | 390 | missing[dep.name] = dep |
393 | no_upgrade[dep.name] = dep | ||
394 | else | ||
395 | missing[dep.name] = dep | ||
396 | end | ||
397 | end | 391 | end |
398 | end | 392 | end |
399 | end | 393 | end |
diff --git a/src/luarocks/loader.lua b/src/luarocks/loader.lua index aa3b2781..d828a359 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. |
8 | local global_env = _G | 8 | local global_env = _G |
9 | local package, require, ipairs, pairs, table, type, next, unpack = | 9 | local package, require, ipairs, pairs, table, type, next, unpack, tostring, error = |
10 | package, require, ipairs, pairs, table, type, next, unpack | 10 | package, require, ipairs, pairs, table, type, next, unpack, tostring, error |
11 | 11 | ||
12 | module("luarocks.loader") | 12 | module("luarocks.loader") |
13 | 13 | ||
@@ -146,7 +146,7 @@ local function select_module(module, filter_module_name) | |||
146 | local name, version = entry:match("^([^/]*)/(.*)$") | 146 | local name, version = entry:match("^([^/]*)/(.*)$") |
147 | local module_name = tree.manifest.repository[name][version][1].modules[module] | 147 | local module_name = tree.manifest.repository[name][version][1].modules[module] |
148 | if type(module_name) ~= "string" then | 148 | if type(module_name) ~= "string" then |
149 | error("Invalid format in manifest file (invalid data for "..tostring(name).." "..tostring(version)..")") | 149 | error("Invalid data in manifest file for module "..tostring(module).." (invalid data for "..tostring(name).." "..tostring(version)..")") |
150 | end | 150 | end |
151 | module_name = filter_module_name(module_name, name, version, tree.tree, i) | 151 | module_name = filter_module_name(module_name, name, version, tree.tree, i) |
152 | if context[name] == version then | 152 | if context[name] == version then |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index 1fc1f9a1..356e06e8 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -209,6 +209,12 @@ function search_repos(query) | |||
209 | end | 209 | end |
210 | end | 210 | end |
211 | end | 211 | end |
212 | -- search through rocks in cfg.rocks_provided | ||
213 | local provided_repo = "provided by VM or rocks_provided" | ||
214 | local name, versions | ||
215 | for name, versions in pairs(cfg.rocks_provided) do | ||
216 | store_if_match(results, provided_repo, name, versions, "installed", query) | ||
217 | end | ||
212 | return results | 218 | return results |
213 | end | 219 | end |
214 | 220 | ||
@@ -273,6 +279,12 @@ function find_suitable_rock(query) | |||
273 | if not first then | 279 | if not first then |
274 | return nil, "No results matching query were found." | 280 | return nil, "No results matching query were found." |
275 | elseif not next(results, first) then | 281 | elseif not next(results, first) then |
282 | if cfg.rocks_provided[query.name] ~= nil then | ||
283 | -- do not install versions that listed in cfg.rocks_provided | ||
284 | return nil, "Rock "..query.name.. | ||
285 | " "..cfg.rocks_provided[query.name].. | ||
286 | " was found but it is provided by VM or 'rocks_provided' in the config file." | ||
287 | end | ||
276 | return pick_latest_version(query.name, results[first]) | 288 | return pick_latest_version(query.name, results[first]) |
277 | else | 289 | else |
278 | return results | 290 | return results |