1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * Copyright (C) 2000-2002 Ximian, Inc.
5 * Copyright (C) 2005 SUSE Linux Products GmbH
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 #include <solv/repo_solv.h>
24 #include <solv/poolarch.h>
26 #include <solv/poolvendor.h>
27 #include <solv/policy.h>
28 #include <solv/bitmap.h>
29 #include <solv/queue.h>
32 #include "zypp/solver/detail/Helper.h"
33 #include "zypp/base/String.h"
34 #include "zypp/Product.h"
35 #include "zypp/Capability.h"
36 #include "zypp/ResStatus.h"
37 #include "zypp/VendorAttr.h"
38 #include "zypp/base/LogTools.h"
39 #include "zypp/base/String.h"
40 #include "zypp/base/Gettext.h"
41 #include "zypp/base/Algorithm.h"
42 #include "zypp/ResPool.h"
43 #include "zypp/ResFilters.h"
44 #include "zypp/ZConfig.h"
45 #include "zypp/sat/Pool.h"
46 #include "zypp/sat/WhatProvides.h"
47 #include "zypp/sat/WhatObsoletes.h"
48 #include "zypp/solver/detail/SATResolver.h"
49 #include "zypp/solver/detail/ProblemSolutionCombi.h"
50 #include "zypp/solver/detail/ProblemSolutionIgnore.h"
51 #include "zypp/solver/detail/SolverQueueItemInstall.h"
52 #include "zypp/solver/detail/SolverQueueItemDelete.h"
53 #include "zypp/solver/detail/SystemCheck.h"
54 #include "zypp/sat/Transaction.h"
56 /////////////////////////////////////////////////////////////////////////
58 { ///////////////////////////////////////////////////////////////////////
59 ///////////////////////////////////////////////////////////////////////
61 { /////////////////////////////////////////////////////////////////////
62 /////////////////////////////////////////////////////////////////////
64 { ///////////////////////////////////////////////////////////////////
68 IMPL_PTR_TYPE(SATResolver);
70 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0)
72 //---------------------------------------------------------------------------
73 // Callbacks for SAT policies
74 //---------------------------------------------------------------------------
76 int vendorCheck( Pool *pool, Solvable *solvable1, Solvable *solvable2 )
78 return VendorAttr::instance().equivalent( IdString(solvable1->vendor),
79 IdString(solvable2->vendor) ) ? 0 : 1;
83 inline std::string itemToString( const PoolItem & item )
88 sat::Solvable slv( item.satSolvable() );
89 std::string ret( slv.asString() ); // n-v-r.a
90 if ( ! slv.isSystem() )
93 ret += slv.repository().alias();
99 inline PoolItem getPoolItem( Id id_r )
101 PoolItem ret( (sat::Solvable( id_r )) );
103 INT << "id " << id_r << " not found in ZYPP pool." << endl;
107 //---------------------------------------------------------------------------
110 SATResolver::dumpOn( std::ostream & os ) const
112 os << "<resolver>" << endl;
114 // os << " fixsystem = " << _solv->fixsystem << endl;
115 // os << " updatesystem = " << _solv->updatesystem << endl;
116 os << " allowdowngrade = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_DOWNGRADE) << endl;
117 os << " allowarchchange = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_ARCHCHANGE) << endl;
118 os << " allowvendorchange = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_VENDORCHANGE) << endl;
119 os << " allowuninstall = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_UNINSTALL) << endl;
120 os << " noupdateprovide = " << solver_get_flag(_solv, SOLVER_FLAG_NO_UPDATEPROVIDE) << endl;
121 os << " dosplitprovides = " << solver_get_flag(_solv, SOLVER_FLAG_SPLITPROVIDES) << endl;
122 os << " onlyRequires = " << solver_get_flag(_solv, SOLVER_FLAG_IGNORE_RECOMMENDED) << endl;
123 os << " ignorealreadyrecommended = " << solver_get_flag(_solv, SOLVER_FLAG_IGNORE_ALREADY_RECOMMENDED) << endl;
124 os << " distupgrade = " << _distupgrade << endl;
125 os << " distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
126 os << " solveSrcPackages = " << _solveSrcPackages << endl;
127 os << " cleandepsOnRemove = " << _cleandepsOnRemove << endl;
131 return os << "<resolver/>" << endl;
134 //---------------------------------------------------------------------------
136 SATResolver::SATResolver (const ResPool & pool, Pool *SATPool)
141 , _allowdowngrade(false)
142 , _allowarchchange(false)
143 , _allowvendorchange(ZConfig::instance().solver_allowVendorChange())
144 , _allowuninstall(false)
145 , _updatesystem(false)
146 , _noupdateprovide(false)
147 , _dosplitprovides(false)
148 , _onlyRequires(ZConfig::instance().solver_onlyRequires())
149 , _ignorealreadyrecommended(false)
150 , _distupgrade(false)
151 , _distupgrade_removeunsupported(false)
152 , _solveSrcPackages(false)
153 , _cleandepsOnRemove(ZConfig::instance().solver_cleandepsOnRemove())
158 SATResolver::~SATResolver()
163 //---------------------------------------------------------------------------
165 sat::Transaction SATResolver::getTransaction()
168 return sat::Transaction();
170 ::Transaction * sattrans = ::solver_create_transaction( _solv );
171 sat::Transaction ret ( *sattrans );
172 ::transaction_free( sattrans );
177 SATResolver::pool (void) const
183 SATResolver::resetItemTransaction (PoolItem item)
186 for (PoolItemList::const_iterator iter = _items_to_remove.begin();
187 iter != _items_to_remove.end(); ++iter) {
189 _items_to_remove.remove(*iter);
195 for (PoolItemList::const_iterator iter = _items_to_install.begin();
196 iter != _items_to_install.end(); ++iter) {
198 _items_to_install.remove(*iter);
205 for (PoolItemList::const_iterator iter = _items_to_keep.begin();
206 iter != _items_to_keep.end(); ++iter) {
208 _items_to_keep.remove(*iter);
215 for (PoolItemList::const_iterator iter = _items_to_lock.begin();
216 iter != _items_to_lock.end(); ++iter) {
218 _items_to_lock.remove(*iter);
228 SATResolver::addPoolItemToInstall (PoolItem item)
230 resetItemTransaction (item);
231 _items_to_install.push_back (item);
232 _items_to_install.unique ();
237 SATResolver::addPoolItemsToInstallFromList (PoolItemList & rl)
239 for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
240 addPoolItemToInstall (*iter);
246 SATResolver::addPoolItemToRemove (PoolItem item)
248 resetItemTransaction (item);
249 _items_to_remove.push_back (item);
250 _items_to_remove.unique ();
255 SATResolver::addPoolItemsToRemoveFromList (PoolItemList & rl)
257 for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
258 addPoolItemToRemove (*iter);
263 SATResolver::addPoolItemToLock (PoolItem item)
265 resetItemTransaction (item);
266 _items_to_lock.push_back (item);
267 _items_to_lock.unique ();
271 SATResolver::addPoolItemToKeep (PoolItem item)
273 resetItemTransaction (item);
274 _items_to_keep.push_back (item);
275 _items_to_keep.unique ();
278 //---------------------------------------------------------------------------
280 // copy marked item from solution back to pool
281 // if data != NULL, set as APPL_LOW (from establishPool())
284 SATSolutionToPool (PoolItem item, const ResStatus & status, const ResStatus::TransactByValue causer)
287 item.status().resetTransact (causer);
288 item.status().resetWeak ();
292 // installation/deletion
293 if (status.isToBeInstalled()) {
294 r = item.status().setToBeInstalled (causer);
295 _XDEBUG("SATSolutionToPool install returns " << item << ", " << r);
297 else if (status.isToBeUninstalledDueToUpgrade()) {
298 r = item.status().setToBeUninstalledDueToUpgrade (causer);
299 _XDEBUG("SATSolutionToPool upgrade returns " << item << ", " << r);
301 else if (status.isToBeUninstalled()) {
302 r = item.status().setToBeUninstalled (causer);
303 _XDEBUG("SATSolutionToPool remove returns " << item << ", " << r);
309 //----------------------------------------------------------------------------
310 //----------------------------------------------------------------------------
312 //----------------------------------------------------------------------------
313 //----------------------------------------------------------------------------
315 //----------------------------------------------------------------------------
316 // Helper functions for the ZYPP-Pool
317 //----------------------------------------------------------------------------
320 //------------------------------------------------------------------------------------------------------------
321 // This function loops over the pool and grabs all items
322 // It clears all previous bySolver() states also
324 // Every toBeInstalled is passed to zypp::solver:detail::Resolver.addPoolItemToInstall()
325 // Every toBeUninstalled is passed to zypp::solver:detail::Resolver.addPoolItemToRemove()
327 // Solver results must be written back to the pool.
328 //------------------------------------------------------------------------------------------------------------
331 struct SATCollectTransact : public resfilter::PoolItemFilterFunctor
333 SATResolver & resolver;
335 SATCollectTransact (SATResolver & r)
339 bool operator()( PoolItem item ) // only transacts() items go here
341 ResStatus status = item.status();
342 bool by_solver = (status.isBySolver() || status.isByApplLow());
345 item.status().resetTransact( ResStatus::APPL_LOW );// clear any solver/establish transactions
346 return true; // back out here, dont re-queue former solver result
349 if ( item.satSolvable().isKind<SrcPackage>() && ! resolver.solveSrcPackages() )
351 // Later we may continue on a per source package base.
352 return true; // dont process this source package.
355 if (status.isToBeInstalled()) {
356 resolver.addPoolItemToInstall(item); // -> install!
358 else if (status.isToBeUninstalled()) {
359 resolver.addPoolItemToRemove(item); // -> remove !
361 else if (status.isLocked()
363 resolver.addPoolItemToLock (item);
365 else if (status.isKept()
367 resolver.addPoolItemToKeep (item);
375 //----------------------------------------------------------------------------
376 //----------------------------------------------------------------------------
378 //----------------------------------------------------------------------------
379 //----------------------------------------------------------------------------
382 class CheckIfUpdate : public resfilter::PoolItemFilterFunctor
387 sat::Solvable _installed;
389 CheckIfUpdate( sat::Solvable installed_r )
390 : is_updated( false )
391 , multiversion( installed_r.multiversionInstall() )
392 , _installed( installed_r )
395 // check this item will be updated
397 bool operator()( PoolItem item )
399 if ( item.status().isToBeInstalled() )
401 if ( ! multiversion || sameNVRA( _installed, item ) )
412 class CollectPseudoInstalled : public resfilter::PoolItemFilterFunctor
415 Queue *solvableQueue;
417 CollectPseudoInstalled( Queue *queue )
418 :solvableQueue (queue)
421 // collecting PseudoInstalled items
422 bool operator()( PoolItem item )
424 if ( traits::isPseudoInstalled( item.satSolvable().kind() ) )
425 queue_push( solvableQueue, item.satSolvable().id() );
431 SATResolver::solving(const CapabilitySet & requires_caps,
432 const CapabilitySet & conflict_caps)
434 _solv = solver_create( _SATPool );
435 _solv->vendorCheckCb = &vendorCheck;
437 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
438 queue_push( &(_jobQueue), 0 );
441 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
442 queue_push( &(_jobQueue), 0 );
445 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
446 queue_push( &(_jobQueue), 0 );
448 if (_distupgrade_removeunsupported) {
449 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
450 queue_push( &(_jobQueue), 0 );
452 solver_set_flag(_solv, SOLVER_FLAG_IGNORE_ALREADY_RECOMMENDED, _ignorealreadyrecommended);
453 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
454 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
455 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
456 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
457 solver_set_flag(_solv, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
458 solver_set_flag(_solv, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
459 solver_set_flag(_solv, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
461 sat::Pool::instance().prepareForSolving();
464 MIL << "Starting solving...." << endl;
466 solver_solve( _solv, &(_jobQueue) );
467 MIL << "....Solver end" << endl;
469 // copying solution back to zypp pool
470 //-----------------------------------------
471 _result_items_to_install.clear();
472 _result_items_to_remove.clear();
474 /* solvables to be installed */
476 queue_init(&decisionq);
477 solver_get_decisionqueue(_solv, &decisionq);
478 for ( int i = 0; i < decisionq.count; ++i )
480 sat::Solvable slv( decisionq.elements[i] );
481 if ( !slv || slv.isSystem() )
484 PoolItem poolItem( slv );
485 SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
486 _result_items_to_install.push_back (poolItem);
488 queue_free(&decisionq);
490 /* solvables to be erased */
491 Repository systemRepo( sat::Pool::instance().findSystemRepo() ); // don't create if it does not exist
492 if ( systemRepo && ! systemRepo.solvablesEmpty() )
494 bool mustCheckObsoletes = false;
495 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
497 if (solver_get_decisionlevel(_solv, it->id()) > 0)
500 // Check if this is an update
501 CheckIfUpdate info( *it );
502 PoolItem poolItem( *it );
503 invokeOnEach( _pool.byIdentBegin( poolItem ),
504 _pool.byIdentEnd( poolItem ),
505 resfilter::ByUninstalled(), // ByUninstalled
506 functor::functorRef<bool,PoolItem> (info) );
508 if (info.is_updated) {
509 SATSolutionToPool( poolItem, ResStatus::toBeUninstalledDueToUpgrade, ResStatus::SOLVER );
511 SATSolutionToPool( poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER );
512 if ( ! mustCheckObsoletes )
513 mustCheckObsoletes = true; // lazy check for UninstalledDueToObsolete
515 _result_items_to_remove.push_back (poolItem);
517 if ( mustCheckObsoletes )
519 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
520 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
522 ResStatus & status( it->status() );
523 // WhatObsoletes contains installed items only!
524 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
525 status.setToBeUninstalledDueToObsolete();
530 /* solvables which are recommended */
531 for ( int i = 0; i < _solv->recommendations.count; ++i )
533 PoolItem poolItem( getPoolItem( _solv->recommendations.elements[i] ) );
534 poolItem.status().setRecommended( true );
537 /* solvables which are suggested */
538 for ( int i = 0; i < _solv->suggestions.count; ++i )
540 PoolItem poolItem( getPoolItem( _solv->suggestions.elements[i] ) );
541 poolItem.status().setSuggested( true );
544 _problem_items.clear();
545 /* solvables which are orphaned */
546 for ( int i = 0; i < _solv->orphaned.count; ++i )
548 PoolItem poolItem( getPoolItem( _solv->orphaned.elements[i] ) );
549 poolItem.status().setOrphaned( true );
550 _problem_items.push_back( poolItem );
553 /* Write validation state back to pool */
554 Queue flags, solvableQueue;
557 queue_init(&solvableQueue);
559 CollectPseudoInstalled collectPseudoInstalled(&solvableQueue);
560 invokeOnEach( _pool.begin(),
562 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
563 solver_trivial_installable(_solv, &solvableQueue, &flags );
564 for (int i = 0; i < solvableQueue.count; i++) {
565 PoolItem item = _pool.find (sat::Solvable(solvableQueue.elements[i]));
566 item.status().setUndetermined();
568 if (flags.elements[i] == -1) {
569 item.status().setNonRelevant();
570 _XDEBUG("SATSolutionToPool(" << item << " ) nonRelevant !");
571 } else if (flags.elements[i] == 1) {
572 item.status().setSatisfied();
573 _XDEBUG("SATSolutionToPool(" << item << " ) satisfied !");
574 } else if (flags.elements[i] == 0) {
575 item.status().setBroken();
576 _XDEBUG("SATSolutionToPool(" << item << " ) broken !");
579 queue_free(&(solvableQueue));
583 // Solvables which were selected due requirements which have been made by the user will
584 // be selected by APPL_LOW. We can't use any higher level, because this setting must
585 // not serve as a request for the next solver run. APPL_LOW is reset before solving.
586 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
587 sat::WhatProvides rpmProviders(*iter);
588 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
589 PoolItem poolItem(*iter2);
590 if (poolItem.status().isToBeInstalled()) {
591 MIL << "User requirement " << *iter << " sets " << poolItem << endl;
592 poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
596 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
597 sat::WhatProvides rpmProviders(*iter);
598 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
599 PoolItem poolItem(*iter2);
600 if (poolItem.status().isToBeUninstalled()) {
601 MIL << "User conflict " << *iter << " sets " << poolItem << endl;
602 poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
607 if (solver_problem_count(_solv) > 0 )
609 ERR << "Solverrun finished with an ERROR" << endl;
618 SATResolver::solverInit(const PoolItemList & weakItems)
620 SATCollectTransact info (*this);
622 MIL << "SATResolver::solverInit()" << endl;
627 queue_init( &_jobQueue );
628 _items_to_install.clear();
629 _items_to_remove.clear();
630 _items_to_lock.clear();
631 _items_to_keep.clear();
633 invokeOnEach ( _pool.begin(), _pool.end(),
634 functor::functorRef<bool,PoolItem>(info) );
636 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
637 Id id = (*iter)->satSolvable().id();
639 ERR << "Weaken: " << *iter << " not found" << endl;
641 MIL << "Weaken dependencies of " << *iter << endl;
642 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
643 queue_push( &(_jobQueue), id );
646 // Add rules for parallel installable resolvables with different versions
647 for_( it, sat::Pool::instance().multiversionBegin(), sat::Pool::instance().multiversionEnd() )
649 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVABLE_NAME );
650 queue_push( &(_jobQueue), it->id() );
653 if ( cleandepsOnRemove() )
655 // Add all items known to be installed by user request (not solver selected).
656 for_( it, sat::Pool::instance().onSystemByUserBegin(), sat::Pool::instance().onSystemByUserEnd() )
658 queue_push( &(_jobQueue), SOLVER_USERINSTALLED | SOLVER_SOLVABLE_NAME );
659 queue_push( &(_jobQueue), it->id() );
665 if ( ZConfig::instance().solverUpgradeRemoveDroppedPackages() )
667 MIL << "Checking droplists ..." << endl;
668 // Dropped packages: look for 'weakremover()' provides
669 // in dup candidates of installed products.
670 ResPoolProxy proxy( ResPool::instance().proxy() );
671 for_( it, proxy.byKindBegin<Product>(), proxy.byKindEnd<Product>() )
673 if ( (*it)->onSystem() ) // (to install) or (not to delete)
675 Product::constPtr prodCand( (*it)->candidateAsKind<Product>() );
676 if ( ! prodCand || (*it)->identicalInstalledCandidate() )
677 continue; // product no longer available or unchanged
679 CapabilitySet droplist( prodCand->droplist() );
680 dumpRangeLine( MIL << "Droplist for " << (*it)->candidateObj() << ": " << droplist.size() << " ", droplist.begin(), droplist.end() ) << endl;
681 for_( cap, droplist.begin(), droplist.end() )
683 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
684 queue_push( &_jobQueue, cap->id() );
691 MIL << "Droplist processing is disabled." << endl;
697 SATResolver::solverEnd()
704 queue_free( &(_jobQueue) );
710 SATResolver::resolvePool(const CapabilitySet & requires_caps,
711 const CapabilitySet & conflict_caps,
712 const PoolItemList & weakItems,
713 const std::set<Repository> & upgradeRepos)
715 MIL << "SATResolver::resolvePool()" << endl;
718 solverInit(weakItems);
720 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
721 Id id = (*iter)->satSolvable().id();
723 ERR << "Install: " << *iter << " not found" << endl;
725 MIL << "Install " << *iter << endl;
726 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
727 queue_push( &(_jobQueue), id );
731 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
732 Id id = (*iter)->satSolvable().id();
734 ERR << "Delete: " << *iter << " not found" << endl;
736 MIL << "Delete " << *iter << endl;
737 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
738 queue_push( &(_jobQueue), id);
742 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
744 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
745 queue_push( &(_jobQueue), iter->get()->repoid );
746 MIL << "Upgrade repo " << *iter << endl;
749 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
750 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
751 queue_push( &(_jobQueue), iter->id() );
752 MIL << "Requires " << *iter << endl;
755 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
756 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
757 queue_push( &(_jobQueue), iter->id() );
758 MIL << "Conflicts " << *iter << endl;
761 // set requirements for a running system
762 setSystemRequirements();
764 // set locks for the solver
768 bool ret = solving(requires_caps, conflict_caps);
770 (ret?MIL:WAR) << "SATResolver::resolvePool() done. Ret:" << ret << endl;
776 SATResolver::resolveQueue(const SolverQueueItemList &requestQueue,
777 const PoolItemList & weakItems)
779 MIL << "SATResolver::resolvQueue()" << endl;
782 solverInit(weakItems);
784 // generate solver queue
785 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
786 (*iter)->addRule(_jobQueue);
789 // Add addition item status to the resolve-queue cause these can be set by problem resolutions
790 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
791 Id id = (*iter)->satSolvable().id();
793 ERR << "Install: " << *iter << " not found" << endl;
795 MIL << "Install " << *iter << endl;
796 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
797 queue_push( &(_jobQueue), id );
800 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
801 sat::detail::IdType ident( (*iter)->satSolvable().ident().id() );
802 MIL << "Delete " << *iter << ident << endl;
803 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | MAYBE_CLEANDEPS );
804 queue_push( &(_jobQueue), ident);
807 // set requirements for a running system
808 setSystemRequirements();
810 // set locks for the solver
814 bool ret = solving();
816 MIL << "SATResolver::resolveQueue() done. Ret:" << ret << endl;
820 /** \todo duplicate code to be joined with \ref solving. */
821 void SATResolver::doUpdate()
823 MIL << "SATResolver::doUpdate()" << endl;
826 solverInit(PoolItemList());
828 // set requirements for a running system
829 setSystemRequirements();
831 // set locks for the solver
834 _solv = solver_create( _SATPool );
835 _solv->vendorCheckCb = &vendorCheck;
837 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
838 queue_push( &(_jobQueue), 0 );
841 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
842 queue_push( &(_jobQueue), 0 );
845 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
846 queue_push( &(_jobQueue), 0 );
848 if (_distupgrade_removeunsupported) {
849 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
850 queue_push( &(_jobQueue), 0 );
852 solver_set_flag(_solv, SOLVER_FLAG_IGNORE_ALREADY_RECOMMENDED, _ignorealreadyrecommended);
853 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
854 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
855 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
856 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
857 solver_set_flag(_solv, SOLVER_FLAG_SPLITPROVIDES, true);
858 solver_set_flag(_solv, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
859 solver_set_flag(_solv, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
861 sat::Pool::instance().prepareForSolving();
864 MIL << "Starting solving for update...." << endl;
866 solver_solve( _solv, &(_jobQueue) );
867 MIL << "....Solver end" << endl;
869 // copying solution back to zypp pool
870 //-----------------------------------------
872 /* solvables to be installed */
874 queue_init(&decisionq);
875 solver_get_decisionqueue(_solv, &decisionq);
876 for (int i = 0; i < decisionq.count; i++)
879 p = decisionq.elements[i];
880 if (p < 0 || !sat::Solvable(p))
882 if (sat::Solvable(p).repository().get() == _solv->pool->installed)
885 PoolItem poolItem = _pool.find (sat::Solvable(p));
887 SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
889 ERR << "id " << p << " not found in ZYPP pool." << endl;
892 queue_free(&decisionq);
894 /* solvables to be erased */
895 for (int i = _solv->pool->installed->start; i < _solv->pool->installed->start + _solv->pool->installed->nsolvables; i++)
897 if (solver_get_decisionlevel(_solv, i) > 0)
900 PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
902 // Check if this is an update
903 CheckIfUpdate info( (sat::Solvable(i)) );
904 invokeOnEach( _pool.byIdentBegin( poolItem ),
905 _pool.byIdentEnd( poolItem ),
906 resfilter::ByUninstalled(), // ByUninstalled
907 functor::functorRef<bool,PoolItem> (info) );
909 if (info.is_updated) {
910 SATSolutionToPool (poolItem, ResStatus::toBeUninstalledDueToUpgrade , ResStatus::SOLVER);
912 SATSolutionToPool (poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER);
915 ERR << "id " << i << " not found in ZYPP pool." << endl;
918 MIL << "SATResolver::doUpdate() done" << endl;
923 //----------------------------------------------------------------------------
924 //----------------------------------------------------------------------------
926 //----------------------------------------------------------------------------
927 //----------------------------------------------------------------------------
929 //----------------------------------------------------------------------------
931 //----------------------------------------------------------------------------
933 struct FindPackage : public resfilter::ResObjectFilterFunctor
935 ProblemSolutionCombi *problemSolution;
936 TransactionKind action;
937 FindPackage (ProblemSolutionCombi *p, const TransactionKind act)
938 : problemSolution (p)
943 bool operator()( PoolItem p)
945 problemSolution->addSingleAction (p, action);
951 //----------------------------------------------------------------------------
952 // Checking if this solvable/item has a buddy which reflect the real
953 // user visible description of an item
954 // e.g. The release package has a buddy to the concerning product item.
955 // This user want's the message "Product foo conflicts with product bar" and
956 // NOT "package release-foo conflicts with package release-bar"
957 //----------------------------------------------------------------------------
960 PoolItem SATResolver::mapItem (const PoolItem &item)
962 sat::Solvable buddy = item.buddy();
963 if (buddy != sat::Solvable())
965 return _pool.find (buddy);
973 sat::Solvable SATResolver::mapSolvable (const Id &id)
975 PoolItem item = _pool.find (sat::Solvable(id));
976 return mapItem(item).satSolvable();
979 string SATResolver::SATprobleminfoString(Id problem, string &detail, Id &ignoreId)
982 Pool *pool = _solv->pool;
984 Id dep, source, target;
988 probr = solver_findproblemrule(_solv, problem);
989 switch (solver_ruleinfo(_solv, probr, &source, &target, &dep))
991 case SOLVER_RULE_DISTUPGRADE:
992 s = mapSolvable (source);
993 ret = str::form (_("%s does not belong to a distupgrade repository"), s.asString().c_str());
995 case SOLVER_RULE_INFARCH:
996 s = mapSolvable (source);
997 ret = str::form (_("%s has inferior architecture"), s.asString().c_str());
999 case SOLVER_RULE_UPDATE:
1000 s = mapSolvable (source);
1001 ret = str::form (_("problem with installed package %s"), s.asString().c_str());
1003 case SOLVER_RULE_JOB:
1004 ret = _("conflicting requests");
1006 case SOLVER_RULE_RPM:
1007 ret = _("some dependency problem");
1009 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1010 ret = str::form (_("nothing provides requested %s"), pool_dep2str(pool, dep));
1011 detail += _("Have you enabled all requested repositories?");
1013 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1014 s = mapSolvable (source);
1015 ret = str::form (_("%s is not installable"), s.asString().c_str());
1017 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1018 ignoreId = source; // for setting weak dependencies
1019 s = mapSolvable (source);
1020 ret = str::form (_("nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1022 case SOLVER_RULE_RPM_SAME_NAME:
1023 s = mapSolvable (source);
1024 s2 = mapSolvable (target);
1025 ret = str::form (_("cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1027 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1028 s = mapSolvable (source);
1029 s2 = mapSolvable (target);
1030 ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1032 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1033 s = mapSolvable (source);
1034 s2 = mapSolvable (target);
1035 ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1037 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1038 s = mapSolvable (source);
1039 s2 = mapSolvable (target);
1040 ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1042 case SOLVER_RULE_RPM_SELF_CONFLICT:
1043 s = mapSolvable (source);
1044 ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1046 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1047 ignoreId = source; // for setting weak dependencies
1048 s = mapSolvable (source);
1049 Capability cap(dep);
1050 sat::WhatProvides possibleProviders(cap);
1052 // check, if a provider will be deleted
1053 typedef list<PoolItem> ProviderList;
1054 ProviderList providerlistInstalled, providerlistUninstalled;
1055 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1056 PoolItem provider1 = ResPool::instance().find( *iter1 );
1057 // find pair of an installed/uninstalled item with the same NVR
1059 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1060 PoolItem provider2 = ResPool::instance().find( *iter2 );
1061 if (compareByNVR (provider1.resolvable(),provider2.resolvable()) == 0
1062 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1063 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1069 if (provider1.status().isInstalled())
1070 providerlistInstalled.push_back(provider1);
1072 providerlistUninstalled.push_back(provider1);
1076 ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1077 if (providerlistInstalled.size() > 0) {
1078 detail += _("deleted providers: ");
1079 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1080 if (iter == providerlistInstalled.begin())
1081 detail += itemToString( *iter );
1083 detail += "\n " + itemToString( mapItem(*iter) );
1086 if (providerlistUninstalled.size() > 0) {
1087 if (detail.size() > 0)
1088 detail += _("\nuninstallable providers: ");
1090 detail = _("uninstallable providers: ");
1091 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1092 if (iter == providerlistUninstalled.begin())
1093 detail += itemToString( *iter );
1095 detail += "\n " + itemToString( mapItem(*iter) );
1105 SATResolver::problems ()
1107 ResolverProblemList resolverProblems;
1108 if (_solv && solver_problem_count(_solv)) {
1109 Pool *pool = _solv->pool;
1112 Id problem, solution, element;
1113 sat::Solvable s, sd;
1115 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1116 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1118 MIL << "Encountered problems! Here are the solutions:\n" << endl;
1121 while ((problem = solver_next_problem(_solv, problem)) != 0) {
1122 MIL << "Problem " << pcnt++ << ":" << endl;
1123 MIL << "====================================" << endl;
1126 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1127 MIL << whatString << endl;
1128 MIL << "------------------------------------" << endl;
1129 ResolverProblem_Ptr resolverProblem = new ResolverProblem (whatString, detail);
1132 while ((solution = solver_next_solution(_solv, problem, solution)) != 0) {
1134 ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi(resolverProblem);
1135 while ((element = solver_next_solutionelement(_solv, problem, solution, element, &p, &rp)) != 0) {
1136 if (p == SOLVER_SOLUTION_JOB) {
1137 /* job, rp is index into job queue */
1138 what = _jobQueue.elements[rp];
1139 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1141 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1142 s = mapSolvable (what);
1143 PoolItem poolItem = _pool.find (s);
1145 if (pool->installed && s.get()->repo == pool->installed) {
1146 problemSolution->addSingleAction (poolItem, REMOVE);
1147 string description = str::form (_("do not keep %s installed"), s.asString().c_str() );
1148 MIL << description << endl;
1149 problemSolution->addDescription (description);
1151 problemSolution->addSingleAction (poolItem, KEEP);
1152 string description = str::form (_("do not install %s"), s.asString().c_str());
1153 MIL << description << endl;
1154 problemSolution->addDescription (description);
1157 ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1161 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1162 s = mapSolvable (what);
1163 PoolItem poolItem = _pool.find (s);
1165 if (pool->installed && s.get()->repo == pool->installed) {
1166 problemSolution->addSingleAction (poolItem, KEEP);
1167 string description = str::form (_("keep %s"), s.asString().c_str());
1168 MIL << description << endl;
1169 problemSolution->addDescription (description);
1171 problemSolution->addSingleAction (poolItem, UNLOCK);
1172 string description = str::form (_("do not forbid installation of %s"), itemToString( poolItem ).c_str());
1173 MIL << description << endl;
1174 problemSolution->addDescription (description);
1177 ERR << "SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1181 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1183 IdString ident( what );
1184 SolverQueueItemInstall_Ptr install =
1185 new SolverQueueItemInstall(_pool, ident.asString(), false );
1186 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1188 string description = str::form (_("do not install %s"), ident.c_str() );
1189 MIL << description << endl;
1190 problemSolution->addDescription (description);
1193 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1195 // As we do not know, if this request has come from resolvePool or
1196 // resolveQueue we will have to take care for both cases.
1197 IdString ident( what );
1198 FindPackage info (problemSolution, KEEP);
1199 invokeOnEach( _pool.byIdentBegin( ident ),
1200 _pool.byIdentEnd( ident ),
1201 functor::chain (resfilter::ByInstalled (), // ByInstalled
1202 resfilter::ByTransact ()), // will be deinstalled
1203 functor::functorRef<bool,PoolItem> (info) );
1205 SolverQueueItemDelete_Ptr del =
1206 new SolverQueueItemDelete(_pool, ident.asString(), false );
1207 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1209 string description = str::form (_("keep %s"), ident.c_str());
1210 MIL << description << endl;
1211 problemSolution->addDescription (description);
1214 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1216 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1217 string description = "";
1219 // Checking if this problem solution would break your system
1220 if (system_requires.find(Capability(what)) != system_requires.end()) {
1221 // Show a better warning
1222 resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1223 resolverProblem->setDescription(_("This request will break your system!"));
1224 description = _("ignore the warning of a broken system");
1225 description += string(" (requires:")+pool_dep2str(pool, what)+")";
1226 MIL << description << endl;
1227 problemSolution->addFrontDescription (description);
1229 description = str::form (_("do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1230 MIL << description << endl;
1231 problemSolution->addDescription (description);
1235 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1237 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1238 string description = "";
1240 // Checking if this problem solution would break your system
1241 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1242 // Show a better warning
1243 resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1244 resolverProblem->setDescription(_("This request will break your system!"));
1245 description = _("ignore the warning of a broken system");
1246 description += string(" (conflicts:")+pool_dep2str(pool, what)+")";
1247 MIL << description << endl;
1248 problemSolution->addFrontDescription (description);
1251 description = str::form (_("do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1252 MIL << description << endl;
1253 problemSolution->addDescription (description);
1257 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1259 s = mapSolvable (what);
1260 PoolItem poolItem = _pool.find (s);
1262 if (pool->installed && s.get()->repo == pool->installed) {
1263 problemSolution->addSingleAction (poolItem, KEEP);
1264 string description = str::form (_("do not install most recent version of %s"), s.asString().c_str());
1265 MIL << description << endl;
1266 problemSolution->addDescription (description);
1268 ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem << " is not selected for installation" << endl;
1271 ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1276 MIL << "- do something different" << endl;
1277 ERR << "No valid solution available" << endl;
1280 } else if (p == SOLVER_SOLUTION_INFARCH) {
1281 s = mapSolvable (rp);
1282 PoolItem poolItem = _pool.find (s);
1283 if (pool->installed && s.get()->repo == pool->installed) {
1284 problemSolution->addSingleAction (poolItem, LOCK);
1285 string description = str::form (_("keep %s despite the inferior architecture"), s.asString().c_str());
1286 MIL << description << endl;
1287 problemSolution->addDescription (description);
1289 problemSolution->addSingleAction (poolItem, INSTALL);
1290 string description = str::form (_("install %s despite the inferior architecture"), s.asString().c_str());
1291 MIL << description << endl;
1292 problemSolution->addDescription (description);
1294 } else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1295 s = mapSolvable (rp);
1296 PoolItem poolItem = _pool.find (s);
1297 if (pool->installed && s.get()->repo == pool->installed) {
1298 problemSolution->addSingleAction (poolItem, LOCK);
1299 string description = str::form (_("keep obsolete %s"), s.asString().c_str());
1300 MIL << description << endl;
1301 problemSolution->addDescription (description);
1303 problemSolution->addSingleAction (poolItem, INSTALL);
1304 string description = str::form (_("install %s from excluded repository"), s.asString().c_str());
1305 MIL << description << endl;
1306 problemSolution->addDescription (description);
1309 /* policy, replace p with rp */
1310 s = mapSolvable (p);
1311 PoolItem itemFrom = _pool.find (s);
1316 sd = mapSolvable (rp);
1317 PoolItem itemTo = _pool.find (sd);
1318 if (itemFrom && itemTo) {
1319 problemSolution->addSingleAction (itemTo, INSTALL);
1320 int illegal = policy_is_illegal(_solv, s.get(), sd.get(), 0);
1322 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1324 string description = str::form (_("downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1325 MIL << description << endl;
1326 problemSolution->addDescription (description);
1329 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1331 string description = str::form (_("architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1332 MIL << description << endl;
1333 problemSolution->addDescription (description);
1336 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1338 IdString s_vendor( s.vendor() );
1339 IdString sd_vendor( sd.vendor() );
1340 string description = str::form (_("install %s (with vendor change)\n %s --> %s") ,
1341 sd.asString().c_str(),
1342 ( s_vendor ? s_vendor.c_str() : " (no vendor) " ),
1343 ( sd_vendor ? sd_vendor.c_str() : " (no vendor) " ) );
1344 MIL << description << endl;
1345 problemSolution->addDescription (description);
1349 string description = str::form (_("replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1350 MIL << description << endl;
1351 problemSolution->addDescription (description);
1354 ERR << s.asString() << " or " << sd.asString() << " not found" << endl;
1360 string description = str::form (_("deinstallation of %s"), s.asString().c_str());
1361 MIL << description << endl;
1362 problemSolution->addDescription (description);
1363 problemSolution->addSingleAction (itemFrom, REMOVE);
1368 resolverProblem->addSolution (problemSolution,
1369 problemSolution->actionCount() > 1 ? true : false); // Solutions with more than 1 action will be shown first.
1370 MIL << "------------------------------------" << endl;
1374 // There is a possibility to ignore this error by setting weak dependencies
1375 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1376 ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(resolverProblem, item);
1377 resolverProblem->addSolution (problemSolution,
1378 false); // Solutions will be shown at the end
1379 MIL << "ignore some dependencies of " << item << endl;
1380 MIL << "------------------------------------" << endl;
1384 resolverProblems.push_back (resolverProblem);
1387 return resolverProblems;
1391 SATResolver::applySolutions (const ProblemSolutionList & solutions)
1393 for (ProblemSolutionList::const_iterator iter = solutions.begin();
1394 iter != solutions.end(); ++iter) {
1395 ProblemSolution_Ptr solution = *iter;
1396 Resolver dummyResolver(_pool);
1397 if (!solution->apply (dummyResolver))
1402 void SATResolver::setLocks()
1404 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); iter++) {
1405 sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
1406 if (iter->status().isInstalled()) {
1407 MIL << "Lock installed item " << *iter << endl;
1408 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1409 queue_push( &(_jobQueue), ident );
1411 MIL << "Lock NOT installed item " << *iter << endl;
1412 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
1413 queue_push( &(_jobQueue), ident );
1417 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); iter++) {
1418 sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
1419 if (iter->status().isInstalled()) {
1420 MIL << "Keep installed item " << *iter << endl;
1421 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE | SOLVER_WEAK);
1422 queue_push( &(_jobQueue), ident );
1424 MIL << "Keep NOT installed item " << *iter << ident << endl;
1425 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | SOLVER_WEAK | MAYBE_CLEANDEPS );
1426 queue_push( &(_jobQueue), ident );
1431 void SATResolver::setSystemRequirements()
1433 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1434 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1436 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); iter++) {
1437 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1438 queue_push( &(_jobQueue), iter->id() );
1439 MIL << "SYSTEM Requires " << *iter << endl;
1442 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); iter++) {
1443 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
1444 queue_push( &(_jobQueue), iter->id() );
1445 MIL << "SYSTEM Conflicts " << *iter << endl;
1448 // Lock the architecture of the running systems rpm
1449 // package on distupgrade.
1450 if ( _distupgrade && ZConfig::instance().systemRoot() == "/" )
1452 ResPool pool( ResPool::instance() );
1453 IdString rpm( "rpm" );
1454 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1456 if ( (*it)->isSystem() )
1458 Capability archrule( (*it)->arch(), rpm.c_str(), Capability::PARSED );
1459 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVABLE_NAME | SOLVER_ESSENTIAL );
1460 queue_push( &(_jobQueue), archrule.id() );
1468 ///////////////////////////////////////////////////////////////////
1469 };// namespace detail
1470 /////////////////////////////////////////////////////////////////////
1471 /////////////////////////////////////////////////////////////////////
1472 };// namespace solver
1473 ///////////////////////////////////////////////////////////////////////
1474 ///////////////////////////////////////////////////////////////////////
1476 /////////////////////////////////////////////////////////////////////////