From 784e43d876397ead3e23873636506c71d5141c62 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 12 Nov 2015 12:24:33 +0100 Subject: [PATCH] conflicts: do not take into account conflicts for on hold pkgs. --- NEWS | 3 ++ lib/transaction_conflicts.c | 29 +++++++++++++------ tests/xbps/libxbps/shell/conflicts.sh | 40 +++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index ebf6a31f..e9687687 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ xbps-0.51 (???): + * libxbps: another bugfix for conflicts: do not take into account packages + that are on hold mode. + xbps-0.50 (2015-11-10): * libxbps: another bugfix for conflicts; do not take into account conflicts diff --git a/lib/transaction_conflicts.c b/lib/transaction_conflicts.c index 4dce0743..7baaa111 100644 --- a/lib/transaction_conflicts.c +++ b/lib/transaction_conflicts.c @@ -39,16 +39,16 @@ pkg_conflicts_trans(struct xbps_handle *xhp, xbps_array_t array, xbps_dictionary_t pkgd, tpkgd; xbps_object_t obj; xbps_object_iterator_t iter; - const char *cfpkg, *repopkgver, *pkgver, *atract; + const char *cfpkg, *repopkgver, *pkgver, *tract; char *pkgname, *repopkgname, *buf; pkg_cflicts = xbps_dictionary_get(pkg_repod, "conflicts"); if (xbps_array_count(pkg_cflicts) == 0) return; - if (xbps_dictionary_get_cstring_nocopy(pkg_repod, "transaction", &atract)) { - /* ignore pkgs to be removed */ - if (strcmp(atract, "remove") == 0) + if (xbps_dictionary_get_cstring_nocopy(pkg_repod, "transaction", &tract)) { + /* ignore pkgs to be removed or on hold */ + if (!strcmp(tract, "remove") || !strcmp(tract, "hold")) return; } @@ -76,16 +76,21 @@ pkg_conflicts_trans(struct xbps_handle *xhp, xbps_array_t array, free(pkgname); continue; } + /* + * If the conflicting pkg is on hold, ignore it. + */ + if (xbps_dictionary_get(pkgd, "hold")) { + free(pkgname); + continue; + } /* * If there's a pkg for the conflict in transaction, * ignore it. */ if ((tpkgd = xbps_find_pkg_in_array(array, pkgname, NULL))) { - const char *tract; - xbps_dictionary_get_cstring_nocopy(tpkgd, "transaction", &tract); - if (strcmp(tract, "remove")) { + if (!strcmp(tract, "install") || !strcmp(tract, "update")) { free(pkgname); continue; } @@ -117,12 +122,18 @@ pkg_conflicts_trans(struct xbps_handle *xhp, xbps_array_t array, continue; } free(pkgname); + /* ignore pkgs to be removed or on hold */ + if (xbps_dictionary_get_cstring_nocopy(pkgd, + "transaction", &tract)) { + if (!strcmp(tract, "remove") || !strcmp(tract, "hold")) + return; + } xbps_dbg_printf(xhp, "found conflicting pkgs in " "transaction %s <-> %s (matched by %s)\n", pkgver, repopkgver, cfpkg); buf = xbps_xasprintf("CONFLICT: %s with " - "%s in transaction (mached by %s)", - repopkgver, pkgver); + "%s in transaction (matched by %s)", + repopkgver, pkgver, cfpkg); if (!xbps_match_string_in_array(trans_cflicts, buf)) xbps_array_add_cstring(trans_cflicts, buf); diff --git a/tests/xbps/libxbps/shell/conflicts.sh b/tests/xbps/libxbps/shell/conflicts.sh index 3eb56497..ac8b4869 100644 --- a/tests/xbps/libxbps/shell/conflicts.sh +++ b/tests/xbps/libxbps/shell/conflicts.sh @@ -27,6 +27,45 @@ conflicts_trans_body() { atf_check_equal $(xbps-query -r root -l|wc -l) 0 } +conflicts_trans_hold_head() { + atf_set "descr" "Tests for pkg conflicts: conflicting pkg with on-hold installed pkg" +} + +conflicts_trans_hold_body() { + mkdir some_repo + mkdir -p pkg_{A,B}/usr/bin + cd some_repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" --conflicts "B>=1.1_1" ../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 .. + + xbps-install -r root --repository=$PWD/some_repo -dy A B + atf_check_equal $? 0 + + cd some_repo + xbps-create -A noarch -n A-1.1_1 -s "A pkg" --conflicts "B>=1.1_1" ../pkg_A + atf_check_equal $? 0 + xbps-create -A noarch -n B-1.1_1 -s "B pkg" ../pkg_B + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root --repository=$PWD/some_repo -dyuv + atf_check_equal $? 11 + + xbps-pkgdb -r root -m hold B + xbps-install -r root --repository=$PWD/some_repo -dyuv + atf_check_equal $? 0 + + atf_check_equal $(xbps-query -r root -p pkgver A) A-1.1_1 + atf_check_equal $(xbps-query -r root -p pkgver B) B-1.0_1 +} + atf_test_case conflicts_trans_vpkg conflicts_trans_vpkg_head() { @@ -242,6 +281,7 @@ conflicts_trans_installed_multi_body() { atf_init_test_cases() { atf_add_test_case conflicts_trans + atf_add_test_case conflicts_trans_hold atf_add_test_case conflicts_trans_vpkg atf_add_test_case conflicts_trans_multi atf_add_test_case conflicts_trans_installed