From 0c5a1e77532ef0047d411d8782188a1ec74896d6 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Wed, 11 May 2022 13:54:24 -0700 Subject: [PATCH] kpatch-build: make xtrace output less verbose With '--debug', most of the xtrace output shows the reading of the .config and Module.symvers files, which isn't very useful and floods the rest of the xtrace output. Temporarily disable xtrace before reading the files. Signed-off-by: Josh Poimboeuf --- kpatch-build/kpatch-build | 54 ++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index b1f03e3..f8745d4 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -97,6 +97,18 @@ logger() { fi } +trace_on() { + if [[ $DEBUG -eq 1 ]] || [[ $DEBUG -ge 3 ]]; then + set -o xtrace + fi +} + +trace_off() { + if [[ $DEBUG -eq 1 ]] || [[ $DEBUG -ge 3 ]]; then + set +o xtrace + fi +} + save_env() { export -p | grep -wv -e 'OLDPWD=' -e 'PWD=' > "$ENVFILE" } @@ -619,9 +631,7 @@ if [[ ${#PATCH_LIST[@]} -eq 0 ]]; then exit 1 fi -if [[ $DEBUG -eq 1 ]] || [[ $DEBUG -ge 3 ]]; then - set -o xtrace -fi +trace_on if [[ -n "$SRCRPM" ]]; then if [[ -n "$ARCHVERSION" ]]; then @@ -822,9 +832,11 @@ fi # kernel option checking +trace_off "reading .config" # Don't check external file. # shellcheck disable=SC1090 source "$CONFIGFILE" +trace_on [[ -z "$CONFIG_DEBUG_INFO" ]] && die "kernel doesn't have 'CONFIG_DEBUG_INFO' enabled" @@ -971,26 +983,28 @@ fi grep -q vmlinux "$KERNEL_SRCDIR/Module.symvers" || die "truncated $KERNEL_SRCDIR/Module.symvers file" if [[ -n "$CONFIG_MODVERSIONS" ]]; then - while read -ra sym_line; do - if [[ ${#sym_line[@]} -lt 4 ]]; then - die "Malformed ${TEMPDIR}/Module.symvers file" - fi + trace_off "reading Module.symvers" + while read -ra sym_line; do + if [[ ${#sym_line[@]} -lt 4 ]]; then + die "Malformed ${TEMPDIR}/Module.symvers file" + fi - sym=${sym_line[1]} + sym=${sym_line[1]} - read -ra patched_sym_line <<< "$(grep "\s$sym\s" "$BUILDDIR/Module.symvers")" - if [[ ${#patched_sym_line[@]} -lt 4 ]]; then - die "Malformed symbol entry for ${sym} in ${BUILDDIR}/Module.symvers file" - fi + read -ra patched_sym_line <<< "$(grep "\s$sym\s" "$BUILDDIR/Module.symvers")" + if [[ ${#patched_sym_line[@]} -lt 4 ]]; then + die "Malformed symbol entry for ${sym} in ${BUILDDIR}/Module.symvers file" + fi - # Assume that both original and patched symvers have the same format. - # In both cases, the symbol should have the same CRC, belong to the same - # Module/Namespace and have the same export type. - if [[ ${#sym_line[@]} -ne ${#patched_sym_line[@]} || \ - "${sym_line[*]}" != "${patched_sym_line[*]}" ]]; then - warn "Version disagreement for symbol ${sym}" - fi - done < "${TEMPDIR}/Module.symvers" + # Assume that both original and patched symvers have the same format. + # In both cases, the symbol should have the same CRC, belong to the same + # Module/Namespace and have the same export type. + if [[ ${#sym_line[@]} -ne ${#patched_sym_line[@]} || \ + "${sym_line[*]}" != "${patched_sym_line[*]}" ]]; then + warn "Version disagreement for symbol ${sym}" + fi + done < "${TEMPDIR}/Module.symvers" + trace_on fi # Read as words, no quotes.