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 #define ZYPP_USE_RESOLVER_INTERNALS 63 #define XDEBUG(x) do { if (base::logger::isExcessive()) XXX << x << std::endl;} while (0) 65 #undef ZYPP_BASE_LOGGER_LOGGROUP 66 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::solver" 75 inline bool HACKENV(
const char * var_r,
bool default_r )
78 const char * val = ::getenv( var_r );
82 if ( ret != default_r )
83 INT <<
"HACKENV " << var_r <<
" = " << ret << endl;
101 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0) 110 IdString(solvable2->vendor) ) ? 0 : 1;
117 return std::string();
120 std::string ret( slv.asString() );
121 if ( ! slv.isSystem() )
134 INT <<
"id " << id_r <<
" not found in ZYPP pool." << endl;
143 os <<
"<resolver>" << endl;
145 #define OUTS(X) os << " " << #X << "\t= " << solver_get_flag(_satSolver, SOLVER_FLAG_##X) << endl 146 OUTS( ALLOW_DOWNGRADE );
147 OUTS( ALLOW_ARCHCHANGE );
148 OUTS( ALLOW_VENDORCHANGE );
149 OUTS( ALLOW_NAMECHANGE );
150 OUTS( ALLOW_UNINSTALL );
151 OUTS( NO_UPDATEPROVIDE );
152 OUTS( SPLITPROVIDES );
153 OUTS( IGNORE_RECOMMENDED );
154 OUTS( ADD_ALREADY_RECOMMENDED );
155 OUTS( NO_INFARCHCHECK );
156 OUTS( KEEP_EXPLICIT_OBSOLETES );
157 OUTS( BEST_OBEY_POLICY );
158 OUTS( NO_AUTOTARGET );
159 OUTS( DUP_ALLOW_DOWNGRADE );
160 OUTS( DUP_ALLOW_ARCHCHANGE );
161 OUTS( DUP_ALLOW_VENDORCHANGE );
162 OUTS( DUP_ALLOW_NAMECHANGE );
163 OUTS( KEEP_ORPHANS );
164 OUTS( BREAK_ORPHANS );
165 OUTS( FOCUS_INSTALLED );
166 OUTS( YUM_OBSOLETES );
168 os <<
" distupgrade = " << _distupgrade << endl;
169 os <<
" distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
170 os <<
" solveSrcPackages = " << _solveSrcPackages << endl;
171 os <<
" cleandepsOnRemove = " << _cleandepsOnRemove << endl;
172 os <<
" fixsystem = " << _fixsystem << endl;
176 return os <<
"<resolver/>" << endl;
187 , _allowdowngrade ( false )
188 , _allownamechange ( true )
189 , _allowarchchange ( false )
191 , _allowuninstall ( false )
192 , _updatesystem(false)
193 , _noupdateprovide ( false )
194 , _dosplitprovides ( true )
195 , _onlyRequires (ZConfig::instance().solver_onlyRequires())
196 , _ignorealreadyrecommended(true)
197 , _distupgrade(false)
198 , _distupgrade_removeunsupported(false)
203 , _solveSrcPackages(false)
204 , _cleandepsOnRemove(ZConfig::instance().solver_cleandepsOnRemove())
209 SATResolver::~SATResolver()
217 SATResolver::pool (
void)
const 239 XDEBUG(
"SATSolutionToPool install returns " << item <<
", " << r);
243 XDEBUG(
"SATSolutionToPool upgrade returns " << item <<
", " << r);
247 XDEBUG(
"SATSolutionToPool remove returns " << item <<
", " << r);
268 PoolItemList & items_to_remove_r,
269 PoolItemList & items_to_lock_r,
270 PoolItemList & items_to_keep_r,
271 bool solveSrcPackages_r )
272 : _items_to_install( items_to_install_r )
273 , _items_to_remove( items_to_remove_r )
274 , _items_to_lock( items_to_lock_r )
275 , _items_to_keep( items_to_keep_r )
276 , _solveSrcPackages( solveSrcPackages_r )
278 _items_to_install.clear();
279 _items_to_remove.clear();
280 _items_to_lock.clear();
281 _items_to_keep.clear();
288 bool by_solver = ( itemStatus.isBySolver() || itemStatus.isByApplLow() );
303 switch ( itemStatus.getTransactValue() )
306 itemStatus.isUninstalled() ? _items_to_install.push_back( item_r )
307 : _items_to_remove.push_back( item_r );
break;
339 : is_updated( false )
340 , _installed( installed_r )
366 :solvableQueue (queue)
382 _satSolver = solver_create( _satPool );
383 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
385 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
386 queue_push( &(_jobQueue), 0 );
389 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
390 queue_push( &(_jobQueue), 0 );
393 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
394 queue_push( &(_jobQueue), 0 );
396 if (_distupgrade_removeunsupported) {
397 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
398 queue_push( &(_jobQueue), 0 );
400 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
401 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
402 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
403 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
405 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
406 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
407 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
408 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED,
false);
409 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires);
415 #define HACKENV(X,D) solver_set_flag(_satSolver, X, env::HACKENV( #X, D ) ); 425 MIL <<
"Starting solving...." << endl;
427 solver_solve( _satSolver, &(_jobQueue) );
428 MIL <<
"....Solver end" << endl;
432 _result_items_to_install.clear();
433 _result_items_to_remove.clear();
437 queue_init(&decisionq);
438 solver_get_decisionqueue(_satSolver, &decisionq);
439 for (
int i = 0; i < decisionq.count; ++i )
441 sat::Solvable slv( decisionq.elements[i] );
442 if ( !slv || slv.isSystem() )
445 PoolItem poolItem( slv );
447 _result_items_to_install.push_back( poolItem );
449 queue_free(&decisionq);
453 if ( systemRepo && ! systemRepo.solvablesEmpty() )
455 bool mustCheckObsoletes =
false;
456 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
458 if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
462 CheckIfUpdate info( *it );
463 PoolItem poolItem( *it );
465 _pool.byIdentEnd( poolItem ),
466 resfilter::ByUninstalled(),
467 functor::functorRef<bool,PoolItem> (info) );
469 if (info.is_updated) {
473 if ( ! mustCheckObsoletes )
474 mustCheckObsoletes =
true;
476 _result_items_to_remove.push_back (poolItem);
478 if ( mustCheckObsoletes )
480 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
481 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
483 ResStatus & status( it->status() );
485 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
486 status.setToBeUninstalledDueToObsolete();
491 Queue recommendations;
495 queue_init(&recommendations);
496 queue_init(&suggestions);
497 queue_init(&orphaned);
498 queue_init(&unneeded);
499 solver_get_recommendations(_satSolver, &recommendations, &suggestions, 0);
500 solver_get_orphaned(_satSolver, &orphaned);
501 solver_get_unneeded(_satSolver, &unneeded, 1);
503 for (
int i = 0; i < recommendations.count; ++i )
505 PoolItem poolItem(
getPoolItem( recommendations.elements[i] ) );
506 poolItem.status().setRecommended(
true );
510 for (
int i = 0; i < suggestions.count; ++i )
512 PoolItem poolItem(
getPoolItem( suggestions.elements[i] ) );
513 poolItem.status().setSuggested(
true );
516 _problem_items.clear();
518 for (
int i = 0; i < orphaned.count; ++i )
520 PoolItem poolItem(
getPoolItem( orphaned.elements[i] ) );
521 poolItem.status().setOrphaned(
true );
522 _problem_items.push_back( poolItem );
526 for (
int i = 0; i < unneeded.count; ++i )
528 PoolItem poolItem(
getPoolItem( unneeded.elements[i] ) );
529 poolItem.status().setUnneeded(
true );
532 queue_free(&recommendations);
533 queue_free(&suggestions);
534 queue_free(&orphaned);
535 queue_free(&unneeded);
538 Queue flags, solvableQueue;
541 queue_init(&solvableQueue);
543 CollectPseudoInstalled collectPseudoInstalled(&solvableQueue);
546 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
547 solver_trivial_installable(_satSolver, &solvableQueue, &flags );
548 for (
int i = 0; i < solvableQueue.count; i++) {
549 PoolItem item = _pool.find (sat::Solvable(solvableQueue.elements[i]));
550 item.status().setUndetermined();
552 if (flags.elements[i] == -1) {
553 item.status().setNonRelevant();
554 XDEBUG(
"SATSolutionToPool(" << item <<
" ) nonRelevant !");
555 }
else if (flags.elements[i] == 1) {
556 item.status().setSatisfied();
557 XDEBUG(
"SATSolutionToPool(" << item <<
" ) satisfied !");
558 }
else if (flags.elements[i] == 0) {
559 item.status().setBroken();
560 XDEBUG(
"SATSolutionToPool(" << item <<
" ) broken !");
563 queue_free(&(solvableQueue));
570 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
571 sat::WhatProvides rpmProviders(*iter);
572 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
573 PoolItem poolItem(*iter2);
574 if (poolItem.status().isToBeInstalled()) {
575 MIL <<
"User requirement " << *iter <<
" sets " << poolItem << endl;
580 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
581 sat::WhatProvides rpmProviders(*iter);
582 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
583 PoolItem poolItem(*iter2);
584 if (poolItem.status().isToBeUninstalled()) {
585 MIL <<
"User conflict " << *iter <<
" sets " << poolItem << endl;
591 if (solver_problem_count(_satSolver) > 0 )
593 ERR <<
"Solverrun finished with an ERROR" << endl;
602 SATResolver::solverInit(
const PoolItemList & weakItems)
605 MIL <<
"SATResolver::solverInit()" << endl;
609 queue_init( &_jobQueue );
613 SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
614 invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
617 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
618 Id
id = (*iter)->satSolvable().id();
620 ERR <<
"Weaken: " << *iter <<
" not found" << endl;
622 MIL <<
"Weaken dependencies of " << *iter << endl;
623 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
624 queue_push( &(_jobQueue),
id );
629 const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
632 for (
const auto & locale : trackedLocaleIds.added() )
634 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
638 for (
const auto & locale : trackedLocaleIds.removed() )
640 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS );
646 for (
const sat::Solvable & solv : myPool().multiversionList() )
648 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
649 queue_push( &(_jobQueue), solv.id() );
652 ::pool_add_userinstalled_jobs(_satPool,
sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
658 MIL <<
"Checking droplists ..." << endl;
662 for_( it, proxy.byKindBegin<Product>(), proxy.byKindEnd<Product>() )
664 if ( (*it)->onSystem() )
671 dumpRangeLine(
MIL <<
"Droplist for " << (*it)->candidateObj() <<
": " << droplist.size() <<
" ", droplist.begin(), droplist.end() ) << endl;
672 for_( cap, droplist.begin(), droplist.end() )
674 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
675 queue_push( &_jobQueue, cap->id() );
682 MIL <<
"Droplist processing is disabled." << endl;
688 SATResolver::solverEnd()
693 solver_free(_satSolver);
695 queue_free( &(_jobQueue) );
701 SATResolver::resolvePool(
const CapabilitySet & requires_caps,
703 const PoolItemList & weakItems,
704 const std::set<Repository> & upgradeRepos)
706 MIL <<
"SATResolver::resolvePool()" << endl;
709 solverInit(weakItems);
711 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
712 Id
id = (*iter)->satSolvable().id();
714 ERR <<
"Install: " << *iter <<
" not found" << endl;
716 MIL <<
"Install " << *iter << endl;
717 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
718 queue_push( &(_jobQueue),
id );
722 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
723 Id
id = (*iter)->satSolvable().id();
725 ERR <<
"Delete: " << *iter <<
" not found" << endl;
727 MIL <<
"Delete " << *iter << endl;
728 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
729 queue_push( &(_jobQueue),
id);
733 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
735 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
736 queue_push( &(_jobQueue), iter->get()->repoid );
737 MIL <<
"Upgrade repo " << *iter << endl;
740 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
741 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
742 queue_push( &(_jobQueue), iter->id() );
743 MIL <<
"Requires " << *iter << endl;
746 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
747 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
748 queue_push( &(_jobQueue), iter->id() );
749 MIL <<
"Conflicts " << *iter << endl;
753 setSystemRequirements();
759 bool ret = solving(requires_caps, conflict_caps);
761 (ret?
MIL:
WAR) <<
"SATResolver::resolvePool() done. Ret:" << ret << endl;
768 const PoolItemList & weakItems)
770 MIL <<
"SATResolver::resolvQueue()" << endl;
773 solverInit(weakItems);
776 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
777 (*iter)->addRule(_jobQueue);
781 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
782 Id
id = (*iter)->satSolvable().id();
784 ERR <<
"Install: " << *iter <<
" not found" << endl;
786 MIL <<
"Install " << *iter << endl;
787 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
788 queue_push( &(_jobQueue),
id );
791 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
793 MIL <<
"Delete " << *iter << ident << endl;
794 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME |
MAYBE_CLEANDEPS );
795 queue_push( &(_jobQueue), ident);
799 setSystemRequirements();
805 bool ret = solving();
807 MIL <<
"SATResolver::resolveQueue() done. Ret:" << ret << endl;
812 void SATResolver::doUpdate()
814 MIL <<
"SATResolver::doUpdate()" << endl;
817 solverInit(PoolItemList());
820 setSystemRequirements();
825 _satSolver = solver_create( _satPool );
826 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
828 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
829 queue_push( &(_jobQueue), 0 );
832 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
833 queue_push( &(_jobQueue), 0 );
836 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
837 queue_push( &(_jobQueue), 0 );
839 if (_distupgrade_removeunsupported) {
840 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
841 queue_push( &(_jobQueue), 0 );
843 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
844 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
845 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
846 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
848 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
849 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
850 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
851 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED,
false);
852 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires);
857 MIL <<
"Starting solving for update...." << endl;
859 solver_solve( _satSolver, &(_jobQueue) );
860 MIL <<
"....Solver end" << endl;
867 queue_init(&decisionq);
868 solver_get_decisionqueue(_satSolver, &decisionq);
869 for (
int i = 0; i < decisionq.count; i++)
872 p = decisionq.elements[i];
873 if (p < 0 || !sat::Solvable(p))
875 if (sat::Solvable(p).repository().get() == _satSolver->pool->installed)
878 PoolItem poolItem = _pool.find (sat::Solvable(p));
882 ERR <<
"id " << p <<
" not found in ZYPP pool." << endl;
885 queue_free(&decisionq);
888 for (
int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
890 if (solver_get_decisionlevel(_satSolver, i) > 0)
893 PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
896 CheckIfUpdate info( (sat::Solvable(i)) );
898 _pool.byIdentEnd( poolItem ),
899 resfilter::ByUninstalled(),
900 functor::functorRef<bool,PoolItem> (info) );
902 if (info.is_updated) {
908 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
911 MIL <<
"SATResolver::doUpdate() done" << endl;
931 : problemSolution (p)
938 problemSolution->addSingleAction (p, action);
971 string SATResolver::SATprobleminfoString(Id problem,
string &detail, Id &ignoreId)
976 Id dep, source, target;
983 probr = solver_findproblemrule(_satSolver, problem);
984 switch (solver_ruleinfo(_satSolver, probr, &source, &target, &dep))
986 case SOLVER_RULE_DISTUPGRADE:
987 s = mapSolvable (source);
988 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.asString().c_str());
990 case SOLVER_RULE_INFARCH:
991 s = mapSolvable (source);
992 ret =
str::form (
_(
"%s has inferior architecture"), s.asString().c_str());
994 case SOLVER_RULE_UPDATE:
995 s = mapSolvable (source);
996 ret =
str::form (
_(
"problem with installed package %s"), s.asString().c_str());
998 case SOLVER_RULE_JOB:
999 ret =
_(
"conflicting requests");
1001 case SOLVER_RULE_RPM:
1002 ret =
_(
"some dependency problem");
1004 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1005 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
1006 detail +=
_(
"Have you enabled all requested repositories?");
1008 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1009 ret =
str::form (
_(
"package %s does not exist"), pool_dep2str(pool, dep));
1010 detail +=
_(
"Have you enabled all requested repositories?");
1012 case SOLVER_RULE_JOB_UNSUPPORTED:
1013 ret =
_(
"unsupported request");
1015 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1016 ret =
str::form (
_(
"%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1018 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1019 s = mapSolvable (source);
1020 ret =
str::form (
_(
"%s is not installable"), s.asString().c_str());
1022 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1024 s = mapSolvable (source);
1025 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1027 case SOLVER_RULE_RPM_SAME_NAME:
1028 s = mapSolvable (source);
1029 s2 = mapSolvable (target);
1030 ret =
str::form (
_(
"cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1032 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1033 s = mapSolvable (source);
1034 s2 = mapSolvable (target);
1035 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1037 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1038 s = mapSolvable (source);
1039 s2 = mapSolvable (target);
1040 ret =
str::form (
_(
"%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1042 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1043 s = mapSolvable (source);
1044 s2 = mapSolvable (target);
1045 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1047 case SOLVER_RULE_RPM_SELF_CONFLICT:
1048 s = mapSolvable (source);
1049 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1051 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1053 s = mapSolvable (source);
1054 Capability cap(dep);
1055 sat::WhatProvides possibleProviders(cap);
1058 typedef list<PoolItem> ProviderList;
1059 ProviderList providerlistInstalled, providerlistUninstalled;
1060 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1064 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1067 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1068 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1074 if (provider1.status().isInstalled())
1075 providerlistInstalled.push_back(provider1);
1077 providerlistUninstalled.push_back(provider1);
1081 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1082 if (providerlistInstalled.size() > 0) {
1083 detail +=
_(
"deleted providers: ");
1084 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1085 if (iter == providerlistInstalled.begin())
1091 if (providerlistUninstalled.size() > 0) {
1092 if (detail.size() > 0)
1093 detail +=
_(
"\nnot installable providers: ");
1095 detail =
_(
"not installable providers: ");
1096 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1097 if (iter == providerlistUninstalled.begin())
1110 SATResolver::problems ()
1113 if (_satSolver && solver_problem_count(_satSolver)) {
1117 Id problem, solution, element;
1118 sat::Solvable s, sd;
1120 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1121 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1123 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1126 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1127 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1128 MIL <<
"====================================" << endl;
1131 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1132 MIL << whatString << endl;
1133 MIL <<
"------------------------------------" << endl;
1134 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail);
1137 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1139 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1140 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1141 if (p == SOLVER_SOLUTION_JOB) {
1143 what = _jobQueue.elements[rp];
1144 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1146 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1147 s = mapSolvable (what);
1148 PoolItem poolItem = _pool.find (s);
1150 if (pool->installed && s.get()->repo == pool->installed) {
1151 problemSolution->addSingleAction (poolItem, REMOVE);
1152 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.asString().c_str() );
1153 MIL << description << endl;
1154 problemSolution->addDescription (description);
1156 problemSolution->addSingleAction (poolItem, KEEP);
1157 string description =
str::form (
_(
"do not install %s"), s.asString().c_str());
1158 MIL << description << endl;
1159 problemSolution->addDescription (description);
1162 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1166 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1167 s = mapSolvable (what);
1168 PoolItem poolItem = _pool.find (s);
1170 if (pool->installed && s.get()->repo == pool->installed) {
1171 problemSolution->addSingleAction (poolItem, KEEP);
1172 string description =
str::form (
_(
"keep %s"), s.asString().c_str());
1173 MIL << description << endl;
1174 problemSolution->addDescription (description);
1176 problemSolution->addSingleAction (poolItem, UNLOCK);
1177 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1178 MIL << description << endl;
1179 problemSolution->addDescription (description);
1182 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1186 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1188 IdString ident( what );
1189 SolverQueueItemInstall_Ptr install =
1190 new SolverQueueItemInstall(_pool, ident.asString(), false );
1191 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1193 string description =
str::form (
_(
"do not install %s"), ident.c_str() );
1194 MIL << description << endl;
1195 problemSolution->addDescription (description);
1198 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1202 IdString ident( what );
1203 FindPackage info (problemSolution, KEEP);
1205 _pool.byIdentEnd( ident ),
1207 resfilter::ByTransact ()),
1208 functor::functorRef<bool,PoolItem> (info) );
1210 SolverQueueItemDelete_Ptr del =
1211 new SolverQueueItemDelete(_pool, ident.asString(), false );
1212 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1214 string description =
str::form (
_(
"keep %s"), ident.c_str());
1215 MIL << description << endl;
1216 problemSolution->addDescription (description);
1219 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1221 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1222 string description =
"";
1225 if (system_requires.find(Capability(what)) != system_requires.end()) {
1227 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1228 resolverProblem->setDescription(
_(
"This request will break your system!"));
1229 description =
_(
"ignore the warning of a broken system");
1230 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1231 MIL << description << endl;
1232 problemSolution->addFrontDescription (description);
1234 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1235 MIL << description << endl;
1236 problemSolution->addDescription (description);
1240 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1242 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1243 string description =
"";
1246 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1248 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1249 resolverProblem->setDescription(
_(
"This request will break your system!"));
1250 description =
_(
"ignore the warning of a broken system");
1251 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1252 MIL << description << endl;
1253 problemSolution->addFrontDescription (description);
1256 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1257 MIL << description << endl;
1258 problemSolution->addDescription (description);
1262 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1264 s = mapSolvable (what);
1265 PoolItem poolItem = _pool.find (s);
1267 if (pool->installed && s.get()->repo == pool->installed) {
1268 problemSolution->addSingleAction (poolItem, KEEP);
1269 string description =
str::form (
_(
"do not install most recent version of %s"), s.asString().c_str());
1270 MIL << description << endl;
1271 problemSolution->addDescription (description);
1273 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1276 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1281 MIL <<
"- do something different" << endl;
1282 ERR <<
"No valid solution available" << endl;
1285 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1286 s = mapSolvable (rp);
1287 PoolItem poolItem = _pool.find (s);
1288 if (pool->installed && s.get()->repo == pool->installed) {
1289 problemSolution->addSingleAction (poolItem, LOCK);
1290 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.asString().c_str());
1291 MIL << description << endl;
1292 problemSolution->addDescription (description);
1294 problemSolution->addSingleAction (poolItem, INSTALL);
1295 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.asString().c_str());
1296 MIL << description << endl;
1297 problemSolution->addDescription (description);
1299 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1300 s = mapSolvable (rp);
1301 PoolItem poolItem = _pool.find (s);
1302 if (pool->installed && s.get()->repo == pool->installed) {
1303 problemSolution->addSingleAction (poolItem, LOCK);
1304 string description =
str::form (
_(
"keep obsolete %s"), s.asString().c_str());
1305 MIL << description << endl;
1306 problemSolution->addDescription (description);
1308 problemSolution->addSingleAction (poolItem, INSTALL);
1309 string description =
str::form (
_(
"install %s from excluded repository"), s.asString().c_str());
1310 MIL << description << endl;
1311 problemSolution->addDescription (description);
1315 s = mapSolvable (p);
1316 PoolItem itemFrom = _pool.find (s);
1321 sd = mapSolvable (rp);
1322 PoolItem itemTo = _pool.find (sd);
1323 if (itemFrom && itemTo) {
1324 problemSolution->addSingleAction (itemTo, INSTALL);
1325 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1327 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1329 string description =
str::form (
_(
"downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1330 MIL << description << endl;
1331 problemSolution->addDescription (description);
1334 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1336 string description =
str::form (
_(
"architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1337 MIL << description << endl;
1338 problemSolution->addDescription (description);
1341 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1343 IdString s_vendor( s.vendor() );
1344 IdString sd_vendor( sd.vendor() );
1345 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1346 sd.asString().c_str(),
1347 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1348 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1349 MIL << description << endl;
1350 problemSolution->addDescription (description);
1354 string description =
str::form (
_(
"replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1355 MIL << description << endl;
1356 problemSolution->addDescription (description);
1359 ERR << s.asString() <<
" or " << sd.asString() <<
" not found" << endl;
1365 string description =
str::form (
_(
"deinstallation of %s"), s.asString().c_str());
1366 MIL << description << endl;
1367 problemSolution->addDescription (description);
1368 problemSolution->addSingleAction (itemFrom, REMOVE);
1373 resolverProblem->addSolution (problemSolution,
1374 problemSolution->actionCount() > 1 ? true :
false);
1375 MIL <<
"------------------------------------" << endl;
1380 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1381 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1382 resolverProblem->addSolution (problemSolution,
1384 MIL <<
"ignore some dependencies of " << item << endl;
1385 MIL <<
"------------------------------------" << endl;
1389 resolverProblems.push_back (resolverProblem);
1392 return resolverProblems;
1396 { Resolver( _pool ).applySolutions( solutions ); }
1398 void SATResolver::setLocks()
1403 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1405 if (iter->status().isInstalled()) {
1407 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1408 queue_push( &(_jobQueue), ident );
1411 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1412 queue_push( &(_jobQueue), ident );
1415 MIL <<
"Locked " << icnt <<
" installed items and " << acnt <<
" NOT installed items." << endl;
1421 std::set<IdString> unifiedByName;
1422 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1423 IdString ident( (*iter)->satSolvable().ident() );
1424 if ( unifiedByName.insert( ident ).second )
1428 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1429 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1430 queue_push( &(_jobQueue), ident.id() );
1436 void SATResolver::setSystemRequirements()
1438 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1439 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1441 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1442 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1443 queue_push( &(_jobQueue), iter->id() );
1444 MIL <<
"SYSTEM Requires " << *iter << endl;
1447 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1448 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1449 queue_push( &(_jobQueue), iter->id() );
1450 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1458 IdString rpm(
"rpm" );
1459 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1461 if ( (*it)->isSystem() )
1464 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1465 queue_push( &(_jobQueue), archrule.id() );
1476 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1484 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES );
std::list< ProblemSolution_Ptr > ProblemSolutionList
int IdType
Generic Id type.
A Solvable object within the sat Pool.
IdType id() const
Expert backdoor.
PoolItemList & _items_to_remove
ResKind kind() const
The Solvables ResKind.
static ZConfig & instance()
Singleton ctor.
bool isToBeInstalled() const
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings should be treated as the same vendor.
ProblemSolutionCombi * problemSolution
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
bool operator()(PoolItem p)
ResStatus & status() const
Returns the current status.
static const ResStatus toBeInstalled
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
sat::Solvable buddy() const
Return the buddy we share our status object with.
Access to the sat-pools string space.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
bool sameNVRA(const SolvableType< Derived > &lhs, const Solvable &rhs)
bool resetTransact(TransactByValue causer_r)
Not the same as setTransact( false ).
TraitsType::constPtrType constPtr
std::list< SolverQueueItem_Ptr > SolverQueueItemList
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
static void SATSolutionToPool(PoolItem item, const ResStatus &status, const ResStatus::TransactByValue causer)
bool setToBeUninstalledDueToUpgrade(TransactByValue causer)
static const ResStatus toBeUninstalledDueToUpgrade
std::unary_function< ResObject::constPtr, bool > ResObjectFilterFunctor
void prepare() const
Update housekeeping data if necessary (e.g.
CheckIfUpdate(const sat::Solvable &installed_r)
Repository repository() const
The Repository this Solvable belongs to.
Queue StringQueue
Queue with String ids.
std::list< ResolverProblem_Ptr > ResolverProblemList
static Pool instance()
Singleton ctor.
Commit helper functor distributing PoolItem by status into lists.
bool operator()(const PoolItem &item)
int vendorCheck(sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2)
std::unary_function< PoolItem, bool > PoolItemFilterFunctor
bool HACKENV(const char *var_r, bool default_r)
bool multiversionInstall() const
PoolItemList & _items_to_lock
SATCollectTransact(PoolItemList &items_to_install_r, PoolItemList &items_to_remove_r, PoolItemList &items_to_lock_r, PoolItemList &items_to_keep_r, bool solveSrcPackages_r)
bool isPseudoInstalled(ResKind kind_r)
Those are denoted to be installed, if the solver verifies them as being satisfied.
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
bool operator()(const PoolItem &item_r)
bool setToBeUninstalled(TransactByValue causer)
FindPackage(ProblemSolutionCombi *p, const TransactionKind act)
CollectPseudoInstalled(Queue *queue)
PoolItemList & _items_to_keep
bool compareByNVR(const SolvableType< Derived > &lhs, const Solvable &rhs)
std::unordered_set< Capability > CapabilitySet
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
sat::Solvable mapBuddy(sat::Solvable item_r)
PoolItemList & _items_to_install
std::string alias() const
Short unique string to identify a repo.
PoolItem getPoolItem(Id id_r)
bool isToBeUninstalled() const
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Chain< TACondition, TBCondition > chain(TACondition conda_r, TBCondition condb_r)
Convenience function for creating a Chain from two conditions conda_r and condb_r.
bool setToBeInstalled(TransactByValue causer)
std::ostream & dumpRangeLine(std::ostream &str, TIterator begin, TIterator end)
Print range defined by iterators (single line style).
bool operator()(PoolItem item)
IMPL_PTR_TYPE(SATResolver)
Combining sat::Solvable and ResStatus.
Pathname systemRoot() const
The target root directory.
bool isKind(const ResKind &kind_r) const
static const VendorAttr & instance()
Singleton.
int invokeOnEach(TIterator begin_r, TIterator end_r, TFilter filter_r, TFunction fnc_r)
Iterate through [begin_r,end_r) and invoke fnc_r on each item that passes filter_r.
std::string itemToString(const PoolItem &item)
Easy-to use interface to the ZYPP dependency resolver.
Solvable satSolvable() const
Return the corresponding sat::Solvable.
static const ResStatus toBeUninstalled
bool isToBeUninstalledDueToUpgrade() const
static ResPool instance()
Singleton ctor.