strip: don't create debug packages from .a files

.a files are not valid ELF files so we can't run objcopy nor debugedit
on them.

Rename STRIPLTO to STATICLIB to be more descriptive.

Signed-off-by: Morten Linderud <morten@linderud.pw>
This commit is contained in:
Morten Linderud 2023-12-17 16:03:36 +01:00
parent 7a4fff3310
commit 00d2b1f902
No known key found for this signature in database
GPG key ID: 9C02FF419FECBE16

View file

@ -156,7 +156,7 @@ tidy_strip() {
local binary strip_flags
find . -type f -perm -u+w -print0 2>/dev/null | LC_ALL=C sort -z | while IFS= read -rd '' binary ; do
local STRIPLTO=0
local STATICLIB=0
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";;
@ -167,7 +167,7 @@ tidy_strip() {
*Type:*'REL (Relocatable file)'*) # Libraries (.a) or objects
if ar t "$binary" &>/dev/null; then # Libraries (.a)
strip_flags="$STRIP_STATIC"
STRIPLTO=1
STATICLIB=1
elif [[ $binary = *'.ko' || $binary = *'.o' ]]; then # Kernel module or object file
strip_flags="$STRIP_SHARED"
else
@ -177,9 +177,9 @@ tidy_strip() {
*)
continue ;;
esac
collect_debug_symbols "$binary"
(( ! STATICLIB )) && collect_debug_symbols "$binary"
strip_file "$binary" ${strip_flags}
(( STRIPLTO )) && strip_lto "$binary"
(( STATICLIB )) && strip_lto "$binary"
done
elif check_option "debug" "y"; then