Bug159696, Klaus could you please check it ?
authorStefan Schubert <schubi@suse.de>
Wed, 22 Mar 2006 11:48:34 +0000 (11:48 +0000)
committerStefan Schubert <schubi@suse.de>
Wed, 22 Mar 2006 11:48:34 +0000 (11:48 +0000)
zypp/solver/detail/QueueItemUninstall.cc
zypp/solver/detail/Resolver.cc

index e6d143c9420a0ecd125038b48afaafc5f9a7cd48..eeb854e07dea0375767f5eba26a285e35e4d78e8 100644 (file)
@@ -240,6 +240,33 @@ struct EstablishItem
     }
 };
 
+// Handle items which provides a recommend -> remove it soft
+
+struct ProvidesItem
+{
+    const ResPool & pool;
+    QueueItemList & qil;
+    bool soft;
+
+    ProvidesItem (const ResPool & p, QueueItemList &l, bool s)
+       : pool(p)
+       , qil(l)
+       , soft(s)
+    { }
+
+
+    bool operator()( const CapAndItem & cai )
+    {
+       _XDEBUG("remove soft item (" << cai.item << ", " << cai.cap << ")");
+
+       QueueItemUninstall_Ptr uninstall_item = new QueueItemUninstall (pool, cai.item, QueueItemUninstall::EXPLICIT, soft);
+       uninstall_item->setUnlink ();
+       qil.push_back (uninstall_item);
+       return true;
+    }
+};
+
+
 
 //-----------------------------------------------------------------------------
 
@@ -314,7 +341,6 @@ QueueItemUninstall::process (ResolverContext_Ptr context, QueueItemList & qil)
     this->logInfo (context);
     
     context->uninstall (_item, _upgraded_to /*bool*/, _due_to_obsolete, _unlink);
-
     if (status.staysInstalled()) {
        if (! _explicitly_requested
            && _item.status().isLocked()) {
@@ -375,6 +401,21 @@ QueueItemUninstall::process (ResolverContext_Ptr context, QueueItemList & qil)
                          resfilter::ByCapMatch( *iter ),
                          functor::functorRef<bool,CapAndItem>( establish ) );
        }
+
+       // remove the items which have been recommended by the 
+       CapSet recomments = _item->dep (Dep::RECOMMENDS);
+       for (CapSet::const_iterator iter = recomments.begin(); iter != recomments.end(); iter++) {
+           const Capability cap = *iter;
+           _XDEBUG("this recommends " << cap);
+           ProvidesItem provides( pool(), qil, true ); // soft
+
+           Dep dep(Dep::PROVIDES);
+           invokeOnEach( pool().byCapabilityIndexBegin( iter->index(), dep ),
+                         pool().byCapabilityIndexEnd( iter->index(), dep ),
+                         resfilter::ByCapMatch( *iter ),
+                         functor::functorRef<bool,CapAndItem>( provides ) );
+       }
+       
     }
 
  finished:
index d11532e4a7d4c63703208660f6a59ca0b72acf29..89045e8eea306de9ee80872228f8e5cddf2828db 100644 (file)
@@ -840,21 +840,41 @@ transactCaps( const ResPool & pool, const CapSet & caps, bool install, bool soft
        PoolItem_Ref installed = Helper::findInstalledByNameAndKind( pool, it->index(), it->refers() );
        PoolItem_Ref uninstalled = Helper::findUninstalledByNameAndKind( pool, it->index(), it->refers() );
 
-       if (uninstalled
-           && !uninstalled.status().isLocked())
-       {
-           if (soft) 
-               uninstalled.status().setSoftTransact( install, ResStatus::SOLVER );
-           else
-               uninstalled.status().setTransact( install, ResStatus::SOLVER );
-       }
-       if (installed
-           && !installed.status().isLocked())
-       {
-           if (soft) 
-               installed.status().setSoftTransact( false, ResStatus::SOLVER );
-           else
-               installed.status().setTransact( false, ResStatus::SOLVER );
+       if (install) {
+           if (uninstalled
+               && !uninstalled.status().isLocked())
+           {
+               if (soft) 
+                   uninstalled.status().setSoftTransact( install, ResStatus::SOLVER );
+               else
+                   uninstalled.status().setTransact( install, ResStatus::SOLVER );
+           }
+           if (installed
+               && !installed.status().isLocked())
+           {
+               if (soft) 
+                   installed.status().setSoftTransact( false, ResStatus::SOLVER );
+               else
+                   installed.status().setTransact( false, ResStatus::SOLVER );
+           }
+       } else {
+           // uninstall
+           if (uninstalled
+               && !uninstalled.status().isLocked())
+           {
+               if (soft) 
+                   uninstalled.status().setSoftTransact( false, ResStatus::SOLVER );
+               else
+                   uninstalled.status().setTransact( false, ResStatus::SOLVER );
+           }
+           if (installed
+               && !installed.status().isLocked())
+           {
+               if (soft) 
+                   installed.status().setSoftTransact( true, ResStatus::SOLVER );
+               else
+                   installed.status().setTransact( true, ResStatus::SOLVER );
+           }       
        }
        if (!uninstalled
            && !installed)