aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-10-19 18:46:21 -0200
committerHisham Muhammad <hisham@gobolinux.org>2015-10-19 18:46:45 -0200
commitf8179800d0eccaef960442a7e65b1e305f3a96d5 (patch)
treea16878df7e9f602ae58baae7ba08c003e0672798
parent24049bffb8069ceff1a4e0f4367389c531188fef (diff)
downloadluarocks-f8179800d0eccaef960442a7e65b1e305f3a96d5.tar.gz
luarocks-f8179800d0eccaef960442a7e65b1e305f3a96d5.tar.bz2
luarocks-f8179800d0eccaef960442a7e65b1e305f3a96d5.zip
Support "luajit" as a provided dependency in rockspec format 3.0
-rw-r--r--src/luarocks/cfg.lua6
-rw-r--r--src/luarocks/deps.lua22
-rw-r--r--src/luarocks/fetch.lua5
-rw-r--r--test/testfiles/luajit-fail-1.0-1.rockspec22
-rw-r--r--test/testfiles/luajit-success-1.0-1.rockspec23
-rwxr-xr-xtest/testing.sh8
6 files changed, 75 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])
diff --git a/test/testfiles/luajit-fail-1.0-1.rockspec b/test/testfiles/luajit-fail-1.0-1.rockspec
new file mode 100644
index 00000000..f8204600
--- /dev/null
+++ b/test/testfiles/luajit-fail-1.0-1.rockspec
@@ -0,0 +1,22 @@
1package = "luajit-fail"
2version = "1.0-1"
3source = {
4 url = "https://raw.githubusercontent.com/keplerproject/luarocks/master/test/testing.lua",
5}
6description = {
7 summary = "Test luajit dependency fail",
8 detailed = [[
9Fail luajit dependency when running with rockspec_format < 3.0.
10]],
11 homepage = "http://luarocks.org/",
12 license = "MIT/X license"
13}
14dependencies = {
15 "luajit >= 2.0"
16}
17build = {
18 type = "builtin",
19 modules = {
20 testing = "testing.lua"
21 }
22}
diff --git a/test/testfiles/luajit-success-1.0-1.rockspec b/test/testfiles/luajit-success-1.0-1.rockspec
new file mode 100644
index 00000000..31c930c3
--- /dev/null
+++ b/test/testfiles/luajit-success-1.0-1.rockspec
@@ -0,0 +1,23 @@
1rockspec_format = "3.0"
2package = "luajit-success"
3version = "1.0-1"
4source = {
5 url = "https://raw.githubusercontent.com/keplerproject/luarocks/master/test/testing.lua",
6}
7description = {
8 summary = "Test luajit dependency fail",
9 detailed = [[
10Use luajit dependency when running with rockspec_format >= 3.0.
11]],
12 homepage = "http://luarocks.org/",
13 license = "MIT/X license"
14}
15dependencies = {
16 "luajit >= 2.0"
17}
18build = {
19 type = "builtin",
20 modules = {
21 testing = "testing.lua"
22 }
23}
diff --git a/test/testing.sh b/test/testing.sh
index 7292c75d..5ae6bb35 100755
--- a/test/testing.sh
+++ b/test/testing.sh
@@ -224,6 +224,7 @@ luarocks_noecho="run_lua --noecho luarocks"
224luarocks_noecho_nocov="run_lua --noecho --nocov luarocks" 224luarocks_noecho_nocov="run_lua --noecho --nocov luarocks"
225luarocks_admin="run_lua luarocks-admin" 225luarocks_admin="run_lua luarocks-admin"
226luarocks_admin_nocov="run_lua --nocov luarocks-admin" 226luarocks_admin_nocov="run_lua --nocov luarocks-admin"
227luajit_luarocks="luajit -e require('luacov.runner')('$testing_dir/luacov.config') $basedir/bin/luarocks"
227 228
228################################################### 229###################################################
229 230
@@ -524,6 +525,13 @@ test_fetch_base_dir() { $lua <<EOF
524EOF 525EOF
525} 526}
526 527
528test_luajit_dependency() {
529 $luajit_luarocks build "$testing_dir/testfiles/luajit-success-1.0-1.rockspec"
530}
531fail_luajit_dependency() {
532 $luajit_luarocks build "$testing_dir/testfiles/luajit-fail-1.0-1.rockspec"
533}
534
527test_doc() { $luarocks install luarepl; $luarocks doc luarepl; } 535test_doc() { $luarocks install luarepl; $luarocks doc luarepl; }
528 536
529# Driver ######################################### 537# Driver #########################################