razor.c
changeset 190 d8b7dd11813d
parent 186 7f45d0401e37
child 191 6e94ebe58141
     1.1 --- a/razor.c	Sat Apr 05 01:15:04 2008 -0400
     1.2 +++ b/razor.c	Sun Apr 06 19:24:07 2008 -0400
     1.3 @@ -1716,6 +1716,51 @@
     1.4  	razor_package_iterator_destroy(pi2);
     1.5  }
     1.6  
     1.7 +struct razor_transaction;
     1.8 +struct razor_transaction_package;
     1.9 +struct razor_transaction_resolver;
    1.10 +
    1.11 +struct razor_transaction {
    1.12 +	int package_count, errors;
    1.13 +	struct razor_transaction_package *packages;
    1.14 +
    1.15 +	struct razor_set *system, *upstream;
    1.16 +};
    1.17 +
    1.18 +struct razor_transaction_package {
    1.19 +	const char *name, *old_version, *new_version;
    1.20 +	struct razor_package *old_package, *new_package;
    1.21 +	enum razor_transaction_package_state state;
    1.22 +
    1.23 +	/* dep_package is the name of the package that resulted in
    1.24 +	 * this entry being created (or NULL if the user requested the
    1.25 +	 * install/remove), with the other dep_ fields providing
    1.26 +	 * additional information.
    1.27 +	 *
    1.28 +	 * For INSTALL, if dep_type is REQUIRES, then dep_package
    1.29 +	 * required something that this package provides. If dep_type
    1.30 +	 * is CONFLICTS, then dep_package is a package that conflicted
    1.31 +	 * with an older version of this package, forcing an upgrade.
    1.32 +	 *
    1.33 +	 * For REMOVE, if dep_type is REQUIRES, then dep_package is a
    1.34 +	 * package that is being removed. If dep_type is OBSOLETES,
    1.35 +	 * then dep_package is a package that obsoletes this one.
    1.36 +	 *
    1.37 +	 * For OLD_CONFLICT or NEW_CONFLICT, dep_package is an
    1.38 +	 * existing package that conflicts with this one. The
    1.39 +	 * conflicting property comes from the already-installed
    1.40 +	 * package for OLD_CONFLICT, or the to-be-installed package
    1.41 +	 * for NEW_CONFLICT.
    1.42 +	 *
    1.43 +	 * For UNSATISFIABLE, the dep_ fields are as for an INSTALL,
    1.44 +	 * but the name field will be NULL.
    1.45 +	 */
    1.46 +	const char *dep_package;
    1.47 +	enum razor_property_type dep_type;
    1.48 +	const char *dep_property;
    1.49 +	enum razor_version_relation dep_relation;
    1.50 +	const char *dep_version;
    1.51 +};
    1.52  
    1.53  struct razor_transaction_resolver {
    1.54  	struct razor_set *system, *upstream;
    1.55 @@ -2637,7 +2682,7 @@
    1.56  	}
    1.57  }
    1.58  
    1.59 -void
    1.60 +int
    1.61  razor_transaction_describe(struct razor_transaction *trans)
    1.62  {
    1.63  	struct razor_transaction_package *p, *pend, *tps;
    1.64 @@ -2769,6 +2814,31 @@
    1.65  			break;
    1.66  		}
    1.67  	}
    1.68 +
    1.69 +	return trans->errors;
    1.70 +}
    1.71 +
    1.72 +int
    1.73 +razor_transaction_unsatisfied_property(struct razor_transaction *trans,
    1.74 +				       const char *name,
    1.75 +				       enum razor_version_relation rel,
    1.76 +				       const char *version)
    1.77 +{
    1.78 +	struct razor_transaction_package *p, *end;
    1.79 +
    1.80 +	end = trans->packages + trans->package_count;
    1.81 +	for (p = trans->packages; p < end; p++) {
    1.82 +		if (p->state != RAZOR_PACKAGE_UNSATISFIABLE)
    1.83 +			continue;
    1.84 +		if (strcmp(name, p->dep_property) != 0 ||
    1.85 +		    rel != p->dep_relation ||
    1.86 +		    strcmp(version, p->dep_version) != 0)
    1.87 +			continue;
    1.88 +
    1.89 +		return 1;
    1.90 +	}
    1.91 +
    1.92 +	return 0;
    1.93  }
    1.94  
    1.95  struct razor_set *