aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-12-05 14:08:39 -0200
committerHisham Muhammad <hisham@gobolinux.org>2015-12-05 14:08:39 -0200
commit0b4741a2622a08c6ec6baa099cd1bd3de5c8139b (patch)
tree8d03ba6d145bc86868a2077dd3cc3541fb611d5a
parent90d0b9caaba831a5d88a74bca736afa233f49f2c (diff)
parentf59f8719eb6c462ad332190c3750f5f209d028b8 (diff)
downloadluarocks-0b4741a2622a08c6ec6baa099cd1bd3de5c8139b.tar.gz
luarocks-0b4741a2622a08c6ec6baa099cd1bd3de5c8139b.tar.bz2
luarocks-0b4741a2622a08c6ec6baa099cd1bd3de5c8139b.zip
Merge pull request #464 from mpeterv/improve-ext-deps
Show candidate files when external deps are missing
-rw-r--r--src/luarocks/deps.lua53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
index 0e3265b5..eb01075c 100644
--- a/src/luarocks/deps.lua
+++ b/src/luarocks/deps.lua
@@ -545,10 +545,11 @@ function deps.check_external_deps(rockspec, mode)
545 subdirs = cfg.runtime_external_deps_subdirs 545 subdirs = cfg.runtime_external_deps_subdirs
546 end 546 end
547 if rockspec.external_dependencies then 547 if rockspec.external_dependencies then
548 for name, files in pairs(rockspec.external_dependencies) do 548 for name, ext_files in util.sortedpairs(rockspec.external_dependencies) do
549 local ok = true 549 local ok = true
550 local failed_file = nil 550 local failed_files = {program = {}, header = {}, library = {}}
551 local failed_dirname = nil 551 local failed_dirname
552 local failed_testfile
552 for _, extdir in ipairs(cfg.external_deps_dirs) do 553 for _, extdir in ipairs(cfg.external_deps_dirs) do
553 ok = true 554 ok = true
554 local prefix = vars[name.."_DIR"] 555 local prefix = vars[name.."_DIR"]
@@ -577,7 +578,7 @@ function deps.check_external_deps(rockspec, mode)
577 end 578 end
578 prefix = prefix.prefix 579 prefix = prefix.prefix
579 end 580 end
580 for dirname, dirdata in pairs(dirs) do 581 for dirname, dirdata in util.sortedpairs(dirs) do
581 local paths 582 local paths
582 local path_var_value = vars[name.."_"..dirname] 583 local path_var_value = vars[name.."_"..dirname]
583 if path_var_value then 584 if path_var_value then
@@ -591,7 +592,7 @@ function deps.check_external_deps(rockspec, mode)
591 paths = { dir.path(prefix, dirdata.subdir) } 592 paths = { dir.path(prefix, dirdata.subdir) }
592 end 593 end
593 dirdata.dir = paths[1] 594 dirdata.dir = paths[1]
594 local file = files[dirdata.testfile] 595 local file = ext_files[dirdata.testfile]
595 if file then 596 if file then
596 local files = {} 597 local files = {}
597 if not file:match("%.") then 598 if not file:match("%.") then
@@ -606,19 +607,23 @@ function deps.check_external_deps(rockspec, mode)
606 table.insert(files, file) 607 table.insert(files, file)
607 end 608 end
608 local found = false 609 local found = false
609 failed_file = nil 610 for _, f in ipairs(files) do
610 for _, f in pairs(files) do 611
611
612 -- small convenience hack 612 -- small convenience hack
613 if f:match("%.so$") or f:match("%.dylib$") or f:match("%.dll$") then 613 if f:match("%.so$") or f:match("%.dylib$") or f:match("%.dll$") then
614 f = f:gsub("%.[^.]+$", "."..cfg.external_lib_extension) 614 f = f:gsub("%.[^.]+$", "."..cfg.external_lib_extension)
615 end 615 end
616 616
617 local pattern
618 if f:match("%*") then
619 pattern = f:gsub("%.", "%%."):gsub("%*", ".*")
620 f = "matching "..f
621 end
622
617 for _, d in ipairs(paths) do 623 for _, d in ipairs(paths) do
618 if f:match("%*") then 624 if pattern then
619 local replaced = f:gsub("%.", "%%."):gsub("%*", ".*")
620 for entry in fs.dir(d) do 625 for entry in fs.dir(d) do
621 if entry:match(replaced) then 626 if entry:match(pattern) then
622 found = true 627 found = true
623 break 628 break
624 end 629 end
@@ -629,21 +634,18 @@ function deps.check_external_deps(rockspec, mode)
629 if found then 634 if found then
630 dirdata.dir = d 635 dirdata.dir = d
631 break 636 break
637 else
638 table.insert(failed_files[dirdata.testfile], f.." in "..d)
632 end 639 end
633 end 640 end
634 if found then 641 if found then
635 break 642 break
636 else
637 if failed_file then
638 failed_file = failed_file .. ", or " .. f
639 else
640 failed_file = f
641 end
642 end 643 end
643 end 644 end
644 if not found then 645 if not found then
645 ok = false 646 ok = false
646 failed_dirname = dirname 647 failed_dirname = dirname
648 failed_testfile = dirdata.testfile
647 break 649 break
648 end 650 end
649 end 651 end
@@ -657,7 +659,20 @@ function deps.check_external_deps(rockspec, mode)
657 end 659 end
658 end 660 end
659 if not ok then 661 if not ok then
660 return nil, "Could not find expected file "..failed_file.." for "..name.." -- you may have to install "..name.." in your system and/or pass "..name.."_DIR or "..name.."_"..failed_dirname.." to the luarocks command. Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local", "dependency" 662 local lines = {"Could not find "..failed_testfile.." file for "..name}
663
664 local failed_paths = {}
665 for _, failed_file in ipairs(failed_files[failed_testfile]) do
666 if not failed_paths[failed_file] then
667 failed_paths[failed_file] = true
668 table.insert(lines, " No file "..failed_file)
669 end
670 end
671
672 table.insert(lines, "You may have to install "..name.." in your system and/or pass "..name.."_DIR or "..name.."_"..failed_dirname.." to the luarocks command.")
673 table.insert(lines, "Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local")
674
675 return nil, table.concat(lines, "\n"), "dependency"
661 end 676 end
662 end 677 end
663 end 678 end