forked from pool/debugedit
90 lines
3.2 KiB
Diff
90 lines
3.2 KiB
Diff
|
--- ./scripts/find-debuginfo.in.orig 2019-09-09 07:56:53.377788842 +0000
|
||
|
+++ ./scripts/find-debuginfo.in 2019-10-02 11:11:56.878979662 +0000
|
||
|
@@ -348,12 +348,18 @@ trap 'rm -rf "$temp"' EXIT
|
||
|
|
||
|
# Build a list of unstripped ELF files and their hardlinks
|
||
|
touch "$temp/primary"
|
||
|
-find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \
|
||
|
- \( -perm -0100 -or -perm -0010 -or -perm -0001 \) \
|
||
|
- -print | LC_ALL=C sort |
|
||
|
-file -N -f - | sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped.*/\1/p' |
|
||
|
-xargs --no-run-if-empty stat -c '%h %D_%i %n' |
|
||
|
+find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \( -perm /111 -or -name "*.so*" -or -name "*.ko" \) ! -name "*.a" -print0 | LC_ALL=C sort -z |
|
||
|
+xargs --no-run-if-empty -0 stat -c '%h %D_%i %n' |
|
||
|
while read nlinks inum f; do
|
||
|
+ case $(objdump -h $f 2>/dev/null | egrep -o '(debug[\.a-z_]*|gnu.version)') in
|
||
|
+ *debuglink*) continue ;;
|
||
|
+ *debug*) ;;
|
||
|
+ *gnu.version*)
|
||
|
+ echo "WARNING: "`echo $f | sed -e "s,^$RPM_BUILD_ROOT/*,/,"`" is already stripped!"
|
||
|
+ continue
|
||
|
+ ;;
|
||
|
+ *) continue ;;
|
||
|
+ esac
|
||
|
if [ $nlinks -gt 1 ]; then
|
||
|
var=seen_$inum
|
||
|
if test -n "${!var}"; then
|
||
|
@@ -386,6 +392,8 @@ do_file()
|
||
|
if [ "$no_recompute_build_id" = "true" ]; then
|
||
|
no_recompute="-n"
|
||
|
fi
|
||
|
+ mode=$(stat -c %a "$f")
|
||
|
+ chmod +w "$f"
|
||
|
id=$(${install_dir}/debugedit -b "$debug_base_name" -d "$debug_dest_name" \
|
||
|
$no_recompute -i \
|
||
|
${build_id_seed:+--build-id-seed="$build_id_seed"} \
|
||
|
@@ -413,17 +421,30 @@ do_file()
|
||
|
# just has its file names collected and adjusted.
|
||
|
case "$dn" in
|
||
|
/usr/lib/debug/*)
|
||
|
+ chmod $mode "$f"
|
||
|
return ;;
|
||
|
esac
|
||
|
|
||
|
mkdir -p "${debugdn}"
|
||
|
- if test -w "$f"; then
|
||
|
- strip_to_debug "${debugfn}" "$f"
|
||
|
- else
|
||
|
- chmod u+w "$f"
|
||
|
- strip_to_debug "${debugfn}" "$f"
|
||
|
- chmod u-w "$f"
|
||
|
- fi
|
||
|
+ objcopy --only-keep-debug "$f" "$debugfn" || :
|
||
|
+ (
|
||
|
+ shopt -s extglob
|
||
|
+ strip_option="--strip-all"
|
||
|
+ case "$f" in
|
||
|
+ *.ko)
|
||
|
+ strip_option="--strip-debug" ;;
|
||
|
+ *$STRIP_KEEP_SYMTAB*)
|
||
|
+ if test -n "$STRIP_KEEP_SYMTAB"; then
|
||
|
+ strip_option="--strip-debug"
|
||
|
+ fi
|
||
|
+ ;;
|
||
|
+ esac
|
||
|
+ if test "$NO_DEBUGINFO_STRIP_DEBUG" = true ; then
|
||
|
+ strip_option=
|
||
|
+ fi
|
||
|
+ objcopy --add-gnu-debuglink="$debugfn" -R .comment -R .GCC.command.line $strip_option "$f"
|
||
|
+ chmod $mode "$f"
|
||
|
+ ) || :
|
||
|
|
||
|
# strip -g implies we have full symtab, don't add mini symtab in that case.
|
||
|
# It only makes sense to add a minisymtab for executables and shared
|
||
|
@@ -581,12 +602,14 @@ if [ -s "$SOURCEFILE" ]; then
|
||
|
# and non-standard modes may be inherented from original directories, fixup
|
||
|
find "${RPM_BUILD_ROOT}${debug_dest_name}" -type d -print0 |
|
||
|
xargs --no-run-if-empty -0 chmod 0755
|
||
|
+ find "${RPM_BUILD_ROOT}${debug_dest_name}" -type f -print0 |
|
||
|
+ xargs --no-run-if-empty -0 chmod a+r
|
||
|
fi
|
||
|
|
||
|
if [ -d "${RPM_BUILD_ROOT}/usr/lib" ] || [ -d "${RPM_BUILD_ROOT}/usr/src" ]; then
|
||
|
((nout > 0)) ||
|
||
|
test ! -d "${RPM_BUILD_ROOT}/usr/lib" ||
|
||
|
- (cd "${RPM_BUILD_ROOT}/usr/lib"; find debug -type d) |
|
||
|
+ (cd "${RPM_BUILD_ROOT}/usr/lib"; test ! -d debug || find debug -type d) |
|
||
|
sed 's,^,%dir /usr/lib/,' >> "$LISTFILE"
|
||
|
|
||
|
(cd "${RPM_BUILD_ROOT}/usr"
|