diff --git a/include/xbps_api_impl.h b/include/xbps_api_impl.h index 83dfff55..ca5b2dae 100644 --- a/include/xbps_api_impl.h +++ b/include/xbps_api_impl.h @@ -176,14 +176,10 @@ int HIDDEN xbps_repository_find_deps(struct xbps_handle *, * @private * From lib/plist_find.c */ -xbps_dictionary_t HIDDEN xbps_find_pkg_in_array(xbps_array_t, const char *); -xbps_dictionary_t HIDDEN - xbps_find_virtualpkg_in_array(struct xbps_handle *, xbps_array_t, - const char *); xbps_dictionary_t HIDDEN xbps_find_pkg_in_dict(xbps_dictionary_t, const char *); -xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_dict(struct xbps_handle *, - xbps_dictionary_t, - const char *); +xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_dict(struct xbps_handle *, xbps_dictionary_t, const char *); +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 *); /** * @private * From lib/transaction_revdeps.c diff --git a/lib/package_conflicts.c b/lib/package_conflicts.c index 22e5f4d7..c09a6666 100644 --- a/lib/package_conflicts.c +++ b/lib/package_conflicts.c @@ -76,7 +76,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, * the transaction and does not match the pattern, * ignore it. */ - if ((tpkgd = xbps_find_pkg_in_array(unsorted, pkgname))) { + if ((tpkgd = xbps_find_pkg_in_array(unsorted, pkgname, NULL))) { const char *tract, *p; xbps_dictionary_get_cstring_nocopy(tpkgd, @@ -104,8 +104,8 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, /* * Check if current pkg conflicts with any pkg in transaction. */ - if ((pkgd = xbps_find_pkg_in_array(unsorted, cfpkg)) || - (pkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, cfpkg))) { + if ((pkgd = xbps_find_pkg_in_array(unsorted, cfpkg, NULL)) || + (pkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, cfpkg, NULL))) { xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); pkgname = xbps_pkg_name(pkgver); diff --git a/lib/package_orphans.c b/lib/package_orphans.c index 16e3be09..a6847c85 100644 --- a/lib/package_orphans.c +++ b/lib/package_orphans.c @@ -123,8 +123,8 @@ find_orphans: for (unsigned int x = 0; x < xbps_array_count(rdeps); x++) { cnt = 0; xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver); - if (xbps_find_pkg_in_array(array, deppkgver) || - xbps_find_virtualpkg_in_array(xhp, array, deppkgver)) + if (xbps_find_pkg_in_array(array, deppkgver, NULL) || + xbps_find_virtualpkg_in_array(xhp, array, deppkgver, NULL)) continue; reqby = xbps_pkgdb_get_pkg_revdeps(xhp, deppkgver); if (reqby == NULL) @@ -132,8 +132,8 @@ find_orphans: reqbycnt = xbps_array_count(reqby); for (unsigned int j = 0; j < reqbycnt; j++) { xbps_array_get_cstring_nocopy(reqby, j, &reqbydep); - if (xbps_find_pkg_in_array(array, reqbydep) || - xbps_find_virtualpkg_in_array(xhp, array, reqbydep)) + if (xbps_find_pkg_in_array(array, reqbydep, NULL) || + xbps_find_virtualpkg_in_array(xhp, array, reqbydep, NULL)) cnt++; } if (cnt == reqbycnt) { diff --git a/lib/plist_find.c b/lib/plist_find.c index 1ba298b9..cf878b4e 100644 --- a/lib/plist_find.c +++ b/lib/plist_find.c @@ -35,18 +35,20 @@ #include "xbps_api_impl.h" static xbps_dictionary_t -get_pkg_in_array(xbps_array_t array, const char *str, bool virtual) +get_pkg_in_array(xbps_array_t array, const char *str, const char *trans, bool virtual) { xbps_object_t obj = NULL; xbps_object_iterator_t iter; - const char *pkgver; - char *dpkgn; + const char *tract; bool found = false; iter = xbps_array_iterator(array); assert(iter); while ((obj = xbps_object_iterator_next(iter))) { + const char *pkgver; + char *dpkgn; + if (virtual) { /* * Check if package pattern matches @@ -90,6 +92,11 @@ get_pkg_in_array(xbps_array_t array, const char *str, bool virtual) } xbps_object_iterator_release(iter); + if (found && trans && + xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract)) { + if (strcmp(tract, trans) == 0) + found = false; + } if (!found) { errno = ENOENT; return NULL; @@ -98,18 +105,19 @@ get_pkg_in_array(xbps_array_t array, const char *str, bool virtual) } xbps_dictionary_t HIDDEN -xbps_find_pkg_in_array(xbps_array_t a, const char *s) +xbps_find_pkg_in_array(xbps_array_t a, const char *s, const char *trans) { assert(xbps_object_type(a) == XBPS_TYPE_ARRAY); assert(s); - return get_pkg_in_array(a, s, false); + return get_pkg_in_array(a, s, trans, false); } xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_array(struct xbps_handle *x, xbps_array_t a, - const char *s) + const char *s, + const char *trans) { xbps_dictionary_t pkgd; const char *vpkg; @@ -123,11 +131,11 @@ xbps_find_virtualpkg_in_array(struct xbps_handle *x, bypattern = true; if ((vpkg = vpkg_user_conf(x, s, bypattern))) { - if ((pkgd = get_pkg_in_array(a, vpkg, true))) + if ((pkgd = get_pkg_in_array(a, vpkg, trans, true))) return pkgd; } - return get_pkg_in_array(a, s, true); + return get_pkg_in_array(a, s, trans, true); } static xbps_dictionary_t diff --git a/lib/repo_pkgdeps.c b/lib/repo_pkgdeps.c index bad74389..c72adc7c 100644 --- a/lib/repo_pkgdeps.c +++ b/lib/repo_pkgdeps.c @@ -229,8 +229,8 @@ find_repo_deps(struct xbps_handle *xhp, * Pass 2: check if required dependency has been already * added in the transaction dictionary. */ - if ((curpkgd = xbps_find_pkg_in_array(unsorted, reqpkg)) || - (curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, reqpkg))) { + if ((curpkgd = xbps_find_pkg_in_array(unsorted, reqpkg, NULL)) || + (curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, reqpkg, NULL))) { xbps_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q); xbps_dbg_printf_append(xhp, " (%s queued)\n", pkgver_q); free(pkgname); diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c index d648ec13..7dd52e4d 100644 --- a/lib/transaction_ops.c +++ b/lib/transaction_ops.c @@ -156,7 +156,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall) * in transaction, in that case ignore it. */ if (action == TRANS_UPDATE) { - if (xbps_find_pkg_in_array(unsorted, repopkgver)) { + if (xbps_find_pkg_in_array(unsorted, repopkgver, NULL)) { xbps_dbg_printf(xhp, "[update] `%s' already queued in " "transaction.\n", repopkgver); return EEXIST; diff --git a/lib/transaction_package_replace.c b/lib/transaction_package_replace.c index 2e6310a1..5c706149 100644 --- a/lib/transaction_package_replace.c +++ b/lib/transaction_package_replace.c @@ -89,7 +89,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp) /* * Make sure to not add duplicates. */ - reppkgd = xbps_find_pkg_in_array(unsorted, curpkgname); + reppkgd = xbps_find_pkg_in_array(unsorted, curpkgname, NULL); if (reppkgd) { xbps_dictionary_get_cstring_nocopy(reppkgd, "transaction", &tract); @@ -102,7 +102,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp) * transaction and it's going to be updated. */ xbps_dictionary_get_bool(instd, "automatic-install", &instd_auto); - if ((reppkgd = xbps_find_pkg_in_array(unsorted, curpkgname))) { + if ((reppkgd = xbps_find_pkg_in_array(unsorted, curpkgname, NULL))) { xbps_dictionary_set_bool(instd, "remove-and-update", true); xbps_dictionary_set_bool(reppkgd, diff --git a/lib/transaction_revdeps.c b/lib/transaction_revdeps.c index aad477c1..643b1477 100644 --- a/lib/transaction_revdeps.c +++ b/lib/transaction_revdeps.c @@ -86,7 +86,7 @@ check_virtual_pkgs(struct xbps_handle *xhp, xbps_dictionary_get_cstring_nocopy(trans_pkgd, "pkgver", &pkgver); pkgdepname = xbps_pkg_name(pkgver); assert(pkgdepname); - if (xbps_find_pkg_in_array(unsorted, pkgdepname)) { + if (xbps_find_pkg_in_array(unsorted, pkgdepname, NULL)) { free(pkgdepname); continue; } @@ -196,7 +196,7 @@ xbps_transaction_revdeps(struct xbps_handle *xhp) * is in the transaction. */ pkgname = xbps_pkg_name(curpkgver); - if (xbps_find_pkg_in_array(unsorted, pkgname)) { + if (xbps_find_pkg_in_array(unsorted, pkgname, NULL)) { free(pkgname); continue; } diff --git a/lib/transaction_shlibs.c b/lib/transaction_shlibs.c index 506d869c..a1fb2d08 100644 --- a/lib/transaction_shlibs.c +++ b/lib/transaction_shlibs.c @@ -54,7 +54,7 @@ shlib_trans_matched(struct xbps_handle *xhp, const char *pkgver, const char *shl assert(pkgname); unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps"); - if ((pkgd = xbps_find_pkg_in_array(unsorted, pkgname)) == NULL) { + if ((pkgd = xbps_find_pkg_in_array(unsorted, pkgname, NULL)) == NULL) { free(pkgname); return false; } diff --git a/lib/transaction_sortdeps.c b/lib/transaction_sortdeps.c index a822171f..adc1257d 100644 --- a/lib/transaction_sortdeps.c +++ b/lib/transaction_sortdeps.c @@ -200,8 +200,8 @@ again: xbps_dbg_printf_append(xhp, "installed.\n"); continue; } - if (((curpkgd = xbps_find_pkg_in_array(unsorted, str)) == NULL) && - ((curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, str)) == NULL)) { + if (((curpkgd = xbps_find_pkg_in_array(unsorted, str, "remove")) == NULL) && + ((curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, str, "remove")) == NULL)) { xbps_dbg_printf_append(xhp, "cannot find %s in unsorted array\n", str); rv = EINVAL; break;