distinguish between keep and lock in the solver request
authorStefan Schubert <schubi@suse.de>
Fri, 4 Apr 2008 15:05:04 +0000 (15:05 +0000)
committerStefan Schubert <schubi@suse.de>
Fri, 4 Apr 2008 15:05:04 +0000 (15:05 +0000)
zypp/sat/SATResolver.cc
zypp/sat/SATResolver.h

index f38d7e0..292d71c 100644 (file)
@@ -215,6 +215,12 @@ SATResolver::addPoolItemToLock (PoolItem item)
     _items_to_lock.unique ();
 }
 
+void
+SATResolver::addPoolItemToKeep (PoolItem item)
+{
+    _items_to_keep.push_back (item);
+    _items_to_keep.unique ();
+}
 
 //---------------------------------------------------------------------------
 
@@ -337,10 +343,13 @@ struct SATCollectTransact : public resfilter::PoolItemFilterFunctor
            resolver.addPoolItemToRemove(item);         // -> remove !
        }
         else if (status.isLocked()
-                 || (status.isKept()
-                     && !by_solver)) {
-            resolver.addPoolItemToLock (item);
+                && !by_solver) {
+           resolver.addPoolItemToLock (item);
         }
+        else if (status.isKept()
+                && !by_solver) {
+           resolver.addPoolItemToKeep (item);
+        }      
 
        return true;
     }
@@ -396,6 +405,7 @@ SATResolver::resolvePool(const CapabilitySet & requires_caps,
     _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) );
@@ -444,6 +454,19 @@ SATResolver::resolvePool(const CapabilitySet & requires_caps,
        }
     }
 
+    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 << " with the string ID: " << ident << endl;
+           queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE | SOLVER_WEAK);
+           queue_push( &(_jobQueue), ident );
+       } else {
+           MIL << "Keep NOT installed item " << *iter << " with the string ID: " << ident << endl;
+           queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE | SOLVER_WEAK);
+           queue_push( &(_jobQueue), ident );
+       }
+    }    
+
     _solv = solver_create( _SATPool, sat::Pool::instance().systemRepo().get() );
     _solv->vendorCheckCb = &vendorCheck;
     _solv->fixsystem = _fixsystem;
index 0ea8b04..2ae1486 100644 (file)
@@ -68,6 +68,7 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
     PoolItemList _items_to_install;
     PoolItemList _items_to_remove;
     PoolItemList _items_to_lock;
+    PoolItemList _items_to_keep;    
 
     bool _fixsystem;                   // repair errors in rpm dependency graph 
     bool _allowdowngrade;              // allow to downgrade installed solvable 
@@ -108,6 +109,7 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
     void addPoolItemsToInstallFromList (PoolItemList & rl);
 
     void addPoolItemToLock (PoolItem item);
+    void addPoolItemToKeep (PoolItem item);    
 
     void addPoolItemToRemove (PoolItem item);
     void addPoolItemsToRemoveFromList (PoolItemList & rl);