richardphibel / rpms / rpm

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