From 7bd04f012d10fcd244304dc546240af096ff8990 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Mon, 14 Sep 2026 15:55:25 -0300 Subject: [PATCH] fix(xcat-core): otherpkgs writes a trailing space into the generated baseurl Line 297 of xCAT/postscripts/otherpkgs appends each http OTHERPKGDIR entry as "${dir} ,". The list is split on the comma alone, so every url keeps the space, and the url repository block writes "baseurl= " into the yum repository file and "deb " into the apt source. The separator no longer carries the space. postscripts_otherpkgs.bats runs the split and the url repository block and compares the generated baseurl and deb lines with the url. Against the unfixed script both differ by the trailing space. dnf 4.20 strips trailing whitespace from an ini value, and apt splits a source line on whitespace, so no package manager reads the space today. The generated file is still wrong. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/bats/postscripts_otherpkgs.bats | 29 +++++++++++++++++++++++ xCAT/postscripts/otherpkgs | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/xCAT-test/bats/postscripts_otherpkgs.bats b/xCAT-test/bats/postscripts_otherpkgs.bats index 4dc227d59..a21bb0893 100644 --- a/xCAT-test/bats/postscripts_otherpkgs.bats +++ b/xCAT-test/bats/postscripts_otherpkgs.bats @@ -236,3 +236,32 @@ run_repo_postremove_block() run eval "$cond" [ "$status" -eq 0 ] } + +# Runs the OTHERPKGDIR split and then the url repository block, and leaves the repository +# files the url block wrote under BATS_TEST_TMPDIR. +run_url_repo_block() +{ + local split url_block + split="$(extract_shell_if_block "$OTHERPKGS" 'if [ -n "$OTHERPKGDIR" ]; then')" || return 99 + url_block="$(otherpkgs_block '#add repo for url repos in otherpkgdir' 'OTHERPKGDIR_INTERNET')" || return 99 + local OTHERPKGDIR="$1" OTHERPKGDIR_INTERNET="" OTHERPKGDIR_LOCAL="" + local hasyum="${2:-1}" haszypper=0 hasapt="${3:-0}" + local repo_base="$BATS_TEST_TMPDIR" urlrepoindex=0 + eval "$split" + eval "$url_block" + printf 'urlrepoindex=%s\n' "$urlrepoindex" +} + +@test "the generated yum baseurl carries no trailing space" { + run run_url_repo_block 'http://192.0.2.1/repo-a,/install/post/otherpkgs,http://192.0.2.1/repo-b' + [ "$status" -eq 0 ] + [[ "$output" == *'urlrepoindex=2'* ]] + [ "$(grep '^baseurl=' "${BATS_TEST_TMPDIR}/xCAT-otherpkgs0.repo")" = "baseurl=http://192.0.2.1/repo-a" ] + [ "$(grep '^baseurl=' "${BATS_TEST_TMPDIR}/xCAT-otherpkgs1.repo")" = "baseurl=http://192.0.2.1/repo-b" ] +} + +@test "the generated apt source carries no trailing space" { + run run_url_repo_block 'http://192.0.2.1/repo-a' 0 1 + [ "$status" -eq 0 ] + [ "$(cat "${BATS_TEST_TMPDIR}/xCAT-otherpkgs0.list")" = "deb http://192.0.2.1/repo-a" ] +} diff --git a/xCAT/postscripts/otherpkgs b/xCAT/postscripts/otherpkgs index 0d66899ca..507de1078 100755 --- a/xCAT/postscripts/otherpkgs +++ b/xCAT/postscripts/otherpkgs @@ -294,7 +294,7 @@ if [ -n "$OTHERPKGDIR" ]; then do dirtype=${dir:0:4} if [ $dirtype = 'http' ]; then - OTHERPKGDIR_INTERNET="${OTHERPKGDIR_INTERNET}${dir} ," + OTHERPKGDIR_INTERNET="${OTHERPKGDIR_INTERNET}${dir}," else OTHERPKGDIR_LOCAL=$dir fi