1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/* vim: sw=2 et
*/
#include <stdio.h>
#include <stdlib.h>
#include "pool.h"
#include "repo.h"
#include "solver.h"
#include "solverdebug.h"
#include "hash.h"
#include "repo_rpmdb.h"
#include "pool_fileconflicts.h"
static void *
iterate_handle(Pool *pool, Id p, void *cbdata)
{
Solvable *s = pool->solvables + p;
Id rpmdbid;
if (!s->repo->rpmdbid)
return 0;
rpmdbid = s->repo->rpmdbid[p - s->repo->start];
if (!rpmdbid)
return 0;
return rpm_byrpmdbid(cbdata, rpmdbid);
}
int main(int argc, char **argv)
{
Pool *pool;
Repo *installed;
Solvable *s;
Id p;
int i;
Queue todo, conflicts;
void *state = 0;
pool = pool_create();
pool_setdebuglevel(pool, 1);
installed = repo_create(pool, "@System");
pool_set_installed(pool, installed);
if (repo_add_rpmdb(installed, 0, 0))
{
fprintf(stderr, "findfileconflicts: %s\n", pool_errstr(pool));
exit(1);
}
queue_init(&todo);
queue_init(&conflicts);
FOR_REPO_SOLVABLES(installed, p, s)
queue_push(&todo, p);
state = rpm_state_create(0);
pool_findfileconflicts(pool, &todo, 0, &conflicts, FINDFILECONFLICTS_USESOLVABLEFILELIST, &iterate_handle, state);
rpm_state_free(state);
queue_free(&todo);
for (i = 0; i < conflicts.count; i += 6)
printf("%s: %s[%s] %s[%s]\n", pool_id2str(pool, conflicts.elements[i]), pool_solvid2str(pool, conflicts.elements[i + 1]), pool_id2str(pool, conflicts.elements[i + 2]), pool_solvid2str(pool, conflicts.elements[i + 4]), pool_id2str(pool, conflicts.elements[i + 5]));
if (conflicts.count)
{
Queue job;
int problemcnt;
queue_init(&job);
pool_add_fileconflicts_deps(pool, &conflicts);
pool_addfileprovides(pool);
pool_createwhatprovides(pool);
pool_setdebuglevel(pool, 0);
Solver *solv = solver_create(pool);
queue_push2(&job, SOLVER_VERIFY|SOLVER_SOLVABLE_ALL, 0);
#if 0
solver_set_flag(solv, SOLVER_FLAG_ALLOW_UNINSTALL, 1);
#endif
problemcnt = solver_solve(solv, &job);
if (problemcnt)
solver_printallsolutions(solv);
else
{
Transaction *trans = solver_create_transaction(solv);
transaction_print(trans);
transaction_free(trans);
}
queue_free(&job);
solver_free(solv);
}
queue_free(&conflicts);
exit(0);
}
|