aboutsummaryrefslogtreecommitdiffstats
path: root/find-debuginfo.sh
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-07-31 10:36:47 +0000
committerThierry Vignaud <tv@mageia.org>2012-07-31 10:36:47 +0000
commitee7e65693c0b7f58404e4f5053e0a521601e3c5b (patch)
tree17c5d4fcb5321e04737b019570fb5fcc3c48d396 /find-debuginfo.sh
parent27f37f8ca63e0834afc9fa57852b7b5971c87957 (diff)
downloadrpm-setup-ee7e65693c0b7f58404e4f5053e0a521601e3c5b.tar
rpm-setup-ee7e65693c0b7f58404e4f5053e0a521601e3c5b.tar.gz
rpm-setup-ee7e65693c0b7f58404e4f5053e0a521601e3c5b.tar.bz2
rpm-setup-ee7e65693c0b7f58404e4f5053e0a521601e3c5b.tar.xz
rpm-setup-ee7e65693c0b7f58404e4f5053e0a521601e3c5b.zip
shrunk debug packages through using dwz
(https://fedoraproject.org/wiki/Features/DwarfCompressor)
Diffstat (limited to 'find-debuginfo.sh')
-rwxr-xr-xfind-debuginfo.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/find-debuginfo.sh b/find-debuginfo.sh
index c2bc7df..0feb1c0 100755
--- a/find-debuginfo.sh
+++ b/find-debuginfo.sh
@@ -4,6 +4,8 @@
#
# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m]
# [-o debugfiles.list]
+# [--run-dwz] [--dwz-low-mem-die-limit N]
+# [--dwz-max-die-limit N]
# [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
# [builddir]
#
@@ -20,6 +22,10 @@
# The -p argument is an grep -E -style regexp matching the a file name,
# and must not use anchors (^ or $).
#
+# The --run-dwz flag instructs find-debuginfo.sh to run the dwz utility
+# if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
+# provide detailed limits. See dwz(1) -l and -L option for details.
+#
# All file names in switches are relative to builddir (. if not given).
#
@@ -35,6 +41,11 @@ include_minidebug=false
# Barf on missing build IDs.
strict=false
+# DWZ parameters.
+run_dwz=false
+dwz_low_mem_die_limit=
+dwz_max_die_limit=
+
BUILDDIR=.
out=debugfiles.list
nout=0
@@ -43,6 +54,17 @@ while [ $# -gt 0 ]; do
--strict-build-id)
strict=true
;;
+ --run-dwz)
+ run_dwz=true
+ ;;
+ --dwz-low-mem-die-limit)
+ dwz_low_mem_die_limit=$2
+ shift
+ ;;
+ --dwz-max-die-limit)
+ dwz_max_die_limit=$2
+ shift
+ ;;
-g)
strip_g=true
;;
@@ -313,6 +335,37 @@ while read nlinks inum f; do
fi
done || exit
+# Invoke the DWARF Compressor utility.
+if $run_dwz && type dwz >/dev/null 2>&1 \
+ && [ -d "${RPM_BUILD_ROOT}/usr/lib/debug" ]; then
+ dwz_files="`cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f -name \*.debug`"
+ if [ -n "${dwz_files}" ]; then
+ dwz_multifile_name="${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}-${RPM_PACKAGE_RELEASE}.${RPM_ARCH}"
+ dwz_multifile_suffix=
+ dwz_multifile_idx=0
+ while [ -f "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}${dwz_multifile_suffix}" ]; do
+ let ++dwz_multifile_idx
+ dwz_multifile_suffix=".${dwz_multifile_idx}"
+ done
+ dwz_multfile_name="${dwz_multifile_name}${dwz_multifile_suffix}"
+ dwz_opts="-h -q -r -m .dwz/${dwz_multifile_name}"
+ mkdir -p "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz"
+ [ -n "${dwz_low_mem_die_limit}" ] \
+ && dwz_opts="${dwz_opts} -l ${dwz_low_mem_die_limit}"
+ [ -n "${dwz_max_die_limit}" ] \
+ && dwz_opts="${dwz_opts} -L ${dwz_max_die_limit}"
+ ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts $dwz_files )
+ # Remove .dwz directory if empty
+ rmdir "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz" 2>/dev/null
+ if [ -f "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}" ]; then
+ id="`readelf -Wn "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}" \
+ 2>/dev/null | sed -n 's/^ Build ID: \([0-9a-f]\+\)/\1/p'`"
+ [ -n "$id" ] \
+ && make_id_link "$id" "/usr/lib/debug/.dwz/${dwz_multifile_name}" .debug
+ fi
+ fi
+fi
+
# For each symlink whose target has a .debug file,
# make a .debug symlink to that file.
find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*" -type l -print |