ref: refs/heads/master commit 3e8a11721bbee4be2dacaf5643ba6e0a663c8521 Author: Klaus Kämpf <kkaempf@suse.de> Date: Mon Jun 22 16:20:30 2009 +0200 Make problem/solution handling less ZyPPish --- applayer/CMakeLists.txt | 4 +- applayer/applayer.c | 10 ++-- applayer/applayer.h | 6 +- applayer/job.c | 18 ++---- applayer/job.h | 23 +++++-- applayer/problem.c | 153 ++++++++++++----------------------------------- applayer/problem.h | 15 +++-- applayer/relation.c | 2 +- applayer/relation.h | 4 +- applayer/ruleinfo.c | 2 +- applayer/solution.c | 17 +++--- applayer/solution.h | 30 ++------- applayer/xsolvable.c | 26 ++++---- applayer/xsolvable.h | 16 +++--- bindings/job.i | 1 + bindings/problem.i | 54 ++++++++++------- 16 files changed, 151 insertions(+), 230 deletions(-) diff --git a/applayer/CMakeLists.txt b/applayer/CMakeLists.txt index ac6bfcb..af4e96d 100644 --- a/applayer/CMakeLists.txt +++ b/applayer/CMakeLists.txt @@ -5,12 +5,12 @@ ADD_SUBDIRECTORY(tests) SET(libappsatsolver_SRCS job.c applayer.c covenant.c decision.c dependency.c - kinds.c problem.c relation.c solution.c request.c xrepokey.c xsolvable.c) + kinds.c problem.c relation.c ruleinfo.c solution.c request.c xrepokey.c xsolvable.c) ADD_LIBRARY(appsatsolver STATIC ${libappsatsolver_SRCS}) SET(libappsatsolver_HEADERS job.h applayer.h covenant.h decision.h dependency.h - kinds.h problem.h relation.h solution.h request.h xrepokey.h xsolvable.h) + kinds.h problem.h relation.h solution.h request.h ruleinfo.h xrepokey.h xsolvable.h) SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -Werror" ) diff --git a/applayer/applayer.c b/applayer/applayer.c index d983dc4..6aeef6a 100644 --- a/applayer/applayer.c +++ b/applayer/applayer.c @@ -15,7 +15,7 @@ #include "applayer.h" const char * -my_id2str( Pool *pool, Id id ) +my_id2str( const Pool *pool, Id id ) { if (id == STRID_NULL) return NULL; @@ -25,9 +25,9 @@ my_id2str( Pool *pool, Id id ) } unsigned int -pool_xsolvables_count( Pool *pool ) +pool_xsolvables_count( const Pool *pool ) { - Solvable *s; + const Solvable *s; Id p; int count = 0; /* skip Id 0 since it is reserved @@ -47,9 +47,9 @@ pool_xsolvables_count( Pool *pool ) } void -pool_xsolvables_iterate( Pool *pool, int (*callback)(const XSolvable *xs, void *user_data), void *user_data) +pool_xsolvables_iterate( const Pool *pool, int (*callback)(const XSolvable *xs, void *user_data), void *user_data) { - Solvable *s; + const Solvable *s; Id p; /* skip Id 0 and Id 1, see pool_count() above */ for (p = 2, s = pool->solvables + p; p < pool->nsolvables; p++, s++) diff --git a/applayer/applayer.h b/applayer/applayer.h index 5a49aa5..a097270 100644 --- a/applayer/applayer.h +++ b/applayer/applayer.h @@ -25,14 +25,14 @@ * */ -const char *my_id2str( Pool *pool, Id id ); +const char *my_id2str( const Pool *pool, Id id ); /************************************************ * Pool * */ -unsigned int pool_xsolvables_count( Pool *pool ); -void pool_xsolvables_iterate( Pool *pool, int (*callback)(const XSolvable *xs, void *user_data), void *user_data); +unsigned int pool_xsolvables_count( const Pool *pool ); +void pool_xsolvables_iterate( const Pool *pool, int (*callback)(const XSolvable *xs, void *user_data), void *user_data); #endif /* SATSOLVER_APPLAYER_H */ diff --git a/applayer/job.c b/applayer/job.c index 2590bd0..d7e9b20 100644 --- a/applayer/job.c +++ b/applayer/job.c @@ -18,7 +18,7 @@ #include "applayer.h" Job * -job_new( Pool *pool, Id cmd, Id id ) +job_new( const Pool *pool, Id cmd, Id id ) { Job *job = (Job *)malloc( sizeof( Job )); job->pool = pool; @@ -36,11 +36,9 @@ job_free( Job *j ) XSolvable * -job_xsolvable( Job *j ) +job_xsolvable( const Job *j ) { - if (j->cmd == SOLVER_INSTALL_SOLVABLE - || j->cmd == SOLVER_ERASE_SOLVABLE) - { + if (j->cmd & SOLVER_SOLVABLE) { return xsolvable_new( j->pool, j->id ); } return NULL; @@ -48,10 +46,9 @@ job_xsolvable( Job *j ) const char * -job_name( Job *j ) +job_name( const Job *j ) { - if (j->cmd == SOLVER_INSTALL_SOLVABLE_NAME - || j->cmd == SOLVER_ERASE_SOLVABLE_NAME) + if (j->cmd & SOLVER_SOLVABLE_NAME) { return my_id2str( j->pool, j->id ); } @@ -60,10 +57,9 @@ job_name( Job *j ) Relation * -job_relation( Job *j ) +job_relation( const Job *j ) { - if (j->cmd == SOLVER_INSTALL_SOLVABLE_PROVIDES - || j->cmd == SOLVER_ERASE_SOLVABLE_PROVIDES) + if (j->cmd == SOLVER_SOLVABLE_PROVIDES) { return relation_new( j->pool, j->id ); } diff --git a/applayer/job.h b/applayer/job.h index bc7e5e7..d1fd677 100644 --- a/applayer/job.h +++ b/applayer/job.h @@ -10,6 +10,9 @@ * * A single 'job' item of a Request * + * Internally, a Job is translated to a solver rule. Thus, solver + * problems will only reference bad rules. + * */ @@ -23,17 +26,23 @@ #include "relation.h" typedef struct _Job { - Pool *pool; - Id cmd; - Id id; + const Pool *pool; + int cmd; /* solver queue command */ + Id id; /* Id of Name, Relation, or Solvable */ } Job; -Job *job_new( Pool *pool, Id cmd, Id id ); +Job *job_new( const Pool *pool, int cmd, Id id ); void job_free( Job *j ); -XSolvable *job_xsolvable( Job *j ); -const char *job_name( Job *j ); -Relation *job_relation( Job *j ); + +/* Return Solvable (or NULL if job doesn't affect Solvable) */ +XSolvable *job_xsolvable( const Job *j ); + +/* Return Name (or NULL if job doesn't affect Name) */ +const char *job_name( const Job *j ); + +/* Return Relation (or NULL if job doesn't affect Relation) */ +Relation *job_relation( const Job *j ); #endif /* SATSOLVER_JOB_H */ diff --git a/applayer/problem.c b/applayer/problem.c index 9ab2434..a211aa1 100644 --- a/applayer/problem.c +++ b/applayer/problem.c @@ -19,20 +19,17 @@ #include <policy.h> #include "problem.h" +#include "solution.h" #include "evr.h" Problem * problem_new( Solver *s, Request *t, Id id ) { - Id prule; - Problem *p = (Problem *)malloc( sizeof( Problem )); p->solver = s; p->request = t; p->id = id; - prule = solver_findproblemrule( s, id ); - p->reason = solver_problemruleinfo( s, &(t->queue), prule, &(p->relation), &(p->source), &(p->target) ); return p; } @@ -66,122 +63,48 @@ problem_solutions_iterate( Problem *problem, int (*callback)( const Solution *s, return; Id solution = 0; + while ((solution = solver_next_solution( problem->solver, problem->id, solution )) != 0) { - Id p, rp, element, what; + Id p, rp, element = 0; + - Id s1, s2, n1, n2; - int code = SOLUTION_UNKNOWN; - - Solver *solver = problem->solver; - Pool *pool = solver->pool; - element = 0; - s1 = s2 = n1 = n2 = 0; + /* from src/problems.c: + * + * return the next item of the proposed solution + * here are the possibilities for p / rp and what + * the solver expects the application to do: + * p rp + * ------------------------------------------------------- + * SOLVER_SOLUTION_INFARCH pkgid + * -> add (SOLVER_INSTALL|SOLVER_SOLVABLE, rp) to the job + * + * SOLVER_SOLUTION_DISTUPGRADE pkgid + * -> add (SOLVER_INSTALL|SOLVER_SOLVABLE, rp) to the job + * + * SOLVER_SOLUTION_JOB jobidx + * -> remove job (jobidx - 1, jobidx) from job queue + * + * pkgid (> 0) 0 + * -> add (SOLVER_ERASE|SOLVER_SOLVABLE, p) to the job + * + * pkgid (> 0) pkgid (> 0) + * -> add (SOLVER_INSTALL|SOLVER_SOLVABLE, rp) to the job + * (this will replace package p) + * + * Thus, the solver will either ask the application to remove + * a specific job from the job queue, or ask to add an install/erase + * job to it. + * + */ - while ((element = solver_next_solutionelement( solver, problem->id, solution, element, &p, &rp)) != 0) + while ((element = solver_next_solutionelement( problem->solver, problem->id, solution, element, &p, &rp)) != 0) { - if (p == 0) - { - - /* job, rp is index into job queue */ - what = solver->job.elements[rp]; - - switch (solver->job.elements[rp - 1]) - { - case SOLVER_INSTALL_SOLVABLE: - s1 = what; - if (solver->installed - && (pool->solvables + s1)->repo == solver->installed) - { - code = SOLUTION_NOKEEP_INSTALLED; /* s1 */ - } - else - { - code = SOLUTION_NOINSTALL_SOLV; /* s1 */ - } - break; - case SOLVER_ERASE_SOLVABLE: - s1 = what; - if (solver->installed - && (pool->solvables + s1)->repo == solver->installed) - { - code = SOLUTION_NOREMOVE_SOLV; /* s1 */ - } - else - { - code = SOLUTION_NOFORBID_INSTALL; /* s1 */ - } - break; - case SOLVER_INSTALL_SOLVABLE_NAME: - n1 = what; - code = SOLUTION_NOINSTALL_NAME; /* n1 */ - break; - case SOLVER_ERASE_SOLVABLE_NAME: - n1 = what; - code = SOLUTION_NOREMOVE_NAME; /* n1 */ - break; - case SOLVER_INSTALL_SOLVABLE_PROVIDES: - n1 = what; - code = SOLUTION_NOINSTALL_REL; /* r1 */ - break; - case SOLVER_ERASE_SOLVABLE_PROVIDES: - n1 = what; - code = SOLUTION_NOREMOVE_REL; /* r1 */ - break; - case SOLVER_INSTALL_SOLVABLE_UPDATE: - s1 = what; - code = SOLUTION_NOUPDATE; - break; - default: - code = SOLUTION_UNKNOWN; - break; - } - } - else - { - s1 = p; - s2 = rp; - if (p < 0) - p = rp; - /* policy, replace p with rp */ - Solvable *sp = pool->solvables + p; - Solvable *sr = rp ? pool->solvables + rp : 0; - if (sr) - { - if (!solver->allowdowngrade - && evrcmp( pool, sp->evr, sr->evr, EVRCMP_MATCH_RELEASE ) > 0) - { - code = SOLUTION_ALLOW_DOWNGRADE; - } - else if (!solver->allowarchchange - && sp->name == sr->name - && sp->arch != sr->arch - && policy_illegal_archchange(solver, sp, sr ) ) - { - code = SOLUTION_ALLOW_ARCHCHANGE; /* s1, s2 */ - } - else if (!solver->allowvendorchange - && sp->name == sr->name - && sp->vendor != sr->vendor - && policy_illegal_vendorchange( solver, sp, sr ) ) - { - n1 = sp->vendor; - n2 = sr->vendor; - code = SOLUTION_ALLOW_VENDORCHANGE; - } - else - { - code = SOLUTION_ALLOW_REPLACEMENT; - } - } - else - { - code = SOLUTION_ALLOW_REMOVE; /* s1 */ - } - } + Solution *s = solution_new( problem, solution, p, rp ); + int result = callback( s, user_data ); + solution_free(s); + if (result) + break; } - Solution *s = solution_new( problem->solver->pool, code, s1, n1, s2, n2 ); - if (callback( s, user_data )) - break; } } diff --git a/applayer/problem.h b/applayer/problem.h index bfb7b0f..25f0d2f 100644 --- a/applayer/problem.h +++ b/applayer/problem.h @@ -19,24 +19,25 @@ */ #include "solver.h" +#include "job.h" #include "request.h" -#include "solution.h" typedef struct _Problem { Solver *solver; Request *request; - Id id; /* [PRIVATE] problem id */ - SolverRuleinfo reason; - Id source; /* solvable id */ - Id relation; /* relation id */ - Id target; /* solvable id */ + Id id; /* problem id */ } Problem; Problem *problem_new( Solver *s, Request *t, Id id ); void problem_free( Problem *p ); void solver_problems_iterate( Solver *solver, Request *t, int (*callback)( const Problem *p, void *user_data ), void *user_data ); -void problem_solutions_iterate( Problem *p, int (*callback)( const Solution *s, void *user_data ), void *user_data ); + +/* loop over Jobs leading to the problem */ +void problem_jobs_iterate( Problem *p, int (*callback)( const Job *j, void *user_data ), void *user_data ); + +struct _Solution; /* forward decl, cannot include solution.h due to cycles */ +void problem_solutions_iterate( Problem *p, int (*callback)( const struct _Solution *s, void *user_data ), void *user_data ); #endif /* SATSOLVER_PROBLEM_H */ diff --git a/applayer/relation.c b/applayer/relation.c index 598b460..4ac2a25 100644 --- a/applayer/relation.c +++ b/applayer/relation.c @@ -16,7 +16,7 @@ Relation * -relation_new( Pool *pool, Id id ) +relation_new( const Pool *pool, Id id ) { Relation *relation; if (!id) return NULL; diff --git a/applayer/relation.h b/applayer/relation.h index 90c9647..b1fab4f 100644 --- a/applayer/relation.h +++ b/applayer/relation.h @@ -19,10 +19,10 @@ typedef struct _Relation { Offset id; - Pool *pool; + const Pool *pool; } Relation; -Relation *relation_new( Pool *pool, Id id ); +Relation *relation_new( const Pool *pool, Id id ); Relation *relation_create( Pool *pool, const char *name, int op, const char *evr ); void relation_free( Relation *r ); Id relation_evrid( const Relation *r ); diff --git a/applayer/ruleinfo.c b/applayer/ruleinfo.c index 1e13601..3fa45a8 100644 --- a/applayer/ruleinfo.c +++ b/applayer/ruleinfo.c @@ -24,7 +24,7 @@ ruleinfo_new( const Solver *solver, Id rule ) { Ruleinfo *ri = (Ruleinfo *)calloc( 1, sizeof( Ruleinfo )); ri->solver = solver; - ri->cmd = solver_ruleinfo(solver, rule, &(ri->source), &(ri->target), &(ri->dep)); + ri->cmd = solver_ruleinfo((Solver *)solver, rule, &(ri->source), &(ri->target), &(ri->dep)); return ri; } diff --git a/applayer/solution.c b/applayer/solution.c index 7ab9cda..5b83834 100644 --- a/applayer/solution.c +++ b/applayer/solution.c @@ -21,18 +21,17 @@ Solution * -solution_new( Pool *pool, int solution, Id s1, Id n1, Id s2, Id n2 ) +solution_new( const Problem *problem, Id s, Id p, Id rp ) { - Solution *s = (Solution *)malloc( sizeof( Solution )); - s->pool = pool; - s->solution = solution; - s->s1 = s1; - s->n1 = n1; - s->s2 = s2; - s->n2 = n2; - return s; + Solution *solution = (Solution *)malloc( sizeof( Solution )); + solution->problem = problem; + solution->s = s; + solution->p = p; + solution->rp = rp; + return solution; } + void solution_free( Solution *s ) { diff --git a/applayer/solution.h b/applayer/solution.h index 0a6d978..98fd943 100644 --- a/applayer/solution.h +++ b/applayer/solution.h @@ -20,34 +20,16 @@ #include "pool.h" -enum solutions { - SOLUTION_UNKNOWN = 0, - SOLUTION_NOKEEP_INSTALLED, - SOLUTION_NOINSTALL_SOLV, - SOLUTION_NOREMOVE_SOLV, - SOLUTION_NOFORBID_INSTALL, - SOLUTION_NOINSTALL_NAME, - SOLUTION_NOREMOVE_NAME, - SOLUTION_NOINSTALL_REL, - SOLUTION_NOREMOVE_REL, - SOLUTION_NOUPDATE, - SOLUTION_ALLOW_DOWNGRADE, - SOLUTION_ALLOW_ARCHCHANGE, - SOLUTION_ALLOW_VENDORCHANGE, - SOLUTION_ALLOW_REPLACEMENT, - SOLUTION_ALLOW_REMOVE -}; +#include "problem.h" typedef struct _Solution { - Pool *pool; - enum solutions solution; - Id s1; - Id n1; - Id s2; - Id n2; + const Problem *problem; + Id s; /* solution set id. */ + Id p; + Id rp; } Solution; -Solution *solution_new( Pool *pool, int solution, Id s1, Id n1, Id s2, Id n2 ); +Solution *solution_new( const Problem *problem, Id s, Id p, Id rp ); void solution_free( Solution *s ); #endif /* SATSOLVER_SOLUTION_H */ diff --git a/applayer/xsolvable.c b/applayer/xsolvable.c index eedb12e..ed1ca08 100644 --- a/applayer/xsolvable.c +++ b/applayer/xsolvable.c @@ -26,7 +26,7 @@ XSolvable * -xsolvable_new( Pool *pool, Id id ) +xsolvable_new( const Pool *pool, Id id ) { if (id) { XSolvable *xsolvable = (XSolvable *)malloc( sizeof( XSolvable )); @@ -82,7 +82,7 @@ xsolvable_solvable( const XSolvable *xs ) */ int -xsolvable_equal( XSolvable *xs1, XSolvable *xs2 ) +xsolvable_equal( const XSolvable *xs1, const XSolvable *xs2 ) { /* fprintf(stderr, "%p[%p/%d] == %p[%p/%d] ?\n", xs1, xs1->pool, xs1->id, xs2, xs2->pool, xs2->id); */ if ((xs1 == xs2) @@ -109,7 +109,7 @@ copy_deps( Repo *repo, Offset *ndeps, Id *odeps ) */ XSolvable * -xsolvable_add( Repo *repo, XSolvable *xs ) +xsolvable_add( Repo *repo, const XSolvable *xs ) { Id sid; Solvable *old_s, *new_s; @@ -146,14 +146,16 @@ xsolvable_add( Repo *repo, XSolvable *xs ) */ XSolvable * -xsolvable_find( Pool *pool, char *name, const Repo *repo ) +xsolvable_find( Pool *pool, const char *name, const Repo *repo ) { Id id; Queue plist; int i, end; Solvable *s; - id = str2id( pool, name, 1 ); + id = str2id( (Pool *)pool, name, 0 ); + if (id == ID_NULL) + return NULL; /* 'name' unknown in pool */ queue_init( &plist); i = repo ? repo->start : 1; end = repo ? repo->start + repo->nsolvables : pool->nsolvables; @@ -189,7 +191,7 @@ xsolvable_find( Pool *pool, char *name, const Repo *repo ) */ XSolvable * -xsolvable_get( Pool *pool, int i, const Repo *repo ) +xsolvable_get( const Pool *pool, int i, const Repo *repo ) { if (repo == NULL) i += 2; /* adapt to internal Id, see size() above */ @@ -230,7 +232,7 @@ solver_installs_iterate( Solver *solver, int all, int (*callback)( const XSolvab // getting repo s = solver->pool->solvables + p; - Repo *repo = s->repo; + const Repo *repo = s->repo; if (!repo || repo == installed) continue; /* already installed resolvable */ @@ -253,7 +255,7 @@ solver_removals_iterate( Solver *solver, int all, int (*callback)( const XSolvab Id p; Solvable *s; Id *obsoletesmap = NULL; - Repo *installed = solver->installed; /* repo of installed solvables */ + const Repo *installed = solver->installed; /* repo of installed solvables */ if (!callback) return; @@ -289,7 +291,7 @@ solver_updates_iterate( Solver *solver, int (*callback)( const XSolvable *xs_old Id p; Solvable *s; Id *obsoletesmap = NULL; - Repo *installed = solver->installed; /* repo of installed solvables */ + const Repo *installed = solver->installed; /* repo of installed solvables */ if (!callback) return; @@ -314,7 +316,7 @@ solver_updates_iterate( Solver *solver, int (*callback)( const XSolvable *xs_old void -solver_suggestions_iterate( Solver *solver, int (*callback)( const XSolvable *xs, void *user_data ), void *user_data ) +solver_suggestions_iterate( const Solver *solver, int (*callback)( const XSolvable *xs, void *user_data ), void *user_data ) { int i; @@ -335,7 +337,7 @@ solver_suggestions_iterate( Solver *solver, int (*callback)( const XSolvable *xs */ int -repo_xsolvables_count( Repo *repo ) +repo_xsolvables_count( const Repo *repo ) { Solvable *s; Id p; @@ -357,7 +359,7 @@ repo_xsolvables_count( Repo *repo ) */ void -repo_xsolvables_iterate( Repo *repo, int (*callback)( const XSolvable *xs, void *user_data ), void *user_data ) +repo_xsolvables_iterate( const Repo *repo, int (*callback)( const XSolvable *xs, void *user_data ), void *user_data ) { Solvable *s; Id p; diff --git a/applayer/xsolvable.h b/applayer/xsolvable.h index e857137..28875da 100644 --- a/applayer/xsolvable.h +++ b/applayer/xsolvable.h @@ -28,7 +28,7 @@ */ typedef struct _xsolvable { - Pool *pool; + const Pool *pool; Id id; unsigned int kind; /* one of KIND_xxx */ } XSolvable; @@ -36,7 +36,7 @@ typedef struct _xsolvable { /* * Create a new XSolvable in pool from Solvable id */ -XSolvable *xsolvable_new( Pool *pool, Id id ); +XSolvable *xsolvable_new( const Pool *pool, Id id ); /* * Create a new XSolvable in pool from name, evr, arch @@ -52,7 +52,7 @@ void xsolvable_free( XSolvable *xs ); * Check for equality * Two XSolvables are equal if they both reference the same Id of the same pool. */ -int xsolvable_equal( XSolvable *xs1, XSolvable *xs2 ); +int xsolvable_equal( const XSolvable *xs1, const XSolvable *xs2 ); /* * Return the Solvable corresponding to the given XSolvable @@ -62,14 +62,14 @@ Solvable *xsolvable_solvable( const XSolvable *xs ); /* * Add an existing solvable to Repo */ -XSolvable *xsolvable_add( Repo *repo, XSolvable *xs ); +XSolvable *xsolvable_add( Repo *repo, const XSolvable *xs ); /* * Find XSolvable by name in pool (and repo) * If repo == NULL, search the complete pool * If repo != NULL, limit search to the given repo */ -XSolvable *xsolvable_find( Pool *pool, char *name, const Repo *repo ); +XSolvable *xsolvable_find( Pool *pool, const char *name, const Repo *repo ); /* iterate over all (newly-)to-be-installed solvables * if all = 0, only report *newly* installed ones (non-updates) @@ -91,17 +91,17 @@ void solver_updates_iterate( Solver *solver, int (*callback)( const XSolvable *x /* * Iterate over all solvables being suggested in the last solver run */ -void solver_suggestions_iterate( Solver *solver, int (*callback)( const XSolvable *xs, void *user_data ), void *user_data ); +void solver_suggestions_iterate( const Solver *solver, int (*callback)( const XSolvable *xs, void *user_data ), void *user_data ); /* * Count solvables in a Repo * This is the number of iterations when calling repo_xsolvables_iterate for this Repo */ -int repo_xsolvables_count( Repo *repo ); +int repo_xsolvables_count( const Repo *repo ); /* * Iterate over all solvables of the given repo */ -void repo_xsolvables_iterate( Repo *repo, int (*callback)( const XSolvable *xs, void *user_data ), void *user_data ); +void repo_xsolvables_iterate( const Repo *repo, int (*callback)( const XSolvable *xs, void *user_data ), void *user_data ); #endif /* SATSOLVER_XSOLVABLE_H */ diff --git a/bindings/job.i b/bindings/job.i index d87ef46..ba48574 100644 --- a/bindings/job.i +++ b/bindings/job.i @@ -45,6 +45,7 @@ typedef struct _Job {} Job; XSolvable *solvable() { return job_xsolvable( $self ); } + const char *name() { return job_name( $self ); } diff --git a/bindings/problem.i b/bindings/problem.i index ddd3d14..4c3829d 100644 --- a/bindings/problem.i +++ b/bindings/problem.i @@ -14,6 +14,21 @@ %{ /* + * iterating over problem causes ('yield' in Ruby) + */ + +static int +problem_rules_iterate_callback(const Rule *r, void *user_data) +{ +#if defined(SWIGRUBY) + /* FIXME: how to pass 'break' back to the caller ? */ + rb_yield( SWIG_NewPointerObj((void*) r, SWIGTYPE_p__Rule, 0) ); +#endif + return 0; +} + + +/* * iterating over problem solutions ('yield' in Ruby) */ @@ -36,30 +51,23 @@ typedef struct _Problem {} Problem; %extend Problem { - /* The problem is caused by an update rule (i.e. 'better' Solvable available) */ - %constant int SOLVER_PROBLEM_UPDATE_RULE = SOLVER_RULE_UPDATE; - /* The problem is caused by a Job inside the Request */ - %constant int SOLVER_PROBLEM_JOB_RULE = SOLVER_RULE_JOB; - /* A Job based on a Relation could not be fulfilled because there is no Solvable in the Pool providing it. */ - %constant int SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP; - /* The Solvable is not installable (wrong architecture, etc.) */ - %constant int SOLVER_PROBLEM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE; - /* A requirement could not be fulfilled because there is no Solvable in the Pool providing it. */ - %constant int SOLVER_PROBLEM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP; - /* Same name */ - %constant int SOLVER_PROBLEM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME; - /* Packages conflict */ - %constant int SOLVER_PROBLEM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT; - /* Package is obsoleted */ - %constant int SOLVER_PROBLEM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES; - /* A requirement is fulfilled by an uninstallable Solvable */ - %constant int SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE = SOLVER_RULE_RPM_PACKAGE_REQUIRES; - /* The Solvable conflicts with itself. */ - %constant int SOLVER_PROBLEM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT; - /* A dependency of an already installed Solvable could not be fulfilled (broken system) */ - %constant int SOLVER_PROBLEM_RPM_RULE = SOLVER_RULE_RPM; + + %constant int SOLVER_RULE_RPM = SOLVER_RULE_RPM; + %constant int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE, + %constant int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP, + %constant int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES, + %constant int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT, + %constant int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT, + %constant int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME, + %constant int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES, + %constant int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES, + %constant int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE = 0x200, + %constant int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE = 0x300, + %constant int SOLVER_RULE_JOB = SOLVER_RULE_JOB = 0x400, + %constant int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP, %constant int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE; %constant int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH; + %constant int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT; ~Problem() { problem_free ($self); } @@ -77,7 +85,7 @@ typedef struct _Problem {} Problem; { return $self->request; } /* - * The reason for the problem. One of +Satsolver::SOLVER_PROBLEM_*+ + * The reason for the problem. One of +Satsolver::SOLVER_RULE_*+ * */ int reason() -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org