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 <jpoimboe@redhat.com>
This commit is contained in:
Josh Poimboeuf 2022-05-11 13:54:24 -07:00
parent f6e0142b3c
commit 0c5a1e7753
1 changed files with 34 additions and 20 deletions

View File

@ -97,6 +97,18 @@ logger() {
fi 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() { save_env() {
export -p | grep -wv -e 'OLDPWD=' -e 'PWD=' > "$ENVFILE" export -p | grep -wv -e 'OLDPWD=' -e 'PWD=' > "$ENVFILE"
} }
@ -619,9 +631,7 @@ if [[ ${#PATCH_LIST[@]} -eq 0 ]]; then
exit 1 exit 1
fi fi
if [[ $DEBUG -eq 1 ]] || [[ $DEBUG -ge 3 ]]; then trace_on
set -o xtrace
fi
if [[ -n "$SRCRPM" ]]; then if [[ -n "$SRCRPM" ]]; then
if [[ -n "$ARCHVERSION" ]]; then if [[ -n "$ARCHVERSION" ]]; then
@ -822,9 +832,11 @@ fi
# kernel option checking # kernel option checking
trace_off "reading .config"
# Don't check external file. # Don't check external file.
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "$CONFIGFILE" source "$CONFIGFILE"
trace_on
[[ -z "$CONFIG_DEBUG_INFO" ]] && die "kernel doesn't have 'CONFIG_DEBUG_INFO' enabled" [[ -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" grep -q vmlinux "$KERNEL_SRCDIR/Module.symvers" || die "truncated $KERNEL_SRCDIR/Module.symvers file"
if [[ -n "$CONFIG_MODVERSIONS" ]]; then if [[ -n "$CONFIG_MODVERSIONS" ]]; then
while read -ra sym_line; do trace_off "reading Module.symvers"
if [[ ${#sym_line[@]} -lt 4 ]]; then while read -ra sym_line; do
die "Malformed ${TEMPDIR}/Module.symvers file" if [[ ${#sym_line[@]} -lt 4 ]]; then
fi 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")" read -ra patched_sym_line <<< "$(grep "\s$sym\s" "$BUILDDIR/Module.symvers")"
if [[ ${#patched_sym_line[@]} -lt 4 ]]; then if [[ ${#patched_sym_line[@]} -lt 4 ]]; then
die "Malformed symbol entry for ${sym} in ${BUILDDIR}/Module.symvers file" die "Malformed symbol entry for ${sym} in ${BUILDDIR}/Module.symvers file"
fi fi
# Assume that both original and patched symvers have the same format. # 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 # In both cases, the symbol should have the same CRC, belong to the same
# Module/Namespace and have the same export type. # Module/Namespace and have the same export type.
if [[ ${#sym_line[@]} -ne ${#patched_sym_line[@]} || \ if [[ ${#sym_line[@]} -ne ${#patched_sym_line[@]} || \
"${sym_line[*]}" != "${patched_sym_line[*]}" ]]; then "${sym_line[*]}" != "${patched_sym_line[*]}" ]]; then
warn "Version disagreement for symbol ${sym}" warn "Version disagreement for symbol ${sym}"
fi fi
done < "${TEMPDIR}/Module.symvers" done < "${TEMPDIR}/Module.symvers"
trace_on
fi fi
# Read as words, no quotes. # Read as words, no quotes.