diff options
| author | mpeterv <mpeterval@gmail.com> | 2015-12-05 14:32:37 +0300 |
|---|---|---|
| committer | mpeterv <mpeterval@gmail.com> | 2015-12-05 18:39:18 +0300 |
| commit | 5ff2408d35eee424359ba5bdd6b5f792f8a0b046 (patch) | |
| tree | cd66dad9432a728a7923da667850207e322d55a9 /src | |
| parent | 90d0b9caaba831a5d88a74bca736afa233f49f2c (diff) | |
| download | luarocks-5ff2408d35eee424359ba5bdd6b5f792f8a0b046.tar.gz luarocks-5ff2408d35eee424359ba5bdd6b5f792f8a0b046.tar.bz2 luarocks-5ff2408d35eee424359ba5bdd6b5f792f8a0b046.zip | |
Show candidate files when external deps are missing
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/deps.lua | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 0e3265b5..38541b68 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 pairs(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"] |
| @@ -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 |
