IMPL_PTR_TYPE(Resolver);
static const unsigned MAX_SECOND_RUNS( 3 );
-static const unsigned MAX_VALID_SOLUTIONS( 50 );
+static const unsigned MAX_VALID_SOLUTIONS( 50 );
static const unsigned TIMOUT_SECOND_RUN( 30 );
static PoolItemSet triggeredSolution; // only the latest state of an item is interesting
{ return compareByNVRA(p1.resolvable(),p2.resolvable()) < 0; }
};
-
+
std::ostream &
Resolver::dumpOn( std::ostream & os ) const
{
Resolver::Resolver (const ResPool & pool)
: _pool (pool)
+ , _poolchanged( _pool.serial() )
, _timeout_seconds (0)
, _maxSolverPasses (0)
, _verifying (false)
, _forceResolve (false)
, _upgradeMode (false)
, _preferHighestVersion (true)
-
-{}
+
+{
+ //if ( _poolchanged.remember( _pool.serial() ) )
+ //{
+ // SEC << "CHANGED" << endl;
+ //}
+}
Resolver::~Resolver()
if (resetValidResults)
contextPool.reset();
-
+
}
//--------------------------------------------------------------------------------------------------
if (needed_by->items().size() >= 1) {
PoolItem_Ref item = info->affected();
PoolItemList itemList = needed_by->items();
-
+
for (PoolItemList::const_iterator iter = itemList.begin();
iter != itemList.end(); iter++) {
bool found = false;
&& !found) {
ItemCapKind capKind = pos->second;
if (capKind.item == item) found = true;
- pos++;
- }
+ pos++;
+ }
if (!found) {
ItemCapKind capKindReverse( item, needed_by->capability(), needed_by->capKind(), needed_by->initialInstallation() );
collector->installs.insert (make_pair( *iter, capKindReverse));
}
}
-
+
}
}
}
-
-void
+
+void
Resolver::collectResolverInfo(void)
{
ResolverContext_Ptr collectContext = context(); // best context or failed context
const ItemCapKindList Resolver::isInstalledBy (const PoolItem_Ref item) {
ItemCapKindList ret;
collectResolverInfo();
-
+
for (ItemCapKindMap::const_iterator iter = _isInstalledBy.find(item); iter != _isInstalledBy.end();) {
ItemCapKind info = iter->second;
PoolItem_Ref iterItem = iter->first;
} else {
// exit
iter = _isInstalledBy.end();
- }
+ }
}
return ret;
}
const ItemCapKindList Resolver::installs (const PoolItem_Ref item) {
ItemCapKindList ret;
collectResolverInfo();
-
+
for (ItemCapKindMap::const_iterator iter = _installs.find(item); iter != _installs.end();) {
ItemCapKind info = iter->second;
PoolItem_Ref iterItem = iter->first;
} else {
// exit
iter = _installs.end();
- }
+ }
}
- return ret;
+ return ret;
}
}
if (!found) {
_items_to_remove.push_back (item);
- _items_to_remove.unique ();
+ _items_to_remove.unique ();
}
}
Resolver::verifySystem (bool considerNewHardware)
{
UndoTransact resetting (ResStatus::APPL_HIGH);
-
+
_DEBUG ("Resolver::verifySystem() " << (considerNewHardware ? "consider new hardware":""));
invokeOnEach ( _pool.begin(), _pool.end(),
invokeOnEach( pool().byKindBegin( ResTraits<Pattern>::kind ),
pool().byKindEnd( ResTraits<Pattern>::kind ),
resfilter::ByInstalled ( ),
- functor::functorRef<bool,PoolItem>(info) );
+ functor::functorRef<bool,PoolItem>(info) );
_verifying = true;
DoTransact setting (ResStatus::APPL_HIGH);
invokeOnEach ( _pool.begin(), _pool.end(),
- resfilter::ByTransact( ),
- functor::functorRef<bool,PoolItem>(setting) );
-
+ resfilter::ByTransact( ),
+ functor::functorRef<bool,PoolItem>(setting) );
+
return success;
}
// resetting transaction only
item.status().resetTransact((data != NULL) ? ResStatus::APPL_LOW : ResStatus::SOLVER );
-
+
bool r;
if (status.isToBeInstalled()) {
_ignoreInstalledItem,
_ignoreArchitectureItem);
context->setForceResolve( _forceResolve );
- context->setEstablishContext( _establish_context );
+ context->setEstablishContext( _establish_context );
context->setPreferHighestVersion ( _preferHighestVersion );
context->setUpgradeMode( _upgradeMode );
ResolverContext_Ptr solution = bestContext();
if (solution) { // copy solution back to pool
- triggeredSolution.clear();
+ triggeredSolution.clear();
solution->foreachMarked (solution_to_pool, (void *)1); // as APPL_LOW
}
else {
_ignoreInstalledItem,
_ignoreArchitectureItem );
context->setForceResolve( _forceResolve );
- context->setEstablishContext( _establish_context );
+ context->setEstablishContext( _establish_context );
context->setPreferHighestVersion( _preferHighestVersion );
context->setUpgradeMode( _upgradeMode );
// process the queue
resolveDependencies( context );
-
+
if (resetAfterSolve) {
- reset( false, true ); //resetValidResults,keepExtras
+ reset( false, true ); //resetValidResults,keepExtras
context->setEstablishing( false );
_best_context = context;
}
ignoreRequires.insert(make_pair(PoolItem_Ref(), *cit));
}
}
-
+
// Initialize all ignoring dependencies
initial_queue->context()->setIgnoreCababilities (_ignoreConflicts,
ignoreRequires,
_ignoreInstalledItem,
_ignoreArchitectureItem);
initial_queue->context()->setForceResolve( _forceResolve );
- initial_queue->context()->setEstablishContext( _establish_context );
+ initial_queue->context()->setEstablishContext( _establish_context );
initial_queue->context()->setPreferHighestVersion( _preferHighestVersion );
initial_queue->context()->setUpgradeMode( _upgradeMode );
initial_queue->context()->setTryAllPossibilities( _tryAllPossibilities );
for (CapSet::const_iterator iter = _extra_caps.begin(); iter != _extra_caps.end(); iter++) {
initial_queue->addExtraCapability (*iter);
}
-
+
// adding "external" requires
additionalCapSet = pool().additionalRequire();
for (ResPool::AdditionalCapSet::const_iterator it = additionalCapSet.begin();
it != additionalCapSet.end(); it++) {
CapSet cset = it->second;
for (CapSet::const_iterator cit = cset.begin(); cit != cset.end(); ++cit) {
- initial_queue->addExtraCapability (*cit);
+ initial_queue->addExtraCapability (*cit);
}
}
it != additionalCapSet.end(); it++) {
CapSet cset = it->second;
for (CapSet::const_iterator cit = cset.begin(); cit != cset.end(); ++cit) {
- initial_queue->addExtraConflict (*cit);
+ initial_queue->addExtraConflict (*cit);
}
}
<< " ) reached -> exit" << endl;
break;
}
-
+
ResolverQueue_Ptr queue = _pending_queues.front();
_pending_queues.pop_front();
ResolverContext_Ptr context = queue->context();
<< " / Prun " << (long) _pruned_queues.size()
<< " / Defr " << (long) _deferred_queues.size()
<< " / Invl " << (long) _invalid_queues.size() );
-
+
return _best_context && _best_context->isValid();
}
WAR << "Can't find " << item << " for re-installation" << endl;
}
}
-
+
if (status.isLocked()
&& status.isUninstalled()) {
// This item could be selected by solver in a former run. Now it
// is locked. So we will have to evaluate a new solver run.
resolver.addPoolItemToLockUninstalled (item);
}
-
+
return true;
}
};
<< endl;
MIL << "Solver run with ALL possibilities"
<< endl;
- if (_maxSolverPasses <= 0)
- _maxSolverPasses = MAX_SECOND_RUNS;
- if (_timeout_seconds <= 0)
+ if (_maxSolverPasses <= 0)
+ _maxSolverPasses = MAX_SECOND_RUNS;
+ if (_timeout_seconds <= 0)
_timeout_seconds = TIMOUT_SECOND_RUN;
-
+
MIL << "But no longer than " << MAX_SECOND_RUNS << " runs or "
<< TIMOUT_SECOND_RUN << " seconds" << endl;
MIL << "================================================================" << endl;
PoolItemList _completeItems_to_install = _items_to_install;
PoolItemList _completeItems_to_remove = _items_to_remove;
PoolItemList _completeItems_to_lockUninstalled = _items_to_lockUninstalled;
-
+
// We have to find a valid context in order to recycle it.
saveContext = contextPool.findContext (_items_to_install, _items_to_remove, _items_to_lockUninstalled);
// _items_to_install, _items_to_remove contains addition items which has been selected but are
- // not solved with that context. They will be solved now.
+ // not solved with that context. They will be solved now.
// If we have not found any former fitting context, saveContext is NULL. So the solver
// make a complete run
if (saveContext != NULL) {
// create a new context in order not overwriting the old
saveContext = new ResolverContext (saveContext->pool(), saveContext->architecture(), saveContext);
- saveContext->setTryAllPossibilities( true );
+ saveContext->setTryAllPossibilities( true );
}
bool have_solution = resolveDependencies (saveContext); // resolve !
if (have_solution) { // copy solution back to pool
MIL << "Have solution, copying back to pool" << endl;
ResolverContext_Ptr solution = bestContext();
- triggeredSolution.clear();
+ triggeredSolution.clear();
solution->foreachMarked (solution_to_pool, NULL);
#if 1
_XDEBUG( "Pool after resolve" );
#endif
// insert best_context in ContextPool for further solver runs
contextPool.addContext( solution,_completeItems_to_install, _completeItems_to_remove, _completeItems_to_lockUninstalled);
-
+
}
else {
MIL << "!!! Have NO solution !!! Additional solver information:" << endl;
counter++;
MIL << "-----------------------------------------------------------------" << endl;
MIL << counter++ << ". failed queue:" << endl;
- ResolverQueue_Ptr invalid = *iter;
+ ResolverQueue_Ptr invalid = *iter;
// invalid->context()->spewInfo (); No additional information needed here
MIL << *invalid->context() << endl;
- MIL << "-----------------------------------------------------------------" << endl;
+ MIL << "-----------------------------------------------------------------" << endl;
}
}
if (tryAllPossibilities) {
_tryAllPossibilities = saveTryAllPossibilities; // reset to old value
}
-
+
return have_solution;
}
{
MIL << "transactResObject()" << endl;
MIL << "is obsolete; use resolvePool() instead" << endl;
-
+
return true;
}
Resolver::transactResKind( Resolvable::Kind kind )
{
MIL << "transactResKind(" << kind << ")" << endl;
- MIL << "is obsolete; use resolvePool() instead" << endl;
+ MIL << "is obsolete; use resolvePool() instead" << endl;
return true;
}
#include "zypp/base/PtrTypes.h"
#include "zypp/ResPool.h"
+#include "zypp/base/SerialNumber.h"
#include "zypp/solver/detail/Types.h"
#include "zypp/solver/detail/ResolverQueue.h"
/////////////////////////////////////////////////////////////////////
namespace detail
{ ///////////////////////////////////////////////////////////////////
-
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : ItemCapKind
{ }
};
typedef std::multimap<PoolItem_Ref,ItemCapKind> ItemCapKindMap;
- typedef std::list<ItemCapKind> ItemCapKindList;
+ typedef std::list<ItemCapKind> ItemCapKindList;
///////////////////////////////////////////////////////////////////
//
private:
ResPool _pool;
+ SerialNumberWatcher _poolchanged;
unsigned _timeout_seconds;
unsigned _maxSolverPasses;
bool _verifying;
bool _testing;
-
+
// In order reducing solver time we are reducing the branches
// by skipping resolvables which have worse architecture,edition
// than a resolvable which provides the same cababilities.
PoolItemList _items_to_establish;
PoolItemList _items_to_remove;
PoolItemList _items_to_verify;
- PoolItemList _items_to_lockUninstalled;
-
+ PoolItemList _items_to_lockUninstalled;
+
// pool of valid contexts which are "recycled" in order to fasten the solver
ContextPool contextPool;
// Additional information about the solverrun
ItemCapKindMap _isInstalledBy;
ItemCapKindMap _installs;
-
+
CapSet _extra_caps;
CapSet _extra_conflicts;
// These conflict should be ignored of the concering item
IgnoreMap _ignoreConflicts;
- // These requires should be ignored of the concering item
+ // These requires should be ignored of the concering item
IgnoreMap _ignoreRequires;
- // These obsoletes should be ignored of the concering item
- IgnoreMap _ignoreObsoletes;
+ // These obsoletes should be ignored of the concering item
+ IgnoreMap _ignoreObsoletes;
// Ignore architecture of the item
PoolItemList _ignoreArchitecture;
// Ignore the status "installed" of the item
PoolItemList _ignoreInstalledItem;
// Ignore the architecture of the item
- PoolItemList _ignoreArchitectureItem;
-
+ PoolItemList _ignoreArchitectureItem;
+
ResolverQueueList _pending_queues;
ResolverQueueList _pruned_queues;
ResolverContext_Ptr _best_context;
// Context of the last establishing call ( without any transaction )
- ResolverContext_Ptr _establish_context;
+ ResolverContext_Ptr _establish_context;
bool _timed_out;
std::set<Repository> _subscribed;
// This behaviour is favourited by ZMD
bool _upgradeMode; // Resolver has been called with doUpgrade
bool _preferHighestVersion; // Prefer the result with the newest version
- //if there are more solver results.
+ //if there are more solver results.
// helpers
bool doesObsoleteCapability (PoolItem_Ref candidate, const Capability & cap);
bool doesObsoleteItem (PoolItem_Ref candidate, PoolItem_Ref installed);
void collectResolverInfo (void);
-
+
public:
friend std::ostream& operator<<(std::ostream& str, const Resolver & obj)
{ return obj.dumpOn (str); }
void dumpTaskList(const PoolItemList &install, const PoolItemList &remove );
-
+
// ---------------------------------- accessors
QueueItemList initialItems () const { return _initial_items; }
void addIgnoreObsoletes (const PoolItem_Ref item,
const Capability & capability);
void addIgnoreInstalledItem (const PoolItem_Ref item);
- void addIgnoreArchitectureItem (const PoolItem_Ref item);
+ void addIgnoreArchitectureItem (const PoolItem_Ref item);
void setForceResolve (const bool force) { _forceResolve = force; }
const bool forceResolve() { return _forceResolve; }
void setTryAllPossibilities (const bool tryAllPossibilities) { _tryAllPossibilities = tryAllPossibilities; }
const bool tryAllPossibilities () { return _tryAllPossibilities; };
-
+
bool verifySystem (bool considerNewHardware = false);
void establishState (ResolverContext_Ptr context = NULL);
bool establishPool (void);
// Get more information about the solverrun
// Which item will be installed by another item or triggers an item for
- // installation
+ // installation
const ItemCapKindList isInstalledBy (const PoolItem_Ref item);
const ItemCapKindList installs (const PoolItem_Ref item);