From cac412e10c843d5a56022d0feebecce55d39ab90 Mon Sep 17 00:00:00 2001 From: Klaus Kaempf Date: Mon, 3 Apr 2006 17:28:13 +0000 Subject: [PATCH] add Resolver::freshenPool() (#156980) --- zypp/Resolver.cc | 2 ++ zypp/Resolver.h | 15 ++++++++ zypp/solver/detail/Resolver.cc | 81 ++++++++++++++++++++++++++++++++++++++++-- zypp/solver/detail/Resolver.h | 4 ++- 4 files changed, 98 insertions(+), 4 deletions(-) diff --git a/zypp/Resolver.cc b/zypp/Resolver.cc index 3b5fa63..5ea5d1b 100644 --- a/zypp/Resolver.cc +++ b/zypp/Resolver.cc @@ -60,6 +60,8 @@ namespace zypp { return _pimpl->verifySystem(); } bool Resolver::establishPool () { return _pimpl->establishPool(); } + bool Resolver::freshenPool () + { return _pimpl->freshenPool(); } bool Resolver::resolvePool () { return _pimpl->resolvePool (); } void Resolver::undo() diff --git a/zypp/Resolver.h b/zypp/Resolver.h index 73117cb..2d79961 100644 --- a/zypp/Resolver.h +++ b/zypp/Resolver.h @@ -70,6 +70,21 @@ namespace zypp bool establishPool (void); /** + * go through all package 'freshen' dependencies and + * schedule matches for installation. + * + * To be called at begin of installation and upgrade. + * Probably also useful after adding a new package + * repository. + * + * return true if it was successful + * return false if not (this will only happen if other + * transactions are in the pool which will lead to + * no solution) + **/ + bool freshenPool (void); + + /** * Resolve package dependencies: * * Try to execute all pending transactions (there may be more than diff --git a/zypp/solver/detail/Resolver.cc b/zypp/solver/detail/Resolver.cc index db4a576..5545faa 100644 --- a/zypp/solver/detail/Resolver.cc +++ b/zypp/solver/detail/Resolver.cc @@ -385,8 +385,6 @@ solution_to_pool (PoolItem_Ref item, const ResStatus & status, void *data) //--------------------------------------------------------------------------- - - // establish state struct EstablishState @@ -406,7 +404,7 @@ struct EstablishState void -Resolver::establishState (ResolverContext_Ptr context) +Resolver::establishState( ResolverContext_Ptr context ) { _DEBUG( "Resolver::establishState ()" ); typedef list KindList; @@ -476,6 +474,83 @@ Resolver::establishPool () return true; } + +//--------------------------------------------------------------------------- +// freshen state + +struct FreshenState +{ + Resolver & resolver; + + FreshenState (Resolver & r) + : resolver (r) + { } + + bool operator()( PoolItem_Ref item) + { + CapSet freshens( item->dep( Dep::FRESHENS ) ); + if (!freshens.empty()) + resolver.addPoolItemToEstablish( item ); + return true; + } +}; + + +void +Resolver::freshenState( ResolverContext_Ptr context ) +{ + _DEBUG( "Resolver::freshenState ()" ); + + if (context == NULL) + context = new ResolverContext( _pool, _architecture ); + + context->setEstablishing( true ); + context->setIgnoreCababilities( _ignoreConflicts, + _ignoreRequires, + _ignoreObsoletes, + _ignoreInstalledItem, + _ignoreArchitectureItem ); + context->setForceResolve( _forceResolve ); + context->setUpgradeMode( _upgradeMode ); + + FreshenState info( *this ); + + invokeOnEach( pool().byKindBegin( ResTraits::kind ), + pool().byKindEnd( ResTraits::kind ), + functor::functorRef(info) ); + + // process the queue + resolveDependencies( context ); + + reset(); + + context->setEstablishing( false ); + + _best_context = context; + + return; +} + + +bool +Resolver::freshenPool () +{ + MIL << "Resolver::freshenPool()" << endl; + + freshenState (); // establish all packages with freshens ! + ResolverContext_Ptr solution = bestContext(); + + if (solution) { // copy solution back to pool + solution->foreachMarked (solution_to_pool, (void *)1); // as APPL_HIGH + } + else { + ERR << "freshenState did not return a bestContext" << endl; + return false; + } + + return true; +} + //--------------------------------------------------------------------------- bool diff --git a/zypp/solver/detail/Resolver.h b/zypp/solver/detail/Resolver.h index edba991..12e05d5 100644 --- a/zypp/solver/detail/Resolver.h +++ b/zypp/solver/detail/Resolver.h @@ -184,8 +184,10 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable { const bool forceResolve() { return _forceResolve; } bool verifySystem (void); - void establishState (const ResolverContext_Ptr context = NULL); + void establishState (ResolverContext_Ptr context = NULL); bool establishPool (void); + void freshenState( ResolverContext_Ptr context = NULL ); + bool freshenPool( void ); bool resolveDependencies (const ResolverContext_Ptr context = NULL); bool resolvePool (void); -- 2.7.4