aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/cfg.lua6
-rw-r--r--src/luarocks/deps.lua22
-rw-r--r--src/luarocks/fetch.lua5
3 files changed, 22 insertions, 11 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 3b7f9c37..a4f60f55 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -371,7 +371,8 @@ local defaults = {
371 include = "include" 371 include = "include"
372 }, 372 },
373 373
374 rocks_provided = {} 374 rocks_provided = {},
375 rocks_provided_3_0 = {},
375} 376}
376 377
377if cfg.platforms.windows then 378if cfg.platforms.windows then
@@ -575,8 +576,8 @@ end
575if package.loaded.jit then 576if package.loaded.jit then
576 -- LuaJIT 577 -- LuaJIT
577 local lj_version = package.loaded.jit.version:match("LuaJIT (.*)"):gsub("%-","") 578 local lj_version = package.loaded.jit.version:match("LuaJIT (.*)"):gsub("%-","")
578 --defaults.rocks_provided["luajit"] = lj_version.."-1"
579 defaults.rocks_provided["luabitop"] = lj_version.."-1" 579 defaults.rocks_provided["luabitop"] = lj_version.."-1"
580 defaults.rocks_provided_3_0["luajit"] = lj_version.."-1"
580end 581end
581 582
582-- Use defaults: 583-- Use defaults:
@@ -593,6 +594,7 @@ for _, entry in ipairs({"variables", "rocks_provided"}) do
593 end 594 end
594 end 595 end
595end 596end
597setmetatable(defaults.rocks_provided_3_0, { __index = cfg.rocks_provided })
596 598
597-- For values not set in the config file, use values from the 'defaults' table. 599-- For values not set in the config file, use values from the 'defaults' table.
598local cfg_mt = { 600local cfg_mt = {
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
index f6c86d1c..3f7eb4d2 100644
--- a/src/luarocks/deps.lua
+++ b/src/luarocks/deps.lua
@@ -327,16 +327,20 @@ end
327-- @param dep table: A dependency parsed in table format. 327-- @param dep table: A dependency parsed in table format.
328-- @param blacklist table: Versions that can't be accepted. Table where keys 328-- @param blacklist table: Versions that can't be accepted. Table where keys
329-- are program versions and values are 'true'. 329-- are program versions and values are 'true'.
330-- @param provided table: A table of auto-dependencies provided
331-- by this Lua implementation for the given dependency.
330-- @return table or nil: A table containing fields 'name' and 'version' 332-- @return table or nil: A table containing fields 'name' and 'version'
331-- representing an installed rock which matches the given dependency, 333-- representing an installed rock which matches the given dependency,
332-- or nil if it could not be matched. 334-- or nil if it could not be matched.
333local function match_dep(dep, blacklist, deps_mode) 335local function match_dep(dep, blacklist, deps_mode, rocks_provided)
334 assert(type(dep) == "table") 336 assert(type(dep) == "table")
335 337 assert(type(rocks_provided) == "table")
336 local versions = cfg.rocks_provided[dep.name] 338
337 if cfg.rocks_provided[dep.name] then 339 local versions
340 local provided = rocks_provided[dep.name]
341 if provided then
338 -- provided rocks have higher priority than manifest's rocks 342 -- provided rocks have higher priority than manifest's rocks
339 versions = { cfg.rocks_provided[dep.name] } 343 versions = { provided }
340 else 344 else
341 versions = manif_core.get_versions(dep.name, deps_mode) 345 versions = manif_core.get_versions(dep.name, deps_mode)
342 end 346 end
@@ -388,9 +392,9 @@ function deps.match_deps(rockspec, blacklist, deps_mode)
388 local matched, missing, no_upgrade = {}, {}, {} 392 local matched, missing, no_upgrade = {}, {}, {}
389 393
390 for _, dep in ipairs(rockspec.dependencies) do 394 for _, dep in ipairs(rockspec.dependencies) do
391 local found = match_dep(dep, blacklist and blacklist[dep.name] or nil, deps_mode) 395 local found = match_dep(dep, blacklist and blacklist[dep.name] or nil, deps_mode, rockspec.rocks_provided)
392 if found then 396 if found then
393 if not cfg.rocks_provided[dep.name] then 397 if not rockspec.rocks_provided[dep.name] then
394 matched[dep] = found 398 matched[dep] = found
395 end 399 end
396 else 400 else
@@ -488,7 +492,7 @@ function deps.fulfill_dependencies(rockspec, deps_mode)
488 492
489 for _, dep in pairs(missing) do 493 for _, dep in pairs(missing) do
490 -- Double-check in case dependency was filled during recursion. 494 -- Double-check in case dependency was filled during recursion.
491 if not match_dep(dep, nil, deps_mode) then 495 if not match_dep(dep, nil, deps_mode, rockspec.rocks_provided) then
492 local rock = search.find_suitable_rock(dep) 496 local rock = search.find_suitable_rock(dep)
493 if not rock then 497 if not rock then
494 return nil, "Could not satisfy dependency: "..deps.show_dep(dep) 498 return nil, "Could not satisfy dependency: "..deps.show_dep(dep)
@@ -708,7 +712,7 @@ function deps.scan_deps(results, missing, manifest, name, version, deps_mode)
708 end 712 end
709 dependencies_name[version] = rockspec.dependencies 713 dependencies_name[version] = rockspec.dependencies
710 else 714 else
711 rockspec = { dependencies = deplist } 715 rockspec = { dependencies = deplist, rocks_provided = {} }
712 end 716 end
713 local matched, failures = deps.match_deps(rockspec, nil, deps_mode) 717 local matched, failures = deps.match_deps(rockspec, nil, deps_mode)
714 results[name] = results 718 results[name] = results
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua
index 5ae05826..e1cad11b 100644
--- a/src/luarocks/fetch.lua
+++ b/src/luarocks/fetch.lua
@@ -252,6 +252,11 @@ function fetch.load_local_rockspec(filename, quick)
252 and (fetch.is_basic_protocol(protocol) and "." or base) 252 and (fetch.is_basic_protocol(protocol) and "." or base)
253 or ".") ) 253 or ".") )
254 or base 254 or base
255
256 rockspec.rocks_provided = (deps.format_is_at_least(rockspec, "3.0")
257 and cfg.rocks_provided_3_0
258 or cfg.rocks_provided)
259
255 if rockspec.dependencies then 260 if rockspec.dependencies then
256 for i = 1, #rockspec.dependencies do 261 for i = 1, #rockspec.dependencies do
257 local parsed, err = deps.parse_dep(rockspec.dependencies[i]) 262 local parsed, err = deps.parse_dep(rockspec.dependencies[i])