summaryrefslogtreecommitdiffstats
path: root/scripts/libmakepkg/tidy
diff options
context:
space:
mode:
authorEthan Sommer <e5ten.arch@gmail.com>2019-11-26 22:29:56 +0100
committerAllan McRae <allan@archlinux.org>2019-12-11 02:02:15 +0100
commit56e0763c6d1d248b986ac22836de5ede0a805cfb (patch)
tree6eb22d4a48154654d18e88961cf158af2988f788 /scripts/libmakepkg/tidy
parentb7f61aa55755d95d2e3a6dd7058971c68276c369 (diff)
downloadpacman-56e0763c6d1d248b986ac22836de5ede0a805cfb.tar.gz
pacman-56e0763c6d1d248b986ac22836de5ede0a805cfb.tar.xz
libmakepkg: use readelf instead of file for finding ELF file types
Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts/libmakepkg/tidy')
-rw-r--r--scripts/libmakepkg/tidy/strip.sh.in26
1 files 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
+ *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