11 #include "repo_solv.h"
12 #include "repo_susetags.h"
13 #include "repo_rpmmd.h"
17 cookie_gzread(void *cookie, char *buf, size_t nbytes)
19 return gzread((gzFile *)cookie, buf, nbytes);
23 cookie_gzclose(void *cookie)
25 return gzclose((gzFile *)cookie);
29 myfopen(const char *fn)
31 cookie_io_functions_t cio;
37 suf = strrchr(fn, '.');
38 if (!suf || strcmp(suf, ".gz") != 0)
39 return fopen(fn, "r");
40 gzf = gzopen(fn, "r");
43 memset(&cio, 0, sizeof(cio));
44 cio.read = cookie_gzread;
45 cio.close = cookie_gzclose;
46 return fopencookie(gzf, "r", cio);
50 main(int argc, char **argv)
61 Id rpmid, rpmarch, rpmrel, archlock;
68 pool_setarch(pool, arch);
69 for (i = 2; i < argc; i++)
74 if (!strcmp(argv[i], "--nocheck"))
77 nocheck = pool->nsolvables;
81 if (!strcmp(argv[i], "-"))
83 else if ((fp = myfopen(argv[i])) == 0)
88 Repo *repo = repo_create(pool, argv[i]);
89 if (l >= 8 && !strcmp(argv[i] + l - 8, "packages"))
91 repo_add_susetags(repo, fp, 0, 0, 0);
93 else if (l >= 11 && !strcmp(argv[i] + l - 11, "packages.gz"))
95 repo_add_susetags(repo, fp, 0, 0, 0);
97 else if (l >= 14 && !strcmp(argv[i] + l - 14, "primary.xml.gz"))
99 repo_add_rpmmd(repo, fp, 0, 0);
101 else if (repo_add_solv(repo, fp))
103 fprintf(stderr, "could not add repo %s\n", argv[i]);
109 pool_addfileprovides(pool);
110 pool_createwhatprovides(pool);
111 rpmid = str2id(pool, "rpm", 0);
112 rpmarch = str2id(pool, arch, 0);
114 if (rpmid && rpmarch)
116 for (p = 1; p < pool->nsolvables; p++)
118 Solvable *s = pool->solvables + p;
119 if (s->name == rpmid && s->arch == rpmarch)
122 if (p < pool->nsolvables)
123 rpmrel = rel2id(pool, rpmid, rpmarch, REL_ARCH, 1);
129 queue_init(&archlocks);
130 for (p = 1; p < pool->nsolvables; p++)
132 Solvable *s = pool->solvables + p;
135 if (!pool_installable(pool, s))
137 if (rpmrel && s->arch != rpmarch)
140 FOR_PROVIDES(rp, rpp, s->name)
142 if (pool->solvables[rp].name != s->name)
144 if (pool->solvables[rp].arch == rpmarch)
149 queue_push(&archlocks, p);
153 queue_push(&cand, p);
158 archlock = pool_queuetowhatprovides(pool, &archlocks);
160 /* prune cand by doing weak installs */
163 solv = solver_create(pool);
165 for (i = 0; i < cand.count; i++)
167 p = cand.elements[i];
168 queue_push(&job, SOLVER_INSTALL|SOLVER_SOLVABLE|SOLVER_WEAK);
173 queue_push(&job, SOLVER_INSTALL|SOLVER_SOLVABLE_NAME);
174 queue_push(&job, rpmrel);
178 queue_push(&job, SOLVER_LOCK|SOLVER_SOLVABLE_ONE_OF);
179 queue_push(&job, archlock);
181 solv->dontinstallrecommended = 1;
182 solver_solve(solv, &job);
184 for (i = j = 0; i < cand.count; i++)
186 p = cand.elements[i];
187 if (solv->decisionmap[p] <= 0)
189 cand.elements[j++] = p;
193 Solvable *s = pool->solvables + p;
194 if (!strcmp(id2str(pool, s->name), "libusb-compat-devel"))
196 cand.elements[j++] = p;
206 /* now check every candidate */
207 for (i = 0; i < cand.count; i++)
211 p = cand.elements[i];
212 if (nocheck && p >= nocheck)
214 s = pool->solvables + p;
215 solv = solver_create(pool);
217 queue_push(&job, SOLVER_INSTALL|SOLVER_SOLVABLE);
221 queue_push(&job, SOLVER_INSTALL|SOLVER_SOLVABLE_NAME);
222 queue_push(&job, rpmrel);
226 queue_push(&job, SOLVER_LOCK|SOLVER_SOLVABLE_ONE_OF);
227 queue_push(&job, archlock);
229 solv->dontinstallrecommended = 1;
230 solver_solve(solv, &job);
231 if (solv->problems.count)
237 printf("can't install %s:\n", solvable2str(pool, s));
238 while ((problem = solver_next_problem(solv, problem)) != 0)
240 solver_findallproblemrules(solv, problem, &rids);
241 for (j = 0; j < rids.count; j++)
243 Id probr = rids.elements[j];
248 solver_allruleinfos(solv, probr, &rinfo);
249 for (k = 0; k < rinfo.count; k += 4)
251 Id dep, source, target;
252 source = rinfo.elements[k + 1];
253 target = rinfo.elements[k + 2];
254 dep = rinfo.elements[k + 3];
255 switch (rinfo.elements[k])
257 case SOLVER_PROBLEM_DISTUPGRADE_RULE:
259 case SOLVER_PROBLEM_INFARCH_RULE:
260 s = pool_id2solvable(pool, source);
261 printf(" %s has inferior architecture\n", solvable2str(pool, s));
263 case SOLVER_PROBLEM_UPDATE_RULE:
265 case SOLVER_PROBLEM_JOB_RULE:
267 case SOLVER_PROBLEM_RPM_RULE:
268 printf(" some dependency problem\n");
270 case SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP:
271 printf(" nothing provides requested %s\n", dep2str(pool, dep));
273 case SOLVER_PROBLEM_NOT_INSTALLABLE:
274 s = pool_id2solvable(pool, source);
275 printf(" package %s is not installable\n", solvable2str(pool, s));
277 case SOLVER_PROBLEM_NOTHING_PROVIDES_DEP:
278 s = pool_id2solvable(pool, source);
279 printf(" nothing provides %s needed by %s\n", dep2str(pool, dep), solvable2str(pool, s));
282 Reldep *rd = GETRELDEP(pool, dep);
283 if (!ISRELDEP(rd->name))
286 FOR_PROVIDES(rp, rpp, rd->name)
287 printf(" (we have %s)\n", solvable2str(pool, pool->solvables + rp));
291 case SOLVER_PROBLEM_SAME_NAME:
292 s = pool_id2solvable(pool, source);
293 s2 = pool_id2solvable(pool, target);
294 printf(" cannot install both %s and %s\n", solvable2str(pool, s), solvable2str(pool, s2));
296 case SOLVER_PROBLEM_PACKAGE_CONFLICT:
297 s = pool_id2solvable(pool, source);
298 s2 = pool_id2solvable(pool, target);
299 printf(" package %s conflicts with %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
301 case SOLVER_PROBLEM_PACKAGE_OBSOLETES:
302 s = pool_id2solvable(pool, source);
303 s2 = pool_id2solvable(pool, target);
304 printf(" package %s obsoletes %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
306 case SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE:
307 s = pool_id2solvable(pool, source);
308 printf(" package %s requires %s, but none of the providers can be installed\n", solvable2str(pool, s), dep2str(pool, dep));
310 case SOLVER_PROBLEM_SELF_CONFLICT:
311 s = pool_id2solvable(pool, source);
312 printf(" package %s conflicts with %s provided by itself\n", solvable2str(pool, s), dep2str(pool, dep));
322 if (!strcmp(id2str(pool, s->name), "libusb-compat-devel"))
324 solver_printdecisions(solv);