From fefced0b49a1b0cb70c375232cbdda6f6e30fda5 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Tue, 15 Sep 2026 12:58:14 -0300 Subject: [PATCH] fix(xcat-core): otherpkgs prints the whole package list on every run The otherpkgs postscript writes two diagnostic lines for each package sublist: the split package array with its size, and the detected package manager. On a list with tens of entries these lines fill the updatenode output and the node log, and hide the install results. The two echo commands sit in xCAT/postscripts/otherpkgs, after the IFS split that builds pkgsarray, and no condition guards them. Every other diagnostic in the script runs only when VERBOSE is set. This change puts the two lines in the same "if [ $VERBOSE ]" block the rest of the script uses. xCAT-test/bats/postscripts_otherpkgs.bats runs the split and the lines that follow it. One case asserts no output when VERBOSE is empty, and fails on the parent commit. A second case asserts both lines are still printed when VERBOSE is set. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> (cherry picked from commit 402a6f4a45c70594435f916b934f10e39b7a22a3) --- xCAT-test/bats/postscripts_otherpkgs.bats | 24 +++++++++++++++++++++++ xCAT/postscripts/otherpkgs | 6 ++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/xCAT-test/bats/postscripts_otherpkgs.bats b/xCAT-test/bats/postscripts_otherpkgs.bats index 3a7ffb4cc..26495412e 100644 --- a/xCAT-test/bats/postscripts_otherpkgs.bats +++ b/xCAT-test/bats/postscripts_otherpkgs.bats @@ -334,3 +334,27 @@ run_sdk_block() [ "$status" -eq 0 ] grep -q 'xCAT-sles15-sdk1' "$LOGGER_LOG" } + +# Drives the package list split and the two diagnostic lines that follow it. The range ends on +# the "for" line that starts the package loop, and that line is dropped: the loop is not part of +# what is measured. +run_pkglist_diagnostics() +{ + local range + range="$(extract_line_range "$OTHERPKGS" 'pkgsarray=' '^[[:space:]]*for x in')" || return 99 + local pkglist="foo bar" hasyum=1 yumcmd=dnf hasapt=0 haszypper=0 oifs=$IFS + eval "$(printf '%s\n' "$range" | sed '$d')" +} + +@test "the package list diagnostics print nothing when VERBOSE is not set" { + VERBOSE= run run_pkglist_diagnostics + [ "$status" -eq 0 ] + [ -z "$output" ] +} + +@test "the package list diagnostics print the list and the package manager under VERBOSE" { + VERBOSE=1 run run_pkglist_diagnostics + [ "$status" -eq 0 ] + [[ "$output" == *'pkgsarray: foo bar, 2'* ]] + [[ "$output" == *'yum/dnf: 1 (dnf), apt: 0, zypper: 0'* ]] +} diff --git a/xCAT/postscripts/otherpkgs b/xCAT/postscripts/otherpkgs index 49383801c..70a90376a 100755 --- a/xCAT/postscripts/otherpkgs +++ b/xCAT/postscripts/otherpkgs @@ -708,8 +708,10 @@ while [ $op_index -le $OTHERPKGS_INDEX ]; do IFS=$',' pkgsarray=($pkglist) IFS=$oifs - echo "pkgsarray: ${pkgsarray[@]}, ${#pkgsarray[@]}" - echo "yum/dnf: $hasyum ($yumcmd), apt: $hasapt, zypper: $haszypper" + if [ $VERBOSE ]; then + echo "pkgsarray: ${pkgsarray[@]}, ${#pkgsarray[@]}" + echo "yum/dnf: $hasyum ($yumcmd), apt: $hasapt, zypper: $haszypper" + fi for x in ${pkgsarray[@]} do #check if the file name starts with -- or -.