Checking delete request if the reason for is an update/upgrade.
authorStefan Schubert <schubi@suse.de>
Thu, 10 Jan 2008 14:42:01 +0000 (14:42 +0000)
committerStefan Schubert <schubi@suse.de>
Thu, 10 Jan 2008 14:42:01 +0000 (14:42 +0000)
zypp/sat/SATResolver.cc

index 8baa23e1c62d9380f6fd46877ceea72a2cdf68de..772ec3f49f8bdebe79ffd4281589272c5589949c 100644 (file)
@@ -357,6 +357,29 @@ struct SATCollectTransact : public resfilter::PoolItemFilterFunctor
 //----------------------------------------------------------------------------
 
 
+class CheckIfUpdate : public resfilter::PoolItemFilterFunctor
+{
+  public:
+    bool is_updated;
+
+    CheckIfUpdate()
+       : is_updated( false )
+    {}
+
+    // check this item will be installed
+
+    bool operator()( PoolItem_Ref item )
+    {
+       if (item.status().isToBeInstalled())    
+       {
+           is_updated = true;
+           return false;
+       }
+       return true;
+    }
+};
+
+
 bool
 SATResolver::resolvePool()
 {
@@ -426,19 +449,6 @@ SATResolver::resolvePool()
        ERR << "Solverrun finished with an ERROR" << endl;
        return false;
     }
-    /* solvables to be erased */
-    for (int i = solv->installed->start; i < solv->installed->start + solv->installed->nsolvables; i++)
-    {
-      if (solv->decisionmap[i] > 0)
-       continue;
-
-      PoolItem_Ref poolItem = _pool.find (sat::Solvable(i));
-      if (poolItem) {
-         SATSolutionToPool (poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER);
-      } else {
-         ERR << "id " << i << " not found in ZYPP pool." << endl;
-      }
-    }
 
     /*  solvables to be installed */
     for (int i = 0; i < solv->decisionq.count; i++)
@@ -458,6 +468,32 @@ SATResolver::resolvePool()
       }
     }
 
+    /* solvables to be erased */
+    for (int i = solv->installed->start; i < solv->installed->start + solv->installed->nsolvables; i++)
+    {
+      if (solv->decisionmap[i] > 0)
+       continue;
+
+      PoolItem_Ref poolItem = _pool.find (sat::Solvable(i));
+      if (poolItem) {
+         // Check if this is an update
+         CheckIfUpdate info;     
+         invokeOnEach( _pool.byNameBegin( poolItem->name() ),
+                       _pool.byNameEnd( poolItem->name() ),
+                       functor::chain (resfilter::ByUninstalled (),                    // ByUninstalled
+                                       resfilter::ByKind( poolItem->kind() ) ),        // equal kind
+                       functor::functorRef<bool,PoolItem> (info) );
+         
+         if (info.is_updated) {
+             SATSolutionToPool (poolItem, ResStatus::toBeUninstalledDueToUpgrade , ResStatus::SOLVER);
+         } else {
+             SATSolutionToPool (poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER);
+         }
+      } else {
+         ERR << "id " << i << " not found in ZYPP pool." << endl;
+      }
+    }
+
     // clean up
     solver_free(solv);
     solv = NULL;