Mercurial > repo
comparison share/lua/5.2/luarocks/fetch/svn.lua @ 1132:d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
author | HackBot |
---|---|
date | Fri, 14 Dec 2012 22:24:27 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1131:ff65dfb63263 | 1132:d137f631bad5 |
---|---|
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 svn_cmd = rockspec.variables.SVN | |
21 local name_version = rockspec.name .. "-" .. rockspec.version | |
22 local module = rockspec.source.module or dir.base_name(rockspec.source.url) | |
23 local url = rockspec.source.url:gsub("^svn://", "") | |
24 local command = {svn_cmd, "checkout", url, module} | |
25 if rockspec.source.tag then | |
26 table.insert(command, 5, "-r") | |
27 table.insert(command, 6, rockspec.source.tag) | |
28 end | |
29 local store_dir | |
30 if not dest_dir then | |
31 store_dir = fs.make_temp_dir(name_version) | |
32 if not store_dir then | |
33 return nil, "Failed creating temporary directory." | |
34 end | |
35 util.schedule_function(fs.delete, store_dir) | |
36 else | |
37 store_dir = dest_dir | |
38 end | |
39 fs.change_dir(store_dir) | |
40 if not fs.execute(unpack(command)) then | |
41 return nil, "Failed fetching files from Subversion." | |
42 end | |
43 fs.change_dir(module) | |
44 for _, d in ipairs(fs.find(".")) do | |
45 if dir.base_name(d) == ".svn" then | |
46 fs.delete(dir.path(store_dir, module, d)) | |
47 end | |
48 end | |
49 fs.pop_dir() | |
50 fs.pop_dir() | |
51 return module, store_dir | |
52 end | |
53 |