malmond / rpms / rpm

Forked from rpms/rpm 4 years ago
Clone
Blob Blame History Raw
From 1da9e839bb573b9187403983f5a69853ab364306 Mon Sep 17 00:00:00 2001
From: Pavlina Moravcova Varekova <pmoravco@redhat.com>
Date: Sun, 17 Mar 2019 06:47:26 +0100
Subject: [PATCH] Add flag to use strip -g instead of full strip on DSOs
 (RhBug:1663264)

The find-debuginfo.sh flag -g had exactly this meaning. But from
version rpm-4.13.0-alpha flag -g changes its behavior. It affects
both libraries and executables.

For some packages the original behavior was preferred. That is why
the new find-debuginfo.sh flag --g-libs is created.

Options -g and --g-libs are mutually exclusive.


Adjusted for rpm-4.14.2 in RHEL

--- rpm-4.14.2/scripts/find-debuginfo.sh.orig	2019-04-24 15:14:29.351010878 +0200
+++ rpm-4.14.2/scripts/find-debuginfo.sh	2019-04-24 15:19:42.296240705 +0200
@@ -4,6 +4,7 @@
 #
 # Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
 #			   [--keep-section SECTION] [--remove-section SECTION]
+#			   [--g-libs]
 #	 		   [-j N] [--jobs N]
 #	 		   [-o debugfiles.list]
 #	 		   [-S debugsourcefiles.list]
@@ -16,6 +17,8 @@
 #			   [builddir]
 #
 # The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
+# The --g-libs flag says to use strip -g instead of full strip ONLY on DSOs.
+# Options -g and --g-libs are mutually exclusive.
 # The -r flag says to use eu-strip --reloc-debug-sections.
 # Use --keep-section SECTION or --remove-section SECTION to explicitly
 # keep a (non-allocated) section in the main executable or explicitly
@@ -68,6 +71,9 @@
 # With -g arg, pass it to strip on libraries or executables.
 strip_g=false
 
+# With --g-libs arg, pass it to strip on libraries.
+strip_glibs=false
+
 # with -r arg, pass --reloc-debug-sections to eu-strip.
 strip_r=false
 
@@ -135,6 +141,9 @@
     unique_debug_src_base=$2
     shift
     ;;
+  --g-libs)
+    strip_glibs=true
+    ;;
   -g)
     strip_g=true
     ;;
@@ -204,6 +213,11 @@
   exit 2
 fi
 
+if ("$strip_g" = "true") && ("$strip_glibs" = "true"); then
+  echo >&2 "*** ERROR: -g  and --g-libs cannot be used together"
+  exit 2
+fi
+
 i=0
 while ((i < nout)); do
   outs[$i]="$BUILDDIR/${outs[$i]}"
@@ -237,6 +251,9 @@
   application/x-executable*) g=-g ;;
   application/x-pie-executable*) g=-g ;;
   esac
+  $strip_glibs && case "$(file -bi "$2")" in
+    application/x-sharedlib*) g=-g ;;
+  esac
   eu-strip --remove-comment $r $g ${keep_remove_args} -f "$1" "$2" || exit
   chmod 444 "$1" || exit
 }
@@ -430,8 +430,12 @@
   # libraries. Other executable ELF files (like kernel modules) don't need it.
   if [ "$include_minidebug" = "true" -a "$strip_g" = "false" ]; then
     skip_mini=true
+    if [ "$strip_glibs" = "false" ]; then
+      case "$(file -bi "$f")" in
+        application/x-sharedlib*) skip_mini=false ;;
+      esac
+    fi
     case "$(file -bi "$f")" in
-      application/x-sharedlib*) skip_mini=false ;;
       application/x-executable*) skip_mini=false ;;
       application/x-pie-executable*) skip_mini=false ;;
     esac