From 2202482e0e4200774a364526026ed423e9648283 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 12 Nov 2015 13:23:00 +0100 Subject: [PATCH] conflicts: really fix the issue with on hold pkgs and update test case. --- lib/transaction_conflicts.c | 34 ++++++++++++++++----------- tests/xbps/libxbps/shell/conflicts.sh | 12 ++++++---- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/lib/transaction_conflicts.c b/lib/transaction_conflicts.c index 8166d77b..09975cee 100644 --- a/lib/transaction_conflicts.c +++ b/lib/transaction_conflicts.c @@ -68,6 +68,11 @@ pkg_conflicts_trans(struct xbps_handle *xhp, xbps_array_t array, */ if ((pkgd = xbps_pkgdb_get_pkg(xhp, cfpkg)) || (pkgd = xbps_pkgdb_get_virtualpkg(xhp, cfpkg))) { + /* If the conflicting pkg is on hold, ignore it */ + if (xbps_dictionary_get(pkgd, "hold")) + continue; + + /* Ignore itself */ xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); pkgname = xbps_pkg_name(pkgver); @@ -76,13 +81,6 @@ 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. @@ -115,6 +113,13 @@ pkg_conflicts_trans(struct xbps_handle *xhp, xbps_array_t array, */ if ((pkgd = xbps_find_pkg_in_array(array, cfpkg, NULL)) || (pkgd = xbps_find_virtualpkg_in_array(xhp, array, cfpkg, NULL))) { + /* ignore pkgs to be removed or on hold */ + if (xbps_dictionary_get_cstring_nocopy(pkgd, + "transaction", &tract)) { + if (!strcmp(tract, "remove") || !strcmp(tract, "hold")) + continue; + } + /* ignore itself */ xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); pkgname = xbps_pkg_name(pkgver); @@ -124,12 +129,6 @@ 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")) - continue; - } xbps_dbg_printf(xhp, "found conflicting pkgs in " "transaction %s <-> %s (matched by %s [trans])\n", pkgver, repopkgver, cfpkg); @@ -155,7 +154,7 @@ pkgdb_conflicts_cb(struct xbps_handle *xhp, xbps_object_t obj, xbps_dictionary_t pkgd; xbps_object_t obj2; xbps_object_iterator_t iter; - const char *cfpkg, *repopkgver, *pkgver; + const char *cfpkg, *repopkgver, *pkgver, *tract; char *pkgname, *repopkgname, *buf; pkg_cflicts = xbps_dictionary_get(obj, "conflicts"); @@ -182,6 +181,13 @@ pkgdb_conflicts_cb(struct xbps_handle *xhp, xbps_object_t obj, (pkgd = xbps_find_virtualpkg_in_array(xhp, pkgs, cfpkg, NULL))) { xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + /* ignore pkgs to be removed or on hold */ + if (xbps_dictionary_get_cstring_nocopy(pkgd, + "transaction", &tract)) { + if (!strcmp(tract, "remove") || !strcmp(tract, "hold")) + continue; + } + /* ignore itself */ pkgname = xbps_pkg_name(pkgver); assert(pkgname); if (strcmp(pkgname, repopkgname) == 0) { diff --git a/tests/xbps/libxbps/shell/conflicts.sh b/tests/xbps/libxbps/shell/conflicts.sh index ac8b4869..802c5873 100644 --- a/tests/xbps/libxbps/shell/conflicts.sh +++ b/tests/xbps/libxbps/shell/conflicts.sh @@ -35,9 +35,9 @@ 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 + xbps-create -A noarch -n A-1.0_1 -s "A pkg" --conflicts "vpkg>19_1" ../pkg_A atf_check_equal $? 0 - xbps-create -A noarch -n B-1.0_1 -s "B pkg" ../pkg_B + xbps-create -A noarch -n B-1.0_1 -s "B pkg" --provides "vpkg-19_1" ../pkg_B atf_check_equal $? 0 xbps-rindex -d -a $PWD/*.xbps atf_check_equal $? 0 @@ -47,17 +47,19 @@ conflicts_trans_hold_body() { 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 + xbps-create -A noarch -n A-1.1_1 -s "A pkg" --conflicts "vpkg>19_1" ../pkg_B atf_check_equal $? 0 - xbps-create -A noarch -n B-1.1_1 -s "B pkg" ../pkg_B + xbps-create -A noarch -n B-1.1_1 -s "B pkg" --provides "vpkg-20_1" ../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 + echo "B updated to 1.1_1" + xbps-install -r root --repository=$PWD/some_repo -dyuv B atf_check_equal $? 11 + echo "B is now on hold" xbps-pkgdb -r root -m hold B xbps-install -r root --repository=$PWD/some_repo -dyuv atf_check_equal $? 0