cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit b07cbe029447e8cfe68bee34a7661ac1f689e566
parent 08311a30604b36b28d001432c70746dcb48a54c4
Author: Cem Keylan <cem@ckyln.com>
Date:   Thu, 28 May 2020 15:31:05 +0300

kiss: switch to POSIX od as well.

Diffstat:
Mkiss | 32+++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/kiss b/kiss @@ -451,19 +451,29 @@ pkg_strip() { log "$1" "Stripping binaries and libraries" - # Strip only files matching the below ELF types. - # NOTE: 'readelf' is used in place of 'file' as - # it allows us to remove 'file' from the - # core repositories altogether. find "$pkg_dir/$1" -type f | while read -r file; do - case $(readelf -h "$file") in - *" DYN "*) strip_opt=unneeded ;; - *" EXEC "*) strip_opt=all ;; - *" REL "*) strip_opt=debug ;; - *) continue - esac + case $(od -A o -t c -N 18 "$file") in + # REL (object files (.o), static libraries (.a)). + *177*E*L*F*0000020\ 001\ *|*\!*\<*a*r*c*h*\>*) + strip -g -R .comment -R .note "$file" + strip_opt=DEBUG + ;; + + # EXEC (static binaries). + *177*E*L*F*0000020\ 002\ *) + strip -s -R .comment -R .note "$file" + strip_opt=ALL + ;; - strip "--strip-$strip_opt" "$file" && + # DYN (shared libraries, dynamic binaries). + # Shared libraries keep global symbols in a separate ELF section + # called '.dynsym'. '--strip-all/-s' does not touch the dynamic + # symbol entries which makes this safe to do. + *177*E*L*F*0000020\ 003\ *) + strip -s -R .comment -R .note "$file" + strip_opt=UNNEEDED + ;; + esac printf 'Stripped %10s %s\n' "($strip_opt)" "${file##$pkg_dir/$1}" done 2>/dev/null ||: }