Author: kkaempf Date: Thu Jan 3 16:21:42 2008 New Revision: 8185 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8185&view=rev Log: cleanup and documentation Modified: trunk/sat-solver/bindings/ruby/tests/action.rb trunk/sat-solver/bindings/ruby/tests/decisions.rb trunk/sat-solver/bindings/ruby/tests/loading.rb trunk/sat-solver/bindings/ruby/tests/pool.rb trunk/sat-solver/bindings/ruby/tests/problems.rb trunk/sat-solver/bindings/ruby/tests/relation.rb trunk/sat-solver/bindings/ruby/tests/repo.rb trunk/sat-solver/bindings/ruby/tests/rpmdb.rb trunk/sat-solver/bindings/ruby/tests/solutions.rb trunk/sat-solver/bindings/satsolver.i Modified: trunk/sat-solver/bindings/ruby/tests/action.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/action.rb?rev=8185&r1=8184&r2=8185&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/action.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/action.rb Thu Jan 3 16:21:42 2008 @@ -1,3 +1,32 @@ +# +# Solving dependencies needs 'something to do' +# +# This is specified via Actions, collected in an Transaction. +# +# You should NOT create Actions manually, but via the Transaction +# class. See Transaction for details. +# +# An Action consist of +# - a command (action.cmd) +# - a name, solvable or relation id (action.id), depending on the command +# +# The command is one of +# INSTALL_SOLVABLE +# install a specific solvable, id specifies a solvable +# REMOVE_SOLVABLE; +# remove a specific solvable, id specifies a solvable +# INSTALL_SOLVABLE_NAME +# install a solvable by name, id specifies a name +# REMOVE_SOLVABLE_NAME +# remove a solvable by name, id specifies a name +# INSTALL_SOLVABLE_PROVIDES +# install a solvable by provides, id specifies a relation the solvable must provide +# REMOVE_SOLVABLE_PROVIDES +# remove a solvable by provides, id specifies a relation the solvable must provide +# +# + + $: << "../../../build/bindings/ruby" # test Action require 'test/unit' Modified: trunk/sat-solver/bindings/ruby/tests/decisions.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/decisions.rb?rev=8185&r1=8184&r2=8185&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/decisions.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/decisions.rb Thu Jan 3 16:21:42 2008 @@ -1,3 +1,24 @@ +# +# After successful solving, the solver returns the result as list of Decisions. +# +# A Decision consitst of +# - an operation (see below) +# - a solvable (affected by the operation) +# - a reason (the reason for the decision) +# +# Operation can be one of +# - DEC_INSTALL +# install solvable, required by 'reason' (if reason is set) +# - DEC_REMOVE +# remove solvable, updated/obsoleted/conflicted by 'reason' (if reason is set) +# - DEC_OBSOLETE +# auto-remove solvable through an obsoletes/update coming from 'reason' +# - DEC_UPDATE +# install solvable, thereby updating 'reason' +# +# The number of decision steps is available through Solver.decision_count +# + $: << "../../../build/bindings/ruby" # test Decisions require 'test/unit' Modified: trunk/sat-solver/bindings/ruby/tests/loading.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/loading.rb?rev=8185&r1=8184&r2=8185&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/loading.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/loading.rb Thu Jan 3 16:21:42 2008 @@ -1,3 +1,7 @@ +# +# Test loading of the bindings +# + $: << "../../../build/bindings/ruby" # test loading of extension require 'test/unit' Modified: trunk/sat-solver/bindings/ruby/tests/pool.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/pool.rb?rev=8185&r1=8184&r2=8185&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/pool.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/pool.rb Thu Jan 3 16:21:42 2008 @@ -1,3 +1,19 @@ +# +# The Pool is the main data structure for sat-solver. +# +# It contains all solvables, grouped by Repo(sitorie)s +# and is needed to create instances of other classes. +# +# For Solvable, Repo, Transaction, Solver and Relation, +# Pool provides create_... methods as counterparts to +# the instance contructors, all requiring a Pool argument. +# +# The main object within a Pool is the Solvable. So Pool.size, +# Pool.each, Pool.get (resp. Pool[]) and Pool.find all operate +# on Solvables. +# +# For Repos there is each_repo, count_repos, get_repo and find_repo. +# $: << "../../../build/bindings/ruby" # test Pool require 'test/unit' Modified: trunk/sat-solver/bindings/ruby/tests/problems.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/problems.rb?rev=8185&r1=8184&r2=8185&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/problems.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/problems.rb Thu Jan 3 16:21:42 2008 @@ -1,3 +1,44 @@ +# +# In case the Solver cannot find a solution (Solver.problems? true), +# it reports Problems through Solver.each_problem. +# +# There is no 'problem count' provided by the Solver, only the +# existance of problems is reported via Solver.problems? +# +# Linked to each problem is a set of solutions, accessible +# through Problem.each_solution +# +# Each problem contains +# - a problem identifier (Problem.id) +# - a reason code (Problem.reason) +# see below +# - a source identifier +# - a relation identifier +# - a target identifier +# +# The identifiers can have various meanings (name, relation, solvable), depending +# on the reason. +# +# The following reasons are defined +# SOLVER_PROBLEM_UPDATE_RULE +# problem with installed source +# SOLVER_PROBLEM_JOB_RULE +# conflicting requests +# SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP +# nothing provides requested relation +# SOLVER_PROBLEM_NOT_INSTALLABLE +# source not installable +# SOLVER_PROBLEM_NOTHING_PROVIDES_DEP +# nothing provides relation required by source +# SOLVER_PROBLEM_SAME_NAME +# cannot install both source and target +# SOLVER_PROBLEM_PACKAGE_CONFLICT +# source conflicts with relation provided by target +# SOLVER_PROBLEM_PACKAGE_OBSOLETES +# source obsoletes relation provided by target +# SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE +# source requires relation but no providers are installable +# $: << "../../../build/bindings/ruby" # test Problems require 'test/unit' Modified: trunk/sat-solver/bindings/ruby/tests/relation.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/relation.rb?rev=8185&r1=8184&r2=8185&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/relation.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/relation.rb Thu Jan 3 16:21:42 2008 @@ -1,3 +1,22 @@ +# +# Relations are the primary means to specify dependencies. +# Relations combine names and version through an operator. +# Relations can be compared (<=> operator) or matched (=~ operator) +# +# The following operators are defined: +# REL_GT: greater than +# REL_EQ: equals +# REL_GE: greater equal +# REL_LT: less than +# REL_NE: not equal +# REL_LE: less equal +# Future extensions (not fully defined currently) +# REL_AND: and +# REL_OR: or +# REL_WITH: with +# REL_NAMESPACE: namespace +# +# $: << "../../../build/bindings/ruby" # test Relation require 'test/unit' @@ -15,6 +34,7 @@ end def test_relation rel = SatSolver::Relation.new( @pool, "A", SatSolver::REL_EQ, "1.0-0" ) + # equivalent: @pool.create_relation( "A", SatSolver::REL_EQ, "1.0-0" ) puts "Relation: #{rel}" @repo.each { |s| unless (s.provides.empty?) Modified: trunk/sat-solver/bindings/ruby/tests/repo.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/repo.rb?rev=8185&r1=8184&r2=8185&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/repo.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/repo.rb Thu Jan 3 16:21:42 2008 @@ -1,3 +1,30 @@ +# +# A Repo (repository) groups Solvables +# A Repo has a name and always belongs to a Pool. The size of a Repo is the number +# of Solvables it contains. +# +# A Repo can be created +# - from a .solv file +# repo = Pool.add_solv( "path/to/repo.solv" ) +# - from the rpm database +# repo = pool.add_rpmdb( "/" ) +# - empty +# repo = pool.create_repo( "repo name" ) +# +# Solvables are added to a Repo by creation. There is no 'add' method, use either +# Repo.create_solvable( ... ) +# or +# Solvable.new( repo, ... ) +# +# Solvables can be retrieved from a Repo by +# - index +# repo.get( i ) or repo[i] +# - iteration +# repo.each { |solvable| ... } +# - name +# repo.find( "A" ) +# this will return the 'best' solvable named 'A' or nil if no such solvable exists. +# $: << "../../../build/bindings/ruby" # test Repo require 'test/unit' @@ -8,6 +35,7 @@ pool = SatSolver::Pool.new assert pool repo = SatSolver::Repo.new( pool, "test" ) + # equivalent: repo = pool.create_repo( "test" ) assert repo assert repo.size == 0 assert repo.name == "test" Modified: trunk/sat-solver/bindings/ruby/tests/rpmdb.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/rpmdb.rb?rev=8185&r1=8184&r2=8185&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/rpmdb.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/rpmdb.rb Thu Jan 3 16:21:42 2008 @@ -1,3 +1,14 @@ +# +# Load repository from rpm database +# +# repo = pool.add_rpmdb( "/root/dir/of/system" ) +# will create an unnamed repository by reading the rpm database +# and create a solvable for each installed package. +# Use +# repo.name = "..." +# to name the repository +# +# $: << "../../../build/bindings/ruby" # test adding rpmdb require 'test/unit' Modified: trunk/sat-solver/bindings/ruby/tests/solutions.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/solutions.rb?rev=8185&r1=8184&r2=8185&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/solutions.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/solutions.rb Thu Jan 3 16:21:42 2008 @@ -1,3 +1,9 @@ +# +# Solutions provide 'exit strategies' for Problems. +# +# Solutions are enumeratable through Problem.each_solution +# +# $: << "../../../build/bindings/ruby" # test Solutions require 'test/unit' Modified: trunk/sat-solver/bindings/satsolver.i URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/satsolver.i?rev=8185&r1=8184&r2=8185&view=diff ============================================================================== --- trunk/sat-solver/bindings/satsolver.i (original) +++ trunk/sat-solver/bindings/satsolver.i Thu Jan 3 16:21:42 2008 @@ -482,9 +482,9 @@ #if defined(SWIGRUBY) /* %rename is rejected by swig for [] */ - %alias get_solvable "[]"; + %alias get "[]"; #endif - Solvable *get_solvable( int i ) + Solvable *get( int i ) { if (i < 0) return NULL; if (i >= $self->nsolvables) return NULL; @@ -518,8 +518,7 @@ queue_init( &plist); i = repo ? repo->start : 1; end = repo ? repo->start + repo->nsolvables : pool->nsolvables; - for (; i < end; i++) - { + for (; i < end; i++) { s = pool->solvables + i; if (!pool_installable(pool, s)) continue; @@ -529,10 +528,8 @@ prune_best_version_arch(pool, &plist); - if (plist.count == 0) - { - printf("unknown package '%s'\n", name); - exit(1); + if (plist.count == 0) { + return NULL; } id = plist.elements[0]; @@ -623,14 +620,49 @@ #if defined(SWIGRUBY) /* %rename is rejected by swig for [] */ - %alias get_solvable "[]"; + %alias get "[]"; #endif - Solvable *get_solvable( int i ) + Solvable *get( int i ) { if (i < 0) return NULL; if (i >= $self->nsolvables) return NULL; return pool_id2solvable( $self->pool, $self->start + i ); } + + Solvable * + find( char *name ) + { + Id id; + Queue plist; + int i, end; + Solvable *s; + Pool *pool; + + pool = $self->pool; + id = str2id( pool, name, 1 ); + queue_init( &plist); + i = $self->start; + end = $self->start + $self->nsolvables; + for (; i < end; i++) { + s = pool->solvables + i; + if (!pool_installable( pool, s )) + continue; + if (s->name == id) + queue_push( &plist, i ); + } + + prune_best_version_arch( pool, &plist ); + + if (plist.count == 0) { + return NULL; + } + + id = plist.elements[0]; + queue_free(&plist); + + return pool->solvables + id; + } + } /*-------------------------------------------------------------*/ -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org