Commit 5b163c2d authored by tcely's avatar tcely Committed by Natanael Copa

abuild: default_dbg: eliminate side effects

- do not overwrite variables

srcdir is very important for abuild operation

- quoted various paths
- use a sub-shell to contain directory changing

Resolves alpinelinux/abuild#58
parent dc41c1fc
......@@ -1676,25 +1676,26 @@ doc() {
# predefined splitfunc dbg
default_dbg() {
local f
local ddbg_binfiles f ddbg_srcdir ddbg_srcfile ddbg_dstdir ddbg_dstfile
pkgdesc="$pkgdesc (debug symbols)"
binfiles=$(scanelf -R "$pkgdir" | grep ET_DYN | sed "s:$pkgdir\/::g" | sed "s:ET_DYN ::g")
for f in $binfiles; do
srcdir=$(dirname $pkgdir/$f)
srcfile=$(basename $pkgdir/$f)
dstdir=$(dirname $subpkgdir/usr/lib/debug/$f.debug)
dstfile=$(basename $subpkgdir/usr/lib/debug/$f.debug)
if [ ! -d $dstdir ] ; then
mkdir -p $dstdir
fi
cd $srcdir
local XATTR=$(getfattr --match="" --dump "${srcfile}")
${CROSS_COMPILE}objcopy --only-keep-debug $srcfile $dstfile
${CROSS_COMPILE}objcopy --add-gnu-debuglink=$dstfile $srcdir/$srcfile
mv $dstfile $dstdir
${CROSS_COMPILE}strip $srcfile
[ -n "$XATTR" ] && { echo "$XATTR" | setfattr --restore=-; }
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=-; }
)
done
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