aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2012-02-22 16:59:30 -0200
committerHisham Muhammad <hisham@gobolinux.org>2012-02-22 16:59:30 -0200
commitc7e978427594ed0cd895eb7f8bfa1b658bd02591 (patch)
tree7df48cd8ebe83b84d13e98aa443f08d98f115fa2
parentcaa486a74909e2e0066a5531e2a3fd6af46ca9af (diff)
downloadluarocks-c7e978427594ed0cd895eb7f8bfa1b658bd02591.tar.gz
luarocks-c7e978427594ed0cd895eb7f8bfa1b658bd02591.tar.bz2
luarocks-c7e978427594ed0cd895eb7f8bfa1b658bd02591.zip
Simplify detection of binary files for determining arch suffix of packed rocks. Closes #61.
-rw-r--r--src/luarocks/fs/unix.lua30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua
index 979fd166..88bafaf6 100644
--- a/src/luarocks/fs/unix.lua
+++ b/src/luarocks/fs/unix.lua
@@ -71,30 +71,16 @@ function is_actual_binary(filename)
71 return false 71 return false
72 end 72 end
73 local file = io.open(filename) 73 local file = io.open(filename)
74 if file then 74 if not file then
75 local found = false 75 return true
76 local first = file:read() 76 end
77 if not first then 77 local first = file:read(2)
78 file:close() 78 file:close()
79 util.printerr("Warning: could not read "..filename) 79 if not first then
80 return false 80 util.printerr("Warning: could not read "..filename)
81 end
82 if first:match("#!.*lua") then
83 file:close()
84 return true
85 elseif first:match("#!/bin/sh") then
86 local line = file:read()
87 line = file:read()
88 if not(line and line:match("LUA_PATH")) then
89 file:close()
90 return true
91 end
92 end
93 file:close()
94 else
95 return true 81 return true
96 end 82 end
97 return false 83 return first ~= "#!"
98end 84end
99 85
100function copy_binary(filename, dest) 86function copy_binary(filename, dest)