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.
This commit is contained in:
Natanael Copa 2019-04-30 07:41:23 +00:00
parent acf1fa5553
commit cf86b45836
1 changed files with 17 additions and 19 deletions

View File

@ -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}")
${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
)
cd "$ddbg_srcdir"
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"
if [ -n "$xattr" ]; then
echo "$xattr" | setfattr --restore=-
fi
done
return 0
}
@ -1720,7 +1718,7 @@ default_dev() {
usr/share/qt*/mkspecs \
usr/lib/qt*/mkspecs \
usr/lib/cmake \
$(find . -name include -type d) \
$(find . -name include -type d) \
$([ -z "${subpackages##*$pkgname-static*}" ] && find $libdirs \
-name '*.a' 2>/dev/null) \
$(find $libdirs -name '*.[cho]' \