diff --git a/NEWS b/NEWS index e99384f0..f053e9ad 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ xbps-0.50 (???): + * libxbps: another bugfix for conflicts; do not take into account conflicts + in installed pkgs when the same pkg is in the transaction. + * xbps-alternatives(1): symlinks are now always created relative to the rootdir of the target file. Implemented by Enno Boland (@Gottox). diff --git a/lib/transaction_conflicts.c b/lib/transaction_conflicts.c index eb4429c0..4dce0743 100644 --- a/lib/transaction_conflicts.c +++ b/lib/transaction_conflicts.c @@ -77,29 +77,26 @@ pkg_conflicts_trans(struct xbps_handle *xhp, xbps_array_t array, continue; } /* - * If there's an update for the conflicting pkg in - * the transaction and does not match the pattern, + * 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, *p; + const char *tract; xbps_dictionary_get_cstring_nocopy(tpkgd, "transaction", &tract); - xbps_dictionary_get_cstring_nocopy(tpkgd, - "pkgver", &p); - if ((xbps_pkgpattern_match(p, cfpkg) == 0) && - (strcmp(tract, "update") == 0)) { + if (strcmp(tract, "remove")) { free(pkgname); continue; } } free(pkgname); xbps_dbg_printf(xhp, "found conflicting installed " - "pkg %s with pkg in transaction %s\n", pkgver, - repopkgver); + "pkg %s with pkg in transaction %s " + "(matched by %s)\n", pkgver, repopkgver, cfpkg); buf = xbps_xasprintf("CONFLICT: %s with " - "installed pkg %s", repopkgver, pkgver); + "installed pkg %s (matched by %s)", + repopkgver, pkgver, cfpkg); if (!xbps_match_string_in_array(trans_cflicts, buf)) xbps_array_add_cstring(trans_cflicts, buf); @@ -121,9 +118,11 @@ pkg_conflicts_trans(struct xbps_handle *xhp, xbps_array_t array, } free(pkgname); xbps_dbg_printf(xhp, "found conflicting pkgs in " - "transaction %s <-> %s\n", pkgver, repopkgver); + "transaction %s <-> %s (matched by %s)\n", + pkgver, repopkgver, cfpkg); buf = xbps_xasprintf("CONFLICT: %s with " - "%s in transaction", repopkgver, pkgver); + "%s in transaction (mached by %s)", + repopkgver, pkgver); if (!xbps_match_string_in_array(trans_cflicts, buf)) xbps_array_add_cstring(trans_cflicts, buf); @@ -155,6 +154,12 @@ pkgdb_conflicts_cb(struct xbps_handle *xhp, xbps_object_t obj, repopkgname = xbps_pkg_name(repopkgver); assert(repopkgname); + /* if a pkg is in the transaction, ignore the one from pkgdb */ + if (xbps_find_pkg_in_array(pkgs, repopkgname, NULL)) { + free(repopkgname); + return 0; + } + iter = xbps_array_iterator(pkg_cflicts); assert(iter); @@ -172,9 +177,11 @@ pkgdb_conflicts_cb(struct xbps_handle *xhp, xbps_object_t obj, } free(pkgname); xbps_dbg_printf(xhp, "found conflicting pkgs in " - "transaction %s <-> %s\n", pkgver, repopkgver); + "transaction %s <-> %s (matched by %s)\n", + pkgver, repopkgver, cfpkg); buf = xbps_xasprintf("CONFLICT: %s with " - "%s in transaction", 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 db9c2d44..3eb56497 100644 --- a/tests/xbps/libxbps/shell/conflicts.sh +++ b/tests/xbps/libxbps/shell/conflicts.sh @@ -166,6 +166,51 @@ conflicts_trans_installed_body() { atf_check_equal $(xbps-query -r root -l|wc -l) 1 } +atf_test_case conflicts_trans_update + +conflicts_trans_update_head() { + atf_set "descr" "Tests for pkg conflicts: no conflicts with updated pkgs in transaction" +} + +conflicts_trans_update_body() { + mkdir repo repo2 + mkdir -p pkg_{A,B}/usr/bin + + cd repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" --provides "xserver-abi-video-19_1" ../pkg_A + atf_check_equal $? 0 + xbps-create -A noarch -n B-1.0_1 -s "B pkg" --conflicts "xserver-abi-video<19" ../pkg_B + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root --repository=$PWD/repo -dy A B + atf_check_equal $? 0 + + cd repo2 + xbps-create -A noarch -n A-1.1_1 -s "A pkg" --provides "xserver-abi-video-20_1" ../pkg_A + atf_check_equal $? 0 + xbps-create -A noarch -n B-1.1_1 -s "B pkg" --conflicts "xserver-abi-video<20" ../pkg_B + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root --repository=$PWD/repo2 -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.1_1 + + xbps-install -r root --repository=$PWD/repo -dyvf A B + atf_check_equal $? 0 + atf_check_equal $(xbps-query -r root -p pkgver A) A-1.0_1 + atf_check_equal $(xbps-query -r root -p pkgver B) B-1.0_1 + + xbps-install -r root --repository=$PWD/repo2 -dyvf B-1.1_1 + atf_check_equal $? 11 +} + atf_test_case conflicts_trans_installed_multi conflicts_trans_installed_multi_head() { @@ -203,4 +248,5 @@ atf_init_test_cases() { atf_add_test_case conflicts_trans_installed_multi atf_add_test_case conflicts_installed atf_add_test_case conflicts_installed_multi + atf_add_test_case conflicts_trans_update }