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 <allan@archlinux.org>
This commit is contained in:
Allan McRae 2022-12-06 10:11:52 +10:00
parent 471a030466
commit fcb1d4f87e

View file

@ -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
}