*/
extern "C"
{
-#include <satsolver/repo_solv.h>
-#include <satsolver/poolarch.h>
-#include <satsolver/evr.h>
-#include <satsolver/poolvendor.h>
-#include <satsolver/policy.h>
-#include <satsolver/bitmap.h>
-#include <satsolver/queue.h>
+#include <solv/repo_solv.h>
+#include <solv/poolarch.h>
+#include <solv/evr.h>
+#include <solv/poolvendor.h>
+#include <solv/policy.h>
+#include <solv/bitmap.h>
+#include <solv/queue.h>
}
-#include "zypp/solver/detail/Helper.h"
+#define ZYPP_USE_RESOLVER_INTERNALS
+
#include "zypp/base/String.h"
#include "zypp/Product.h"
#include "zypp/Capability.h"
#include "zypp/sat/Pool.h"
#include "zypp/sat/WhatProvides.h"
#include "zypp/sat/WhatObsoletes.h"
+#include "zypp/solver/detail/Resolver.h"
#include "zypp/solver/detail/SATResolver.h"
#include "zypp/solver/detail/ProblemSolutionCombi.h"
#include "zypp/solver/detail/ProblemSolutionIgnore.h"
#include "zypp/solver/detail/SolverQueueItemInstall.h"
#include "zypp/solver/detail/SolverQueueItemDelete.h"
#include "zypp/solver/detail/SystemCheck.h"
+#include "zypp/solver/detail/SolutionAction.h"
+#include "zypp/solver/detail/SolverQueueItem.h"
+#include "zypp/sat/Transaction.h"
+#include "zypp/sat/Queue.h"
+
+#include "zypp/sat/detail/PoolImpl.h"
+
+#define XDEBUG(x) do { if (base::logger::isExcessive()) XXX << x << std::endl;} while (0)
/////////////////////////////////////////////////////////////////////////
namespace zypp
{ ///////////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////////////
+ namespace env
+ {
+ inline bool HACKENV( const char * var_r, bool default_r )
+ {
+ bool ret = default_r;
+ const char * val = ::getenv( var_r );
+ if ( val )
+ {
+ ret = str::strToBool( val, default_r );
+ if ( ret != default_r )
+ INT << "HACKENV " << var_r << " = " << ret << endl;
+ }
+ return ret;
+ }
+ } // namespace env
+ /////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////
namespace solver
{ /////////////////////////////////////////////////////////////////////
// Callbacks for SAT policies
//---------------------------------------------------------------------------
-int vendorCheck( Pool *pool, Solvable *solvable1, Solvable *solvable2 )
+int vendorCheck( sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2 )
{
return VendorAttr::instance().equivalent( IdString(solvable1->vendor),
IdString(solvable2->vendor) ) ? 0 : 1;
SATResolver::dumpOn( std::ostream & os ) const
{
os << "<resolver>" << endl;
- if (_solv) {
- os << " fixsystem = " << _solv->fixsystem << endl;
- os << " allowdowngrade = " << _solv->allowdowngrade << endl;
- os << " allowarchchange = " << _solv->allowarchchange << endl;
- os << " allowvendorchange = " << _solv->allowvendorchange << endl;
- os << " allowuninstall = " << _solv->allowuninstall << endl;
- os << " updatesystem = " << _solv->updatesystem << endl;
- os << " noupdateprovide = " << _solv->noupdateprovide << endl;
- os << " dosplitprovides = " << _solv->dosplitprovides << endl;
- os << " onlyRequires = " << _solv->dontinstallrecommended << endl;
- os << " ignorealreadyrecommended = " << _solv->ignorealreadyrecommended << endl;
- os << " distupgrade = " << _distupgrade << endl;
- os << " distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
- os << " solveSrcPackages = " << _solveSrcPackages << endl;
- os << " cleandepsOnRemove = " << _cleandepsOnRemove << endl;
+ if (_satSolver) {
+#define OUTS(X) os << " " << #X << "\t= " << solver_get_flag(_satSolver, SOLVER_FLAG_##X) << endl
+ OUTS( ALLOW_DOWNGRADE );
+ OUTS( ALLOW_ARCHCHANGE );
+ OUTS( ALLOW_VENDORCHANGE );
+ OUTS( ALLOW_UNINSTALL );
+ OUTS( NO_UPDATEPROVIDE );
+ OUTS( SPLITPROVIDES );
+ OUTS( IGNORE_RECOMMENDED );
+ OUTS( ADD_ALREADY_RECOMMENDED );
+ OUTS( NO_INFARCHCHECK );
+ OUTS( ALLOW_NAMECHANGE );
+ OUTS( KEEP_EXPLICIT_OBSOLETES );
+ OUTS( BEST_OBEY_POLICY );
+ OUTS( NO_AUTOTARGET );
+ OUTS( DUP_ALLOW_DOWNGRADE );
+ OUTS( DUP_ALLOW_ARCHCHANGE );
+ OUTS( DUP_ALLOW_VENDORCHANGE );
+ OUTS( DUP_ALLOW_NAMECHANGE );
+ OUTS( KEEP_ORPHANS );
+ OUTS( BREAK_ORPHANS );
+ OUTS( FOCUS_INSTALLED );
+ OUTS( YUM_OBSOLETES );
+#undef OUTS
+ os << " distupgrade = " << _distupgrade << endl;
+ os << " distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
+ os << " solveSrcPackages = " << _solveSrcPackages << endl;
+ os << " cleandepsOnRemove = " << _cleandepsOnRemove << endl;
+ os << " fixsystem = " << _fixsystem << endl;
} else {
os << "<NULL>";
}
//---------------------------------------------------------------------------
-SATResolver::SATResolver (const ResPool & pool, Pool *SATPool)
- : _pool (pool)
- , _SATPool (SATPool)
- , _solv(NULL)
+SATResolver::SATResolver (const ResPool & pool, sat::detail::CPool *satPool)
+ : _pool(pool)
+ , _satPool(satPool)
+ , _satSolver(NULL)
, _fixsystem(false)
, _allowdowngrade(false)
, _allowarchchange(false)
, _allowuninstall(false)
, _updatesystem(false)
, _noupdateprovide(false)
- , _dosplitprovides(false)
+ , _dosplitprovides(true)
, _onlyRequires(ZConfig::instance().solver_onlyRequires())
, _ignorealreadyrecommended(true)
, _distupgrade(false)
, _distupgrade_removeunsupported(false)
+ , _dup_allowdowngrade ( ZConfig::instance().solver_dupAllowDowngrade() )
+ , _dup_allownamechange ( ZConfig::instance().solver_dupAllowNameChange() )
+ , _dup_allowarchchange ( ZConfig::instance().solver_dupAllowArchChange() )
+ , _dup_allowvendorchange ( ZConfig::instance().solver_dupAllowVendorChange() )
, _solveSrcPackages(false)
, _cleandepsOnRemove(ZConfig::instance().solver_cleandepsOnRemove())
{
SATResolver::~SATResolver()
{
+ solverEnd();
}
//---------------------------------------------------------------------------
-
ResPool
SATResolver::pool (void) const
{
return _pool;
}
-
-void
-SATResolver::resetItemTransaction (PoolItem item)
-{
- bool found = false;
- for (PoolItemList::const_iterator iter = _items_to_remove.begin();
- iter != _items_to_remove.end(); ++iter) {
- if (*iter == item) {
- _items_to_remove.remove(*iter);
- found = true;
- break;
- }
- }
- if (!found) {
- for (PoolItemList::const_iterator iter = _items_to_install.begin();
- iter != _items_to_install.end(); ++iter) {
- if (*iter == item) {
- _items_to_install.remove(*iter);
- found = true;
- break;
- }
- }
- }
- if (!found) {
- for (PoolItemList::const_iterator iter = _items_to_keep.begin();
- iter != _items_to_keep.end(); ++iter) {
- if (*iter == item) {
- _items_to_keep.remove(*iter);
- found = true;
- break;
- }
- }
- }
- if (!found) {
- for (PoolItemList::const_iterator iter = _items_to_lock.begin();
- iter != _items_to_lock.end(); ++iter) {
- if (*iter == item) {
- _items_to_lock.remove(*iter);
- found = true;
- break;
- }
- }
- }
-}
-
-
-void
-SATResolver::addPoolItemToInstall (PoolItem item)
-{
- resetItemTransaction (item);
- _items_to_install.push_back (item);
- _items_to_install.unique ();
-}
-
-
-void
-SATResolver::addPoolItemsToInstallFromList (PoolItemList & rl)
-{
- for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
- addPoolItemToInstall (*iter);
- }
-}
-
-
-void
-SATResolver::addPoolItemToRemove (PoolItem item)
-{
- resetItemTransaction (item);
- _items_to_remove.push_back (item);
- _items_to_remove.unique ();
-}
-
-
-void
-SATResolver::addPoolItemsToRemoveFromList (PoolItemList & rl)
-{
- for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
- addPoolItemToRemove (*iter);
- }
-}
-
-void
-SATResolver::addPoolItemToLock (PoolItem item)
-{
- resetItemTransaction (item);
- _items_to_lock.push_back (item);
- _items_to_lock.unique ();
-}
-
-void
-SATResolver::addPoolItemToKeep (PoolItem item)
-{
- resetItemTransaction (item);
- _items_to_keep.push_back (item);
- _items_to_keep.unique ();
-}
-
//---------------------------------------------------------------------------
// copy marked item from solution back to pool
// installation/deletion
if (status.isToBeInstalled()) {
r = item.status().setToBeInstalled (causer);
- _XDEBUG("SATSolutionToPool install returns " << item << ", " << r);
+ XDEBUG("SATSolutionToPool install returns " << item << ", " << r);
}
else if (status.isToBeUninstalledDueToUpgrade()) {
r = item.status().setToBeUninstalledDueToUpgrade (causer);
- _XDEBUG("SATSolutionToPool upgrade returns " << item << ", " << r);
+ XDEBUG("SATSolutionToPool upgrade returns " << item << ", " << r);
}
else if (status.isToBeUninstalled()) {
r = item.status().setToBeUninstalled (causer);
- _XDEBUG("SATSolutionToPool remove returns " << item << ", " << r);
+ XDEBUG("SATSolutionToPool remove returns " << item << ", " << r);
}
return;
// resolvePool
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// Helper functions for the ZYPP-Pool
-//----------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------------------------------------
-// This function loops over the pool and grabs all items
-// It clears all previous bySolver() states also
-//
-// Every toBeInstalled is passed to zypp::solver:detail::Resolver.addPoolItemToInstall()
-// Every toBeUninstalled is passed to zypp::solver:detail::Resolver.addPoolItemToRemove()
-//
-// Solver results must be written back to the pool.
-//------------------------------------------------------------------------------------------------------------
-
-
+/////////////////////////////////////////////////////////////////////////
+/// \class SATCollectTransact
+/// \brief Commit helper functor distributing PoolItem by status into lists
+///
+/// On the fly it clears all PoolItem bySolver/ByApplLow status.
+/// The lists are cleared in the Ctor, populated by \ref operator().
+/////////////////////////////////////////////////////////////////////////
struct SATCollectTransact : public resfilter::PoolItemFilterFunctor
{
- SATResolver & resolver;
+ SATCollectTransact( PoolItemList & items_to_install_r,
+ PoolItemList & items_to_remove_r,
+ PoolItemList & items_to_lock_r,
+ PoolItemList & items_to_keep_r,
+ bool solveSrcPackages_r )
+ : _items_to_install( items_to_install_r )
+ , _items_to_remove( items_to_remove_r )
+ , _items_to_lock( items_to_lock_r )
+ , _items_to_keep( items_to_keep_r )
+ , _solveSrcPackages( solveSrcPackages_r )
+ {
+ _items_to_install.clear();
+ _items_to_remove.clear();
+ _items_to_lock.clear();
+ _items_to_keep.clear();
+ }
- SATCollectTransact (SATResolver & r)
- : resolver (r)
- { }
+ bool operator()( const PoolItem & item_r )
+ {
+
+ ResStatus & itemStatus( item_r.status() );
+ bool by_solver = ( itemStatus.isBySolver() || itemStatus.isByApplLow() );
- bool operator()( PoolItem item ) // only transacts() items go here
+ if ( by_solver )
{
- ResStatus status = item.status();
- bool by_solver = (status.isBySolver() || status.isByApplLow());
+ // Clear former solver/establish resultd
+ itemStatus.resetTransact( ResStatus::APPL_LOW );
+ return true; // -> back out here, don't re-queue former results
+ }
- if (by_solver) {
- item.status().resetTransact( ResStatus::APPL_LOW );// clear any solver/establish transactions
- return true; // back out here, dont re-queue former solver result
- }
+ if ( !_solveSrcPackages && item_r.isKind<SrcPackage>() )
+ {
+ // Later we may continue on a per source package base.
+ return true; // dont process this source package.
+ }
- if ( item.satSolvable().isKind<SrcPackage>() && ! resolver.solveSrcPackages() )
- {
- // Later we may continue on a per source package base.
- return true; // dont process this source package.
- }
+ switch ( itemStatus.getTransactValue() )
+ {
+ case ResStatus::TRANSACT:
+ itemStatus.isUninstalled() ? _items_to_install.push_back( item_r )
+ : _items_to_remove.push_back( item_r ); break;
+ case ResStatus::LOCKED: _items_to_lock.push_back( item_r ); break;
+ case ResStatus::KEEP_STATE: _items_to_keep.push_back( item_r ); break;
+ }
+ return true;
+ }
- if (status.isToBeInstalled()) {
- resolver.addPoolItemToInstall(item); // -> install!
- }
- else if (status.isToBeUninstalled()) {
- resolver.addPoolItemToRemove(item); // -> remove !
- }
- else if (status.isLocked()
- && !by_solver) {
- resolver.addPoolItemToLock (item);
- }
- else if (status.isKept()
- && !by_solver) {
- resolver.addPoolItemToKeep (item);
- }
+private:
+ PoolItemList & _items_to_install;
+ PoolItemList & _items_to_remove;
+ PoolItemList & _items_to_lock;
+ PoolItemList & _items_to_keep;
+ bool _solveSrcPackages;
- return true;
- }
};
+/////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------
{
public:
bool is_updated;
- bool multiversion;
sat::Solvable _installed;
- CheckIfUpdate( sat::Solvable installed_r )
- : is_updated( false )
- , multiversion( installed_r.multiversionInstall() )
- , _installed( installed_r )
+ CheckIfUpdate( const sat::Solvable & installed_r )
+ : is_updated( false )
+ , _installed( installed_r )
{}
// check this item will be updated
- bool operator()( PoolItem item )
+ bool operator()( const PoolItem & item )
{
if ( item.status().isToBeInstalled() )
{
- if ( ! multiversion || sameNVRA( _installed, item ) )
+ if ( ! item.multiversionInstall() || sameNVRA( _installed, item ) )
{
is_updated = true;
return false;
SATResolver::solving(const CapabilitySet & requires_caps,
const CapabilitySet & conflict_caps)
{
- _solv = solver_create( _SATPool );
- _solv->vendorCheckCb = &vendorCheck;
- _solv->fixsystem = _fixsystem;
- _solv->ignorealreadyrecommended = _ignorealreadyrecommended;
- _solv->updatesystem = _updatesystem;
- _solv->allowdowngrade = _allowdowngrade;
- _solv->allowuninstall = _allowuninstall;
- _solv->allowarchchange = _allowarchchange;
- _solv->allowvendorchange = _allowvendorchange;
- _solv->dosplitprovides = _dosplitprovides;
- _solv->noupdateprovide = _noupdateprovide;
- _solv->dontinstallrecommended = _onlyRequires;
- _solv->distupgrade = _distupgrade;
- _solv->distupgrade_removeunsupported = _distupgrade_removeunsupported;
-
- sat::Pool::instance().prepare();
+ _satSolver = solver_create( _satPool );
+ ::pool_set_custom_vendorcheck( _satPool, &vendorCheck );
+ if (_fixsystem) {
+ queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
+ queue_push( &(_jobQueue), 0 );
+ }
+ if (_updatesystem) {
+ queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
+ queue_push( &(_jobQueue), 0 );
+ }
+ if (_distupgrade) {
+ queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
+ queue_push( &(_jobQueue), 0 );
+ }
+ if (_distupgrade_removeunsupported) {
+ queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
+ queue_push( &(_jobQueue), 0 );
+ }
+ solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
+ solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
+ solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
+ solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
+ solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
+ solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
+ solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
+ solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
+ solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, _dup_allowdowngrade );
+ solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_NAMECHANGE, _dup_allownamechange );
+ solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE, _dup_allowarchchange );
+ solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE, _dup_allowvendorchange );
+#if 1
+#define HACKENV(X,D) solver_set_flag(_satSolver, X, env::HACKENV( #X, D ) );
+ HACKENV( SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, _dup_allowdowngrade );
+ HACKENV( SOLVER_FLAG_DUP_ALLOW_NAMECHANGE, _dup_allownamechange );
+ HACKENV( SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE, _dup_allowarchchange );
+ HACKENV( SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE,_dup_allowvendorchange );
+#undef HACKENV
+#endif
+ sat::Pool::instance().prepareForSolving();
// Solve !
MIL << "Starting solving...." << endl;
MIL << *this;
- solver_solve( _solv, &(_jobQueue) );
+ solver_solve( _satSolver, &(_jobQueue) );
MIL << "....Solver end" << endl;
// copying solution back to zypp pool
_result_items_to_remove.clear();
/* solvables to be installed */
- for ( int i = 0; i < _solv->decisionq.count; ++i )
+ Queue decisionq;
+ queue_init(&decisionq);
+ solver_get_decisionqueue(_satSolver, &decisionq);
+ for ( int i = 0; i < decisionq.count; ++i )
{
- sat::Solvable slv( _solv->decisionq.elements[i] );
+ sat::Solvable slv( decisionq.elements[i] );
if ( !slv || slv.isSystem() )
continue;
PoolItem poolItem( slv );
SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
- _result_items_to_install.push_back (poolItem);
+ _result_items_to_install.push_back( poolItem );
}
+ queue_free(&decisionq);
/* solvables to be erased */
Repository systemRepo( sat::Pool::instance().findSystemRepo() ); // don't create if it does not exist
bool mustCheckObsoletes = false;
for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
{
- if (_solv->decisionmap[it->id()] > 0)
+ if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
continue;
// Check if this is an update
}
}
+ Queue recommendations;
+ Queue suggestions;
+ Queue orphaned;
+ Queue unneeded;
+ queue_init(&recommendations);
+ queue_init(&suggestions);
+ queue_init(&orphaned);
+ queue_init(&unneeded);
+ solver_get_recommendations(_satSolver, &recommendations, &suggestions, 0);
+ solver_get_orphaned(_satSolver, &orphaned);
+ solver_get_unneeded(_satSolver, &unneeded, 1);
/* solvables which are recommended */
- for ( int i = 0; i < _solv->recommendations.count; ++i )
+ for ( int i = 0; i < recommendations.count; ++i )
{
- PoolItem poolItem( getPoolItem( _solv->recommendations.elements[i] ) );
+ PoolItem poolItem( getPoolItem( recommendations.elements[i] ) );
poolItem.status().setRecommended( true );
}
/* solvables which are suggested */
- for ( int i = 0; i < _solv->suggestions.count; ++i )
+ for ( int i = 0; i < suggestions.count; ++i )
{
- PoolItem poolItem( getPoolItem( _solv->suggestions.elements[i] ) );
+ PoolItem poolItem( getPoolItem( suggestions.elements[i] ) );
poolItem.status().setSuggested( true );
}
_problem_items.clear();
/* solvables which are orphaned */
- for ( int i = 0; i < _solv->orphaned.count; ++i )
+ for ( int i = 0; i < orphaned.count; ++i )
{
- PoolItem poolItem( getPoolItem( _solv->orphaned.elements[i] ) );
+ PoolItem poolItem( getPoolItem( orphaned.elements[i] ) );
poolItem.status().setOrphaned( true );
_problem_items.push_back( poolItem );
}
+ /* solvables which are unneeded */
+ for ( int i = 0; i < unneeded.count; ++i )
+ {
+ PoolItem poolItem( getPoolItem( unneeded.elements[i] ) );
+ poolItem.status().setUnneeded( true );
+ }
+
+ queue_free(&recommendations);
+ queue_free(&suggestions);
+ queue_free(&orphaned);
+ queue_free(&unneeded);
+
/* Write validation state back to pool */
Queue flags, solvableQueue;
invokeOnEach( _pool.begin(),
_pool.end(),
functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
- solver_trivial_installable(_solv, &solvableQueue, &flags );
+ solver_trivial_installable(_satSolver, &solvableQueue, &flags );
for (int i = 0; i < solvableQueue.count; i++) {
PoolItem item = _pool.find (sat::Solvable(solvableQueue.elements[i]));
item.status().setUndetermined();
if (flags.elements[i] == -1) {
item.status().setNonRelevant();
- _XDEBUG("SATSolutionToPool(" << item << " ) nonRelevant !");
+ XDEBUG("SATSolutionToPool(" << item << " ) nonRelevant !");
} else if (flags.elements[i] == 1) {
item.status().setSatisfied();
- _XDEBUG("SATSolutionToPool(" << item << " ) satisfied !");
+ XDEBUG("SATSolutionToPool(" << item << " ) satisfied !");
} else if (flags.elements[i] == 0) {
item.status().setBroken();
- _XDEBUG("SATSolutionToPool(" << item << " ) broken !");
+ XDEBUG("SATSolutionToPool(" << item << " ) broken !");
}
}
+ queue_free(&(solvableQueue));
+ queue_free(&flags);
+
// Solvables which were selected due requirements which have been made by the user will
// be selected by APPL_LOW. We can't use any higher level, because this setting must
}
}
- if (_solv->problems.count > 0 )
+ if (solver_problem_count(_satSolver) > 0 )
{
ERR << "Solverrun finished with an ERROR" << endl;
return false;
}
- queue_free(&(solvableQueue));
- queue_free(&flags);
-
return true;
}
void
SATResolver::solverInit(const PoolItemList & weakItems)
{
- SATCollectTransact info (*this);
MIL << "SATResolver::solverInit()" << endl;
- if (_solv) {
- // remove old stuff
- solver_free(_solv);
- _solv = NULL;
- queue_free( &(_jobQueue) );
- }
-
+ // remove old stuff
+ solverEnd();
queue_init( &_jobQueue );
- _items_to_install.clear();
- _items_to_remove.clear();
- _items_to_lock.clear();
- _items_to_keep.clear();
- invokeOnEach ( _pool.begin(), _pool.end(),
- functor::functorRef<bool,PoolItem>(info) );
+ // clear and rebuild: _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep
+ {
+ SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
+ invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
+ }
for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
Id id = (*iter)->satSolvable().id();
ERR << "Weaken: " << *iter << " not found" << endl;
}
MIL << "Weaken dependencies of " << *iter << endl;
- queue_push( &(_jobQueue), SOLVER_WEAKEN_SOLVABLE_DEPS );
+ queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
queue_push( &(_jobQueue), id );
}
+ // Ad rules for changed requestedLocales
+ const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
+ for ( const auto & locale : trackedLocaleIds.added() )
+ {
+ queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
+ queue_push( &(_jobQueue), Capability( ResolverNamespace::language, IdString(locale) ).id() );
+ }
+
+ for ( const auto & locale : trackedLocaleIds.removed() )
+ {
+ queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS ); // needs uncond. SOLVER_CLEANDEPS!
+ queue_push( &(_jobQueue), Capability( ResolverNamespace::language, IdString(locale) ).id() );
+ }
+
// Add rules for parallel installable resolvables with different versions
- for_( it, sat::Pool::instance().multiversionBegin(), sat::Pool::instance().multiversionEnd() )
+ for ( const sat::Solvable & solv : myPool().multiversionList() )
{
- queue_push( &(_jobQueue), SOLVER_NOOBSOLETES_SOLVABLE_NAME );
- queue_push( &(_jobQueue), it->id() );
+ queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
+ queue_push( &(_jobQueue), solv.id() );
}
+ ::pool_add_userinstalled_jobs(_satPool, sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
+
if ( _distupgrade )
{
if ( ZConfig::instance().solverUpgradeRemoveDroppedPackages() )
if ( (*it)->onSystem() ) // (to install) or (not to delete)
{
Product::constPtr prodCand( (*it)->candidateAsKind<Product>() );
- if ( ! prodCand || (*it)->identicalInstalledCandidate() )
- continue; // product no longer available or unchanged
+ if ( ! prodCand )
+ continue; // product no longer available
CapabilitySet droplist( prodCand->droplist() );
dumpRangeLine( MIL << "Droplist for " << (*it)->candidateObj() << ": " << droplist.size() << " ", droplist.begin(), droplist.end() ) << endl;
for_( cap, droplist.begin(), droplist.end() )
{
- queue_push( &_jobQueue, SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_NAME );
+ queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
queue_push( &_jobQueue, cap->id() );
}
}
void
SATResolver::solverEnd()
{
- // cleanup
- solver_free(_solv);
- _solv = NULL;
+ // cleanup
+ if ( _satSolver )
+ {
+ solver_free(_satSolver);
+ _satSolver = NULL;
queue_free( &(_jobQueue) );
+ }
}
ERR << "Install: " << *iter << " not found" << endl;
} else {
MIL << "Install " << *iter << endl;
- queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE );
+ queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
queue_push( &(_jobQueue), id );
}
}
ERR << "Delete: " << *iter << " not found" << endl;
} else {
MIL << "Delete " << *iter << endl;
- queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE | MAYBE_CLEANDEPS );
+ queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
queue_push( &(_jobQueue), id);
}
}
for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
{
- queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_REPO );
+ queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
queue_push( &(_jobQueue), iter->get()->repoid );
MIL << "Upgrade repo " << *iter << endl;
}
for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
- queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE_PROVIDES );
+ queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
queue_push( &(_jobQueue), iter->id() );
MIL << "Requires " << *iter << endl;
}
for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
- queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
+ queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
queue_push( &(_jobQueue), iter->id() );
MIL << "Conflicts " << *iter << endl;
}
// solving
bool ret = solving(requires_caps, conflict_caps);
- // cleanup
- if (ret)
- solverEnd(); // remove solver only if no errors happend. Need it for solving problems
(ret?MIL:WAR) << "SATResolver::resolvePool() done. Ret:" << ret << endl;
return ret;
ERR << "Install: " << *iter << " not found" << endl;
} else {
MIL << "Install " << *iter << endl;
- queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE );
+ queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
queue_push( &(_jobQueue), id );
}
}
for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
sat::detail::IdType ident( (*iter)->satSolvable().ident().id() );
MIL << "Delete " << *iter << ident << endl;
- queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE_NAME | MAYBE_CLEANDEPS );
+ queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | MAYBE_CLEANDEPS );
queue_push( &(_jobQueue), ident);
}
// solving
bool ret = solving();
- // cleanup
- if (ret)
- solverEnd(); // remove solver only if no errors happend. Need it for solving problems
-
MIL << "SATResolver::resolveQueue() done. Ret:" << ret << endl;
return ret;
}
// set locks for the solver
setLocks();
- _solv = solver_create( _SATPool );
- _solv->vendorCheckCb = &vendorCheck;
- _solv->fixsystem = _fixsystem;
- _solv->ignorealreadyrecommended = _ignorealreadyrecommended;
- _solv->updatesystem = true;
- _solv->allowdowngrade = _allowdowngrade;
- _solv->allowuninstall = _allowuninstall;
- _solv->allowarchchange = _allowarchchange;
- _solv->allowvendorchange = _allowvendorchange;
- _solv->dosplitprovides = true;
- _solv->noupdateprovide = _noupdateprovide;
- _solv->dontinstallrecommended = true; // #FIXME dontinstallrecommended maybe set to false if it works correctly
- _solv->distupgrade = _distupgrade;
- _solv->distupgrade_removeunsupported = _distupgrade_removeunsupported;
-
- sat::Pool::instance().prepare();
+ _satSolver = solver_create( _satPool );
+ ::pool_set_custom_vendorcheck( _satPool, &vendorCheck );
+ if (_fixsystem) {
+ queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
+ queue_push( &(_jobQueue), 0 );
+ }
+ if (1) {
+ queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
+ queue_push( &(_jobQueue), 0 );
+ }
+ if (_distupgrade) {
+ queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
+ queue_push( &(_jobQueue), 0 );
+ }
+ if (_distupgrade_removeunsupported) {
+ queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
+ queue_push( &(_jobQueue), 0 );
+ }
+ solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
+ solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
+ solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
+ solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
+ solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
+ solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
+ solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
+ solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
+
+ sat::Pool::instance().prepareForSolving();
// Solve !
MIL << "Starting solving for update...." << endl;
MIL << *this;
- solver_solve( _solv, &(_jobQueue) );
+ solver_solve( _satSolver, &(_jobQueue) );
MIL << "....Solver end" << endl;
// copying solution back to zypp pool
//-----------------------------------------
/* solvables to be installed */
- for (int i = 0; i < _solv->decisionq.count; i++)
+ Queue decisionq;
+ queue_init(&decisionq);
+ solver_get_decisionqueue(_satSolver, &decisionq);
+ for (int i = 0; i < decisionq.count; i++)
{
Id p;
- p = _solv->decisionq.elements[i];
+ p = decisionq.elements[i];
if (p < 0 || !sat::Solvable(p))
continue;
- if (sat::Solvable(p).repository().get() == _solv->installed)
+ if (sat::Solvable(p).repository().get() == _satSolver->pool->installed)
continue;
PoolItem poolItem = _pool.find (sat::Solvable(p));
ERR << "id " << p << " not found in ZYPP pool." << endl;
}
}
+ queue_free(&decisionq);
/* solvables to be erased */
- for (int i = _solv->installed->start; i < _solv->installed->start + _solv->installed->nsolvables; i++)
+ for (int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
{
- if (_solv->decisionmap[i] > 0)
- continue;
+ if (solver_get_decisionlevel(_satSolver, i) > 0)
+ continue;
PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
if (poolItem) {
ERR << "id " << i << " not found in ZYPP pool." << endl;
}
}
-
- // cleanup
- solverEnd();
-
MIL << "SATResolver::doUpdate() done" << endl;
}
// e.g. The release package has a buddy to the concerning product item.
// This user want's the message "Product foo conflicts with product bar" and
// NOT "package release-foo conflicts with package release-bar"
+// (ma: that's why we should map just packages to buddies, not vice versa)
//----------------------------------------------------------------------------
-
-
-PoolItem SATResolver::mapItem (const PoolItem &item)
+inline sat::Solvable mapBuddy( const PoolItem & item_r )
{
- sat::Solvable buddy = item.buddy();
- if (buddy != sat::Solvable())
- {
- return _pool.find (buddy);
- }
- else
- {
- return item;
- }
+ if ( item_r.satSolvable().isKind<Package>() )
+ {
+ sat::Solvable buddy = item_r.buddy();
+ if ( buddy )
+ return buddy;
+ }
+ return item_r.satSolvable();
}
+inline sat::Solvable mapBuddy( sat::Solvable item_r )
+{ return mapBuddy( PoolItem( item_r ) ); }
-sat::Solvable SATResolver::mapSolvable (const Id &id)
-{
- PoolItem item = _pool.find (sat::Solvable(id));
- return mapItem(item).satSolvable();
-}
+PoolItem SATResolver::mapItem ( const PoolItem & item )
+{ return PoolItem( mapBuddy( item ) ); }
+
+sat::Solvable SATResolver::mapSolvable ( const Id & id )
+{ return mapBuddy( sat::Solvable(id) ); }
string SATResolver::SATprobleminfoString(Id problem, string &detail, Id &ignoreId)
{
string ret;
- Pool *pool = _solv->pool;
+ sat::detail::CPool *pool = _satSolver->pool;
Id probr;
Id dep, source, target;
sat::Solvable s, s2;
ignoreId = 0;
- probr = solver_findproblemrule(_solv, problem);
- switch (solver_ruleinfo(_solv, probr, &source, &target, &dep))
+
+ // FIXME: solver_findallproblemrules to get all rules for this problem
+ // (the 'most relevabt' one returned by solver_findproblemrule is embedded
+ probr = solver_findproblemrule(_satSolver, problem);
+ switch (solver_ruleinfo(_satSolver, probr, &source, &target, &dep))
{
case SOLVER_RULE_DISTUPGRADE:
s = mapSolvable (source);
ret = _("some dependency problem");
break;
case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
- ret = str::form (_("nothing provides requested %s"), dep2str(pool, dep));
+ ret = str::form (_("nothing provides requested %s"), pool_dep2str(pool, dep));
+ detail += _("Have you enabled all requested repositories?");
+ break;
+ case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
+ ret = str::form (_("package %s does not exist"), pool_dep2str(pool, dep));
detail += _("Have you enabled all requested repositories?");
break;
+ case SOLVER_RULE_JOB_UNSUPPORTED:
+ ret = _("unsupported request");
+ break;
+ case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
+ ret = str::form (_("%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
+ break;
case SOLVER_RULE_RPM_NOT_INSTALLABLE:
s = mapSolvable (source);
ret = str::form (_("%s is not installable"), s.asString().c_str());
case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
ignoreId = source; // for setting weak dependencies
s = mapSolvable (source);
- ret = str::form (_("nothing provides %s needed by %s"), dep2str(pool, dep), s.asString().c_str());
+ ret = str::form (_("nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
break;
case SOLVER_RULE_RPM_SAME_NAME:
s = mapSolvable (source);
case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
s = mapSolvable (source);
s2 = mapSolvable (target);
- ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), dep2str(pool, dep), s2.asString().c_str());
+ ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
break;
case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
s = mapSolvable (source);
s2 = mapSolvable (target);
- ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), dep2str(pool, dep), s2.asString().c_str());
+ ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
break;
case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
s = mapSolvable (source);
s2 = mapSolvable (target);
- ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), dep2str(pool, dep), s2.asString().c_str());
+ ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
break;
case SOLVER_RULE_RPM_SELF_CONFLICT:
s = mapSolvable (source);
- ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), dep2str(pool, dep));
+ ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
break;
case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
ignoreId = source; // for setting weak dependencies
bool found = false;
for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
PoolItem provider2 = ResPool::instance().find( *iter2 );
- if (compareByNVR (provider1.resolvable(),provider2.resolvable()) == 0
+ if (compareByNVR (provider1,provider2) == 0
&& ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
|| (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
found = true;
}
}
- ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), dep2str(pool, dep));
+ ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
if (providerlistInstalled.size() > 0) {
detail += _("deleted providers: ");
for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
SATResolver::problems ()
{
ResolverProblemList resolverProblems;
- if (_solv && _solv->problems.count) {
- Pool *pool = _solv->pool;
+ if (_satSolver && solver_problem_count(_satSolver)) {
+ sat::detail::CPool *pool = _satSolver->pool;
int pcnt;
Id p, rp, what;
Id problem, solution, element;
MIL << "Encountered problems! Here are the solutions:\n" << endl;
pcnt = 1;
problem = 0;
- while ((problem = solver_next_problem(_solv, problem)) != 0) {
+ while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
MIL << "Problem " << pcnt++ << ":" << endl;
MIL << "====================================" << endl;
string detail;
ResolverProblem_Ptr resolverProblem = new ResolverProblem (whatString, detail);
solution = 0;
- while ((solution = solver_next_solution(_solv, problem, solution)) != 0) {
+ while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
element = 0;
- ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi(resolverProblem);
- while ((element = solver_next_solutionelement(_solv, problem, solution, element, &p, &rp)) != 0) {
+ ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi;
+ while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
if (p == SOLVER_SOLUTION_JOB) {
/* job, rp is index into job queue */
what = _jobQueue.elements[rp];
- switch (_jobQueue.elements[rp-1])
+ switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
{
- case SOLVER_INSTALL_SOLVABLE: {
+ case SOLVER_INSTALL | SOLVER_SOLVABLE: {
s = mapSolvable (what);
PoolItem poolItem = _pool.find (s);
if (poolItem) {
- if (_solv->installed && s.get()->repo == _solv->installed) {
+ if (pool->installed && s.get()->repo == pool->installed) {
problemSolution->addSingleAction (poolItem, REMOVE);
- string description = str::form (_("do not keep %s installed"), s.asString().c_str() );
+ string description = str::form (_("remove lock to allow removal of %s"), s.asString().c_str() );
MIL << description << endl;
problemSolution->addDescription (description);
} else {
}
}
break;
- case SOLVER_ERASE_SOLVABLE: {
+ case SOLVER_ERASE | SOLVER_SOLVABLE: {
s = mapSolvable (what);
PoolItem poolItem = _pool.find (s);
if (poolItem) {
- if (_solv->installed && s.get()->repo == _solv->installed) {
+ if (pool->installed && s.get()->repo == pool->installed) {
problemSolution->addSingleAction (poolItem, KEEP);
string description = str::form (_("keep %s"), s.asString().c_str());
MIL << description << endl;
problemSolution->addDescription (description);
} else {
problemSolution->addSingleAction (poolItem, UNLOCK);
- string description = str::form (_("do not forbid installation of %s"), itemToString( poolItem ).c_str());
+ string description = str::form (_("remove lock to allow installation of %s"), itemToString( poolItem ).c_str());
MIL << description << endl;
problemSolution->addDescription (description);
}
}
}
break;
- case SOLVER_INSTALL_SOLVABLE_NAME:
+ case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
{
IdString ident( what );
SolverQueueItemInstall_Ptr install =
problemSolution->addDescription (description);
}
break;
- case SOLVER_ERASE_SOLVABLE_NAME:
+ case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
{
// As we do not know, if this request has come from resolvePool or
// resolveQueue we will have to take care for both cases.
problemSolution->addDescription (description);
}
break;
- case SOLVER_INSTALL_SOLVABLE_PROVIDES:
+ case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
{
problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
string description = "";
resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
resolverProblem->setDescription(_("This request will break your system!"));
description = _("ignore the warning of a broken system");
- description += string(" (requires:")+dep2str(pool, what)+")";
+ description += string(" (requires:")+pool_dep2str(pool, what)+")";
MIL << description << endl;
problemSolution->addFrontDescription (description);
} else {
- description = str::form (_("do not ask to install a solvable providing %s"), dep2str(pool, what));
+ description = str::form (_("do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
MIL << description << endl;
problemSolution->addDescription (description);
}
}
break;
- case SOLVER_ERASE_SOLVABLE_PROVIDES:
+ case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
{
problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
string description = "";
resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
resolverProblem->setDescription(_("This request will break your system!"));
description = _("ignore the warning of a broken system");
- description += string(" (conflicts:")+dep2str(pool, what)+")";
+ description += string(" (conflicts:")+pool_dep2str(pool, what)+")";
MIL << description << endl;
problemSolution->addFrontDescription (description);
} else {
- description = str::form (_("do not ask to delete all solvables providing %s"), dep2str(pool, what));
+ description = str::form (_("do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
MIL << description << endl;
problemSolution->addDescription (description);
}
}
break;
- case SOLVER_INSTALL_SOLVABLE_UPDATE:
+ case SOLVER_UPDATE | SOLVER_SOLVABLE:
{
s = mapSolvable (what);
PoolItem poolItem = _pool.find (s);
if (poolItem) {
- if (_solv->installed && s.get()->repo == _solv->installed) {
+ if (pool->installed && s.get()->repo == pool->installed) {
problemSolution->addSingleAction (poolItem, KEEP);
string description = str::form (_("do not install most recent version of %s"), s.asString().c_str());
MIL << description << endl;
} else if (p == SOLVER_SOLUTION_INFARCH) {
s = mapSolvable (rp);
PoolItem poolItem = _pool.find (s);
- if (_solv->installed && s.get()->repo == _solv->installed) {
+ if (pool->installed && s.get()->repo == pool->installed) {
problemSolution->addSingleAction (poolItem, LOCK);
string description = str::form (_("keep %s despite the inferior architecture"), s.asString().c_str());
MIL << description << endl;
} else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
s = mapSolvable (rp);
PoolItem poolItem = _pool.find (s);
- if (_solv->installed && s.get()->repo == _solv->installed) {
+ if (pool->installed && s.get()->repo == pool->installed) {
problemSolution->addSingleAction (poolItem, LOCK);
string description = str::form (_("keep obsolete %s"), s.asString().c_str());
MIL << description << endl;
} else {
/* policy, replace p with rp */
s = mapSolvable (p);
- if (rp)
- sd = mapSolvable (rp);
-
PoolItem itemFrom = _pool.find (s);
- if (s == sd && _solv->distupgrade)
- {
- PoolItem poolItem = _pool.find (s);
- if (poolItem) {
- problemSolution->addSingleAction (poolItem, LOCK); // for solver reason: NOT weak lock.
- string description = str::form (_("keep obsolete %s"), s.asString().c_str());
- MIL << description << endl;
- problemSolution->addDescription (description);
- } else {
- ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
- }
- }
- else if (rp)
+ if (rp)
{
int gotone = 0;
+ sd = mapSolvable (rp);
PoolItem itemTo = _pool.find (sd);
if (itemFrom && itemTo) {
problemSolution->addSingleAction (itemTo, INSTALL);
+ int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
- if (evrcmp(pool, s.get()->evr, sd.get()->evr, EVRCMP_COMPARE ) > 0)
+ if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
{
string description = str::form (_("downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
MIL << description << endl;
problemSolution->addDescription (description);
gotone = 1;
}
- if (!_solv->allowarchchange && s.get()->name == sd.get()->name && s.get()->arch != sd.get()->arch
- && policy_illegal_archchange(_solv, s.get(), sd.get()))
+ if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
{
string description = str::form (_("architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
MIL << description << endl;
problemSolution->addDescription (description);
gotone = 1;
}
- if (!_solv->allowvendorchange && s.get()->name == sd.get()->name && s.get()->vendor != sd.get()->vendor
- && policy_illegal_vendorchange(_solv, s.get(), sd.get()))
+ if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
{
IdString s_vendor( s.vendor() );
IdString sd_vendor( sd.vendor() );
if (ignoreId > 0) {
// There is a possibility to ignore this error by setting weak dependencies
PoolItem item = _pool.find (sat::Solvable(ignoreId));
- ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(resolverProblem, item);
+ ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(item);
resolverProblem->addSolution (problemSolution,
false); // Solutions will be shown at the end
MIL << "ignore some dependencies of " << item << endl;
return resolverProblems;
}
-void
-SATResolver::applySolutions (const ProblemSolutionList & solutions)
-{
- for (ProblemSolutionList::const_iterator iter = solutions.begin();
- iter != solutions.end(); ++iter) {
- ProblemSolution_Ptr solution = *iter;
- Resolver dummyResolver(_pool);
- if (!solution->apply (dummyResolver))
- break;
- }
-}
+void SATResolver::applySolutions( const ProblemSolutionList & solutions )
+{ Resolver( _pool ).applySolutions( solutions ); }
void SATResolver::setLocks()
{
- for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); iter++) {
+ for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
if (iter->status().isInstalled()) {
MIL << "Lock installed item " << *iter << endl;
- queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE );
+ queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
queue_push( &(_jobQueue), ident );
} else {
MIL << "Lock NOT installed item " << *iter << endl;
- queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE | MAYBE_CLEANDEPS );
+ queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
queue_push( &(_jobQueue), ident );
}
}
- for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); iter++) {
- sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
- if (iter->status().isInstalled()) {
- MIL << "Keep installed item " << *iter << endl;
- queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE | SOLVER_WEAK);
- queue_push( &(_jobQueue), ident );
- } else {
- MIL << "Keep NOT installed item " << *iter << ident << endl;
- queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE | SOLVER_WEAK | MAYBE_CLEANDEPS );
- queue_push( &(_jobQueue), ident );
+ ///////////////////////////////////////////////////////////////////
+ // Weak locks: Ignore if an item with this name is already installed.
+ // If it's not installed try to keep it this way using a weak delete
+ ///////////////////////////////////////////////////////////////////
+ std::set<IdString> unifiedByName;
+ for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
+ IdString ident( (*iter)->satSolvable().ident() );
+ if ( unifiedByName.insert( ident ).second )
+ {
+ if ( ! ui::Selectable::get( *iter )->hasInstalledObj() )
+ {
+ MIL << "Keep NOT installed name " << ident << " (" << *iter << ")" << endl;
+ queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK | MAYBE_CLEANDEPS );
+ queue_push( &(_jobQueue), ident.id() );
}
+ }
}
}
CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
- for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); iter++) {
- queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE_PROVIDES);
+ for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
+ queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
queue_push( &(_jobQueue), iter->id() );
MIL << "SYSTEM Requires " << *iter << endl;
}
- for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); iter++) {
- queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
+ for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
+ queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
queue_push( &(_jobQueue), iter->id() );
MIL << "SYSTEM Conflicts " << *iter << endl;
}
if ( (*it)->isSystem() )
{
Capability archrule( (*it)->arch(), rpm.c_str(), Capability::PARSED );
- queue_push( &(_jobQueue), SOLVER_INSTALL|SOLVABLE_NAME|SOLVER_ESSENTIAL );
+ queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
queue_push( &(_jobQueue), archrule.id() );
}
}
}
+sat::StringQueue SATResolver::autoInstalled() const
+{
+ sat::StringQueue ret;
+ if ( _satSolver )
+ ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
+ return ret;
+}
+
+sat::StringQueue SATResolver::userInstalled() const
+{
+ sat::StringQueue ret;
+ if ( _satSolver )
+ ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES );
+ return ret;
+}
+
///////////////////////////////////////////////////////////////////
};// namespace detail