summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2013-08-21 14:34:46 +0200
committerMichael Schroeder <mls@suse.de>2013-08-21 14:34:46 +0200
commit6861611dc8a8dcce70578d4494d9fbb7352ff019 (patch)
tree964f79f29ec36a6dc6875e4e4355c1d3f11cb3f7 /src
parenteee4aa9298efb0d87f2e069ca895e0da0b718833 (diff)
downloadlibsolv-6861611dc8a8dcce70578d4494d9fbb7352ff019.tar.gz
libsolv-6861611dc8a8dcce70578d4494d9fbb7352ff019.tar.bz2
libsolv-6861611dc8a8dcce70578d4494d9fbb7352ff019.zip
make solver_describe_decision always return a rule, add solver_rule2solvable()
that way users of describe_decision have the correct rule, they can use solver_rule2solvable to get the id of the solvable.
Diffstat (limited to 'src')
-rw-r--r--src/libsolv.ver1
-rw-r--r--src/rules.c10
-rw-r--r--src/rules.h1
-rw-r--r--src/solver.c20
4 files changed, 15 insertions, 17 deletions
diff --git a/src/libsolv.ver b/src/libsolv.ver
index 7982dbb..eec2018 100644
--- a/src/libsolv.ver
+++ b/src/libsolv.ver
@@ -350,6 +350,7 @@ SOLV_1.0 {
solver_problemruleinfo2str;
solver_rule2job;
solver_rule2jobidx;
+ solver_rule2solvable;
solver_ruleclass;
solver_ruleinfo;
solver_ruleliterals;
diff --git a/src/rules.c b/src/rules.c
index ae14eba..677807c 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -2307,6 +2307,16 @@ solver_rule2job(Solver *solv, Id rid, Id *whatp)
return solv->job.elements[idx];
}
+Id
+solver_rule2solvable(Solver *solv, Id rid)
+{
+ if (rid >= solv->updaterules && rid < solv->updaterules_end)
+ return rid - solv->updaterules;
+ if (rid >= solv->featurerules && rid < solv->featurerules_end)
+ return rid - solv->featurerules;
+ return 0;
+}
+
/* check if the newest versions of pi still provides the dependency we're looking for */
static int
solver_choicerulecheck(Solver *solv, Id pi, Rule *r, Map *m)
diff --git a/src/rules.h b/src/rules.h
index 9205b86..42e8285 100644
--- a/src/rules.h
+++ b/src/rules.h
@@ -138,6 +138,7 @@ extern SolverRuleinfo solver_ruleclass(struct _Solver *solv, Id rid);
extern void solver_ruleliterals(struct _Solver *solv, Id rid, Queue *q);
extern int solver_rule2jobidx(struct _Solver *solv, Id rid);
extern Id solver_rule2job(struct _Solver *solv, Id rid, Id *whatp);
+extern Id solver_rule2solvable(struct _Solver *solv, Id rid);
#ifdef __cplusplus
diff --git a/src/solver.c b/src/solver.c
index a846477..eb4afde 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -4025,11 +4025,7 @@ solver_describe_decision(Solver *solv, Id p, Id *infop)
if (i < solv->decisioncnt_update)
{
if (i == 0)
- {
- if (infop)
- *infop = SYSTEMSOLVABLE;
- return SOLVER_REASON_KEEP_INSTALLED;
- }
+ return SOLVER_REASON_KEEP_INSTALLED;
if (infop)
*infop = why;
return SOLVER_REASON_RESOLVE_JOB;
@@ -4039,12 +4035,7 @@ solver_describe_decision(Solver *solv, Id p, Id *infop)
if (why == 0 && pp < 0)
return SOLVER_REASON_CLEANDEPS_ERASE;
if (infop)
- {
- if (why >= solv->updaterules && why < solv->updaterules_end)
- *infop = why - solv->updaterules;
- else if (why >= solv->featurerules && why < solv->featurerules_end)
- *infop = why - solv->featurerules;
- }
+ *infop = why;
return SOLVER_REASON_UPDATE_INSTALLED;
}
if (i < solv->decisioncnt_resolve)
@@ -4052,12 +4043,7 @@ solver_describe_decision(Solver *solv, Id p, Id *infop)
if (why == 0 && pp < 0)
return SOLVER_REASON_CLEANDEPS_ERASE;
if (infop)
- {
- if (why >= solv->updaterules && why < solv->updaterules_end)
- *infop = why - solv->updaterules;
- else if (why >= solv->featurerules && why < solv->featurerules_end)
- *infop = why - solv->featurerules;
- }
+ *infop = why;
return SOLVER_REASON_KEEP_INSTALLED;
}
if (i < solv->decisioncnt_weak)