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