Mercurial > repo
annotate share/lua/5.2/luarocks/fetch/sscm.lua @ 9020:030e84226810
<oerjan> ` mv wisdom/culprit{,s}
author | HackBot |
---|---|
date | Thu, 08 Sep 2016 01:15:58 +0000 |
parents | d137f631bad5 |
children |
rev | line source |
---|---|
1132
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
1 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
2 --- Fetch back-end for retrieving sources from Surround SCM Server |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
3 module("luarocks.fetch.sscm", package.seeall) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
4 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
5 local fs = require("luarocks.fs") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
6 local dir = require("luarocks.dir") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
7 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
8 --- Download sources via Surround SCM Server for building a rock. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
9 -- @param rockspec table: The rockspec table |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
10 -- @param extract boolean: Unused in this module (required for API purposes.) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
11 -- @param dest_dir string or nil: If set, will extract to the given directory. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
12 -- @return (string, string) or (nil, string): The absolute pathname of |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
13 -- the fetched source tarball and the temporary directory created to |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
14 -- store it; or nil and an error message. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
15 function get_sources(rockspec, extract, dest_dir) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
16 assert(type(rockspec) == "table") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
17 assert(type(dest_dir) == "string" or not dest_dir) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
18 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
19 local sscm_cmd = rockspec.variables.SSCM |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
20 local module = rockspec.source.module or dir.base_name(rockspec.source.url) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
21 local branch, repository = string.match(rockspec.source.pathname, "^([^/]*)/(.*)") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
22 if not branch or not repository then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
23 return nil, "Error retrieving branch and repository from rockspec." |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
24 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
25 -- Search for working directory. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
26 local working_dir |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
27 local tmp = io.popen(string.format(sscm_cmd..[[ property "/" -d -b%s -p%s]], branch, repository)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
28 for line in tmp:lines() do |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
29 --%c because a chr(13) comes in the end. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
30 working_dir = string.match(line, "Working directory:[%s]*(.*)%c$") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
31 if working_dir then break end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
32 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
33 tmp:close() |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
34 if not working_dir then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
35 return nil, "Error retrieving working directory from SSCM." |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
36 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
37 if not fs.execute(sscm_cmd, "get", "*", "-e" , "-r", "-b"..branch, "-p"..repository, "-tmodify", "-wreplace") then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
38 return nil, "Failed fetching files from SSCM." |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
39 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
40 -- FIXME: This function does not honor the dest_dir parameter. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
41 return module, working_dir |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
42 end |