libxbps: fixed replaces/replace_vpkg test case.
This commit is contained in:
@ -176,14 +176,10 @@ int HIDDEN xbps_repository_find_deps(struct xbps_handle *,
|
|||||||
* @private
|
* @private
|
||||||
* From lib/plist_find.c
|
* 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_pkg_in_dict(xbps_dictionary_t, const char *);
|
||||||
xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_dict(struct xbps_handle *,
|
xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_dict(struct xbps_handle *, xbps_dictionary_t, const char *);
|
||||||
xbps_dictionary_t,
|
xbps_dictionary_t HIDDEN xbps_find_pkg_in_array(xbps_array_t, const char *, const char *);
|
||||||
const char *);
|
xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_array(struct xbps_handle *, xbps_array_t, const char *, const char *);
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* From lib/transaction_revdeps.c
|
* From lib/transaction_revdeps.c
|
||||||
|
@ -76,7 +76,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
|
|||||||
* the transaction and does not match the pattern,
|
* the transaction and does not match the pattern,
|
||||||
* ignore it.
|
* 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;
|
const char *tract, *p;
|
||||||
|
|
||||||
xbps_dictionary_get_cstring_nocopy(tpkgd,
|
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.
|
* Check if current pkg conflicts with any pkg in transaction.
|
||||||
*/
|
*/
|
||||||
if ((pkgd = xbps_find_pkg_in_array(unsorted, cfpkg)) ||
|
if ((pkgd = xbps_find_pkg_in_array(unsorted, cfpkg, NULL)) ||
|
||||||
(pkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, cfpkg))) {
|
(pkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, cfpkg, NULL))) {
|
||||||
xbps_dictionary_get_cstring_nocopy(pkgd,
|
xbps_dictionary_get_cstring_nocopy(pkgd,
|
||||||
"pkgver", &pkgver);
|
"pkgver", &pkgver);
|
||||||
pkgname = xbps_pkg_name(pkgver);
|
pkgname = xbps_pkg_name(pkgver);
|
||||||
|
@ -123,8 +123,8 @@ find_orphans:
|
|||||||
for (unsigned int x = 0; x < xbps_array_count(rdeps); x++) {
|
for (unsigned int x = 0; x < xbps_array_count(rdeps); x++) {
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver);
|
xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver);
|
||||||
if (xbps_find_pkg_in_array(array, deppkgver) ||
|
if (xbps_find_pkg_in_array(array, deppkgver, NULL) ||
|
||||||
xbps_find_virtualpkg_in_array(xhp, array, deppkgver))
|
xbps_find_virtualpkg_in_array(xhp, array, deppkgver, NULL))
|
||||||
continue;
|
continue;
|
||||||
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, deppkgver);
|
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, deppkgver);
|
||||||
if (reqby == NULL)
|
if (reqby == NULL)
|
||||||
@ -132,8 +132,8 @@ find_orphans:
|
|||||||
reqbycnt = xbps_array_count(reqby);
|
reqbycnt = xbps_array_count(reqby);
|
||||||
for (unsigned int j = 0; j < reqbycnt; j++) {
|
for (unsigned int j = 0; j < reqbycnt; j++) {
|
||||||
xbps_array_get_cstring_nocopy(reqby, j, &reqbydep);
|
xbps_array_get_cstring_nocopy(reqby, j, &reqbydep);
|
||||||
if (xbps_find_pkg_in_array(array, reqbydep) ||
|
if (xbps_find_pkg_in_array(array, reqbydep, NULL) ||
|
||||||
xbps_find_virtualpkg_in_array(xhp, array, reqbydep))
|
xbps_find_virtualpkg_in_array(xhp, array, reqbydep, NULL))
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
if (cnt == reqbycnt) {
|
if (cnt == reqbycnt) {
|
||||||
|
@ -35,18 +35,20 @@
|
|||||||
#include "xbps_api_impl.h"
|
#include "xbps_api_impl.h"
|
||||||
|
|
||||||
static xbps_dictionary_t
|
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_t obj = NULL;
|
||||||
xbps_object_iterator_t iter;
|
xbps_object_iterator_t iter;
|
||||||
const char *pkgver;
|
const char *tract;
|
||||||
char *dpkgn;
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
iter = xbps_array_iterator(array);
|
iter = xbps_array_iterator(array);
|
||||||
assert(iter);
|
assert(iter);
|
||||||
|
|
||||||
while ((obj = xbps_object_iterator_next(iter))) {
|
while ((obj = xbps_object_iterator_next(iter))) {
|
||||||
|
const char *pkgver;
|
||||||
|
char *dpkgn;
|
||||||
|
|
||||||
if (virtual) {
|
if (virtual) {
|
||||||
/*
|
/*
|
||||||
* Check if package pattern matches
|
* 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);
|
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) {
|
if (!found) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -98,18 +105,19 @@ get_pkg_in_array(xbps_array_t array, const char *str, bool virtual)
|
|||||||
}
|
}
|
||||||
|
|
||||||
xbps_dictionary_t HIDDEN
|
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(xbps_object_type(a) == XBPS_TYPE_ARRAY);
|
||||||
assert(s);
|
assert(s);
|
||||||
|
|
||||||
return get_pkg_in_array(a, s, false);
|
return get_pkg_in_array(a, s, trans, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
xbps_dictionary_t HIDDEN
|
xbps_dictionary_t HIDDEN
|
||||||
xbps_find_virtualpkg_in_array(struct xbps_handle *x,
|
xbps_find_virtualpkg_in_array(struct xbps_handle *x,
|
||||||
xbps_array_t a,
|
xbps_array_t a,
|
||||||
const char *s)
|
const char *s,
|
||||||
|
const char *trans)
|
||||||
{
|
{
|
||||||
xbps_dictionary_t pkgd;
|
xbps_dictionary_t pkgd;
|
||||||
const char *vpkg;
|
const char *vpkg;
|
||||||
@ -123,11 +131,11 @@ xbps_find_virtualpkg_in_array(struct xbps_handle *x,
|
|||||||
bypattern = true;
|
bypattern = true;
|
||||||
|
|
||||||
if ((vpkg = vpkg_user_conf(x, s, bypattern))) {
|
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 pkgd;
|
||||||
}
|
}
|
||||||
|
|
||||||
return get_pkg_in_array(a, s, true);
|
return get_pkg_in_array(a, s, trans, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static xbps_dictionary_t
|
static xbps_dictionary_t
|
||||||
|
@ -229,8 +229,8 @@ find_repo_deps(struct xbps_handle *xhp,
|
|||||||
* Pass 2: check if required dependency has been already
|
* Pass 2: check if required dependency has been already
|
||||||
* added in the transaction dictionary.
|
* added in the transaction dictionary.
|
||||||
*/
|
*/
|
||||||
if ((curpkgd = xbps_find_pkg_in_array(unsorted, reqpkg)) ||
|
if ((curpkgd = xbps_find_pkg_in_array(unsorted, reqpkg, NULL)) ||
|
||||||
(curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, reqpkg))) {
|
(curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, reqpkg, NULL))) {
|
||||||
xbps_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q);
|
xbps_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q);
|
||||||
xbps_dbg_printf_append(xhp, " (%s queued)\n", pkgver_q);
|
xbps_dbg_printf_append(xhp, " (%s queued)\n", pkgver_q);
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
|
@ -156,7 +156,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall)
|
|||||||
* in transaction, in that case ignore it.
|
* in transaction, in that case ignore it.
|
||||||
*/
|
*/
|
||||||
if (action == TRANS_UPDATE) {
|
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 "
|
xbps_dbg_printf(xhp, "[update] `%s' already queued in "
|
||||||
"transaction.\n", repopkgver);
|
"transaction.\n", repopkgver);
|
||||||
return EEXIST;
|
return EEXIST;
|
||||||
|
@ -89,7 +89,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
/*
|
/*
|
||||||
* Make sure to not add duplicates.
|
* 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) {
|
if (reppkgd) {
|
||||||
xbps_dictionary_get_cstring_nocopy(reppkgd,
|
xbps_dictionary_get_cstring_nocopy(reppkgd,
|
||||||
"transaction", &tract);
|
"transaction", &tract);
|
||||||
@ -102,7 +102,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
* transaction and it's going to be updated.
|
* transaction and it's going to be updated.
|
||||||
*/
|
*/
|
||||||
xbps_dictionary_get_bool(instd, "automatic-install", &instd_auto);
|
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,
|
xbps_dictionary_set_bool(instd,
|
||||||
"remove-and-update", true);
|
"remove-and-update", true);
|
||||||
xbps_dictionary_set_bool(reppkgd,
|
xbps_dictionary_set_bool(reppkgd,
|
||||||
|
@ -86,7 +86,7 @@ check_virtual_pkgs(struct xbps_handle *xhp,
|
|||||||
xbps_dictionary_get_cstring_nocopy(trans_pkgd, "pkgver", &pkgver);
|
xbps_dictionary_get_cstring_nocopy(trans_pkgd, "pkgver", &pkgver);
|
||||||
pkgdepname = xbps_pkg_name(pkgver);
|
pkgdepname = xbps_pkg_name(pkgver);
|
||||||
assert(pkgdepname);
|
assert(pkgdepname);
|
||||||
if (xbps_find_pkg_in_array(unsorted, pkgdepname)) {
|
if (xbps_find_pkg_in_array(unsorted, pkgdepname, NULL)) {
|
||||||
free(pkgdepname);
|
free(pkgdepname);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ xbps_transaction_revdeps(struct xbps_handle *xhp)
|
|||||||
* is in the transaction.
|
* is in the transaction.
|
||||||
*/
|
*/
|
||||||
pkgname = xbps_pkg_name(curpkgver);
|
pkgname = xbps_pkg_name(curpkgver);
|
||||||
if (xbps_find_pkg_in_array(unsorted, pkgname)) {
|
if (xbps_find_pkg_in_array(unsorted, pkgname, NULL)) {
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ shlib_trans_matched(struct xbps_handle *xhp, const char *pkgver, const char *shl
|
|||||||
assert(pkgname);
|
assert(pkgname);
|
||||||
|
|
||||||
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
|
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);
|
free(pkgname);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -200,8 +200,8 @@ again:
|
|||||||
xbps_dbg_printf_append(xhp, "installed.\n");
|
xbps_dbg_printf_append(xhp, "installed.\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (((curpkgd = xbps_find_pkg_in_array(unsorted, str)) == NULL) &&
|
if (((curpkgd = xbps_find_pkg_in_array(unsorted, str, "remove")) == NULL) &&
|
||||||
((curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, str)) == 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);
|
xbps_dbg_printf_append(xhp, "cannot find %s in unsorted array\n", str);
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user