Modify eu-strip option to perform strip in post script of rpm package & add option...
[platform/upstream/rpm.git] / scripts / find-debuginfo.sh
index 8b7a6c4..885b9b1 100644 (file)
@@ -2,7 +2,7 @@
 #find-debuginfo.sh - automagically generate debug info and file list
 #for inclusion in an rpm spec file.
 #
-# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r]
+# Usage: find-debuginfo.sh [--strict-build-id] [--strip-disable] [--strip-option] [-g] [-r]
 #                         [-o debugfiles.list]
 #                         [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
 #                         [builddir]
@@ -32,6 +32,12 @@ strip_r=false
 # Barf on missing build IDs.
 strict=false
 
+# With --strip-disable arg, no strip
+strip_disable=false
+
+# With --strip-option arg, this will be used as arg. of eu-strip
+strip_option=
+
 BUILDDIR=.
 out=debugfiles.list
 nout=0
@@ -40,6 +46,12 @@ while [ $# -gt 0 ]; do
   --strict-build-id)
     strict=true
     ;;
+  --strip-disable)
+    strip_disable=true
+    ;;
+  *--strip-option*)
+    strip_option=$(echo $1 | sed 's/--strip-option=//')
+    ;;
   -g)
     strip_g=true
     ;;
@@ -95,17 +107,27 @@ debugdir="${RPM_BUILD_ROOT}/usr/lib/debug"
 
 strip_to_debug()
 {
+  local g=
   local r=
+
+  if test "$strip_disable" = true ; then
+      exit
+  fi
+
   $strip_r && r=--reloc-debug-sections
+  $strip_g && case "$(file -bi "$2")" in
+  application/x-sharedlib*) g=-g ;;
+  esac
+
   case $2 in
       *.ko)
-         # don't attempt to create a minimal backtrace binary for
-         # kernel modules as this just causes the stripping process
-         # to be skipped entirely
-         eu-strip --remove-comment $r -f "$1" "$2" || exit
-         ;;
+          # don't attempt to create a minimal backtrace binary for
+          # kernel modules as this just causes the stripping process
+          # to be skipped entirely
+          eu-strip --remove-comment $r $strip_option -f "$1" "$2" || exit
+          ;;
       *)
-         eu-strip --remove-comment -g -f "$1" "$2" || exit
+          eu-strip --remove-comment $g $strip_option -f "$1" "$2" || exit
   esac
   chmod 444 "$1" || exit
 }
@@ -317,6 +339,9 @@ while read nlinks inum f; do
          if test "$NO_DEBUGINFO_STRIP_DEBUG" = true ; then
              strip_option=
          fi
+          if test "$strip_disable" = true ; then
+              strip_option=
+          fi
          objcopy --add-gnu-debuglink=$debugfn -R .comment -R .GCC.command.line $strip_option $f
          chmod $mode $f
       ) || :