[pacman-dev] [PATCH 2/3] libmakepkg: use readelf instead of file for finding ELF file types

Ethan Sommer e5ten.arch at gmail.com
Wed Nov 27 17:32:12 UTC 2019


> > --- a/scripts/libmakepkg/tidy/strip.sh.in
> > +++ b/scripts/libmakepkg/tidy/strip.sh.in
> > @@ -111,22 +111,20 @@ tidy_strip() {
> >
> >               local binary strip_flags
> >               find . -type f -perm -u+w -print0 2>/dev/null | while IFS= read -rd '' binary ; do
> > -                     case "$(file -bi "$binary")" in
> > -                             *application/x-sharedlib*)  # Libraries (.so)
> > +                     case "$(LC_ALL=C readelf -h "$binary" 2>/dev/null)" in
>
> More squelching of errors.
The error redirection to null is because readelf outputs an error when
the file it is run on isn't an ELF file at all, and obviously that error
is unwanted.

> Incidentally, is the output of this, documented, or can it arbitrarily
> change in the future? file is guaranteed to emit output in the
> RFC-documented IANA media type format.
These file types and their specification in the file header are part of
the ELF spec, and the readelf output has remained consistent, at least
the part that matters to us, and the relevant part is the same across 4
different implementations, and I doubt there will be some change of the
word 'Type:' being used, given that the ELF specification refers to those
file types as 'types'.


More information about the pacman-dev mailing list