2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-10-20 14:45:41 +00:00

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 402a6f4a45)
This commit is contained in:
Daniel Hilst
2026-09-15 12:58:14 -03:00
committed by github-actions[bot]
parent 75fb7a9758
commit fefced0b49
2 changed files with 28 additions and 2 deletions
+24
View File
@@ -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'* ]]
}
+4 -2
View File
@@ -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 -.