On 11/26/19 4:29 PM, Ethan Sommer wrote:
Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com> --- scripts/libmakepkg/tidy/strip.sh.in | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in index 1bd810f0..301d1989 100644 --- 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. 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.
+ *Type:*'DYN (Shared object file)'*) # Libraries (.so) or Relocatable binaries strip_flags="$STRIP_SHARED";; - *application/x-archive*) # Libraries (.a) - strip_flags="$STRIP_STATIC";; - *application/x-object*) - case "$binary" in - *.ko) # Kernel module - strip_flags="$STRIP_SHARED";; - *) - continue;; - esac;; - *application/x-executable*) # Binaries + *Type:*'EXEC (Executable file)'*) # Binaries strip_flags="$STRIP_BINARIES";; - *application/x-pie-executable*) # Relocatable binaries - strip_flags="$STRIP_SHARED";; + *Type:*'REL (Relocatable file)'*) # Libraries (.a) or objects + if ar t "$binary" &>/dev/null; then # Libraries (.a) + strip_flags="$STRIP_STATIC" + elif [[ $binary = *'.ko' ]]; then # Kernel module + strip_flags="$STRIP_SHARED" + else + continue + fi + ;; *) continue ;; esac
-- Eli Schwartz Bug Wrangler and Trusted User