From 5b43614e80c5a334231f28e191f709b2679e6fc7 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 3 Feb 2020 09:19:54 +0100 Subject: [PATCH] libxbps: fixed regression introduced in 0.58. While looking for dependencies, we need to check if xbps_rpool_get_pkg() returned a suitable match; and then validate its result. This fixes the update_and_install test case that was reverted via #218. --- lib/repo_pkgdeps.c | 36 ++++++++++++++++++++++-- tests/xbps/libxbps/shell/install_test.sh | 1 - 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/lib/repo_pkgdeps.c b/lib/repo_pkgdeps.c index 21b529b1..6917e36a 100644 --- a/lib/repo_pkgdeps.c +++ b/lib/repo_pkgdeps.c @@ -131,7 +131,6 @@ find_repo_deps(struct xbps_handle *xhp, const char *reqpkg, *pkgver_q, *reason = NULL; char *pkgname, *reqpkgname; int rv = 0; - bool foundvpkg; if (*depth >= MAX_DEPTH) return ELOOP; @@ -144,8 +143,9 @@ find_repo_deps(struct xbps_handle *xhp, assert(iter); while ((obj = xbps_object_iterator_next(iter))) { - foundvpkg = false; + bool error = false, foundvpkg = false; reqpkg = xbps_string_cstring_nocopy(obj); + if (xhp->flags & XBPS_FLAG_DEBUG) { xbps_dbg_printf(xhp, "%s", ""); for (unsigned short x = 0; x < *depth; x++) { @@ -345,6 +345,38 @@ find_repo_deps(struct xbps_handle *xhp, } free(pkgname); free(reqpkgname); + /* + * Installed package must be updated, check if dependency is + * satisfied. + */ + if (!strcmp(reason, "update")) { + switch (xbps_pkgpattern_match(pkgver_q, reqpkg)) { + case 0: /* nomatch */ + break; + case 1: /* match */ + pkgname = xbps_pkg_name(pkgver_q); + assert(pkgname); + /* + * If there's an update in transaction, + * it's assumed version is greater. + * So dependency pattern matching didn't + * succeed... return ENODEV. + */ + if (xbps_find_pkg_in_array(unsorted, pkgname, "update")) { + error = true; + rv = ENODEV; + } + free(pkgname); + break; + default: + error = true; + rv = EINVAL; + break; + } + if (error) + break; + } + /* * If package doesn't have rundeps, pass to the next one. */ diff --git a/tests/xbps/libxbps/shell/install_test.sh b/tests/xbps/libxbps/shell/install_test.sh index eb30ba82..c0fe9a1a 100644 --- a/tests/xbps/libxbps/shell/install_test.sh +++ b/tests/xbps/libxbps/shell/install_test.sh @@ -598,7 +598,6 @@ atf_test_case update_and_install update_and_install_head() { atf_set "descr" "Tests for pkg install: update installed version and install new from other repo" - atf_expect_fail "fix introduced a regression" } update_and_install_body() {