alexk / rpms / rpm

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