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 55 #define XDEBUG(x) do { if (base::logger::isExcessive()) XXX << x << std::endl;} while (0) 57 #undef ZYPP_BASE_LOGGER_LOGGROUP 58 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::solver" 79 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
80 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
83 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 1 );
84 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
87 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
88 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 1 );
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( YUM_OBSOLETES );
167 os <<
" focus = " << _focus << endl;
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;
186 , _focus ( ZConfig::instance().solver_focus() )
188 , _allowdowngrade ( false )
189 , _allownamechange ( true )
190 , _allowarchchange ( false )
192 , _allowuninstall ( false )
193 , _updatesystem(false)
194 , _noupdateprovide ( false )
195 , _dosplitprovides ( true )
196 , _onlyRequires (ZConfig::instance().solver_onlyRequires())
197 , _ignorealreadyrecommended(true)
198 , _distupgrade(false)
199 , _distupgrade_removeunsupported(false)
204 , _solveSrcPackages(false)
205 , _cleandepsOnRemove(ZConfig::instance().solver_cleandepsOnRemove())
210 SATResolver::~SATResolver()
218 SATResolver::pool (
void)
const 240 XDEBUG(
"SATSolutionToPool install returns " << item <<
", " << r);
244 XDEBUG(
"SATSolutionToPool upgrade returns " << item <<
", " << r);
248 XDEBUG(
"SATSolutionToPool remove returns " << item <<
", " << r);
269 PoolItemList & items_to_remove_r,
270 PoolItemList & items_to_lock_r,
271 PoolItemList & items_to_keep_r,
272 bool solveSrcPackages_r )
273 : _items_to_install( items_to_install_r )
274 , _items_to_remove( items_to_remove_r )
275 , _items_to_lock( items_to_lock_r )
276 , _items_to_keep( items_to_keep_r )
277 , _solveSrcPackages( solveSrcPackages_r )
279 _items_to_install.clear();
280 _items_to_remove.clear();
281 _items_to_lock.clear();
282 _items_to_keep.clear();
289 bool by_solver = ( itemStatus.isBySolver() || itemStatus.isByApplLow() );
304 switch ( itemStatus.getTransactValue() )
307 itemStatus.isUninstalled() ? _items_to_install.push_back( item_r )
308 : _items_to_remove.push_back( item_r );
break;
340 : is_updated( false )
341 , _installed( installed_r )
367 :solvableQueue (queue)
383 _satSolver = solver_create( _satPool );
384 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
386 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
387 queue_push( &(_jobQueue), 0 );
390 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
391 queue_push( &(_jobQueue), 0 );
394 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
395 queue_push( &(_jobQueue), 0 );
397 if (_distupgrade_removeunsupported) {
398 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
399 queue_push( &(_jobQueue), 0 );
401 solverSetFocus( *_satSolver, _focus );
402 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
403 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
404 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
405 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
407 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
408 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
409 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
410 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED,
false);
411 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires);
420 MIL <<
"Starting solving...." << endl;
422 if ( solver_solve( _satSolver, &(_jobQueue) ) == 0 )
429 if ( _distupgrade_removeunsupported )
430 MIL <<
"Droplist processing not needed. RemoveUnsupported is On." << endl;
432 MIL <<
"Droplist processing is disabled in ZConfig." << endl;
435 bool resolve =
false;
436 MIL <<
"Checking droplists ..." << endl;
439 solver_get_decisionqueue( _satSolver, decisionq );
444 sat::Solvable slv {
id };
446 static const Capability productCap {
"product()" };
447 if ( slv && slv.provides().matches( productCap ) )
449 CapabilitySet droplist { slv.valuesOfNamespace(
"weakremover" ) };
450 MIL <<
"Droplist for " << slv <<
": size " << droplist.size() << endl;
451 if ( !droplist.empty() )
453 for (
const auto & cap : droplist )
455 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
456 queue_push( &_jobQueue, cap.id() );
459 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
460 queue_push( &(_jobQueue),
id );
466 solver_solve( _satSolver, &(_jobQueue) );
470 MIL <<
"....Solver end" << endl;
474 _result_items_to_install.clear();
475 _result_items_to_remove.clear();
479 queue_init(&decisionq);
480 solver_get_decisionqueue(_satSolver, &decisionq);
481 for (
int i = 0; i < decisionq.count; ++i )
483 Id p = decisionq.elements[i];
487 sat::Solvable slv { p };
488 if ( ! slv || slv.isSystem() )
491 PoolItem poolItem( slv );
493 _result_items_to_install.push_back( poolItem );
495 queue_free(&decisionq);
499 if ( systemRepo && ! systemRepo.solvablesEmpty() )
501 bool mustCheckObsoletes =
false;
502 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
504 if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
508 CheckIfUpdate info( *it );
509 PoolItem poolItem( *it );
511 _pool.byIdentEnd( poolItem ),
512 resfilter::ByUninstalled(),
513 functor::functorRef<bool,PoolItem> (info) );
515 if (info.is_updated) {
519 if ( ! mustCheckObsoletes )
520 mustCheckObsoletes =
true;
522 _result_items_to_remove.push_back (poolItem);
524 if ( mustCheckObsoletes )
526 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
527 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
529 ResStatus & status( it->status() );
531 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
532 status.setToBeUninstalledDueToObsolete();
537 Queue recommendations;
541 queue_init(&recommendations);
542 queue_init(&suggestions);
543 queue_init(&orphaned);
544 queue_init(&unneeded);
545 solver_get_recommendations(_satSolver, &recommendations, &suggestions, 0);
546 solver_get_orphaned(_satSolver, &orphaned);
547 solver_get_unneeded(_satSolver, &unneeded, 1);
549 for (
int i = 0; i < recommendations.count; ++i )
551 PoolItem poolItem(
getPoolItem( recommendations.elements[i] ) );
552 poolItem.status().setRecommended(
true );
556 for (
int i = 0; i < suggestions.count; ++i )
558 PoolItem poolItem(
getPoolItem( suggestions.elements[i] ) );
559 poolItem.status().setSuggested(
true );
562 _problem_items.clear();
564 for (
int i = 0; i < orphaned.count; ++i )
566 PoolItem poolItem(
getPoolItem( orphaned.elements[i] ) );
567 poolItem.status().setOrphaned(
true );
568 _problem_items.push_back( poolItem );
572 for (
int i = 0; i < unneeded.count; ++i )
574 PoolItem poolItem(
getPoolItem( unneeded.elements[i] ) );
575 poolItem.status().setUnneeded(
true );
578 queue_free(&recommendations);
579 queue_free(&suggestions);
580 queue_free(&orphaned);
581 queue_free(&unneeded);
584 Queue flags, solvableQueue;
587 queue_init(&solvableQueue);
589 CollectPseudoInstalled collectPseudoInstalled(&solvableQueue);
592 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
593 solver_trivial_installable(_satSolver, &solvableQueue, &flags );
594 for (
int i = 0; i < solvableQueue.count; i++) {
595 PoolItem item = _pool.find (sat::Solvable(solvableQueue.elements[i]));
596 item.status().setUndetermined();
598 if (flags.elements[i] == -1) {
599 item.status().setNonRelevant();
600 XDEBUG(
"SATSolutionToPool(" << item <<
" ) nonRelevant !");
601 }
else if (flags.elements[i] == 1) {
602 item.status().setSatisfied();
603 XDEBUG(
"SATSolutionToPool(" << item <<
" ) satisfied !");
604 }
else if (flags.elements[i] == 0) {
605 item.status().setBroken();
606 XDEBUG(
"SATSolutionToPool(" << item <<
" ) broken !");
609 queue_free(&(solvableQueue));
616 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
617 sat::WhatProvides rpmProviders(*iter);
618 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
619 PoolItem poolItem(*iter2);
620 if (poolItem.status().isToBeInstalled()) {
621 MIL <<
"User requirement " << *iter <<
" sets " << poolItem << endl;
626 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
627 sat::WhatProvides rpmProviders(*iter);
628 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
629 PoolItem poolItem(*iter2);
630 if (poolItem.status().isToBeUninstalled()) {
631 MIL <<
"User conflict " << *iter <<
" sets " << poolItem << endl;
637 if (solver_problem_count(_satSolver) > 0 )
639 ERR <<
"Solverrun finished with an ERROR" << endl;
648 SATResolver::solverInit(
const PoolItemList & weakItems)
651 MIL <<
"SATResolver::solverInit()" << endl;
655 queue_init( &_jobQueue );
659 SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
660 invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
663 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
664 Id
id = (*iter)->satSolvable().id();
666 ERR <<
"Weaken: " << *iter <<
" not found" << endl;
668 MIL <<
"Weaken dependencies of " << *iter << endl;
669 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
670 queue_push( &(_jobQueue),
id );
675 queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
677 queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
683 const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
686 for (
const auto & locale : trackedLocaleIds.added() )
688 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
692 for (
const auto & locale : trackedLocaleIds.removed() )
694 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS );
700 for (
const sat::Solvable & solv : myPool().multiversionList() )
702 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
703 queue_push( &(_jobQueue), solv.id() );
706 ::pool_add_userinstalled_jobs(_satPool,
sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
710 SATResolver::solverEnd()
715 solver_free(_satSolver);
717 queue_free( &(_jobQueue) );
723 SATResolver::resolvePool(
const CapabilitySet & requires_caps,
725 const PoolItemList & weakItems,
726 const std::set<Repository> & upgradeRepos)
728 MIL <<
"SATResolver::resolvePool()" << endl;
731 solverInit(weakItems);
733 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
734 Id
id = (*iter)->satSolvable().id();
736 ERR <<
"Install: " << *iter <<
" not found" << endl;
738 MIL <<
"Install " << *iter << endl;
739 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
740 queue_push( &(_jobQueue),
id );
744 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
745 Id
id = (*iter)->satSolvable().id();
747 ERR <<
"Delete: " << *iter <<
" not found" << endl;
749 MIL <<
"Delete " << *iter << endl;
750 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
751 queue_push( &(_jobQueue),
id);
755 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
757 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
758 queue_push( &(_jobQueue), iter->get()->repoid );
759 MIL <<
"Upgrade repo " << *iter << endl;
762 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
763 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
764 queue_push( &(_jobQueue), iter->id() );
765 MIL <<
"Requires " << *iter << endl;
768 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
769 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
770 queue_push( &(_jobQueue), iter->id() );
771 MIL <<
"Conflicts " << *iter << endl;
775 setSystemRequirements();
781 bool ret = solving(requires_caps, conflict_caps);
783 (ret?
MIL:
WAR) <<
"SATResolver::resolvePool() done. Ret:" << ret << endl;
790 const PoolItemList & weakItems)
792 MIL <<
"SATResolver::resolvQueue()" << endl;
795 solverInit(weakItems);
798 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
799 (*iter)->addRule(_jobQueue);
803 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
804 Id
id = (*iter)->satSolvable().id();
806 ERR <<
"Install: " << *iter <<
" not found" << endl;
808 MIL <<
"Install " << *iter << endl;
809 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
810 queue_push( &(_jobQueue),
id );
813 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
815 MIL <<
"Delete " << *iter << ident << endl;
816 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME |
MAYBE_CLEANDEPS );
817 queue_push( &(_jobQueue), ident);
821 setSystemRequirements();
827 bool ret = solving();
829 MIL <<
"SATResolver::resolveQueue() done. Ret:" << ret << endl;
834 void SATResolver::doUpdate()
836 MIL <<
"SATResolver::doUpdate()" << endl;
839 solverInit(PoolItemList());
842 setSystemRequirements();
847 _satSolver = solver_create( _satPool );
848 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
850 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
851 queue_push( &(_jobQueue), 0 );
854 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
855 queue_push( &(_jobQueue), 0 );
858 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
859 queue_push( &(_jobQueue), 0 );
861 if (_distupgrade_removeunsupported) {
862 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
863 queue_push( &(_jobQueue), 0 );
865 solverSetFocus( *_satSolver, _focus );
866 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
867 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
868 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
869 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
871 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
872 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
873 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
874 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED,
false);
875 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires);
880 MIL <<
"Starting solving for update...." << endl;
882 solver_solve( _satSolver, &(_jobQueue) );
883 MIL <<
"....Solver end" << endl;
890 queue_init(&decisionq);
891 solver_get_decisionqueue(_satSolver, &decisionq);
892 for (
int i = 0; i < decisionq.count; i++)
894 Id p = decisionq.elements[i];
898 sat::Solvable solv { p };
899 if ( ! solv || solv.isSystem() )
904 queue_free(&decisionq);
907 for (
int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
909 if (solver_get_decisionlevel(_satSolver, i) > 0)
912 PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
915 CheckIfUpdate info( (sat::Solvable(i)) );
917 _pool.byIdentEnd( poolItem ),
918 resfilter::ByUninstalled(),
919 functor::functorRef<bool,PoolItem> (info) );
921 if (info.is_updated) {
927 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
930 MIL <<
"SATResolver::doUpdate() done" << endl;
950 : problemSolution (p)
957 problemSolution->addSingleAction (p, action);
990 std::vector<std::string> SATResolver::SATgetCompleteProblemInfoStrings ( Id problem )
992 std::vector<std::string> ret;
994 solver_findallproblemrules( _satSolver, problem, problems );
1000 SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1001 if ( ruleClass != SolverRuleinfo::SOLVER_RULE_UPDATE && ruleClass != SolverRuleinfo::SOLVER_RULE_JOB ) {
1007 SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1008 if ( nobad && ( ruleClass == SolverRuleinfo::SOLVER_RULE_UPDATE || ruleClass == SolverRuleinfo::SOLVER_RULE_JOB ) ) {
1014 std::string pInfo = SATproblemRuleInfoString( problems[i], detail, ignore );
1017 if ( std::find( ret.begin(), ret.end(), pInfo ) == ret.end() )
1018 ret.push_back( pInfo );
1023 string SATResolver::SATprobleminfoString(Id problem,
string &detail, Id &ignoreId)
1027 Id probr = solver_findproblemrule(_satSolver, problem);
1028 return SATproblemRuleInfoString( probr, detail, ignoreId );
1031 std::string SATResolver::SATproblemRuleInfoString (Id probr, std::string &detail, Id &ignoreId)
1035 Id dep, source, target;
1036 SolverRuleinfo type = solver_ruleinfo(_satSolver, probr, &source, &target, &dep);
1040 sat::Solvable s = mapSolvable( source );
1041 sat::Solvable s2 = mapSolvable( target );
1048 case SOLVER_RULE_DISTUPGRADE:
1049 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.asString().c_str());
1051 case SOLVER_RULE_INFARCH:
1052 ret =
str::form (
_(
"%s has inferior architecture"), s.asString().c_str());
1054 case SOLVER_RULE_UPDATE:
1055 ret =
str::form (
_(
"problem with installed package %s"), s.asString().c_str());
1057 case SOLVER_RULE_JOB:
1058 ret =
_(
"conflicting requests");
1060 case SOLVER_RULE_PKG:
1061 ret =
_(
"some dependency problem");
1063 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1064 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
1065 detail +=
_(
"Have you enabled all requested repositories?");
1067 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1068 ret =
str::form (
_(
"package %s does not exist"), pool_dep2str(pool, dep));
1069 detail +=
_(
"Have you enabled all requested repositories?");
1071 case SOLVER_RULE_JOB_UNSUPPORTED:
1072 ret =
_(
"unsupported request");
1074 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1075 ret =
str::form (
_(
"%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1077 case SOLVER_RULE_PKG_NOT_INSTALLABLE:
1078 ret =
str::form (
_(
"%s is not installable"), s.asString().c_str());
1080 case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
1082 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1084 case SOLVER_RULE_PKG_SAME_NAME:
1085 ret =
str::form (
_(
"cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1087 case SOLVER_RULE_PKG_CONFLICTS:
1088 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1090 case SOLVER_RULE_PKG_OBSOLETES:
1091 ret =
str::form (
_(
"%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1093 case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
1094 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1096 case SOLVER_RULE_PKG_SELF_CONFLICT:
1097 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1099 case SOLVER_RULE_PKG_REQUIRES: {
1101 Capability cap(dep);
1102 sat::WhatProvides possibleProviders(cap);
1105 typedef list<PoolItem> ProviderList;
1106 ProviderList providerlistInstalled, providerlistUninstalled;
1107 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1111 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1114 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1115 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1121 if (provider1.status().isInstalled())
1122 providerlistInstalled.push_back(provider1);
1124 providerlistUninstalled.push_back(provider1);
1128 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1129 if (providerlistInstalled.size() > 0) {
1130 detail +=
_(
"deleted providers: ");
1131 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1132 if (iter == providerlistInstalled.begin())
1138 if (providerlistUninstalled.size() > 0) {
1139 if (detail.size() > 0)
1140 detail +=
_(
"\nnot installable providers: ");
1142 detail =
_(
"not installable providers: ");
1143 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1144 if (iter == providerlistUninstalled.begin())
1153 DBG <<
"Unknown rule type(" << type <<
") going to query libsolv for rule information." << endl;
1154 ret =
str::asString( ::solver_problemruleinfo2str( _satSolver, type, static_cast<Id>(s.id()), static_cast<Id>(s2.id()), dep ) );
1162 SATResolver::problems ()
1165 if (_satSolver && solver_problem_count(_satSolver)) {
1169 Id problem, solution, element;
1170 sat::Solvable s, sd;
1172 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1173 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1175 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1178 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1179 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1180 MIL <<
"====================================" << endl;
1183 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1184 MIL << whatString << endl;
1185 MIL <<
"------------------------------------" << endl;
1186 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail, SATgetCompleteProblemInfoStrings( problem ));
1189 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1191 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1192 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1193 if (p == SOLVER_SOLUTION_JOB) {
1195 what = _jobQueue.elements[rp];
1196 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1198 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1199 s = mapSolvable (what);
1200 PoolItem poolItem = _pool.find (s);
1202 if (pool->installed && s.get()->repo == pool->installed) {
1203 problemSolution->addSingleAction (poolItem, REMOVE);
1204 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.asString().c_str() );
1205 MIL << description << endl;
1206 problemSolution->addDescription (description);
1208 problemSolution->addSingleAction (poolItem, KEEP);
1209 string description =
str::form (
_(
"do not install %s"), s.asString().c_str());
1210 MIL << description << endl;
1211 problemSolution->addDescription (description);
1214 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1218 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1219 s = mapSolvable (what);
1220 PoolItem poolItem = _pool.find (s);
1222 if (pool->installed && s.get()->repo == pool->installed) {
1223 problemSolution->addSingleAction (poolItem, KEEP);
1224 string description =
str::form (
_(
"keep %s"), s.asString().c_str());
1225 MIL << description << endl;
1226 problemSolution->addDescription (description);
1228 problemSolution->addSingleAction (poolItem, UNLOCK);
1229 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1230 MIL << description << endl;
1231 problemSolution->addDescription (description);
1234 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1238 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1241 SolverQueueItemInstall_Ptr install =
1242 new SolverQueueItemInstall(_pool, ident.asString(), false );
1243 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1245 string description =
str::form (
_(
"do not install %s"), ident.c_str() );
1246 MIL << description << endl;
1247 problemSolution->addDescription (description);
1250 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1255 FindPackage info (problemSolution, KEEP);
1257 _pool.byIdentEnd( ident ),
1259 resfilter::ByTransact ()),
1260 functor::functorRef<bool,PoolItem> (info) );
1262 SolverQueueItemDelete_Ptr del =
1263 new SolverQueueItemDelete(_pool, ident.asString(), false );
1264 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1266 string description =
str::form (
_(
"keep %s"), ident.c_str());
1267 MIL << description << endl;
1268 problemSolution->addDescription (description);
1271 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1273 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1274 string description =
"";
1277 if (system_requires.find(Capability(what)) != system_requires.end()) {
1279 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1280 resolverProblem->setDescription(
_(
"This request will break your system!"));
1281 description =
_(
"ignore the warning of a broken system");
1282 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1283 MIL << description << endl;
1284 problemSolution->addFrontDescription (description);
1286 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1287 MIL << description << endl;
1288 problemSolution->addDescription (description);
1292 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1294 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1295 string description =
"";
1298 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1300 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1301 resolverProblem->setDescription(
_(
"This request will break your system!"));
1302 description =
_(
"ignore the warning of a broken system");
1303 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1304 MIL << description << endl;
1305 problemSolution->addFrontDescription (description);
1308 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1309 MIL << description << endl;
1310 problemSolution->addDescription (description);
1314 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1316 s = mapSolvable (what);
1317 PoolItem poolItem = _pool.find (s);
1319 if (pool->installed && s.get()->repo == pool->installed) {
1320 problemSolution->addSingleAction (poolItem, KEEP);
1321 string description =
str::form (
_(
"do not install most recent version of %s"), s.asString().c_str());
1322 MIL << description << endl;
1323 problemSolution->addDescription (description);
1325 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1328 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1333 MIL <<
"- do something different" << endl;
1334 ERR <<
"No valid solution available" << endl;
1337 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1338 s = mapSolvable (rp);
1339 PoolItem poolItem = _pool.find (s);
1340 if (pool->installed && s.get()->repo == pool->installed) {
1341 problemSolution->addSingleAction (poolItem, LOCK);
1342 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.asString().c_str());
1343 MIL << description << endl;
1344 problemSolution->addDescription (description);
1346 problemSolution->addSingleAction (poolItem, INSTALL);
1347 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.asString().c_str());
1348 MIL << description << endl;
1349 problemSolution->addDescription (description);
1351 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1352 s = mapSolvable (rp);
1353 PoolItem poolItem = _pool.find (s);
1354 if (pool->installed && s.get()->repo == pool->installed) {
1355 problemSolution->addSingleAction (poolItem, LOCK);
1356 string description =
str::form (
_(
"keep obsolete %s"), s.asString().c_str());
1357 MIL << description << endl;
1358 problemSolution->addDescription (description);
1360 problemSolution->addSingleAction (poolItem, INSTALL);
1361 string description =
str::form (
_(
"install %s from excluded repository"), s.asString().c_str());
1362 MIL << description << endl;
1363 problemSolution->addDescription (description);
1365 }
else if ( p == SOLVER_SOLUTION_BLACK ) {
1368 s = mapSolvable (rp);
1369 PoolItem poolItem = _pool.find (s);
1371 problemSolution->addSingleAction (poolItem, INSTALL);
1373 if ( s.isRetracted() ) {
1375 description = str::Format(
_(
"install %1% although it has been retracted")) % s.asString();
1376 }
else if ( s.isPtf() ) {
1378 description = str::Format(
_(
"allow to install the PTF %1%")) % s.asString();
1381 description = str::Format(
_(
"install %1% although it is blacklisted")) % s.asString();
1383 MIL << description << endl;
1384 problemSolution->addDescription( description );
1385 }
else if ( p > 0 ) {
1387 s = mapSolvable (p);
1388 PoolItem itemFrom = _pool.find (s);
1393 sd = mapSolvable (rp);
1394 PoolItem itemTo = _pool.find (sd);
1395 if (itemFrom && itemTo) {
1396 problemSolution->addSingleAction (itemTo, INSTALL);
1397 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1399 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1401 string description =
str::form (
_(
"downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1402 MIL << description << endl;
1403 problemSolution->addDescription (description);
1406 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1408 string description =
str::form (
_(
"architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1409 MIL << description << endl;
1410 problemSolution->addDescription (description);
1413 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1417 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1418 sd.asString().c_str(),
1419 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1420 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1421 MIL << description << endl;
1422 problemSolution->addDescription (description);
1426 string description =
str::form (
_(
"replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1427 MIL << description << endl;
1428 problemSolution->addDescription (description);
1431 ERR << s.asString() <<
" or " << sd.asString() <<
" not found" << endl;
1437 string description =
str::form (
_(
"deinstallation of %s"), s.asString().c_str());
1438 MIL << description << endl;
1439 problemSolution->addDescription (description);
1440 problemSolution->addSingleAction (itemFrom, REMOVE);
1446 INT <<
"Unknown solution " << p << endl;
1450 resolverProblem->addSolution (problemSolution,
1451 problemSolution->actionCount() > 1 ? true :
false);
1452 MIL <<
"------------------------------------" << endl;
1457 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1458 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1459 resolverProblem->addSolution (problemSolution,
1461 MIL <<
"ignore some dependencies of " << item << endl;
1462 MIL <<
"------------------------------------" << endl;
1466 resolverProblems.push_back (resolverProblem);
1469 return resolverProblems;
1473 { Resolver( _pool ).applySolutions( solutions ); }
1475 void SATResolver::setLocks()
1480 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1482 if (iter->status().isInstalled()) {
1484 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1485 queue_push( &(_jobQueue), ident );
1488 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1489 queue_push( &(_jobQueue), ident );
1492 MIL <<
"Locked " << icnt <<
" installed items and " << acnt <<
" NOT installed items." << endl;
1498 std::set<IdString> unifiedByName;
1499 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1500 IdString ident( (*iter)->satSolvable().ident() );
1501 if ( unifiedByName.insert( ident ).second )
1505 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1506 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1507 queue_push( &(_jobQueue), ident.id() );
1513 void SATResolver::setSystemRequirements()
1515 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1516 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1518 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1519 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1520 queue_push( &(_jobQueue), iter->id() );
1521 MIL <<
"SYSTEM Requires " << *iter << endl;
1524 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1525 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1526 queue_push( &(_jobQueue), iter->id() );
1527 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1536 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1538 if ( (*it)->isSystem() )
1541 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1542 queue_push( &(_jobQueue), archrule.id() );
1553 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1561 ::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
Focus on updating requested packages and their dependencies as much as possible.
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.
static const IdString ptfToken
Indicator provides ptf()
ProblemSolutionCombi * problemSolution
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
ResolverFocus
The resolvers general attitude.
bool operator()(PoolItem p)
Queue SolvableQueue
Queue with Solvable ids.
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.
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
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)
Request the standard behavior (as defined in zypp.conf or 'Job')
bool resetTransact(TransactByValue causer_r)
Not the same as setTransact( false ).
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
Focus on applying as little changes to the installed packages as needed.
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)
::s_Solver CSolver
Wrapped libsolv C data type exposed as backdoor.
bool isToBeUninstalled() const
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)
bool operator()(PoolItem item)
IMPL_PTR_TYPE(SATResolver)
Combining sat::Solvable and ResStatus.
Pathname systemRoot() const
The target root directory.
static const IdString retractedToken
Indicator provides retracted-patch-package()
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.
Focus on installing the best version of the requested packages.
static const ResStatus toBeUninstalled
bool isToBeUninstalledDueToUpgrade() const
static ResPool instance()
Singleton ctor.