From f103b91663c37fc300f150948b966805559e9aad Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Mon, 5 Aug 2019 11:48:15 +0200 Subject: [PATCH] Revert "lib/transaction_{revdeps,prepare}.c: try to update packages if necessary" This reverts commit 0e950156fc046da707480d1e19995bc9fe50afda. --- include/xbps_api_impl.h | 2 +- lib/transaction_prepare.c | 119 ++++++++++++++++---------------------- lib/transaction_revdeps.c | 21 +------ 3 files changed, 51 insertions(+), 91 deletions(-) diff --git a/include/xbps_api_impl.h b/include/xbps_api_impl.h index 391dabbe..7dab942c 100644 --- a/include/xbps_api_impl.h +++ b/include/xbps_api_impl.h @@ -127,7 +127,7 @@ xbps_dictionary_t HIDDEN xbps_find_pkg_in_array(xbps_array_t, const char *, const char *); xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_array(struct xbps_handle *, xbps_array_t, const char *, const char *); -int HIDDEN xbps_transaction_revdeps(struct xbps_handle *, xbps_array_t); +void HIDDEN xbps_transaction_revdeps(struct xbps_handle *, xbps_array_t); bool HIDDEN xbps_transaction_shlibs(struct xbps_handle *, xbps_array_t, xbps_array_t); int HIDDEN xbps_transaction_init(struct xbps_handle *); diff --git a/lib/transaction_prepare.c b/lib/transaction_prepare.c index 7bdd5d02..425fca42 100644 --- a/lib/transaction_prepare.c +++ b/lib/transaction_prepare.c @@ -272,13 +272,11 @@ xbps_transaction_init(struct xbps_handle *xhp) return 0; } -#define MAX_REPEAT 512 - int xbps_transaction_prepare(struct xbps_handle *xhp) { xbps_array_t array, pkgs, edges; - unsigned int i, j, cnt; + unsigned int i, cnt; int rv = 0; if ((rv = xbps_transaction_init(xhp)) != 0) @@ -287,79 +285,60 @@ xbps_transaction_prepare(struct xbps_handle *xhp) if (xhp->transd == NULL) return ENXIO; - for (j = 0; j < MAX_REPEAT; j++) { - /* - * Collect dependencies for pkgs in transaction. - */ - if ((edges = xbps_array_create()) == NULL) - return ENOMEM; - /* - * The edges are also appended after its dependencies have been - * collected; the edges at the original array are removed later. - */ - pkgs = xbps_dictionary_get(xhp->transd, "packages"); - assert(xbps_object_type(pkgs) == XBPS_TYPE_ARRAY); - cnt = xbps_array_count(pkgs); - for (i = 0; i < cnt; i++) { - xbps_dictionary_t pkgd; - xbps_string_t str; - const char *tract = NULL; - - pkgd = xbps_array_get(pkgs, i); - str = xbps_dictionary_get(pkgd, "pkgver"); - xbps_dictionary_get_cstring_nocopy(pkgd, "transaction", &tract); - if ((strcmp(tract, "remove") == 0) || strcmp(tract, "hold") == 0) - continue; - - assert(xbps_object_type(str) == XBPS_TYPE_STRING); - - if (!xbps_array_add(edges, str)) - return ENOMEM; - - if ((rv = xbps_repository_find_deps(xhp, pkgs, pkgd)) != 0) - return rv; - - if (!xbps_array_add(pkgs, pkgd)) - return ENOMEM; - } - /* ... remove dup edges at head */ - for (i = 0; i < xbps_array_count(edges); i++) { - const char *pkgver = NULL; - xbps_array_get_cstring_nocopy(edges, i, &pkgver); - xbps_remove_pkg_from_array_by_pkgver(pkgs, pkgver); - } - xbps_object_release(edges); - - /* - * Check for packages to be replaced. - */ - if ((rv = xbps_transaction_package_replace(xhp, pkgs)) != 0) { - xbps_object_release(xhp->transd); - xhp->transd = NULL; - return rv; - } - /* - * Check reverse dependencies. - */ - if ((rv = xbps_transaction_revdeps(xhp, pkgs)) == 0) - break; - if (rv != EAGAIN) - return rv; - } /* - * Repeated too many times. + * Collect dependencies for pkgs in transaction. */ - if (j == MAX_REPEAT) { - xbps_dbg_printf(xhp, "[trans] aborted due to too many repetitions" - " while resolving dependencies!\n"); - return ELOOP; - } else { - xbps_dbg_printf(xhp, "[trans] resolved dependencies in" - " %d repetitions.\n", j); + if ((edges = xbps_array_create()) == NULL) + return ENOMEM; + /* + * The edges are also appended after its dependencies have been + * collected; the edges at the original array are removed later. + */ + pkgs = xbps_dictionary_get(xhp->transd, "packages"); + assert(xbps_object_type(pkgs) == XBPS_TYPE_ARRAY); + cnt = xbps_array_count(pkgs); + for (i = 0; i < cnt; i++) { + xbps_dictionary_t pkgd; + xbps_string_t str; + const char *tract = NULL; + + pkgd = xbps_array_get(pkgs, i); + str = xbps_dictionary_get(pkgd, "pkgver"); + xbps_dictionary_get_cstring_nocopy(pkgd, "transaction", &tract); + if ((strcmp(tract, "remove") == 0) || strcmp(tract, "hold") == 0) + continue; + + assert(xbps_object_type(str) == XBPS_TYPE_STRING); + + if (!xbps_array_add(edges, str)) + return ENOMEM; + + if ((rv = xbps_repository_find_deps(xhp, pkgs, pkgd)) != 0) + return rv; + + if (!xbps_array_add(pkgs, pkgd)) + return ENOMEM; + } + /* ... remove dup edges at head */ + for (i = 0; i < xbps_array_count(edges); i++) { + const char *pkgver = NULL; + xbps_array_get_cstring_nocopy(edges, i, &pkgver); + xbps_remove_pkg_from_array_by_pkgver(pkgs, pkgver); + } + xbps_object_release(edges); + + /* + * Check for packages to be replaced. + */ + if ((rv = xbps_transaction_package_replace(xhp, pkgs)) != 0) { + xbps_object_release(xhp->transd); + xhp->transd = NULL; + return rv; } /* * If there are missing deps or revdeps bail out. */ + xbps_transaction_revdeps(xhp, pkgs); array = xbps_dictionary_get(xhp->transd, "missing_deps"); if (xbps_array_count(array)) { if (xhp->flags & XBPS_FLAG_FORCE_REMOVE_REVDEPS) { diff --git a/lib/transaction_revdeps.c b/lib/transaction_revdeps.c index ee686301..fb27d97d 100644 --- a/lib/transaction_revdeps.c +++ b/lib/transaction_revdeps.c @@ -101,21 +101,10 @@ broken_pkg(xbps_array_t mdeps, const char *dep, const char *pkg, const char *tra free(str); } -static int -update_pkg(struct xbps_handle *xhp, const char *pkg) -{ - int rv = 0; - rv = xbps_transaction_update_pkg(xhp, pkg); - if (rv == EEXIST) - return 0; - return rv; -} - -int HIDDEN +void HIDDEN xbps_transaction_revdeps(struct xbps_handle *xhp, xbps_array_t pkgs) { xbps_array_t mdeps; - int updated = 0; mdeps = xbps_dictionary_get(xhp->transd, "missing_deps"); @@ -246,17 +235,9 @@ xbps_transaction_revdeps(struct xbps_handle *xhp, xbps_array_t pkgs) free(pkgname); continue; } - if (update_pkg(xhp, pkgname) == 0) { - updated++; - free(pkgname); - continue; - } free(pkgname); broken_pkg(mdeps, curpkgver, pkgver, tract); } } - if (updated > 0) - return EAGAIN; - return 0; }