diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2011-10-24 01:05:13 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-10-24 01:05:13 -0200 |
| commit | 9534e4c10af1b0a4f605b616b9d1ba8399d36ce0 (patch) | |
| tree | b096c76af0832405a52fccc62a90e10d2da01ee9 /src | |
| parent | 8728bd989c646d3e36ed68a0196a93dd21287dd5 (diff) | |
| download | luarocks-9534e4c10af1b0a4f605b616b9d1ba8399d36ce0.tar.gz luarocks-9534e4c10af1b0a4f605b616b9d1ba8399d36ce0.tar.bz2 luarocks-9534e4c10af1b0a4f605b616b9d1ba8399d36ce0.zip | |
force executable permissions when copying entries into bin/
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fs/lua.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/fs/unix.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/fs/unix/tools.lua | 13 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 1a7e4eff..a286ca50 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
| @@ -231,9 +231,11 @@ end | |||
| 231 | --- Copy a file. | 231 | --- Copy a file. |
| 232 | -- @param src string: Pathname of source | 232 | -- @param src string: Pathname of source |
| 233 | -- @param dest string: Pathname of destination | 233 | -- @param dest string: Pathname of destination |
| 234 | -- @param perms string or nil: Permissions for destination file, | ||
| 235 | -- or nil to use the source filename permissions | ||
| 234 | -- @return boolean or (boolean, string): true on success, false on failure, | 236 | -- @return boolean or (boolean, string): true on success, false on failure, |
| 235 | -- plus an error message. | 237 | -- plus an error message. |
| 236 | function copy(src, dest) | 238 | function copy(src, dest, perms) |
| 237 | assert(src and dest) | 239 | assert(src and dest) |
| 238 | src = normalize(src) | 240 | src = normalize(src) |
| 239 | dest = normalize(dest) | 241 | dest = normalize(dest) |
| @@ -241,7 +243,7 @@ function copy(src, dest) | |||
| 241 | if destmode == "directory" then | 243 | if destmode == "directory" then |
| 242 | dest = dir.path(dest, dir.base_name(src)) | 244 | dest = dir.path(dest, dir.base_name(src)) |
| 243 | end | 245 | end |
| 244 | local perms = fs.get_permissions(src) | 246 | if not perms then perms = fs.get_permissions(src) end |
| 245 | local src_h, err = io.open(src, "rb") | 247 | local src_h, err = io.open(src, "rb") |
| 246 | if not src_h then return nil, err end | 248 | if not src_h then return nil, err end |
| 247 | local dest_h, err = io.open(dest, "wb+") | 249 | local dest_h, err = io.open(dest, "wb+") |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 0930cadb..844a6fb0 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
| @@ -126,5 +126,5 @@ function is_actual_binary(filename) | |||
| 126 | end | 126 | end |
| 127 | 127 | ||
| 128 | function copy_binary(filename, dest) | 128 | function copy_binary(filename, dest) |
| 129 | return fs.copy(filename, dest) | 129 | return fs.copy(filename, dest, "0755") |
| 130 | end | 130 | end |
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index d1722f4b..73f01518 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
| @@ -91,11 +91,22 @@ end | |||
| 91 | --- Copy a file. | 91 | --- Copy a file. |
| 92 | -- @param src string: Pathname of source | 92 | -- @param src string: Pathname of source |
| 93 | -- @param dest string: Pathname of destination | 93 | -- @param dest string: Pathname of destination |
| 94 | -- @param perms string or nil: Permissions for destination file, | ||
| 94 | -- @return boolean or (boolean, string): true on success, false on failure, | 95 | -- @return boolean or (boolean, string): true on success, false on failure, |
| 95 | -- plus an error message. | 96 | -- plus an error message. |
| 96 | function copy(src, dest) | 97 | function copy(src, dest, perm) |
| 97 | assert(src and dest) | 98 | assert(src and dest) |
| 98 | if fs.execute(vars.CP, src, dest) then | 99 | if fs.execute(vars.CP, src, dest) then |
| 100 | if perm then | ||
| 101 | if fs.is_dir(dest) then | ||
| 102 | dest = dir.path(dest, dir.base_name(src)) | ||
| 103 | end | ||
| 104 | if fs.execute(vars.CHMOD, perm, dest) then | ||
| 105 | return true | ||
| 106 | else | ||
| 107 | return false, "Failed setting permissions of "..dest | ||
| 108 | end | ||
| 109 | end | ||
| 99 | return true | 110 | return true |
| 100 | else | 111 | else |
| 101 | return false, "Failed copying "..src.." to "..dest | 112 | return false, "Failed copying "..src.." to "..dest |
