From fcb1d4f87e67f3f6d56ef360302e8d4f8ead27d9 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Tue, 6 Dec 2022 10:11:52 +1000 Subject: [PATCH] makepkg: package debug source files with options 'debug' and '!strip' When package software with debug symbols without stripping, we should still process the files with debugedit and include the needed source files in the package. Signed-off-by: Allan McRae --- scripts/libmakepkg/tidy/strip.sh.in | 37 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in index 69c9f041..035a2142 100644 --- a/scripts/libmakepkg/tidy/strip.sh.in +++ b/scripts/libmakepkg/tidy/strip.sh.in @@ -52,6 +52,20 @@ source_files() { | sort -zu | tr '\0' '\n' } +package_source_files() { + local binary=$1 + + local file dest t + while IFS= read -r t; do + file="${srcdir}/${t}" + dest="${dbgsrc}/${t}" + mkdir -p "${dest%/*}" + if [[ -f "$file" ]]; then + cp -- "$file" "$dest" + fi + done < <(source_files "$binary") +} + strip_file() { local binary=$1; shift @@ -68,15 +82,7 @@ strip_file() { fi # copy source files to debug directory - local file dest t - while IFS= read -r t; do - file="${srcdir}/${t}" - dest="${dbgsrc}/${t}" - mkdir -p "${dest%/*}" - if [[ -f "$file" ]]; then - cp -- "$file" "$dest" - fi - done < <(source_files "$binary") + package_source_files "$binary" # copy debug symbols to debug directory mkdir -p "$dbgdir/${binary%/*}" @@ -139,7 +145,6 @@ tidy_strip() { [[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S" if check_option "debug" "y"; then - dbgdir="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@/usr/lib/debug" dbgsrcdir="${DBGSRCDIR:-/usr/src/debug}/${pkgbase}" dbgsrc="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@$dbgsrcdir" @@ -172,5 +177,17 @@ tidy_strip() { strip_file "$binary" ${strip_flags} (( STRIPLTO )) && strip_lto "$binary" done + + elif check_option "debug" "y"; then + msg2 "$(gettext "Copying source files needed for debug symbols...")" + + dbgsrcdir="${DBGSRCDIR:-/usr/src/debug}/${pkgbase}" + dbgsrc="$pkgdirbase/$pkgbase/$dbgsrcdir" + mkdir -p "$dbgsrc" + + local binary + find . -type f -perm -u+w -print0 2>/dev/null | while IFS= read -rd '' binary ; do + package_source_files "$binary" 2>/dev/null + done fi }