From 70e31f2f15d9eb0a6f721bbd9a0385a0599f29ce Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Mon, 14 Sep 2026 15:54:59 -0300 Subject: [PATCH] fix(xcat-core): the otherpkgs url repository guard tests a literal string Line 672 of xCAT/postscripts/otherpkgs reads [ -n "OTHERPKGDIR_INTERNET" ]. The $ is missing, so the test is on the name of the variable and is always true. The guard cannot select the case it was written for. The guard now tests $OTHERPKGDIR_INTERNET. postscripts_otherpkgs.bats extracts the condition from the script and runs it with the variable empty and with an http entry. Against the unfixed script the empty case is true. The block is inert when the variable is empty, because the loop inside it iterates an empty array, so the run of the postscript does not change. The guard is still wrong. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/bats/postscripts_otherpkgs.bats | 15 +++++++++++++++ xCAT/postscripts/otherpkgs | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/xCAT-test/bats/postscripts_otherpkgs.bats b/xCAT-test/bats/postscripts_otherpkgs.bats index 0883cacb7..4dc227d59 100644 --- a/xCAT-test/bats/postscripts_otherpkgs.bats +++ b/xCAT-test/bats/postscripts_otherpkgs.bats @@ -221,3 +221,18 @@ run_repo_postremove_block() [ "$status" -eq 0 ] grep -q 'oldfoo removed\.' "$LOGGER_LOG" } + +@test "the url repository guard is false when OTHERPKGDIR has no http entry" { + local guard cond + guard="$(extract_first_matching_line "$OTHERPKGS" 'OTHERPKGDIR_INTERNET" *[]] *; *then')" || return 99 + cond="${guard#*if }" + cond="${cond%%;then*}" + + OTHERPKGDIR_INTERNET="" + run eval "$cond" + [ "$status" -ne 0 ] + + OTHERPKGDIR_INTERNET="http://192.0.2.1/repo," + run eval "$cond" + [ "$status" -eq 0 ] +} diff --git a/xCAT/postscripts/otherpkgs b/xCAT/postscripts/otherpkgs index d3018eb7d..0d66899ca 100755 --- a/xCAT/postscripts/otherpkgs +++ b/xCAT/postscripts/otherpkgs @@ -669,7 +669,7 @@ while [ $op_index -le $OTHERPKGS_INDEX ]; do urlrepoindex=0 #add repo for url repos in otherpkgdir - if [ -n "OTHERPKGDIR_INTERNET" ];then + if [ -n "$OTHERPKGDIR_INTERNET" ];then OIFS=$IFS IFS=',' OTHERPKGDIRLIST_INTERNET=($OTHERPKGDIR_INTERNET)