Mailinglist Archive: zypp-commit (171 mails)

< Previous Next >
[zypp-commit] <sat-solver> master : - move some flags describing the rpm from solver to pool
  • From: Michael Schroeder <mls@xxxxxxx>
  • Date: Thu, 4 Jun 2009 11:42:08 +0200
  • Message-id: <E1MC9VN-0008AE-9I@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit e6b243e99812cc58cea001d9120d76fb382e27d8
Author: Michael Schroeder <mls@xxxxxxx>
Date: Thu Jun 4 11:42:08 2009 +0200

- move some flags describing the rpm from solver to pool
- change prune_to_best_version to just need a pool pointer
- create a new type containing transaction data
- change transaction code to work with a pool, not a solver
- add solver_calculate_noobsmap() helper function that calculates
the noobsoletes map from a solver job
---
applayer/xsolvable.c | 4 +-
bindings/pool.i | 107 +++++++++
bindings/solver.i | 107 ---------
src/bitmap.c | 2 +-
src/policy.c | 28 ++--
src/policy.h | 3 +-
src/pool.h | 7 +-
src/rules.c | 12 +-
src/solver.c | 45 +++--
src/solver.h | 10 +-
src/solverdebug.c | 16 +-
src/transaction.c | 226 +++++++++++---------
src/transaction.h | 25 ++-
.../install-zypper-force-test.solution | 4 +-
.../install-zypper-noforce-test.solution | 4 +-
tests/solver/deptestomatic.c | 26 +--
16 files changed, 338 insertions(+), 288 deletions(-)

diff --git a/applayer/xsolvable.c b/applayer/xsolvable.c
index be77b17..eedb12e 100644
--- a/applayer/xsolvable.c
+++ b/applayer/xsolvable.c
@@ -152,7 +152,6 @@ xsolvable_find( Pool *pool, char *name, const Repo *repo )
Queue plist;
int i, end;
Solvable *s;
- Solver *solver = solver_create(pool); /* XXX: who sets those flags? */

id = str2id( pool, name, 1 );
queue_init( &plist);
@@ -169,8 +168,7 @@ xsolvable_find( Pool *pool, char *name, const Repo *repo )
}

prune_to_best_arch(pool, &plist);
- prune_to_best_version(solver, &plist);
- solver_free(solver);
+ prune_to_best_version(pool, &plist);
if (plist.count == 0) {
return NULL;
}
diff --git a/bindings/pool.i b/bindings/pool.i
index dbf1121..85a8caf 100644
--- a/bindings/pool.i
+++ b/bindings/pool.i
@@ -210,6 +210,113 @@ typedef struct _Pool {} Pool;
void set_promoteepoch( int b )
{ $self->promoteepoch = b; }

+#if defined(SWIGRUBY)
+ %typemap(out) int no_virtual_conflicts
+ "$result = $1 ? Qtrue : Qfalse;";
+#endif
+ /*
+ * Allow virtual conflicts
+ *
+ * call-seq:
+ * pool.no_virtual_conflicts -> bool
+ *
+ */
+ int no_virtual_conflicts()
+ { return $self->novirtualconflicts; }
+
+#if defined(SWIGRUBY)
+ %rename( "no_virtual_conflicts=" ) set_no_virtual_conflicts( int bflag );
+#endif
+ /*
+ * call-seq:
+ * pool.no_virtual_conflicts = true
+ *
+ */
+ void set_no_virtual_conflicts( int bflag )
+ { $self->novirtualconflicts = bflag; }
+
+#if defined(SWIGRUBY)
+ %typemap(out) int allow_self_conflicts
+ "$result = $1 ? Qtrue : Qfalse;";
+#endif
+ /*
+ * Allow self conflicts
+ *
+ * If a package can conflict with itself
+ *
+ * call-seq:
+ * pool.allow_self_conflicts -> bool
+ *
+ */
+ int allow_self_conflicts()
+ { return $self->allowselfconflicts; }
+
+#if defined(SWIGRUBY)
+ %rename( "allow_self_conflicts=" ) set_allow_self_conflicts( int bflag );
+#endif
+ /*
+ * call-seq:
+ * pool.allow_self_conflicts = true
+ *
+ */
+ void set_allow_self_conflicts( int bflag )
+ { $self->allowselfconflicts = bflag; }
+
+#if defined(SWIGRUBY)
+ %typemap(out) int obsolete_uses_provides
+ "$result = $1 ? Qtrue : Qfalse;";
+#endif
+ /*
+ * Obsolete uses provides
+ *
+ * Obsolete dependencies usually match on package names only.
+ * Setting this flag will make obsoletes also match a provides.
+ *
+ * call-seq:
+ * pool.obsolete_uses_provides -> bool
+ *
+ */
+ int obsolete_uses_provides()
+ { return $self->obsoleteusesprovides; }
+
+#if defined(SWIGRUBY)
+ %rename( "obsolete_uses_provides=" ) set_obsolete_uses_provides( int bflag );
+#endif
+ /*
+ * Obsolete uses provides
+ *
+ * call-seq:
+ * pool.obsolete_uses_provides = true
+ *
+ */
+ void set_obsolete_uses_provides( int bflag )
+ { $self->obsoleteusesprovides= bflag; }
+
+#if defined(SWIGRUBY)
+ %typemap(out) int implicit_obsolete_uses_provides
+ "$result = $1 ? Qtrue : Qfalse;";
+#endif
+ /*
+ * Implicit obsolete uses provides
+ *
+ * call-seq:
+ * pool.implicit_obsolete_uses_provides -> bool
+ *
+ */
+ int implicit_obsolete_uses_provides()
+ { return $self->implicitobsoleteusesprovides; }
+
+#if defined(SWIGRUBY)
+ %rename( "implicit_obsolete_uses_provides=" )
set_implicit_obsolete_uses_provides( int bflag );
+#endif
+ /*
+ * call-seq:
+ * pool.implicit_obsolete_uses_provides = true
+ *
+ */
+ void set_implicit_obsolete_uses_provides( int bflag )
+ { $self->implicitobsoleteusesprovides= bflag; }
+
/*
* Set the pool to an _unprepared_ status.
*
diff --git a/bindings/solver.i b/bindings/solver.i
index 498c8e3..8c61840 100644
--- a/bindings/solver.i
+++ b/bindings/solver.i
@@ -304,113 +304,6 @@ typedef struct solver {} Solver;
{ $self->updatesystem = bflag; }

#if defined(SWIGRUBY)
- %typemap(out) int allow_virtual_conflicts
- "$result = $1 ? Qtrue : Qfalse;";
-#endif
- /*
- * Allow virtual conflicts
- *
- * call-seq:
- * solver.allow_virtual_conflicts -> bool
- *
- */
- int allow_virtual_conflicts()
- { return $self->allowvirtualconflicts; }
-
-#if defined(SWIGRUBY)
- %rename( "allow_virtual_conflicts=" ) set_allow_virtual_conflicts( int bflag
);
-#endif
- /*
- * call-seq:
- * solver.allow_virtual_conflicts = true
- *
- */
- void set_allow_virtual_conflicts( int bflag )
- { $self->allowvirtualconflicts = bflag; }
-
-#if defined(SWIGRUBY)
- %typemap(out) int allow_self_conflicts
- "$result = $1 ? Qtrue : Qfalse;";
-#endif
- /*
- * Allow self conflicts
- *
- * If a package can conflict with itself
- *
- * call-seq:
- * solver.allow_self_conflicts -> bool
- *
- */
- int allow_self_conflicts()
- { return $self->allowselfconflicts; }
-
-#if defined(SWIGRUBY)
- %rename( "allow_self_conflicts=" ) set_allow_self_conflicts( int bflag );
-#endif
- /*
- * call-seq:
- * solver.allow_self_conflicts = true
- *
- */
- void set_allow_self_conflicts( int bflag )
- { $self->allowselfconflicts = bflag; }
-
-#if defined(SWIGRUBY)
- %typemap(out) int obsolete_uses_provides
- "$result = $1 ? Qtrue : Qfalse;";
-#endif
- /*
- * Obsolete uses provides
- *
- * Obsolete dependencies usually match on package names only.
- * Setting this flag will make obsoletes also match a provides.
- *
- * call-seq:
- * solver.obsolete_uses_provides -> bool
- *
- */
- int obsolete_uses_provides()
- { return $self->obsoleteusesprovides; }
-
-#if defined(SWIGRUBY)
- %rename( "obsolete_uses_provides=" ) set_obsolete_uses_provides( int bflag );
-#endif
- /*
- * Obsolete uses provides
- *
- * call-seq:
- * solver.obsolete_uses_provides = true
- *
- */
- void set_obsolete_uses_provides( int bflag )
- { $self->obsoleteusesprovides= bflag; }
-
-#if defined(SWIGRUBY)
- %typemap(out) int implicit_obsolete_uses_provides
- "$result = $1 ? Qtrue : Qfalse;";
-#endif
- /*
- * Implicit obsolete uses provides
- *
- * call-seq:
- * solver.implicit_obsolete_uses_provides -> bool
- *
- */
- int implicit_obsolete_uses_provides()
- { return $self->implicitobsoleteusesprovides; }
-
-#if defined(SWIGRUBY)
- %rename( "implicit_obsolete_uses_provides=" )
set_implicit_obsolete_uses_provides( int bflag );
-#endif
- /*
- * call-seq:
- * solver.implicit_obsolete_uses_provides = true
- *
- */
- void set_implicit_obsolete_uses_provides( int bflag )
- { $self->implicitobsoleteusesprovides= bflag; }
-
-#if defined(SWIGRUBY)
%typemap(out) int no_update_provide
"$result = $1 ? Qtrue : Qfalse;";
#endif
diff --git a/src/bitmap.c b/src/bitmap.c
index c94afe0..200bb41 100644
--- a/src/bitmap.c
+++ b/src/bitmap.c
@@ -20,7 +20,7 @@ void
map_init(Map *m, int n)
{
m->size = (n + 7) >> 3;
- m->map = sat_calloc(m->size, 1);
+ m->map = n ? sat_calloc(m->size, 1) : 0;
}

// free space allocated
diff --git a/src/policy.c b/src/policy.c
index 2148b10..caddaf6 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -32,8 +32,7 @@
static int
prune_to_best_version_sortcmp(const void *ap, const void *bp, void *dp)
{
- Solver *solv = dp;
- Pool *pool = solv->pool;
+ Pool *pool = dp;
int r;
Id a = *(Id *)ap;
Id b = *(Id *)bp;
@@ -52,14 +51,14 @@ prune_to_best_version_sortcmp(const void *ap, const void
*bp, void *dp)
return strcmp(na, nb);
}
/* the same name, bring installed solvables to the front */
- if (solv->installed)
+ if (pool->installed)
{
- if (sa->repo == solv->installed)
+ if (sa->repo == pool->installed)
{
- if (sb->repo != solv->installed)
+ if (sb->repo != pool->installed)
return -1;
}
- else if (sb->repo == solv->installed)
+ else if (sb->repo == pool->installed)
return 1;
}
/* sort by repository sub-prio (installed repo handled above) */
@@ -269,9 +268,8 @@ prune_to_best_arch(Pool *pool, Queue *plist)
* return result through plist
*/
void
-prune_to_best_version(Solver *solv, Queue *plist)
+prune_to_best_version(Pool *pool, Queue *plist)
{
- Pool *pool = solv->pool;
Id best;
int i, j;
Solvable *s;
@@ -281,7 +279,7 @@ prune_to_best_version(Solver *solv, Queue *plist)
POOL_DEBUG(SAT_DEBUG_POLICY, "prune_to_best_version %d\n", plist->count);

/* sort by name first, prefer installed */
- sat_sort(plist->elements, plist->count, sizeof(Id),
prune_to_best_version_sortcmp, solv);
+ sat_sort(plist->elements, plist->count, sizeof(Id),
prune_to_best_version_sortcmp, pool);

/* delete obsoleted. hmm, looks expensive! */
/* FIXME maybe also check provides depending on noupdateprovide? */
@@ -299,7 +297,7 @@ prune_to_best_version(Solver *solv, Queue *plist)
{
if (pool->solvables[p].name == s->name)
continue;
- if (!solv->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p, obs))
+ if (!pool->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p, obs))
continue;
for (j = 0; j < plist->count; j++)
{
@@ -325,7 +323,7 @@ prune_to_best_version(Solver *solv, Queue *plist)

POOL_DEBUG(SAT_DEBUG_POLICY, "- %s[%s]\n",
solvable2str(pool, s),
- (solv->installed && s->repo == solv->installed) ? "installed"
: "not installed");
+ (pool->installed && s->repo == pool->installed) ? "installed"
: "not installed");

if (!best) /* if no best yet, the current is best */
{
@@ -371,7 +369,7 @@ prune_best_arch_name_version(Solver *solv, Pool *pool,
Queue *plist)
if (plist->count > 1)
prune_to_best_arch(pool, plist);
if (plist->count > 1)
- prune_to_best_version(solv, plist);
+ prune_to_best_version(pool, plist);
}


@@ -473,7 +471,7 @@ policy_create_obsolete_index(Solver *solv)
continue;
if (pool->solvables[p].name == s->name)
continue;
- if (!solv->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p, obs))
+ if (!pool->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p, obs))
continue;
obsoletes[p - installed->start]++;
}
@@ -504,7 +502,7 @@ policy_create_obsolete_index(Solver *solv)
continue;
if (pool->solvables[p].name == s->name)
continue;
- if (!solv->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p, obs))
+ if (!pool->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p, obs))
continue;
p -= installed->start;
if (obsoletes_data[obsoletes[p]] != i)
@@ -567,7 +565,7 @@ policy_findupdatepackages(Solver *solv, Solvable *s, Queue
*qs, int allow_all)
{
FOR_PROVIDES(p2, pp2, obs) /* and all matching providers of the
obsoletes */
{
- if (!solv->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p2, obs))
+ if (!pool->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p2, obs))
continue;
if (p2 == n) /* match ! */
break;
diff --git a/src/policy.h b/src/policy.h
index 4c69177..9e4de94 100644
--- a/src/policy.h
+++ b/src/policy.h
@@ -19,8 +19,9 @@
/* This functions can be used for sorting solvables to a specific order like
architecture, version. */
/* Solvables which does not fit to the system will be deleted from the list.
*/
extern void prune_best_arch_name_version(Solver *solv, Pool *pool, Queue
*plist);
+
extern void prune_to_best_arch(Pool *pool, Queue *plist);
-extern void prune_to_best_version(Solver *solv, Queue *plist);
+extern void prune_to_best_version(Pool *pool, Queue *plist);


/* The following default policies can be overloaded by the application by
using callbacks which are
diff --git a/src/pool.h b/src/pool.h
index 085f004..1c54264 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -72,7 +72,12 @@ struct _Pool {
Id *languagecache;
int languagecacheother;

- int promoteepoch; /* 0/1 */
+ /* flags to tell the library how the installed rpm works */
+ int promoteepoch; /* true: missing epoch is replaced by epoch of
dependency */
+ int obsoleteusesprovides; /* true: obsoletes are matched against
provides, not names */
+ int implicitobsoleteusesprovides; /* true: implicit obsoletes due to same
name are matched against provides, not names */
+ int novirtualconflicts; /* true: conflicts on names, not on provides */
+ int allowselfconflicts; /* true: packages which conflict with itself
are installable */

Id *id2arch; /* map arch ids to scores */
Id lastarch; /* last valid entry in id2arch */
diff --git a/src/rules.c b/src/rules.c
index 288252a..11f3301 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -632,7 +632,7 @@ solver_addrpmrulesforsolvable(Solver *solv, Solvable *s,
Map *m)
if (dontfix && pool->solvables[p].repo == installed)
continue;
/* p == n: self conflict */
- if (p == n && !solv->allowselfconflicts)
+ if (p == n && !pool->allowselfconflicts)
{
if (ISRELDEP(con))
{
@@ -669,7 +669,7 @@ solver_addrpmrulesforsolvable(Solver *solv, Solvable *s,
Map *m)
/* foreach provider of an obsoletes of 's' */
FOR_PROVIDES(p, pp, obs)
{
- if (!solv->obsoleteusesprovides /* obsoletes are matched
names, not provides */
+ if (!pool->obsoleteusesprovides /* obsoletes are matched
names, not provides */
&& !pool_match_nevr(pool, pool->solvables + p, obs))
continue;
addrpmrule(solv, -n, -p,
SOLVER_RULE_RPM_PACKAGE_OBSOLETES, obs);
@@ -683,7 +683,7 @@ solver_addrpmrulesforsolvable(Solver *solv, Solvable *s,
Map *m)
/* (actually, rpm mixes those packages. yuck...) */
if (noobs && (s->name != ps->name || s->evr != ps->evr || s->arch
!= ps->arch))
continue;
- if (!solv->implicitobsoleteusesprovides && s->name != ps->name)
+ if (!pool->implicitobsoleteusesprovides && s->name != ps->name)
continue;
if (s->name == ps->name)
addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_SAME_NAME, 0);
@@ -1170,7 +1170,7 @@ solver_createdupmaps(Solver *solv)
{
FOR_PROVIDES(pi, pp, obs)
{
- if (!solv->obsoleteusesprovides &&
!pool_match_nevr(pool, pool->solvables + pi, obs))
+ if (!pool->obsoleteusesprovides &&
!pool_match_nevr(pool, pool->solvables + pi, obs))
continue;
MAPSET(&solv->dupinvolvedmap, pi);
}
@@ -1361,7 +1361,7 @@ jobtodisablelist(Solver *solv, Id how, Id what, Queue *q)
Solvable *ps = pool->solvables + p;
if (ps->repo != installed)
continue;
- if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, ps,
obs))
+ if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps,
obs))
continue;
queue_push(q, DISABLE_UPDATE);
queue_push(q, p);
@@ -1372,7 +1372,7 @@ jobtodisablelist(Solver *solv, Id how, Id what, Queue *q)
Solvable *ps = pool->solvables + p;
if (ps->repo != installed)
continue;
- if (!solv->implicitobsoleteusesprovides && ps->name != s->name)
+ if (!pool->implicitobsoleteusesprovides && ps->name != s->name)
continue;
queue_push(q, DISABLE_UPDATE);
queue_push(q, p);
diff --git a/src/solver.c b/src/solver.c
index e17205b..055ea32 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -1228,8 +1228,7 @@ solver_create(Pool *pool)
solv->pool = pool;
solv->installed = pool->installed;

- queue_init(&solv->transaction);
- queue_init(&solv->transaction_info);
+ transaction_init(&solv->trans, pool);
queue_init(&solv->ruletojob);
queue_init(&solv->decisionq);
queue_init(&solv->decisionq_why);
@@ -1266,8 +1265,7 @@ solver_create(Pool *pool)
void
solver_free(Solver *solv)
{
- queue_free(&solv->transaction);
- queue_free(&solv->transaction_info);
+ transaction_free(&solv->trans);
queue_free(&solv->job);
queue_free(&solv->ruletojob);
queue_free(&solv->decisionq);
@@ -1300,7 +1298,6 @@ solver_free(Solver *solv)
sat_free(solv->obsoletes);
sat_free(solv->obsoletes_data);
sat_free(solv->multiversionupdaters);
- sat_free(solv->transaction_installed);
sat_free(solv);
}

@@ -2346,6 +2343,25 @@ findrecommendedsuggested(Solver *solv)
map_free(&obsmap);
}

+void
+solver_calculate_noobsmap(Pool *pool, Map *noobsmap, Queue *job)
+{
+ int i;
+ Id how, what, select;
+ Id p, pp;
+ for (i = 0; i < job->count; i += 2)
+ {
+ how = job->elements[i];
+ if ((how & SOLVER_JOBMASK) != SOLVER_NOOBSOLETES)
+ continue;
+ what = job->elements[i + 1];
+ select = how & SOLVER_SELECTMASK;
+ if (!noobsmap->size)
+ map_init(noobsmap, pool->nsolvables);
+ FOR_JOB_SELECT(p, pp, select, what)
+ MAPSET(noobsmap, p);
+ }
+}

/*
*
@@ -2376,8 +2392,8 @@ solver_solve(Solver *solv, Queue *job)
POOL_DEBUG(SAT_DEBUG_STATS, "fixsystem=%d updatesystem=%d
dosplitprovides=%d, noupdateprovide=%d noinfarchcheck=%d\n", solv->fixsystem,
solv->updatesystem, solv->dosplitprovides, solv->noupdateprovide,
solv->noinfarchcheck);
POOL_DEBUG(SAT_DEBUG_STATS, "distupgrade=%d
distupgrade_removeunsupported=%d\n", solv->distupgrade,
solv->distupgrade_removeunsupported);
POOL_DEBUG(SAT_DEBUG_STATS, "allowuninstall=%d, allowdowngrade=%d,
allowarchchange=%d, allowvendorchange=%d\n", solv->allowuninstall,
solv->allowdowngrade, solv->allowarchchange, solv->allowvendorchange);
- POOL_DEBUG(SAT_DEBUG_STATS, "promoteepoch=%d, allowvirtualconflicts=%d,
allowselfconflicts=%d\n", pool->promoteepoch, solv->allowvirtualconflicts,
solv->allowselfconflicts);
- POOL_DEBUG(SAT_DEBUG_STATS, "obsoleteusesprovides=%d,
implicitobsoleteusesprovides=%d\n", solv->obsoleteusesprovides,
solv->implicitobsoleteusesprovides);
+ POOL_DEBUG(SAT_DEBUG_STATS, "promoteepoch=%d, novirtualconflicts=%d,
allowselfconflicts=%d\n", pool->promoteepoch, pool->novirtualconflicts,
pool->allowselfconflicts);
+ POOL_DEBUG(SAT_DEBUG_STATS, "obsoleteusesprovides=%d,
implicitobsoleteusesprovides=%d\n", pool->obsoleteusesprovides,
pool->implicitobsoleteusesprovides);
POOL_DEBUG(SAT_DEBUG_STATS, "dontinstallrecommended=%d,
ignorealreadyrecommended=%d, dontshowinstalledrecommended=%d\n",
solv->dontinstallrecommended, solv->ignorealreadyrecommended,
solv->dontshowinstalledrecommended);

/* create whatprovides if not already there */
@@ -2397,18 +2413,7 @@ solver_solve(Solver *solv, Queue *job)
*/

/* create noobsolete map if needed */
- for (i = 0; i < job->count; i += 2)
- {
- how = job->elements[i];
- if ((how & SOLVER_JOBMASK) != SOLVER_NOOBSOLETES)
- continue;
- what = job->elements[i + 1];
- select = how & SOLVER_SELECTMASK;
- if (!solv->noobsoletes.size)
- map_init(&solv->noobsoletes, pool->nsolvables);
- FOR_JOB_SELECT(p, pp, select, what)
- MAPSET(&solv->noobsoletes, p);
- }
+ solver_calculate_noobsmap(pool, &solv->noobsoletes, job);

map_init(&addedmap, pool->nsolvables);
MAPSET(&addedmap, SYSTEMSOLVABLE);
@@ -2825,7 +2830,7 @@ solver_solve(Solver *solv, Queue *job)
/*
* finally prepare transaction info
*/
- solver_create_transaction(solv);
+ transaction_calculate(&solv->trans, &solv->decisionq, &solv->noobsoletes);

POOL_DEBUG(SAT_DEBUG_STATS, "final solver statistics: %d problems, %d
learned rules, %d unsolvable\n", solv->problems.count / 2, solv->stats_learned,
solv->stats_unsolvable);
POOL_DEBUG(SAT_DEBUG_STATS, "solver_solve took %d ms\n",
sat_timems(solve_start));
diff --git a/src/solver.h b/src/solver.h
index 08e6101..3166602 100644
--- a/src/solver.h
+++ b/src/solver.h
@@ -42,9 +42,7 @@ typedef struct _Solver {
Pool *pool;
Queue job; /* copy of the job we're solving */

- Queue transaction; /* solver result */
- Queue transaction_info; /* transaction obsoletes info */
- Id *transaction_installed; /* data for installed packages */
+ Transaction trans; /* calculated transaction */

Repo *installed; /* copy of pool->installed */

@@ -142,10 +140,6 @@ typedef struct _Solver {
int allowvendorchange; /* allow to change vendor of installed
solvables */
int allowuninstall; /* allow removal of installed solvables
*/
int updatesystem; /* update all packages to the newest
version */
- int allowvirtualconflicts; /* false: conflicts on package name,
true: conflicts on package provides */
- int allowselfconflicts; /* true: packages wich conflict with
itself are installable */
- int obsoleteusesprovides; /* true: obsoletes are matched against
provides, not names */
- int implicitobsoleteusesprovides; /* true: implicit obsoletes due to same
name are matched against provides, not names */
int noupdateprovide; /* true: update packages needs not to
provide old package */
int dosplitprovides; /* true: consider legacy split provides
*/
int dontinstallrecommended; /* true: do not install recommended
packages */
@@ -275,6 +269,8 @@ extern void solver_reset(Solver *solv);
extern int solver_dep_installed(Solver *solv, Id dep);
extern int solver_splitprovides(Solver *solv, Id dep);

+extern void solver_calculate_noobsmap(Pool *pool, Map *noobsmap, Queue *job);
+
/* obsolete */
extern SolverRuleinfo solver_problemruleinfo(Solver *solv, Queue *job, Id rid,
Id *depp, Id *sourcep, Id *targetp);

diff --git a/src/solverdebug.c b/src/solverdebug.c
index 6bfc2a3..85796f5 100644
--- a/src/solverdebug.c
+++ b/src/solverdebug.c
@@ -37,6 +37,8 @@
*
*/

+/* OBSOLETE: use transaction code instead! */
+
Id *
solver_create_decisions_obsoletesmap(Solver *solv)
{
@@ -68,7 +70,7 @@ solver_create_decisions_obsoletesmap(Solver *solv)
Solvable *ps = pool->solvables + p;
if (noobs && (s->name != ps->name || s->evr != ps->evr || s->arch
!= ps->arch))
continue;
- if (!solv->implicitobsoleteusesprovides && s->name != ps->name)
+ if (!pool->implicitobsoleteusesprovides && s->name != ps->name)
continue;
if (pool->solvables[p].repo == installed && !obsoletesmap[p])
{
@@ -99,7 +101,7 @@ solver_create_decisions_obsoletesmap(Solver *solv)
{
FOR_PROVIDES(p, pp, obs)
{
- if (!solv->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p, obs))
+ if (!pool->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p, obs))
continue;
if (pool->solvables[p].repo == installed && !obsoletesmap[p])
{
@@ -273,10 +275,10 @@ solver_printdecisions(Solver *solv)
POOL_DEBUG(SAT_DEBUG_RESULT, "transaction:\n");

queue_init(&iq);
- for (i = 0; i < solv->transaction.count; i += 2)
+ for (i = 0; i < solv->trans.steps.count; i += 2)
{
- s = pool->solvables + solv->transaction.elements[i + 1];
- switch(solv->transaction.elements[i])
+ s = pool->solvables + solv->trans.steps.elements[i + 1];
+ switch(solv->trans.steps.elements[i])
{
case SOLVER_TRANSACTION_MULTIINSTALL:
POOL_DEBUG(SAT_DEBUG_RESULT, " multi install %s",
solvable2str(pool, s));
@@ -306,7 +308,7 @@ solver_printdecisions(Solver *solv)
default:
break;
}
- switch(solv->transaction.elements[i])
+ switch(solv->trans.steps.elements[i])
{
case SOLVER_TRANSACTION_INSTALL:
case SOLVER_TRANSACTION_ERASE:
@@ -317,7 +319,7 @@ solver_printdecisions(Solver *solv)
case SOLVER_TRANSACTION_CHANGE:
case SOLVER_TRANSACTION_UPGRADE:
case SOLVER_TRANSACTION_REPLACE:
- solver_transaction_all_pkgs(solv, solv->transaction.elements[i + 1],
&iq);
+ solver_transaction_all_pkgs(&solv->trans,
solv->trans.steps.elements[i + 1], &iq);
if (iq.count)
{
POOL_DEBUG(SAT_DEBUG_RESULT, " (obsoletes");
diff --git a/src/transaction.c b/src/transaction.c
index 78646ac..cfedc79 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -58,20 +58,20 @@ obsq_sortcmp(const void *ap, const void *bp, void *dp)
}

void
-solver_transaction_all_pkgs(Solver *solv, Id p, Queue *pkgs)
+solver_transaction_all_pkgs(Transaction *trans, Id p, Queue *pkgs)
{
- Pool *pool = solv->pool;
+ Pool *pool = trans->pool;
Solvable *s = pool->solvables + p;
- Queue *ti = &solv->transaction_info;
+ Queue *ti = &trans->transaction_info;
Id q;
int i;

queue_empty(pkgs);
if (p <= 0 || !s->repo)
return;
- if (s->repo == solv->installed)
+ if (s->repo == pool->installed)
{
- q = solv->transaction_installed[p - solv->installed->start];
+ q = trans->transaction_installed[p - pool->installed->start];
if (!q)
return;
if (q > 0)
@@ -107,22 +107,22 @@ solver_transaction_all_pkgs(Solver *solv, Id p, Queue
*pkgs)
}

Id
-solver_transaction_pkg(Solver *solv, Id p)
+solver_transaction_pkg(Transaction *trans, Id p)
{
- Pool *pool = solv->pool;
+ Pool *pool = trans->pool;
Solvable *s = pool->solvables + p;
Queue ti;
Id tibuf[5];

if (p <= 0 || !s->repo)
return 0;
- if (s->repo == solv->installed)
+ if (s->repo == pool->installed)
{
- p = solv->transaction_installed[p - solv->installed->start];
+ p = trans->transaction_installed[p - pool->installed->start];
return p < 0 ? -p : p;
}
queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
- solver_transaction_all_pkgs(solv, p, &ti);
+ solver_transaction_all_pkgs(trans, p, &ti);
p = ti.count ? ti.elements[0] : 0;
queue_free(&ti);
return p;
@@ -133,9 +133,9 @@ solver_transaction_pkg(Solver *solv, Id p)
* transaction might not be shown to the user */

Id
-solver_transaction_filter(Solver *solv, Id type, Id p, int flags)
+solver_transaction_show(Transaction *trans, Id type, Id p, int flags)
{
- Pool *pool = solv->pool;
+ Pool *pool = trans->pool;
Solvable *s = pool->solvables + p;
Queue oq, rq;
Id q;
@@ -159,7 +159,7 @@ solver_transaction_filter(Solver *solv, Id type, Id p, int
flags)
}

/* most of the time there's only one reference, so check it first */
- q = solver_transaction_pkg(solv, p);
+ q = solver_transaction_pkg(trans, p);
if ((flags & SOLVER_TRANSACTION_SHOW_REPLACES) == 0)
{
Solvable *sq = pool->solvables + q;
@@ -173,13 +173,13 @@ solver_transaction_filter(Solver *solv, Id type, Id p,
int flags)
return SOLVER_TRANSACTION_INSTALL;
}
}
- if (solver_transaction_pkg(solv, q) == p)
+ if (solver_transaction_pkg(trans, q) == p)
return type;

/* too bad, a miss. check em all */
queue_init(&oq);
queue_init(&rq);
- solver_transaction_all_pkgs(solv, p, &oq);
+ solver_transaction_all_pkgs(trans, p, &oq);
for (i = 0; i < oq.count; i++)
{
q = oq.elements[i];
@@ -192,7 +192,7 @@ solver_transaction_filter(Solver *solv, Id type, Id p, int
flags)
/* check if we are referenced? */
if ((flags & SOLVER_TRANSACTION_SHOW_ALL) != 0)
{
- solver_transaction_all_pkgs(solv, q, &rq);
+ solver_transaction_all_pkgs(trans, q, &rq);
for (j = 0; j < rq.count; j++)
if (rq.elements[j] == p)
{
@@ -202,7 +202,7 @@ solver_transaction_filter(Solver *solv, Id type, Id p, int
flags)
if (ref)
break;
}
- else if (solver_transaction_pkg(solv, q) == p)
+ else if (solver_transaction_pkg(trans, q) == p)
{
ref = 1;
break;
@@ -224,11 +224,11 @@ solver_transaction_filter(Solver *solv, Id type, Id p,
int flags)
}

static void
-create_transaction_info(Solver *solv)
+create_transaction_info(Transaction *trans, Queue *decisionq, Map *noobsmap)
{
- Pool *pool = solv->pool;
- Queue *ti = &solv->transaction_info;
- Repo *installed = solv->installed;
+ Pool *pool = trans->pool;
+ Queue *ti = &trans->transaction_info;
+ Repo *installed = pool->installed;
int i, j, noobs;
Id p, p2, pp2;
Solvable *s, *s2;
@@ -236,25 +236,25 @@ create_transaction_info(Solver *solv)
queue_empty(ti);
if (!installed)
return; /* no info needed */
- for (i = 0; i < solv->decisionq.count; i++)
+ for (i = 0; i < decisionq->count; i++)
{
- p = solv->decisionq.elements[i];
+ p = decisionq->elements[i];
if (p <= 0 || p == SYSTEMSOLVABLE)
continue;
s = pool->solvables + p;
if (s->repo == installed)
continue;
- noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p);
+ noobs = noobsmap && MAPTST(noobsmap, p);
FOR_PROVIDES(p2, pp2, s->name)
{
- if (solv->decisionmap[p2] > 0)
+ if (!MAPTST(&trans->transactsmap, p2))
continue;
s2 = pool->solvables + p2;
if (s2->repo != installed)
continue;
if (noobs && (s->name != s2->name || s->evr != s2->evr || s->arch !=
s2->arch))
continue;
- if (!solv->implicitobsoleteusesprovides && s->name != s2->name)
+ if (!pool->implicitobsoleteusesprovides && s->name != s2->name)
continue;
queue_push(ti, p);
queue_push(ti, p2);
@@ -269,7 +269,7 @@ create_transaction_info(Solver *solv)
s2 = pool->solvables + p2;
if (s2->repo != installed)
continue;
- if (!solv->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p2, obs))
+ if (!pool->obsoleteusesprovides && !pool_match_nevr(pool,
pool->solvables + p2, obs))
continue;
queue_push(ti, p);
queue_push(ti, p2);
@@ -289,109 +289,138 @@ create_transaction_info(Solver *solv)
ti->count = j;

/* create transaction_installed helper */
- solv->transaction_installed = sat_calloc(installed->end - installed->start,
sizeof(Id));
+ trans->transaction_installed = sat_calloc(installed->end - installed->start,
sizeof(Id));
for (i = 0; i < ti->count; i += 2)
{
j = ti->elements[i + 1] - installed->start;
- if (!solv->transaction_installed[j])
- solv->transaction_installed[j] = ti->elements[i];
+ if (!trans->transaction_installed[j])
+ trans->transaction_installed[j] = ti->elements[i];
else
{
/* more than one package obsoletes us. compare */
Id q[4];
- if (solv->transaction_installed[j] > 0)
- solv->transaction_installed[j] = -solv->transaction_installed[j];
+ if (trans->transaction_installed[j] > 0)
+ trans->transaction_installed[j] = -trans->transaction_installed[j];
q[0] = q[2] = ti->elements[i + 1];
q[1] = ti->elements[i];
- q[3] = -solv->transaction_installed[j];
+ q[3] = -trans->transaction_installed[j];
if (obsq_sortcmp(q, q + 2, pool) < 0)
- solv->transaction_installed[j] = -ti->elements[i];
+ trans->transaction_installed[j] = -ti->elements[i];
}
}
}

+void
+transaction_init(Transaction *trans, Pool *pool)
+{
+ memset(trans, 0, sizeof(*trans));
+ trans->pool = pool;
+}

void
-solver_create_transaction(Solver *solv)
+transaction_free(Transaction *trans)
{
- Pool *pool = solv->pool;
- Repo *installed = solv->installed;
+ queue_free(&trans->steps);
+ queue_free(&trans->transaction_info);
+ trans->transaction_installed = sat_free(trans->transaction_installed);
+ map_free(&trans->transactsmap);
+}
+
+void
+transaction_calculate(Transaction *trans, Queue *decisionq, Map *noobsmap)
+{
+ Pool *pool = trans->pool;
+ Repo *installed = pool->installed;
int i, r, noobs;
Id p, p2;
Solvable *s, *s2;

- queue_empty(&solv->transaction);
- create_transaction_info(solv);
+ if (noobsmap && !noobsmap->size)
+ noobsmap = 0; /* ignore empty map */
+ queue_empty(&trans->steps);
+ map_init(&trans->transactsmap, pool->nsolvables);
+ for (i = 0; i < decisionq->count; i++)
+ {
+ p = decisionq->elements[i];
+ s = pool->solvables + (p > 0 ? p : -p);
+ if (!s->repo)
+ continue;
+ if (installed && s->repo == installed && p < 0)
+ MAPSET(&trans->transactsmap, -p);
+ if ((!installed || s->repo != installed) && p > 0)
+ MAPSET(&trans->transactsmap, p);
+ }
+ create_transaction_info(trans, decisionq, noobsmap);

if (installed)
{
FOR_REPO_SOLVABLES(installed, p, s)
{
- if (solv->decisionmap[p] > 0)
+ if (!MAPTST(&trans->transactsmap, p))
continue;
- p2 = solver_transaction_pkg(solv, p);
+ p2 = solver_transaction_pkg(trans, p);
if (!p2)
- queue_push(&solv->transaction, SOLVER_TRANSACTION_ERASE);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_ERASE);
else
{
s2 = pool->solvables + p2;
if (s->name == s2->name)
{
if (s->evr == s2->evr && solvable_identical(s, s2))
- queue_push(&solv->transaction,
SOLVER_TRANSACTION_REINSTALLED);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_REINSTALLED);
else
{
r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
if (r < 0)
- queue_push(&solv->transaction,
SOLVER_TRANSACTION_UPGRADED);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_UPGRADED);
else if (r > 0)
- queue_push(&solv->transaction,
SOLVER_TRANSACTION_DOWNGRADED);
+ queue_push(&trans->steps,
SOLVER_TRANSACTION_DOWNGRADED);
else
- queue_push(&solv->transaction,
SOLVER_TRANSACTION_CHANGED);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_CHANGED);
}
}
else
- queue_push(&solv->transaction, SOLVER_TRANSACTION_REPLACED);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_REPLACED);
}
- queue_push(&solv->transaction, p);
+ queue_push(&trans->steps, p);
}
}
- for (i = 0; i < solv->decisionq.count; i++)
+ for (i = 0; i < decisionq->count; i++)
{
- p = solv->decisionq.elements[i];
+ p = decisionq->elements[i];
if (p < 0 || p == SYSTEMSOLVABLE)
continue;
s = pool->solvables + p;
- if (solv->installed && s->repo == solv->installed)
+ if (installed && s->repo == installed)
continue;
- noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p);
- p2 = solver_transaction_pkg(solv, p);
+ noobs = noobsmap && MAPTST(noobsmap, p);
+ p2 = solver_transaction_pkg(trans, p);
if (noobs)
- queue_push(&solv->transaction, p2 ? SOLVER_TRANSACTION_MULTIREINSTALL :
SOLVER_TRANSACTION_MULTIINSTALL);
+ queue_push(&trans->steps, p2 ? SOLVER_TRANSACTION_MULTIREINSTALL :
SOLVER_TRANSACTION_MULTIINSTALL);
else if (!p2)
- queue_push(&solv->transaction, SOLVER_TRANSACTION_INSTALL);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_INSTALL);
else
{
s2 = pool->solvables + p2;
if (s->name == s2->name)
{
if (s->evr == s2->evr && solvable_identical(s, s2))
- queue_push(&solv->transaction, SOLVER_TRANSACTION_REINSTALL);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_REINSTALL);
else
{
r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
if (r > 0)
- queue_push(&solv->transaction, SOLVER_TRANSACTION_UPGRADE);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_UPGRADE);
else if (r < 0)
- queue_push(&solv->transaction,
SOLVER_TRANSACTION_DOWNGRADE);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_DOWNGRADE);
else
- queue_push(&solv->transaction, SOLVER_TRANSACTION_CHANGE);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_CHANGE);
}
}
else
- queue_push(&solv->transaction, SOLVER_TRANSACTION_REPLACE);
+ queue_push(&trans->steps, SOLVER_TRANSACTION_REPLACE);
}
- queue_push(&solv->transaction, p);
+ queue_push(&trans->steps, p);
}
}

@@ -417,7 +446,7 @@ struct transel {
};

struct orderdata {
- Solver *solv;
+ Transaction *trans;
struct transel *tes;
int ntes;
Id *edgedata;
@@ -429,19 +458,19 @@ struct orderdata {
static int
addedge(struct orderdata *od, Id from, Id to, int type)
{
- Solver *solv = od->solv;
- Pool *pool = solv->pool;
+ Transaction *trans = od->trans;
+ Pool *pool = trans->pool;
Solvable *s;
struct transel *te;
int i;

// printf("addedge %d %d type %d\n", from, to, type);
s = pool->solvables + from;
- if (s->repo == solv->installed && solv->transaction_installed[from -
solv->installed->start])
+ if (s->repo == pool->installed && trans->transaction_installed[from -
pool->installed->start])
{
/* passive, map to active */
- if (solv->transaction_installed[from - solv->installed->start] > 0)
- from = solv->transaction_installed[from - solv->installed->start];
+ if (trans->transaction_installed[from - pool->installed->start] > 0)
+ from = trans->transaction_installed[from - pool->installed->start];
else
{
int ret = 0;
@@ -449,7 +478,7 @@ addedge(struct orderdata *od, Id from, Id to, int type)
Id tibuf[5];

queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
- solver_transaction_all_pkgs(solv, from, &ti);
+ solver_transaction_all_pkgs(trans, from, &ti);
for (i = 0; i < ti.count; i++)
ret |= addedge(od, ti.elements[i], to, type);
queue_free(&ti);
@@ -457,11 +486,11 @@ addedge(struct orderdata *od, Id from, Id to, int type)
}
}
s = pool->solvables + to;
- if (s->repo == solv->installed && solv->transaction_installed[to -
solv->installed->start])
+ if (s->repo == pool->installed && trans->transaction_installed[to -
pool->installed->start])
{
/* passive, map to active */
- if (solv->transaction_installed[to - solv->installed->start] > 0)
- to = solv->transaction_installed[to - solv->installed->start];
+ if (trans->transaction_installed[to - pool->installed->start] > 0)
+ to = trans->transaction_installed[to - pool->installed->start];
else
{
int ret = 0;
@@ -469,7 +498,7 @@ addedge(struct orderdata *od, Id from, Id to, int type)
Id tibuf[5];

queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
- solver_transaction_all_pkgs(solv, to, &ti);
+ solver_transaction_all_pkgs(trans, to, &ti);
for (i = 0; i < ti.count; i++)
ret |= addedge(od, from, ti.elements[i], type);
queue_free(&ti);
@@ -535,7 +564,8 @@ addedge(struct orderdata *od, Id from, Id to, int type)
static int
havechoice(struct orderdata *od, Id p, Id q1, Id q2)
{
- Solver *solv = od->solv;
+ Transaction *trans = od->trans;
+ Pool *pool = trans->pool;
Id ti1buf[5], ti2buf[5];
Queue ti1, ti2;
int i, j;
@@ -543,18 +573,18 @@ havechoice(struct orderdata *od, Id p, Id q1, Id q2)
/* both q1 and q2 are uninstalls. check if their TEs intersect */
/* common case: just one TE for both packages */
printf("havechoice %d %d %d\n", p, q1, q2);
- if (solv->transaction_installed[q1 - solv->installed->start] == 0)
+ if (trans->transaction_installed[q1 - pool->installed->start] == 0)
return 1;
- if (solv->transaction_installed[q2 - solv->installed->start] == 0)
+ if (trans->transaction_installed[q2 - pool->installed->start] == 0)
return 1;
- if (solv->transaction_installed[q1 - solv->installed->start] ==
solv->transaction_installed[q2 - solv->installed->start])
+ if (trans->transaction_installed[q1 - pool->installed->start] ==
trans->transaction_installed[q2 - pool->installed->start])
return 0;
- if (solv->transaction_installed[q1 - solv->installed->start] > 0 &&
solv->transaction_installed[q2 - solv->installed->start] > 0)
+ if (trans->transaction_installed[q1 - pool->installed->start] > 0 &&
trans->transaction_installed[q2 - pool->installed->start] > 0)
return 1;
queue_init_buffer(&ti1, ti1buf, sizeof(ti1buf)/sizeof(*ti1buf));
- solver_transaction_all_pkgs(solv, q1, &ti1);
+ solver_transaction_all_pkgs(trans, q1, &ti1);
queue_init_buffer(&ti2, ti2buf, sizeof(ti2buf)/sizeof(*ti2buf));
- solver_transaction_all_pkgs(solv, q2, &ti2);
+ solver_transaction_all_pkgs(trans, q2, &ti2);
for (i = 0; i < ti1.count; i++)
for (j = 0; j < ti2.count; j++)
if (ti1.elements[i] == ti2.elements[j])
@@ -572,12 +602,12 @@ havechoice(struct orderdata *od, Id p, Id q1, Id q2)
static void
addsolvableedges(struct orderdata *od, Solvable *s)
{
- Solver *solv = od->solv;
- Pool *pool = solv->pool;
+ Transaction *trans = od->trans;
+ Pool *pool = trans->pool;
Id req, *reqp, con, *conp;
Id p, p2, pp2;
int i, j, pre, numins;
- Repo *installed = solv->installed;
+ Repo *installed = pool->installed;
Solvable *s2;
Queue reqq;

@@ -604,12 +634,12 @@ addsolvableedges(struct orderdata *od, Solvable *s)
reqq.count = 0; /* self provides */
break;
}
- if (s2->repo == installed && solv->decisionmap[p2] > 0)
+ if (s2->repo == installed && !MAPTST(&trans->transactsmap, p2))
{
reqq.count = 0; /* provided by package that stays
installed */
break;
}
- if (s2->repo != installed && solv->decisionmap[p2] <= 0)
+ if (s2->repo != installed && !MAPTST(&trans->transactsmap, p2))
continue; /* package stays uninstalled */

if (s->repo == installed)
@@ -694,7 +724,7 @@ addsolvableedges(struct orderdata *od, Solvable *s)
continue;
if (s->repo == installed)
{
- if (s2->repo != installed && solv->decisionmap[p2] >= 0)
+ if (s2->repo != installed && MAPTST(&trans->transactsmap, p2))
{
/* deinstall p before installing p2 */
addedge(od, p2, p, TYPE_CON);
@@ -702,7 +732,7 @@ addsolvableedges(struct orderdata *od, Solvable *s)
}
else
{
- if (s2->repo == installed && solv->decisionmap[p2] < 0)
+ if (s2->repo == installed && MAPTST(&trans->transactsmap, p2))
{
/* deinstall p2 before installing p */
addedge(od, p, p2, TYPE_CON);
@@ -741,7 +771,7 @@ haveprereq(Pool *pool, Id solvid)
void
breakcycle(struct orderdata *od, Id *cycle)
{
- Pool *pool = od->solv->pool;
+ Pool *pool = od->trans->pool;
Id ddegmin, ddegmax, ddeg;
int k, l;
struct transel *te;
@@ -797,11 +827,11 @@ breakcycle(struct orderdata *od, Id *cycle)
}

void
-solver_order_transaction(Solver *solv)
+transaction_order(Transaction *trans)
{
- Pool *pool = solv->pool;
- Queue *tr = &solv->transaction;
- Repo *installed = solv->installed;
+ Pool *pool = trans->pool;
+ Queue *tr = &trans->steps;
+ Repo *installed = pool->installed;
Id type, p;
Solvable *s;
int i, j, k, numte, numedge;
@@ -821,8 +851,9 @@ solver_order_transaction(Solver *solv)
{
p = tr->elements[i + 1];
s = pool->solvables + p;
- if (s->repo != installed || !solv->transaction_installed[p -
solv->installed->start])
- numte++;
+ if (installed && s->repo == installed && trans->transaction_installed[p
- installed->start])
+ continue;
+ numte++;
}
if (!numte)
return; /* nothing to do... */
@@ -830,7 +861,7 @@ solver_order_transaction(Solver *solv)
POOL_DEBUG(SAT_DEBUG_STATS, "transaction elements: %d\n", numte);
numte++; /* leave first one zero */
memset(&od, 0, sizeof(od));
- od.solv = solv;
+ od.trans = trans;
od.ntes = numte;
od.tes = sat_calloc(numte, sizeof(*od.tes));
od.edgedata = sat_extend(0, 0, 1, sizeof(Id), EDGEDATA_BLOCK);
@@ -842,7 +873,7 @@ solver_order_transaction(Solver *solv)
{
p = tr->elements[i + 1];
s = pool->solvables + p;
- if (s->repo == installed && solv->transaction_installed[p -
solv->installed->start])
+ if (installed && s->repo == installed && trans->transaction_installed[p
- installed->start])
continue;
te->p = p;
te->type = tr->elements[i];
@@ -864,6 +895,7 @@ solver_order_transaction(Solver *solv)
for (j = te->edges; od.edgedata[j]; j += 2)
numedge++;
POOL_DEBUG(SAT_DEBUG_STATS, "edges: %d, edge space: %d\n", numedge,
od.nedgedata / 2);
+ POOL_DEBUG(SAT_DEBUG_STATS, "edge creation took %d ms\n", sat_timems(now));

/* kill all cycles */
broken = 0;
@@ -995,7 +1027,7 @@ solver_order_transaction(Solver *solv)
{
p = tr->elements[i + 1];
s = pool->solvables + p;
- if (s->repo == installed && solv->transaction_installed[p -
installed->start])
+ if (s->repo == installed && trans->transaction_installed[p -
installed->start])
obstypes[p - installed->start] = tr->elements[i];
}
}
@@ -1036,7 +1068,7 @@ solver_order_transaction(Solver *solv)
if (installed && s->repo != installed)
{
queue_empty(&obsq);
- solver_transaction_all_pkgs(solv, te->p, &obsq);
+ solver_transaction_all_pkgs(trans, te->p, &obsq);
for (j = 0; j < obsq.count; j++)
{
p = obsq.elements[j];
diff --git a/src/transaction.h b/src/transaction.h
index 25a7967..c1f87b8 100644
--- a/src/transaction.h
+++ b/src/transaction.h
@@ -19,9 +19,20 @@ extern "C" {

#include "pooltypes.h"
#include "queue.h"
+#include "bitmap.h"

-struct _Solver;
+struct _Pool;

+typedef struct _Transaction {
+ struct _Pool *pool;
+ Queue steps;
+ Queue transaction_info;
+ Id *transaction_installed;
+ Map transactsmap;
+} Transaction;
+
+
+/* step types */
#define SOLVER_TRANSACTION_ERASE 0x10
#define SOLVER_TRANSACTION_REINSTALLED 0x11
#define SOLVER_TRANSACTION_DOWNGRADED 0x12
@@ -39,14 +50,18 @@ struct _Solver;
#define SOLVER_TRANSACTION_MULTIINSTALL 0x30
#define SOLVER_TRANSACTION_MULTIREINSTALL 0x31

+/* show modes */
#define SOLVER_TRANSACTION_SHOW_ACTIVE (1 << 0)
#define SOLVER_TRANSACTION_SHOW_ALL (1 << 1)
#define SOLVER_TRANSACTION_SHOW_REPLACES (1 << 2)

-extern void solver_create_transaction(struct _Solver *solv);
-extern void solver_transaction_all_pkgs(struct _Solver *solv, Id p, Queue
*pkgs);
-extern Id solver_transaction_pkg(struct _Solver *solv, Id p);
-extern Id solver_transaction_filter(struct _Solver *solv, Id type, Id p, int
mode);
+extern void transaction_init(Transaction *trans, struct _Pool *pool);
+extern void transaction_free(Transaction *trans);
+extern void transaction_calculate(Transaction *trans, Queue *decisionq, Map
*noobsmap);
+extern void solver_transaction_all_pkgs(Transaction *trans, Id p, Queue *pkgs);
+extern Id solver_transaction_pkg(Transaction *trans, Id p);
+extern Id solver_transaction_show(Transaction *trans, Id type, Id p, int
mode);
+extern void transaction_order(Transaction *trans);

#ifdef __cplusplus
}
diff --git
a/tests/solver/data.libzypp/sat-tests/install-zypper/install-zypper-force-test.solution

b/tests/solver/data.libzypp/sat-tests/install-zypper/install-zypper-force-test.solution
index 84390b0..2025e5f 100644
---
a/tests/solver/data.libzypp/sat-tests/install-zypper/install-zypper-force-test.solution
+++
b/tests/solver/data.libzypp/sat-tests/install-zypper/install-zypper-force-test.solution
@@ -1,6 +1,5 @@
!> Installing zypper from channel zypp:svn
!> Solution #1:
->!> install bash-completion-20060301-71.noarch[factory]
!> upgrade glibc-2.7-15.x86_64 => glibc-2.8-5.x86_64[factory]
!> upgrade glibc-devel-2.7-14.x86_64 => glibc-devel-2.8-5.x86_64[factory]
!> upgrade glibc-locale-2.7-14.x86_64 => glibc-locale-2.8-5.x86_64[factory]
@@ -11,8 +10,9 @@
!> upgrade ruby-zypp-0.4.6-12.12.x86_64 =>
ruby-zypp-0.4.6-15.5.x86_64[zypp:svn]
!> upgrade satsolver-tools-0.0.25-12.1.x86_64 =>
satsolver-tools-0.0.28-3.1.x86_64[zypp:svn]
!> upgrade yast2-ncurses-pkg-2.16.6-13.1.x86_64 =>
yast2-ncurses-pkg-2.16.6-24.1.x86_64[YaST_SVN]
->!> upgrade yast2-perl-bindings-2.16.5-12.13.x86_64 =>
yast2-perl-bindings-2.16.6-4.x86_64[factory]
+>!> upgrade yast2-perl-bindings-2.16.5-12.13.x86_64 =>
yast2-perl-bindings-2.16.6-3.9.x86_64[YaST_SVN]
!> upgrade yast2-pkg-bindings-2.16.23-18.2.x86_64 =>
yast2-pkg-bindings-2.16.29-1.1.x86_64[YaST_SVN]
!> upgrade yast2-qt-pkg-2.16.32-1.3.x86_64 =>
yast2-qt-pkg-2.16.37-2.1.x86_64[YaST_SVN]
!> upgrade zypper-0.10.6-6.4.x86_64 => zypper-0.11.0-8.1.x86_64[zypp:svn]
+>!> install bash-completion-20060301-71.noarch[factory]
!> installs=1, upgrades=14, uninstalls=0
diff --git
a/tests/solver/data.libzypp/sat-tests/install-zypper/install-zypper-noforce-test.solution

b/tests/solver/data.libzypp/sat-tests/install-zypper/install-zypper-noforce-test.solution
index 84390b0..2025e5f 100644
---
a/tests/solver/data.libzypp/sat-tests/install-zypper/install-zypper-noforce-test.solution
+++
b/tests/solver/data.libzypp/sat-tests/install-zypper/install-zypper-noforce-test.solution
@@ -1,6 +1,5 @@
!> Installing zypper from channel zypp:svn
!> Solution #1:
->!> install bash-completion-20060301-71.noarch[factory]
!> upgrade glibc-2.7-15.x86_64 => glibc-2.8-5.x86_64[factory]
!> upgrade glibc-devel-2.7-14.x86_64 => glibc-devel-2.8-5.x86_64[factory]
!> upgrade glibc-locale-2.7-14.x86_64 => glibc-locale-2.8-5.x86_64[factory]
@@ -11,8 +10,9 @@
!> upgrade ruby-zypp-0.4.6-12.12.x86_64 =>
ruby-zypp-0.4.6-15.5.x86_64[zypp:svn]
!> upgrade satsolver-tools-0.0.25-12.1.x86_64 =>
satsolver-tools-0.0.28-3.1.x86_64[zypp:svn]
!> upgrade yast2-ncurses-pkg-2.16.6-13.1.x86_64 =>
yast2-ncurses-pkg-2.16.6-24.1.x86_64[YaST_SVN]
->!> upgrade yast2-perl-bindings-2.16.5-12.13.x86_64 =>
yast2-perl-bindings-2.16.6-4.x86_64[factory]
+>!> upgrade yast2-perl-bindings-2.16.5-12.13.x86_64 =>
yast2-perl-bindings-2.16.6-3.9.x86_64[YaST_SVN]
!> upgrade yast2-pkg-bindings-2.16.23-18.2.x86_64 =>
yast2-pkg-bindings-2.16.29-1.1.x86_64[YaST_SVN]
!> upgrade yast2-qt-pkg-2.16.32-1.3.x86_64 =>
yast2-qt-pkg-2.16.37-2.1.x86_64[YaST_SVN]
!> upgrade zypper-0.10.6-6.4.x86_64 => zypper-0.11.0-8.1.x86_64[zypp:svn]
+>!> install bash-completion-20060301-71.noarch[factory]
!> installs=1, upgrades=14, uninstalls=0
diff --git a/tests/solver/deptestomatic.c b/tests/solver/deptestomatic.c
index 5da6b4c..8eccf0e 100644
--- a/tests/solver/deptestomatic.c
+++ b/tests/solver/deptestomatic.c
@@ -1503,9 +1503,9 @@ endElement( void *userData, const char *name )
if (redcarpet)
pool->promoteepoch = 1;

- Solver *solv = solver_create( pd->pool );
+ Solver *solv = solver_create(pd->pool);
solv->fixsystem = pd->fixsystem;
- solv->allowselfconflicts = 1;
+ pd->pool->allowselfconflicts = 1; /* XXX: should fix test cases
instead */
solv->updatesystem = pd->updatesystem;
solv->allowdowngrade = pd->allowdowngrade;
solv->allowuninstall = pd->allowuninstall;
@@ -1534,11 +1534,8 @@ endElement( void *userData, const char *name )
}
rc_printdecisions(solv, &pd->trials);
#if 0
- if (1)
- {
- extern void solver_order_transaction(Solver *solv);
- solver_order_transaction(solv);
- }
+ transaction_order(&solv->trans);
+ solver_printdecisions(solv);
#endif
}
// clean up
@@ -1610,6 +1607,7 @@ static void
rc_printdecisions(Solver *solv, Queue *job)
{
Pool *pool = solv->pool;
+ Transaction *trans = &solv->trans;
int i;
Solvable *s;

@@ -1631,14 +1629,14 @@ rc_printdecisions(Solver *solv, Queue *job)
int installs = 0, uninstalls = 0, upgrades = 0;
Id type, p;

- sat_sort(solv->transaction.elements, solv->transaction.count / 2, 2 *
sizeof(Id), transaction_sortcmp, pool);
+ sat_sort(trans->steps.elements, trans->steps.count / 2, 2 * sizeof(Id),
transaction_sortcmp, pool);

- for (i = 0; i < solv->transaction.count; i += 2)
+ for (i = 0; i < trans->steps.count; i += 2)
{
- type = solv->transaction.elements[i];
- p = solv->transaction.elements[i + 1];
- s = pool->solvables + solv->transaction.elements[i + 1];
- type = solver_transaction_filter(solv, type, p, 0);
+ type = trans->steps.elements[i];
+ p = trans->steps.elements[i + 1];
+ s = pool->solvables + trans->steps.elements[i + 1];
+ type = solver_transaction_show(trans, type, p, 0);
switch(type)
{
case SOLVER_TRANSACTION_INSTALL:
@@ -1666,7 +1664,7 @@ rc_printdecisions(Solver *solv, Queue *job)
printf(">!> upgrade %s-%s => ", id2str(pool, s->name), id2str(pool,
s->evr));
else
printf(">!> upgrade %s-%s.%s => ", id2str(pool, s->name),
id2str(pool, s->evr), id2str(pool, s->arch));
- s = pool->solvables + solver_transaction_pkg(solv,
solv->transaction.elements[i + 1]);
+ s = pool->solvables + solver_transaction_pkg(trans,
trans->steps.elements[i + 1]);
if (redcarpet)
printf("%s-%s%s", id2str(pool, s->name), id2rc(solv, s->evr),
id2str(pool, s->evr));
else
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages