diff options
-rw-r--r-- | src/luarocks/build/cmake.lua | 5 | ||||
-rw-r--r-- | src/luarocks/fetch/cvs.lua | 5 | ||||
-rw-r--r-- | src/luarocks/fetch/git.lua | 5 | ||||
-rw-r--r-- | src/luarocks/fetch/hg.lua | 5 | ||||
-rw-r--r-- | src/luarocks/fetch/svn.lua | 5 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 21 |
6 files changed, 36 insertions, 10 deletions
diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index e5b29147..c8f5a669 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua | |||
@@ -23,8 +23,9 @@ function cmake.run(rockspec) | |||
23 | 23 | ||
24 | util.variable_substitutions(variables, rockspec.variables) | 24 | util.variable_substitutions(variables, rockspec.variables) |
25 | 25 | ||
26 | if not fs.execute_quiet(rockspec.variables.CMAKE, "--help") then | 26 | local ok, err_msg = fs.is_tool_available(rockspec.variables.CMAKE, "CMake") |
27 | return nil, "'"..rockspec.variables.CMAKE.."' program not found. Is cmake installed? You may want to edit variables.CMAKE" | 27 | if not ok then |
28 | return nil, err_msg | ||
28 | end | 29 | end |
29 | 30 | ||
30 | -- If inline cmake is present create CMakeLists.txt from it. | 31 | -- If inline cmake is present create CMakeLists.txt from it. |
diff --git a/src/luarocks/fetch/cvs.lua b/src/luarocks/fetch/cvs.lua index fad1ca0d..ccf928c4 100644 --- a/src/luarocks/fetch/cvs.lua +++ b/src/luarocks/fetch/cvs.lua | |||
@@ -21,8 +21,9 @@ function cvs.get_sources(rockspec, extract, dest_dir) | |||
21 | assert(type(dest_dir) == "string" or not dest_dir) | 21 | assert(type(dest_dir) == "string" or not dest_dir) |
22 | 22 | ||
23 | local cvs_cmd = rockspec.variables.CVS | 23 | local cvs_cmd = rockspec.variables.CVS |
24 | if not fs.execute_quiet(cvs_cmd, "--version") then | 24 | local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS") |
25 | return nil, "'"..cvs_cmd.."' program not found. Is CVS installed? You may want to edit variables.CVS" | 25 | if not ok then |
26 | return nil, err_msg | ||
26 | end | 27 | end |
27 | 28 | ||
28 | local name_version = rockspec.name .. "-" .. rockspec.version | 29 | local name_version = rockspec.name .. "-" .. rockspec.version |
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index bea53fc8..e540d696 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua | |||
@@ -40,8 +40,9 @@ function git.get_sources(rockspec, extract, dest_dir, depth) | |||
40 | -- Strip off .git from base name if present | 40 | -- Strip off .git from base name if present |
41 | module = module:gsub("%.git$", "") | 41 | module = module:gsub("%.git$", "") |
42 | 42 | ||
43 | if not fs.execute_quiet(git_cmd, "--version") then | 43 | local ok, err_msg = fs.is_tool_available(git_cmd, "Git") |
44 | return nil, "'"..git_cmd.."' program not found. Is git installed? You may want to edit variables.GIT" | 44 | if not ok then |
45 | return nil, err_msg | ||
45 | end | 46 | end |
46 | 47 | ||
47 | local store_dir | 48 | local store_dir |
diff --git a/src/luarocks/fetch/hg.lua b/src/luarocks/fetch/hg.lua index 055e3bbe..518130b4 100644 --- a/src/luarocks/fetch/hg.lua +++ b/src/luarocks/fetch/hg.lua | |||
@@ -21,8 +21,9 @@ function hg.get_sources(rockspec, extract, dest_dir) | |||
21 | assert(type(dest_dir) == "string" or not dest_dir) | 21 | assert(type(dest_dir) == "string" or not dest_dir) |
22 | 22 | ||
23 | local hg_cmd = rockspec.variables.HG | 23 | local hg_cmd = rockspec.variables.HG |
24 | if not fs.execute_quiet(hg_cmd, "--version") then | 24 | local ok, err_msg = fs.is_tool_available(hg_cmd, "Mercurial") |
25 | return nil, "'"..hg_cmd.."' program not found. Is Mercurial installed? You may want to edit variables.HG" | 25 | if not ok then |
26 | return nil, err_msg | ||
26 | end | 27 | end |
27 | 28 | ||
28 | local name_version = rockspec.name .. "-" .. rockspec.version | 29 | local name_version = rockspec.name .. "-" .. rockspec.version |
diff --git a/src/luarocks/fetch/svn.lua b/src/luarocks/fetch/svn.lua index 8fe582f6..755e5e32 100644 --- a/src/luarocks/fetch/svn.lua +++ b/src/luarocks/fetch/svn.lua | |||
@@ -21,8 +21,9 @@ function svn.get_sources(rockspec, extract, dest_dir) | |||
21 | assert(type(dest_dir) == "string" or not dest_dir) | 21 | assert(type(dest_dir) == "string" or not dest_dir) |
22 | 22 | ||
23 | local svn_cmd = rockspec.variables.SVN | 23 | local svn_cmd = rockspec.variables.SVN |
24 | if not fs.execute_quiet(svn_cmd, "--version") then | 24 | local ok, err_msg = fs.is_tool_available(svn_cmd, "--version", "Subversion") |
25 | return nil, "'"..svn_cmd.."' program not found. Is Subversion installed? You may want to edit variables.SVN" | 25 | if not ok then |
26 | return nil, err_msg | ||
26 | end | 27 | end |
27 | 28 | ||
28 | local name_version = rockspec.name .. "-" .. rockspec.version | 29 | local name_version = rockspec.name .. "-" .. rockspec.version |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index c0f6c1c6..73ae2698 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -122,6 +122,27 @@ function fs_lua.execute_quiet(command, ...) | |||
122 | end | 122 | end |
123 | end | 123 | end |
124 | 124 | ||
125 | --- Checks if the given tool is available. | ||
126 | -- The tool is executed using a flag, usually just to ask its version. | ||
127 | -- @param tool_cmd string: The command to be used to check the tool's presence (e.g. hg in case of Mercurial) | ||
128 | -- @param tool_name string: The actual name of the tool (e.g. Mercurial) | ||
129 | -- @param arg string: The flag to pass to the tool. '--version' by default. | ||
130 | function fs_lua.is_tool_available(tool_cmd, tool_name, arg) | ||
131 | assert(type(tool_cmd) == "string") | ||
132 | assert(type(tool_name) == "string") | ||
133 | |||
134 | arg = arg or "--version" | ||
135 | assert(type(arg) == "string") | ||
136 | |||
137 | if not fs.execute_quiet(tool_cmd, arg) then | ||
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')" | ||
140 | return nil, msg:format(tool_cmd, tool_name, tool_cmd:upper()) | ||
141 | else | ||
142 | return true | ||
143 | end | ||
144 | end | ||
145 | |||
125 | --- Check the MD5 checksum for a file. | 146 | --- Check the MD5 checksum for a file. |
126 | -- @param file string: The file to be checked. | 147 | -- @param file string: The file to be checked. |
127 | -- @param md5sum string: The string with the expected MD5 checksum. | 148 | -- @param md5sum string: The string with the expected MD5 checksum. |