2 * Copyright (c) 2007-2009, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
11 * Transaction handling
20 #include "transaction.h"
28 obsq_sortcmp(const void *ap, const void *bp, void *dp)
32 Solvable *s, *oas, *obs;
43 s = pool->solvables + a;
44 oas = pool->solvables + oa;
45 obs = pool->solvables + ob;
46 if (oas->name != obs->name)
48 if (oas->name == s->name)
50 if (obs->name == s->name)
52 return strcmp(id2str(pool, oas->name), id2str(pool, obs->name));
54 r = evrcmp(pool, oas->evr, obs->evr, EVRCMP_COMPARE);
56 return -r; /* highest version first */
61 transaction_all_obs_pkgs(Transaction *trans, Id p, Queue *pkgs)
63 Pool *pool = trans->pool;
64 Solvable *s = pool->solvables + p;
65 Queue *ti = &trans->transaction_info;
70 if (p <= 0 || !s->repo)
72 if (s->repo == pool->installed)
74 q = trans->transaction_installed[p - pool->installed->start];
82 /* find which packages obsolete us */
83 for (i = 0; i < ti->count; i += 2)
84 if (ti->elements[i + 1] == p)
87 queue_push(pkgs, ti->elements[i]);
91 sat_sort(pkgs->elements, pkgs->count / 2, 2 * sizeof(Id), obsq_sortcmp, pool);
92 for (i = 0; i < pkgs->count; i += 2)
93 pkgs->elements[i / 2] = pkgs->elements[i + 1];
98 /* find the packages we obsolete */
99 for (i = 0; i < ti->count; i += 2)
101 if (ti->elements[i] == p)
102 queue_push(pkgs, ti->elements[i + 1]);
103 else if (pkgs->count)
110 transaction_obs_pkg(Transaction *trans, Id p)
112 Pool *pool = trans->pool;
113 Solvable *s = pool->solvables + p;
117 if (p <= 0 || !s->repo)
119 if (s->repo == pool->installed)
121 p = trans->transaction_installed[p - pool->installed->start];
122 return p < 0 ? -p : p;
124 queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
125 transaction_all_obs_pkgs(trans, p, &ti);
126 p = ti.count ? ti.elements[0] : 0;
133 * calculate base type of transaction element
137 transaction_base_type(Transaction *trans, Id p)
139 Pool *pool = trans->pool;
144 if (!MAPTST(&trans->transactsmap, p))
145 return SOLVER_TRANSACTION_IGNORE;
146 p2 = transaction_obs_pkg(trans, p);
147 if (pool->installed && pool->solvables[p].repo == pool->installed)
151 return SOLVER_TRANSACTION_ERASE;
152 s = pool->solvables + p;
153 s2 = pool->solvables + p2;
154 if (s->name == s2->name)
156 if (s->evr == s2->evr && solvable_identical(s, s2))
157 return SOLVER_TRANSACTION_REINSTALLED;
158 r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
160 return SOLVER_TRANSACTION_UPGRADED;
162 return SOLVER_TRANSACTION_DOWNGRADED;
163 return SOLVER_TRANSACTION_CHANGED;
165 return SOLVER_TRANSACTION_OBSOLETED;
169 int noobs = trans->noobsmap.size && MAPTST(&trans->noobsmap, p);
171 return p2 ? SOLVER_TRANSACTION_MULTIREINSTALL : SOLVER_TRANSACTION_MULTIINSTALL;
173 return SOLVER_TRANSACTION_INSTALL;
174 s = pool->solvables + p;
175 s2 = pool->solvables + p2;
176 if (s->name == s2->name)
178 if (s->evr == s2->evr && solvable_identical(s, s2))
179 return SOLVER_TRANSACTION_REINSTALL;
180 r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
182 return SOLVER_TRANSACTION_UPGRADE;
184 return SOLVER_TRANSACTION_DOWNGRADE;
186 return SOLVER_TRANSACTION_CHANGE;
188 return SOLVER_TRANSACTION_OBSOLETES;
193 * return type of transaction element
195 * filtering is needed if either not all packages are shown
196 * or replaces are not shown, as otherwise parts of the
197 * transaction might not be shown to the user */
200 transaction_type(Transaction *trans, Id p, int mode)
202 Pool *pool = trans->pool;
203 Solvable *s = pool->solvables + p;
209 return SOLVER_TRANSACTION_IGNORE;
211 type = transaction_base_type(trans, p);
213 if ((mode & SOLVER_TRANSACTION_RPM_ONLY) != 0)
215 /* application wants to know what to feed to rpm */
216 if (type == SOLVER_TRANSACTION_ERASE || type == SOLVER_TRANSACTION_INSTALL || type == SOLVER_TRANSACTION_MULTIINSTALL)
218 if (s->repo == pool->installed)
219 return SOLVER_TRANSACTION_IGNORE; /* ignore as we're being obsoleted */
220 if (type == SOLVER_TRANSACTION_MULTIREINSTALL)
221 return SOLVER_TRANSACTION_MULTIINSTALL;
222 return SOLVER_TRANSACTION_INSTALL;
225 if ((mode & SOLVER_TRANSACTION_SHOW_MULTIINSTALL) == 0)
227 /* application wants to make no difference between install
228 * and multiinstall */
229 if (type == SOLVER_TRANSACTION_MULTIINSTALL)
230 type = SOLVER_TRANSACTION_INSTALL;
231 if (type == SOLVER_TRANSACTION_MULTIREINSTALL)
232 type = SOLVER_TRANSACTION_REINSTALL;
235 if ((mode & SOLVER_TRANSACTION_CHANGE_IS_REINSTALL))
237 /* application wants to make no difference between change
239 if (type == SOLVER_TRANSACTION_CHANGED)
240 type = SOLVER_TRANSACTION_REINSTALLED;
241 else if (type == SOLVER_TRANSACTION_CHANGE)
242 type = SOLVER_TRANSACTION_REINSTALL;
245 if (type == SOLVER_TRANSACTION_ERASE || type == SOLVER_TRANSACTION_INSTALL || type == SOLVER_TRANSACTION_MULTIINSTALL)
248 if (s->repo == pool->installed && (mode & SOLVER_TRANSACTION_SHOW_ACTIVE) == 0)
250 /* erase element and we're showing the passive side */
251 if ((mode & SOLVER_TRANSACTION_SHOW_OBSOLETES) == 0 && type == SOLVER_TRANSACTION_OBSOLETED)
252 type = SOLVER_TRANSACTION_ERASE;
255 if (s->repo != pool->installed && (mode & SOLVER_TRANSACTION_SHOW_ACTIVE) != 0)
257 /* install element and we're showing the active side */
258 if ((mode & SOLVER_TRANSACTION_SHOW_OBSOLETES) == 0 && type == SOLVER_TRANSACTION_OBSOLETES)
259 type = SOLVER_TRANSACTION_INSTALL;
263 /* the element doesn't match the show mode */
265 /* if we're showing all references, we can ignore this package */
266 if ((mode & (SOLVER_TRANSACTION_SHOW_ALL|SOLVER_TRANSACTION_SHOW_OBSOLETES)) == (SOLVER_TRANSACTION_SHOW_ALL|SOLVER_TRANSACTION_SHOW_OBSOLETES))
267 return SOLVER_TRANSACTION_IGNORE;
269 /* we're not showing all refs. check if some other package
270 * references us. If yes, it's safe to ignore this package,
271 * otherwise we need to map the type */
273 /* most of the time there's only one reference, so check it first */
274 q = transaction_obs_pkg(trans, p);
276 if ((mode & SOLVER_TRANSACTION_SHOW_OBSOLETES) == 0)
278 Solvable *sq = pool->solvables + q;
279 if (sq->name != s->name)
281 /* it's a replace but we're not showing replaces. map type. */
282 if (s->repo == pool->installed)
283 return SOLVER_TRANSACTION_ERASE;
284 else if (type == SOLVER_TRANSACTION_MULTIREINSTALL)
285 return SOLVER_TRANSACTION_MULTIINSTALL;
287 return SOLVER_TRANSACTION_INSTALL;
291 /* if there's a match, p will be shown when q
293 if (transaction_obs_pkg(trans, q) == p)
294 return SOLVER_TRANSACTION_IGNORE;
296 /* too bad, a miss. check em all */
299 transaction_all_obs_pkgs(trans, p, &oq);
300 for (i = 0; i < oq.count; i++)
303 if ((mode & SOLVER_TRANSACTION_SHOW_OBSOLETES) == 0)
305 Solvable *sq = pool->solvables + q;
306 if (sq->name != s->name)
309 /* check if we are referenced? */
310 if ((mode & SOLVER_TRANSACTION_SHOW_ALL) != 0)
312 transaction_all_obs_pkgs(trans, q, &rq);
313 for (j = 0; j < rq.count; j++)
314 if (rq.elements[j] == p)
322 else if (transaction_obs_pkg(trans, q) == p)
333 /* we're not referenced. map type */
334 if (s->repo == pool->installed)
335 return SOLVER_TRANSACTION_ERASE;
336 else if (type == SOLVER_TRANSACTION_MULTIREINSTALL)
337 return SOLVER_TRANSACTION_MULTIINSTALL;
339 return SOLVER_TRANSACTION_INSTALL;
341 /* there was a ref, so p is shown with some other package */
342 return SOLVER_TRANSACTION_IGNORE;
348 classify_cmp(const void *ap, const void *bp, void *dp)
350 Transaction *trans = dp;
351 Pool *pool = trans->pool;
361 return a[2] && b[2] ? strcmp(id2str(pool, a[2]), id2str(pool, b[2])) : r;
364 return a[3] && b[3] ? strcmp(id2str(pool, a[3]), id2str(pool, b[3])) : r;
369 classify_cmp_pkgs(const void *ap, const void *bp, void *dp)
371 Transaction *trans = dp;
372 Pool *pool = trans->pool;
377 sa = pool->solvables + a;
378 sb = pool->solvables + b;
379 if (sa->name != sb->name)
380 return strcmp(id2str(pool, sa->name), id2str(pool, sb->name));
381 if (sa->evr != sb->evr)
383 int r = evrcmp(pool, sa->evr, sb->evr, EVRCMP_COMPARE);
391 transaction_classify(Transaction *trans, int mode, Queue *classes)
393 Pool *pool = trans->pool;
394 int ntypes[SOLVER_TRANSACTION_MAXTYPE];
396 Id v, vq, type, p, q;
399 queue_empty(classes);
400 memset(ntypes, 0, sizeof(ntypes));
401 /* go through transaction and classify each step */
402 for (i = 0; i < trans->steps.count; i++)
404 p = trans->steps.elements[i];
405 s = pool->solvables + p;
406 type = transaction_type(trans, p, mode);
408 if (!pool->installed || s->repo != pool->installed)
410 /* look at arch/vendor changes */
411 q = transaction_obs_pkg(trans, p);
414 sq = pool->solvables + q;
420 if ((mode & SOLVER_TRANSACTION_MERGE_ARCHCHANGES) != 0)
422 for (j = 0; j < classes->count; j += 4)
423 if (classes->elements[j] == SOLVER_TRANSACTION_ARCHCHANGE && classes->elements[j + 2] == v && classes->elements[j + 3] == vq)
425 if (j == classes->count)
427 queue_push(classes, SOLVER_TRANSACTION_ARCHCHANGE);
428 queue_push(classes, 1);
429 queue_push(classes, v);
430 queue_push(classes, vq);
433 classes->elements[j + 1]++;
436 v = s->vendor ? s->vendor : 1;
437 vq = sq->vendor ? sq->vendor : 1;
440 if ((mode & SOLVER_TRANSACTION_MERGE_VENDORCHANGES) != 0)
442 for (j = 0; j < classes->count; j += 4)
443 if (classes->elements[j] == SOLVER_TRANSACTION_VENDORCHANGE && classes->elements[j + 2] == v && classes->elements[j + 3] == vq)
445 if (j == classes->count)
447 queue_push(classes, SOLVER_TRANSACTION_VENDORCHANGE);
448 queue_push(classes, 1);
449 queue_push(classes, v);
450 queue_push(classes, vq);
453 classes->elements[j + 1]++;
456 /* now sort all vendor/arch changes */
458 sat_sort(classes->elements, classes->count / 4, 4 * sizeof(Id), classify_cmp, trans);
459 /* finally add all classes. put erases last */
460 i = SOLVER_TRANSACTION_ERASE;
463 queue_unshift(classes, 0);
464 queue_unshift(classes, 0);
465 queue_unshift(classes, ntypes[i]);
466 queue_unshift(classes, i);
468 for (i = SOLVER_TRANSACTION_MAXTYPE; i > 0; i--)
472 if (i == SOLVER_TRANSACTION_ERASE)
474 queue_unshift(classes, 0);
475 queue_unshift(classes, 0);
476 queue_unshift(classes, ntypes[i]);
477 queue_unshift(classes, i);
482 transaction_classify_pkgs(Transaction *trans, int mode, Id class, Id from, Id to, Queue *pkgs)
484 Pool *pool = trans->pool;
490 for (i = 0; i < trans->steps.count; i++)
492 p = trans->steps.elements[i];
493 s = pool->solvables + p;
494 if (class <= SOLVER_TRANSACTION_MAXTYPE)
496 type = transaction_type(trans, p, mode);
501 if (!pool->installed || s->repo != pool->installed)
503 q = transaction_obs_pkg(trans, p);
506 sq = pool->solvables + q;
507 if (class == SOLVER_TRANSACTION_ARCHCHANGE)
509 if ((!from && !to) || (s->arch == from && sq->arch == to))
513 if (class == SOLVER_TRANSACTION_VENDORCHANGE)
515 Id v = s->vendor ? s->vendor : 1;
516 Id vq = sq->vendor ? sq->vendor : 1;
517 if ((!from && !to) || (v == from && vq == to))
523 sat_sort(pkgs->elements, pkgs->count, sizeof(Id), classify_cmp_pkgs, trans);
527 create_transaction_info(Transaction *trans, Queue *decisionq)
529 Pool *pool = trans->pool;
530 Queue *ti = &trans->transaction_info;
531 Repo *installed = pool->installed;
537 trans->transaction_installed = sat_free(trans->transaction_installed);
539 return; /* no info needed */
540 for (i = 0; i < decisionq->count; i++)
542 p = decisionq->elements[i];
543 if (p <= 0 || p == SYSTEMSOLVABLE)
545 s = pool->solvables + p;
546 if (s->repo == installed)
548 noobs = trans->noobsmap.size && MAPTST(&trans->noobsmap, p);
549 FOR_PROVIDES(p2, pp2, s->name)
551 if (!MAPTST(&trans->transactsmap, p2))
553 s2 = pool->solvables + p2;
554 if (s2->repo != installed)
556 if (noobs && (s->name != s2->name || s->evr != s2->evr || s->arch != s2->arch))
558 if (!pool->implicitobsoleteusesprovides && s->name != s2->name)
563 if (s->obsoletes && !noobs)
565 Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
566 while ((obs = *obsp++) != 0)
568 FOR_PROVIDES(p2, pp2, obs)
570 s2 = pool->solvables + p2;
571 if (s2->repo != installed)
573 if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p2, obs))
581 sat_sort(ti->elements, ti->count / 2, 2 * sizeof(Id), obsq_sortcmp, pool);
583 for (i = j = 0; i < ti->count; i += 2)
585 if (j && ti->elements[i] == ti->elements[j - 2] && ti->elements[i + 1] == ti->elements[j - 1])
587 ti->elements[j++] = ti->elements[i];
588 ti->elements[j++] = ti->elements[i + 1];
592 /* create transaction_installed helper */
593 trans->transaction_installed = sat_calloc(installed->end - installed->start, sizeof(Id));
594 for (i = 0; i < ti->count; i += 2)
596 j = ti->elements[i + 1] - installed->start;
597 if (!trans->transaction_installed[j])
598 trans->transaction_installed[j] = ti->elements[i];
601 /* more than one package obsoletes us. compare */
603 if (trans->transaction_installed[j] > 0)
604 trans->transaction_installed[j] = -trans->transaction_installed[j];
605 q[0] = q[2] = ti->elements[i + 1];
606 q[1] = ti->elements[i];
607 q[3] = -trans->transaction_installed[j];
608 if (obsq_sortcmp(q, q + 2, pool) < 0)
609 trans->transaction_installed[j] = -ti->elements[i];
616 transaction_calculate(Transaction *trans, Queue *decisionq, Map *noobsmap)
618 Pool *pool = trans->pool;
619 Repo *installed = pool->installed;
624 if (noobsmap && !noobsmap->size)
625 noobsmap = 0; /* ignore empty map */
626 queue_empty(&trans->steps);
627 map_init(&trans->transactsmap, pool->nsolvables);
629 for (i = 0; i < decisionq->count; i++)
631 p = decisionq->elements[i];
632 s = pool->solvables + (p > 0 ? p : -p);
635 if (installed && s->repo == installed && p < 0)
636 MAPSET(&trans->transactsmap, -p);
637 if ((!installed || s->repo != installed) && p > 0)
639 MAPSET(&trans->transactsmap, p);
640 if (noobsmap && MAPTST(noobsmap, p))
644 MAPCLR(&trans->transactsmap, SYSTEMSOLVABLE);
646 map_init_clone(&trans->noobsmap, noobsmap);
648 create_transaction_info(trans, decisionq);
652 FOR_REPO_SOLVABLES(installed, p, s)
654 if (MAPTST(&trans->transactsmap, p))
655 queue_push(&trans->steps, p);
658 for (i = 0; i < decisionq->count; i++)
660 p = decisionq->elements[i];
661 if (p > 0 && MAPTST(&trans->transactsmap, p))
662 queue_push(&trans->steps, p);
668 struct _TransactionElement {
669 Id p; /* solvable id */
670 Id edges; /* pointer into edges data */
674 struct _TransactionOrderdata {
675 struct _TransactionElement *tes;
680 #define TYPE_BROKEN (1<<0)
681 #define TYPE_CON (1<<1)
683 #define TYPE_REQ_P (1<<2)
684 #define TYPE_PREREQ_P (1<<3)
686 #define TYPE_REQ (1<<4)
687 #define TYPE_PREREQ (1<<5)
689 #define TYPE_CYCLETAIL (1<<16)
690 #define TYPE_CYCLEHEAD (1<<17)
692 #define EDGEDATA_BLOCK 127
695 transaction_init(Transaction *trans, Pool *pool)
697 memset(trans, 0, sizeof(*trans));
702 transaction_free(Transaction *trans)
704 queue_free(&trans->steps);
705 queue_free(&trans->transaction_info);
706 trans->transaction_installed = sat_free(trans->transaction_installed);
707 map_free(&trans->transactsmap);
708 map_free(&trans->noobsmap);
709 if (trans->orderdata)
711 struct _TransactionOrderdata *od = trans->orderdata;
712 od->tes = sat_free(od->tes);
713 od->invedgedata = sat_free(od->invedgedata);
714 trans->orderdata = sat_free(trans->orderdata);
720 struct _TransactionElement *tes;
732 addteedge(struct orderdata *od, int from, int to, int type)
735 struct _TransactionElement *te;
740 /* printf("edge %d(%s) -> %d(%s) type %x\n", from, solvid2str(pool, od->tes[from].p), to, solvid2str(pool, od->tes[to].p), type); */
743 for (i = te->edges; od->edgedata[i]; i += 2)
744 if (od->edgedata[i] == to)
746 /* test of brokenness */
747 if (type == TYPE_BROKEN)
748 return od->edgedata[i] && (od->edgedata[i + 1] & TYPE_BROKEN) != 0 ? 1 : 0;
751 od->edgedata[i + 1] |= type;
754 if (i + 1 == od->nedgedata)
756 /* printf("tail add %d\n", i - te->edges); */
759 od->edgedata = sat_extend(od->edgedata, od->nedgedata, 3, sizeof(Id), EDGEDATA_BLOCK);
763 /* printf("extend %d\n", i - te->edges); */
764 od->edgedata = sat_extend(od->edgedata, od->nedgedata, 3 + (i - te->edges), sizeof(Id), EDGEDATA_BLOCK);
766 memcpy(od->edgedata + od->nedgedata, od->edgedata + te->edges, sizeof(Id) * (i - te->edges));
767 i = od->nedgedata + (i - te->edges);
768 te->edges = od->nedgedata;
770 od->edgedata[i] = to;
771 od->edgedata[i + 1] = type;
772 od->edgedata[i + 2] = 0; /* end marker */
773 od->nedgedata = i + 3;
778 addedge(struct orderdata *od, Id from, Id to, int type)
780 Transaction *trans = od->trans;
781 Pool *pool = trans->pool;
783 struct _TransactionElement *te;
786 // printf("addedge %d %d type %d\n", from, to, type);
787 s = pool->solvables + from;
788 if (s->repo == pool->installed && trans->transaction_installed[from - pool->installed->start])
790 /* obsolete, map to install */
791 if (trans->transaction_installed[from - pool->installed->start] > 0)
792 from = trans->transaction_installed[from - pool->installed->start];
799 queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
800 transaction_all_obs_pkgs(trans, from, &ti);
801 for (i = 0; i < ti.count; i++)
802 ret |= addedge(od, ti.elements[i], to, type);
807 s = pool->solvables + to;
808 if (s->repo == pool->installed && trans->transaction_installed[to - pool->installed->start])
810 /* obsolete, map to install */
811 if (trans->transaction_installed[to - pool->installed->start] > 0)
812 to = trans->transaction_installed[to - pool->installed->start];
819 queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
820 transaction_all_obs_pkgs(trans, to, &ti);
821 for (i = 0; i < ti.count; i++)
822 ret |= addedge(od, from, ti.elements[i], type);
828 /* map from/to to te numbers */
829 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
836 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
842 return addteedge(od, i, to, type);
847 havechoice(struct orderdata *od, Id p, Id q1, Id q2)
849 Transaction *trans = od->trans;
850 Pool *pool = trans->pool;
851 Id ti1buf[5], ti2buf[5];
855 /* both q1 and q2 are uninstalls. check if their TEs intersect */
856 /* common case: just one TE for both packages */
858 printf("havechoice %d %d %d\n", p, q1, q2);
860 if (trans->transaction_installed[q1 - pool->installed->start] == 0)
862 if (trans->transaction_installed[q2 - pool->installed->start] == 0)
864 if (trans->transaction_installed[q1 - pool->installed->start] == trans->transaction_installed[q2 - pool->installed->start])
866 if (trans->transaction_installed[q1 - pool->installed->start] > 0 && trans->transaction_installed[q2 - pool->installed->start] > 0)
868 queue_init_buffer(&ti1, ti1buf, sizeof(ti1buf)/sizeof(*ti1buf));
869 transaction_all_obs_pkgs(trans, q1, &ti1);
870 queue_init_buffer(&ti2, ti2buf, sizeof(ti2buf)/sizeof(*ti2buf));
871 transaction_all_obs_pkgs(trans, q2, &ti2);
872 for (i = 0; i < ti1.count; i++)
873 for (j = 0; j < ti2.count; j++)
874 if (ti1.elements[i] == ti2.elements[j])
876 /* found a common edge */
888 havescripts(Pool *pool, Id solvid)
890 Solvable *s = pool->solvables + solvid;
896 reqp = s->repo->idarraydata + s->requires;
897 while ((req = *reqp++) != 0)
899 if (req == SOLVABLE_PREREQMARKER)
906 dep = id2str(pool, req);
907 if (*dep == '/' && strcmp(dep, "/sbin/ldconfig") != 0)
915 addsolvableedges(struct orderdata *od, Solvable *s)
917 Transaction *trans = od->trans;
918 Pool *pool = trans->pool;
919 Id req, *reqp, con, *conp;
921 int i, j, pre, numins;
922 Repo *installed = pool->installed;
928 printf("addsolvableedges %s\n", solvable2str(pool, s));
930 p = s - pool->solvables;
934 reqp = s->repo->idarraydata + s->requires;
936 while ((req = *reqp++) != 0)
938 if (req == SOLVABLE_PREREQMARKER)
944 if (pre != TYPE_PREREQ && installed && s->repo == installed)
946 /* ignore normal requires if we're getting obsoleted */
947 if (trans->transaction_installed[p - pool->installed->start])
952 numins = 0; /* number of packages to be installed providing it */
953 provbyinst = 0; /* provided by kept package */
954 FOR_PROVIDES(p2, pp2, req)
956 s2 = pool->solvables + p2;
959 reqq.count = 0; /* self provides */
962 if (s2->repo == installed && !MAPTST(&trans->transactsmap, p2))
966 printf("IGNORE inst provides %s by %s\n", dep2str(pool, req), solvable2str(pool, s2));
967 reqq.count = 0; /* provided by package that stays installed */
973 if (s2->repo != installed && !MAPTST(&trans->transactsmap, p2))
974 continue; /* package stays uninstalled */
976 if (s->repo == installed)
978 /* s gets uninstalled */
979 queue_pushunique(&reqq, p2);
980 if (s2->repo != installed)
985 if (s2->repo == installed)
986 continue; /* s2 gets uninstalled */
987 queue_pushunique(&reqq, p2);
992 /* prune to harmless ->inst edges */
993 for (i = j = 0; i < reqq.count; i++)
994 if (pool->solvables[reqq.elements[i]].repo != installed)
995 reqq.elements[j++] = reqq.elements[i];
999 if (numins && reqq.count)
1001 if (s->repo == installed)
1003 for (i = 0; i < reqq.count; i++)
1005 if (pool->solvables[reqq.elements[i]].repo == installed)
1007 for (j = 0; j < reqq.count; j++)
1009 if (pool->solvables[reqq.elements[j]].repo != installed)
1011 if (trans->transaction_installed[reqq.elements[i] - pool->installed->start] == reqq.elements[j])
1012 continue; /* no self edge */
1014 printf("add interrreq uninst->inst edge (%s -> %s -> %s)\n", solvid2str(pool, reqq.elements[i]), dep2str(pool, req), solvid2str(pool, reqq.elements[j]));
1016 addedge(od, reqq.elements[i], reqq.elements[j], pre == TYPE_PREREQ ? TYPE_PREREQ_P : TYPE_REQ_P);
1022 /* no mixed types, remove all deps on uninstalls */
1023 for (i = j = 0; i < reqq.count; i++)
1024 if (pool->solvables[reqq.elements[i]].repo != installed)
1025 reqq.elements[j++] = reqq.elements[i];
1030 for (i = 0; i < reqq.count; i++)
1033 p2 = reqq.elements[i];
1034 if (pool->solvables[p2].repo != installed)
1036 /* all elements of reqq are installs, thus have different TEs */
1037 choice = reqq.count - 1;
1038 if (pool->solvables[p].repo != installed)
1041 printf("add inst->inst edge choice %d (%s -> %s -> %s)\n", choice, solvid2str(pool, p), dep2str(pool, req), solvid2str(pool, p2));
1043 addedge(od, p, p2, pre);
1048 printf("add uninst->inst edge choice %d (%s -> %s -> %s)\n", choice, solvid2str(pool, p), dep2str(pool, req), solvid2str(pool, p2));
1050 addedge(od, p, p2, pre == TYPE_PREREQ ? TYPE_PREREQ_P : TYPE_REQ_P);
1055 if (s->repo != installed)
1056 continue; /* no inst->uninst edges, please! */
1058 /* uninst -> uninst edge. Those make trouble. Only add if we must */
1059 if (trans->transaction_installed[p - installed->start] && !havescripts(pool, p))
1061 /* p is obsoleted by another package and has no scripts */
1062 /* we assume that the obsoletor is good enough to replace p */
1067 for (j = 0; j < reqq.count; j++)
1071 if (havechoice(od, p, reqq.elements[i], reqq.elements[j]))
1076 printf("add uninst->uninst edge choice %d (%s -> %s -> %s)\n", choice, solvid2str(pool, p), dep2str(pool, req), solvid2str(pool, p2));
1078 addedge(od, p2, p, pre == TYPE_PREREQ ? TYPE_PREREQ_P : TYPE_REQ_P);
1085 conp = s->repo->idarraydata + s->conflicts;
1086 while ((con = *conp++) != 0)
1088 FOR_PROVIDES(p2, pp2, con)
1092 s2 = pool->solvables + p2;
1095 if (s->repo == installed)
1097 if (s2->repo != installed && MAPTST(&trans->transactsmap, p2))
1099 /* deinstall p before installing p2 */
1100 addedge(od, p2, p, TYPE_CON);
1105 if (s2->repo == installed && MAPTST(&trans->transactsmap, p2))
1107 /* deinstall p2 before installing p */
1108 addedge(od, p, p2, TYPE_CON);
1119 /* break an edge in a cycle */
1121 breakcycle(struct orderdata *od, Id *cycle)
1123 Pool *pool = od->trans->pool;
1124 Id ddegmin, ddegmax, ddeg;
1126 struct _TransactionElement *te;
1129 ddegmin = ddegmax = 0;
1130 for (k = 0; cycle[k + 1]; k += 2)
1132 ddeg = od->edgedata[cycle[k + 1] + 1];
1135 if (!k || ddeg < ddegmin)
1141 if (ddeg == ddegmin)
1143 if (havescripts(pool, od->tes[cycle[l]].p) && !havescripts(pool, od->tes[cycle[k]].p))
1145 /* prefer k, as l comes from a package with contains scriptlets */
1150 /* same edge value, check for prereq */
1154 /* record brkoen cycle starting with the tail */
1155 queue_push(&od->cycles, od->cyclesdata.count); /* offset into data */
1156 queue_push(&od->cycles, k / 2); /* cycle elements */
1157 queue_push(&od->cycles, od->edgedata[cycle[l + 1] + 1]); /* broken edge */
1164 queue_push(&od->cyclesdata, cycle[k]);
1168 queue_push(&od->cyclesdata, 0); /* mark end */
1170 /* break that edge */
1171 od->edgedata[cycle[l + 1] + 1] |= TYPE_BROKEN;
1174 if (ddegmin < TYPE_REQ)
1178 /* cycle recorded, print it */
1179 if (ddegmin >= TYPE_REQ && (ddegmax & TYPE_PREREQ) != 0)
1180 POOL_DEBUG(SAT_DEBUG_STATS, "CRITICAL ");
1181 POOL_DEBUG(SAT_DEBUG_STATS, "cycle: --> ");
1182 for (k = 0; cycle[k + 1]; k += 2)
1184 te = od->tes + cycle[k];
1185 if ((od->edgedata[cycle[k + 1] + 1] & TYPE_BROKEN) != 0)
1186 POOL_DEBUG(SAT_DEBUG_STATS, "%s ##%x##> ", solvid2str(pool, te->p), od->edgedata[cycle[k + 1] + 1]);
1188 POOL_DEBUG(SAT_DEBUG_STATS, "%s --%x--> ", solvid2str(pool, te->p), od->edgedata[cycle[k + 1] + 1]);
1190 POOL_DEBUG(SAT_DEBUG_STATS, "\n");
1194 dump_tes(struct orderdata *od)
1196 Pool *pool = od->trans->pool;
1199 struct _TransactionElement *te, *te2;
1202 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
1204 Solvable *s = pool->solvables + te->p;
1205 POOL_DEBUG(SAT_WARN, "TE %4d: %c%s\n", i, s->repo == pool->installed ? '-' : '+', solvable2str(pool, s));
1206 if (s->repo != pool->installed)
1209 transaction_all_obs_pkgs(od->trans, te->p, &obsq);
1210 for (j = 0; j < obsq.count; j++)
1211 POOL_DEBUG(SAT_WARN, " -%s\n", solvid2str(pool, obsq.elements[j]));
1213 for (j = te->edges; od->edgedata[j]; j += 2)
1215 te2 = od->tes + od->edgedata[j];
1216 POOL_DEBUG(SAT_WARN, " --%x--> TE %4d: %s\n", od->edgedata[j + 1], od->edgedata[j], solvid2str(pool, te2->p));
1223 reachable(struct orderdata *od, Id i)
1225 struct _TransactionElement *te = od->tes + i;
1231 for (j = te->edges; (k = od->edgedata[j]) != 0; j += 2)
1233 if ((od->edgedata[j + 1] & TYPE_BROKEN) != 0)
1235 if (!od->tes[k].mark)
1237 if (od->tes[k].mark == 2)
1248 addcycleedges(struct orderdata *od, Id *cycle, Queue *todo)
1251 Transaction *trans = od->trans;
1252 Pool *pool = trans->pool;
1254 struct _TransactionElement *te;
1261 printf("addcycleedges\n");
1262 for (i = 0; (j = cycle[i]) != 0; i++)
1263 printf("cycle %s\n", solvid2str(pool, od->tes[j].p));
1266 /* first add all the tail cycle edges */
1268 /* see what we can reach from the cycle */
1270 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
1272 for (i = 0; (j = cycle[i]) != 0; i++)
1274 od->tes[j].mark = -1;
1275 queue_push(todo, j);
1279 i = queue_pop(todo);
1283 te->mark = te->mark < 0 ? 2 : 1;
1284 for (j = te->edges; (k = od->edgedata[j]) != 0; j += 2)
1286 if ((od->edgedata[j + 1] & TYPE_BROKEN) != 0)
1288 if (od->tes[k].mark > 0)
1289 continue; /* no need to visit again */
1290 queue_push(todo, k);
1293 /* now all cycle TEs are marked with 2, all TEs reachable
1294 * from the cycle are marked with 1 */
1296 od->tes[tail].mark = 1; /* no need to add edges */
1298 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
1301 continue; /* reachable from cycle */
1302 for (j = te->edges; (k = od->edgedata[j]) != 0; j += 2)
1304 if ((od->edgedata[j + 1] & TYPE_BROKEN) != 0)
1306 if (od->tes[k].mark != 2)
1308 /* We found an edge to the cycle. Add an extra edge to the tail */
1309 /* the TE was not reachable, so we're not creating a new cycle! */
1311 printf("adding TO TAIL cycle edge %d->%d %s->%s!\n", i, tail, solvid2str(pool, od->tes[i].p), solvid2str(pool, od->tes[tail].p));
1313 j -= te->edges; /* in case we move */
1314 addteedge(od, i, tail, TYPE_CYCLETAIL);
1316 break; /* one edge is enough */
1321 /* now add all head cycle edges */
1324 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
1327 for (i = 0; (j = cycle[i]) != 0; i++)
1330 od->tes[j].mark = 2;
1332 /* first the head to save some time */
1333 te = od->tes + head;
1334 for (j = te->edges; (k = od->edgedata[j]) != 0; j += 2)
1336 if ((od->edgedata[j + 1] & TYPE_BROKEN) != 0)
1338 if (!od->tes[k].mark)
1340 if (od->tes[k].mark == -1)
1341 od->tes[k].mark = -2; /* no need for another edge */
1343 for (i = 0; cycle[i] != 0; i++)
1345 if (cycle[i] == head)
1347 te = od->tes + cycle[i];
1348 for (j = te->edges; (k = od->edgedata[j]) != 0; j += 2)
1350 if ((od->edgedata[j + 1] & TYPE_BROKEN) != 0)
1352 /* see if we can reach a cycle TE from k */
1353 if (!od->tes[k].mark)
1355 if (od->tes[k].mark == -1)
1358 printf("adding FROM HEAD cycle edge %d->%d %s->%s [%s]!\n", head, k, solvid2str(pool, od->tes[head].p), solvid2str(pool, od->tes[k].p), solvid2str(pool, od->tes[cycle[i]].p));
1360 addteedge(od, head, k, TYPE_CYCLEHEAD);
1361 od->tes[k].mark = -2; /* no need to add that one again */
1369 transaction_order(Transaction *trans, int flags)
1371 Pool *pool = trans->pool;
1372 Queue *tr = &trans->steps;
1373 Repo *installed = pool->installed;
1376 int i, j, k, numte, numedge;
1377 struct orderdata od;
1378 struct _TransactionElement *te;
1379 Queue todo, obsq, samerepoq, uninstq;
1380 int cycstart, cycel;
1382 unsigned char *obsoleted;
1389 start = now = sat_timems(0);
1390 POOL_DEBUG(SAT_DEBUG_STATS, "ordering transaction\n");
1391 /* free old data if present */
1392 if (trans->orderdata)
1394 struct _TransactionOrderdata *od = trans->orderdata;
1395 od->tes = sat_free(od->tes);
1396 od->invedgedata = sat_free(od->invedgedata);
1397 trans->orderdata = sat_free(trans->orderdata);
1400 /* create a transaction element for every active component */
1402 for (i = 0; i < tr->count; i++)
1404 p = tr->elements[i];
1405 s = pool->solvables + p;
1406 if (installed && s->repo == installed && trans->transaction_installed[p - installed->start])
1410 POOL_DEBUG(SAT_DEBUG_STATS, "transaction elements: %d\n", numte);
1412 return; /* nothing to do... */
1414 numte++; /* leave first one zero */
1415 memset(&od, 0, sizeof(od));
1418 od.tes = sat_calloc(numte, sizeof(*od.tes));
1419 od.edgedata = sat_extend(0, 0, 1, sizeof(Id), EDGEDATA_BLOCK);
1422 queue_init(&od.cycles);
1424 /* initialize TEs */
1425 for (i = 0, te = od.tes + 1; i < tr->count; i++)
1427 p = tr->elements[i];
1428 s = pool->solvables + p;
1429 if (installed && s->repo == installed && trans->transaction_installed[p - installed->start])
1435 /* create dependency graph */
1436 for (i = 0; i < tr->count; i++)
1437 addsolvableedges(&od, pool->solvables + tr->elements[i]);
1441 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1442 for (j = te->edges; od.edgedata[j]; j += 2)
1444 POOL_DEBUG(SAT_DEBUG_STATS, "edges: %d, edge space: %d\n", numedge, od.nedgedata / 2);
1445 POOL_DEBUG(SAT_DEBUG_STATS, "edge creation took %d ms\n", sat_timems(now));
1451 now = sat_timems(0);
1452 /* kill all cycles */
1454 for (i = numte - 1; i > 0; i--)
1455 queue_push(&todo, i);
1459 i = queue_pop(&todo);
1460 /* printf("- look at TE %d\n", i); */
1464 od.tes[i].mark = 2; /* done with that one */
1469 continue; /* already finished before */
1472 int edgestovisit = 0;
1473 /* new node, visit edges */
1474 for (j = te->edges; (k = od.edgedata[j]) != 0; j += 2)
1476 if ((od.edgedata[j + 1] & TYPE_BROKEN) != 0)
1478 if (od.tes[k].mark == 2)
1479 continue; /* no need to visit again */
1480 if (!edgestovisit++)
1481 queue_push(&todo, -i); /* end of edges marker */
1482 queue_push(&todo, k);
1485 te->mark = 2; /* no edges, done with that one */
1487 te->mark = 1; /* under investigation */
1490 /* oh no, we found a cycle */
1491 /* find start of cycle node (<0) */
1492 for (j = todo.count - 1; j >= 0; j--)
1493 if (todo.elements[j] == -i)
1497 /* build te/edge chain */
1499 for (j = k; j < todo.count; j++)
1500 if (todo.elements[j] < 0)
1501 todo.elements[k++] = -todo.elements[j];
1502 cycel = k - cycstart;
1504 /* make room for edges, two extra element for cycle loop + terminating 0 */
1505 while (todo.count < cycstart + 2 * cycel + 2)
1506 queue_push(&todo, 0);
1507 cycle = todo.elements + cycstart;
1508 cycle[cycel] = i; /* close the loop */
1509 cycle[2 * cycel + 1] = 0; /* terminator */
1510 for (k = cycel; k > 0; k--)
1512 cycle[k * 2] = cycle[k];
1513 te = od.tes + cycle[k - 1];
1514 assert(te->mark == 1);
1515 te->mark = 0; /* reset investigation marker */
1516 /* printf("searching for edge from %d to %d\n", cycle[k - 1], cycle[k]); */
1517 for (j = te->edges; od.edgedata[j]; j += 2)
1518 if (od.edgedata[j] == cycle[k])
1520 assert(od.edgedata[j]);
1521 cycle[k * 2 - 1] = j;
1523 /* now cycle looks like this: */
1524 /* te1 edge te2 edge te3 ... teN edge te1 0 */
1525 breakcycle(&od, cycle);
1526 /* restart with start of cycle */
1527 todo.count = cycstart + 1;
1529 POOL_DEBUG(SAT_DEBUG_STATS, "cycles broken: %d\n", od.ncycles);
1530 POOL_DEBUG(SAT_DEBUG_STATS, "cycle breaking took %d ms\n", sat_timems(now));
1532 now = sat_timems(0);
1533 /* now go through all broken cycles and create cycle edges to help
1535 for (i = od.cycles.count - 3; i >= 0; i -= 3)
1537 if (od.cycles.elements[i + 2] >= TYPE_REQ)
1538 addcycleedges(&od, od.cyclesdata.elements + od.cycles.elements[i], &todo);
1540 for (i = od.cycles.count - 3; i >= 0; i -= 3)
1542 if (od.cycles.elements[i + 2] < TYPE_REQ)
1543 addcycleedges(&od, od.cyclesdata.elements + od.cycles.elements[i], &todo);
1545 POOL_DEBUG(SAT_DEBUG_STATS, "cycle edge creation took %d ms\n", sat_timems(now));
1547 /* all edges are finally set up and there are no cycles, now the easy part.
1548 * Create an ordered transaction */
1549 now = sat_timems(0);
1550 /* first invert all edges */
1551 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1552 te->mark = 1; /* term 0 */
1553 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1555 for (j = te->edges; od.edgedata[j]; j += 2)
1557 if ((od.edgedata[j + 1] & TYPE_BROKEN) != 0)
1559 od.tes[od.edgedata[j]].mark++;
1563 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1568 POOL_DEBUG(SAT_DEBUG_STATS, "invedge space: %d\n", j + 1);
1569 od.invedgedata = sat_calloc(j + 1, sizeof(Id));
1570 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1572 for (j = te->edges; od.edgedata[j]; j += 2)
1574 if ((od.edgedata[j + 1] & TYPE_BROKEN) != 0)
1576 od.invedgedata[--od.tes[od.edgedata[j]].mark] = i;
1579 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1580 te->edges = te->mark; /* edges now points into invedgedata */
1581 od.edgedata = sat_free(od.edgedata);
1583 /* now the final ordering */
1584 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1586 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1587 for (j = te->edges; od.invedgedata[j]; j++)
1588 od.tes[od.invedgedata[j]].mark++;
1590 queue_init(&samerepoq);
1591 queue_init(&uninstq);
1593 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1596 if (installed && pool->solvables[te->p].repo == installed)
1597 queue_push(&uninstq, i);
1599 queue_push(&todo, i);
1601 assert(todo.count > 0 || uninstq.count > 0);
1603 obsoleted = sat_calloc(installed->end - installed->start, 1);
1606 oldcount = tr->count;
1613 temedianr = sat_calloc(numte, sizeof(Id));
1614 for (i = 1; i < numte; i++)
1616 Solvable *s = pool->solvables + od.tes[i].p;
1617 if (installed && s->repo == installed)
1620 j = solvable_lookup_num(s, SOLVABLE_MEDIANR, 1);
1625 /* select an TE i */
1627 i = queue_shift(&uninstq);
1628 else if (samerepoq.count)
1629 i = queue_shift(&samerepoq);
1630 else if (todo.count)
1632 /* find next repo/media */
1633 for (j = 0; j < todo.count; j++)
1635 if (!j || temedianr[todo.elements[j]] < lastmedia)
1638 lastmedia = temedianr[todo.elements[j]];
1641 lastrepo = pool->solvables[od.tes[todo.elements[i]].p].repo;
1643 /* move all matching TEs to samerepoq */
1644 for (i = j = 0; j < todo.count; j++)
1646 int k = todo.elements[j];
1647 if (temedianr[k] == lastmedia && pool->solvables[od.tes[k].p].repo == lastrepo)
1648 queue_push(&samerepoq, k);
1650 todo.elements[i++] = k;
1654 assert(samerepoq.count);
1655 i = queue_shift(&samerepoq);
1661 queue_push(tr, te->p);
1663 printf("do %s [%d]\n", solvid2str(pool, te->p), temedianr[i]);
1665 s = pool->solvables + te->p;
1666 if (installed && s->repo != installed)
1669 transaction_all_obs_pkgs(trans, te->p, &obsq);
1670 for (j = 0; j < obsq.count; j++)
1672 p = obsq.elements[j];
1673 assert(p >= installed->start && p < installed->end);
1674 if (!obsoleted[p - installed->start])
1677 obsoleted[p - installed->start] = 1;
1681 for (j = te->edges; od.invedgedata[j]; j++)
1683 struct _TransactionElement *te2 = od.tes + od.invedgedata[j];
1684 assert(te2->mark > 0);
1685 if (--te2->mark == 0)
1687 Solvable *s = pool->solvables + te2->p;
1689 printf("free %s [%d]\n", solvid2str(pool, te2->p), temedianr[od.invedgedata[j]]);
1691 if (installed && s->repo == installed)
1692 queue_push(&uninstq, od.invedgedata[j]);
1693 else if (s->repo == lastrepo && temedianr[od.invedgedata[j]] == lastmedia)
1694 queue_push(&samerepoq, od.invedgedata[j]);
1696 queue_push(&todo, od.invedgedata[j]);
1700 sat_free(obsoleted);
1701 sat_free(temedianr);
1703 queue_free(&samerepoq);
1704 queue_free(&uninstq);
1706 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1707 assert(te->mark == 0);
1708 assert(tr->count == oldcount);
1709 POOL_DEBUG(SAT_DEBUG_STATS, "creating new transaction took %d ms\n", sat_timems(now));
1710 POOL_DEBUG(SAT_DEBUG_STATS, "transaction ordering took %d ms\n", sat_timems(start));
1712 if ((flags & SOLVER_TRANSACTION_KEEP_ORDERDATA) != 0)
1714 trans->orderdata = sat_calloc(1, sizeof(*trans->orderdata));
1715 trans->orderdata->tes = od.tes;
1716 trans->orderdata->ntes = numte;
1717 trans->orderdata->invedgedata = od.invedgedata;
1722 sat_free(od.invedgedata);
1728 transaction_order_add_choices(Transaction *trans, Id chosen, Queue *choices)
1731 struct _TransactionOrderdata *od = trans->orderdata;
1732 struct _TransactionElement *te;
1735 return choices->count;
1738 /* initialization step */
1739 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
1741 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
1743 for (j = te->edges; od->invedgedata[j]; j++)
1744 od->tes[od->invedgedata[j]].mark++;
1746 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
1748 queue_push(choices, te->p);
1749 return choices->count;
1751 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
1752 if (te->p == chosen)
1755 return choices->count;
1758 /* hey! out-of-order installation! */
1761 for (j = te->edges; od->invedgedata[j]; j++)
1763 te = od->tes + od->invedgedata[j];
1764 assert(te->mark > 0 || te->mark == -1);
1765 if (te->mark > 0 && --te->mark == 0)
1766 queue_push(choices, te->p);
1768 return choices->count;
1772 transaction_check_pkg(Transaction *trans, Id tepkg, Id pkg, Map *ins, Map *seen, int onlyprereq, Id noconfpkg, int depth)
1774 Pool *pool = trans->pool;
1779 if (MAPTST(seen, pkg))
1782 s = pool->solvables + pkg;
1784 printf("- %*s%c%s\n", depth * 2, "", s->repo == pool->installed ? '-' : '+', solvable2str(pool, s));
1790 reqp = s->repo->idarraydata + s->requires;
1791 while ((req = *reqp++) != 0)
1793 if (req == SOLVABLE_PREREQMARKER)
1798 if (onlyprereq && !inpre)
1800 if (!strncmp(id2str(pool, req), "rpmlib(", 7))
1803 /* first check kept packages, then freshly installed, then not yet uninstalled */
1804 FOR_PROVIDES(p, pp, req)
1806 if (!MAPTST(ins, p))
1808 if (MAPTST(&trans->transactsmap, p))
1811 transaction_check_pkg(trans, tepkg, p, ins, seen, 0, noconfpkg, depth + 1);
1815 FOR_PROVIDES(p, pp, req)
1817 if (!MAPTST(ins, p))
1819 if (pool->solvables[p].repo == pool->installed)
1822 transaction_check_pkg(trans, tepkg, p, ins, seen, 0, noconfpkg, depth + 1);
1827 FOR_PROVIDES(p, pp, req)
1829 if (!MAPTST(ins, p))
1832 transaction_check_pkg(trans, tepkg, p, ins, seen, 0, noconfpkg, depth + 1);
1837 POOL_DEBUG(SAT_WARN, " %c%s: nothing provides %s needed by %c%s\n", pool->solvables[tepkg].repo == pool->installed ? '-' : '+', solvid2str(pool, tepkg), dep2str(pool, req), s->repo == pool->installed ? '-' : '+', solvable2str(pool, s));
1844 transaction_check_order(Transaction *trans)
1846 Pool *pool = trans->pool;
1852 POOL_DEBUG(SAT_WARN, "\nchecking transaction order...\n");
1853 map_init(&ins, pool->nsolvables);
1854 map_init(&seen, pool->nsolvables);
1855 if (pool->installed)
1856 FOR_REPO_SOLVABLES(pool->installed, p, s)
1859 for (i = 0; i < trans->steps.count; i++)
1861 p = trans->steps.elements[i];
1862 s = pool->solvables + p;
1863 if (s->repo != pool->installed)
1865 if (s->repo != pool->installed)
1867 if (havescripts(pool, p))
1870 transaction_check_pkg(trans, p, p, &ins, &seen, 1, lastins, 0);
1872 if (s->repo == pool->installed)
1877 POOL_DEBUG(SAT_WARN, "transaction order check done.\n");