Class Satsolver::Solver
In: satsolver.i
Parent: Object

The solver class is at the heart of the satsolver, providing ultra-fast dependency resolution.

The solver is always attached to a pool, containing all solvables the solver can operate on. The pool also has designated repository for ‘installed’ solvables.

Solving is done by creating a Request and feeding it to the solver as input. On success (solver.solve() returning ‘true’), one can retrieve the Decisions made by the solver (i.e. install this, remove that, update those). On failure, the solver creates a list of Problems, explaining what went wrong and how to resolve the problem.

Solving can be controlled globally by setting solver flags. Additionally, specific constraints can be set by using Covenants.

Example code

   pool = Satsolver::Pool.new
   pool.arch = "i686"
   system = pool.add_rpmdb( "/" )
   pool.installed = system
   repo = pool.add_solv( "myrepo.solv" )

   request = pool.create_request
   request.install( "packageA" )
   request.install( "packageB" )
   request.remove( "old_package" )

   solver = pool.create_solver
   solver.allow_uninstall = true
   pool.prepare
   result = solver.solve( request )
   if !result
     raise "Couldn't solve request"
   end

   solver.each_to_install do |s|
     puts "Install #{s}"
   end
   solver.each_to_remove do |s|
     puts "Remove #{s}"
   end

Methods

Public Class methods

Solver.new(pool) → Solver

Create a solver operating on a pool

Equivalent: Pool.create_solver

Public Instance methods

Allow arch change

After installation, the architecture of a package is fixed an the solver will not change it during upgrades. This prevents updates to a higher version but inferior architecture. If this flag is set, packages can change their architecture. The solver will usually try to select the ‘best’ architecture.

Allow or disallow architecture changes

Allow downgrade The normal solver operation tries to install (to update to) the ‘best’ package, usually the one with the highest version. If allow_downgrade is set, packages may be downgraded in order to fulfill a request or a dependency

Allow or disallow package downgrades

On package removal, also remove dependant packages.

If removal of a package breaks dependencies, the request is usually considered not solvable. The dependencies of installed packages take precedence over request actions.

On package removal, also remove dependant packages.

Setting allow_uninstall to ‘true’ will revert the precedence and remove all dependant packages.

Allow vendor change

The package vendor is usually an indicator of the package origin. Updates should only come from the same origin. If this flag is true, the solver will allow vendor changes during package upgrades.

Remove all covenants from this solver

Return the number of decisions after solving.

If its >0, a solution of the Request was found.

If its ==0, and ‘Solver.problems?’ returns true, the Request couldn‘t be solved.

If its ==0, and ‘Solver.problems?’ returns false, the Request is trivially solved.

Distupgrade, remove unsupported

Iterate of all suggested (weak install) solvables.

Iterate over all to-be-newly-installed solvables those brought in for update reasons are normally not reported.

if true is passed, iterate over all to-be-installed solvables

Iterate over all to-be-removed-without-replacement solvables those replaced by an updated are normally not reported.

if true is passed, iterate over all to-be-removed solvables

iterate over all to-be-updated solvables

Exclude (specific) solvable

Excluding a (specific) Solvable means that this Solvable must not be installed.

Excluding a Solvable by name means that any Solvable with the given name must not be installed.

Excluding a Solvable by relation means that any Solvable providing the given relation must not be installed.

Check and fix inconsistencies of the installed system

Normally, broken dependencies in the RPM database are silently ignored in order to prevent clutter in the solution. Setting fix_system to ‘true’ will repair broken system dependencies.

getInstallList()

Get Covenant by index

The index is just a convenience access method and does NOT imply any preference/ordering of the Covenants.

The solver always considers Covenants as a set.

ignore_already_recommended()

Include (specific) solvable

Including a Solvable explicitly means that this Solvable must be installed.

Including a Solvable by name means that one Solvable with the given name must be installed. The solver is free to choose one.

Including a Solvable by relation means that any Solvable providing the given relation must be installed.

installs()

Pool of solver

Check if the last solver run had problems.

Returns true if any problems occured during solve, returns false on successful solve.

Return number of problems

removes()

INTERNAL!

Return the size change of the installed system

This is how much disk space gets allocated/freed after the solver decisions are applied to the system.

See Transaction for more details.

Solve the given Request

Returns true if a solution was found, else false.

The computed Transaction

Will return nil if solver.solve was not successful

updates()

[Validate]