bin/xbps-remove: allow removing uninstalled packages from the cache

Change "obsolete packages" to "outdated packages" when describing the
old behaviour.
This commit is contained in:
Duncan Overbruck
2023-01-30 15:57:01 +01:00
parent 6d940e647f
commit ee770cb8e4
5 changed files with 77 additions and 23 deletions
+42 -1
View File
@@ -53,13 +53,15 @@ clean_cache_head() {
}
clean_cache_body() {
mkdir -p repo pkg_A/B/C
mkdir -p repo pkg_A/B/C pkg_B
touch pkg_A/
cd repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n A-1.0_2 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
@@ -69,12 +71,15 @@ clean_cache_body() {
cp repo/*.xbps root/var/cache/xbps
atf_check_equal $? 0
echo "repository=https://localhost/" >root/etc/xbps.d/localrepo.conf
xbps-install -r root -C etc/xbps.d -R repo -dvy B
xbps-remove -r root -C etc/xbps.d -dvO
atf_check_equal $? 0
test -f root/var/cache/xbps/A-1.0_2.noarch.xbps
atf_check_equal $? 0
test -f root/var/cache/xbps/A-1.0_1.noarch.xbps
atf_check_equal $? 1
test -f root/var/cache/xbps/B-1.0_1.noarch.xbps
atf_check_equal $? 0
}
atf_test_case clean_cache_dry_run
@@ -136,10 +141,46 @@ clean_cache_dry_run_perm_body() {
atf_check_equal "$out" "Removed A-1.0_1.noarch.xbps from cachedir (obsolete)"
}
clean_cache_uninstalled_head() {
atf_set "descr" "xbps-remove(1): clean uninstalled package from cache"
}
clean_cache_uninstalled_body() {
mkdir -p repo pkg_A/B/C pkg_B
touch pkg_A/
cd repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n A-1.0_2 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
mkdir -p root/etc/xbps.d root/var/db/xbps/https___localhost_ root/var/cache/xbps
cp repo/*-repodata root/var/db/xbps/https___localhost_
atf_check_equal $? 0
cp repo/*.xbps root/var/cache/xbps
atf_check_equal $? 0
echo "repository=https://localhost/" >root/etc/xbps.d/localrepo.conf
xbps-install -r root -C etc/xbps.d -R repo -dvy B
atf_check_equal $? 0
xbps-remove -r root -C etc/xbps.d -dvOO
atf_check_equal $? 0
test -f root/var/cache/xbps/A-1.0_2.noarch.xbps
atf_check_equal $? 1
test -f root/var/cache/xbps/A-1.0_1.noarch.xbps
atf_check_equal $? 1
test -f root/var/cache/xbps/B-1.0_1.noarch.xbps
atf_check_equal $? 0
}
atf_init_test_cases() {
atf_add_test_case remove_directory
atf_add_test_case remove_orphans
atf_add_test_case clean_cache
atf_add_test_case clean_cache_dry_run
atf_add_test_case clean_cache_dry_run_perm
atf_add_test_case clean_cache_uninstalled
}