Igor Gnatenko 323283
From 7bac47a54fef8fc01fa29865a9622677dbdfa28d Mon Sep 17 00:00:00 2001
Igor Gnatenko 323283
From: Igor Gnatenko <ignatenko@redhat.com>
Igor Gnatenko 323283
Date: Wed, 3 Aug 2016 11:14:05 +0200
Mark Wielaard 284dc3
Subject: [PATCH] let debuginfo packages provide the build-id
Igor Gnatenko 323283
Igor Gnatenko 323283
This patch lets debuginfo packages provide build-id like follows:
Igor Gnatenko 323283
Igor Gnatenko 323283
 debuginfo(build-id) = c63cb23876c5fa85f36beaff58f8557e1bf22517
Igor Gnatenko 323283
Igor Gnatenko 323283
Originally this patch was written by Jan Blunck <jblunck@suse.de>.
Igor Gnatenko 323283
Igor Gnatenko 323283
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
Igor Gnatenko 323283
(cherry picked from commit 95712183458748ea6cafebac1bdd5daa097d9bee)
Igor Gnatenko 323283
---
Igor Gnatenko 323283
 fileattrs/Makefile.am    |  4 ++--
Igor Gnatenko 323283
 fileattrs/debuginfo.attr |  2 ++
Igor Gnatenko 323283
 macros.in                |  3 ++-
Igor Gnatenko 323283
 scripts/Makefile.am      |  2 ++
Igor Gnatenko 323283
 scripts/debuginfo.prov   | 14 ++++++++++++++
Igor Gnatenko 323283
 5 files changed, 22 insertions(+), 3 deletions(-)
Igor Gnatenko 323283
 create mode 100644 fileattrs/debuginfo.attr
Igor Gnatenko 323283
 create mode 100755 scripts/debuginfo.prov
Igor Gnatenko 323283
Igor Gnatenko 323283
diff --git a/fileattrs/Makefile.am b/fileattrs/Makefile.am
Igor Gnatenko 323283
index e54395b3b..148d2ff0d 100644
Igor Gnatenko 323283
--- a/fileattrs/Makefile.am
Igor Gnatenko 323283
+++ b/fileattrs/Makefile.am
Igor Gnatenko 323283
@@ -5,8 +5,8 @@ include $(top_srcdir)/rpm.am
Igor Gnatenko 323283
 fattrsdir = $(rpmconfigdir)/fileattrs
Igor Gnatenko 323283
 
Igor Gnatenko 323283
 fattrs_DATA = \
Igor Gnatenko 323283
-	appdata.attr desktop.attr elf.attr font.attr libtool.attr perl.attr \
Igor Gnatenko 323283
-	perllib.attr pkgconfig.attr python.attr ocaml.attr script.attr \
Igor Gnatenko 323283
+	appdata.attr debuginfo.attr desktop.attr elf.attr font.attr libtool.attr \
Igor Gnatenko 323283
+	perl.attr perllib.attr pkgconfig.attr python.attr ocaml.attr script.attr \
Igor Gnatenko 323283
 	mono.attr
Igor Gnatenko 323283
 
Igor Gnatenko 323283
 EXTRA_DIST = $(fattrs_DATA)
Igor Gnatenko 323283
diff --git a/fileattrs/debuginfo.attr b/fileattrs/debuginfo.attr
Igor Gnatenko 323283
new file mode 100644
Igor Gnatenko 323283
index 000000000..03f453843
Igor Gnatenko 323283
--- /dev/null
Igor Gnatenko 323283
+++ b/fileattrs/debuginfo.attr
Igor Gnatenko 323283
@@ -0,0 +1,2 @@
Igor Gnatenko 323283
+%__debuginfo_provides %{_rpmconfigdir}/debuginfo.prov
Igor Gnatenko 323283
+%__debuginfo_path ^/usr/lib/debug/
Igor Gnatenko 323283
diff --git a/macros.in b/macros.in
Igor Gnatenko 323283
index 2a114ccd7..962b84ade 100644
Igor Gnatenko 323283
--- a/macros.in
Igor Gnatenko 323283
+++ b/macros.in
Igor Gnatenko 323283
@@ -200,7 +200,8 @@
Igor Gnatenko 323283
 %package debuginfo\
Igor Gnatenko 323283
 Summary: Debug information for package %{name}\
Igor Gnatenko 323283
 Group: Development/Debug\
Igor Gnatenko 323283
-AutoReqProv: 0\
Igor Gnatenko 323283
+AutoReq: 0\
Igor Gnatenko 323283
+AutoProv: 1\
Igor Gnatenko 323283
 %description debuginfo\
Igor Gnatenko 323283
 This package provides debug information for package %{name}.\
Igor Gnatenko 323283
 Debug information is useful when developing applications that use this\
Igor Gnatenko 323283
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
Igor Gnatenko 323283
index 036105d63..8e60c3ce7 100644
Igor Gnatenko 323283
--- a/scripts/Makefile.am
Igor Gnatenko 323283
+++ b/scripts/Makefile.am
Igor Gnatenko 323283
@@ -10,6 +10,7 @@ EXTRA_DIST = \
Igor Gnatenko 323283
 	brp-strip-shared brp-strip-static-archive \
Igor Gnatenko 323283
 	check-files check-prereqs \
Igor Gnatenko 323283
 	check-buildroot check-rpaths check-rpaths-worker \
Igor Gnatenko 323283
+	debuginfo.prov \
Igor Gnatenko 323283
 	find-debuginfo.sh find-lang.sh \
Igor Gnatenko 323283
 	perl.prov perl.req pythondeps.sh \
Igor Gnatenko 323283
 	rpmdb_loadcvt rpm.daily rpm.log rpm.supp rpm2cpio.sh \
Igor Gnatenko 323283
@@ -29,6 +30,7 @@ rpmconfig_SCRIPTS = \
Igor Gnatenko 323283
 	brp-strip-shared brp-strip-static-archive \
Igor Gnatenko 323283
 	check-files check-prereqs \
Igor Gnatenko 323283
 	check-buildroot check-rpaths check-rpaths-worker \
Igor Gnatenko 323283
+	debuginfo.prov \
Igor Gnatenko 323283
 	find-lang.sh find-requires find-provides \
Igor Gnatenko 323283
 	perl.prov perl.req pythondeps.sh \
Igor Gnatenko 323283
 	mono-find-requires mono-find-provides \
Igor Gnatenko 323283
diff --git a/scripts/debuginfo.prov b/scripts/debuginfo.prov
Igor Gnatenko 323283
new file mode 100755
Igor Gnatenko 323283
index 000000000..a8636c976
Igor Gnatenko 323283
--- /dev/null
Igor Gnatenko 323283
+++ b/scripts/debuginfo.prov
Igor Gnatenko 323283
@@ -0,0 +1,14 @@
Igor Gnatenko 323283
+#!/bin/sh
Igor Gnatenko 323283
+
Igor Gnatenko 323283
+while read instfile; do
Igor Gnatenko 323283
+  case "$instfile" in
Igor Gnatenko 323283
+    */usr/lib/debug/.build-id/*.debug)
Igor Gnatenko 323283
+      if [ -f "$instfile" ]; then
Igor Gnatenko 323283
+        BUILDID=$(echo "$instfile" | sed -ne 's|.*/usr/lib/debug/.build-id/\([0-9a-f]\+\)/\([0-9a-f]\+\)\.debug|\1\2|p')
Igor Gnatenko 323283
+        if [ -n "$BUILDID" ]; then
Igor Gnatenko 323283
+          echo "debuginfo(build-id) = $BUILDID"
Igor Gnatenko 323283
+        fi
Igor Gnatenko 323283
+      fi
Igor Gnatenko 323283
+      ;;
Igor Gnatenko 323283
+  esac
Igor Gnatenko 323283
+done