Process debuginfo in parallel

- Split processing of single binary into separate script.
- Call it from xargs -P.
This commit is contained in:
Виталий Чикунов 2020-06-24 21:33:29 +03:00
parent 7aa048df38
commit 5cc014bed6
4 changed files with 115 additions and 73 deletions

View File

@ -939,6 +939,7 @@ AC_OUTPUT([ Doxyfile Makefile rpmrc macros platform rpmpopt
scripts/find-lang scripts/find-lang
scripts/find-package scripts/find-package
scripts/find-debuginfo-files scripts/find-debuginfo-files
scripts/process-debuginfo
scripts/find-scriptlet-requires scripts/find-scriptlet-requires
scripts/fixup-binconfig scripts/fixup-binconfig
scripts/fixup-libraries scripts/fixup-libraries

View File

@ -6,7 +6,7 @@ EXTRA_DIST = \
posttrans-filetriggers 0ldconfig.filetrigger \ posttrans-filetriggers 0ldconfig.filetrigger \
debuginfo.req debuginfo.req.files debuginfo.prov debuginfo.prov.files \ debuginfo.req debuginfo.req.files debuginfo.prov debuginfo.prov.files \
functions find-package .provides.sh \ functions find-package .provides.sh \
find-debuginfo-files \ find-debuginfo-files process-debuginfo \
find-scriptlet-requires \ find-scriptlet-requires \
brp-adjust_libraries brp-alt brp-bytecompile_python \ brp-adjust_libraries brp-alt brp-bytecompile_python \
brp-check_contents brp-cleanup brp-compress brp-debuginfo \ brp-check_contents brp-cleanup brp-compress brp-debuginfo \
@ -42,7 +42,7 @@ configdir = ${prefix}/lib/rpm
config_DATA = 0common-files.req.list # .provides.sh config_DATA = 0common-files.req.list # .provides.sh
config_SCRIPTS = \ config_SCRIPTS = \
debuginfo.req debuginfo.req.files debuginfo.prov debuginfo.prov.files \ debuginfo.req debuginfo.req.files debuginfo.prov debuginfo.prov.files \
find-debuginfo-files \ find-debuginfo-files process-debuginfo \
find-scriptlet-requires \ find-scriptlet-requires \
brp-alt \ brp-alt \
compress_files \ compress_files \
@ -78,6 +78,7 @@ install-data-local:
$(INSTALL) -m755 brp-verify-info $(DESTDIR)$(configdir)/brp.d/040-verify-info.brp $(INSTALL) -m755 brp-verify-info $(DESTDIR)$(configdir)/brp.d/040-verify-info.brp
$(INSTALL) -m755 brp-adjust_libraries $(DESTDIR)$(configdir)/brp.d/048-adjust_libraries.brp $(INSTALL) -m755 brp-adjust_libraries $(DESTDIR)$(configdir)/brp.d/048-adjust_libraries.brp
$(INSTALL) -m755 brp-debuginfo $(DESTDIR)$(configdir)/brp.d/056-debuginfo.brp $(INSTALL) -m755 brp-debuginfo $(DESTDIR)$(configdir)/brp.d/056-debuginfo.brp
$(INSTALL) -m755 process-debuginfo $(DESTDIR)$(configdir)/process-debuginfo
$(INSTALL) -m755 brp-verify_elf $(DESTDIR)$(configdir)/brp.d/064-verify_elf.brp $(INSTALL) -m755 brp-verify_elf $(DESTDIR)$(configdir)/brp.d/064-verify_elf.brp
$(INSTALL) -m755 brp-bytecompile_python $(DESTDIR)$(configdir)/brp.d/072-bytecompile_python.brp $(INSTALL) -m755 brp-bytecompile_python $(DESTDIR)$(configdir)/brp.d/072-bytecompile_python.brp
$(INSTALL) -m755 brp-hardlink_pyo_pyc $(DESTDIR)$(configdir)/brp.d/128-hardlink_pyo_pyc.brp $(INSTALL) -m755 brp-hardlink_pyo_pyc $(DESTDIR)$(configdir)/brp.d/128-hardlink_pyo_pyc.brp

View File

@ -5,6 +5,7 @@
# #
# Written by Alexey Tourbin <at@altlinux.org>. Based on find-debuginfo.sh # Written by Alexey Tourbin <at@altlinux.org>. Based on find-debuginfo.sh
# by Jeff Johnson <jbj@rpm5.org> and Roland McGrath <roland@redhat.com>. # by Jeff Johnson <jbj@rpm5.org> and Roland McGrath <roland@redhat.com>.
# Copyright (c) 2020 Vitaly Chikunov <vt@altlinux.org>.
# License: GPLv2+. # License: GPLv2+.
. @RPMCONFIGDIR@/functions . @RPMCONFIGDIR@/functions
@ -30,36 +31,27 @@ sed -n -e '/ ELF .* shared object, no machine, /d' \
-e 's/^\(\.\/lib\/modules\/.*\.ko\.[gx]z\)\t.* \(gzip\|xz\) compressed data.*/\1/p' \ -e 's/^\(\.\/lib\/modules\/.*\.ko\.[gx]z\)\t.* \(gzip\|xz\) compressed data.*/\1/p' \
-e 's/^\(\.\/boot\/vmlinuz-.*\)\t.*/\1/p' | -e 's/^\(\.\/boot\/vmlinuz-.*\)\t.*/\1/p' |
xargs -r --delimiter='\n' stat -c '%h %i %n' >.tmp/flist xargs -r --delimiter='\n' stat -c '%h %i %n' >.tmp/flist
while read -r nlink ino f; do
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
elfcompress=yes
else
echo "Warning: vmlinux not found for -debuginfo" >&2
fi
fi
debugf=./usr/lib/debug${f#.}.debug # Filter out what will be hard-linked later and process the rest.
while read -r nlink ino f; do
if [ "$nlink" -gt 1 ]; then if [ "$nlink" -gt 1 ]; then
eval f0="\${f0_$ino-}" eval f0="\${f0_$ino-}"
if [ -n "$f0" ]; then if [ -n "$f0" ]; then
printf '%u %s\n' "$ino" "$f" >&3
continue
else
eval f0_$ino="\$f"
fi
fi
printf '%s\n' "$f"
done <.tmp/flist \
3>.tmp/link-list \
| xargs -r -P$(nproc) -n1 @RPMCONFIGDIR@/process-debuginfo
# Hard-link debuginfo for hard-linked binaries
while read -r ino f; do
debugf=./usr/lib/debug${f#.}.debug
eval f0="\${f0_$ino-}"
debugf0=./usr/lib/debug${f0#.}.debug debugf0=./usr/lib/debug${f0#.}.debug
if [ -f "$debugf0" ]; then if [ -f "$debugf0" ]; then
mkdir -p "${debugf%/*}" mkdir -p "${debugf%/*}"
@ -67,52 +59,7 @@ while read -r nlink ino f; do
fi fi
mkdir -p .debuginfo/src/"${f%/*}" mkdir -p .debuginfo/src/"${f%/*}"
ln -nf .debuginfo/src/"$f0" .debuginfo/src/"$f" ln -nf .debuginfo/src/"$f0" .debuginfo/src/"$f"
continue done <.tmp/link-list
else
eval f0_$ino="\$f"
fi
fi
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
touch -r "$f" .tmp/stamp
@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 "$debugf"
fi
touch -r .tmp/stamp "$debugf" "$f"
chmod 644 "$debugf"
else
touch -r .tmp/stamp "$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
[ -f ./usr/src/debug/"$src" ] ||
install -pD -m644 "$RPM_BUILD_DIR"/"$src" ./usr/src/debug/"$src"
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
done <.tmp/flist
# Make symbolic links that mimic the original tree. # Make symbolic links that mimic the original tree.
find . '(' -path './.*' $prune_tests ')' -prune -o -type l -print |sort >.tmp/flist find . '(' -path './.*' $prune_tests ')' -prune -o -type l -print |sort >.tmp/flist

93
scripts/process-debuginfo.in Executable file
View File

@ -0,0 +1,93 @@
#!/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
elfcompress=yes
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