2017-06-30 15:03:35 +00:00
|
|
|
From 534fae47e4d05fd27c277c9e04ad238e608289f5 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Michal Marek <mmarek@suse.com>
|
|
|
|
Date: Sat, 10 Sep 2016 23:13:24 +0200
|
2017-07-18 13:49:11 +00:00
|
|
|
Subject: [PATCH] find-debuginfo.sh: Split directory traversal and debuginfo
|
|
|
|
extraction
|
2017-06-23 14:24:36 +00:00
|
|
|
|
2017-06-30 15:03:35 +00:00
|
|
|
This siplifies the handling of hardlinks a bit and allows a later patch
|
|
|
|
to parallelize the debuginfo extraction.
|
|
|
|
|
|
|
|
Signed-off-by: Michal Marek <mmarek@suse.com>
|
|
|
|
|
|
|
|
(cherry picked from commit 038bfe01796f751001e02de41c5d8678f511f366)
|
|
|
|
|
|
|
|
Conflicts:
|
|
|
|
scripts/find-debuginfo.sh
|
|
|
|
---
|
|
|
|
scripts/find-debuginfo.sh | 53 ++++++++++++++++++++++++++++++-----------------
|
|
|
|
1 file changed, 34 insertions(+), 19 deletions(-)
|
|
|
|
mode change 100755 => 100644 scripts/find-debuginfo.sh
|
2017-06-23 14:24:36 +00:00
|
|
|
|
|
|
|
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
|
2017-06-30 15:03:35 +00:00
|
|
|
old mode 100755
|
|
|
|
new mode 100644
|
|
|
|
index 5087c4050..097b749bb
|
2017-06-23 14:24:36 +00:00
|
|
|
--- a/scripts/find-debuginfo.sh
|
|
|
|
+++ b/scripts/find-debuginfo.sh
|
2017-06-30 15:03:35 +00:00
|
|
|
@@ -283,32 +283,36 @@ set -o pipefail
|
2017-06-23 14:24:36 +00:00
|
|
|
strict_error=ERROR
|
|
|
|
$strict || strict_error=WARNING
|
|
|
|
|
|
|
|
-# Strip ELF binaries
|
|
|
|
+temp=$(mktemp -d ${TMPDIR:-/tmp}/find-debuginfo.XXXXXX)
|
|
|
|
+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 |
|
|
|
|
file -N -f - | sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped.*/\1/p' |
|
|
|
|
xargs --no-run-if-empty stat -c '%h %D_%i %n' |
|
|
|
|
while read nlinks inum f; do
|
|
|
|
- get_debugfn "$f"
|
|
|
|
- [ -f "${debugfn}" ] && continue
|
|
|
|
-
|
|
|
|
- # If this file has multiple links, keep track and make
|
|
|
|
- # the corresponding .debug files all links to one file too.
|
|
|
|
if [ $nlinks -gt 1 ]; then
|
|
|
|
- eval linked=\$linked_$inum
|
|
|
|
- if [ -n "$linked" ]; then
|
|
|
|
- eval id=\$linkedid_$inum
|
|
|
|
- link=$debugfn
|
|
|
|
- get_debugfn "$linked"
|
|
|
|
- echo "hard linked $link to $debugfn"
|
|
|
|
- mkdir -p "$(dirname "$link")" && ln -nf "$debugfn" "$link"
|
|
|
|
+ var=seen_$inum
|
|
|
|
+ if test -n "${!var}"; then
|
|
|
|
+ echo "$inum $f" >>"$temp/linked"
|
|
|
|
continue
|
|
|
|
else
|
|
|
|
- eval linked_$inum=\$f
|
|
|
|
- echo "file $f has $[$nlinks - 1] other hard links"
|
|
|
|
+ read "$var" < <(echo 1)
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
+ echo "$nlinks $inum $f" >>"$temp/primary"
|
|
|
|
+done
|
|
|
|
+
|
|
|
|
+# Strip ELF binaries
|
|
|
|
+do_file()
|
|
|
|
+{
|
|
|
|
+ local nlinks=$1 inum=$2 f=$3 id link linked
|
|
|
|
+
|
|
|
|
+ get_debugfn "$f"
|
|
|
|
+ [ -f "${debugfn}" ] && return
|
|
|
|
|
|
|
|
echo "extracting debug info from $f"
|
|
|
|
build_id_seed=
|
2017-06-30 15:03:35 +00:00
|
|
|
@@ -328,9 +332,6 @@ while read nlinks inum f; do
|
2017-06-23 14:24:36 +00:00
|
|
|
fi
|
|
|
|
id=$(${lib_rpm_dir}/debugedit -b $debug_base_name -d $debug_dest_name \
|
2017-06-30 15:03:35 +00:00
|
|
|
$no_recompute -i $build_id_seed -l "$SOURCEFILE" "$f") || exit
|
2017-06-23 14:24:36 +00:00
|
|
|
- if [ $nlinks -gt 1 ]; then
|
|
|
|
- eval linkedid_$inum=\$id
|
|
|
|
- fi
|
|
|
|
if [ -z "$id" ]; then
|
|
|
|
echo >&2 "*** ${strict_error}: No build ID note found in $f"
|
|
|
|
$strict && exit 2
|
2017-06-30 15:03:35 +00:00
|
|
|
@@ -376,7 +377,21 @@ while read nlinks inum f; do
|
2017-06-23 14:24:36 +00:00
|
|
|
|
|
|
|
echo "./${f#$RPM_BUILD_ROOT}" >> "$ELFBINSFILE"
|
|
|
|
|
|
|
|
-done || exit
|
|
|
|
+ # If this file has multiple links, make the corresponding .debug files
|
|
|
|
+ # all links to one file too.
|
|
|
|
+ if [ $nlinks -gt 1 ]; then
|
|
|
|
+ grep "^$inum " "$temp/linked" | while read inum linked; do
|
|
|
|
+ link=$debugfn
|
|
|
|
+ get_debugfn "$linked"
|
|
|
|
+ echo "hard linked $link to $debugfn"
|
|
|
|
+ mkdir -p "$(dirname "$debugfn")" && ln -nf "$link" "$debugfn"
|
|
|
|
+ done
|
|
|
|
+ fi
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+while read nlinks inum f; do
|
|
|
|
+ do_file "$nlinks" "$inum" "$f"
|
|
|
|
+done <"$temp/primary"
|
|
|
|
|
|
|
|
# Invoke the DWARF Compressor utility.
|
|
|
|
if $run_dwz \
|