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 solver_transaction_all_pkgs(Solver *solv, Id p, Queue *pkgs)
63 Pool *pool = solv->pool;
64 Solvable *s = pool->solvables + p;
65 Queue *ti = &solv->transaction_info;
70 if (p <= 0 || !s->repo)
72 if (s->repo == solv->installed)
74 q = solv->transaction_installed[p - solv->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 solver_transaction_pkg(Solver *solv, Id p)
112 Pool *pool = solv->pool;
113 Solvable *s = pool->solvables + p;
117 if (p <= 0 || !s->repo)
119 if (s->repo == solv->installed)
121 p = solv->transaction_installed[p - solv->installed->start];
122 return p < 0 ? -p : p;
124 queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
125 solver_transaction_all_pkgs(solv, p, &ti);
126 p = ti.count ? ti.elements[0] : 0;
131 /* type filtering, needed if either not all packages are shown
132 * or replaces are not shown, as otherwise parts of the
133 * transaction might not be shown to the user */
136 solver_transaction_filter(Solver *solv, Id type, Id p, int flags)
138 Pool *pool = solv->pool;
139 Solvable *s = pool->solvables + p;
144 if (type == SOLVER_TRANSACTION_ERASE || type == SOLVER_TRANSACTION_INSTALL || type == SOLVER_TRANSACTION_MULTIINSTALL)
147 if (s->repo == pool->installed && (flags & SOLVER_TRANSACTION_SHOW_ACTIVE) == 0)
150 if ((flags & SOLVER_TRANSACTION_SHOW_REPLACES) == 0 && type == SOLVER_TRANSACTION_REPLACED)
151 type = SOLVER_TRANSACTION_ERASE;
154 if (s->repo != pool->installed && (flags & SOLVER_TRANSACTION_SHOW_ACTIVE) != 0)
156 if ((flags & SOLVER_TRANSACTION_SHOW_REPLACES) == 0 && type == SOLVER_TRANSACTION_REPLACE)
157 type = SOLVER_TRANSACTION_INSTALL;
161 /* most of the time there's only one reference, so check it first */
162 q = solver_transaction_pkg(solv, p);
163 if ((flags & SOLVER_TRANSACTION_SHOW_REPLACES) == 0)
165 Solvable *sq = pool->solvables + q;
166 if (sq->name != s->name)
168 if (s->repo == pool->installed)
169 return SOLVER_TRANSACTION_ERASE;
170 else if (type == SOLVER_TRANSACTION_MULTIREINSTALL)
171 return SOLVER_TRANSACTION_MULTIINSTALL;
173 return SOLVER_TRANSACTION_INSTALL;
176 if (solver_transaction_pkg(solv, q) == p)
179 /* too bad, a miss. check em all */
182 solver_transaction_all_pkgs(solv, p, &oq);
183 for (i = 0; i < oq.count; i++)
186 if ((flags & SOLVER_TRANSACTION_SHOW_REPLACES) == 0)
188 Solvable *sq = pool->solvables + q;
189 if (sq->name != s->name)
192 /* check if we are referenced? */
193 if ((flags & SOLVER_TRANSACTION_SHOW_ALL) != 0)
195 solver_transaction_all_pkgs(solv, q, &rq);
196 for (j = 0; j < rq.count; j++)
197 if (rq.elements[j] == p)
205 else if (solver_transaction_pkg(solv, q) == p)
216 if (s->repo == pool->installed)
217 type = SOLVER_TRANSACTION_ERASE;
218 else if (type == SOLVER_TRANSACTION_MULTIREINSTALL)
219 type = SOLVER_TRANSACTION_MULTIINSTALL;
221 type = SOLVER_TRANSACTION_INSTALL;
227 create_transaction_info(Solver *solv)
229 Pool *pool = solv->pool;
230 Queue *ti = &solv->transaction_info;
231 Repo *installed = solv->installed;
238 return; /* no info needed */
239 for (i = 0; i < solv->decisionq.count; i++)
241 p = solv->decisionq.elements[i];
242 if (p <= 0 || p == SYSTEMSOLVABLE)
244 s = pool->solvables + p;
245 if (s->repo == installed)
247 noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p);
248 FOR_PROVIDES(p2, pp2, s->name)
250 if (solv->decisionmap[p2] > 0)
252 s2 = pool->solvables + p2;
253 if (s2->repo != installed)
255 if (noobs && (s->name != s2->name || s->evr != s2->evr || s->arch != s2->arch))
257 if (!solv->implicitobsoleteusesprovides && s->name != s2->name)
262 if (s->obsoletes && !noobs)
264 Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
265 while ((obs = *obsp++) != 0)
267 FOR_PROVIDES(p2, pp2, obs)
269 s2 = pool->solvables + p2;
270 if (s2->repo != installed)
272 if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p2, obs))
280 sat_sort(ti->elements, ti->count / 2, 2 * sizeof(Id), obsq_sortcmp, pool);
282 for (i = j = 0; i < ti->count; i += 2)
284 if (j && ti->elements[i] == ti->elements[j - 2] && ti->elements[i + 1] == ti->elements[j - 1])
286 ti->elements[j++] = ti->elements[i];
287 ti->elements[j++] = ti->elements[i + 1];
291 /* create transaction_installed helper */
292 solv->transaction_installed = sat_calloc(installed->end - installed->start, sizeof(Id));
293 for (i = 0; i < ti->count; i += 2)
295 j = ti->elements[i + 1] - installed->start;
296 if (!solv->transaction_installed[j])
297 solv->transaction_installed[j] = ti->elements[i];
300 /* more than one package obsoletes us. compare */
302 if (solv->transaction_installed[j] > 0)
303 solv->transaction_installed[j] = -solv->transaction_installed[j];
304 q[0] = q[2] = ti->elements[i + 1];
305 q[1] = ti->elements[i];
306 q[3] = -solv->transaction_installed[j];
307 if (obsq_sortcmp(q, q + 2, pool) < 0)
308 solv->transaction_installed[j] = -ti->elements[i];
315 solver_create_transaction(Solver *solv)
317 Pool *pool = solv->pool;
318 Repo *installed = solv->installed;
323 queue_empty(&solv->transaction);
324 create_transaction_info(solv);
328 FOR_REPO_SOLVABLES(installed, p, s)
330 if (solv->decisionmap[p] > 0)
332 p2 = solver_transaction_pkg(solv, p);
334 queue_push(&solv->transaction, SOLVER_TRANSACTION_ERASE);
337 s2 = pool->solvables + p2;
338 if (s->name == s2->name)
340 if (s->evr == s2->evr && solvable_identical(s, s2))
341 queue_push(&solv->transaction, SOLVER_TRANSACTION_REINSTALLED);
344 r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
346 queue_push(&solv->transaction, SOLVER_TRANSACTION_UPGRADED);
348 queue_push(&solv->transaction, SOLVER_TRANSACTION_DOWNGRADED);
350 queue_push(&solv->transaction, SOLVER_TRANSACTION_CHANGED);
354 queue_push(&solv->transaction, SOLVER_TRANSACTION_REPLACED);
356 queue_push(&solv->transaction, p);
359 for (i = 0; i < solv->decisionq.count; i++)
361 p = solv->decisionq.elements[i];
362 if (p < 0 || p == SYSTEMSOLVABLE)
364 s = pool->solvables + p;
365 if (solv->installed && s->repo == solv->installed)
367 noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p);
368 p2 = solver_transaction_pkg(solv, p);
370 queue_push(&solv->transaction, p2 ? SOLVER_TRANSACTION_MULTIREINSTALL : SOLVER_TRANSACTION_MULTIINSTALL);
372 queue_push(&solv->transaction, SOLVER_TRANSACTION_INSTALL);
375 s2 = pool->solvables + p2;
376 if (s->name == s2->name)
378 if (s->evr == s2->evr && solvable_identical(s, s2))
379 queue_push(&solv->transaction, SOLVER_TRANSACTION_REINSTALL);
382 r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
384 queue_push(&solv->transaction, SOLVER_TRANSACTION_UPGRADE);
386 queue_push(&solv->transaction, SOLVER_TRANSACTION_DOWNGRADE);
388 queue_push(&solv->transaction, SOLVER_TRANSACTION_CHANGE);
392 queue_push(&solv->transaction, SOLVER_TRANSACTION_REPLACE);
394 queue_push(&solv->transaction, p);
398 #define TYPE_BROKEN (1<<0)
399 #define TYPE_CON (1<<1)
401 #define TYPE_REQ_P (1<<2)
402 #define TYPE_PREREQ_P (1<<3)
404 #define TYPE_REQ (1<<4)
405 #define TYPE_PREREQ (1<<5)
407 #define EDGEDATA_BLOCK 127
416 Id ddeg; /* unused */
430 addedge(struct orderdata *od, Id from, Id to, int type)
432 Solver *solv = od->solv;
433 Pool *pool = solv->pool;
438 // printf("addedge %d %d type %d\n", from, to, type);
439 s = pool->solvables + from;
440 if (s->repo == solv->installed && solv->transaction_installed[from - solv->installed->start])
442 /* passive, map to active */
443 if (solv->transaction_installed[from - solv->installed->start] > 0)
444 from = solv->transaction_installed[from - solv->installed->start];
451 queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
452 solver_transaction_all_pkgs(solv, from, &ti);
453 for (i = 0; i < ti.count; i++)
454 ret |= addedge(od, ti.elements[i], to, type);
459 s = pool->solvables + to;
460 if (s->repo == solv->installed && solv->transaction_installed[to - solv->installed->start])
462 /* passive, map to active */
463 if (solv->transaction_installed[to - solv->installed->start] > 0)
464 to = solv->transaction_installed[to - solv->installed->start];
471 queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
472 solver_transaction_all_pkgs(solv, to, &ti);
473 for (i = 0; i < ti.count; i++)
474 ret |= addedge(od, from, ti.elements[i], type);
480 /* map target to te num */
481 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
488 for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
495 return 0; /* no edges to ourselfes */
497 /* printf("edge %d(%s) -> %d(%s) type %x\n", i, solvid2str(pool, od->tes[i].p), to, solvid2str(pool, od->tes[to].p), type); */
499 for (i = te->edges; od->edgedata[i]; i += 2)
500 if (od->edgedata[i] == to)
502 /* test of brokenness */
503 if (type == TYPE_BROKEN)
504 return od->edgedata[i] && (od->edgedata[i + 1] & TYPE_BROKEN) != 0 ? 1 : 0;
507 od->edgedata[i + 1] |= type;
510 if (i + 1 == od->nedgedata)
512 /* printf("tail add %d\n", i - te->edges); */
515 od->edgedata = sat_extend(od->edgedata, od->nedgedata, 3, sizeof(Id), EDGEDATA_BLOCK);
519 /* printf("extend %d\n", i - te->edges); */
520 od->edgedata = sat_extend(od->edgedata, od->nedgedata, 3 + (i - te->edges), sizeof(Id), EDGEDATA_BLOCK);
522 memcpy(od->edgedata + od->nedgedata, od->edgedata + te->edges, sizeof(Id) * (i - te->edges));
523 i = od->nedgedata + (i - te->edges);
524 te->edges = od->nedgedata;
526 od->edgedata[i] = to;
527 od->edgedata[i + 1] = type;
528 od->edgedata[i + 2] = 0;
529 od->nedgedata = i + 3;
536 havechoice(struct orderdata *od, Id p, Id q1, Id q2)
538 Solver *solv = od->solv;
539 Id ti1buf[5], ti2buf[5];
543 /* both q1 and q2 are uninstalls. check if their TEs intersect */
544 /* common case: just one TE for both packages */
545 printf("havechoice %d %d %d\n", p, q1, q2);
546 if (solv->transaction_installed[q1 - solv->installed->start] == 0)
548 if (solv->transaction_installed[q2 - solv->installed->start] == 0)
550 if (solv->transaction_installed[q1 - solv->installed->start] == solv->transaction_installed[q2 - solv->installed->start])
552 if (solv->transaction_installed[q1 - solv->installed->start] > 0 && solv->transaction_installed[q2 - solv->installed->start] > 0)
554 queue_init_buffer(&ti1, ti1buf, sizeof(ti1buf)/sizeof(*ti1buf));
555 solver_transaction_all_pkgs(solv, q1, &ti1);
556 queue_init_buffer(&ti2, ti2buf, sizeof(ti2buf)/sizeof(*ti2buf));
557 solver_transaction_all_pkgs(solv, q2, &ti2);
558 for (i = 0; i < ti1.count; i++)
559 for (j = 0; j < ti2.count; j++)
560 if (ti1.elements[i] == ti2.elements[j])
562 /* found a common edge */
573 addsolvableedges(struct orderdata *od, Solvable *s)
575 Solver *solv = od->solv;
576 Pool *pool = solv->pool;
577 Id req, *reqp, con, *conp;
579 int i, j, pre, numins;
580 Repo *installed = solv->installed;
584 p = s - pool->solvables;
588 reqp = s->repo->idarraydata + s->requires;
590 while ((req = *reqp++) != 0)
592 if (req == SOLVABLE_PREREQMARKER)
598 numins = 0; /* number of packages to be installed providing it */
599 FOR_PROVIDES(p2, pp2, req)
601 s2 = pool->solvables + p2;
604 reqq.count = 0; /* self provides */
607 if (s2->repo == installed && solv->decisionmap[p2] > 0)
609 reqq.count = 0; /* provided by package that stays installed */
612 if (s2->repo != installed && solv->decisionmap[p2] <= 0)
613 continue; /* package stays uninstalled */
615 if (s->repo == installed)
617 /* s gets uninstalled */
618 queue_pushunique(&reqq, p2);
619 if (s2->repo != installed)
624 if (s2->repo == installed)
625 continue; /* s2 gets uninstalled */
626 queue_pushunique(&reqq, p2);
627 /* EDGE s(A) -> s2(A) */
630 if (numins && reqq.count)
632 /* no mixed types, remove all deps on uninstalls */
633 for (i = j = 0; i < reqq.count; i++)
634 if (pool->solvables[reqq.elements[i]].repo != installed)
635 reqq.elements[j++] = reqq.elements[i];
640 for (i = 0; i < reqq.count; i++)
643 p2 = reqq.elements[i];
644 if (pool->solvables[p2].repo != installed)
646 /* all elements of reqq are installs, thus have different TEs */
647 choice = reqq.count - 1;
648 if (pool->solvables[p].repo != installed)
651 printf("add inst edge choice %d (%s -> %s -> %s)\n", choice, solvid2str(pool, p), dep2str(pool, req), solvid2str(pool, p2));
653 addedge(od, p, p2, pre);
658 printf("add uninst->inst edge choice %d (%s -> %s -> %s)\n", choice, solvid2str(pool, p), dep2str(pool, req), solvid2str(pool, p2));
660 addedge(od, p, p2, pre == TYPE_PREREQ ? TYPE_PREREQ_P : TYPE_REQ_P);
667 for (j = 0; j < reqq.count; j++)
671 if (havechoice(od, p, reqq.elements[i], reqq.elements[j]))
676 printf("add uninst->uninst edge choice %d (%s -> %s -> %s)\n", choice, solvid2str(pool, p), dep2str(pool, req), solvid2str(pool, p2));
678 addedge(od, p2, p, pre == TYPE_PREREQ ? TYPE_PREREQ_P : TYPE_REQ_P);
685 conp = s->repo->idarraydata + s->conflicts;
686 while ((con = *conp++) != 0)
688 FOR_PROVIDES(p2, pp2, con)
692 s2 = pool->solvables + p2;
695 if (s->repo == installed)
697 if (s2->repo != installed && solv->decisionmap[p2] >= 0)
699 /* deinstall p before installing p2 */
700 addedge(od, p2, p, TYPE_CON);
705 if (s2->repo == installed && solv->decisionmap[p2] < 0)
707 /* deinstall p2 before installing p */
708 addedge(od, p, p2, TYPE_CON);
719 haveprereq(Pool *pool, Id solvid)
721 Solvable *s = pool->solvables + solvid;
726 reqp = s->repo->idarraydata + s->requires;
727 while ((req = *reqp++) != 0)
729 if (req == SOLVABLE_PREREQMARKER)
734 if (inpre && strncmp(id2str(pool, req), "rpmlib(", 7) != 0)
742 breakcycle(struct orderdata *od, Id *cycle)
744 Pool *pool = od->solv->pool;
745 Id ddegmin, ddegmax, ddeg;
750 ddegmin = ddegmax = 0;
751 for (k = 0; cycle[k + 1]; k += 2)
753 MAPSET(&od->cycletes, cycle[k]); /* this te is involved in a cycle */
754 ddeg = od->edgedata[cycle[k + 1] + 1];
757 if (!k || ddeg < ddegmin)
765 if (haveprereq(pool, od->tes[cycle[l]].p) && !haveprereq(pool, od->tes[cycle[k]].p))
767 /* prefer k, as l comes from a package with contains scriptlets */
772 /* same edge value, check for prereq */
776 od->edgedata[cycle[l + 1] + 1] |= TYPE_BROKEN;
779 if (ddegmin < TYPE_REQ)
784 /* cycle recorded, print it */
785 if ((ddegmax & TYPE_PREREQ) != 0)
787 printf("cycle: --> ");
788 for (k = 0; cycle[k + 1]; k += 2)
790 te = od->tes + cycle[k];
791 if ((od->edgedata[cycle[k + 1] + 1] & TYPE_BROKEN) != 0)
792 printf("%s ##%x##> ", solvid2str(pool, te->p), od->edgedata[cycle[k + 1] + 1]);
794 printf("%s --%x--> ", solvid2str(pool, te->p), od->edgedata[cycle[k + 1] + 1]);
800 solver_order_transaction(Solver *solv)
802 Pool *pool = solv->pool;
803 Queue *tr = &solv->transaction;
804 Repo *installed = solv->installed;
807 int i, j, k, numte, numedge;
811 int cycstart, cycel, broken;
812 Id *cycle, *obstypes;
816 POOL_DEBUG(SAT_DEBUG_STATS, "ordering transaction\n");
818 /* create a transaction element for every active component */
820 for (i = 0; i < tr->count; i += 2)
822 p = tr->elements[i + 1];
823 s = pool->solvables + p;
824 if (s->repo != installed || !solv->transaction_installed[p - solv->installed->start])
828 return; /* nothing to do... */
830 POOL_DEBUG(SAT_DEBUG_STATS, "transaction elements: %d\n", numte);
831 numte++; /* leave first one zero */
832 memset(&od, 0, sizeof(od));
835 od.tes = sat_calloc(numte, sizeof(*od.tes));
836 od.edgedata = sat_extend(0, 0, 1, sizeof(Id), EDGEDATA_BLOCK);
839 map_init(&od.cycletes, numte);
841 for (i = 0, te = od.tes + 1; i < tr->count; i += 2)
843 p = tr->elements[i + 1];
844 s = pool->solvables + p;
845 if (s->repo == installed && solv->transaction_installed[p - solv->installed->start])
848 te->type = tr->elements[i];
849 te->medianr = solvable_lookup_num(s, SOLVABLE_MEDIANR, 0);
853 /* create dependency graph */
854 for (i = 0; i < tr->count; i += 2)
856 type = tr->elements[i];
857 p = tr->elements[i + 1];
858 addsolvableedges(&od, pool->solvables + p);
863 for (i = 1, te = od.tes + i; i < numte; i++, te++)
864 for (j = te->edges; od.edgedata[j]; j += 2)
866 POOL_DEBUG(SAT_DEBUG_STATS, "edges: %d, edge space: %d\n", numedge, od.nedgedata / 2);
868 /* kill all cycles */
872 for (i = numte - 1; i > 0; i--)
873 queue_push(&todo, i);
877 i = queue_pop(&todo);
878 /* printf("- look at TE %d\n", i); */
882 od.tes[i].mark = 2; /* done with that one */
887 continue; /* already finished before */
890 int edgestovisit = 0;
891 /* new node, visit edges */
892 for (j = te->edges; (k = od.edgedata[j]) != 0; j += 2)
894 if ((od.edgedata[j + 1] & TYPE_BROKEN) != 0)
896 if (od.tes[k].mark == 2)
897 continue; /* no need to visit again */
899 queue_push(&todo, -i); /* end of edges marker */
900 queue_push(&todo, k);
903 te->mark = 2; /* no edges, done with that one */
905 te->mark = 1; /* under investigation */
908 /* oh no, we found a cycle */
909 /* find start of cycle node (<0) */
910 for (j = todo.count - 1; j >= 0; j--)
911 if (todo.elements[j] == -i)
915 /* build te/edge chain */
917 for (j = k; j < todo.count; j++)
918 if (todo.elements[j] < 0)
919 todo.elements[k++] = -todo.elements[j];
920 cycel = k - cycstart;
922 /* make room for edges, two extra element for cycle loop + terminating 0 */
923 while (todo.count < cycstart + 2 * cycel + 2)
924 queue_push(&todo, 0);
925 cycle = todo.elements + cycstart;
926 cycle[cycel] = i; /* close the loop */
927 cycle[2 * cycel + 1] = 0; /* terminator */
928 for (k = cycel; k > 0; k--)
930 cycle[k * 2] = cycle[k];
931 te = od.tes + cycle[k - 1];
933 te->mark = 0; /* reset investigation marker */
934 /* printf("searching for edge from %d to %d\n", cycle[k - 1], cycle[k]); */
935 for (j = te->edges; od.edgedata[j]; j += 2)
936 if (od.edgedata[j] == cycle[k])
938 assert(od.edgedata[j]);
939 cycle[k * 2 - 1] = j;
941 /* now cycle looks like this: */
942 /* te1 edge te2 edge te3 ... teN edge te1 0 */
943 breakcycle(&od, cycle);
945 /* restart with start of cycle */
946 todo.count = cycstart + 1;
948 POOL_DEBUG(SAT_DEBUG_STATS, "cycles broken: %d\n", broken);
950 /* invert all edges */
951 for (i = 1, te = od.tes + i; i < numte; i++, te++)
953 te->invedges = 1; /* term 0 */
954 te->mark = 0; /* backref count */
957 for (i = 1, te = od.tes + i; i < numte; i++, te++)
959 for (j = te->edges; od.edgedata[j]; j += 2)
961 if ((od.edgedata[j + 1] & TYPE_BROKEN) != 0)
963 struct transel *te2 = od.tes + od.edgedata[j];
968 for (i = 1, te = od.tes + i; i < numte; i++, te++)
973 POOL_DEBUG(SAT_DEBUG_STATS, "invedge space: %d\n", j + 1);
974 od.invedgedata = sat_calloc(j + 1, sizeof(Id));
975 for (i = 1, te = od.tes + i; i < numte; i++, te++)
977 for (j = te->edges; od.edgedata[j]; j += 2)
979 if ((od.edgedata[j + 1] & TYPE_BROKEN) != 0)
981 struct transel *te2 = od.tes + od.edgedata[j];
982 od.invedgedata[--te2->invedges] = i;
986 /* now the final ordering */
987 for (i = 1, te = od.tes + i; i < numte; i++, te++)
989 queue_push(&todo, i);
990 assert(todo.count > 0);
993 obstypes = sat_calloc(installed->end - installed->start, sizeof(Id));
994 for (i = 0; i < tr->count; i += 2)
996 p = tr->elements[i + 1];
997 s = pool->solvables + p;
998 if (s->repo == installed && solv->transaction_installed[p - installed->start])
999 obstypes[p - installed->start] = tr->elements[i];
1004 oldcount = tr->count;
1014 for (i = 0; i < todo.count; i++)
1016 j = todo.elements[i];
1017 if (pool->solvables[od.tes[j].p].repo == installed)
1021 if (i == todo.count)
1023 for (i = 0; i < todo.count; i++)
1025 j = todo.elements[i];
1026 if (MAPTST(&od.cycletes, j))
1030 if (i == todo.count)
1032 te = od.tes + todo.elements[i];
1033 queue_push(tr, te->type);
1034 queue_push(tr, te->p);
1035 s = pool->solvables + te->p;
1036 if (installed && s->repo != installed)
1039 solver_transaction_all_pkgs(solv, te->p, &obsq);
1040 for (j = 0; j < obsq.count; j++)
1042 p = obsq.elements[j];
1043 assert(p >= installed->start && p < installed->end);
1044 if (obstypes[p - installed->start])
1046 queue_push(tr, obstypes[p - installed->start]);
1048 obstypes[p - installed->start] = 0;
1052 if (i < todo.count - 1)
1053 memmove(todo.elements + i, todo.elements + i + 1, (todo.count - 1 - i) * sizeof(Id));
1055 for (j = te->invedges; od.invedgedata[j]; j++)
1057 struct transel *te2 = od.tes + od.invedgedata[j];
1058 assert(te2->mark > 0);
1059 if (--te2->mark == 0)
1061 queue_push(&todo, od.invedgedata[j]);
1067 for (i = 1, te = od.tes + i; i < numte; i++, te++)
1068 assert(te->mark == 0);
1069 assert(tr->count == oldcount);
1070 POOL_DEBUG(SAT_DEBUG_STATS, "transaction ordering took %d ms\n", sat_timems(now));