diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/fs/lua.lua | 19 | ||||
-rw-r--r-- | src/luarocks/fs/unix.lua | 34 | ||||
-rw-r--r-- | src/luarocks/fs/unix/tools.lua | 2 |
3 files changed, 22 insertions, 33 deletions
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index d75bb476..1cae25f4 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -578,7 +578,26 @@ end | |||
578 | 578 | ||
579 | if posix_ok then | 579 | if posix_ok then |
580 | 580 | ||
581 | local octal_to_rwx = { | ||
582 | ["0"] = "---", | ||
583 | ["1"] = "--x", | ||
584 | ["2"] = "-w-", | ||
585 | ["3"] = "-wx", | ||
586 | ["4"] = "r--", | ||
587 | ["5"] = "r-x", | ||
588 | ["6"] = "rw-", | ||
589 | ["7"] = "rwx", | ||
590 | } | ||
591 | |||
581 | function chmod(file, mode) | 592 | function chmod(file, mode) |
593 | -- LuaPosix (as of 5.1.15) does not support octal notation... | ||
594 | if mode:sub(1,1) == "0" then | ||
595 | local new_mode = {} | ||
596 | for c in mode:sub(2):gmatch(".") do | ||
597 | table.insert(new_mode, octal_to_rwx[c]) | ||
598 | end | ||
599 | mode = table.concat(new_mode) | ||
600 | end | ||
582 | local err = posix.chmod(file, mode) | 601 | local err = posix.chmod(file, mode) |
583 | return err == 0 | 602 | return err == 0 |
584 | end | 603 | end |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 262cb3d0..979fd166 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
@@ -54,7 +54,7 @@ function wrap_script(file, dest) | |||
54 | wrapper:write('export LUA_PATH LUA_CPATH\n') | 54 | wrapper:write('export LUA_PATH LUA_CPATH\n') |
55 | wrapper:write('exec "'..dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)..'" -lluarocks.loader "'..file..'" "$@"\n') | 55 | wrapper:write('exec "'..dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)..'" -lluarocks.loader "'..file..'" "$@"\n') |
56 | wrapper:close() | 56 | wrapper:close() |
57 | if fs.execute("chmod +x",wrapname) then | 57 | if fs.chmod(wrapname, "0755") then |
58 | return true | 58 | return true |
59 | else | 59 | else |
60 | return nil, "Could not make "..wrapname.." executable." | 60 | return nil, "Could not make "..wrapname.." executable." |
@@ -74,35 +74,6 @@ function is_actual_binary(filename) | |||
74 | if file then | 74 | if file then |
75 | local found = false | 75 | local found = false |
76 | local first = file:read() | 76 | local first = file:read() |
77 | if first:match("#!.*lua") then | ||
78 | found = true | ||
79 | elseif first:match("#!/bin/sh") then | ||
80 | local line = file:read() | ||
81 | line = file:read() | ||
82 | if not(line and line:match("LUA_PATH")) then | ||
83 | found = true | ||
84 | end | ||
85 | end | ||
86 | file:close() | ||
87 | if found then | ||
88 | return false | ||
89 | else | ||
90 | return true | ||
91 | end | ||
92 | else | ||
93 | return true | ||
94 | end | ||
95 | return false | ||
96 | end | ||
97 | |||
98 | function is_actual_binary(filename) | ||
99 | if filename:match("%.lua$") then | ||
100 | return false | ||
101 | end | ||
102 | local file = io.open(filename) | ||
103 | if file then | ||
104 | local found = false | ||
105 | local first = file:read() | ||
106 | if not first then | 77 | if not first then |
107 | file:close() | 78 | file:close() |
108 | util.printerr("Warning: could not read "..filename) | 79 | util.printerr("Warning: could not read "..filename) |
@@ -127,6 +98,5 @@ function is_actual_binary(filename) | |||
127 | end | 98 | end |
128 | 99 | ||
129 | function copy_binary(filename, dest) | 100 | function copy_binary(filename, dest) |
130 | -- LuaPosix (as of 5.1.15) does not support octal notation... | 101 | return fs.copy(filename, dest, "0755") |
131 | return fs.copy(filename, dest, "u=rwx,g=rx,o=rx") | ||
132 | end | 102 | end |
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index 5e91439b..d6d60adc 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -101,7 +101,7 @@ function copy(src, dest, perm) | |||
101 | if fs.is_dir(dest) then | 101 | if fs.is_dir(dest) then |
102 | dest = dir.path(dest, dir.base_name(src)) | 102 | dest = dir.path(dest, dir.base_name(src)) |
103 | end | 103 | end |
104 | if fs.execute(vars.CHMOD, perm, dest) then | 104 | if fs.chmod(dest, perm) then |
105 | return true | 105 | return true |
106 | else | 106 | else |
107 | return false, "Failed setting permissions of "..dest | 107 | return false, "Failed setting permissions of "..dest |