00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 extern "C"
00022 {
00023 #include <satsolver/repo_solv.h>
00024 #include <satsolver/poolarch.h>
00025 #include <satsolver/evr.h>
00026 #include <satsolver/poolvendor.h>
00027 #include <satsolver/policy.h>
00028 #include <satsolver/bitmap.h>
00029 #include <satsolver/queue.h>
00030 }
00031
00032 #include "zypp/solver/detail/Helper.h"
00033 #include "zypp/base/String.h"
00034 #include "zypp/Product.h"
00035 #include "zypp/Capability.h"
00036 #include "zypp/ResStatus.h"
00037 #include "zypp/VendorAttr.h"
00038 #include "zypp/base/LogTools.h"
00039 #include "zypp/base/String.h"
00040 #include "zypp/base/Gettext.h"
00041 #include "zypp/base/Algorithm.h"
00042 #include "zypp/ResPool.h"
00043 #include "zypp/ResFilters.h"
00044 #include "zypp/ZConfig.h"
00045 #include "zypp/sat/Pool.h"
00046 #include "zypp/sat/WhatProvides.h"
00047 #include "zypp/sat/WhatObsoletes.h"
00048 #include "zypp/solver/detail/SATResolver.h"
00049 #include "zypp/solver/detail/ProblemSolutionCombi.h"
00050 #include "zypp/solver/detail/ProblemSolutionIgnore.h"
00051 #include "zypp/solver/detail/SolverQueueItemInstall.h"
00052 #include "zypp/solver/detail/SolverQueueItemDelete.h"
00053 #include "zypp/solver/detail/SystemCheck.h"
00054
00056 namespace zypp
00057 {
00058
00059 namespace solver
00060 {
00061
00062 namespace detail
00063 {
00064
00065 using namespace std;
00066
00067 IMPL_PTR_TYPE(SATResolver);
00068
00069
00070
00071
00072
00073 int vendorCheck( Pool *pool, Solvable *solvable1, Solvable *solvable2 )
00074 {
00075 return VendorAttr::instance().equivalent( IdString(solvable1->vendor),
00076 IdString(solvable2->vendor) ) ? 0 : 1;
00077 }
00078
00079
00080 inline std::string itemToString( const PoolItem & item )
00081 {
00082 if ( !item )
00083 return std::string();
00084
00085 sat::Solvable slv( item.satSolvable() );
00086 std::string ret( slv.asString() );
00087 if ( ! slv.isSystem() )
00088 {
00089 ret += "[";
00090 ret += slv.repository().alias();
00091 ret += "]";
00092 }
00093 return ret;
00094 }
00095
00096 inline PoolItem getPoolItem( Id id_r )
00097 {
00098 PoolItem ret( (sat::Solvable( id_r )) );
00099 if ( !ret && id_r )
00100 INT << "id " << id_r << " not found in ZYPP pool." << endl;
00101 return ret;
00102 }
00103
00104
00105
00106 std::ostream &
00107 SATResolver::dumpOn( std::ostream & os ) const
00108 {
00109 os << "<resolver>" << endl;
00110 if (_solv) {
00111 os << " fixsystem = " << _solv->fixsystem << endl;
00112 os << " allowdowngrade = " << _solv->allowdowngrade << endl;
00113 os << " allowarchchange = " << _solv->allowarchchange << endl;
00114 os << " allowvendorchange = " << _solv->allowvendorchange << endl;
00115 os << " allowuninstall = " << _solv->allowuninstall << endl;
00116 os << " updatesystem = " << _solv->updatesystem << endl;
00117 os << " noupdateprovide = " << _solv->noupdateprovide << endl;
00118 os << " dosplitprovides = " << _solv->dosplitprovides << endl;
00119 os << " onlyRequires = " << _solv->dontinstallrecommended << endl;
00120 os << " ignorealreadyrecommended = " << _solv->ignorealreadyrecommended << endl;
00121 os << " distupgrade = " << _distupgrade << endl;
00122 os << " distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
00123 os << " solveSrcPackages = " << _solveSrcPackages << endl;
00124 } else {
00125 os << "<NULL>";
00126 }
00127 return os << "<resolver/>" << endl;
00128 }
00129
00130
00131
00132 SATResolver::SATResolver (const ResPool & pool, Pool *SATPool)
00133 : _pool (pool)
00134 , _SATPool (SATPool)
00135 , _solv(NULL)
00136 , _fixsystem(false)
00137 , _allowdowngrade(false)
00138 , _allowarchchange(false)
00139 , _allowvendorchange(false)
00140 , _allowuninstall(false)
00141 , _updatesystem(false)
00142 , _noupdateprovide(false)
00143 , _dosplitprovides(false)
00144 , _onlyRequires(ZConfig::instance().solver_onlyRequires())
00145 , _ignorealreadyrecommended(false)
00146 , _distupgrade(false)
00147 , _distupgrade_removeunsupported(false)
00148
00149 {
00150 }
00151
00152
00153 SATResolver::~SATResolver()
00154 {
00155 }
00156
00157
00158
00159
00160 ResPool
00161 SATResolver::pool (void) const
00162 {
00163 return _pool;
00164 }
00165
00166
00167 void
00168 SATResolver::resetItemTransaction (PoolItem item)
00169 {
00170 bool found = false;
00171 for (PoolItemList::const_iterator iter = _items_to_remove.begin();
00172 iter != _items_to_remove.end(); ++iter) {
00173 if (*iter == item) {
00174 _items_to_remove.remove(*iter);
00175 found = true;
00176 break;
00177 }
00178 }
00179 if (!found) {
00180 for (PoolItemList::const_iterator iter = _items_to_install.begin();
00181 iter != _items_to_install.end(); ++iter) {
00182 if (*iter == item) {
00183 _items_to_install.remove(*iter);
00184 found = true;
00185 break;
00186 }
00187 }
00188 }
00189 if (!found) {
00190 for (PoolItemList::const_iterator iter = _items_to_keep.begin();
00191 iter != _items_to_keep.end(); ++iter) {
00192 if (*iter == item) {
00193 _items_to_keep.remove(*iter);
00194 found = true;
00195 break;
00196 }
00197 }
00198 }
00199 if (!found) {
00200 for (PoolItemList::const_iterator iter = _items_to_lock.begin();
00201 iter != _items_to_lock.end(); ++iter) {
00202 if (*iter == item) {
00203 _items_to_lock.remove(*iter);
00204 found = true;
00205 break;
00206 }
00207 }
00208 }
00209 }
00210
00211
00212 void
00213 SATResolver::addPoolItemToInstall (PoolItem item)
00214 {
00215 resetItemTransaction (item);
00216 _items_to_install.push_back (item);
00217 _items_to_install.unique ();
00218 }
00219
00220
00221 void
00222 SATResolver::addPoolItemsToInstallFromList (PoolItemList & rl)
00223 {
00224 for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
00225 addPoolItemToInstall (*iter);
00226 }
00227 }
00228
00229
00230 void
00231 SATResolver::addPoolItemToRemove (PoolItem item)
00232 {
00233 resetItemTransaction (item);
00234 _items_to_remove.push_back (item);
00235 _items_to_remove.unique ();
00236 }
00237
00238
00239 void
00240 SATResolver::addPoolItemsToRemoveFromList (PoolItemList & rl)
00241 {
00242 for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
00243 addPoolItemToRemove (*iter);
00244 }
00245 }
00246
00247 void
00248 SATResolver::addPoolItemToLock (PoolItem item)
00249 {
00250 resetItemTransaction (item);
00251 _items_to_lock.push_back (item);
00252 _items_to_lock.unique ();
00253 }
00254
00255 void
00256 SATResolver::addPoolItemToKeep (PoolItem item)
00257 {
00258 resetItemTransaction (item);
00259 _items_to_keep.push_back (item);
00260 _items_to_keep.unique ();
00261 }
00262
00263
00264
00265
00266
00267
00268 static void
00269 SATSolutionToPool (PoolItem item, const ResStatus & status, const ResStatus::TransactByValue causer)
00270 {
00271
00272 item.status().resetTransact (causer);
00273 item.status().resetWeak ();
00274
00275 bool r;
00276
00277
00278 if (status.isToBeInstalled()) {
00279 r = item.status().setToBeInstalled (causer);
00280 _XDEBUG("SATSolutionToPool install returns " << item << ", " << r);
00281 }
00282 else if (status.isToBeUninstalledDueToUpgrade()) {
00283 r = item.status().setToBeUninstalledDueToUpgrade (causer);
00284 _XDEBUG("SATSolutionToPool upgrade returns " << item << ", " << r);
00285 }
00286 else if (status.isToBeUninstalled()) {
00287 r = item.status().setToBeUninstalled (causer);
00288 _XDEBUG("SATSolutionToPool remove returns " << item << ", " << r);
00289 }
00290
00291 return;
00292 }
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316 struct SATCollectTransact : public resfilter::PoolItemFilterFunctor
00317 {
00318 SATResolver & resolver;
00319
00320 SATCollectTransact (SATResolver & r)
00321 : resolver (r)
00322 { }
00323
00324 bool operator()( PoolItem item )
00325 {
00326 ResStatus status = item.status();
00327 bool by_solver = (status.isBySolver() || status.isByApplLow());
00328
00329 if (by_solver) {
00330 item.status().resetTransact( ResStatus::APPL_LOW );
00331 return true;
00332 }
00333
00334 if ( item.satSolvable().isKind<SrcPackage>() && ! resolver.solveSrcPackages() )
00335 {
00336
00337 return true;
00338 }
00339
00340 if (status.isToBeInstalled()) {
00341 resolver.addPoolItemToInstall(item);
00342 }
00343 else if (status.isToBeUninstalled()) {
00344 resolver.addPoolItemToRemove(item);
00345 }
00346 else if (status.isLocked()
00347 && !by_solver) {
00348 resolver.addPoolItemToLock (item);
00349 }
00350 else if (status.isKept()
00351 && !by_solver) {
00352 resolver.addPoolItemToKeep (item);
00353 }
00354
00355 return true;
00356 }
00357 };
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367 class CheckIfUpdate : public resfilter::PoolItemFilterFunctor
00368 {
00369 public:
00370 bool is_updated;
00371 bool multiversion;
00372 sat::Solvable _installed;
00373
00374 CheckIfUpdate( sat::Solvable installed_r )
00375 : is_updated( false )
00376 , multiversion( installed_r.multiversionInstall() )
00377 , _installed( installed_r )
00378 {}
00379
00380
00381
00382 bool operator()( PoolItem item )
00383 {
00384 if ( item.status().isToBeInstalled() )
00385 {
00386 if ( ! multiversion || sameNVRA( _installed, item ) )
00387 {
00388 is_updated = true;
00389 return false;
00390 }
00391 }
00392 return true;
00393 }
00394 };
00395
00396
00397 class CollectPseudoInstalled : public resfilter::PoolItemFilterFunctor
00398 {
00399 public:
00400 Queue *solvableQueue;
00401
00402 CollectPseudoInstalled( Queue *queue )
00403 :solvableQueue (queue)
00404 {}
00405
00406
00407 bool operator()( PoolItem item )
00408 {
00409 if ( traits::isPseudoInstalled( item.satSolvable().kind() ) )
00410 queue_push( solvableQueue, item.satSolvable().id() );
00411 return true;
00412 }
00413 };
00414
00415 bool
00416 SATResolver::solving(const CapabilitySet & requires_caps,
00417 const CapabilitySet & conflict_caps)
00418 {
00419 _solv = solver_create( _SATPool );
00420 _solv->vendorCheckCb = &vendorCheck;
00421 _solv->fixsystem = _fixsystem;
00422 _solv->ignorealreadyrecommended = _ignorealreadyrecommended;
00423 _solv->updatesystem = _updatesystem;
00424 _solv->allowdowngrade = _allowdowngrade;
00425 _solv->allowuninstall = _allowuninstall;
00426 _solv->allowarchchange = _allowarchchange;
00427 _solv->allowvendorchange = _allowvendorchange;
00428 _solv->dosplitprovides = _dosplitprovides;
00429 _solv->noupdateprovide = _noupdateprovide;
00430 _solv->dontinstallrecommended = _onlyRequires;
00431 _solv->distupgrade = _distupgrade;
00432 _solv->distupgrade_removeunsupported = _distupgrade_removeunsupported;
00433
00434 sat::Pool::instance().prepare();
00435
00436
00437 MIL << "Starting solving...." << endl;
00438 MIL << *this;
00439 solver_solve( _solv, &(_jobQueue) );
00440 MIL << "....Solver end" << endl;
00441
00442
00443
00444 _result_items_to_install.clear();
00445 _result_items_to_remove.clear();
00446
00447
00448 for ( int i = 0; i < _solv->decisionq.count; ++i )
00449 {
00450 sat::Solvable slv( _solv->decisionq.elements[i] );
00451 if ( !slv || slv.isSystem() )
00452 continue;
00453
00454 PoolItem poolItem( slv );
00455 SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
00456 _result_items_to_install.push_back (poolItem);
00457 }
00458
00459
00460 Repository systemRepo( sat::Pool::instance().findSystemRepo() );
00461 if ( systemRepo && ! systemRepo.solvablesEmpty() )
00462 {
00463 bool mustCheckObsoletes = false;
00464 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
00465 {
00466 if (_solv->decisionmap[it->id()] > 0)
00467 continue;
00468
00469
00470 CheckIfUpdate info( *it );
00471 PoolItem poolItem( *it );
00472 invokeOnEach( _pool.byIdentBegin( poolItem ),
00473 _pool.byIdentEnd( poolItem ),
00474 resfilter::ByUninstalled(),
00475 functor::functorRef<bool,PoolItem> (info) );
00476
00477 if (info.is_updated) {
00478 SATSolutionToPool( poolItem, ResStatus::toBeUninstalledDueToUpgrade, ResStatus::SOLVER );
00479 } else {
00480 SATSolutionToPool( poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER );
00481 if ( ! mustCheckObsoletes )
00482 mustCheckObsoletes = true;
00483 }
00484 _result_items_to_remove.push_back (poolItem);
00485 }
00486 if ( mustCheckObsoletes )
00487 {
00488 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
00489 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
00490 {
00491 ResStatus & status( it->status() );
00492
00493 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
00494 status.setToBeUninstalledDueToObsolete();
00495 }
00496 }
00497 }
00498
00499
00500 for ( int i = 0; i < _solv->recommendations.count; ++i )
00501 {
00502 PoolItem poolItem( getPoolItem( _solv->recommendations.elements[i] ) );
00503 poolItem.status().setRecommended( true );
00504 }
00505
00506
00507 for ( int i = 0; i < _solv->suggestions.count; ++i )
00508 {
00509 PoolItem poolItem( getPoolItem( _solv->suggestions.elements[i] ) );
00510 poolItem.status().setSuggested( true );
00511 }
00512
00513 _problem_items.clear();
00514
00515 for ( int i = 0; i < _solv->orphaned.count; ++i )
00516 {
00517 PoolItem poolItem( getPoolItem( _solv->orphaned.elements[i] ) );
00518 poolItem.status().setOrphaned( true );
00519 _problem_items.push_back( poolItem );
00520 }
00521
00522
00523 Queue flags, solvableQueue;
00524
00525 queue_init(&flags);
00526 queue_init(&solvableQueue);
00527
00528 CollectPseudoInstalled collectPseudoInstalled(&solvableQueue);
00529 invokeOnEach( _pool.begin(),
00530 _pool.end(),
00531 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
00532 solver_trivial_installable(_solv, &solvableQueue, &flags );
00533 for (int i = 0; i < solvableQueue.count; i++) {
00534 PoolItem item = _pool.find (sat::Solvable(solvableQueue.elements[i]));
00535 item.status().setUndetermined();
00536
00537 if (flags.elements[i] == -1) {
00538 item.status().setNonRelevant();
00539 _XDEBUG("SATSolutionToPool(" << item << " ) nonRelevant !");
00540 } else if (flags.elements[i] == 1) {
00541 item.status().setSatisfied();
00542 _XDEBUG("SATSolutionToPool(" << item << " ) satisfied !");
00543 } else if (flags.elements[i] == 0) {
00544 item.status().setBroken();
00545 _XDEBUG("SATSolutionToPool(" << item << " ) broken !");
00546 }
00547 }
00548
00549
00550
00551
00552 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
00553 sat::WhatProvides rpmProviders(*iter);
00554 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
00555 PoolItem poolItem(*iter2);
00556 if (poolItem.status().isToBeInstalled()) {
00557 MIL << "User requirement " << *iter << " sets " << poolItem << endl;
00558 poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
00559 }
00560 }
00561 }
00562 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
00563 sat::WhatProvides rpmProviders(*iter);
00564 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
00565 PoolItem poolItem(*iter2);
00566 if (poolItem.status().isToBeUninstalled()) {
00567 MIL << "User conflict " << *iter << " sets " << poolItem << endl;
00568 poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
00569 }
00570 }
00571 }
00572
00573 if (_solv->problems.count > 0 )
00574 {
00575 ERR << "Solverrun finished with an ERROR" << endl;
00576 return false;
00577 }
00578
00579 queue_free(&(solvableQueue));
00580 queue_free(&flags);
00581
00582 return true;
00583 }
00584
00585
00586 void
00587 SATResolver::solverInit(const PoolItemList & weakItems)
00588 {
00589 SATCollectTransact info (*this);
00590
00591 MIL << "SATResolver::solverInit()" << endl;
00592
00593 if (_solv) {
00594
00595 solver_free(_solv);
00596 _solv = NULL;
00597 queue_free( &(_jobQueue) );
00598 }
00599
00600 queue_init( &_jobQueue );
00601 _items_to_install.clear();
00602 _items_to_remove.clear();
00603 _items_to_lock.clear();
00604 _items_to_keep.clear();
00605
00606 invokeOnEach ( _pool.begin(), _pool.end(),
00607 functor::functorRef<bool,PoolItem>(info) );
00608
00609 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
00610 Id id = (*iter)->satSolvable().id();
00611 if (id == ID_NULL) {
00612 ERR << "Weaken: " << *iter << " not found" << endl;
00613 }
00614 MIL << "Weaken dependencies of " << *iter << endl;
00615 queue_push( &(_jobQueue), SOLVER_WEAKEN_SOLVABLE_DEPS );
00616 queue_push( &(_jobQueue), id );
00617 }
00618
00619
00620 for_( it, sat::Pool::instance().multiversionBegin(), sat::Pool::instance().multiversionEnd() )
00621 {
00622 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES_SOLVABLE_NAME );
00623 queue_push( &(_jobQueue), it->id() );
00624 }
00625
00626 if ( _distupgrade )
00627 {
00628 if ( ZConfig::instance().solverUpgradeRemoveDroppedPackages() )
00629 {
00630 MIL << "Checking droplists ..." << endl;
00631
00632
00633 ResPoolProxy proxy( ResPool::instance().proxy() );
00634 for_( it, proxy.byKindBegin<Product>(), proxy.byKindEnd<Product>() )
00635 {
00636 if ( (*it)->onSystem() )
00637 {
00638 Product::constPtr prodCand( (*it)->candidateAsKind<Product>() );
00639 if ( ! prodCand || (*it)->identicalInstalledCandidate() )
00640 continue;
00641
00642 CapabilitySet droplist( prodCand->droplist() );
00643 dumpRangeLine( MIL << "Droplist for " << (*it)->candidateObj() << ": " << droplist.size() << " ", droplist.begin(), droplist.end() ) << endl;
00644 for_( cap, droplist.begin(), droplist.end() )
00645 {
00646 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_NAME );
00647 queue_push( &_jobQueue, cap->id() );
00648 }
00649 }
00650 }
00651 }
00652 else
00653 {
00654 MIL << "Droplist processing is disabled." << endl;
00655 }
00656 }
00657 }
00658
00659 void
00660 SATResolver::solverEnd()
00661 {
00662
00663 solver_free(_solv);
00664 _solv = NULL;
00665 queue_free( &(_jobQueue) );
00666 }
00667
00668
00669 bool
00670 SATResolver::resolvePool(const CapabilitySet & requires_caps,
00671 const CapabilitySet & conflict_caps,
00672 const PoolItemList & weakItems,
00673 const std::set<Repository> & upgradeRepos)
00674 {
00675 MIL << "SATResolver::resolvePool()" << endl;
00676
00677
00678 solverInit(weakItems);
00679
00680 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
00681 Id id = (*iter)->satSolvable().id();
00682 if (id == ID_NULL) {
00683 ERR << "Install: " << *iter << " not found" << endl;
00684 } else {
00685 MIL << "Install " << *iter << endl;
00686 queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE );
00687 queue_push( &(_jobQueue), id );
00688 }
00689 }
00690
00691 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
00692 Id id = (*iter)->satSolvable().id();
00693 if (id == ID_NULL) {
00694 ERR << "Delete: " << *iter << " not found" << endl;
00695 } else {
00696 MIL << "Delete " << *iter << endl;
00697 queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE );
00698 queue_push( &(_jobQueue), id);
00699 }
00700 }
00701
00702 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
00703 {
00704 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_REPO );
00705 queue_push( &(_jobQueue), iter->get()->repoid );
00706 MIL << "Upgrade repo " << *iter << endl;
00707 }
00708
00709 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
00710 queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE_PROVIDES );
00711 queue_push( &(_jobQueue), iter->id() );
00712 MIL << "Requires " << *iter << endl;
00713 }
00714
00715 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
00716 queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE_PROVIDES);
00717 queue_push( &(_jobQueue), iter->id() );
00718 MIL << "Conflicts " << *iter << endl;
00719 }
00720
00721
00722 setSystemRequirements();
00723
00724
00725 setLocks();
00726
00727
00728 bool ret = solving(requires_caps, conflict_caps);
00729
00730 if (ret)
00731 solverEnd();
00732
00733 (ret?MIL:WAR) << "SATResolver::resolvePool() done. Ret:" << ret << endl;
00734 return ret;
00735 }
00736
00737
00738 bool
00739 SATResolver::resolveQueue(const SolverQueueItemList &requestQueue,
00740 const PoolItemList & weakItems)
00741 {
00742 MIL << "SATResolver::resolvQueue()" << endl;
00743
00744
00745 solverInit(weakItems);
00746
00747
00748 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
00749 (*iter)->addRule(_jobQueue);
00750 }
00751
00752
00753 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
00754 Id id = (*iter)->satSolvable().id();
00755 if (id == ID_NULL) {
00756 ERR << "Install: " << *iter << " not found" << endl;
00757 } else {
00758 MIL << "Install " << *iter << endl;
00759 queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE );
00760 queue_push( &(_jobQueue), id );
00761 }
00762 }
00763 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
00764 sat::detail::IdType ident( (*iter)->satSolvable().ident().id() );
00765 MIL << "Delete " << *iter << ident << endl;
00766 queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE_NAME );
00767 queue_push( &(_jobQueue), ident);
00768 }
00769
00770
00771 setSystemRequirements();
00772
00773
00774 setLocks();
00775
00776
00777 bool ret = solving();
00778
00779
00780 if (ret)
00781 solverEnd();
00782
00783 MIL << "SATResolver::resolveQueue() done. Ret:" << ret << endl;
00784 return ret;
00785 }
00786
00788 void SATResolver::doUpdate()
00789 {
00790 MIL << "SATResolver::doUpdate()" << endl;
00791
00792
00793 solverInit(PoolItemList());
00794
00795
00796 setSystemRequirements();
00797
00798
00799 setLocks();
00800
00801 _solv = solver_create( _SATPool );
00802 _solv->vendorCheckCb = &vendorCheck;
00803 _solv->fixsystem = _fixsystem;
00804 _solv->ignorealreadyrecommended = _ignorealreadyrecommended;
00805 _solv->updatesystem = true;
00806 _solv->allowdowngrade = _allowdowngrade;
00807 _solv->allowuninstall = _allowuninstall;
00808 _solv->allowarchchange = _allowarchchange;
00809 _solv->allowvendorchange = _allowvendorchange;
00810 _solv->dosplitprovides = _dosplitprovides;
00811 _solv->noupdateprovide = _noupdateprovide;
00812 _solv->dontinstallrecommended = true;
00813 _solv->distupgrade = _distupgrade;
00814 _solv->distupgrade_removeunsupported = _distupgrade_removeunsupported;
00815
00816 sat::Pool::instance().prepare();
00817
00818
00819 MIL << "Starting solving for update...." << endl;
00820 MIL << *this;
00821 solver_solve( _solv, &(_jobQueue) );
00822 MIL << "....Solver end" << endl;
00823
00824
00825
00826
00827
00828 for (int i = 0; i < _solv->decisionq.count; i++)
00829 {
00830 Id p;
00831 p = _solv->decisionq.elements[i];
00832 if (p < 0 || !sat::Solvable(p))
00833 continue;
00834 if (sat::Solvable(p).repository().get() == _solv->installed)
00835 continue;
00836
00837 PoolItem poolItem = _pool.find (sat::Solvable(p));
00838 if (poolItem) {
00839 SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
00840 } else {
00841 ERR << "id " << p << " not found in ZYPP pool." << endl;
00842 }
00843 }
00844
00845
00846 for (int i = _solv->installed->start; i < _solv->installed->start + _solv->installed->nsolvables; i++)
00847 {
00848 if (_solv->decisionmap[i] > 0)
00849 continue;
00850
00851 PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
00852 if (poolItem) {
00853
00854 CheckIfUpdate info( (sat::Solvable(i)) );
00855 invokeOnEach( _pool.byIdentBegin( poolItem ),
00856 _pool.byIdentEnd( poolItem ),
00857 resfilter::ByUninstalled(),
00858 functor::functorRef<bool,PoolItem> (info) );
00859
00860 if (info.is_updated) {
00861 SATSolutionToPool (poolItem, ResStatus::toBeUninstalledDueToUpgrade , ResStatus::SOLVER);
00862 } else {
00863 SATSolutionToPool (poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER);
00864 }
00865 } else {
00866 ERR << "id " << i << " not found in ZYPP pool." << endl;
00867 }
00868 }
00869
00870
00871 solverEnd();
00872
00873 MIL << "SATResolver::doUpdate() done" << endl;
00874 }
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888 struct FindPackage : public resfilter::ResObjectFilterFunctor
00889 {
00890 ProblemSolutionCombi *problemSolution;
00891 TransactionKind action;
00892 FindPackage (ProblemSolutionCombi *p, const TransactionKind act)
00893 : problemSolution (p)
00894 , action (act)
00895 {
00896 }
00897
00898 bool operator()( PoolItem p)
00899 {
00900 problemSolution->addSingleAction (p, action);
00901 return true;
00902 }
00903 };
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915 PoolItem SATResolver::mapItem (const PoolItem &item)
00916 {
00917 sat::Solvable buddy = item.buddy();
00918 if (buddy != sat::Solvable())
00919 {
00920 return _pool.find (buddy);
00921 }
00922 else
00923 {
00924 return item;
00925 }
00926 }
00927
00928 sat::Solvable SATResolver::mapSolvable (const Id &id)
00929 {
00930 PoolItem item = _pool.find (sat::Solvable(id));
00931 return mapItem(item).satSolvable();
00932 }
00933
00934 string SATResolver::SATprobleminfoString(Id problem, string &detail, Id &ignoreId)
00935 {
00936 string ret;
00937 Pool *pool = _solv->pool;
00938 Id probr;
00939 Id dep, source, target;
00940 sat::Solvable s, s2;
00941
00942 ignoreId = 0;
00943 probr = solver_findproblemrule(_solv, problem);
00944 switch (solver_problemruleinfo(_solv, &(_jobQueue), probr, &dep, &source, &target))
00945 {
00946 case SOLVER_PROBLEM_DISTUPGRADE_RULE:
00947 s = mapSolvable (source);
00948 ret = str::form (_("%s does not belong to a distupgrade repository"), s.asString().c_str());
00949 break;
00950 case SOLVER_PROBLEM_INFARCH_RULE:
00951 s = mapSolvable (source);
00952 ret = str::form (_("%s has inferior architecture"), s.asString().c_str());
00953 break;
00954 case SOLVER_PROBLEM_UPDATE_RULE:
00955 s = mapSolvable (source);
00956 ret = str::form (_("problem with installed package %s"), s.asString().c_str());
00957 break;
00958 case SOLVER_PROBLEM_JOB_RULE:
00959 ret = _("conflicting requests");
00960 break;
00961 case SOLVER_PROBLEM_RPM_RULE:
00962 ret = _("some dependency problem");
00963 break;
00964 case SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP:
00965 ret = str::form (_("nothing provides requested %s"), dep2str(pool, dep));
00966 detail += _("Have you enabled all requested repositories?");
00967 break;
00968 case SOLVER_PROBLEM_NOT_INSTALLABLE:
00969 s = mapSolvable (source);
00970 ret = str::form (_("%s is not installable"), s.asString().c_str());
00971 break;
00972 case SOLVER_PROBLEM_NOTHING_PROVIDES_DEP:
00973 ignoreId = source;
00974 s = mapSolvable (source);
00975 ret = str::form (_("nothing provides %s needed by %s"), dep2str(pool, dep), s.asString().c_str());
00976 break;
00977 case SOLVER_PROBLEM_SAME_NAME:
00978 s = mapSolvable (source);
00979 s2 = mapSolvable (target);
00980 ret = str::form (_("cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
00981 break;
00982 case SOLVER_PROBLEM_PACKAGE_CONFLICT:
00983 s = mapSolvable (source);
00984 s2 = mapSolvable (target);
00985 ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), dep2str(pool, dep), s2.asString().c_str());
00986 break;
00987 case SOLVER_PROBLEM_PACKAGE_OBSOLETES:
00988 s = mapSolvable (source);
00989 s2 = mapSolvable (target);
00990 ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), dep2str(pool, dep), s2.asString().c_str());
00991 break;
00992 case SOLVER_PROBLEM_SELF_CONFLICT:
00993 s = mapSolvable (source);
00994 ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), dep2str(pool, dep));
00995 break;
00996 case SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE:
00997 ignoreId = source;
00998 s = mapSolvable (source);
00999 Capability cap(dep);
01000 sat::WhatProvides possibleProviders(cap);
01001
01002
01003 typedef list<PoolItem> ProviderList;
01004 ProviderList providerlistInstalled, providerlistUninstalled;
01005 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
01006 PoolItem provider1 = ResPool::instance().find( *iter1 );
01007
01008 bool found = false;
01009 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
01010 PoolItem provider2 = ResPool::instance().find( *iter2 );
01011 if (compareByNVR (provider1.resolvable(),provider2.resolvable()) == 0
01012 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
01013 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
01014 found = true;
01015 break;
01016 }
01017 }
01018 if (!found) {
01019 if (provider1.status().isInstalled())
01020 providerlistInstalled.push_back(provider1);
01021 else
01022 providerlistUninstalled.push_back(provider1);
01023 }
01024 }
01025
01026 ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), dep2str(pool, dep));
01027 if (providerlistInstalled.size() > 0) {
01028 detail += _("deleted providers: ");
01029 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
01030 if (iter == providerlistInstalled.begin())
01031 detail += itemToString( *iter );
01032 else
01033 detail += "\n " + itemToString( mapItem(*iter) );
01034 }
01035 }
01036 if (providerlistUninstalled.size() > 0) {
01037 if (detail.size() > 0)
01038 detail += _("\nuninstallable providers: ");
01039 else
01040 detail = _("uninstallable providers: ");
01041 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
01042 if (iter == providerlistUninstalled.begin())
01043 detail += itemToString( *iter );
01044 else
01045 detail += "\n " + itemToString( mapItem(*iter) );
01046 }
01047 }
01048 break;
01049 }
01050
01051 return ret;
01052 }
01053
01054 ResolverProblemList
01055 SATResolver::problems ()
01056 {
01057 ResolverProblemList resolverProblems;
01058 if (_solv && _solv->problems.count) {
01059 Pool *pool = _solv->pool;
01060 int pcnt;
01061 Id p, rp, what;
01062 Id problem, solution, element;
01063 sat::Solvable s, sd;
01064
01065 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
01066 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
01067
01068 MIL << "Encountered problems! Here are the solutions:\n" << endl;
01069 pcnt = 1;
01070 problem = 0;
01071 while ((problem = solver_next_problem(_solv, problem)) != 0) {
01072 MIL << "Problem " << pcnt++ << ":" << endl;
01073 MIL << "====================================" << endl;
01074 string detail;
01075 Id ignoreId;
01076 string whatString = SATprobleminfoString (problem,detail,ignoreId);
01077 MIL << whatString << endl;
01078 MIL << "------------------------------------" << endl;
01079 ResolverProblem_Ptr resolverProblem = new ResolverProblem (whatString, detail);
01080
01081 solution = 0;
01082 while ((solution = solver_next_solution(_solv, problem, solution)) != 0) {
01083 element = 0;
01084 ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi(resolverProblem);
01085 while ((element = solver_next_solutionelement(_solv, problem, solution, element, &p, &rp)) != 0) {
01086 if (p == SOLVER_SOLUTION_JOB) {
01087
01088 what = _jobQueue.elements[rp];
01089 switch (_jobQueue.elements[rp-1])
01090 {
01091 case SOLVER_INSTALL_SOLVABLE: {
01092 s = mapSolvable (what);
01093 PoolItem poolItem = _pool.find (s);
01094 if (poolItem) {
01095 if (_solv->installed && s.get()->repo == _solv->installed) {
01096 problemSolution->addSingleAction (poolItem, REMOVE);
01097 string description = str::form (_("do not keep %s installed"), s.asString().c_str() );
01098 MIL << description << endl;
01099 problemSolution->addDescription (description);
01100 } else {
01101 problemSolution->addSingleAction (poolItem, KEEP);
01102 string description = str::form (_("do not install %s"), s.asString().c_str());
01103 MIL << description << endl;
01104 problemSolution->addDescription (description);
01105 }
01106 } else {
01107 ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
01108 }
01109 }
01110 break;
01111 case SOLVER_ERASE_SOLVABLE: {
01112 s = mapSolvable (what);
01113 PoolItem poolItem = _pool.find (s);
01114 if (poolItem) {
01115 if (_solv->installed && s.get()->repo == _solv->installed) {
01116 problemSolution->addSingleAction (poolItem, KEEP);
01117 string description = str::form (_("keep %s"), s.asString().c_str());
01118 MIL << description << endl;
01119 problemSolution->addDescription (description);
01120 } else {
01121 problemSolution->addSingleAction (poolItem, UNLOCK);
01122 string description = str::form (_("do not forbid installation of %s"), itemToString( poolItem ).c_str());
01123 MIL << description << endl;
01124 problemSolution->addDescription (description);
01125 }
01126 } else {
01127 ERR << "SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
01128 }
01129 }
01130 break;
01131 case SOLVER_INSTALL_SOLVABLE_NAME:
01132 {
01133 IdString ident( what );
01134 SolverQueueItemInstall_Ptr install =
01135 new SolverQueueItemInstall(_pool, ident.asString(), false );
01136 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
01137
01138 string description = str::form (_("do not install %s"), ident.c_str() );
01139 MIL << description << endl;
01140 problemSolution->addDescription (description);
01141 }
01142 break;
01143 case SOLVER_ERASE_SOLVABLE_NAME:
01144 {
01145
01146
01147 IdString ident( what );
01148 FindPackage info (problemSolution, KEEP);
01149 invokeOnEach( _pool.byIdentBegin( ident ),
01150 _pool.byIdentEnd( ident ),
01151 functor::chain (resfilter::ByInstalled (),
01152 resfilter::ByTransact ()),
01153 functor::functorRef<bool,PoolItem> (info) );
01154
01155 SolverQueueItemDelete_Ptr del =
01156 new SolverQueueItemDelete(_pool, ident.asString(), false );
01157 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
01158
01159 string description = str::form (_("keep %s"), ident.c_str());
01160 MIL << description << endl;
01161 problemSolution->addDescription (description);
01162 }
01163 break;
01164 case SOLVER_INSTALL_SOLVABLE_PROVIDES:
01165 {
01166 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
01167 string description = "";
01168
01169
01170 if (system_requires.find(Capability(what)) != system_requires.end()) {
01171
01172 resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
01173 resolverProblem->setDescription(_("This request will break your system!"));
01174 description = _("ignore the warning of a broken system");
01175 description += string(" (requires:")+dep2str(pool, what)+")";
01176 MIL << description << endl;
01177 problemSolution->addFrontDescription (description);
01178 } else {
01179 description = str::form (_("do not ask to install a solvable providing %s"), dep2str(pool, what));
01180 MIL << description << endl;
01181 problemSolution->addDescription (description);
01182 }
01183 }
01184 break;
01185 case SOLVER_ERASE_SOLVABLE_PROVIDES:
01186 {
01187 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
01188 string description = "";
01189
01190
01191 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
01192
01193 resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
01194 resolverProblem->setDescription(_("This request will break your system!"));
01195 description = _("ignore the warning of a broken system");
01196 description += string(" (conflicts:")+dep2str(pool, what)+")";
01197 MIL << description << endl;
01198 problemSolution->addFrontDescription (description);
01199
01200 } else {
01201 description = str::form (_("do not ask to delete all solvables providing %s"), dep2str(pool, what));
01202 MIL << description << endl;
01203 problemSolution->addDescription (description);
01204 }
01205 }
01206 break;
01207 case SOLVER_INSTALL_SOLVABLE_UPDATE:
01208 {
01209 s = mapSolvable (what);
01210 PoolItem poolItem = _pool.find (s);
01211 if (poolItem) {
01212 if (_solv->installed && s.get()->repo == _solv->installed) {
01213 problemSolution->addSingleAction (poolItem, KEEP);
01214 string description = str::form (_("do not install most recent version of %s"), s.asString().c_str());
01215 MIL << description << endl;
01216 problemSolution->addDescription (description);
01217 } else {
01218 ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem << " is not selected for installation" << endl;
01219 }
01220 } else {
01221 ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
01222 }
01223 }
01224 break;
01225 default:
01226 MIL << "- do something different" << endl;
01227 ERR << "No valid solution available" << endl;
01228 break;
01229 }
01230 } else if (p == SOLVER_SOLUTION_INFARCH) {
01231 s = mapSolvable (rp);
01232 PoolItem poolItem = _pool.find (s);
01233 if (_solv->installed && s.get()->repo == _solv->installed) {
01234 problemSolution->addSingleAction (poolItem, LOCK);
01235 string description = str::form (_("keep %s despite the inferior architecture"), s.asString().c_str());
01236 MIL << description << endl;
01237 problemSolution->addDescription (description);
01238 } else {
01239 problemSolution->addSingleAction (poolItem, INSTALL);
01240 string description = str::form (_("install %s despite the inferior architecture"), s.asString().c_str());
01241 MIL << description << endl;
01242 problemSolution->addDescription (description);
01243 }
01244 } else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
01245 s = mapSolvable (rp);
01246 PoolItem poolItem = _pool.find (s);
01247 if (_solv->installed && s.get()->repo == _solv->installed) {
01248 problemSolution->addSingleAction (poolItem, LOCK);
01249 string description = str::form (_("keep obsolete %s"), s.asString().c_str());
01250 MIL << description << endl;
01251 problemSolution->addDescription (description);
01252 } else {
01253 problemSolution->addSingleAction (poolItem, INSTALL);
01254 string description = str::form (_("install %s from excluded repository"), s.asString().c_str());
01255 MIL << description << endl;
01256 problemSolution->addDescription (description);
01257 }
01258 } else {
01259
01260 s = mapSolvable (p);
01261 if (rp)
01262 sd = mapSolvable (rp);
01263
01264 PoolItem itemFrom = _pool.find (s);
01265 if (s == sd && _solv->distupgrade)
01266 {
01267 PoolItem poolItem = _pool.find (s);
01268 if (poolItem) {
01269 problemSolution->addSingleAction (poolItem, LOCK);
01270 string description = str::form (_("keep obsolete %s"), s.asString().c_str());
01271 MIL << description << endl;
01272 problemSolution->addDescription (description);
01273 } else {
01274 ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
01275 }
01276 }
01277 else if (rp)
01278 {
01279 int gotone = 0;
01280
01281 PoolItem itemTo = _pool.find (sd);
01282 if (itemFrom && itemTo) {
01283 problemSolution->addSingleAction (itemTo, INSTALL);
01284
01285 if (evrcmp(pool, s.get()->evr, sd.get()->evr, EVRCMP_COMPARE ) > 0)
01286 {
01287 string description = str::form (_("downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
01288 MIL << description << endl;
01289 problemSolution->addDescription (description);
01290 gotone = 1;
01291 }
01292 if (!_solv->allowarchchange && s.get()->name == sd.get()->name && s.get()->arch != sd.get()->arch
01293 && policy_illegal_archchange(_solv, s.get(), sd.get()))
01294 {
01295 string description = str::form (_("architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
01296 MIL << description << endl;
01297 problemSolution->addDescription (description);
01298 gotone = 1;
01299 }
01300 if (!_solv->allowvendorchange && s.get()->name == sd.get()->name && s.get()->vendor != sd.get()->vendor
01301 && policy_illegal_vendorchange(_solv, s.get(), sd.get()))
01302 {
01303 IdString s_vendor( s.vendor() );
01304 IdString sd_vendor( sd.vendor() );
01305 string description = str::form (_("install %s (with vendor change)\n %s --> %s") ,
01306 sd.asString().c_str(),
01307 ( s_vendor ? s_vendor.c_str() : " (no vendor) " ),
01308 ( sd_vendor ? sd_vendor.c_str() : " (no vendor) " ) );
01309 MIL << description << endl;
01310 problemSolution->addDescription (description);
01311 gotone = 1;
01312 }
01313 if (!gotone) {
01314 string description = str::form (_("replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
01315 MIL << description << endl;
01316 problemSolution->addDescription (description);
01317 }
01318 } else {
01319 ERR << s.asString() << " or " << sd.asString() << " not found" << endl;
01320 }
01321 }
01322 else
01323 {
01324 if (itemFrom) {
01325 string description = str::form (_("deinstallation of %s"), s.asString().c_str());
01326 MIL << description << endl;
01327 problemSolution->addDescription (description);
01328 problemSolution->addSingleAction (itemFrom, REMOVE);
01329 }
01330 }
01331 }
01332 }
01333 resolverProblem->addSolution (problemSolution,
01334 problemSolution->actionCount() > 1 ? true : false);
01335 MIL << "------------------------------------" << endl;
01336 }
01337
01338 if (ignoreId > 0) {
01339
01340 PoolItem item = _pool.find (sat::Solvable(ignoreId));
01341 ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(resolverProblem, item);
01342 resolverProblem->addSolution (problemSolution,
01343 false);
01344 MIL << "ignore some dependencies of " << item << endl;
01345 MIL << "------------------------------------" << endl;
01346 }
01347
01348
01349 resolverProblems.push_back (resolverProblem);
01350 }
01351 }
01352 return resolverProblems;
01353 }
01354
01355 void
01356 SATResolver::applySolutions (const ProblemSolutionList & solutions)
01357 {
01358 for (ProblemSolutionList::const_iterator iter = solutions.begin();
01359 iter != solutions.end(); ++iter) {
01360 ProblemSolution_Ptr solution = *iter;
01361 Resolver dummyResolver(_pool);
01362 if (!solution->apply (dummyResolver))
01363 break;
01364 }
01365 }
01366
01367 void SATResolver::setLocks()
01368 {
01369 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
01370 sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
01371 if (iter->status().isInstalled()) {
01372 MIL << "Lock installed item " << *iter << endl;
01373 queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE );
01374 queue_push( &(_jobQueue), ident );
01375 } else {
01376 MIL << "Lock NOT installed item " << *iter << endl;
01377 queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE );
01378 queue_push( &(_jobQueue), ident );
01379 }
01380 }
01381
01383
01384
01386 std::set<IdString> unifiedByName;
01387 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
01388 IdString ident( (*iter)->satSolvable().ident() );
01389 if ( unifiedByName.insert( ident ).second )
01390 {
01391 if ( ! ui::Selectable::get( *iter )->hasInstalledObj() )
01392 {
01393 MIL << "Keep NOT installed name " << ident << " (" << *iter << ")" << endl;
01394 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK );
01395 queue_push( &(_jobQueue), ident.id() );
01396 }
01397 }
01398 }
01399 }
01400
01401 void SATResolver::setSystemRequirements()
01402 {
01403 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
01404 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
01405
01406 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
01407 queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE_PROVIDES);
01408 queue_push( &(_jobQueue), iter->id() );
01409 MIL << "SYSTEM Requires " << *iter << endl;
01410 }
01411
01412 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
01413 queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE_PROVIDES);
01414 queue_push( &(_jobQueue), iter->id() );
01415 MIL << "SYSTEM Conflicts " << *iter << endl;
01416 }
01417
01418
01419
01420 if ( _distupgrade && ZConfig::instance().systemRoot() == "/" )
01421 {
01422 ResPool pool( ResPool::instance() );
01423 IdString rpm( "rpm" );
01424 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
01425 {
01426 if ( (*it)->isSystem() )
01427 {
01428 Capability archrule( (*it)->arch(), rpm.c_str(), Capability::PARSED );
01429 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
01430 queue_push( &(_jobQueue), archrule.id() );
01431
01432 }
01433 }
01434 }
01435 }
01436
01437
01439 };
01442 };
01445 };
01447