Author: schubi2
Date: Thu May 15 14:15:53 2008
New Revision: 10100
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10100&view=rev
Log:
added solutions for ResolveQueue
Modified:
trunk/libzypp/zypp/solver/detail/ProblemSolutionCombi.cc
trunk/libzypp/zypp/solver/detail/ProblemSolutionCombi.h
trunk/libzypp/zypp/solver/detail/Resolver.cc
trunk/libzypp/zypp/solver/detail/Resolver.h
trunk/libzypp/zypp/solver/detail/SATResolver.cc
trunk/libzypp/zypp/solver/detail/SolutionAction.cc
trunk/libzypp/zypp/solver/detail/SolutionAction.h
trunk/libzypp/zypp/solver/detail/SolverQueueItem.h
trunk/libzypp/zypp/solver/detail/SolverQueueItemDelete.cc
trunk/libzypp/zypp/solver/detail/SolverQueueItemInstall.cc
Modified: trunk/libzypp/zypp/solver/detail/ProblemSolutionCombi.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/ProblemSolutionCombi.cc?rev=10100&r1=10099&r2=10100&view=diff
==============================================================================
--- trunk/libzypp/zypp/solver/detail/ProblemSolutionCombi.cc (original)
+++ trunk/libzypp/zypp/solver/detail/ProblemSolutionCombi.cc Thu May 15 14:15:53 2008
@@ -65,6 +65,12 @@
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
Modified: trunk/libzypp/zypp/solver/detail/ProblemSolutionCombi.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/ProblemSolutionCombi.h?rev=10100&r1=10099&r2=10100&view=diff
==============================================================================
--- trunk/libzypp/zypp/solver/detail/ProblemSolutionCombi.h (original)
+++ trunk/libzypp/zypp/solver/detail/ProblemSolutionCombi.h Thu May 15 14:15:53 2008
@@ -25,6 +25,7 @@
#include <string>
#include "zypp/ProblemSolution.h"
#include "zypp/solver/detail/Types.h"
+#include "zypp/solver/detail/SolverQueueItem.h"
/////////////////////////////////////////////////////////////////////////
namespace zypp
@@ -58,9 +59,14 @@
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
Modified: trunk/libzypp/zypp/solver/detail/Resolver.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Resolver.cc?rev=10100&r1=10099&r2=10100&view=diff
==============================================================================
--- trunk/libzypp/zypp/solver/detail/Resolver.cc (original)
+++ trunk/libzypp/zypp/solver/detail/Resolver.cc Thu May 15 14:15:53 2008
@@ -69,6 +69,7 @@
: _pool(pool)
, _satResolver(NULL)
, _poolchanged(_pool.serial() )
+ , _testing(false)
, _forceResolve(false)
, _upgradeMode(false)
, _verifying(false)
@@ -133,6 +134,40 @@
_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)
{
@@ -202,6 +237,10 @@
// 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;
}
@@ -262,6 +301,34 @@
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);
}
Modified: trunk/libzypp/zypp/solver/detail/Resolver.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Resolver.h?rev=10100&r1=10099&r2=10100&view=diff
==============================================================================
--- trunk/libzypp/zypp/solver/detail/Resolver.h (original)
+++ trunk/libzypp/zypp/solver/detail/Resolver.h Thu May 15 14:15:53 2008
@@ -91,6 +91,11 @@
// 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);
@@ -121,7 +126,10 @@
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; }
@@ -153,7 +161,7 @@
bool testing(void) const { return _testing; }
void setTesting( bool testing ) { _testing = testing; }
-
+
};
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/solver/detail/SATResolver.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/SATResolver.cc?rev=10100&r1=10099&r2=10100&view=diff
==============================================================================
--- trunk/libzypp/zypp/solver/detail/SATResolver.cc (original)
+++ trunk/libzypp/zypp/solver/detail/SATResolver.cc Thu May 15 14:15:53 2008
@@ -36,6 +36,8 @@
#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"
@@ -836,23 +838,6 @@
// 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)
{
@@ -1040,12 +1025,11 @@
break;
case SOLVER_INSTALL_SOLVABLE_NAME:
{
- FindPackage info (problemSolution, KEEP);
- IdString ident( what );
- invokeOnEach( _pool.byIdentBegin( ident ),
- _pool.byIdentEnd( ident ),
- resfilter::ByUninstalled (),
- functor::functorRef