Fix #62 (Dup replaced pkgs in transaction)

This commit is contained in:
Juan RP 2014-10-17 09:52:32 +02:00
parent 1c20086896
commit d7633e88e0
3 changed files with 44 additions and 2 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.42 (???): xbps-0.42 (???):
* Fixed issue #62 (Dup replaced pkgs in transaction); see
https://github.com/voidlinux/xbps/issues/62
* If removing a package and euid==0 do not check for file owner, being root * If removing a package and euid==0 do not check for file owner, being root
means that all files can be removed properly. This fixes package removal means that all files can be removed properly. This fixes package removal
when some files were not owned by root, rather by a system account. when some files were not owned by root, rather by a system account.

View File

@ -103,14 +103,13 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
*/ */
xbps_dictionary_get_bool(instd, "automatic-install", &instd_auto); xbps_dictionary_get_bool(instd, "automatic-install", &instd_auto);
if ((reppkgd = xbps_find_pkg_in_array(unsorted, curpkgname, NULL))) { if ((reppkgd = xbps_find_pkg_in_array(unsorted, curpkgname, NULL))) {
xbps_dictionary_set_bool(instd,
"remove-and-update", true);
xbps_dictionary_set_bool(reppkgd, xbps_dictionary_set_bool(reppkgd,
"automatic-install", instd_auto); "automatic-install", instd_auto);
xbps_dictionary_set_bool(reppkgd, xbps_dictionary_set_bool(reppkgd,
"skip-obsoletes", true); "skip-obsoletes", true);
xbps_array_replace_dict_by_name(unsorted, xbps_array_replace_dict_by_name(unsorted,
reppkgd, curpkgname); reppkgd, curpkgname);
continue;
} }
/* /*
* If new package is providing a virtual package to the * If new package is providing a virtual package to the

View File

@ -37,6 +37,45 @@ replace_dups_body() {
atf_check_equal $(xbps-query -C empty.conf -r root -p state B) installed atf_check_equal $(xbps-query -C empty.conf -r root -p state B) installed
} }
atf_test_case replace_ntimes
replace_ntimes_head() {
atf_set "descr" "Tests for package replace: replacing installed pkg by multiple pkgs"
}
replace_ntimes_body() {
mkdir some_repo root
mkdir -p pkg_{A,B,C,D}/usr/bin
cd some_repo
xbps-create -A noarch -n A-1.0_1 -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-create -A noarch -n C-1.0_1 -s "C pkg" ../pkg_C
atf_check_equal $? 0
xbps-create -A noarch -n D-1.0_1 -s "D pkg" ../pkg_D
atf_check_equal $? 0
xbps-rindex -a *.xbps
atf_check_equal $? 0
cd ..
xbps-install -C empty.conf -r root --repository=$PWD/some_repo -yd A B C D
atf_check_equal $? 0
cd some_repo
xbps-create -A noarch -n A-1.1_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-create -A noarch -n B-1.1_1 -s "B pkg" --replaces "A<1.1" ../pkg_B
atf_check_equal $? 0
xbps-create -A noarch -n C-1.1_1 -s "C pkg" --replaces "A<1.1" ../pkg_C
atf_check_equal $? 0
xbps-create -A noarch -n D-1.1_1 -s "D pkg" --replaces "A<1.1" ../pkg_D
atf_check_equal $? 0
xbps-rindex -a *.xbps
atf_check_equal $? 0
cd ..
result=$(xbps-install -C empty.conf -r root --repository=$PWD/some_repo -yun|wc -l)
atf_check_equal $result 4
}
atf_test_case self_replace atf_test_case self_replace
self_replace_head() { self_replace_head() {
@ -97,6 +136,7 @@ replace_vpkg_body() {
atf_init_test_cases() { atf_init_test_cases() {
atf_add_test_case replace_dups atf_add_test_case replace_dups
atf_add_test_case replace_ntimes
atf_add_test_case replace_vpkg atf_add_test_case replace_vpkg
atf_add_test_case self_replace atf_add_test_case self_replace
} }