ref: refs/heads/master commit 989acc8280ba2bc229acfb62c01143552b386e00 Author: Klaus Kämpf <kkaempf@suse.de> Date: Sat Jun 20 07:37:59 2009 +0200 Adapt to new solver api for Jobs and Problems new requests: update and lock prepare for more satsolver-like problem/solution handling --- applayer/request.c | 38 ++++-------------------- applayer/request.h | 10 ++---- bindings/job.i | 30 ++++++++++++++---- bindings/problem.i | 26 +++++++++------- bindings/request.i | 80 +++++++++++++++++++++++++++++++++++++++++++++++---- bindings/solution.i | 7 ++++ 6 files changed, 128 insertions(+), 63 deletions(-) diff --git a/applayer/request.c b/applayer/request.c index b82206f..fe0425e 100644 --- a/applayer/request.c +++ b/applayer/request.c @@ -47,52 +47,26 @@ request_size( Request *t ) void -request_install_xsolvable( Request *t, XSolvable *xs ) +request_xsolvable( Request *t, XSolvable *xs, int what ) { - queue_push( &(t->queue), SOLVER_INSTALL|SOLVER_SOLVABLE ); + queue_push( &(t->queue), what|SOLVER_SOLVABLE ); /* FIXME: check: s->repo->pool == $self->pool */ queue_push( &(t->queue), xs->id ); } void -request_remove_xsolvable( Request *t, XSolvable *xs ) +request_name( Request *t, const char *name, int what ) { - queue_push( &(t->queue), SOLVER_ERASE|SOLVER_SOLVABLE ); - /* FIXME: check: s->repo->pool == $self->pool */ - queue_push( &(t->queue), xs->id ); -} - - -void -request_install_name( Request *t, const char *name ) -{ - queue_push( &(t->queue), SOLVER_INSTALL|SOLVER_SOLVABLE_NAME ); - queue_push( &(t->queue), str2id( t->pool, name, 1 )); -} - - -void -request_remove_name( Request *t, const char *name ) -{ - queue_push( &(t->queue), SOLVER_ERASE|SOLVER_SOLVABLE_NAME ); + queue_push( &(t->queue), what|SOLVER_SOLVABLE_NAME ); queue_push( &(t->queue), str2id( t->pool, name, 1 )); } void -request_install_relation( Request *t, const Relation *rel ) -{ - queue_push( &(t->queue), SOLVER_INSTALL|SOLVER_SOLVABLE_PROVIDES ); - /* FIXME: check: rel->pool == $self->pool */ - queue_push( &(t->queue), rel->id ); -} - - -void -request_remove_relation( Request *t, const Relation *rel ) +request_relation( Request *t, const Relation *rel, int what ) { - queue_push( &(t->queue), SOLVER_ERASE|SOLVER_SOLVABLE_PROVIDES ); + queue_push( &(t->queue), what|SOLVER_SOLVABLE_PROVIDES ); /* FIXME: check: rel->pool == $self->pool */ queue_push( &(t->queue), rel->id ); } diff --git a/applayer/request.h b/applayer/request.h index 777221e..e411d9f 100644 --- a/applayer/request.h +++ b/applayer/request.h @@ -27,12 +27,10 @@ typedef struct _Request { Request *request_new( Pool *pool ); void request_free( Request *t ); -void request_install_xsolvable( Request *t, XSolvable *xs ); -void request_remove_xsolvable( Request *t, XSolvable *xs ); -void request_install_name( Request *t, const char *name ); -void request_remove_name( Request *t, const char *name ); -void request_install_relation( Request *t, const Relation *rel ); -void request_remove_relation( Request *t, const Relation *rel ); +void request_xsolvable( Request *t, XSolvable *xs, int what ); +void request_name( Request *t, const char *name, int what ); +void request_relation( Request *t, const Relation *rel, int what ); + int request_size( Request *t ); Job *request_job_get( Request *t, int i ); diff --git a/bindings/job.i b/bindings/job.i index 79868f3..d87ef46 100644 --- a/bindings/job.i +++ b/bindings/job.i @@ -14,13 +14,29 @@ typedef struct _Job {} Job; %extend Job { - %constant int INSTALL_SOLVABLE = SOLVER_INSTALL_SOLVABLE; - %constant int REMOVE_SOLVABLE = SOLVER_ERASE_SOLVABLE; - %constant int INSTALL_SOLVABLE_NAME = SOLVER_INSTALL_SOLVABLE_NAME; - %constant int REMOVE_SOLVABLE_NAME = SOLVER_ERASE_SOLVABLE_NAME; - %constant int INSTALL_SOLVABLE_PROVIDES = SOLVER_INSTALL_SOLVABLE_PROVIDES; - %constant int REMOVE_SOLVABLE_PROVIDES = SOLVER_ERASE_SOLVABLE_PROVIDES; - + %constant int INSTALL_SOLVABLE = (SOLVER_INSTALL|SOLVER_SOLVABLE); + %constant int UPDATE_SOLVABLE = (SOLVER_UPDATE|SOLVER_SOLVABLE); + %constant int REMOVE_SOLVABLE = (SOLVER_ERASE|SOLVER_SOLVABLE); + %constant int WEAKEN_SOLVABLE = (SOLVER_WEAKENDEPS|SOLVER_SOLVABLE); + %constant int LOCK_SOLVABLE = (SOLVER_LOCK|SOLVER_SOLVABLE); + + %constant int INSTALL_SOLVABLE_NAME = (SOLVER_INSTALL|SOLVER_SOLVABLE_NAME); + %constant int UPDATE_SOLVABLE_NAME = (SOLVER_UPDATE|SOLVER_SOLVABLE_NAME); + %constant int REMOVE_SOLVABLE_NAME = (SOLVER_ERASE|SOLVER_SOLVABLE_NAME); + %constant int WEAKEN_SOLVABLE_NAME = (SOLVER_WEAKENDEPS|SOLVER_SOLVABLE_NAME); + %constant int LOCK_SOLVABLE_NAME = (SOLVER_LOCK|SOLVER_SOLVABLE_NAME); + + %constant int INSTALL_SOLVABLE_PROVIDES = (SOLVER_INSTALL|SOLVER_SOLVABLE_PROVIDES); + %constant int UPDATE_SOLVABLE_PROVIDES = (SOLVER_UPDATE|SOLVER_SOLVABLE_PROVIDES); + %constant int REMOVE_SOLVABLE_PROVIDES = (SOLVER_ERASE|SOLVER_SOLVABLE_PROVIDES); + %constant int WEAKEN_SOLVABLE_PROVIDES = (SOLVER_WEAKENDEPS|SOLVER_SOLVABLE_PROVIDES); + %constant int LOCK_SOLVABLE_PROVIDES = (SOLVER_LOCK|SOLVER_SOLVABLE_PROVIDES); + + %constant int INSTALL_ONE_OF = (SOLVER_INSTALL|SOLVER_SOLVABLE_ONE_OF); + %constant int UPDATE_ONE_OF = (SOLVER_UPDATE|SOLVER_SOLVABLE_ONE_OF); + %constant int REMOVE_ONE_OF = (SOLVER_ERASE|SOLVER_SOLVABLE_ONE_OF); + %constant int LOCK_ONE_OF = (SOLVER_LOCK|SOLVER_SOLVABLE_ONE_OF); + ~Job() { job_free( $self ); } diff --git a/bindings/problem.i b/bindings/problem.i index 164ec31..ddd3d14 100644 --- a/bindings/problem.i +++ b/bindings/problem.i @@ -37,28 +37,30 @@ 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_PROBLEM_UPDATE_RULE; + %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_PROBLEM_JOB_RULE; + %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_PROBLEM_JOB_NOTHING_PROVIDES_DEP; + %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_PROBLEM_NOT_INSTALLABLE; + %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_PROBLEM_NOTHING_PROVIDES_DEP; + %constant int SOLVER_PROBLEM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP; /* Same name */ - %constant int SOLVER_PROBLEM_SAME_NAME = SOLVER_PROBLEM_SAME_NAME; + %constant int SOLVER_PROBLEM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME; /* Packages conflict */ - %constant int SOLVER_PROBLEM_PACKAGE_CONFLICT = SOLVER_PROBLEM_PACKAGE_CONFLICT; + %constant int SOLVER_PROBLEM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT; /* Package is obsoleted */ - %constant int SOLVER_PROBLEM_PACKAGE_OBSOLETES = SOLVER_PROBLEM_PACKAGE_OBSOLETES; + %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_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE; + %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_PROBLEM_SELF_CONFLICT; + %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_PROBLEM_RPM_RULE; - + %constant int SOLVER_PROBLEM_RPM_RULE = SOLVER_RULE_RPM; + %constant int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE; + %constant int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH; + ~Problem() { problem_free ($self); } diff --git a/bindings/request.i b/bindings/request.i index 901db55..f6cb61d 100644 --- a/bindings/request.i +++ b/bindings/request.i @@ -61,7 +61,7 @@ typedef struct _Request {} Request; * */ void install( XSolvable *xs ) - { request_install_xsolvable( $self, xs ); } + { request_xsolvable( $self, xs, SOLVER_INSTALL ); } /* * Remove request @@ -81,34 +81,102 @@ typedef struct _Request {} Request; * */ void remove( XSolvable *xs ) - { request_remove_xsolvable( $self, xs ); } + { request_xsolvable( $self, xs, SOLVER_ERASE ); } + + /* + * Update request + * + * Ensure update of a solvable by either + * * specifying it directly + * * specify it by name + * * specify a required relation + * + * Except when specified directly, the solver is free to choose any + * solvable matching the request (by name, by relation) + * + * call-seq: + * request.update(solvable) -> void + * request.update("kernel") -> void + * request.update(relation) -> void + * + */ + void update( XSolvable *xs ) + { request_xsolvable( $self, xs, SOLVER_UPDATE ); } + + /* + * Lock request + * + * Ensure solvable stays installed/uninstalled + * * specifying it directly + * * specify it by name + * * specify a required relation + * + * Except when specified directly, the solver is free to choose any + * solvable matching the request (by name, by relation) + * + * call-seq: + * request.lock(solvable) -> void + * request.lock("kernel") -> void + * request.lock(relation) -> void + * + */ + void lock( XSolvable *xs ) + { request_xsolvable( $self, xs, SOLVER_LOCK ); } /* * Install solvable by name */ void install( const char *name ) - { request_install_name( $self, name ); } + { request_name( $self, name, SOLVER_INSTALL ); } /* * Remove solvable by name * */ void remove( const char *name ) - { request_remove_name( $self, name ); } + { request_name( $self, name, SOLVER_ERASE ); } + + /* + * Update solvable by name + * + */ + void update( const char *name ) + { request_name( $self, name, SOLVER_UPDATE ); } + + /* + * Lock solvable by name + * + */ + void lock( const char *name ) + { request_name( $self, name, SOLVER_LOCK ); } /* * Install solvable by relation * */ void install( const Relation *rel ) - { request_install_relation( $self, rel ); } + { request_relation( $self, rel, SOLVER_INSTALL ); } /* * Remove solvable by relation * */ void remove( const Relation *rel ) - { return request_remove_relation( $self, rel ); } + { return request_relation( $self, rel, SOLVER_ERASE ); } + + /* + * Update solvable by relation + * + */ + void update( const Relation *rel ) + { return request_relation( $self, rel, SOLVER_UPDATE ); } + + /* + * Lock solvable by relation + * + */ + void lock( const Relation *rel ) + { return request_relation( $self, rel, SOLVER_LOCK ); } #if defined(SWIGRUBY) %rename("empty?") empty(); diff --git a/bindings/solution.i b/bindings/solution.i index 810a393..599a437 100644 --- a/bindings/solution.i +++ b/bindings/solution.i @@ -2,6 +2,13 @@ * Document-class: Solution * Solutions are attached to Problems and give hints on how to solve problems. * + * Solutions as coming from satsolver are 'raw' as they only tell you + * which jobs to change. Thats either job items to remove (from the + * Request) or new job items to add. + * + * How this relates to the application view is up to the application + * using the bindings. + * * === Constructor * There is no constructor defined for Solution. Solution are part of Problem and can be * accessed through Problem.each_solution -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org