File no_recompute_build_ids.diff of Package rpm

--- ./macros.in.orig	2018-05-09 12:41:51.318589439 +0000
+++ ./macros.in	2018-05-09 12:43:54.762257421 +0000
@@ -180,7 +180,7 @@
 #	the script.  See the script for details.
 #
 %__debug_install_post   \
-   %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
+   %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_no_recompute_build_ids:-n} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
 %{nil}
 
 #	Template for debug information sub-package.
@@ -439,6 +439,10 @@ package or when debugging this package.\
 #
 #%_missing_build_ids_terminate_build	1
 
+# Do not recompute build-ids but keep whatever is in the ELF file already.
+# Defaults to undefined (unset).
+#%_no_recompute_build_ids 1
+
 #
 # Use internal dependency generator rather than external helpers?
 %_use_internal_dependency_generator	1
--- ./scripts/find-debuginfo.sh.orig	2018-05-09 12:33:52.779876521 +0000
+++ ./scripts/find-debuginfo.sh	2018-05-09 12:36:36.311436684 +0000
@@ -32,6 +32,9 @@ strip_r=false
 # Barf on missing build IDs.
 strict=false
 
+# Do not recompute build IDs.
+no_recompute_build_id=false
+
 BUILDDIR=.
 out=debugfiles.list
 nout=0
@@ -43,6 +46,9 @@ while [ $# -gt 0 ]; do
   -g)
     strip_g=true
     ;;
+  -n)
+    no_recompute_build_id=true
+    ;;
   -o)
     if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then
       out=$2
@@ -280,9 +286,13 @@ while read nlinks inum f; do
   echo "extracting debug info from $f"
   mode=$(stat -c %a "$f")
   chmod +w "$f"
+  no_recompute=
+  if [ "$no_recompute_build_id" = "true" ]; then
+    no_recompute="-n"
+  fi
   id=$($(DEBUGEDIT=$(which debugedit 2>/dev/null); \
 	echo ${DEBUGEDIT:-/usr/lib/rpm/debugedit}) -b "$RPM_BUILD_DIR" \
-	-d /usr/src/debug -i -l "$SOURCEFILE" "$f") || exit
+	-d /usr/src/debug $no_recompute -i -l "$SOURCEFILE" "$f") || exit
   if [ $nlinks -gt 1 ]; then
     eval linkedid_$inum=\$id
   fi
--- ./tools/debugedit.c.orig	2018-05-09 12:36:59.971373048 +0000
+++ ./tools/debugedit.c	2018-05-09 12:40:56.542736762 +0000
@@ -84,6 +84,7 @@ char *dest_dir = NULL;
 char *list_file = NULL;
 int list_file_fd = -1;
 int do_build_id = 0;
+int no_recompute_build_id = 0;
 
 typedef struct
 {
@@ -1365,6 +1366,8 @@ static struct poptOption optionsTable[]
       "file where to put list of source and header file names", NULL },
     { "build-id",  'i', POPT_ARG_NONE, &do_build_id, 0,
       "recompute build ID note and print ID on stdout", NULL },
+    { "no-recompute-build-id",  'n', POPT_ARG_NONE, &no_recompute_build_id, 0,
+      "do not recompute build ID note even when -i is given", NULL },
       POPT_AUTOHELP
     { NULL, 0, 0, NULL, 0, NULL, NULL }
 };
@@ -1469,7 +1472,7 @@ handle_build_id (DSO *dso, Elf_Data *bui
       exit (1);
     }
 
-  if (!dirty_elf)
+  if (no_recompute_build_id || !dirty_elf)
     goto print;
 
   if (elf_update (dso->elf, ELF_C_NULL) < 0)
openSUSE Build Service is sponsored by