83a7c7
From 1da9e839bb573b9187403983f5a69853ab364306 Mon Sep 17 00:00:00 2001
83a7c7
From: Pavlina Moravcova Varekova <pmoravco@redhat.com>
83a7c7
Date: Sun, 17 Mar 2019 06:47:26 +0100
83a7c7
Subject: [PATCH] Add flag to use strip -g instead of full strip on DSOs
83a7c7
 (RhBug:1663264)
83a7c7
83a7c7
The find-debuginfo.sh flag -g had exactly this meaning. But from
83a7c7
version rpm-4.13.0-alpha flag -g changes its behavior. It affects
83a7c7
both libraries and executables.
83a7c7
83a7c7
For some packages the original behavior was preferred. That is why
83a7c7
the new find-debuginfo.sh flag --g-libs is created.
83a7c7
83a7c7
Options -g and --g-libs are mutually exclusive.
83a7c7
83a7c7
83a7c7
Adjusted for rpm-4.14.2 in RHEL
83a7c7
83a7c7
--- rpm-4.14.2/scripts/find-debuginfo.sh.orig	2019-04-24 15:14:29.351010878 +0200
83a7c7
+++ rpm-4.14.2/scripts/find-debuginfo.sh	2019-04-24 15:19:42.296240705 +0200
83a7c7
@@ -4,6 +4,7 @@
83a7c7
 #
83a7c7
 # Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
83a7c7
 #			   [--keep-section SECTION] [--remove-section SECTION]
83a7c7
+#			   [--g-libs]
83a7c7
 #	 		   [-j N] [--jobs N]
83a7c7
 #	 		   [-o debugfiles.list]
83a7c7
 #	 		   [-S debugsourcefiles.list]
83a7c7
@@ -16,6 +17,8 @@
83a7c7
 #			   [builddir]
83a7c7
 #
83a7c7
 # The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
83a7c7
+# The --g-libs flag says to use strip -g instead of full strip ONLY on DSOs.
83a7c7
+# Options -g and --g-libs are mutually exclusive.
83a7c7
 # The -r flag says to use eu-strip --reloc-debug-sections.
83a7c7
 # Use --keep-section SECTION or --remove-section SECTION to explicitly
83a7c7
 # keep a (non-allocated) section in the main executable or explicitly
83a7c7
@@ -68,6 +71,9 @@
83a7c7
 # With -g arg, pass it to strip on libraries or executables.
83a7c7
 strip_g=false
83a7c7
 
83a7c7
+# With --g-libs arg, pass it to strip on libraries.
83a7c7
+strip_glibs=false
83a7c7
+
83a7c7
 # with -r arg, pass --reloc-debug-sections to eu-strip.
83a7c7
 strip_r=false
83a7c7
 
83a7c7
@@ -135,6 +141,9 @@
83a7c7
     unique_debug_src_base=$2
83a7c7
     shift
83a7c7
     ;;
83a7c7
+  --g-libs)
83a7c7
+    strip_glibs=true
83a7c7
+    ;;
83a7c7
   -g)
83a7c7
     strip_g=true
83a7c7
     ;;
83a7c7
@@ -204,6 +213,11 @@
83a7c7
   exit 2
83a7c7
 fi
83a7c7
 
83a7c7
+if ("$strip_g" = "true") && ("$strip_glibs" = "true"); then
83a7c7
+  echo >&2 "*** ERROR: -g  and --g-libs cannot be used together"
83a7c7
+  exit 2
83a7c7
+fi
83a7c7
+
83a7c7
 i=0
83a7c7
 while ((i < nout)); do
83a7c7
   outs[$i]="$BUILDDIR/${outs[$i]}"
83a7c7
@@ -237,6 +251,9 @@
83a7c7
   application/x-executable*) g=-g ;;
83a7c7
   application/x-pie-executable*) g=-g ;;
83a7c7
   esac
83a7c7
+  $strip_glibs && case "$(file -bi "$2")" in
83a7c7
+    application/x-sharedlib*) g=-g ;;
83a7c7
+  esac
83a7c7
   eu-strip --remove-comment $r $g ${keep_remove_args} -f "$1" "$2" || exit
83a7c7
   chmod 444 "$1" || exit
83a7c7
 }
35cbef
@@ -430,8 +430,12 @@
83a7c7
   # libraries. Other executable ELF files (like kernel modules) don't need it.
83a7c7
   if [ "$include_minidebug" = "true" -a "$strip_g" = "false" ]; then
83a7c7
     skip_mini=true
83a7c7
+    if [ "$strip_glibs" = "false" ]; then
83a7c7
+      case "$(file -bi "$f")" in
83a7c7
+        application/x-sharedlib*) skip_mini=false ;;
83a7c7
+      esac
83a7c7
+    fi
83a7c7
     case "$(file -bi "$f")" in
83a7c7
-      application/x-sharedlib*) skip_mini=false ;;
83a7c7
       application/x-executable*) skip_mini=false ;;
35cbef
       application/x-pie-executable*) skip_mini=false ;;
83a7c7
     esac