diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2016-05-07 19:14:22 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2016-05-07 19:14:22 -0300 |
commit | b4ff8c72d3935f5f0f8c7d0e8739115ca39a0c59 (patch) | |
tree | bffc84a6d0f5787b52b46d8dcb50b14d435dbba9 | |
parent | e281fea83c49e301ff7bfb4af444e68d02309f5f (diff) | |
parent | d80b18dec30e60d68a5060ab4f0f053045d301b9 (diff) | |
download | luarocks-b4ff8c72d3935f5f0f8c7d0e8739115ca39a0c59.tar.gz luarocks-b4ff8c72d3935f5f0f8c7d0e8739115ca39a0c59.tar.bz2 luarocks-b4ff8c72d3935f5f0f8c7d0e8739115ca39a0c59.zip |
Merge pull request #549 from keplerproject/permissions
Set permissions explicitly when copying or moving files.
-rw-r--r-- | src/luarocks/add.lua | 2 | ||||
-rw-r--r-- | src/luarocks/build.lua | 20 | ||||
-rw-r--r-- | src/luarocks/build/builtin.lua | 19 | ||||
-rw-r--r-- | src/luarocks/cfg.lua | 2 | ||||
-rw-r--r-- | src/luarocks/download.lua | 3 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 23 | ||||
-rw-r--r-- | src/luarocks/fs/unix.lua | 4 | ||||
-rw-r--r-- | src/luarocks/pack.lua | 12 | ||||
-rw-r--r-- | src/luarocks/repos.lua | 12 | ||||
-rw-r--r-- | src/luarocks/unpack.lua | 3 |
10 files changed, 60 insertions, 40 deletions
diff --git a/src/luarocks/add.lua b/src/luarocks/add.lua index 81adff9b..ccd303e6 100644 --- a/src/luarocks/add.lua +++ b/src/luarocks/add.lua | |||
@@ -54,7 +54,7 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
54 | if fs.exists(rockfile) then | 54 | if fs.exists(rockfile) then |
55 | util.printout("Copying file "..rockfile.." to "..local_cache.."...") | 55 | util.printout("Copying file "..rockfile.." to "..local_cache.."...") |
56 | local absolute = fs.absolute_name(rockfile) | 56 | local absolute = fs.absolute_name(rockfile) |
57 | fs.copy(absolute, local_cache) | 57 | fs.copy(absolute, local_cache, cfg.perm_read) |
58 | table.insert(files, dir.base_name(absolute)) | 58 | table.insert(files, dir.base_name(absolute)) |
59 | else | 59 | else |
60 | util.printerr("File "..rockfile.." not found") | 60 | util.printerr("File "..rockfile.." not found") |
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 68f20264..bdc3b57a 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -53,9 +53,11 @@ or the name of a rock to be fetched from a repository. | |||
53 | -- @param location string: The base directory files should be copied to. | 53 | -- @param location string: The base directory files should be copied to. |
54 | -- @param is_module_path boolean: True if string keys in files should be | 54 | -- @param is_module_path boolean: True if string keys in files should be |
55 | -- interpreted as dotted module paths. | 55 | -- interpreted as dotted module paths. |
56 | -- @param perms string: Permissions of the newly created files installed. | ||
57 | -- Directories are always created with the default permissions. | ||
56 | -- @return boolean or (nil, string): True if succeeded or | 58 | -- @return boolean or (nil, string): True if succeeded or |
57 | -- nil and an error message. | 59 | -- nil and an error message. |
58 | local function install_files(files, location, is_module_path) | 60 | local function install_files(files, location, is_module_path, perms) |
59 | assert(type(files) == "table" or not files) | 61 | assert(type(files) == "table" or not files) |
60 | assert(type(location) == "string") | 62 | assert(type(location) == "string") |
61 | if files then | 63 | if files then |
@@ -85,7 +87,7 @@ local function install_files(files, location, is_module_path) | |||
85 | local ok, err = fs.make_dir(dest) | 87 | local ok, err = fs.make_dir(dest) |
86 | if not ok then return nil, err end | 88 | if not ok then return nil, err end |
87 | end | 89 | end |
88 | local ok = fs.copy(dir.path(file), dir.path(dest, filename)) | 90 | local ok = fs.copy(dir.path(file), dir.path(dest, filename), perms) |
89 | if not ok then | 91 | if not ok then |
90 | return nil, "Failed copying "..file | 92 | return nil, "Failed copying "..file |
91 | end | 93 | end |
@@ -142,7 +144,7 @@ local function install_default_docs(name, version) | |||
142 | fs.make_dir(dest) | 144 | fs.make_dir(dest) |
143 | has_dir = true | 145 | has_dir = true |
144 | end | 146 | end |
145 | fs.copy(file, dest) | 147 | fs.copy(file, dest, cfg.perm_read) |
146 | break | 148 | break |
147 | end | 149 | end |
148 | end | 150 | end |
@@ -220,10 +222,10 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m | |||
220 | end | 222 | end |
221 | 223 | ||
222 | local dirs = { | 224 | local dirs = { |
223 | lua = { name = path.lua_dir(name, version), is_module_path = true }, | 225 | lua = { name = path.lua_dir(name, version), is_module_path = true, perms = cfg.perm_read }, |
224 | lib = { name = path.lib_dir(name, version), is_module_path = true }, | 226 | lib = { name = path.lib_dir(name, version), is_module_path = true, perms = cfg.perm_exec }, |
225 | conf = { name = path.conf_dir(name, version), is_module_path = false }, | 227 | conf = { name = path.conf_dir(name, version), is_module_path = false, perms = cfg.perm_read }, |
226 | bin = { name = path.bin_dir(name, version), is_module_path = false }, | 228 | bin = { name = path.bin_dir(name, version), is_module_path = false, perms = cfg.perm_exec }, |
227 | } | 229 | } |
228 | 230 | ||
229 | for _, d in pairs(dirs) do | 231 | for _, d in pairs(dirs) do |
@@ -270,7 +272,7 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m | |||
270 | 272 | ||
271 | if build_spec.install then | 273 | if build_spec.install then |
272 | for id, install_dir in pairs(dirs) do | 274 | for id, install_dir in pairs(dirs) do |
273 | ok, err = install_files(build_spec.install[id], install_dir.name, install_dir.is_module_path) | 275 | ok, err = install_files(build_spec.install[id], install_dir.name, install_dir.is_module_path, install_dir.perms) |
274 | if not ok then | 276 | if not ok then |
275 | return nil, err | 277 | return nil, err |
276 | end | 278 | end |
@@ -308,7 +310,7 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m | |||
308 | 310 | ||
309 | fs.pop_dir() | 311 | fs.pop_dir() |
310 | 312 | ||
311 | fs.copy(rockspec.local_filename, path.rockspec_file(name, version)) | 313 | fs.copy(rockspec.local_filename, path.rockspec_file(name, version), cfg.perm_read) |
312 | if need_to_fetch then | 314 | if need_to_fetch then |
313 | fs.pop_dir() | 315 | fs.pop_dir() |
314 | end | 316 | end |
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index afd05954..b6062bd7 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
@@ -175,7 +175,8 @@ function builtin.run(rockspec) | |||
175 | end | 175 | end |
176 | 176 | ||
177 | local ok, err | 177 | local ok, err |
178 | local built_modules = {} | 178 | local lua_modules = {} |
179 | local lib_modules = {} | ||
179 | local luadir = path.lua_dir(rockspec.name, rockspec.version) | 180 | local luadir = path.lua_dir(rockspec.name, rockspec.version) |
180 | local libdir = path.lib_dir(rockspec.name, rockspec.version) | 181 | local libdir = path.lib_dir(rockspec.name, rockspec.version) |
181 | --TODO EXEWRAPPER | 182 | --TODO EXEWRAPPER |
@@ -215,7 +216,7 @@ function builtin.run(rockspec) | |||
215 | end | 216 | end |
216 | end | 217 | end |
217 | local dest = dir.path(luadir, moddir, filename) | 218 | local dest = dir.path(luadir, moddir, filename) |
218 | built_modules[info] = dest | 219 | lua_modules[info] = dest |
219 | else | 220 | else |
220 | info = {info} | 221 | info = {info} |
221 | end | 222 | end |
@@ -242,18 +243,20 @@ function builtin.run(rockspec) | |||
242 | ok, err = fs.make_dir(moddir) | 243 | ok, err = fs.make_dir(moddir) |
243 | if not ok then return nil, err end | 244 | if not ok then return nil, err end |
244 | end | 245 | end |
245 | built_modules[module_name] = dir.path(libdir, module_name) | 246 | lib_modules[module_name] = dir.path(libdir, module_name) |
246 | ok = compile_library(module_name, objects, info.libraries, info.libdirs, name) | 247 | ok = compile_library(module_name, objects, info.libraries, info.libdirs, name) |
247 | if not ok then | 248 | if not ok then |
248 | return nil, "Failed compiling module "..module_name | 249 | return nil, "Failed compiling module "..module_name |
249 | end | 250 | end |
250 | end | 251 | end |
251 | end | 252 | end |
252 | for name, dest in pairs(built_modules) do | 253 | for _, mods in ipairs({{ tbl = lua_modules, perms = cfg.perm_read }, { tbl = lib_modules, perms = cfg.perm_exec }}) do |
253 | fs.make_dir(dir.dir_name(dest)) | 254 | for name, dest in pairs(mods.tbl) do |
254 | ok, err = fs.copy(name, dest) | 255 | fs.make_dir(dir.dir_name(dest)) |
255 | if not ok then | 256 | ok, err = fs.copy(name, dest, mods.perms) |
256 | return nil, "Failed installing "..name.." in "..dest..": "..err | 257 | if not ok then |
258 | return nil, "Failed installing "..name.." in "..dest..": "..err | ||
259 | end | ||
257 | end | 260 | end |
258 | end | 261 | end |
259 | if fs.is_dir("lua") then | 262 | if fs.is_dir("lua") then |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 591a456a..9b1c5902 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -306,6 +306,8 @@ local defaults = { | |||
306 | hooks_enabled = true, | 306 | hooks_enabled = true, |
307 | deps_mode = "one", | 307 | deps_mode = "one", |
308 | check_certificates = false, | 308 | check_certificates = false, |
309 | perm_read = "0644", | ||
310 | perm_exec = "0755", | ||
309 | 311 | ||
310 | lua_modules_path = "/share/lua/"..cfg.lua_version, | 312 | lua_modules_path = "/share/lua/"..cfg.lua_version, |
311 | lib_modules_path = "/lib/lua/"..cfg.lua_version, | 313 | lib_modules_path = "/lib/lua/"..cfg.lua_version, |
diff --git a/src/luarocks/download.lua b/src/luarocks/download.lua index 090f49aa..6d95d8fd 100644 --- a/src/luarocks/download.lua +++ b/src/luarocks/download.lua | |||
@@ -11,6 +11,7 @@ local fetch = require("luarocks.fetch") | |||
11 | local search = require("luarocks.search") | 11 | local search = require("luarocks.search") |
12 | local fs = require("luarocks.fs") | 12 | local fs = require("luarocks.fs") |
13 | local dir = require("luarocks.dir") | 13 | local dir = require("luarocks.dir") |
14 | local cfg = require("luarocks.cfg") | ||
14 | 15 | ||
15 | download.help_summary = "Download a specific rock file from a rocks server." | 16 | download.help_summary = "Download a specific rock file from a rocks server." |
16 | download.help_arguments = "[--all] [--arch=<arch> | --source | --rockspec] [<name> [<version>]]" | 17 | download.help_arguments = "[--all] [--arch=<arch> | --source | --rockspec] [<name> [<version>]]" |
@@ -25,7 +26,7 @@ download.help = [[ | |||
25 | local function get_file(filename) | 26 | local function get_file(filename) |
26 | local protocol, pathname = dir.split_url(filename) | 27 | local protocol, pathname = dir.split_url(filename) |
27 | if protocol == "file" then | 28 | if protocol == "file" then |
28 | local ok, err = fs.copy(pathname, fs.current_dir()) | 29 | local ok, err = fs.copy(pathname, fs.current_dir(), cfg.perm_read) |
29 | if ok then | 30 | if ok then |
30 | return pathname | 31 | return pathname |
31 | else | 32 | else |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 483b3e3c..a31cbb4e 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -255,6 +255,10 @@ function fs_lua.make_dir(directory) | |||
255 | if not ok then | 255 | if not ok then |
256 | return false, err | 256 | return false, err |
257 | end | 257 | end |
258 | ok, err = fs.chmod(path, cfg.perm_exec) | ||
259 | if not ok then | ||
260 | return false, err | ||
261 | end | ||
258 | elseif mode ~= "directory" then | 262 | elseif mode ~= "directory" then |
259 | return false, path.." is not a directory" | 263 | return false, path.." is not a directory" |
260 | end | 264 | end |
@@ -320,12 +324,14 @@ end | |||
320 | -- Assumes paths are normalized. | 324 | -- Assumes paths are normalized. |
321 | -- @param src string: Pathname of source | 325 | -- @param src string: Pathname of source |
322 | -- @param dest string: Pathname of destination | 326 | -- @param dest string: Pathname of destination |
327 | -- @param perms string or nil: Optional permissions. | ||
328 | -- If not given, permissions of the source are copied over to the destination. | ||
323 | -- @return boolean or (boolean, string): true on success, false on failure | 329 | -- @return boolean or (boolean, string): true on success, false on failure |
324 | local function recursive_copy(src, dest) | 330 | local function recursive_copy(src, dest, perms) |
325 | local srcmode = lfs.attributes(src, "mode") | 331 | local srcmode = lfs.attributes(src, "mode") |
326 | 332 | ||
327 | if srcmode == "file" then | 333 | if srcmode == "file" then |
328 | local ok = fs.copy(src, dest) | 334 | local ok = fs.copy(src, dest, perms) |
329 | if not ok then return false end | 335 | if not ok then return false end |
330 | elseif srcmode == "directory" then | 336 | elseif srcmode == "directory" then |
331 | local subdir = dir.path(dest, dir.base_name(src)) | 337 | local subdir = dir.path(dest, dir.base_name(src)) |
@@ -333,7 +339,7 @@ local function recursive_copy(src, dest) | |||
333 | if not ok then return nil, err end | 339 | if not ok then return nil, err end |
334 | for file in lfs.dir(src) do | 340 | for file in lfs.dir(src) do |
335 | if file ~= "." and file ~= ".." then | 341 | if file ~= "." and file ~= ".." then |
336 | local ok = recursive_copy(dir.path(src, file), subdir) | 342 | local ok = recursive_copy(dir.path(src, file), subdir, perms) |
337 | if not ok then return false end | 343 | if not ok then return false end |
338 | end | 344 | end |
339 | end | 345 | end |
@@ -344,9 +350,10 @@ end | |||
344 | --- Recursively copy the contents of a directory. | 350 | --- Recursively copy the contents of a directory. |
345 | -- @param src string: Pathname of source | 351 | -- @param src string: Pathname of source |
346 | -- @param dest string: Pathname of destination | 352 | -- @param dest string: Pathname of destination |
353 | -- @param perms string or nil: Optional permissions. | ||
347 | -- @return boolean or (boolean, string): true on success, false on failure, | 354 | -- @return boolean or (boolean, string): true on success, false on failure, |
348 | -- plus an error message. | 355 | -- plus an error message. |
349 | function fs_lua.copy_contents(src, dest) | 356 | function fs_lua.copy_contents(src, dest, perms) |
350 | assert(src and dest) | 357 | assert(src and dest) |
351 | src = dir.normalize(src) | 358 | src = dir.normalize(src) |
352 | dest = dir.normalize(dest) | 359 | dest = dir.normalize(dest) |
@@ -354,7 +361,7 @@ function fs_lua.copy_contents(src, dest) | |||
354 | 361 | ||
355 | for file in lfs.dir(src) do | 362 | for file in lfs.dir(src) do |
356 | if file ~= "." and file ~= ".." then | 363 | if file ~= "." and file ~= ".." then |
357 | local ok = recursive_copy(dir.path(src, file), dest) | 364 | local ok = recursive_copy(dir.path(src, file), dest, perms) |
358 | if not ok then | 365 | if not ok then |
359 | return false, "Failed copying "..src.." to "..dest | 366 | return false, "Failed copying "..src.." to "..dest |
360 | end | 367 | end |
@@ -799,14 +806,16 @@ end | |||
799 | --- Move a file. | 806 | --- Move a file. |
800 | -- @param src string: Pathname of source | 807 | -- @param src string: Pathname of source |
801 | -- @param dest string: Pathname of destination | 808 | -- @param dest string: Pathname of destination |
809 | -- @param perms string or nil: Permissions for destination file, | ||
810 | -- or nil to use the source filename permissions. | ||
802 | -- @return boolean or (boolean, string): true on success, false on failure, | 811 | -- @return boolean or (boolean, string): true on success, false on failure, |
803 | -- plus an error message. | 812 | -- plus an error message. |
804 | function fs_lua.move(src, dest) | 813 | function fs_lua.move(src, dest, perms) |
805 | assert(src and dest) | 814 | assert(src and dest) |
806 | if fs.exists(dest) and not fs.is_dir(dest) then | 815 | if fs.exists(dest) and not fs.is_dir(dest) then |
807 | return false, "File already exists: "..dest | 816 | return false, "File already exists: "..dest |
808 | end | 817 | end |
809 | local ok, err = fs.copy(src, dest) | 818 | local ok, err = fs.copy(src, dest, perms) |
810 | if not ok then | 819 | if not ok then |
811 | return false, err | 820 | return false, err |
812 | end | 821 | end |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 570b26e4..e2cc825b 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
@@ -66,7 +66,7 @@ function unix.wrap_script(file, dest, name, version) | |||
66 | local addctx = "local k,l,_=pcall(require,"..util.LQ("luarocks.loader")..") _=k and l.add_context("..util.LQ(name)..","..util.LQ(version)..")" | 66 | local addctx = "local k,l,_=pcall(require,"..util.LQ("luarocks.loader")..") _=k and l.add_context("..util.LQ(name)..","..util.LQ(version)..")" |
67 | wrapper:write('exec '..fs.Q(lua)..' -e '..fs.Q(ppaths)..' -e '..fs.Q(addctx)..' '..fs.Q(file)..' "$@"\n') | 67 | wrapper:write('exec '..fs.Q(lua)..' -e '..fs.Q(ppaths)..' -e '..fs.Q(addctx)..' '..fs.Q(file)..' "$@"\n') |
68 | wrapper:close() | 68 | wrapper:close() |
69 | if fs.chmod(wrapname, "0755") then | 69 | if fs.chmod(wrapname, cfg.perm_exec) then |
70 | return true | 70 | return true |
71 | else | 71 | else |
72 | return nil, "Could not make "..wrapname.." executable." | 72 | return nil, "Could not make "..wrapname.." executable." |
@@ -96,7 +96,7 @@ function unix.is_actual_binary(filename) | |||
96 | end | 96 | end |
97 | 97 | ||
98 | function unix.copy_binary(filename, dest) | 98 | function unix.copy_binary(filename, dest) |
99 | return fs.copy(filename, dest, "0755") | 99 | return fs.copy(filename, dest, cfg.perm_exec) |
100 | end | 100 | end |
101 | 101 | ||
102 | --- Move a file on top of the other. | 102 | --- Move a file on top of the other. |
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index c73d66ab..e4498f5a 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua | |||
@@ -53,7 +53,7 @@ function pack.pack_source_rock(rockspec_file) | |||
53 | if not ok then return nil, err end | 53 | if not ok then return nil, err end |
54 | 54 | ||
55 | fs.delete(rock_file) | 55 | fs.delete(rock_file) |
56 | fs.copy(rockspec_file, source_dir) | 56 | fs.copy(rockspec_file, source_dir, cfg.perm_read) |
57 | if not fs.zip(rock_file, dir.base_name(rockspec_file), dir.base_name(source_file)) then | 57 | if not fs.zip(rock_file, dir.base_name(rockspec_file), dir.base_name(source_file)) then |
58 | return nil, "Failed packing "..rock_file | 58 | return nil, "Failed packing "..rock_file |
59 | end | 59 | end |
@@ -62,7 +62,7 @@ function pack.pack_source_rock(rockspec_file) | |||
62 | return rock_file | 62 | return rock_file |
63 | end | 63 | end |
64 | 64 | ||
65 | local function copy_back_files(name, version, file_tree, deploy_dir, pack_dir) | 65 | local function copy_back_files(name, version, file_tree, deploy_dir, pack_dir, perms) |
66 | local ok, err = fs.make_dir(pack_dir) | 66 | local ok, err = fs.make_dir(pack_dir) |
67 | if not ok then return nil, err end | 67 | if not ok then return nil, err end |
68 | for file, sub in pairs(file_tree) do | 68 | for file, sub in pairs(file_tree) do |
@@ -74,9 +74,9 @@ local function copy_back_files(name, version, file_tree, deploy_dir, pack_dir) | |||
74 | else | 74 | else |
75 | local versioned = path.versioned_name(source, deploy_dir, name, version) | 75 | local versioned = path.versioned_name(source, deploy_dir, name, version) |
76 | if fs.exists(versioned) then | 76 | if fs.exists(versioned) then |
77 | fs.copy(versioned, target) | 77 | fs.copy(versioned, target, perms) |
78 | else | 78 | else |
79 | fs.copy(source, target) | 79 | fs.copy(source, target, perms) |
80 | end | 80 | end |
81 | end | 81 | end |
82 | end | 82 | end |
@@ -135,12 +135,12 @@ local function do_pack_binary_rock(name, version) | |||
135 | 135 | ||
136 | local is_binary = false | 136 | local is_binary = false |
137 | if rock_manifest.lib then | 137 | if rock_manifest.lib then |
138 | local ok, err = copy_back_files(name, version, rock_manifest.lib, path.deploy_lib_dir(root), dir.path(temp_dir, "lib")) | 138 | local ok, err = copy_back_files(name, version, rock_manifest.lib, path.deploy_lib_dir(root), dir.path(temp_dir, "lib"), cfg.perm_exec) |
139 | if not ok then return nil, "Failed copying back files: " .. err end | 139 | if not ok then return nil, "Failed copying back files: " .. err end |
140 | is_binary = true | 140 | is_binary = true |
141 | end | 141 | end |
142 | if rock_manifest.lua then | 142 | if rock_manifest.lua then |
143 | local ok, err = copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(root), dir.path(temp_dir, "lua")) | 143 | local ok, err = copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(root), dir.path(temp_dir, "lua"), cfg.perm_read) |
144 | if not ok then return nil, "Failed copying back files: " .. err end | 144 | if not ok then return nil, "Failed copying back files: " .. err end |
145 | end | 145 | end |
146 | 146 | ||
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 17456593..66b1377f 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
@@ -199,9 +199,6 @@ function repos.deploy_files(name, version, wrap_bin_scripts) | |||
199 | 199 | ||
200 | local function deploy_file_tree(file_tree, path_fn, deploy_dir, move_fn) | 200 | local function deploy_file_tree(file_tree, path_fn, deploy_dir, move_fn) |
201 | local source_dir = path_fn(name, version) | 201 | local source_dir = path_fn(name, version) |
202 | if not move_fn then | ||
203 | move_fn = fs.move | ||
204 | end | ||
205 | return recurse_rock_manifest_tree(file_tree, | 202 | return recurse_rock_manifest_tree(file_tree, |
206 | function(parent_path, parent_module, file) | 203 | function(parent_path, parent_module, file) |
207 | local source = dir.path(source_dir, parent_path, file) | 204 | local source = dir.path(source_dir, parent_path, file) |
@@ -239,11 +236,16 @@ function repos.deploy_files(name, version, wrap_bin_scripts) | |||
239 | local move_bin_fn = wrap_bin_scripts and install_binary or fs.copy_binary | 236 | local move_bin_fn = wrap_bin_scripts and install_binary or fs.copy_binary |
240 | ok, err = deploy_file_tree(rock_manifest.bin, path.bin_dir, cfg.deploy_bin_dir, move_bin_fn) | 237 | ok, err = deploy_file_tree(rock_manifest.bin, path.bin_dir, cfg.deploy_bin_dir, move_bin_fn) |
241 | end | 238 | end |
239 | local function make_mover(perms) | ||
240 | return function (src, dest) | ||
241 | return fs.move(src, dest, perms) | ||
242 | end | ||
243 | end | ||
242 | if ok and rock_manifest.lua then | 244 | if ok and rock_manifest.lua then |
243 | ok, err = deploy_file_tree(rock_manifest.lua, path.lua_dir, cfg.deploy_lua_dir) | 245 | ok, err = deploy_file_tree(rock_manifest.lua, path.lua_dir, cfg.deploy_lua_dir, make_mover(cfg.perm_read)) |
244 | end | 246 | end |
245 | if ok and rock_manifest.lib then | 247 | if ok and rock_manifest.lib then |
246 | ok, err = deploy_file_tree(rock_manifest.lib, path.lib_dir, cfg.deploy_lib_dir) | 248 | ok, err = deploy_file_tree(rock_manifest.lib, path.lib_dir, cfg.deploy_lib_dir, make_mover(cfg.perm_exec)) |
247 | end | 249 | end |
248 | return ok, err | 250 | return ok, err |
249 | end | 251 | end |
diff --git a/src/luarocks/unpack.lua b/src/luarocks/unpack.lua index a889bac5..d90f0571 100644 --- a/src/luarocks/unpack.lua +++ b/src/luarocks/unpack.lua | |||
@@ -10,6 +10,7 @@ local fs = require("luarocks.fs") | |||
10 | local util = require("luarocks.util") | 10 | local util = require("luarocks.util") |
11 | local build = require("luarocks.build") | 11 | local build = require("luarocks.build") |
12 | local dir = require("luarocks.dir") | 12 | local dir = require("luarocks.dir") |
13 | local cfg = require("luarocks.cfg") | ||
13 | 14 | ||
14 | unpack.help_summary = "Unpack the contents of a rock." | 15 | unpack.help_summary = "Unpack the contents of a rock." |
15 | unpack.help_arguments = "[--force] {<rock>|<name> [<version>]}" | 16 | unpack.help_arguments = "[--force] {<rock>|<name> [<version>]}" |
@@ -128,7 +129,7 @@ local function run_unpacker(file, force) | |||
128 | end | 129 | end |
129 | if kind == "src" or kind == "rockspec" then | 130 | if kind == "src" or kind == "rockspec" then |
130 | if rockspec.source.dir ~= "." then | 131 | if rockspec.source.dir ~= "." then |
131 | local ok = fs.copy(rockspec.local_filename, rockspec.source.dir) | 132 | local ok = fs.copy(rockspec.local_filename, rockspec.source.dir, cfg.perm_read) |
132 | if not ok then | 133 | if not ok then |
133 | return nil, "Failed copying unpacked rockspec into unpacked source directory." | 134 | return nil, "Failed copying unpacked rockspec into unpacked source directory." |
134 | end | 135 | end |