diff options
author | Allan McRae <allan@archlinux.org> | 2022-05-12 09:45:12 +1000 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2022-05-12 09:45:12 +1000 |
commit | 18152a211aeee07e655c2cc4438c25e558e3b8aa (patch) | |
tree | b5319c88e0c2a430530a37c5672faf91c1e0661b | |
parent | f5f9e0f4ea30503657944b5c34690bd36069b07e (diff) |
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 <allan@archlinux.org>
-rw-r--r-- | scripts/libmakepkg/tidy/strip.sh.in | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in index 688bcf1b..4cf2107c 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" |