find-debuginfo-files: create /usr/lib/debug/.build-id/ links

It might seem that build-id links should be created in brp-debuginfo.
However, there are corner cases: in brp-debugino, it is not yet known
which files are going to be packaged.  This might be a problem when a
few identical files or hardlinks are created under buildroot: it is
possible create a symbolic link to a "wrong" file which will not be
packaged.

The solution is create build-id links in find-debuginfo-files: the link
will point to the first packaged file with the given build-id.  However,
note that find-debuginfo-files is not part of the install stage, and
should remain "reenterable" (so that e.g. rpm -bl can be executed
multiple times).  This means that the script should not make assumptions
whether the links have already been created.
This commit is contained in:
Alexey Tourbin 2011-02-03 08:41:19 +03:00
parent 3132ca2851
commit f90e69d3f1

View File

@ -20,18 +20,27 @@ mkdir .tmp
while read -r f; do
f=${f#$RPM_BUILD_ROOT}
debugf=./usr/lib/debug$f.debug
if [ -L "$debugf" ]; then
continue
fi
if [ -f "$debugf" ]; then
printf '%s\n' "${debugf#.}" >>.tmp/files
fi
[ -f "$debugf" ] && [ ! -L "$debugf" ] || continue
printf '%s\n' "${debugf#.}" >>.tmp/files
if [ -f .debuginfo/links/"$debugf" ]; then
cat .debuginfo/links/"$debugf" >>.tmp/links
fi
if [ -s .debuginfo/src/"$debugf" ]; then
LC_ALL=C sort -m -u -o .tmp/src .tmp/src .debuginfo/src/"$debugf"
fi
id=$(@RPMCONFIGDIR@/debugedit -i "$debugf")
[ -n "$id" ] || continue
link=./usr/lib/debug/.build-id/${id:0:2}/${id:2}
if [ ! -L "$link" ]; then
mkdir -p "${link%/*}"
ln -snf "$(relative "$f" "${link#.}")" "$link"
ln -snf "$(relative "${debugf#.}" "${link#.}".debug)" "$link".debug
fi
to=$(readlink -vm "$link")
if [ "$to" = "$RPM_BUILD_ROOT$f" ]; then
printf '%s\n' "${link#.}" >>.tmp/links
printf '%s\n' "${link#.}".debug >>.tmp/links
fi
done
sed 's|\(.*\)/.*|\1|' .tmp/files .tmp/links .tmp/src |sort -u |