Mercurial > repo
annotate share/lua/5.2/luarocks/build.lua @ 10557:23e8673c32c3
<moonythedwarf> ` cd nasmbuild/nasm-2.13rc9; ./configure > confoutput
author | HackBot |
---|---|
date | Thu, 30 Mar 2017 21:05:13 +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 --- Module implementing the LuaRocks "build" command. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
3 -- Builds a rock, compiling its C parts if any. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
4 module("luarocks.build", package.seeall) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
5 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
6 local pack = require("luarocks.pack") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
7 local path = require("luarocks.path") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
8 local util = require("luarocks.util") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
9 local repos = require("luarocks.repos") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
10 local fetch = require("luarocks.fetch") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
11 local fs = require("luarocks.fs") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
12 local dir = require("luarocks.dir") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
13 local deps = require("luarocks.deps") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
14 local manif = require("luarocks.manif") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
15 local cfg = require("luarocks.cfg") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
16 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
17 help_summary = "Build/compile a rock." |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
18 help_arguments = "[--pack-binary-rock] {<rockspec>|<rock>|<name> [<version>]}" |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
19 help = [[ |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
20 Build and install a rock, compiling its C parts if any. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
21 Argument may be a rockspec file, a source rock file |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
22 or the name of a rock to be fetched from a repository. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
23 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
24 If --pack-binary-rock is passed, the rock is not installed; |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
25 instead, a .rock file with the contents of compilation is produced |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
26 in the current directory. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
27 ]] |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
28 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
29 --- Install files to a given location. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
30 -- Takes a table where the array part is a list of filenames to be copied. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
31 -- In the hash part, other keys, if is_module_path is set, are identifiers |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
32 -- in Lua module format, to indicate which subdirectory the file should be |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
33 -- copied to. For example, install_files({["foo.bar"] = "src/bar.lua"}, "boo") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
34 -- will copy src/bar.lua to boo/foo. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
35 -- @param files table or nil: A table containing a list of files to copy in |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
36 -- the format described above. If nil is passed, this function is a no-op. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
37 -- Directories should be delimited by forward slashes as in internet URLs. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
38 -- @param location string: The base directory files should be copied to. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
39 -- @param is_module_path boolean: True if string keys in files should be |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
40 -- interpreted as dotted module paths. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
41 -- @return boolean or (nil, string): True if succeeded or |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
42 -- nil and an error message. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
43 local function install_files(files, location, is_module_path) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
44 assert(type(files) == "table" or not files) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
45 assert(type(location) == "string") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
46 if files then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
47 for k, file in pairs(files) do |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
48 local dest = location |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
49 if type(k) == "string" then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
50 if is_module_path then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
51 dest = dir.path(location, path.module_to_path(k)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
52 fs.make_dir(dest) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
53 else |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
54 dest = dir.path(location, dir.dir_name(k)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
55 fs.make_dir(dest) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
56 dest = dir.path(dest, dir.base_name(k)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
57 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
58 else |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
59 fs.make_dir(dest) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
60 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
61 local ok = fs.copy(dir.path(file), dest) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
62 if not ok then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
63 return nil, "Failed copying "..file |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
64 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
65 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
66 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
67 return true |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
68 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
69 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
70 --- Write to the current directory the contents of a table, |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
71 -- where each key is a file name and its value is the file content. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
72 -- @param files table: The table of files to be written. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
73 local function extract_from_rockspec(files) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
74 for name, content in pairs(files) do |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
75 local fd = io.open(dir.path(fs.current_dir(), name), "w+") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
76 fd:write(content) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
77 fd:close() |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
78 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
79 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
80 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
81 --- Applies patches inlined in the build.patches section |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
82 -- and extracts files inlined in the build.extra_files section |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
83 -- of a rockspec. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
84 -- @param rockspec table: A rockspec table. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
85 -- @return boolean or (nil, string): True if succeeded or |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
86 -- nil and an error message. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
87 function apply_patches(rockspec) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
88 assert(type(rockspec) == "table") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
89 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
90 local build = rockspec.build |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
91 if build.extra_files then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
92 extract_from_rockspec(build.extra_files) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
93 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
94 if build.patches then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
95 extract_from_rockspec(build.patches) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
96 for patch, patchdata in util.sortedpairs(build.patches) do |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
97 util.printout("Applying patch "..patch.."...") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
98 local ok, err = fs.apply_patch(tostring(patch), patchdata) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
99 if not ok then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
100 return nil, "Failed applying patch "..patch |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
101 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
102 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
103 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
104 return true |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
105 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
106 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
107 --- Build and install a rock given a rockspec. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
108 -- @param rockspec_file string: local or remote filename of a rockspec. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
109 -- @param need_to_fetch boolean: true if sources need to be fetched, |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
110 -- false if the rockspec was obtained from inside a source rock. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
111 -- @param minimal_mode boolean: true if there's no need to fetch, |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
112 -- unpack or change dir (this is used by "luarocks make"). Implies |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
113 -- need_to_fetch = false. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
114 -- @param deps_mode: string: Which trees to check dependencies for: |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
115 -- "none", "one", "order" or "all". |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
116 -- @return boolean or (nil, string, [string]): True if succeeded or |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
117 -- nil and an error message followed by an error code. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
118 function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_mode) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
119 assert(type(rockspec_file) == "string") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
120 assert(type(need_to_fetch) == "boolean") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
121 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
122 local rockspec, err, errcode = fetch.load_rockspec(rockspec_file) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
123 if err then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
124 return nil, err, errcode |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
125 elseif not rockspec.build then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
126 return nil, "Rockspec error: build table not specified" |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
127 elseif not rockspec.build.type then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
128 return nil, "Rockspec error: build type not specified" |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
129 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
130 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
131 if deps_mode == "none" then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
132 util.printerr("Warning: skipping dependency checks.") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
133 else |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
134 local ok, err, errcode = deps.fulfill_dependencies(rockspec, deps_mode) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
135 if err then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
136 return nil, err, errcode |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
137 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
138 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
139 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
140 ok, err, errcode = deps.check_external_deps(rockspec, "build") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
141 if err then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
142 return nil, err, errcode |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
143 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
144 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
145 local name, version = rockspec.name, rockspec.version |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
146 if repos.is_installed(name, version) then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
147 repos.delete_version(name, version) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
148 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
149 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
150 if not minimal_mode then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
151 local _, source_dir |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
152 if need_to_fetch then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
153 ok, source_dir, errcode = fetch.fetch_sources(rockspec, true) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
154 if not ok then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
155 return nil, source_dir, errcode |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
156 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
157 fs.change_dir(source_dir) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
158 elseif rockspec.source.file then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
159 local ok, err = fs.unpack_archive(rockspec.source.file) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
160 if not ok then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
161 return nil, err |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
162 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
163 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
164 fs.change_dir(rockspec.source.dir) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
165 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
166 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
167 local dirs = { |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
168 lua = { name = path.lua_dir(name, version), is_module_path = true }, |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
169 lib = { name = path.lib_dir(name, version), is_module_path = true }, |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
170 conf = { name = path.conf_dir(name, version), is_module_path = false }, |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
171 bin = { name = path.bin_dir(name, version), is_module_path = false }, |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
172 } |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
173 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
174 for _, d in pairs(dirs) do |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
175 fs.make_dir(d.name) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
176 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
177 local rollback = util.schedule_function(function() |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
178 fs.delete(path.install_dir(name, version)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
179 fs.remove_dir_if_empty(path.versions_dir(name)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
180 end) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
181 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
182 local build = rockspec.build |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
183 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
184 if not minimal_mode then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
185 ok, err = apply_patches(rockspec) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
186 if err then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
187 return nil, err |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
188 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
189 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
190 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
191 if build.type ~= "none" then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
192 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
193 -- Temporary compatibility |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
194 if build.type == "module" then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
195 util.printout("Do not use 'module' as a build type. Use 'builtin' instead.") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
196 build.type = "builtin" |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
197 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
198 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
199 local build_type |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
200 ok, build_type = pcall(require, "luarocks.build." .. build.type) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
201 if not ok or not type(build_type) == "table" then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
202 return nil, "Failed initializing build back-end for build type '"..build.type.."': "..build_type |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
203 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
204 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
205 ok, err = build_type.run(rockspec) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
206 if not ok then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
207 return nil, "Build error: " .. err |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
208 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
209 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
210 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
211 if build.install then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
212 for id, install_dir in pairs(dirs) do |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
213 ok, err = install_files(build.install[id], install_dir.name, install_dir.is_module_path) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
214 if not ok then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
215 return nil, err |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
216 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
217 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
218 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
219 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
220 local copy_directories = build.copy_directories or {"doc"} |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
221 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
222 for _, copy_dir in pairs(copy_directories) do |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
223 if fs.is_dir(copy_dir) then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
224 local dest = dir.path(path.install_dir(name, version), copy_dir) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
225 fs.make_dir(dest) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
226 fs.copy_contents(copy_dir, dest) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
227 else |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
228 util.warning("Directory '"..copy_dir.."' not found") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
229 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
230 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
231 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
232 for _, d in pairs(dirs) do |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
233 fs.remove_dir_if_empty(d.name) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
234 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
235 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
236 fs.pop_dir() |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
237 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
238 fs.copy(rockspec.local_filename, path.rockspec_file(name, version)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
239 if need_to_fetch then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
240 fs.pop_dir() |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
241 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
242 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
243 ok, err = manif.make_rock_manifest(name, version) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
244 if err then return nil, err end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
245 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
246 ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
247 if err then return nil, err end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
248 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
249 util.remove_scheduled_function(rollback) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
250 rollback = util.schedule_function(function() |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
251 repos.delete_version(name, version) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
252 end) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
253 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
254 ok, err = repos.run_hook(rockspec, "post_install") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
255 if err then return nil, err end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
256 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
257 ok, err = manif.update_manifest(name, version, nil, deps_mode) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
258 if err then return nil, err end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
259 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
260 local license = "" |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
261 if rockspec.description and rockspec.description.license then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
262 license = ("(license: "..rockspec.description.license..")") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
263 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
264 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
265 local root_dir = path.root_dir(cfg.rocks_dir) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
266 util.printout() |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
267 util.printout(name.." "..version.." is now built and installed in "..root_dir.." "..license) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
268 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
269 util.remove_scheduled_function(rollback) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
270 return true |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
271 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
272 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
273 --- Build and install a rock. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
274 -- @param rock_file string: local or remote filename of a rock. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
275 -- @param need_to_fetch boolean: true if sources need to be fetched, |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
276 -- false if the rockspec was obtained from inside a source rock. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
277 -- @param deps_mode: string: Which trees to check dependencies for: |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
278 -- "none", "one", "order" or "all". |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
279 -- @return boolean or (nil, string, [string]): True if build was successful, |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
280 -- or false and an error message and an optional error code. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
281 function build_rock(rock_file, need_to_fetch, deps_mode) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
282 assert(type(rock_file) == "string") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
283 assert(type(need_to_fetch) == "boolean") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
284 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
285 local unpack_dir, err, errcode = fetch.fetch_and_unpack_rock(rock_file) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
286 if not unpack_dir then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
287 return nil, err, errcode |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
288 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
289 local rockspec_file = path.rockspec_name_from_rock(rock_file) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
290 fs.change_dir(unpack_dir) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
291 local ok, err, errcode = build_rockspec(rockspec_file, need_to_fetch, false, deps_mode) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
292 fs.pop_dir() |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
293 return ok, err, errcode |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
294 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
295 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
296 local function do_build(name, version, deps_mode) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
297 if name:match("%.rockspec$") then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
298 return build_rockspec(name, true, false, deps_mode) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
299 elseif name:match("%.src%.rock$") then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
300 return build_rock(name, false, deps_mode) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
301 elseif name:match("%.all%.rock$") then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
302 local install = require("luarocks.install") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
303 return install.install_binary_rock(name, deps_mode) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
304 elseif name:match("%.rock$") then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
305 return build_rock(name, true, deps_mode) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
306 elseif not name:match(dir.separator) then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
307 local search = require("luarocks.search") |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
308 return search.act_on_src_or_rockspec(run, name:lower(), version, deps.deps_mode_to_flag(deps_mode)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
309 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
310 return nil, "Don't know what to do with "..name |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
311 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
312 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
313 --- Driver function for "build" command. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
314 -- @param name string: A local or remote rockspec or rock file. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
315 -- If a package name is given, forwards the request to "search" and, |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
316 -- if returned a result, installs the matching rock. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
317 -- @param version string: When passing a package name, a version number may |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
318 -- also be given. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
319 -- @return boolean or (nil, string): True if build was successful; nil and an |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
320 -- error message otherwise. |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
321 function run(...) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
322 local flags, name, version = util.parse_flags(...) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
323 if type(name) ~= "string" then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
324 return nil, "Argument missing, see help." |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
325 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
326 assert(type(version) == "string" or not version) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
327 |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
328 if flags["pack-binary-rock"] then |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
329 return pack.pack_binary_rock(name, version, do_build, name, version, deps.get_deps_mode(flags)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
330 else |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
331 local ok, err = fs.check_command_permissions(flags) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
332 if not ok then return nil, err end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
333 return do_build(name, version, deps.get_deps_mode(flags)) |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
334 end |
d137f631bad5
<GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff
changeset
|
335 end |