From b2e76e61e33ab75ed37aae1ea6da86f14f821c7e Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Mon, 28 Sep 2026 14:56:23 -0300 Subject: [PATCH] fix(xcat-core): go-xcat complete uninstall does not purge removed packages After `apt-get remove`, dpkg reports a package as "deinstall ok config-files". uninstall_xcat_completely() selected packages with installed_packages(), which accepts only "install ok installed". So `go-xcat completely uninstall` after `go-xcat uninstall` did not purge the xCAT packages, and their configuration files stayed on the node. uninstall_xcat_completely() now uses purgeable_packages(). On Debian it also accepts packages whose state ends in "ok config-files". On rpm systems it is installed_packages(). uninstall_xcat() keeps the installed-only filter. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-server/share/xcat/tools/go-xcat | 31 +++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index d21e69b6c..51c886de8 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -2068,6 +2068,35 @@ function installed_packages() function_dispatch "${FUNCNAME[0]}" "$@" } +# $@ package names +# Prints the ones this system can purge. rpm has no removed-but-configured state. +function purgeable_packages_rpm() +{ + installed_packages_rpm "$@" +} + +# $@ package names +# `apt-get remove` leaves "deinstall ok config-files". `apt-get purge` still removes those files. +function purgeable_packages_deb() +{ + type dpkg-query >/dev/null 2>&1 || return 255 + local package="" + for package in "$@" + do + case "$(dpkg-query --show '--showformat=${Status}' "${package}" 2>/dev/null)" in + "install ok installed"|*" ok config-files") + echo "${package}" + ;; + esac + done + return 0 +} + +function purgeable_packages() +{ + function_dispatch "${FUNCNAME[0]}" "$@" +} + # $1 -y function uninstall_xcat() { @@ -2130,7 +2159,7 @@ function trash_xcat() function uninstall_xcat_completely() { local -a present=() - readarray -t present < <(installed_packages "${GO_XCAT_UNINSTALL_LIST[@]}") + readarray -t present < <(purgeable_packages "${GO_XCAT_UNINSTALL_LIST[@]}") [[ "${#present[@]}" -eq "0" ]] || purge_package -y "${present[@]}" kill_xcat