diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2010-09-09 16:03:13 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2010-09-09 16:03:13 -0300 |
| commit | 569ab48390725c2d87f9a89cdeb47bae3fc2cd46 (patch) | |
| tree | c475a140fc085ff0714f7e9f032d7a4230a31a44 /src | |
| parent | b6cfc996eb570cdcab1ca4d4c3e80c851aef7d1e (diff) | |
| download | luarocks-569ab48390725c2d87f9a89cdeb47bae3fc2cd46.tar.gz luarocks-569ab48390725c2d87f9a89cdeb47bae3fc2cd46.tar.bz2 luarocks-569ab48390725c2d87f9a89cdeb47bae3fc2cd46.zip | |
Preserve permissions when copying files
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cfg.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/fs/lua.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/fs/unix.lua | 1 | ||||
| -rw-r--r-- | src/luarocks/fs/unix/tools.lua | 9 | ||||
| -rw-r--r-- | src/luarocks/fs/win32.lua | 8 |
5 files changed, 25 insertions, 1 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 67cd17b7..45c73bf6 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -63,9 +63,11 @@ end | |||
| 63 | if system == "FreeBSD" then | 63 | if system == "FreeBSD" then |
| 64 | detected.unix = true | 64 | detected.unix = true |
| 65 | detected.freebsd = true | 65 | detected.freebsd = true |
| 66 | detected.bsd = true | ||
| 66 | elseif system == "Darwin" then | 67 | elseif system == "Darwin" then |
| 67 | detected.unix = true | 68 | detected.unix = true |
| 68 | detected.macosx = true | 69 | detected.macosx = true |
| 70 | detected.bsd = true | ||
| 69 | elseif system == "Linux" then | 71 | elseif system == "Linux" then |
| 70 | detected.unix = true | 72 | detected.unix = true |
| 71 | detected.linux = true | 73 | detected.linux = true |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index cd0a31e0..70df65be 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
| @@ -230,6 +230,7 @@ function copy(src, dest) | |||
| 230 | if destmode == "directory" then | 230 | if destmode == "directory" then |
| 231 | dest = dir.path(dest, dir.base_name(src)) | 231 | dest = dir.path(dest, dir.base_name(src)) |
| 232 | end | 232 | end |
| 233 | local perms = fs.get_permissions(src) | ||
| 233 | local src_h, err = io.open(src, "rb") | 234 | local src_h, err = io.open(src, "rb") |
| 234 | if not src_h then return nil, err end | 235 | if not src_h then return nil, err end |
| 235 | local dest_h, err = io.open(dest, "wb+") | 236 | local dest_h, err = io.open(dest, "wb+") |
| @@ -241,6 +242,7 @@ function copy(src, dest) | |||
| 241 | end | 242 | end |
| 242 | src_h:close() | 243 | src_h:close() |
| 243 | dest_h:close() | 244 | dest_h:close() |
| 245 | fs.chmod(dest, perms) | ||
| 244 | return true | 246 | return true |
| 245 | end | 247 | end |
| 246 | 248 | ||
| @@ -571,6 +573,10 @@ function chmod(file, mode) | |||
| 571 | return err == 0 | 573 | return err == 0 |
| 572 | end | 574 | end |
| 573 | 575 | ||
| 576 | function get_permissions(file) | ||
| 577 | return posix.stat(file, "mode") | ||
| 578 | end | ||
| 579 | |||
| 574 | end | 580 | end |
| 575 | 581 | ||
| 576 | --------------------------------------------------------------------- | 582 | --------------------------------------------------------------------- |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 94a3ad4e..f2290412 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
| @@ -122,4 +122,3 @@ end | |||
| 122 | function copy_binary(filename, dest) | 122 | function copy_binary(filename, dest) |
| 123 | return fs.copy(filename, dest) | 123 | return fs.copy(filename, dest) |
| 124 | end | 124 | end |
| 125 | |||
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index 33dbc489..2bfa7c3e 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
| @@ -343,3 +343,12 @@ function unpack_archive(archive) | |||
| 343 | end | 343 | end |
| 344 | return true | 344 | return true |
| 345 | end | 345 | end |
| 346 | |||
| 347 | function get_permissions(filename) | ||
| 348 | local ret | ||
| 349 | local flag = cfg.is_platform("bsd") and "-f '%A'" or "-c '%a'" | ||
| 350 | local pipe = io.popen("stat "..flag.." "..fs.Q(filename)) | ||
| 351 | ret = pipe:read("*l") | ||
| 352 | pipe:close() | ||
| 353 | return ret | ||
| 354 | end | ||
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index d87ad90d..44740850 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
| @@ -95,3 +95,11 @@ function copy_binary(filename, dest) | |||
| 95 | end | 95 | end |
| 96 | return true | 96 | return true |
| 97 | end | 97 | end |
| 98 | |||
| 99 | function chmod(filename, mode) | ||
| 100 | return true | ||
| 101 | end | ||
| 102 | |||
| 103 | function get_permissions(filename) | ||
| 104 | return "" | ||
| 105 | end | ||
