actNumber++;
}
+void ProblemSolutionCombi::addSingleAction( SolverQueueItem_Ptr item, const TransactionKind action)
+{
+ addAction (new TransactionSolutionAction(item, action));
+ actNumber++;
+}
+
void ProblemSolutionCombi::addDescription( const std::string description)
{
if ( _description.size() == 0
#include <string>
#include "zypp/ProblemSolution.h"
#include "zypp/solver/detail/Types.h"
+#include "zypp/solver/detail/SolverQueueItem.h"
/////////////////////////////////////////////////////////////////////////
namespace zypp
void addSingleAction( PoolItem item, const TransactionKind action);
/**
- * Add a single action of an capability
+ * Add a single action of a capability
*/
- void addSingleAction( Capability capability, const TransactionKind action);
+ void addSingleAction( Capability capability, const TransactionKind action);
+
+ /**
+ * Add a single action of a SolverQueueItem
+ */
+ void addSingleAction( SolverQueueItem_Ptr item, const TransactionKind action);
/**
* returns the number of actions
: _pool(pool)
, _satResolver(NULL)
, _poolchanged(_pool.serial() )
+ , _testing(false)
, _forceResolve(false)
, _upgradeMode(false)
, _verifying(false)
_extra_conflicts.erase (capability);
}
+
+void Resolver::removeQueueItem (const SolverQueueItem_Ptr item)
+{
+ bool found = false;
+ for (SolverQueueItemList::const_iterator iter = _added_queue_items.begin();
+ iter != _added_queue_items.end(); iter++) {
+ if (*iter == item) {
+ _added_queue_items.remove(*iter);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ _removed_queue_items.push_back (item);
+ _removed_queue_items.unique ();
+ }
+}
+void Resolver::addQueueItem (const SolverQueueItem_Ptr item)
+{
+ bool found = false;
+ for (SolverQueueItemList::const_iterator iter = _removed_queue_items.begin();
+ iter != _removed_queue_items.end(); iter++) {
+ if (*iter == item) {
+ _removed_queue_items.remove(*iter);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ _added_queue_items.push_back (item);
+ _added_queue_items.unique ();
+ }
+}
+
void
Resolver::addWeak (const PoolItem item)
{
// Regard dependencies of the item weak onl
_addWeak.clear();
+ // Additional QueueItems which has to be regarded by the solver
+ _removed_queue_items.clear();
+ _added_queue_items.clear();
+
return;
}
Resolver::resolveQueue(solver::detail::SolverQueueItemList & queue)
{
solverInit();
+
+ // add/remove additional SolverQueueItems
+ for (SolverQueueItemList::const_iterator iter = _removed_queue_items.begin();
+ iter != _removed_queue_items.end(); iter++) {
+ for (SolverQueueItemList::const_iterator iterQueue = queue.begin(); iterQueue != queue.end(); iterQueue++) {
+ if ( (*iterQueue)->cmp(*iter) == 0) {
+ MIL << "remove from queue" << *iter;
+ queue.remove(*iterQueue);
+ break;
+ }
+ }
+ }
+
+ for (SolverQueueItemList::const_iterator iter = _added_queue_items.begin();
+ iter != _added_queue_items.end(); iter++) {
+ bool found = false;
+ for (SolverQueueItemList::const_iterator iterQueue = queue.begin(); iterQueue != queue.end(); iterQueue++) {
+ if ( (*iterQueue)->cmp(*iter) == 0) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ MIL << "add to queue" << *iter;
+ queue.push_back(*iter);
+ }
+ }
+
return _satResolver->resolveQueue(queue, _addWeak);
}
// no recommended resolvables, language
// packages, hardware packages (modalias)
+ // Additional QueueItems which has to be regarded by the solver
+ // This will be used e.g. by solution actions
+ solver::detail::SolverQueueItemList _removed_queue_items;
+ solver::detail::SolverQueueItemList _added_queue_items;
+
// helpers
bool doesObsoleteCapability (PoolItem candidate, const Capability & cap);
bool doesObsoleteItem (PoolItem candidate, PoolItem installed);
void addExtraRequire (const Capability & capability);
void removeExtraRequire (const Capability & capability);
void addExtraConflict (const Capability & capability);
- void removeExtraConflict (const Capability & capability);
+ void removeExtraConflict (const Capability & capability);
+
+ void removeQueueItem (const SolverQueueItem_Ptr item);
+ void addQueueItem (const SolverQueueItem_Ptr item);
const CapabilitySet extraRequires () { return _extra_requires; }
const CapabilitySet extraConflicts () { return _extra_conflicts; }
bool testing(void) const { return _testing; }
void setTesting( bool testing ) { _testing = testing; }
-
+
};
///////////////////////////////////////////////////////////////////
#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"
extern "C" {
#include "satsolver/repo_solv.h"
// helper function
//----------------------------------------------------------------------------
-struct FindPackage : public resfilter::ResObjectFilterFunctor
-{
- ProblemSolutionCombi *problemSolution;
- TransactionKind action;
- FindPackage (ProblemSolutionCombi *p, const TransactionKind act)
- : problemSolution (p)
- , action (act)
- {
- }
-
- bool operator()( PoolItem p)
- {
- problemSolution->addSingleAction (p, action);
- return true;
- }
-};
-
string SATResolver::SATprobleminfoString(Id problem, string &detail, Id &ignoreId)
{
break;
case SOLVER_INSTALL_SOLVABLE_NAME:
{
- FindPackage info (problemSolution, KEEP);
- IdString ident( what );
- invokeOnEach( _pool.byIdentBegin( ident ),
- _pool.byIdentEnd( ident ),
- resfilter::ByUninstalled (),
- functor::functorRef<bool,PoolItem> (info) );
+ IdString ident( what );
+ SolverQueueItemInstall_Ptr install =
+ new SolverQueueItemInstall(_pool, ident.asString(), false );
+ problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
+
string description = str::form (_("do not install %s"), ident.c_str() );
MIL << description << endl;
problemSolution->addDescription (description);
break;
case SOLVER_ERASE_SOLVABLE_NAME:
{
- FindPackage info (problemSolution, KEEP);
IdString ident( what );
- invokeOnEach( _pool.byIdentBegin( ident ),
- _pool.byIdentEnd( ident ),
- functor::chain (resfilter::ByInstalled (), // ByInstalled
- resfilter::ByTransact ()), // will be deinstalled
- functor::functorRef<bool,PoolItem> (info) );
+ SolverQueueItemDelete_Ptr del =
+ new SolverQueueItemDelete(_pool, ident.asString(), false );
+ problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
+
string description = str::form (_("keep %s"), ident.c_str());
MIL << description << endl;
problemSolution->addDescription (description);
break;
case SOLVER_INSTALL_SOLVABLE_PROVIDES:
{
- problemSolution->addSingleAction (Capability(what), REMOVE_REQUIRE);
+ problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
string description = str::form (_("do not ask to install a solvable providing %s"), dep2str(pool, what));
MIL << description << endl;
problemSolution->addDescription (description);
break;
case SOLVER_ERASE_SOLVABLE_PROVIDES:
{
- problemSolution->addSingleAction (Capability(what), REMOVE_CONFLICT);
+ problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
string description = str::form (_("do not ask to delete all solvables providing %s"), dep2str(pool, what));
MIL << description << endl;
problemSolution->addDescription (description);
{
os << "TransactionSolutionAction: ";
switch (_action) {
- case KEEP: os << "Keep " << _item; break;
- case INSTALL: os << "Install " << _item; break;
- case REMOVE: os << "Remove " << _item; break;
- case UNLOCK: os << "Unlock " << _item; break;
- case REMOVE_REQUIRE: os << "Remove require " << _capability; break;
- case REMOVE_CONFLICT: os << "Remove conflict " << _capability; break;
+ case KEEP: os << "Keep " << _item; break;
+ case INSTALL: os << "Install " << _item; break;
+ case REMOVE: os << "Remove " << _item; break;
+ case UNLOCK: os << "Unlock " << _item; break;
+ case REMOVE_EXTRA_REQUIRE: os << "Remove require " << _capability; break;
+ case REMOVE_EXTRA_CONFLICT: os << "Remove conflict " << _capability; break;
+ case ADD_SOLVE_QUEUE_ITEM: os << "Add SolveQueueItem " << _solverQueueItem; break;
+ case REMOVE_SOLVE_QUEUE_ITEM: os << "Remove SolveQueueItem " << _solverQueueItem; break;
}
os << endl;
ret = _item.status().setLock (false, ResStatus::USER);
if (!ret) ERR << "Cannot unlock " << _item << endl;
break;
- case REMOVE_REQUIRE:
+ case REMOVE_EXTRA_REQUIRE:
resolver.removeExtraRequire (_capability);
break;
- case REMOVE_CONFLICT:
+ case REMOVE_EXTRA_CONFLICT:
resolver.removeExtraConflict (_capability);
- break;
+ break;
+ case ADD_SOLVE_QUEUE_ITEM:
+ resolver.addQueueItem(_solverQueueItem);
+ break;
+ case REMOVE_SOLVE_QUEUE_ITEM:
+ resolver.removeQueueItem(_solverQueueItem);
+ break;
default:
ERR << "Wrong TransactionKind" << endl;
ret = false;
#include "zypp/solver/detail/Types.h"
#include "zypp/solver/detail/Resolver.h"
+#include "zypp/solver/detail/SolverQueueItem.h"
/////////////////////////////////////////////////////////////////////////
namespace zypp
INSTALL,
REMOVE,
UNLOCK,
- REMOVE_REQUIRE,
- REMOVE_CONFLICT,
+ REMOVE_EXTRA_REQUIRE,
+ REMOVE_EXTRA_CONFLICT,
+ ADD_SOLVE_QUEUE_ITEM,
+ REMOVE_SOLVE_QUEUE_ITEM,
} TransactionKind;
: SolutionAction(),
_capability( capability ), _action( action ) {}
+
+ TransactionSolutionAction( SolverQueueItem_Ptr item,
+ TransactionKind action )
+ : SolutionAction(),
+ _solverQueueItem( item ), _action( action ) {}
+
TransactionSolutionAction( TransactionKind action )
: SolutionAction(),
_item(), _action( action ) {}
// ---------------------------------- accessors
const PoolItem item() const { return _item; }
+ const Capability capability() const { return _capability; }
TransactionKind action() const { return _action; }
// ---------------------------------- methods
PoolItem _item;
Capability _capability;
+ SolverQueueItem_Ptr _solverQueueItem;
+
const TransactionKind _action;
};
virtual int cmp (SolverQueueItem_constPtr item) const = 0;
int compare (SolverQueueItem_constPtr item) const { return CMP(_type, item->_type); }
-
};
///////////////////////////////////////////////////////////////////
SolverQueueItemDelete_constPtr del = dynamic_pointer_cast<const SolverQueueItemDelete>(item);
if (_name != del->_name) {
return _name.compare(del->_name);
- } else {
- if (_soft == del->_soft) {
- return 0;
- } else {
- if (_soft)
- return 1;
- else
- return -1;
- }
}
+ return 0;
}
//---------------------------------------------------------------------------
SolverQueueItemInstall_constPtr ins = dynamic_pointer_cast<const SolverQueueItemInstall>(item);
if (_name != ins->_name) {
return _name.compare(ins->_name);
- } else {
- if (_soft == ins->_soft) {
- return 0;
- } else {
- if (_soft)
- return 1;
- else
- return -1;
- }
- }
+ }
+ return 0;
}