build-pkg: add option --brief to "file" command

Option --brief tells "file" not to prepend filenames
to output lines. Using this option is better than parsing
standard format of output of "file" with a regular expression.

Some filenames contain ":". This confuses the regular
expression:

    [build-pkg]     i686-w64-mingw32.static
    Can't get type of file usr/i686-w64-mingw32.static/share/
    gtk-doc/html/libgda-4.0/gen:sql_identifiers.html (libgda).
    file says "usr/i686-w64-mingw32.static/share/gtk-doc/html/
    libgda-4.0/gen:sql_identifiers.html:
    HTML document, ASCII text"
pull/860/head
Boris Nagaev 9 years ago
parent a8ccc4d3c6
commit 95fd81b139

@ -282,31 +282,25 @@ end
local function checkFile(file, pkg)
-- if it is PE32 file, it must have '.exe' in name
local ext = file:sub(-4):lower()
local cmd = 'file --dereference %q'
local file_type0 = trim(shell(cmd:format(file)))
local file_type = file_type0:match('^[^:]+: (.*)$')
if file_type then
if ext == '.bin' then
-- can be an executable or something else (font)
elseif ext == '.exe' then
if not file_type:match('PE32') then
log('File %s (%s) is %q. Remove .exe',
file, pkg, file_type)
end
elseif ext == '.dll' then
if not file_type:match('PE32.*DLL') then
log('File %s (%s) is %q. Remove .dll',
file, pkg, file_type)
end
else
if file_type:match('PE32') then
log('File %s (%s) is %q. Add exe or dll',
file, pkg, file_type)
end
local cmd = 'file --dereference --brief %q'
local file_type = trim(shell(cmd:format(file)))
if ext == '.bin' then
-- can be an executable or something else (font)
elseif ext == '.exe' then
if not file_type:match('PE32') then
log('File %s (%s) is %q. Remove .exe',
file, pkg, file_type)
end
elseif ext == '.dll' then
if not file_type:match('PE32.*DLL') then
log('File %s (%s) is %q. Remove .dll',
file, pkg, file_type)
end
else
log("Can't get type of file %s (%s). file says %q",
file, pkg, file_type0)
if file_type:match('PE32') then
log('File %s (%s) is %q. Add exe or dll',
file, pkg, file_type)
end
end
for _, t in ipairs(TARGETS) do
if t ~= target and file:match(t) then

Loading…
Cancel
Save