rpm-build/scripts/find-debuginfo-files.in

89 lines
1.9 KiB
Plaintext
Raw Normal View History

2011-01-09 16:55:49 +03:00
#!/bin/sh -efu
#
# find-debuginfo-files - make %files list for debuginfo package
#
# Written by Alexey Tourbin <at@altlinux.org>.
# License: GPLv2+.
2011-01-09 16:55:49 +03:00
. @RPMCONFIGDIR@/functions
ValidateBuildRoot
cd "$RPM_BUILD_ROOT"
rm -rf .tmp
mkdir .tmp
>.tmp/files
>.tmp/files-can
>.tmp/links
>.tmp/links-in
2011-01-09 16:55:49 +03:00
>.tmp/src
while read -r f; do
f=${f#$RPM_BUILD_ROOT}
if [ -f .debuginfo/src/"$f" ]; then
LC_ALL=C sort -m -u -o .tmp/src .tmp/src .debuginfo/src/"$f"
fi
2011-01-09 16:55:49 +03:00
debugf=./usr/lib/debug$f.debug
[ -f "$debugf" ] || continue
if [ -L "$debugf" ]; then
# Save symlink for later filtering.
printf '%s\n' "$debugf" >> .tmp/links-in
continue
2011-01-09 16:55:49 +03:00
fi
printf '%s\n' "${debugf#.}" >> .tmp/files
# Save canonical file name for later symlinks filtering.
readlink -ve "$debugf" >> .tmp/files-can
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
# Filter out symlinks pointing out of the package.
sort -u .tmp/links-in |
while read -r link; do
to=$(readlink -vm "$link")
if grep -Fqsxe "$to" .tmp/files-can; then
printf '%s\n' "${link#.}" >> .tmp/links
fi
2011-01-09 16:55:49 +03:00
done
sed 's|\(.*\)/.*|\1|' .tmp/files .tmp/links .tmp/src |sort -u |
while read -r dir; do
while [ -n "$dir" ]; do
case $dir in
/usr/lib/debug/usr/*/*)
printf '%s\n' "$dir" ;;
/usr/lib/debug/usr/*)
break ;;
/usr/lib/debug/*/*)
printf '%s\n' "$dir" ;;
/usr/lib/debug/*)
break ;;
/usr/src/debug/*)
printf '%s\n' "$dir" ;;
*)
break ;;
esac
dir=${dir%/*}
done
done |
sort -u |
sed 's/^/%dir /'
sort .tmp/files .tmp/links .tmp/src