Commit cf86b458 authored by Natanael Copa's avatar Natanael Copa

abuild: cleanup default_dbg

Run the loop in a subshell via a pipe so we dont need a subshell for
each iteration.

Use `if ...; then` to make code slightly more readable.

Fix a whitespace before tab while at it.
parent acf1fa55
......@@ -1676,27 +1676,25 @@ doc() {
# predefined splitfunc dbg
default_dbg() {
local ddbg_binfiles f ddbg_srcdir ddbg_srcfile ddbg_dstdir ddbg_dstfile
local f
pkgdesc="$pkgdesc (debug symbols)"
ddbg_binfiles=$(scanelf -R "$pkgdir" | grep ET_DYN | sed "s:$pkgdir\/::g" | sed "s:ET_DYN ::g")
for f in $ddbg_binfiles; do
ddbg_srcdir=$(dirname "$pkgdir/$f")
ddbg_srcfile=$(basename "$pkgdir/$f")
ddbg_dstdir=$(dirname "$subpkgdir/usr/lib/debug/$f.debug")
ddbg_dstfile=$(basename "$subpkgdir/usr/lib/debug/$f.debug")
[ -d "$ddbg_dstdir" ] || mkdir -p "$ddbg_dstdir"
scanelf -R "$pkgdir" | grep ET_DYN | sed "s:$pkgdir\/::g" | sed "s:ET_DYN ::g" | while read f; do
local ddbg_srcdir=$(dirname "$pkgdir/$f")
local ddbg_srcfile=$(basename "$pkgdir/$f")
local ddbg_dstdir=$(dirname "$subpkgdir/usr/lib/debug/$f.debug")
local ddbg_dstfile=$(basename "$subpkgdir/usr/lib/debug/$f.debug")
mkdir -p "$ddbg_dstdir"
cd "$ddbg_srcdir"
XATTR=$(getfattr --match="" --dump "${ddbg_srcfile}")
local xattr=$(getfattr --match="" --dump "${ddbg_srcfile}")
${CROSS_COMPILE}objcopy --only-keep-debug "$ddbg_srcfile" "$ddbg_dstfile"
${CROSS_COMPILE}objcopy --add-gnu-debuglink="$ddbg_dstfile" "$ddbg_srcdir/$ddbg_srcfile"
mv "$ddbg_dstfile" "$ddbg_dstdir"
${CROSS_COMPILE}strip "$ddbg_srcfile"
[ -n "$XATTR" ] && { echo "$XATTR" | setfattr --restore=-; }
exit 0
if [ -n "$xattr" ]; then
echo "$xattr" | setfattr --restore=-
return 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment