From 4006aee0bf8ac8860e4eec01a58bce8f453a6d7f Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 3 Nov 2026 08:19:14 +0700 Subject: [PATCH] cookbook: Also strip ar files --- src/cook/script.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cook/script.rs b/src/cook/script.rs index 81384a5ab..89eb05214 100644 --- a/src/cook/script.rs +++ b/src/cook/script.rs @@ -460,12 +460,17 @@ strip_directory() { local strip_flags="${STRIP_ARGS:-}" find "$target_dir" -type f -print0 | while IFS= read -r -d '' file; do - if [ "$(od -An -t x1 -N 4 "$file" | tr -d ' \n')" = "7f454c46" ]; then + # check magic bytes for elf and ar before stripping + local magic_bytes="$(od -An -t x1 -N 4 "$file" | tr -d ' \n')" + if [[ "$magic_bytes" = "7f454c46" || "$magic_bytes" = "213c6172" ]]; then "${STRIP}" ${STRIP_ARGS} "$file" fi - done } +if [ -z "${COOKBOOK_NOSTRIP}" ]; then + [ -z "${COOKBOOK_VERBOSE}" ] || echo "DEBUG: stripping binaries and libraries" +fi + # Strip binaries for dir in "${COOKBOOK_STAGE}/bin" "${COOKBOOK_STAGE}/usr/bin" "${COOKBOOK_STAGE}/libexec" "${COOKBOOK_STAGE}/usr/libexec" do