richardphibel / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
648606
--- rpm-4.10.0/scripts/find-debuginfo.sh	2012-03-20 09:07:25.000000000 +0100
648606
+++ rpm-4.10.0/scripts/find-debuginfo.sh.jj	2012-06-19 12:32:33.147503858 +0200
648606
@@ -4,6 +4,8 @@ 
648606
 #
648606
 # Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r]
648606
 #	 		   [-o debugfiles.list]
648606
+#			   [--run-dwz] [--dwz-low-mem-die-limit N]
648606
+#			   [--dwz-max-die-limit N]
648606
 #			   [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
648606
 #			   [builddir]
648606
 #
648606
@@ -20,6 +22,10 @@ 
648606
 # The -p argument is an grep -E -style regexp matching the a file name,
648606
 # and must not use anchors (^ or $).
648606
 #
648606
+# The --run-dwz flag instructs find-debuginfo.sh to run the dwz utility
648606
+# if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
648606
+# provide detailed limits.  See dwz(1) -l and -L option for details.
648606
+#
648606
 # All file names in switches are relative to builddir (. if not given).
648606
 #
648606
 
648606
@@ -32,6 +38,11 @@ strip_r=false
648606
 # Barf on missing build IDs.
648606
 strict=false
648606
 
648606
+# DWZ parameters.
648606
+run_dwz=false
648606
+dwz_low_mem_die_limit=
648606
+dwz_max_die_limit=
648606
+
648606
 BUILDDIR=.
648606
 out=debugfiles.list
648606
 nout=0
648606
@@ -40,6 +51,17 @@ while [ $# -gt 0 ]; do
648606
   --strict-build-id)
648606
     strict=true
648606
     ;;
648606
+  --run-dwz)
648606
+    run_dwz=true
648606
+    ;;
648606
+  --dwz-low-mem-die-limit)
648606
+    dwz_low_mem_die_limit=$2
648606
+    shift
648606
+    ;;
648606
+  --dwz-max-die-limit)
648606
+    dwz_max_die_limit=$2
648606
+    shift
648606
+    ;;
648606
   -g)
648606
     strip_g=true
648606
     ;;
648606
@@ -266,6 +288,37 @@ while read nlinks inum f; do
648606
   fi
648606
 done || exit
648606
 
648606
+# Invoke the DWARF Compressor utility.
648606
+if $run_dwz && type dwz >/dev/null 2>&1 \
648606
+   && [ -d "${RPM_BUILD_ROOT}/usr/lib/debug" ]; then
648606
+  dwz_files="`cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f -name \*.debug`"
648606
+  if [ -n "${dwz_files}" ]; then
648606
+    dwz_multifile_name="${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}-${RPM_PACKAGE_RELEASE}.${RPM_ARCH}"
648606
+    dwz_multifile_suffix=
648606
+    dwz_multifile_idx=0
648606
+    while [ -f "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}${dwz_multifile_suffix}" ]; do
648606
+      let ++dwz_multifile_idx
648606
+      dwz_multifile_suffix=".${dwz_multifile_idx}"
648606
+    done
648606
+    dwz_multfile_name="${dwz_multifile_name}${dwz_multifile_suffix}"
648606
+    dwz_opts="-h -q -r -m .dwz/${dwz_multifile_name}"
648606
+    mkdir -p "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz"
648606
+    [ -n "${dwz_low_mem_die_limit}" ] \
648606
+      && dwz_opts="${dwz_opts} -l ${dwz_low_mem_die_limit}"
648606
+    [ -n "${dwz_max_die_limit}" ] \
648606
+      && dwz_opts="${dwz_opts} -L ${dwz_max_die_limit}"
648606
+    ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts $dwz_files )
648606
+    # Remove .dwz directory if empty
648606
+    rmdir "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz" 2>/dev/null
648606
+    if [ -f "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}" ]; then
648606
+      id="`readelf -Wn "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}" \
648606
+	     2>/dev/null | sed -n 's/^    Build ID: \([0-9a-f]\+\)/\1/p'`"
648606
+      [ -n "$id" ] \
648606
+	&& make_id_link "$id" "/usr/lib/debug/.dwz/${dwz_multifile_name}" .debug
648606
+    fi
648606
+  fi
648606
+fi
648606
+
648606
 # For each symlink whose target has a .debug file,
648606
 # make a .debug symlink to that file.
648606
 find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*" -type l -print |
648606
--- rpm-4.10.0/macros.in	2012-03-20 09:07:25.000000000 +0100
648606
+++ rpm-4.10.0/macros.in.jj	2012-06-19 12:32:33.147503858 +0200
648606
@@ -176,7 +176,7 @@ 
648606
 #	the script.  See the script for details.
648606
 #
648606
 %__debug_install_post   \
648606
-   %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
648606
+   %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
648606
 %{nil}
648606
 
648606
 #	Template for debug information sub-package.