{
struct razor_set *set, *upstream;
struct razor_transaction *trans;
+ int errors;
set = razor_set_open(repo_filename);
upstream = razor_set_open(rawhide_repo_filename);
if (set == NULL || upstream == NULL)
return 1;
trans = razor_transaction_create(set, upstream, argc, argv, 0, NULL);
- razor_transaction_describe(trans);
- if (trans->errors)
+ errors = razor_transaction_describe(trans);
+ if (errors)
return 1;
set = razor_transaction_run(trans);
{
struct razor_set *set;
struct razor_transaction *trans;
+ int errors;
set = razor_set_open(repo_filename);
if (set == NULL)
return 1;
trans = razor_transaction_create(set, NULL, 0, NULL, argc, argv);
- razor_transaction_describe(trans);
- if (trans->errors)
+ errors = razor_transaction_describe(trans);
+ if (errors)
return 1;
set = razor_transaction_run(trans);
struct razor_rpm *rpm;
const char *filename;
char path[PATH_MAX], new_path[PATH_MAX], **packages;
- int i;
+ int errors, i;
upstream = create_set_from_rpms(argc, argv);
snprintf(path, sizeof path,
argc, (const char **)packages,
0, NULL);
free(packages);
- razor_transaction_describe(trans);
- if (trans->errors)
+ errors = razor_transaction_describe(trans);
+ if (errors)
return 1;
/* FIXME: Use _finish() convention here? That is, a function
razor_package_iterator_destroy(pi2);
}
+struct razor_transaction;
+struct razor_transaction_package;
+struct razor_transaction_resolver;
+
+struct razor_transaction {
+ int package_count, errors;
+ struct razor_transaction_package *packages;
+
+ struct razor_set *system, *upstream;
+};
+
+struct razor_transaction_package {
+ const char *name, *old_version, *new_version;
+ struct razor_package *old_package, *new_package;
+ enum razor_transaction_package_state state;
+
+ /* dep_package is the name of the package that resulted in
+ * this entry being created (or NULL if the user requested the
+ * install/remove), with the other dep_ fields providing
+ * additional information.
+ *
+ * For INSTALL, if dep_type is REQUIRES, then dep_package
+ * required something that this package provides. If dep_type
+ * is CONFLICTS, then dep_package is a package that conflicted
+ * with an older version of this package, forcing an upgrade.
+ *
+ * For REMOVE, if dep_type is REQUIRES, then dep_package is a
+ * package that is being removed. If dep_type is OBSOLETES,
+ * then dep_package is a package that obsoletes this one.
+ *
+ * For OLD_CONFLICT or NEW_CONFLICT, dep_package is an
+ * existing package that conflicts with this one. The
+ * conflicting property comes from the already-installed
+ * package for OLD_CONFLICT, or the to-be-installed package
+ * for NEW_CONFLICT.
+ *
+ * For UNSATISFIABLE, the dep_ fields are as for an INSTALL,
+ * but the name field will be NULL.
+ */
+ const char *dep_package;
+ enum razor_property_type dep_type;
+ const char *dep_property;
+ enum razor_version_relation dep_relation;
+ const char *dep_version;
+};
struct razor_transaction_resolver {
struct razor_set *system, *upstream;
}
}
-void
+int
razor_transaction_describe(struct razor_transaction *trans)
{
struct razor_transaction_package *p, *pend, *tps;
break;
}
}
+
+ return trans->errors;
+}
+
+int
+razor_transaction_unsatisfied_property(struct razor_transaction *trans,
+ const char *name,
+ enum razor_version_relation rel,
+ const char *version)
+{
+ struct razor_transaction_package *p, *end;
+
+ end = trans->packages + trans->package_count;
+ for (p = trans->packages; p < end; p++) {
+ if (p->state != RAZOR_PACKAGE_UNSATISFIABLE)
+ continue;
+ if (strcmp(name, p->dep_property) != 0 ||
+ rel != p->dep_relation ||
+ strcmp(version, p->dep_version) != 0)
+ continue;
+
+ return 1;
+ }
+
+ return 0;
}
struct razor_set *
RAZOR_PACKAGE_UNSATISFIABLE,
};
-struct razor_transaction_package {
- const char *name, *old_version, *new_version;
- struct razor_package *old_package, *new_package;
- enum razor_transaction_package_state state;
-
- /* dep_package is the name of the package that resulted in
- * this entry being created (or NULL if the user requested the
- * install/remove), with the other dep_ fields providing
- * additional information.
- *
- * For INSTALL, if dep_type is REQUIRES, then dep_package
- * required something that this package provides. If dep_type
- * is CONFLICTS, then dep_package is a package that conflicted
- * with an older version of this package, forcing an upgrade.
- *
- * For REMOVE, if dep_type is REQUIRES, then dep_package is a
- * package that is being removed. If dep_type is OBSOLETES,
- * then dep_package is a package that obsoletes this one.
- *
- * For OLD_CONFLICT or NEW_CONFLICT, dep_package is an
- * existing package that conflicts with this one. The
- * conflicting property comes from the already-installed
- * package for OLD_CONFLICT, or the to-be-installed package
- * for NEW_CONFLICT.
- *
- * For UNSATISFIABLE, the dep_ fields are as for an INSTALL,
- * but the name field will be NULL.
- */
- const char *dep_package;
- enum razor_property_type dep_type;
- const char *dep_property;
- enum razor_version_relation dep_relation;
- const char *dep_version;
-};
-
-struct razor_transaction {
- int package_count, errors;
- struct razor_transaction_package *packages;
-
- struct razor_set *system, *upstream;
-};
-
struct razor_transaction *
razor_transaction_create(struct razor_set *system, struct razor_set *upstream,
int update_count, const char **update_packages,
int remove_count, const char **remove_packages);
-void razor_transaction_describe(struct razor_transaction *trans);
+int razor_transaction_describe(struct razor_transaction *trans);
struct razor_set *razor_transaction_run(struct razor_transaction *trans);
void razor_transaction_destroy(struct razor_transaction *trans);
+/* Temporary helper for test suite. */
+int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
+ const char *name,
+ enum razor_version_relation rel,
+ const char *version);
+
/* Importer interface; for building a razor set from external sources,
* like yum, rpmdb or razor package files. */
struct razor_set **importer_set;
struct razor_transaction *trans;
- struct razor_transaction_package *unsat;
char *install_pkgs[3], *remove_pkgs[3];
int n_install_pkgs, n_remove_pkgs;
+ int unsat;
int in_result;
int debug, errors;
}
static void
-check_unsatisfiable_property(struct test_context *ctx, enum razor_property_type type, const char *name, enum razor_version_relation rel, const char *version)
+check_unsatisfiable_property(struct test_context *ctx,
+ enum razor_property_type type,
+ const char *name,
+ enum razor_version_relation rel,
+ const char *version)
{
if (!version)
version = "";
- for (; ctx->unsat < ctx->trans->packages + ctx->trans->package_count; ctx->unsat++) {
- if (ctx->unsat->state != RAZOR_PACKAGE_UNSATISFIABLE)
- continue;
- if (strcmp(name, ctx->unsat->dep_property) != 0 ||
- rel != ctx->unsat->dep_relation ||
- strcmp(version, ctx->unsat->dep_version) != 0)
- continue;
-
- /* OK, found it, so skip over it and continue */
- ctx->unsat++;
+ if (razor_transaction_unsatisfied_property(ctx->trans,
+ name, rel, version))
return;
- }
fprintf(stderr, " didn't get unsatisfiable '%s %s %s'\n",
name, razor_version_relations[rel], version);
static void
end_transaction(struct test_context *ctx)
{
+ int errors;
+
ctx->trans = razor_transaction_create(ctx->system_set, ctx->repo_set,
ctx->n_install_pkgs,
(const char **)ctx->install_pkgs,
ctx->n_remove_pkgs,
(const char **)ctx->remove_pkgs);
- if (ctx->debug) {
- razor_transaction_describe(ctx->trans);
- printf("\n");
- }
+ errors = razor_transaction_describe(ctx->trans);
+ printf("\n");
while (ctx->n_install_pkgs--)
free(ctx->install_pkgs[ctx->n_install_pkgs]);
while (ctx->n_remove_pkgs--)
free(ctx->remove_pkgs[ctx->n_remove_pkgs]);
- if (!ctx->trans->errors) {
+ if (!errors) {
struct razor_set *new;
new = razor_transaction_run(ctx->trans);
razor_set_destroy(ctx->system_set);
exit(1);
}
- ctx->unsat = ctx->trans->packages;
+ ctx->unsat = 1;
}
static void
end_unsatisfiable(struct test_context *ctx)
{
- ctx->unsat = NULL;
+ ctx->unsat = 0;
}
static void