diff options
author | Hisham Muhammad <hisham@NewMachine.localdomain> | 2010-04-19 18:01:42 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@NewMachine.localdomain> | 2010-04-19 18:08:51 -0300 |
commit | 9c501d767c285d9eee6b95c9c27666d3b1367183 (patch) | |
tree | 7e6beba5725f9bcbfb592b9d9a15c8f26c0b5fe7 /src | |
parent | 11757127cdcd5d15d40f189f4b03e32328063cd9 (diff) | |
download | luarocks-9c501d767c285d9eee6b95c9c27666d3b1367183.tar.gz luarocks-9c501d767c285d9eee6b95c9c27666d3b1367183.tar.bz2 luarocks-9c501d767c285d9eee6b95c9c27666d3b1367183.zip |
Support svn URLs (since this is incompatible with earlier LuaRocks versions,
svn:// rockspecs should not be added to the main repository for now.)
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/fetch/svn.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/luarocks/fetch/svn.lua b/src/luarocks/fetch/svn.lua new file mode 100644 index 00000000..01ea6ba9 --- /dev/null +++ b/src/luarocks/fetch/svn.lua | |||
@@ -0,0 +1,45 @@ | |||
1 | |||
2 | --- Fetch back-end for retrieving sources from Subversion. | ||
3 | module("luarocks.fetch.svn", package.seeall) | ||
4 | |||
5 | local fs = require("luarocks.fs") | ||
6 | local dir = require("luarocks.dir") | ||
7 | local util = require("luarocks.util") | ||
8 | |||
9 | --- Download sources for building a rock, using Subversion. | ||
10 | -- @param rockspec table: The rockspec table | ||
11 | -- @param extract boolean: Unused in this module (required for API purposes.) | ||
12 | -- @param dest_dir string or nil: If set, will extract to the given directory. | ||
13 | -- @return (string, string) or (nil, string): The absolute pathname of | ||
14 | -- the fetched source tarball and the temporary directory created to | ||
15 | -- store it; or nil and an error message. | ||
16 | function get_sources(rockspec, extract, dest_dir) | ||
17 | assert(type(rockspec) == "table") | ||
18 | assert(type(dest_dir) == "string" or not dest_dir) | ||
19 | |||
20 | local name_version = rockspec.name .. "-" .. rockspec.version | ||
21 | local module = rockspec.source.module or dir.base_name(rockspec.source.url) | ||
22 | local url = rockspec.source.url:gsub("^svn://", "") | ||
23 | local command = {"svn", "checkout", url, module} | ||
24 | if rockspec.source.tag then | ||
25 | table.insert(command, 5, "-r") | ||
26 | table.insert(command, 6, rockspec.source.tag) | ||
27 | end | ||
28 | local store_dir | ||
29 | if not dest_dir then | ||
30 | store_dir = fs.make_temp_dir(name_version) | ||
31 | if not store_dir then | ||
32 | return nil, "Failed creating temporary directory." | ||
33 | end | ||
34 | util.schedule_function(fs.delete, store_dir) | ||
35 | else | ||
36 | store_dir = dest_dir | ||
37 | end | ||
38 | fs.change_dir(store_dir) | ||
39 | if not fs.execute(unpack(command)) then | ||
40 | return nil, "Failed fetching files from Subversion." | ||
41 | end | ||
42 | fs.pop_dir() | ||
43 | return module, store_dir | ||
44 | end | ||
45 | |||