diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2015-12-05 16:45:25 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-12-05 16:45:25 -0200 |
| commit | 619b8165186741e99d3274826fd95a6f546681be (patch) | |
| tree | 142466631f0698b606336181e31c53720b43a03c /src | |
| parent | e95bfca9f1f1e417a2f554cb756cd44a7eb105cb (diff) | |
| parent | bf12327a64400884b2be50c88cc8b223db57260c (diff) | |
| download | luarocks-619b8165186741e99d3274826fd95a6f546681be.tar.gz luarocks-619b8165186741e99d3274826fd95a6f546681be.tar.bz2 luarocks-619b8165186741e99d3274826fd95a6f546681be.zip | |
Merge branch 'master' into luarocks-3
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cfg.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/command_line.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/deps.lua | 53 | ||||
| -rw-r--r-- | src/luarocks/fs/lua.lua | 23 | ||||
| -rw-r--r-- | src/luarocks/fs/unix.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/fs/win32.lua | 18 |
6 files changed, 79 insertions, 34 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 6706468c..af30417c 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -149,7 +149,7 @@ local sys_config_file_default, home_config_file_default | |||
| 149 | local sys_config_dir, home_config_dir | 149 | local sys_config_dir, home_config_dir |
| 150 | local sys_config_ok, home_config_ok = false, false | 150 | local sys_config_ok, home_config_ok = false, false |
| 151 | local extra_luarocks_module_dir | 151 | local extra_luarocks_module_dir |
| 152 | sys_config_dir = site_config.LUAROCKS_SYSCONFDIR | 152 | sys_config_dir = site_config.LUAROCKS_SYSCONFDIR or site_config.LUAROCKS_PREFIX |
| 153 | if cfg.platforms.windows then | 153 | if cfg.platforms.windows then |
| 154 | cfg.home = os.getenv("APPDATA") or "c:" | 154 | cfg.home = os.getenv("APPDATA") or "c:" |
| 155 | sys_config_dir = sys_config_dir or "c:/luarocks" | 155 | sys_config_dir = sys_config_dir or "c:/luarocks" |
| @@ -665,7 +665,7 @@ function cfg.init_package_paths() | |||
| 665 | end | 665 | end |
| 666 | 666 | ||
| 667 | function cfg.which_config() | 667 | function cfg.which_config() |
| 668 | return { | 668 | local ret = { |
| 669 | system = { | 669 | system = { |
| 670 | file = sys_config_file or sys_config_file_default, | 670 | file = sys_config_file or sys_config_file_default, |
| 671 | ok = sys_config_ok, | 671 | ok = sys_config_ok, |
| @@ -675,6 +675,8 @@ function cfg.which_config() | |||
| 675 | ok = home_config_ok, | 675 | ok = home_config_ok, |
| 676 | } | 676 | } |
| 677 | } | 677 | } |
| 678 | ret.nearest = (ret.user.ok and ret.user.file) or ret.system.file | ||
| 679 | return ret | ||
| 678 | end | 680 | end |
| 679 | 681 | ||
| 680 | cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch | 682 | cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch |
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index dbf64b9c..e1c9f492 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
| @@ -31,12 +31,17 @@ end | |||
| 31 | local function replace_tree(flags, args, tree) | 31 | local function replace_tree(flags, args, tree) |
| 32 | tree = dir.normalize(tree) | 32 | tree = dir.normalize(tree) |
| 33 | flags["tree"] = tree | 33 | flags["tree"] = tree |
| 34 | local added = false | ||
| 34 | for i = 1, #args do | 35 | for i = 1, #args do |
| 35 | if args[i]:match("%-%-tree=") then | 36 | if args[i]:match("%-%-tree=") then |
| 36 | args[i] = "--tree="..tree | 37 | args[i] = "--tree="..tree |
| 38 | added = true | ||
| 37 | break | 39 | break |
| 38 | end | 40 | end |
| 39 | end | 41 | end |
| 42 | if not added then | ||
| 43 | args[#args + 1] = "--tree="..tree | ||
| 44 | end | ||
| 40 | path.use_tree(tree) | 45 | path.use_tree(tree) |
| 41 | end | 46 | end |
| 42 | 47 | ||
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 3f7eb4d2..764116a2 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
| @@ -558,10 +558,11 @@ function deps.check_external_deps(rockspec, mode) | |||
| 558 | subdirs = cfg.runtime_external_deps_subdirs | 558 | subdirs = cfg.runtime_external_deps_subdirs |
| 559 | end | 559 | end |
| 560 | if rockspec.external_dependencies then | 560 | if rockspec.external_dependencies then |
| 561 | for name, files in pairs(rockspec.external_dependencies) do | 561 | for name, ext_files in util.sortedpairs(rockspec.external_dependencies) do |
| 562 | local ok = true | 562 | local ok = true |
| 563 | local failed_file = nil | 563 | local failed_files = {program = {}, header = {}, library = {}} |
| 564 | local failed_dirname = nil | 564 | local failed_dirname |
| 565 | local failed_testfile | ||
| 565 | for _, extdir in ipairs(cfg.external_deps_dirs) do | 566 | for _, extdir in ipairs(cfg.external_deps_dirs) do |
| 566 | ok = true | 567 | ok = true |
| 567 | local prefix = vars[name.."_DIR"] | 568 | local prefix = vars[name.."_DIR"] |
| @@ -590,7 +591,7 @@ function deps.check_external_deps(rockspec, mode) | |||
| 590 | end | 591 | end |
| 591 | prefix = prefix.prefix | 592 | prefix = prefix.prefix |
| 592 | end | 593 | end |
| 593 | for dirname, dirdata in pairs(dirs) do | 594 | for dirname, dirdata in util.sortedpairs(dirs) do |
| 594 | local paths | 595 | local paths |
| 595 | local path_var_value = vars[name.."_"..dirname] | 596 | local path_var_value = vars[name.."_"..dirname] |
| 596 | if path_var_value then | 597 | if path_var_value then |
| @@ -604,7 +605,7 @@ function deps.check_external_deps(rockspec, mode) | |||
| 604 | paths = { dir.path(prefix, dirdata.subdir) } | 605 | paths = { dir.path(prefix, dirdata.subdir) } |
| 605 | end | 606 | end |
| 606 | dirdata.dir = paths[1] | 607 | dirdata.dir = paths[1] |
| 607 | local file = files[dirdata.testfile] | 608 | local file = ext_files[dirdata.testfile] |
| 608 | if file then | 609 | if file then |
| 609 | local files = {} | 610 | local files = {} |
| 610 | if not file:match("%.") then | 611 | if not file:match("%.") then |
| @@ -619,19 +620,23 @@ function deps.check_external_deps(rockspec, mode) | |||
| 619 | table.insert(files, file) | 620 | table.insert(files, file) |
| 620 | end | 621 | end |
| 621 | local found = false | 622 | local found = false |
| 622 | failed_file = nil | 623 | for _, f in ipairs(files) do |
| 623 | for _, f in pairs(files) do | 624 | |
| 624 | |||
| 625 | -- small convenience hack | 625 | -- small convenience hack |
| 626 | if f:match("%.so$") or f:match("%.dylib$") or f:match("%.dll$") then | 626 | if f:match("%.so$") or f:match("%.dylib$") or f:match("%.dll$") then |
| 627 | f = f:gsub("%.[^.]+$", "."..cfg.external_lib_extension) | 627 | f = f:gsub("%.[^.]+$", "."..cfg.external_lib_extension) |
| 628 | end | 628 | end |
| 629 | 629 | ||
| 630 | local pattern | ||
| 631 | if f:match("%*") then | ||
| 632 | pattern = f:gsub("%.", "%%."):gsub("%*", ".*") | ||
| 633 | f = "matching "..f | ||
| 634 | end | ||
| 635 | |||
| 630 | for _, d in ipairs(paths) do | 636 | for _, d in ipairs(paths) do |
| 631 | if f:match("%*") then | 637 | if pattern then |
| 632 | local replaced = f:gsub("%.", "%%."):gsub("%*", ".*") | ||
| 633 | for entry in fs.dir(d) do | 638 | for entry in fs.dir(d) do |
| 634 | if entry:match(replaced) then | 639 | if entry:match(pattern) then |
| 635 | found = true | 640 | found = true |
| 636 | break | 641 | break |
| 637 | end | 642 | end |
| @@ -642,21 +647,18 @@ function deps.check_external_deps(rockspec, mode) | |||
| 642 | if found then | 647 | if found then |
| 643 | dirdata.dir = d | 648 | dirdata.dir = d |
| 644 | break | 649 | break |
| 650 | else | ||
| 651 | table.insert(failed_files[dirdata.testfile], f.." in "..d) | ||
| 645 | end | 652 | end |
| 646 | end | 653 | end |
| 647 | if found then | 654 | if found then |
| 648 | break | 655 | break |
| 649 | else | ||
| 650 | if failed_file then | ||
| 651 | failed_file = failed_file .. ", or " .. f | ||
| 652 | else | ||
| 653 | failed_file = f | ||
| 654 | end | ||
| 655 | end | 656 | end |
| 656 | end | 657 | end |
| 657 | if not found then | 658 | if not found then |
| 658 | ok = false | 659 | ok = false |
| 659 | failed_dirname = dirname | 660 | failed_dirname = dirname |
| 661 | failed_testfile = dirdata.testfile | ||
| 660 | break | 662 | break |
| 661 | end | 663 | end |
| 662 | end | 664 | end |
| @@ -670,7 +672,20 @@ function deps.check_external_deps(rockspec, mode) | |||
| 670 | end | 672 | end |
| 671 | end | 673 | end |
| 672 | if not ok then | 674 | if not ok then |
| 673 | 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" | 675 | local lines = {"Could not find "..failed_testfile.." file for "..name} |
| 676 | |||
| 677 | local failed_paths = {} | ||
| 678 | for _, failed_file in ipairs(failed_files[failed_testfile]) do | ||
| 679 | if not failed_paths[failed_file] then | ||
| 680 | failed_paths[failed_file] = true | ||
| 681 | table.insert(lines, " No file "..failed_file) | ||
| 682 | end | ||
| 683 | end | ||
| 684 | |||
| 685 | 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.") | ||
| 686 | table.insert(lines, "Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local") | ||
| 687 | |||
| 688 | return nil, table.concat(lines, "\n"), "dependency" | ||
| 674 | end | 689 | end |
| 675 | end | 690 | end |
| 676 | end | 691 | end |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 73ae2698..a444f014 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
| @@ -134,10 +134,10 @@ function fs_lua.is_tool_available(tool_cmd, tool_name, arg) | |||
| 134 | arg = arg or "--version" | 134 | arg = arg or "--version" |
| 135 | assert(type(arg) == "string") | 135 | assert(type(arg) == "string") |
| 136 | 136 | ||
| 137 | if not fs.execute_quiet(tool_cmd, arg) then | 137 | if not fs.execute_quiet(fs.Q(tool_cmd), arg) then |
| 138 | local msg = "'%s' program not found. Make sure %s is installed and is available in your PATH " .. | 138 | local msg = "'%s' program not found. Make sure %s is installed and is available in your PATH " .. |
| 139 | "(or you may want to edit the 'variables.%s' value in file 'config.lua')" | 139 | "(or you may want to edit the 'variables.%s' value in file '%s')" |
| 140 | return nil, msg:format(tool_cmd, tool_name, tool_cmd:upper()) | 140 | return nil, msg:format(tool_cmd, tool_name, tool_name:upper(), cfg.which_config().nearest) |
| 141 | else | 141 | else |
| 142 | return true | 142 | return true |
| 143 | end | 143 | end |
| @@ -833,10 +833,19 @@ function fs_lua.check_command_permissions(flags) | |||
| 833 | break | 833 | break |
| 834 | end | 834 | end |
| 835 | end | 835 | end |
| 836 | local root_parent = dir.dir_name(root_dir) | 836 | if ok and not fs.exists(root_dir) then |
| 837 | if ok and not fs.exists(root_dir) and not fs.is_writable(root_parent) then | 837 | local root = fs.root_of(root_dir) |
| 838 | ok = false | 838 | local parent = root_dir |
| 839 | err = root_dir.." does not exist and your user does not have write permissions in " .. root_parent | 839 | repeat |
| 840 | parent = dir.dir_name(parent) | ||
| 841 | if parent == "" then | ||
| 842 | parent = root | ||
| 843 | end | ||
| 844 | until parent == root or fs.exists(parent) | ||
| 845 | if not fs.is_writable(parent) then | ||
| 846 | ok = false | ||
| 847 | err = root_dir.." does not exist and your user does not have write permissions in " .. parent | ||
| 848 | end | ||
| 840 | end | 849 | end |
| 841 | if ok then | 850 | if ok then |
| 842 | return true | 851 | return true |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 6ad5a678..8eb3386a 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
| @@ -36,6 +36,14 @@ function unix.absolute_name(pathname, relative_to) | |||
| 36 | end | 36 | end |
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | --- Return the root directory for the given path. | ||
| 40 | -- In Unix, root is always "/". | ||
| 41 | -- @param pathname string: pathname to use. | ||
| 42 | -- @return string: The root of the given pathname. | ||
| 43 | function unix.root_of(_) | ||
| 44 | return "/" | ||
| 45 | end | ||
| 46 | |||
| 39 | --- Create a wrapper to make a script executable from the command-line. | 47 | --- Create a wrapper to make a script executable from the command-line. |
| 40 | -- @param file string: Pathname of script to be made executable. | 48 | -- @param file string: Pathname of script to be made executable. |
| 41 | -- @param dest string: Directory where to put the wrapper. | 49 | -- @param dest string: Directory where to put the wrapper. |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 32766e53..0c8cc9e9 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
| @@ -18,7 +18,6 @@ local _popen, _execute = io.popen, os.execute | |||
| 18 | io.popen = function(cmd, ...) return _popen(_prefix..cmd, ...) end | 18 | io.popen = function(cmd, ...) return _popen(_prefix..cmd, ...) end |
| 19 | os.execute = function(cmd, ...) return _execute(_prefix..cmd, ...) end | 19 | os.execute = function(cmd, ...) return _execute(_prefix..cmd, ...) end |
| 20 | 20 | ||
| 21 | |||
| 22 | --- Annotate command string for quiet execution. | 21 | --- Annotate command string for quiet execution. |
| 23 | -- @param cmd string: A command-line string. | 22 | -- @param cmd string: A command-line string. |
| 24 | -- @return string: The command-line, with silencing annotation. | 23 | -- @return string: The command-line, with silencing annotation. |
| @@ -26,6 +25,7 @@ function win32.quiet(cmd) | |||
| 26 | return cmd.." 2> NUL 1> NUL" | 25 | return cmd.." 2> NUL 1> NUL" |
| 27 | end | 26 | end |
| 28 | 27 | ||
| 28 | local drive_letter = "[%.a-zA-Z]?:?[\\/]" | ||
| 29 | 29 | ||
| 30 | local win_escape_chars = { | 30 | local win_escape_chars = { |
| 31 | ["%"] = "%%", | 31 | ["%"] = "%%", |
| @@ -47,7 +47,7 @@ end | |||
| 47 | function win32.Q(arg) | 47 | function win32.Q(arg) |
| 48 | assert(type(arg) == "string") | 48 | assert(type(arg) == "string") |
| 49 | -- Quote DIR for Windows | 49 | -- Quote DIR for Windows |
| 50 | if arg:match("^[%.a-zA-Z]?:?[\\/]") then | 50 | if arg:match("^"..drive_letter) then |
| 51 | arg = arg:gsub("/", "\\") | 51 | arg = arg:gsub("/", "\\") |
| 52 | end | 52 | end |
| 53 | if arg == "\\" then | 53 | if arg == "\\" then |
| @@ -68,7 +68,7 @@ end | |||
| 68 | function win32.Qb(arg) | 68 | function win32.Qb(arg) |
| 69 | assert(type(arg) == "string") | 69 | assert(type(arg) == "string") |
| 70 | -- Quote DIR for Windows | 70 | -- Quote DIR for Windows |
| 71 | if arg:match("^[%.a-zA-Z]?:?[\\/]") then | 71 | if arg:match("^"..drive_letter) then |
| 72 | arg = arg:gsub("/", "\\") | 72 | arg = arg:gsub("/", "\\") |
| 73 | end | 73 | end |
| 74 | if arg == "\\" then | 74 | if arg == "\\" then |
| @@ -92,15 +92,21 @@ function win32.absolute_name(pathname, relative_to) | |||
| 92 | assert(type(relative_to) == "string" or not relative_to) | 92 | assert(type(relative_to) == "string" or not relative_to) |
| 93 | 93 | ||
| 94 | relative_to = relative_to or fs.current_dir() | 94 | relative_to = relative_to or fs.current_dir() |
| 95 | -- FIXME I'm not sure this first \\ should be there at all. | 95 | if pathname:match("^"..drive_letter) then |
| 96 | -- What are the Windows rules for drive letters? | ||
| 97 | if pathname:match("^[\\.a-zA-Z]?:?[\\/]") then | ||
| 98 | return pathname | 96 | return pathname |
| 99 | else | 97 | else |
| 100 | return relative_to .. "/" .. pathname | 98 | return relative_to .. "/" .. pathname |
| 101 | end | 99 | end |
| 102 | end | 100 | end |
| 103 | 101 | ||
| 102 | --- Return the root directory for the given path. | ||
| 103 | -- For example, for "c:\hello", returns "c:\" | ||
| 104 | -- @param pathname string: pathname to use. | ||
| 105 | -- @return string: The root of the given pathname. | ||
| 106 | function win32.root_of(pathname) | ||
| 107 | return (fs.absolute_name(pathname):match("^("..drive_letter..")")) | ||
| 108 | end | ||
| 109 | |||
| 104 | --- Create a wrapper to make a script executable from the command-line. | 110 | --- Create a wrapper to make a script executable from the command-line. |
| 105 | -- @param file string: Pathname of script to be made executable. | 111 | -- @param file string: Pathname of script to be made executable. |
| 106 | -- @param dest string: Directory where to put the wrapper. | 112 | -- @param dest string: Directory where to put the wrapper. |
