From ce40629b7d9140df0ccd8deefd8102264f06cc0a Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Thu, 12 May 2022 09:45:12 +1000 Subject: [PATCH] libmakepkg: Do not "strip" files when the format is not recognised We use a multi step process during stripping to ensure permissions do not get changed. However, if the initial objcopy fails, the subsequent cat results in a blank file. Abandon early if objcopy fails. Fixes FS#74486 Signed-off-by: Allan McRae (cherry picked from commit 18152a211aeee07e655c2cc4438c25e558e3b8aa) --- scripts/libmakepkg/tidy/strip.sh.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in index 6955bb68..4a778a9d 100644 --- a/scripts/libmakepkg/tidy/strip.sh.in +++ b/scripts/libmakepkg/tidy/strip.sh.in @@ -80,7 +80,12 @@ strip_file() { # copy debug symbols to debug directory mkdir -p "$dbgdir/${binary%/*}" - objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug" + + # abandon processing files that are not a recognised format + if ! objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug" 2>/dev/null; then + return + fi + local tempfile=$(mktemp "$binary.XXXXXX") objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary" "$tempfile" cat "$tempfile" > "$binary"