rpm-build/scripts/brp-debuginfo.in
Alexey Tourbin 033bb95511 brp-debuginfo: pass LD_ORIGIN_PATH=/usr/bin to eu-strip
This is the same as with eu-findtextrel and eu-elflint; eu-strip
needs to load EBL backend only with --strip-debug, though.
2011-02-05 23:34:11 +03:00

87 lines
2.6 KiB
Bash
Executable File

#!/bin/sh -efu
#
# brp-debuginfo - generate /usr/lib/debug and /usr/src/debug contents
# for debuginfo packages
#
# Written by Alexey Tourbin <at@altlinux.org>. Based on find-debuginfo.sh
# by Jeff Johnson <jbj@rpm5.org> and Roland McGrath <roland@redhat.com>.
# License: GPLv2+.
. @RPMCONFIGDIR@/functions
ValidateBuildRoot
cd "$RPM_BUILD_ROOT"
rm -rf .tmp
mkdir .tmp
# Strip binaries, create .debug files under /usr/lib/debug and install sources into /usr/src/debug.
prune_paths='-path ./usr/share -o -path ./lib/firmware -o -path ./usr/lib/debug -o -path ./usr/src'
find . '(' -path './.*' -o $prune_paths ')' -prune -o -type f -print |sort |
file -NF$'\t' -f - |sed -n 's/\t.* ELF .* \(executable\|shared object\), .*, not stripped.*//p' |
xargs -r --delimiter='\n' stat -c '%h %i %n' >.tmp/flist
while read -r nlink ino f; do
debugf=./usr/lib/debug${f#.}.debug
if [ "$nlink" -gt 1 ]; then
eval f0="\${f0_$ino-}"
if [ -n "$f0" ]; then
debugf0=./usr/lib/debug${f0#.}.debug
if [ -f "$debugf0" ]; then
mkdir -p "${debugf%/*}"
ln -nf "$debugf0" "$debugf"
fi
mkdir -p .debuginfo/src/"${f%/*}"
ln -nf .debuginfo/src/"$f0" .debuginfo/src/"$f"
continue
else
eval f0_$ino="\$f"
fi
fi
strip='--strip-all'
for pat in ${RPM_BRP_STRIP_DEBUG-}; do
if [ -z "${f##.$pat}" ]; then
strip='--strip-debug'
break
fi
done
for pat in ${RPM_BRP_STRIP_NONE-}; do
if [ -z "${f##.$pat}" ]; then
strip=
break
fi
done
touch -r "$f" .tmp/stamp
@RPMCONFIGDIR@/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug -l .tmp/src "$f"
if [ -n "$strip" ]; then
mkdir -p "${debugf%/*}"
LD_ORIGIN_PATH=/usr/bin eu-strip $strip --remove-comment -f "$debugf" "$f"
touch -r .tmp/stamp "$debugf" "$f"
chmod 644 "$debugf"
else
touch -r .tmp/stamp "$f"
fi
mkdir -p .debuginfo/src/"${f%/*}"
awk 'BEGIN{RS="\0";ORS="\n"}{print}' .tmp/src |LC_ALL=C sort -u |
while read -r src; do
[ -f "$RPM_BUILD_DIR"/"$src" ] || continue
[ -f ./usr/src/debug/"$src" ] ||
install -pD -m644 "$RPM_BUILD_DIR"/"$src" ./usr/src/debug/"$src"
printf '%s\n' /usr/src/debug/"$src"
done >.debuginfo/src/"$f"
rm .tmp/src
done <.tmp/flist
# Make symbolic links that mimic the original tree.
find . '(' -path './.*' -o $prune_paths ')' -prune -o -type l -print |sort >.tmp/flist
while read -r l; do
f=$(readlink -vm "$l")
f=${f#$RPM_BUILD_ROOT}
debugf=./usr/lib/debug$f.debug
[ -f "$debugf" ] || continue
debugl=./usr/lib/debug${l#.}.debug
mkdir -p "${debugl%/*}"
ln -snf "$(relative "${debugf#.}" "${debugl#.}")" "$debugl"
mkdir -p .debuginfo/links/"${debugf%/*}"
printf '%s\n' "${debugl#.}" >>.debuginfo/links/"$debugf"
done <.tmp/flist