8 #include "solverdebug.h"
10 #include "repo_write.h"
11 #include "solv_xfopen.h"
14 dump_repo(Repo *repo, char *name)
17 if ((fp = fopen(name, "w")) == 0)
27 sortfunc(const void *ap, const void *bp, void *dp)
31 sa = pool->solvables + *(Id *)ap;
32 sb = pool->solvables + *(Id *)bp;
33 if (sa->name != sb->name)
35 int r = strcmp(pool_id2str(pool, sa->name), pool_id2str(pool, sb->name));
39 if (sa->evr != sb->evr)
41 int r = pool_evrcmp(pool, sa->evr, sb->evr, EVRCMP_COMPARE);
45 return *(Id *)ap - *(Id *)bp;
49 main(int argc, char **argv)
54 Repo *installed, *repo;
63 while (argc > 1 && !strcmp(argv[1], "-d"))
71 fprintf(stderr, "Usage: cudftest <cudfin> [cudfout]\n");
75 cudfout = argc > 2 ? argv[2] : 0;
77 if ((fp = solv_xfopen(cudfin, 0)) == 0)
84 pool_setdebuglevel(pool, debug - 1);
85 installed = repo_create(pool, "installed");
86 pool_set_installed(pool, installed);
87 repo = repo_create(pool, "repo");
89 repo_add_cudf(repo, installed, fp, &job, 0);
92 pool_createwhatprovides(pool);
97 dump_repo(installed, "cudf_installed.solv");
98 dump_repo(repo, "cudf_repo.solv");
101 solv = solver_create(pool);
102 solver_set_flag(solv, SOLVER_FLAG_ALLOW_UNINSTALL, 1);
103 /* solver_set_flag(solv, SOLVER_FLAG_IGNORE_RECOMMENDED, 1); */
105 queue_push2(&job, SOLVER_VERIFY | SOLVER_SOLVABLE_ALL, 0);
106 if (solver_solve(solv, &job) != 0)
109 int pcnt = solver_problem_count(solv);
110 printf("Found %d problems:\n", pcnt);
111 for (problem = 1; problem <= pcnt; problem++)
113 printf("Problem %d:\n", problem);
114 solver_printprobleminfo(solv, problem);
118 trans = solver_create_transaction(solv);
122 transaction_print(trans);
125 transaction_installedresult(trans, &dq);
126 solv_sort(dq.elements, dq.count, sizeof(Id), sortfunc, pool);
129 if (cudfout && ((ofp = fopen(cudfout, "w")) == 0))
134 for (i = 0; i < dq.count; i++)
136 Solvable *s = pool_id2solvable(pool, dq.elements[i]);
137 fprintf(ofp, "package: %s\n", pool_id2str(pool, s->name));
138 fprintf(ofp, "version: %s\n", pool_id2str(pool, s->evr));
139 fprintf(ofp, "installed: true\n");
140 if (s->repo == pool->installed)
141 fprintf(ofp, "was-installed: true\n");
145 transaction_free(trans);