2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-10-21 15:18:19 +00:00

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>
This commit is contained in:
Daniel Hilst
2026-09-28 14:56:23 -03:00
parent a69debb41b
commit b2e76e61e3
+30 -1
View File
@@ -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