From cf86b4583620f178aab61b6c6f2269863ab76873 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 30 Apr 2019 07:41:23 +0000 Subject: 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. --- abuild.in | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/abuild.in b/abuild.in index 42e6731..38970e6 100644 --- a/abuild.in +++ b/abuild.in @@ -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" - - ( - 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 - ) + 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" + 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]' \ -- cgit v1.2.3-70-g09d2