aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-16 18:01:46 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-16 18:01:46 +0300
commitb3653137f1b3edffc354d15ff886938fc7438b5d (patch)
tree57171860d7701f029830d2fac6fe7b9b27700061
parentb9b598374a73d77fb456bb087df993e3754252b5 (diff)
downloadluarocks-b3653137f1b3edffc354d15ff886938fc7438b5d.tar.gz
luarocks-b3653137f1b3edffc354d15ff886938fc7438b5d.tar.bz2
luarocks-b3653137f1b3edffc354d15ff886938fc7438b5d.zip
make and pack
-rw-r--r--src/luarocks/build/make.lua61
-rw-r--r--src/luarocks/build/originals/make-original.lua98
-rw-r--r--src/luarocks/pack-original.lua184
-rw-r--r--src/luarocks/pack.lua88
4 files changed, 360 insertions, 71 deletions
diff --git a/src/luarocks/build/make.lua b/src/luarocks/build/make.lua
index 4345ddff..6601c637 100644
--- a/src/luarocks/build/make.lua
+++ b/src/luarocks/build/make.lua
@@ -1,45 +1,45 @@
1local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local pairs = _tl_compat and _tl_compat.pairs or pairs; local table = _tl_compat and _tl_compat.table or table; local _tl_table_unpack = unpack or table.unpack
1 2
2--- Build back-end for using Makefile-based packages.
3local make = {} 3local make = {}
4 4
5local unpack = unpack or table.unpack
6 5
7local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
8local util = require("luarocks.util") 7local util = require("luarocks.util")
9local cfg = require("luarocks.core.cfg") 8local cfg = require("luarocks.core.cfg")
10 9
11--- Call "make" with given target and variables
12-- @param make_cmd string: the make command to be used (typically
13-- configured through variables.MAKE in the config files, or
14-- the appropriate platform-specific default).
15-- @param pass boolean: If true, run make; if false, do nothing.
16-- @param target string: The make target; an empty string indicates
17-- the default target.
18-- @param variables table: A table containing string-string key-value
19-- pairs representing variable assignments to be passed to make.
20-- @return boolean: false if any errors occurred, true otherwise.
21local function make_pass(make_cmd, pass, target, variables)
22 assert(type(pass) == "boolean")
23 assert(type(target) == "string")
24 assert(type(variables) == "table")
25 10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26local function make_pass(make_cmd, pass, target, variables)
26 local assignments = {} 27 local assignments = {}
27 for k,v in pairs(variables) do 28 for k, v in pairs(variables) do
28 table.insert(assignments, k.."="..v) 29 table.insert(assignments, k .. "=" .. v)
29 end 30 end
30 if pass then 31 if pass then
31 return fs.execute(make_cmd.." "..target, unpack(assignments)) 32 return fs.execute(make_cmd .. " " .. target, _tl_table_unpack(assignments))
32 else 33 else
33 return true 34 return true
34 end 35 end
35end 36end
36 37
37--- Driver function for the "make" build back-end. 38
38-- @param rockspec table: the loaded rockspec. 39
39-- @return boolean or (nil, string): true if no errors occurred, 40
40-- nil and an error message otherwise. 41
41function make.run(rockspec, not_install) 42function make.run(rockspec, not_install)
42 assert(rockspec:type() == "rockspec")
43 43
44 local build = rockspec.build 44 local build = rockspec.build
45 45
@@ -51,9 +51,9 @@ function make.run(rockspec, not_install)
51 build.install_target = build.install_target or "install" 51 build.install_target = build.install_target or "install"
52 local makefile = build.makefile or cfg.makefile 52 local makefile = build.makefile or cfg.makefile
53 if makefile then 53 if makefile then
54 -- Assumes all make's accept -f. True for POSIX make, GNU make and Microsoft nmake. 54
55 build.build_target = "-f "..makefile.." "..build.build_target 55 build.build_target = "-f " .. makefile .. " " .. build.build_target
56 build.install_target = "-f "..makefile.." "..build.install_target 56 build.install_target = "-f " .. makefile .. " " .. build.install_target
57 end 57 end
58 58
59 if build.variables then 59 if build.variables then
@@ -63,14 +63,13 @@ function make.run(rockspec, not_install)
63 end 63 end
64 end 64 end
65 65
66 util.warn_if_not_used(build.build_variables, { CFLAGS=true }, "variable %s was not passed in build_variables") 66 util.warn_if_not_used(build.build_variables, { CFLAGS = true }, "variable %s was not passed in build_variables")
67
68 util.variable_substitutions(build.build_variables, rockspec.variables) 67 util.variable_substitutions(build.build_variables, rockspec.variables)
69 util.variable_substitutions(build.install_variables, rockspec.variables) 68 util.variable_substitutions(build.install_variables, rockspec.variables)
70 69
71 local auto_variables = { "CC" } 70 local auto_variables = { "CC" }
72 71
73 for _, variable in pairs(auto_variables) do 72 for _, variable in ipairs(auto_variables) do
74 if not build.build_variables[variable] then 73 if not build.build_variables[variable] then
75 build.build_variables[variable] = rockspec.variables[variable] 74 build.build_variables[variable] = rockspec.variables[variable]
76 end 75 end
@@ -79,7 +78,7 @@ function make.run(rockspec, not_install)
79 end 78 end
80 end 79 end
81 80
82 -- backwards compatibility 81
83 local make_cmd = cfg.make or rockspec.variables.MAKE 82 local make_cmd = cfg.make or rockspec.variables.MAKE
84 83
85 local ok = make_pass(make_cmd, build.build_pass, build.build_target, build.build_variables) 84 local ok = make_pass(make_cmd, build.build_pass, build.build_target, build.build_variables)
diff --git a/src/luarocks/build/originals/make-original.lua b/src/luarocks/build/originals/make-original.lua
new file mode 100644
index 00000000..4345ddff
--- /dev/null
+++ b/src/luarocks/build/originals/make-original.lua
@@ -0,0 +1,98 @@
1
2--- Build back-end for using Makefile-based packages.
3local make = {}
4
5local unpack = unpack or table.unpack
6
7local fs = require("luarocks.fs")
8local util = require("luarocks.util")
9local cfg = require("luarocks.core.cfg")
10
11--- Call "make" with given target and variables
12-- @param make_cmd string: the make command to be used (typically
13-- configured through variables.MAKE in the config files, or
14-- the appropriate platform-specific default).
15-- @param pass boolean: If true, run make; if false, do nothing.
16-- @param target string: The make target; an empty string indicates
17-- the default target.
18-- @param variables table: A table containing string-string key-value
19-- pairs representing variable assignments to be passed to make.
20-- @return boolean: false if any errors occurred, true otherwise.
21local function make_pass(make_cmd, pass, target, variables)
22 assert(type(pass) == "boolean")
23 assert(type(target) == "string")
24 assert(type(variables) == "table")
25
26 local assignments = {}
27 for k,v in pairs(variables) do
28 table.insert(assignments, k.."="..v)
29 end
30 if pass then
31 return fs.execute(make_cmd.." "..target, unpack(assignments))
32 else
33 return true
34 end
35end
36
37--- Driver function for the "make" build back-end.
38-- @param rockspec table: the loaded rockspec.
39-- @return boolean or (nil, string): true if no errors occurred,
40-- nil and an error message otherwise.
41function make.run(rockspec, not_install)
42 assert(rockspec:type() == "rockspec")
43
44 local build = rockspec.build
45
46 if build.build_pass == nil then build.build_pass = true end
47 if build.install_pass == nil then build.install_pass = true end
48 build.build_variables = build.build_variables or {}
49 build.install_variables = build.install_variables or {}
50 build.build_target = build.build_target or ""
51 build.install_target = build.install_target or "install"
52 local makefile = build.makefile or cfg.makefile
53 if makefile then
54 -- Assumes all make's accept -f. True for POSIX make, GNU make and Microsoft nmake.
55 build.build_target = "-f "..makefile.." "..build.build_target
56 build.install_target = "-f "..makefile.." "..build.install_target
57 end
58
59 if build.variables then
60 for var, val in pairs(build.variables) do
61 build.build_variables[var] = val
62 build.install_variables[var] = val
63 end
64 end
65
66 util.warn_if_not_used(build.build_variables, { CFLAGS=true }, "variable %s was not passed in build_variables")
67
68 util.variable_substitutions(build.build_variables, rockspec.variables)
69 util.variable_substitutions(build.install_variables, rockspec.variables)
70
71 local auto_variables = { "CC" }
72
73 for _, variable in pairs(auto_variables) do
74 if not build.build_variables[variable] then
75 build.build_variables[variable] = rockspec.variables[variable]
76 end
77 if not build.install_variables[variable] then
78 build.install_variables[variable] = rockspec.variables[variable]
79 end
80 end
81
82 -- backwards compatibility
83 local make_cmd = cfg.make or rockspec.variables.MAKE
84
85 local ok = make_pass(make_cmd, build.build_pass, build.build_target, build.build_variables)
86 if not ok then
87 return nil, "Failed building."
88 end
89 if not not_install then
90 ok = make_pass(make_cmd, build.install_pass, build.install_target, build.install_variables)
91 if not ok then
92 return nil, "Failed installing."
93 end
94 end
95 return true
96end
97
98return make
diff --git a/src/luarocks/pack-original.lua b/src/luarocks/pack-original.lua
new file mode 100644
index 00000000..731f49dd
--- /dev/null
+++ b/src/luarocks/pack-original.lua
@@ -0,0 +1,184 @@
1
2-- Create rock files, packing sources or binaries.
3local pack = {}
4
5local unpack = unpack or table.unpack
6
7local queries = require("luarocks.queries")
8local path = require("luarocks.path")
9local repos = require("luarocks.repos")
10local fetch = require("luarocks.fetch")
11local fs = require("luarocks.fs")
12local cfg = require("luarocks.core.cfg")
13local util = require("luarocks.util")
14local dir = require("luarocks.dir")
15local manif = require("luarocks.manif")
16local search = require("luarocks.search")
17local signing = require("luarocks.signing")
18
19--- Create a source rock.
20-- Packages a rockspec and its required source files in a rock
21-- file with the .src.rock extension, which can later be built and
22-- installed with the "build" command.
23-- @param rockspec_file string: An URL or pathname for a rockspec file.
24-- @return string or (nil, string): The filename of the resulting
25-- .src.rock file; or nil and an error message.
26function pack.pack_source_rock(rockspec_file)
27 assert(type(rockspec_file) == "string")
28
29 local rockspec, err = fetch.load_rockspec(rockspec_file)
30 if err then
31 return nil, "Error loading rockspec: "..err
32 end
33 rockspec_file = rockspec.local_abs_filename
34
35 local name_version = rockspec.name .. "-" .. rockspec.version
36 local rock_file = fs.absolute_name(name_version .. ".src.rock")
37
38 local temp_dir, err = fs.make_temp_dir("pack-"..name_version)
39 if not temp_dir then
40 return nil, "Failed creating temporary directory: "..err
41 end
42 util.schedule_function(fs.delete, temp_dir)
43
44 local source_file, source_dir = fetch.fetch_sources(rockspec, true, temp_dir)
45 if not source_file then
46 return nil, source_dir
47 end
48 local ok, err = fs.change_dir(source_dir)
49 if not ok then return nil, err end
50
51 fs.delete(rock_file)
52 fs.copy(rockspec_file, source_dir, "read")
53 ok, err = fs.zip(rock_file, dir.base_name(rockspec_file), dir.base_name(source_file))
54 if not ok then
55 return nil, "Failed packing "..rock_file.." - "..err
56 end
57 fs.pop_dir()
58
59 return rock_file
60end
61
62local function copy_back_files(name, version, file_tree, deploy_dir, pack_dir, perms)
63 local ok, err = fs.make_dir(pack_dir)
64 if not ok then return nil, err end
65 for file, sub in pairs(file_tree) do
66 local source = dir.path(deploy_dir, file)
67 local target = dir.path(pack_dir, file)
68 if type(sub) == "table" then
69 local ok, err = copy_back_files(name, version, sub, source, target)
70 if not ok then return nil, err end
71 else
72 local versioned = path.versioned_name(source, deploy_dir, name, version)
73 if fs.exists(versioned) then
74 fs.copy(versioned, target, perms)
75 else
76 fs.copy(source, target, perms)
77 end
78 end
79 end
80 return true
81end
82
83-- @param name string: Name of package to pack.
84-- @param version string or nil: A version number may also be passed.
85-- @param tree string or nil: An optional tree to pick the package from.
86-- @return string or (nil, string): The filename of the resulting
87-- .src.rock file; or nil and an error message.
88function pack.pack_installed_rock(query, tree)
89
90 local name, version, repo, repo_url = search.pick_installed_rock(query, tree)
91 if not name then
92 return nil, version
93 end
94
95 local root = path.root_from_rocks_dir(repo_url)
96 local prefix = path.install_dir(name, version, root)
97 if not fs.exists(prefix) then
98 return nil, "'"..name.." "..version.."' does not seem to be an installed rock."
99 end
100
101 local rock_manifest, err = manif.load_rock_manifest(name, version, root)
102 if not rock_manifest then return nil, err end
103
104 local name_version = name .. "-" .. version
105 local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock")
106
107 local temp_dir = fs.make_temp_dir("pack")
108 fs.copy_contents(prefix, temp_dir)
109
110 local is_binary = false
111 if rock_manifest.lib then
112 local ok, err = copy_back_files(name, version, rock_manifest.lib, path.deploy_lib_dir(repo), dir.path(temp_dir, "lib"), "exec")
113 if not ok then return nil, "Failed copying back files: " .. err end
114 is_binary = true
115 end
116 if rock_manifest.lua then
117 local ok, err = copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read")
118 if not ok then return nil, "Failed copying back files: " .. err end
119 end
120
121 local ok, err = fs.change_dir(temp_dir)
122 if not ok then return nil, err end
123 if not is_binary and not repos.has_binaries(name, version) then
124 rock_file = rock_file:gsub("%."..cfg.arch:gsub("%-","%%-").."%.", ".all.")
125 end
126 fs.delete(rock_file)
127 ok, err = fs.zip(rock_file, unpack(fs.list_dir()))
128 if not ok then
129 return nil, "Failed packing " .. rock_file .. " - " .. err
130 end
131 fs.pop_dir()
132 fs.delete(temp_dir)
133 return rock_file
134end
135
136function pack.report_and_sign_local_file(file, err, sign)
137 if err then
138 return nil, err
139 end
140 local sigfile
141 if sign then
142 sigfile, err = signing.sign_file(file)
143 util.printout()
144 end
145 util.printout("Packed: "..file)
146 if sigfile then
147 util.printout("Signature stored in: "..sigfile)
148 end
149 if err then
150 return nil, err
151 end
152 return true
153end
154
155function pack.pack_binary_rock(name, namespace, version, sign, cmd)
156
157 -- The --pack-binary-rock option for "luarocks build" basically performs
158 -- "luarocks build" on a temporary tree and then "luarocks pack". The
159 -- alternative would require refactoring parts of luarocks.build and
160 -- luarocks.pack, which would save a few file operations: the idea would be
161 -- to shave off the final deploy steps from the build phase and the initial
162 -- collect steps from the pack phase.
163
164 local temp_dir, err = fs.make_temp_dir("luarocks-build-pack-"..dir.base_name(name))
165 if not temp_dir then
166 return nil, "Failed creating temporary directory: "..err
167 end
168 util.schedule_function(fs.delete, temp_dir)
169
170 path.use_tree(temp_dir)
171 local ok, err = cmd()
172 if not ok then
173 return nil, err
174 end
175 local rname, rversion = path.parse_name(name)
176 if not rname then
177 rname, rversion = name, version
178 end
179 local query = queries.new(rname, namespace, rversion)
180 local file, err = pack.pack_installed_rock(query, temp_dir)
181 return pack.report_and_sign_local_file(file, err, sign)
182end
183
184return pack
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua
index 731f49dd..e083f509 100644
--- a/src/luarocks/pack.lua
+++ b/src/luarocks/pack.lua
@@ -1,8 +1,7 @@
1local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local pairs = _tl_compat and _tl_compat.pairs or pairs; local table = _tl_compat and _tl_compat.table or table; local _tl_table_unpack = unpack or table.unpack
1 2
2-- Create rock files, packing sources or binaries.
3local pack = {} 3local pack = {}
4 4
5local unpack = unpack or table.unpack
6 5
7local queries = require("luarocks.queries") 6local queries = require("luarocks.queries")
8local path = require("luarocks.path") 7local path = require("luarocks.path")
@@ -16,28 +15,37 @@ local manif = require("luarocks.manif")
16local search = require("luarocks.search") 15local search = require("luarocks.search")
17local signing = require("luarocks.signing") 16local signing = require("luarocks.signing")
18 17
19--- Create a source rock. 18
20-- Packages a rockspec and its required source files in a rock 19
21-- file with the .src.rock extension, which can later be built and 20
22-- installed with the "build" command. 21
23-- @param rockspec_file string: An URL or pathname for a rockspec file. 22
24-- @return string or (nil, string): The filename of the resulting 23
25-- .src.rock file; or nil and an error message. 24
25local RockManifest = rm.RockManifest
26
27
28
29
30
31
32
33
34
26function pack.pack_source_rock(rockspec_file) 35function pack.pack_source_rock(rockspec_file)
27 assert(type(rockspec_file) == "string")
28 36
29 local rockspec, err = fetch.load_rockspec(rockspec_file) 37 local rockspec, errload = fetch.load_rockspec(rockspec_file)
30 if err then 38 if errload then
31 return nil, "Error loading rockspec: "..err 39 return nil, "Error loading rockspec: " .. errload
32 end 40 end
33 rockspec_file = rockspec.local_abs_filename 41 rockspec_file = rockspec.local_abs_filename
34 42
35 local name_version = rockspec.name .. "-" .. rockspec.version 43 local name_version = rockspec.name .. "-" .. rockspec.version
36 local rock_file = fs.absolute_name(name_version .. ".src.rock") 44 local rock_file = fs.absolute_name(name_version .. ".src.rock")
37 45
38 local temp_dir, err = fs.make_temp_dir("pack-"..name_version) 46 local temp_dir, err = fs.make_temp_dir("pack-" .. name_version)
39 if not temp_dir then 47 if not temp_dir then
40 return nil, "Failed creating temporary directory: "..err 48 return nil, "Failed creating temporary directory: " .. err
41 end 49 end
42 util.schedule_function(fs.delete, temp_dir) 50 util.schedule_function(fs.delete, temp_dir)
43 51
@@ -45,14 +53,14 @@ function pack.pack_source_rock(rockspec_file)
45 if not source_file then 53 if not source_file then
46 return nil, source_dir 54 return nil, source_dir
47 end 55 end
48 local ok, err = fs.change_dir(source_dir) 56 local ok, errchange = fs.change_dir(source_dir)
49 if not ok then return nil, err end 57 if not ok then return nil, errchange end
50 58
51 fs.delete(rock_file) 59 fs.delete(rock_file)
52 fs.copy(rockspec_file, source_dir, "read") 60 fs.copy(rockspec_file, source_dir, "read")
53 ok, err = fs.zip(rock_file, dir.base_name(rockspec_file), dir.base_name(source_file)) 61 ok, err = fs.zip(rock_file, dir.base_name(rockspec_file), dir.base_name(source_file))
54 if not ok then 62 if not ok then
55 return nil, "Failed packing "..rock_file.." - "..err 63 return nil, "Failed packing " .. rock_file .. " - " .. err
56 end 64 end
57 fs.pop_dir() 65 fs.pop_dir()
58 66
@@ -66,7 +74,7 @@ local function copy_back_files(name, version, file_tree, deploy_dir, pack_dir, p
66 local source = dir.path(deploy_dir, file) 74 local source = dir.path(deploy_dir, file)
67 local target = dir.path(pack_dir, file) 75 local target = dir.path(pack_dir, file)
68 if type(sub) == "table" then 76 if type(sub) == "table" then
69 local ok, err = copy_back_files(name, version, sub, source, target) 77 ok, err = copy_back_files(name, version, sub, source, target)
70 if not ok then return nil, err end 78 if not ok then return nil, err end
71 else 79 else
72 local versioned = path.versioned_name(source, deploy_dir, name, version) 80 local versioned = path.versioned_name(source, deploy_dir, name, version)
@@ -80,11 +88,11 @@ local function copy_back_files(name, version, file_tree, deploy_dir, pack_dir, p
80 return true 88 return true
81end 89end
82 90
83-- @param name string: Name of package to pack. 91
84-- @param version string or nil: A version number may also be passed. 92
85-- @param tree string or nil: An optional tree to pick the package from. 93
86-- @return string or (nil, string): The filename of the resulting 94
87-- .src.rock file; or nil and an error message. 95
88function pack.pack_installed_rock(query, tree) 96function pack.pack_installed_rock(query, tree)
89 97
90 local name, version, repo, repo_url = search.pick_installed_rock(query, tree) 98 local name, version, repo, repo_url = search.pick_installed_rock(query, tree)
@@ -95,36 +103,36 @@ function pack.pack_installed_rock(query, tree)
95 local root = path.root_from_rocks_dir(repo_url) 103 local root = path.root_from_rocks_dir(repo_url)
96 local prefix = path.install_dir(name, version, root) 104 local prefix = path.install_dir(name, version, root)
97 if not fs.exists(prefix) then 105 if not fs.exists(prefix) then
98 return nil, "'"..name.." "..version.."' does not seem to be an installed rock." 106 return nil, "'" .. name .. " " .. version .. "' does not seem to be an installed rock."
99 end 107 end
100 108
101 local rock_manifest, err = manif.load_rock_manifest(name, version, root) 109 local rock_manifest, err = manif.load_rock_manifest(name, version, root)
102 if not rock_manifest then return nil, err end 110 if not rock_manifest then return nil, err end
103 111
104 local name_version = name .. "-" .. version 112 local name_version = name .. "-" .. version
105 local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") 113 local rock_file = fs.absolute_name(name_version .. "." .. cfg.arch .. ".rock")
106 114
107 local temp_dir = fs.make_temp_dir("pack") 115 local temp_dir = fs.make_temp_dir("pack")
108 fs.copy_contents(prefix, temp_dir) 116 fs.copy_contents(prefix, temp_dir)
109 117
110 local is_binary = false 118 local is_binary = false
111 if rock_manifest.lib then 119 if rock_manifest.lib then
112 local ok, err = copy_back_files(name, version, rock_manifest.lib, path.deploy_lib_dir(repo), dir.path(temp_dir, "lib"), "exec") 120 local ok, err = copy_back_files(name, version, (rock_manifest.lib), path.deploy_lib_dir(repo), dir.path(temp_dir, "lib"), "exec")
113 if not ok then return nil, "Failed copying back files: " .. err end 121 if not ok then return nil, "Failed copying back files: " .. err end
114 is_binary = true 122 is_binary = true
115 end 123 end
116 if rock_manifest.lua then 124 if rock_manifest.lua then
117 local ok, err = copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read") 125 local ok, err = copy_back_files(name, version, (rock_manifest.lua), path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read")
118 if not ok then return nil, "Failed copying back files: " .. err end 126 if not ok then return nil, "Failed copying back files: " .. err end
119 end 127 end
120 128
121 local ok, err = fs.change_dir(temp_dir) 129 local ok, err = fs.change_dir(temp_dir)
122 if not ok then return nil, err end 130 if not ok then return nil, err end
123 if not is_binary and not repos.has_binaries(name, version) then 131 if not is_binary and not repos.has_binaries(name, version) then
124 rock_file = rock_file:gsub("%."..cfg.arch:gsub("%-","%%-").."%.", ".all.") 132 rock_file = rock_file:gsub("%." .. cfg.arch:gsub("%-", "%%-") .. "%.", ".all.")
125 end 133 end
126 fs.delete(rock_file) 134 fs.delete(rock_file)
127 ok, err = fs.zip(rock_file, unpack(fs.list_dir())) 135 ok, err = fs.zip(rock_file, _tl_table_unpack(fs.list_dir()))
128 if not ok then 136 if not ok then
129 return nil, "Failed packing " .. rock_file .. " - " .. err 137 return nil, "Failed packing " .. rock_file .. " - " .. err
130 end 138 end
@@ -142,9 +150,9 @@ function pack.report_and_sign_local_file(file, err, sign)
142 sigfile, err = signing.sign_file(file) 150 sigfile, err = signing.sign_file(file)
143 util.printout() 151 util.printout()
144 end 152 end
145 util.printout("Packed: "..file) 153 util.printout("Packed: " .. file)
146 if sigfile then 154 if sigfile then
147 util.printout("Signature stored in: "..sigfile) 155 util.printout("Signature stored in: " .. sigfile)
148 end 156 end
149 if err then 157 if err then
150 return nil, err 158 return nil, err
@@ -154,16 +162,16 @@ end
154 162
155function pack.pack_binary_rock(name, namespace, version, sign, cmd) 163function pack.pack_binary_rock(name, namespace, version, sign, cmd)
156 164
157 -- The --pack-binary-rock option for "luarocks build" basically performs
158 -- "luarocks build" on a temporary tree and then "luarocks pack". The
159 -- alternative would require refactoring parts of luarocks.build and
160 -- luarocks.pack, which would save a few file operations: the idea would be
161 -- to shave off the final deploy steps from the build phase and the initial
162 -- collect steps from the pack phase.
163 165
164 local temp_dir, err = fs.make_temp_dir("luarocks-build-pack-"..dir.base_name(name)) 166
167
168
169
170
171
172 local temp_dir, err = fs.make_temp_dir("luarocks-build-pack-" .. dir.base_name(name))
165 if not temp_dir then 173 if not temp_dir then
166 return nil, "Failed creating temporary directory: "..err 174 return nil, "Failed creating temporary directory: " .. err
167 end 175 end
168 util.schedule_function(fs.delete, temp_dir) 176 util.schedule_function(fs.delete, temp_dir)
169 177