diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2015-06-24 11:07:10 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-06-24 11:07:10 -0300 |
| commit | 9040c749138810744498630ed040eea23330723a (patch) | |
| tree | 176ac1ebdde22e2c7dd997ccf111247817243755 /src | |
| parent | 85edc261eb543315002b888068693c0bbf087009 (diff) | |
| parent | a0315b7bc2432ea517bb90ce39df0cc8b1cd2f65 (diff) | |
| download | luarocks-9040c749138810744498630ed040eea23330723a.tar.gz luarocks-9040c749138810744498630ed040eea23330723a.tar.bz2 luarocks-9040c749138810744498630ed040eea23330723a.zip | |
Merge branch 'master' of https://github.com/keplerproject/luarocks
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/build/cmake.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/cfg.lua | 28 | ||||
| -rw-r--r-- | src/luarocks/fetch/cvs.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/fetch/git.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/fetch/hg.lua | 7 | ||||
| -rw-r--r-- | src/luarocks/fetch/svn.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/fs/lua.lua | 21 |
7 files changed, 65 insertions, 14 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/cfg.lua b/src/luarocks/cfg.lua index 52b8c089..73a8ecb2 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -145,13 +145,28 @@ end | |||
| 145 | cfg.variables = {} | 145 | cfg.variables = {} |
| 146 | cfg.rocks_trees = {} | 146 | cfg.rocks_trees = {} |
| 147 | 147 | ||
| 148 | -- The global environment in the config files; | ||
| 149 | local env_for_config_file | ||
| 150 | env_for_config_file = { | ||
| 151 | home = cfg.home, | ||
| 152 | lua_version = cfg.lua_version, | ||
| 153 | platform = util.make_shallow_copy(detected), | ||
| 154 | processor = proc, | ||
| 155 | os_getenv = os.getenv, | ||
| 156 | dump_env = function() | ||
| 157 | -- debug function, calling it from a config file will show all | ||
| 158 | -- available globals to that config file | ||
| 159 | print(util.show_table(env_for_config_file, "global environment")) | ||
| 160 | end, | ||
| 161 | } | ||
| 162 | |||
| 148 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" | 163 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" |
| 149 | do | 164 | do |
| 150 | local err, errcode | 165 | local err, errcode |
| 151 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) | 166 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file) |
| 152 | if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file | 167 | if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file |
| 153 | sys_config_file = sys_config_dir.."/config.lua" | 168 | sys_config_file = sys_config_dir.."/config.lua" |
| 154 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) | 169 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file) |
| 155 | end | 170 | end |
| 156 | if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error | 171 | if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error |
| 157 | io.stderr:write(err.."\n") | 172 | io.stderr:write(err.."\n") |
| @@ -159,13 +174,6 @@ do | |||
| 159 | end | 174 | end |
| 160 | end | 175 | end |
| 161 | 176 | ||
| 162 | local env_for_config_file = { | ||
| 163 | home = cfg.home, | ||
| 164 | lua_version = cfg.lua_version, | ||
| 165 | platform = util.make_shallow_copy(detected), | ||
| 166 | processor = proc, | ||
| 167 | } | ||
| 168 | |||
| 169 | if not site_config.LUAROCKS_FORCE_CONFIG then | 177 | if not site_config.LUAROCKS_FORCE_CONFIG then |
| 170 | 178 | ||
| 171 | local home_overrides, err, errcode | 179 | local home_overrides, err, errcode |
| @@ -309,7 +317,7 @@ local defaults = { | |||
| 309 | } | 317 | } |
| 310 | 318 | ||
| 311 | if detected.windows then | 319 | if detected.windows then |
| 312 | local full_prefix = site_config.LUAROCKS_PREFIX.."\\"..cfg.major_version | 320 | local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])).."\\"..cfg.major_version |
| 313 | extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" | 321 | extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" |
| 314 | 322 | ||
| 315 | home_config_file = home_config_file and home_config_file:gsub("\\","/") | 323 | home_config_file = home_config_file and home_config_file:gsub("\\","/") |
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 53fd4445..e540d696 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua | |||
| @@ -40,6 +40,11 @@ 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 | local ok, err_msg = fs.is_tool_available(git_cmd, "Git") | ||
| 44 | if not ok then | ||
| 45 | return nil, err_msg | ||
| 46 | end | ||
| 47 | |||
| 43 | local store_dir | 48 | local store_dir |
| 44 | if not dest_dir then | 49 | if not dest_dir then |
| 45 | store_dir = fs.make_temp_dir(name_version) | 50 | store_dir = fs.make_temp_dir(name_version) |
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 |
| 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. |
