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,10 +282,8 @@ 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
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
@ -304,10 +302,6 @@ local function checkFile(file, pkg)
file, pkg, file_type)
end
end
else
log("Can't get type of file %s (%s). file says %q",
file, pkg, file_type0)
end
for _, t in ipairs(TARGETS) do
if t ~= target and file:match(t) then
log('File %s (%s): other target %s in name',

Loading…
Cancel
Save