index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Allan McRae <allan@archlinux.org> | 2016-12-05 14:53:08 +1000 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2017-01-04 14:02:28 +1000 |
commit | 8b0d59b83a60eb504567590346119fe4cd891cad (patch) | |
tree | ab13e8fb574eaeacfc3c5da5dfa47858713a02c9 /scripts/libmakepkg/tidy | |
parent | 37a89e2fac704babbe3badf0d9df0d41ec622f6f (diff) |
-rw-r--r-- | scripts/libmakepkg/tidy/strip.sh.in | 23 |
diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in index 32ea6771..76562808 100644 --- a/scripts/libmakepkg/tidy/strip.sh.in +++ b/scripts/libmakepkg/tidy/strip.sh.in @@ -32,7 +32,12 @@ tidy_modify+=('tidy_strip') build_id() { - LANG=C readelf -n $1 | sed -n '/Build ID/ { s/.*: //p; q; }' + LANG=C readelf -n "$1" | sed -n '/Build ID/ { s/.*: //p; q; }' +} + +source_files() { + LANG=C readelf "$1" --debug-dump | \ + awk '/DW_AT_name +:/{name=$8}/DW_AT_comp_dir +:/{print $8 "/" name}' } strip_file() { @@ -50,6 +55,18 @@ strip_file() { return fi + # copy source files to debug directory + local f t + while read -r f; do + t=${f/"$srcdir"/$dbgsrc} + mkdir -p "${t%/*}" + cp -- "$f" "$t" + done < <(source_files "$binary") + + # adjust debug symbols to point at sources + debugedit -b "${srcdir}" -d /usr/src/debug/ -i "$binary" &> /dev/null + + # copy debug symbols to debug directory mkdir -p "$dbgdir/${binary%/*}" objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug" objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary" @@ -88,8 +105,10 @@ tidy_strip() { [[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S" if check_option "debug" "y"; then + dbgdir="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@/usr/lib/debug" - mkdir -p "$dbgdir" + dbgsrc="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@/usr/src/debug" + mkdir -p "$dbgdir" "$dbgsrc" fi local binary strip_flags |