aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/build/cmake.lua5
-rw-r--r--src/luarocks/fetch/cvs.lua8
-rw-r--r--src/luarocks/fetch/git.lua5
-rw-r--r--src/luarocks/fetch/hg.lua7
-rw-r--r--src/luarocks/fetch/svn.lua5
-rw-r--r--src/luarocks/fs/lua.lua21
6 files changed, 45 insertions, 6 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 cc9fd655..ccf928c4 100644
--- a/src/luarocks/fetch/cvs.lua
+++ b/src/luarocks/fetch/cvs.lua
@@ -20,9 +20,15 @@ function cvs.get_sources(rockspec, extract, dest_dir)
20 assert(type(rockspec) == "table") 20 assert(type(rockspec) == "table")
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
24 local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS")
25 if not ok then
26 return nil, err_msg
27 end
28
23 local name_version = rockspec.name .. "-" .. rockspec.version 29 local name_version = rockspec.name .. "-" .. rockspec.version
24 local module = rockspec.source.module or dir.base_name(rockspec.source.url) 30 local module = rockspec.source.module or dir.base_name(rockspec.source.url)
25 local command = {rockspec.variables.CVS, "-d"..rockspec.source.pathname, "export", module} 31 local command = {cvs_cmd, "-d"..rockspec.source.pathname, "export", module}
26 if rockspec.source.tag then 32 if rockspec.source.tag then
27 table.insert(command, 4, "-r") 33 table.insert(command, 4, "-r")
28 table.insert(command, 5, rockspec.source.tag) 34 table.insert(command, 5, rockspec.source.tag)
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 e736a071..518130b4 100644
--- a/src/luarocks/fetch/hg.lua
+++ b/src/luarocks/fetch/hg.lua
@@ -21,9 +21,14 @@ 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 local ok, err_msg = fs.is_tool_available(hg_cmd, "Mercurial")
25 if not ok then
26 return nil, err_msg
27 end
28
24 local name_version = rockspec.name .. "-" .. rockspec.version 29 local name_version = rockspec.name .. "-" .. rockspec.version
25 -- Strip off special hg:// protocol type 30 -- Strip off special hg:// protocol type
26 local url = rockspec.source.url:gsub("^hg://", "") 31 local url = rockspec.source.url:gsub("^hg://", "")
27 32
28 local module = dir.base_name(url) 33 local module = dir.base_name(url)
29 34
diff --git a/src/luarocks/fetch/svn.lua b/src/luarocks/fetch/svn.lua
index abeacf9a..755e5e32 100644
--- a/src/luarocks/fetch/svn.lua
+++ b/src/luarocks/fetch/svn.lua
@@ -21,6 +21,11 @@ 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 local ok, err_msg = fs.is_tool_available(svn_cmd, "--version", "Subversion")
25 if not ok then
26 return nil, err_msg
27 end
28
24 local name_version = rockspec.name .. "-" .. rockspec.version 29 local name_version = rockspec.name .. "-" .. rockspec.version
25 local module = rockspec.source.module or dir.base_name(rockspec.source.url) 30 local module = rockspec.source.module or dir.base_name(rockspec.source.url)
26 local url = rockspec.source.url:gsub("^svn://", "") 31 local url = rockspec.source.url:gsub("^svn://", "")
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
123end 123end
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.
130function 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
144end
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.