Fix #18. An ATF test-case will be imported in a while.

This commit is contained in:
Juan RP 2013-11-01 18:05:11 +01:00
parent 747f250202
commit f09eab62cd
3 changed files with 23 additions and 7 deletions

View File

@ -37,7 +37,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
xbps_dictionary_t pkg_repod)
{
xbps_array_t pkg_cflicts, trans_cflicts;
xbps_dictionary_t pkgd;
xbps_dictionary_t pkgd, tpkgd;
xbps_object_t obj;
xbps_object_iterator_t iter;
const char *cfpkg, *repopkgver, *pkgver;
@ -71,6 +71,24 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
free(pkgname);
continue;
}
/*
* If there's an update for the conflicting pkg in
* the transaction and does not match the pattern,
* ignore it.
*/
if ((tpkgd = xbps_find_pkg_in_array(unsorted, pkgname))) {
const char *tract, *p;
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)) {
free(pkgname);
continue;
}
}
free(pkgname);
xbps_dbg_printf(xhp, "found conflicting installed "
"pkg %s with pkg in transaction %s\n", pkgver,

View File

@ -237,7 +237,7 @@ xbps_transaction_init(struct xbps_handle *xhp)
int
xbps_transaction_prepare(struct xbps_handle *xhp)
{
xbps_array_t mdeps, conflicts;
xbps_array_t pkgs, mdeps, conflicts;
int rv = 0;
if (xhp->transd == NULL)
@ -251,6 +251,9 @@ xbps_transaction_prepare(struct xbps_handle *xhp)
if (xbps_array_count(mdeps))
return ENODEV;
pkgs = xbps_dictionary_get(xhp->transd, "unsorted_deps");
for (unsigned int i = 0; i < xbps_array_count(pkgs); i++)
xbps_pkg_find_conflicts(xhp, pkgs, xbps_array_get(pkgs, i));
/*
* If there are package conflicts bail out.
*/

View File

@ -118,11 +118,6 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
return rv;
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
/*
* Find out if package has matched conflicts.
*/
xbps_pkg_find_conflicts(xhp, unsorted, pkg_repod);
/*
* Find out if package being updated matches the one already
* in transaction, in that case ignore it.