Fix both sides of provide/conflict handling to work the same way
authorDan Winship <danw@gnome.org>
Fri Mar 07 13:45:37 2008 -0500 (2008-03-07)
changeset 1565197b8e64e42
parent 155 068f443e00cc
child 157 57e8182f59bc
Fix both sides of provide/conflict handling to work the same way

thus fixing conflicts-on-properties-rather-than-names, thus fixing the
last remaining unpassed test
razor.c
     1.1 --- a/razor.c	Fri Mar 07 13:44:22 2008 -0500
     1.2 +++ b/razor.c	Fri Mar 07 13:45:37 2008 -0500
     1.3 @@ -2110,50 +2110,16 @@
     1.4  	return pkg;
     1.5  }
     1.6  
     1.7 -static struct razor_package *
     1.8 -find_upgrade(struct razor_transaction_resolver *trans,
     1.9 -	     struct razor_property *sp, struct razor_property *up)
    1.10 -{
    1.11 -	struct razor_property *conflict, req;
    1.12 -	struct razor_set *set;
    1.13 -	const char *pool;
    1.14 -
    1.15 -	if (sp->type == RAZOR_PROPERTY_CONFLICTS) {
    1.16 -		conflict = sp;
    1.17 -		set = trans->system;
    1.18 -	} else {
    1.19 -		conflict = up;
    1.20 -		set = trans->upstream;
    1.21 -	}
    1.22 -	pool = set->string_pool.data;
    1.23 -
    1.24 -	if (conflict->relation > RAZOR_VERSION_EQUAL ||
    1.25 -	    !pool[conflict->version])
    1.26 -		return NULL;
    1.27 -
    1.28 -	memcpy(&req, conflict, sizeof req);
    1.29 -	req.type = RAZOR_PROPERTY_REQUIRES;
    1.30 -	if (conflict->relation == RAZOR_VERSION_LESS)
    1.31 -		req.relation = RAZOR_VERSION_GREATER_OR_EQUAL;
    1.32 -	else
    1.33 -		req.relation = RAZOR_VERSION_GREATER;
    1.34 -
    1.35 -	return find_package_matching(trans, 0, up, &req, set);
    1.36 -}
    1.37 -
    1.38  /* FIXME */
    1.39  static struct razor_package *
    1.40  find_upgrade_for_installed_conflict(struct razor_transaction_resolver *trans,
    1.41  				    struct razor_package *conflicting_pkg,
    1.42 -				    struct razor_property *provider)
    1.43 +				    struct razor_property *prop)
    1.44  {
    1.45  	struct razor_package *upkgs, *up, *uend;
    1.46  	struct razor_property *uprops;
    1.47  	const char *spool, *upool;
    1.48 -	struct list *prop;
    1.49 -
    1.50 -	if (!package_in_set(conflicting_pkg, trans->system))
    1.51 -		return NULL;
    1.52 +	struct list *p;
    1.53  
    1.54  	up = upkgs = trans->upstream->packages.data;
    1.55  	uend = trans->upstream->packages.data + trans->upstream->packages.size;
    1.56 @@ -2167,9 +2133,14 @@
    1.57  	if (up == uend || strcmp(&upool[up->name], &spool[conflicting_pkg->name]) != 0)
    1.58  		return NULL;
    1.59  
    1.60 -	for (prop = list_first(&up->properties, &trans->system->property_pool); prop; prop = list_next(prop)) {
    1.61 -		if (uprops[prop->data].type == RAZOR_PROPERTY_CONFLICTS &&
    1.62 -		    provider_satisfies_requirement(provider, upool, &uprops[prop->data], upool))
    1.63 +	for (p = list_first(&up->properties, &trans->upstream->property_pool); p; p = list_next(p)) {
    1.64 +		if (prop->type == RAZOR_PROPERTY_PROVIDES &&
    1.65 +		    uprops[p->data].type == RAZOR_PROPERTY_CONFLICTS &&
    1.66 +		    provider_satisfies_requirement(prop, upool, &uprops[p->data], upool))
    1.67 +			return NULL;
    1.68 +		else if (prop->type == RAZOR_PROPERTY_CONFLICTS &&
    1.69 +			 uprops[p->data].type == RAZOR_PROPERTY_PROVIDES &&
    1.70 +			 provider_satisfies_requirement(&uprops[p->data], upool, prop, upool))
    1.71  			return NULL;
    1.72  	}
    1.73  	return up;
    1.74 @@ -2441,7 +2412,7 @@
    1.75  				/* Conflicts with something already installed.
    1.76  				 * Try to upgrade out.
    1.77  				 */
    1.78 -				upgrade = find_upgrade(trans, sp, up);
    1.79 +				upgrade = find_upgrade_for_installed_conflict(trans, pkg, up);
    1.80  				if (upgrade) {
    1.81  					add_transaction_package(trans, upgrade, pkg,
    1.82  								RAZOR_PACKAGE_INSTALL,
    1.83 @@ -2803,32 +2774,6 @@
    1.84  				}
    1.85  			}
    1.86  		}
    1.87 -
    1.88 -#if 0
    1.89 -		/* Likewise with to-be-installed packages (in this
    1.90 -		 * case we can't actually remove them, but
    1.91 -		 * add_transaction_package will handle creating the
    1.92 -		 * error entry).
    1.93 -		 */
    1.94 -		ur = first_up;
    1.95 -		while (ur > uprops + 1 && (ur - 1)->name == ur->name)
    1.96 -			ur--;
    1.97 -		for (; ur->type == RAZOR_PROPERTY_REQUIRES; ur++) {
    1.98 -			if (!prop_is_being_installed(trans, ur))
    1.99 -				continue;
   1.100 -			if (find_installed_package_for_property(trans, sp, up, ur))
   1.101 -				continue;
   1.102 -
   1.103 -			for (reqpkg = list_first(&ur->packages, &trans->upstream->package_pool); reqpkg; reqpkg = list_next(reqpkg)) {
   1.104 -				if (!bitarray_get(&trans->uppkgs, reqpkg->data))
   1.105 -					continue;
   1.106 -				pkg = &upkgs[reqpkg->data];
   1.107 -				add_transaction_package(trans, NULL, pkg,
   1.108 -							RAZOR_PACKAGE_REMOVE,
   1.109 -							NULL, sr);
   1.110 -			}
   1.111 -		}
   1.112 -#endif
   1.113  	}
   1.114  }
   1.115