From 2ef5693bc8267d57092ffac57c9f59d11243461d Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sun, 22 Feb 2026 18:58:34 +0100 Subject: [PATCH 1/2] bin/xbps-remve: when cleaning the cache keep installed versions Fixes: https://github.com/void-linux/xbps/issues/279 --- bin/xbps-remove/clean-cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/xbps-remove/clean-cache.c b/bin/xbps-remove/clean-cache.c index 4027a91d2..ccd041d82 100644 --- a/bin/xbps-remove/clean-cache.c +++ b/bin/xbps-remove/clean-cache.c @@ -102,6 +102,8 @@ cleaner_cb(struct xbps_handle *xhp, xbps_object_t obj, pkgd = xbps_pkgdb_get_pkg(xhp, binpkgver); } else { pkgd = xbps_rpool_get_pkg(xhp, binpkgver); + if (!pkgd) + pkgd = xbps_pkgdb_get_pkg(xhp, binpkgver); } if (pkgd) { xbps_dictionary_get_cstring_nocopy(pkgd, From ba35060b9ae89cf697b858acd7989b2d3f72d778 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sun, 22 Feb 2026 18:59:40 +0100 Subject: [PATCH 2/2] tests: test case for keeping installed version when cleaning cache --- tests/xbps/xbps-remove/basic_test.sh | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/xbps/xbps-remove/basic_test.sh b/tests/xbps/xbps-remove/basic_test.sh index b4c5b8466..bbfc02419 100755 --- a/tests/xbps/xbps-remove/basic_test.sh +++ b/tests/xbps/xbps-remove/basic_test.sh @@ -170,6 +170,36 @@ clean_cache_uninstalled_body() { atf_check_equal $? 0 } +clean_cache_installed_head() { + atf_set "descr" "xbps-remove(1): do not clean currently installed packages" +} + +clean_cache_installed_body() { + mkdir -p repo pkg_A/B/C pkg_B + mkdir -p root/etc/xbps.d root/var/db/xbps/https___localhost_ root/var/cache/xbps + + cd repo + atf_check -o ignore -- xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A + atf_check -o ignore -- xbps-rindex -a $PWD/*.xbps + cd .. + atf_check -- cp repo/*-repodata root/var/db/xbps/https___localhost_ + atf_check -- cp repo/*.xbps root/var/cache/xbps + + echo "repository=https://localhost/" >root/etc/xbps.d/localrepo.conf + atf_check -o ignore -e ignore -- xbps-install -r root -C etc/xbps.d -R repo -dvy A + + cd repo + atf_check -o ignore -- xbps-create -A noarch -n A-1.0_2 -s "A pkg" ../pkg_A + atf_check -o ignore -e ignore -- xbps-rindex -a $PWD/*.xbps + cd .. + atf_check -- cp repo/*-repodata root/var/db/xbps/https___localhost_ + atf_check -- cp repo/*.xbps root/var/cache/xbps + + atf_check -- xbps-remove -r root -C etc/xbps.d -O + atf_check -- test -f root/var/cache/xbps/A-1.0_2.noarch.xbps + atf_check -- test -f root/var/cache/xbps/A-1.0_1.noarch.xbps +} + atf_test_case remove_msg remove_msg_head() { @@ -205,5 +235,6 @@ atf_init_test_cases() { atf_add_test_case clean_cache_dry_run atf_add_test_case clean_cache_dry_run_perm atf_add_test_case clean_cache_uninstalled + atf_add_test_case clean_cache_installed atf_add_test_case remove_msg }