From 76cb1aded30f547ed6fe412355bafcacb6e48e91 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Wed, 22 Mar 2006 11:48:34 +0000 Subject: [PATCH] Bug159696, Klaus could you please check it ? --- zypp/solver/detail/QueueItemUninstall.cc | 43 +++++++++++++++++++- zypp/solver/detail/Resolver.cc | 50 +++++++++++++++++------- 2 files changed, 77 insertions(+), 16 deletions(-) diff --git a/zypp/solver/detail/QueueItemUninstall.cc b/zypp/solver/detail/QueueItemUninstall.cc index e6d143c94..eeb854e07 100644 --- a/zypp/solver/detail/QueueItemUninstall.cc +++ b/zypp/solver/detail/QueueItemUninstall.cc @@ -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( 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( provides ) ); + } + } finished: diff --git a/zypp/solver/detail/Resolver.cc b/zypp/solver/detail/Resolver.cc index d11532e4a..89045e8ee 100644 --- a/zypp/solver/detail/Resolver.cc +++ b/zypp/solver/detail/Resolver.cc @@ -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) -- 2.34.1