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