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_ADD_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 //---------------------------------------------------------------------------
166 SATResolver::pool (void) const
172 SATResolver::resetItemTransaction (PoolItem item)
175 for (PoolItemList::const_iterator iter = _items_to_remove.begin();
176 iter != _items_to_remove.end(); ++iter) {
178 _items_to_remove.remove(*iter);
184 for (PoolItemList::const_iterator iter = _items_to_install.begin();
185 iter != _items_to_install.end(); ++iter) {
187 _items_to_install.remove(*iter);
194 for (PoolItemList::const_iterator iter = _items_to_keep.begin();
195 iter != _items_to_keep.end(); ++iter) {
197 _items_to_keep.remove(*iter);
204 for (PoolItemList::const_iterator iter = _items_to_lock.begin();
205 iter != _items_to_lock.end(); ++iter) {
207 _items_to_lock.remove(*iter);
217 SATResolver::addPoolItemToInstall (PoolItem item)
219 resetItemTransaction (item);
220 _items_to_install.push_back (item);
221 _items_to_install.unique ();
226 SATResolver::addPoolItemsToInstallFromList (PoolItemList & rl)
228 for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
229 addPoolItemToInstall (*iter);
235 SATResolver::addPoolItemToRemove (PoolItem item)
237 resetItemTransaction (item);
238 _items_to_remove.push_back (item);
239 _items_to_remove.unique ();
244 SATResolver::addPoolItemsToRemoveFromList (PoolItemList & rl)
246 for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
247 addPoolItemToRemove (*iter);
252 SATResolver::addPoolItemToLock (PoolItem item)
254 resetItemTransaction (item);
255 _items_to_lock.push_back (item);
256 _items_to_lock.unique ();
260 SATResolver::addPoolItemToKeep (PoolItem item)
262 resetItemTransaction (item);
263 _items_to_keep.push_back (item);
264 _items_to_keep.unique ();
267 //---------------------------------------------------------------------------
269 // copy marked item from solution back to pool
270 // if data != NULL, set as APPL_LOW (from establishPool())
273 SATSolutionToPool (PoolItem item, const ResStatus & status, const ResStatus::TransactByValue causer)
276 item.status().resetTransact (causer);
277 item.status().resetWeak ();
281 // installation/deletion
282 if (status.isToBeInstalled()) {
283 r = item.status().setToBeInstalled (causer);
284 _XDEBUG("SATSolutionToPool install returns " << item << ", " << r);
286 else if (status.isToBeUninstalledDueToUpgrade()) {
287 r = item.status().setToBeUninstalledDueToUpgrade (causer);
288 _XDEBUG("SATSolutionToPool upgrade returns " << item << ", " << r);
290 else if (status.isToBeUninstalled()) {
291 r = item.status().setToBeUninstalled (causer);
292 _XDEBUG("SATSolutionToPool remove returns " << item << ", " << r);
298 //----------------------------------------------------------------------------
299 //----------------------------------------------------------------------------
301 //----------------------------------------------------------------------------
302 //----------------------------------------------------------------------------
304 //----------------------------------------------------------------------------
305 // Helper functions for the ZYPP-Pool
306 //----------------------------------------------------------------------------
309 //------------------------------------------------------------------------------------------------------------
310 // This function loops over the pool and grabs all items
311 // It clears all previous bySolver() states also
313 // Every toBeInstalled is passed to zypp::solver:detail::Resolver.addPoolItemToInstall()
314 // Every toBeUninstalled is passed to zypp::solver:detail::Resolver.addPoolItemToRemove()
316 // Solver results must be written back to the pool.
317 //------------------------------------------------------------------------------------------------------------
320 struct SATCollectTransact : public resfilter::PoolItemFilterFunctor
322 SATResolver & resolver;
324 SATCollectTransact (SATResolver & r)
328 bool operator()( PoolItem item ) // only transacts() items go here
330 ResStatus status = item.status();
331 bool by_solver = (status.isBySolver() || status.isByApplLow());
334 item.status().resetTransact( ResStatus::APPL_LOW );// clear any solver/establish transactions
335 return true; // back out here, dont re-queue former solver result
338 if ( item.satSolvable().isKind<SrcPackage>() && ! resolver.solveSrcPackages() )
340 // Later we may continue on a per source package base.
341 return true; // dont process this source package.
344 if (status.isToBeInstalled()) {
345 resolver.addPoolItemToInstall(item); // -> install!
347 else if (status.isToBeUninstalled()) {
348 resolver.addPoolItemToRemove(item); // -> remove !
350 else if (status.isLocked()
352 resolver.addPoolItemToLock (item);
354 else if (status.isKept()
356 resolver.addPoolItemToKeep (item);
364 //----------------------------------------------------------------------------
365 //----------------------------------------------------------------------------
367 //----------------------------------------------------------------------------
368 //----------------------------------------------------------------------------
371 class CheckIfUpdate : public resfilter::PoolItemFilterFunctor
376 sat::Solvable _installed;
378 CheckIfUpdate( sat::Solvable installed_r )
379 : is_updated( false )
380 , multiversion( installed_r.multiversionInstall() )
381 , _installed( installed_r )
384 // check this item will be updated
386 bool operator()( PoolItem item )
388 if ( item.status().isToBeInstalled() )
390 if ( ! multiversion || sameNVRA( _installed, item ) )
401 class CollectPseudoInstalled : public resfilter::PoolItemFilterFunctor
404 Queue *solvableQueue;
406 CollectPseudoInstalled( Queue *queue )
407 :solvableQueue (queue)
410 // collecting PseudoInstalled items
411 bool operator()( PoolItem item )
413 if ( traits::isPseudoInstalled( item.satSolvable().kind() ) )
414 queue_push( solvableQueue, item.satSolvable().id() );
420 SATResolver::solving(const CapabilitySet & requires_caps,
421 const CapabilitySet & conflict_caps)
423 _solv = solver_create( _SATPool );
424 _solv->vendorCheckCb = &vendorCheck;
426 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
427 queue_push( &(_jobQueue), 0 );
430 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
431 queue_push( &(_jobQueue), 0 );
434 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
435 queue_push( &(_jobQueue), 0 );
437 if (_distupgrade_removeunsupported) {
438 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
439 queue_push( &(_jobQueue), 0 );
441 solver_set_flag(_solv, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
442 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
443 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
444 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
445 solver_set_flag(_solv, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
446 solver_set_flag(_solv, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
447 solver_set_flag(_solv, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
448 solver_set_flag(_solv, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
450 sat::Pool::instance().prepareForSolving();
453 MIL << "Starting solving...." << endl;
455 solver_solve( _solv, &(_jobQueue) );
456 MIL << "....Solver end" << endl;
458 // copying solution back to zypp pool
459 //-----------------------------------------
460 _result_items_to_install.clear();
461 _result_items_to_remove.clear();
463 /* solvables to be installed */
465 queue_init(&decisionq);
466 solver_get_decisionqueue(_solv, &decisionq);
467 for ( int i = 0; i < decisionq.count; ++i )
469 sat::Solvable slv( decisionq.elements[i] );
470 if ( !slv || slv.isSystem() )
473 PoolItem poolItem( slv );
474 SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
475 _result_items_to_install.push_back (poolItem);
477 queue_free(&decisionq);
479 /* solvables to be erased */
480 Repository systemRepo( sat::Pool::instance().findSystemRepo() ); // don't create if it does not exist
481 if ( systemRepo && ! systemRepo.solvablesEmpty() )
483 bool mustCheckObsoletes = false;
484 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
486 if (solver_get_decisionlevel(_solv, it->id()) > 0)
489 // Check if this is an update
490 CheckIfUpdate info( *it );
491 PoolItem poolItem( *it );
492 invokeOnEach( _pool.byIdentBegin( poolItem ),
493 _pool.byIdentEnd( poolItem ),
494 resfilter::ByUninstalled(), // ByUninstalled
495 functor::functorRef<bool,PoolItem> (info) );
497 if (info.is_updated) {
498 SATSolutionToPool( poolItem, ResStatus::toBeUninstalledDueToUpgrade, ResStatus::SOLVER );
500 SATSolutionToPool( poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER );
501 if ( ! mustCheckObsoletes )
502 mustCheckObsoletes = true; // lazy check for UninstalledDueToObsolete
504 _result_items_to_remove.push_back (poolItem);
506 if ( mustCheckObsoletes )
508 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
509 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
511 ResStatus & status( it->status() );
512 // WhatObsoletes contains installed items only!
513 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
514 status.setToBeUninstalledDueToObsolete();
519 Queue recommendations;
522 queue_init(&recommendations);
523 queue_init(&suggestions);
524 queue_init(&orphaned);
525 solver_get_recommendations(_solv, &recommendations, &suggestions, 0);
526 solver_get_orphaned(_solv, &orphaned);
527 /* solvables which are recommended */
528 for ( int i = 0; i < recommendations.count; ++i )
530 PoolItem poolItem( getPoolItem( recommendations.elements[i] ) );
531 poolItem.status().setRecommended( true );
534 /* solvables which are suggested */
535 for ( int i = 0; i < suggestions.count; ++i )
537 PoolItem poolItem( getPoolItem( suggestions.elements[i] ) );
538 poolItem.status().setSuggested( true );
541 _problem_items.clear();
542 /* solvables which are orphaned */
543 for ( int i = 0; i < orphaned.count; ++i )
545 PoolItem poolItem( getPoolItem( orphaned.elements[i] ) );
546 poolItem.status().setOrphaned( true );
547 _problem_items.push_back( poolItem );
549 queue_free(&recommendations);
550 queue_free(&suggestions);
551 queue_free(&orphaned);
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 | SOLVER_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_ADD_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, _dosplitprovides);
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 // (ma: that's why we should map just packages to buddies, not vice versa)
958 //----------------------------------------------------------------------------
959 inline sat::Solvable mapBuddy( const PoolItem & item_r )
961 if ( item_r.satSolvable().isKind<Package>() )
963 sat::Solvable buddy = item_r.buddy();
967 return item_r.satSolvable();
969 inline sat::Solvable mapBuddy( sat::Solvable item_r )
970 { return mapBuddy( PoolItem( item_r ) ); }
972 PoolItem SATResolver::mapItem ( const PoolItem & item )
973 { return PoolItem( mapBuddy( item ) ); }
975 sat::Solvable SATResolver::mapSolvable ( const Id & id )
976 { return mapBuddy( sat::Solvable(id) ); }
978 string SATResolver::SATprobleminfoString(Id problem, string &detail, Id &ignoreId)
981 Pool *pool = _solv->pool;
983 Id dep, source, target;
987 probr = solver_findproblemrule(_solv, problem);
988 switch (solver_ruleinfo(_solv, probr, &source, &target, &dep))
990 case SOLVER_RULE_DISTUPGRADE:
991 s = mapSolvable (source);
992 ret = str::form (_("%s does not belong to a distupgrade repository"), s.asString().c_str());
994 case SOLVER_RULE_INFARCH:
995 s = mapSolvable (source);
996 ret = str::form (_("%s has inferior architecture"), s.asString().c_str());
998 case SOLVER_RULE_UPDATE:
999 s = mapSolvable (source);
1000 ret = str::form (_("problem with installed package %s"), s.asString().c_str());
1002 case SOLVER_RULE_JOB:
1003 ret = _("conflicting requests");
1005 case SOLVER_RULE_RPM:
1006 ret = _("some dependency problem");
1008 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1009 ret = str::form (_("nothing provides requested %s"), pool_dep2str(pool, dep));
1010 detail += _("Have you enabled all requested repositories?");
1012 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1013 s = mapSolvable (source);
1014 ret = str::form (_("%s is not installable"), s.asString().c_str());
1016 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1017 ignoreId = source; // for setting weak dependencies
1018 s = mapSolvable (source);
1019 ret = str::form (_("nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1021 case SOLVER_RULE_RPM_SAME_NAME:
1022 s = mapSolvable (source);
1023 s2 = mapSolvable (target);
1024 ret = str::form (_("cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1026 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1027 s = mapSolvable (source);
1028 s2 = mapSolvable (target);
1029 ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1031 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1032 s = mapSolvable (source);
1033 s2 = mapSolvable (target);
1034 ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1036 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1037 s = mapSolvable (source);
1038 s2 = mapSolvable (target);
1039 ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1041 case SOLVER_RULE_RPM_SELF_CONFLICT:
1042 s = mapSolvable (source);
1043 ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1045 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1046 ignoreId = source; // for setting weak dependencies
1047 s = mapSolvable (source);
1048 Capability cap(dep);
1049 sat::WhatProvides possibleProviders(cap);
1051 // check, if a provider will be deleted
1052 typedef list<PoolItem> ProviderList;
1053 ProviderList providerlistInstalled, providerlistUninstalled;
1054 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1055 PoolItem provider1 = ResPool::instance().find( *iter1 );
1056 // find pair of an installed/uninstalled item with the same NVR
1058 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1059 PoolItem provider2 = ResPool::instance().find( *iter2 );
1060 if (compareByNVR (provider1.resolvable(),provider2.resolvable()) == 0
1061 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1062 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1068 if (provider1.status().isInstalled())
1069 providerlistInstalled.push_back(provider1);
1071 providerlistUninstalled.push_back(provider1);
1075 ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1076 if (providerlistInstalled.size() > 0) {
1077 detail += _("deleted providers: ");
1078 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1079 if (iter == providerlistInstalled.begin())
1080 detail += itemToString( *iter );
1082 detail += "\n " + itemToString( mapItem(*iter) );
1085 if (providerlistUninstalled.size() > 0) {
1086 if (detail.size() > 0)
1087 detail += _("\nuninstallable providers: ");
1089 detail = _("uninstallable providers: ");
1090 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1091 if (iter == providerlistUninstalled.begin())
1092 detail += itemToString( *iter );
1094 detail += "\n " + itemToString( mapItem(*iter) );
1104 SATResolver::problems ()
1106 ResolverProblemList resolverProblems;
1107 if (_solv && solver_problem_count(_solv)) {
1108 Pool *pool = _solv->pool;
1111 Id problem, solution, element;
1112 sat::Solvable s, sd;
1114 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1115 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1117 MIL << "Encountered problems! Here are the solutions:\n" << endl;
1120 while ((problem = solver_next_problem(_solv, problem)) != 0) {
1121 MIL << "Problem " << pcnt++ << ":" << endl;
1122 MIL << "====================================" << endl;
1125 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1126 MIL << whatString << endl;
1127 MIL << "------------------------------------" << endl;
1128 ResolverProblem_Ptr resolverProblem = new ResolverProblem (whatString, detail);
1131 while ((solution = solver_next_solution(_solv, problem, solution)) != 0) {
1133 ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi(resolverProblem);
1134 while ((element = solver_next_solutionelement(_solv, problem, solution, element, &p, &rp)) != 0) {
1135 if (p == SOLVER_SOLUTION_JOB) {
1136 /* job, rp is index into job queue */
1137 what = _jobQueue.elements[rp];
1138 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1140 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1141 s = mapSolvable (what);
1142 PoolItem poolItem = _pool.find (s);
1144 if (pool->installed && s.get()->repo == pool->installed) {
1145 problemSolution->addSingleAction (poolItem, REMOVE);
1146 string description = str::form (_("do not keep %s installed"), s.asString().c_str() );
1147 MIL << description << endl;
1148 problemSolution->addDescription (description);
1150 problemSolution->addSingleAction (poolItem, KEEP);
1151 string description = str::form (_("do not install %s"), s.asString().c_str());
1152 MIL << description << endl;
1153 problemSolution->addDescription (description);
1156 ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1160 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1161 s = mapSolvable (what);
1162 PoolItem poolItem = _pool.find (s);
1164 if (pool->installed && s.get()->repo == pool->installed) {
1165 problemSolution->addSingleAction (poolItem, KEEP);
1166 string description = str::form (_("keep %s"), s.asString().c_str());
1167 MIL << description << endl;
1168 problemSolution->addDescription (description);
1170 problemSolution->addSingleAction (poolItem, UNLOCK);
1171 string description = str::form (_("do not forbid installation of %s"), itemToString( poolItem ).c_str());
1172 MIL << description << endl;
1173 problemSolution->addDescription (description);
1176 ERR << "SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1180 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1182 IdString ident( what );
1183 SolverQueueItemInstall_Ptr install =
1184 new SolverQueueItemInstall(_pool, ident.asString(), false );
1185 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1187 string description = str::form (_("do not install %s"), ident.c_str() );
1188 MIL << description << endl;
1189 problemSolution->addDescription (description);
1192 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1194 // As we do not know, if this request has come from resolvePool or
1195 // resolveQueue we will have to take care for both cases.
1196 IdString ident( what );
1197 FindPackage info (problemSolution, KEEP);
1198 invokeOnEach( _pool.byIdentBegin( ident ),
1199 _pool.byIdentEnd( ident ),
1200 functor::chain (resfilter::ByInstalled (), // ByInstalled
1201 resfilter::ByTransact ()), // will be deinstalled
1202 functor::functorRef<bool,PoolItem> (info) );
1204 SolverQueueItemDelete_Ptr del =
1205 new SolverQueueItemDelete(_pool, ident.asString(), false );
1206 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1208 string description = str::form (_("keep %s"), ident.c_str());
1209 MIL << description << endl;
1210 problemSolution->addDescription (description);
1213 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1215 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1216 string description = "";
1218 // Checking if this problem solution would break your system
1219 if (system_requires.find(Capability(what)) != system_requires.end()) {
1220 // Show a better warning
1221 resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1222 resolverProblem->setDescription(_("This request will break your system!"));
1223 description = _("ignore the warning of a broken system");
1224 description += string(" (requires:")+pool_dep2str(pool, what)+")";
1225 MIL << description << endl;
1226 problemSolution->addFrontDescription (description);
1228 description = str::form (_("do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1229 MIL << description << endl;
1230 problemSolution->addDescription (description);
1234 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1236 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1237 string description = "";
1239 // Checking if this problem solution would break your system
1240 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1241 // Show a better warning
1242 resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1243 resolverProblem->setDescription(_("This request will break your system!"));
1244 description = _("ignore the warning of a broken system");
1245 description += string(" (conflicts:")+pool_dep2str(pool, what)+")";
1246 MIL << description << endl;
1247 problemSolution->addFrontDescription (description);
1250 description = str::form (_("do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1251 MIL << description << endl;
1252 problemSolution->addDescription (description);
1256 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1258 s = mapSolvable (what);
1259 PoolItem poolItem = _pool.find (s);
1261 if (pool->installed && s.get()->repo == pool->installed) {
1262 problemSolution->addSingleAction (poolItem, KEEP);
1263 string description = str::form (_("do not install most recent version of %s"), s.asString().c_str());
1264 MIL << description << endl;
1265 problemSolution->addDescription (description);
1267 ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem << " is not selected for installation" << endl;
1270 ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1275 MIL << "- do something different" << endl;
1276 ERR << "No valid solution available" << endl;
1279 } else if (p == SOLVER_SOLUTION_INFARCH) {
1280 s = mapSolvable (rp);
1281 PoolItem poolItem = _pool.find (s);
1282 if (pool->installed && s.get()->repo == pool->installed) {
1283 problemSolution->addSingleAction (poolItem, LOCK);
1284 string description = str::form (_("keep %s despite the inferior architecture"), s.asString().c_str());
1285 MIL << description << endl;
1286 problemSolution->addDescription (description);
1288 problemSolution->addSingleAction (poolItem, INSTALL);
1289 string description = str::form (_("install %s despite the inferior architecture"), s.asString().c_str());
1290 MIL << description << endl;
1291 problemSolution->addDescription (description);
1293 } else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1294 s = mapSolvable (rp);
1295 PoolItem poolItem = _pool.find (s);
1296 if (pool->installed && s.get()->repo == pool->installed) {
1297 problemSolution->addSingleAction (poolItem, LOCK);
1298 string description = str::form (_("keep obsolete %s"), s.asString().c_str());
1299 MIL << description << endl;
1300 problemSolution->addDescription (description);
1302 problemSolution->addSingleAction (poolItem, INSTALL);
1303 string description = str::form (_("install %s from excluded repository"), s.asString().c_str());
1304 MIL << description << endl;
1305 problemSolution->addDescription (description);
1308 /* policy, replace p with rp */
1309 s = mapSolvable (p);
1310 PoolItem itemFrom = _pool.find (s);
1315 sd = mapSolvable (rp);
1316 PoolItem itemTo = _pool.find (sd);
1317 if (itemFrom && itemTo) {
1318 problemSolution->addSingleAction (itemTo, INSTALL);
1319 int illegal = policy_is_illegal(_solv, s.get(), sd.get(), 0);
1321 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1323 string description = str::form (_("downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1324 MIL << description << endl;
1325 problemSolution->addDescription (description);
1328 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1330 string description = str::form (_("architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1331 MIL << description << endl;
1332 problemSolution->addDescription (description);
1335 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1337 IdString s_vendor( s.vendor() );
1338 IdString sd_vendor( sd.vendor() );
1339 string description = str::form (_("install %s (with vendor change)\n %s --> %s") ,
1340 sd.asString().c_str(),
1341 ( s_vendor ? s_vendor.c_str() : " (no vendor) " ),
1342 ( sd_vendor ? sd_vendor.c_str() : " (no vendor) " ) );
1343 MIL << description << endl;
1344 problemSolution->addDescription (description);
1348 string description = str::form (_("replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1349 MIL << description << endl;
1350 problemSolution->addDescription (description);
1353 ERR << s.asString() << " or " << sd.asString() << " not found" << endl;
1359 string description = str::form (_("deinstallation of %s"), s.asString().c_str());
1360 MIL << description << endl;
1361 problemSolution->addDescription (description);
1362 problemSolution->addSingleAction (itemFrom, REMOVE);
1367 resolverProblem->addSolution (problemSolution,
1368 problemSolution->actionCount() > 1 ? true : false); // Solutions with more than 1 action will be shown first.
1369 MIL << "------------------------------------" << endl;
1373 // There is a possibility to ignore this error by setting weak dependencies
1374 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1375 ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(resolverProblem, item);
1376 resolverProblem->addSolution (problemSolution,
1377 false); // Solutions will be shown at the end
1378 MIL << "ignore some dependencies of " << item << endl;
1379 MIL << "------------------------------------" << endl;
1383 resolverProblems.push_back (resolverProblem);
1386 return resolverProblems;
1390 SATResolver::applySolutions (const ProblemSolutionList & solutions)
1392 for (ProblemSolutionList::const_iterator iter = solutions.begin();
1393 iter != solutions.end(); ++iter) {
1394 ProblemSolution_Ptr solution = *iter;
1395 Resolver dummyResolver(_pool);
1396 if (!solution->apply (dummyResolver))
1401 void SATResolver::setLocks()
1403 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1404 sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
1405 if (iter->status().isInstalled()) {
1406 MIL << "Lock installed item " << *iter << endl;
1407 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1408 queue_push( &(_jobQueue), ident );
1410 MIL << "Lock NOT installed item " << *iter << endl;
1411 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
1412 queue_push( &(_jobQueue), ident );
1416 std::set<IdString> unifiedByName;
1417 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1418 if (iter->status().isInstalled()) {
1419 MIL << "Keep installed item " << *iter << endl;
1420 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE | SOLVER_WEAK );
1421 queue_push( &(_jobQueue), (*iter)->satSolvable().id() );
1423 IdString ident( (*iter)->satSolvable().ident() );
1424 MIL << "Keep NOT installed name " << ident << " (" << *iter << ")" << endl;
1425 if ( unifiedByName.insert( ident ).second )
1427 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK | MAYBE_CLEANDEPS );
1428 queue_push( &(_jobQueue), ident.id() );
1434 void SATResolver::setSystemRequirements()
1436 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1437 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1439 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1440 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1441 queue_push( &(_jobQueue), iter->id() );
1442 MIL << "SYSTEM Requires " << *iter << endl;
1445 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1446 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
1447 queue_push( &(_jobQueue), iter->id() );
1448 MIL << "SYSTEM Conflicts " << *iter << endl;
1451 // Lock the architecture of the running systems rpm
1452 // package on distupgrade.
1453 if ( _distupgrade && ZConfig::instance().systemRoot() == "/" )
1455 ResPool pool( ResPool::instance() );
1456 IdString rpm( "rpm" );
1457 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1459 if ( (*it)->isSystem() )
1461 Capability archrule( (*it)->arch(), rpm.c_str(), Capability::PARSED );
1462 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1463 queue_push( &(_jobQueue), archrule.id() );
1471 ///////////////////////////////////////////////////////////////////
1472 };// namespace detail
1473 /////////////////////////////////////////////////////////////////////
1474 /////////////////////////////////////////////////////////////////////
1475 };// namespace solver
1476 ///////////////////////////////////////////////////////////////////////
1477 ///////////////////////////////////////////////////////////////////////
1479 /////////////////////////////////////////////////////////////////////////