rpm-build/scripts/process-debuginfo.in
Vitaly Chikunov f73a3de55c process-debuginfo: Do not eu-elfcompress vmlinux.debug
Allow `crash` (gdb-7.6 based) to work out of the box.

Otherwise it will fail with the error:

  Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4)

Alas, it will not be able to load debuginfo for the ko modules, but, advanced
user can `eu-elfcompress -t none` them manually.

We can't keep modules uncompressed due to `cpio archive too big - 4136M'
RPM build error.
2020-07-06 08:48:55 +03:00

93 lines
2.4 KiB
Bash
Executable File

#!/bin/sh -efu
#
# Process single file for debuginfo business.
# (Will be run multiple instances in parallel.)
#
# Copyright (c) 2020 Vitaly Chikunov <vt@altlinux.org>. Based on brp-debuginfo
# written by Alexey Tourbin <at@altlinux.org>. Based on find-debuginfo.sh
# by Jeff Johnson <jbj@rpm5.org> and Roland McGrath <roland@redhat.com>.
# License: GPLv2+.
. @RPMCONFIGDIR@/functions
ValidateBuildRoot
cd "$RPM_BUILD_ROOT"
mkdir -p .tmp
f=$1
rezip=
elfcompress=
if [ -z "${f#./lib/modules/*.ko}" ]; then
elfcompress=yes
elif [ -z "${f#./lib/modules/*.ko.[gx]z}" ]; then
rezip=${f##*.}
rezip=${rezip/gz/gzip}
# Compressed module: uncompress it, and work with uncompressed one.
$rezip --decompress --force "$f"
f=${f%.[gx]z}
elfcompress=yes
elif [ -z "${f##./boot/vmlinuz-*}" ]; then
# Compressed kernel: trigger extraction of vmlinux from the source.
kver=${f#./boot/vmlinuz-}
vmlinuxs=$(set +f; ls "$RPM_BUILD_DIR"/kernel-image-*/kernel-source-*/vmlinux)
vmlinuxd=./usr/lib/debug/lib/modules/$kver/vmlinux
if [ -f "$vmlinuxs" ]; then
install -pD -m644 "$vmlinuxs" "$vmlinuxd"
f=$vmlinuxd
else
echo "Warning: vmlinux not found for -debuginfo" >&2
fi
fi
debugf=./usr/lib/debug${f#.}.debug
strip='--strip-all'
for pat in ${RPM_BRP_STRIP_DEBUG-}; do
if [ -z "${f##.$pat}" ]; then
strip='--strip-debug'
break
fi
done
for pat in ${RPM_BRP_STRIP_NONE-}; do
if [ -z "${f##.$pat}" ]; then
strip=
break
fi
done
timestamp=$(date --iso-8601=ns --reference="$f")
@RPMCONFIGDIR@/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug -l .tmp/src.$$ "$f"
if [ -n "$strip" ]; then
mkdir -p "${debugf%/*}"
LD_ORIGIN_PATH=/usr/bin eu-strip $strip --remove-comment -f "$debugf" "$f"
if [ -n "$elfcompress" ]; then
LD_ORIGIN_PATH=/usr/bin eu-elfcompress --quiet "$debugf"
fi
touch --date=$timestamp "$debugf" "$f"
chmod 644 "$debugf"
else
touch --date=$timestamp "$f"
fi
mkdir -p .debuginfo/src/"${f%/*}"
awk 'BEGIN{RS="\0";ORS="\n"}{print}' .tmp/src.$$ |LC_ALL=C sort -u |
while read -r src; do
[ -f "$RPM_BUILD_DIR"/"$src" ] || continue
if [ ! -f ./usr/src/debug/"$src" ]; then
install -pD -m644 "$RPM_BUILD_DIR"/"$src" ./usr/src/debug/"$src".$$
mv -f ./usr/src/debug/"$src".$$ ./usr/src/debug/"$src"
fi
printf '%s\n' /usr/src/debug/"$src"
done >.debuginfo/src/"$f"
rm .tmp/src.$$
if [ -n "$rezip" ]; then
# Compress module, move uncompressed into debug tree.
$rezip --keep --force "$f"
mv "$f" ./usr/lib/debug"${f#.}"
fi