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 );
442 sat::Solvable slv { slvid };
444 static const Capability productCap {
"product()" };
445 if ( slv && slv.provides().matches( productCap ) )
447 CapabilitySet droplist { slv.valuesOfNamespace(
"weakremover" ) };
448 MIL <<
"Droplist for " << slv <<
": size " << droplist.size() << endl;
449 if ( !droplist.empty() )
451 for (
const auto & cap : droplist )
453 INT <<
" => " << cap << endl;
454 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
455 queue_push( &_jobQueue, cap.id() );
458 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
459 queue_push( &(_jobQueue), slvid );
465 solver_solve( _satSolver, &(_jobQueue) );
469 MIL <<
"....Solver end" << endl;
473 _result_items_to_install.clear();
474 _result_items_to_remove.clear();
478 queue_init(&decisionq);
479 solver_get_decisionqueue(_satSolver, &decisionq);
480 for (
int i = 0; i < decisionq.count; ++i )
482 sat::Solvable slv( decisionq.elements[i] );
483 if ( !slv || slv.isSystem() )
486 PoolItem poolItem( slv );
488 _result_items_to_install.push_back( poolItem );
490 queue_free(&decisionq);
494 if ( systemRepo && ! systemRepo.solvablesEmpty() )
496 bool mustCheckObsoletes =
false;
497 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
499 if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
503 CheckIfUpdate info( *it );
504 PoolItem poolItem( *it );
506 _pool.byIdentEnd( poolItem ),
507 resfilter::ByUninstalled(),
508 functor::functorRef<bool,PoolItem> (info) );
510 if (info.is_updated) {
514 if ( ! mustCheckObsoletes )
515 mustCheckObsoletes =
true;
517 _result_items_to_remove.push_back (poolItem);
519 if ( mustCheckObsoletes )
521 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
522 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
524 ResStatus & status( it->status() );
526 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
527 status.setToBeUninstalledDueToObsolete();
532 Queue recommendations;
536 queue_init(&recommendations);
537 queue_init(&suggestions);
538 queue_init(&orphaned);
539 queue_init(&unneeded);
540 solver_get_recommendations(_satSolver, &recommendations, &suggestions, 0);
541 solver_get_orphaned(_satSolver, &orphaned);
542 solver_get_unneeded(_satSolver, &unneeded, 1);
544 for (
int i = 0; i < recommendations.count; ++i )
546 PoolItem poolItem(
getPoolItem( recommendations.elements[i] ) );
547 poolItem.status().setRecommended(
true );
551 for (
int i = 0; i < suggestions.count; ++i )
553 PoolItem poolItem(
getPoolItem( suggestions.elements[i] ) );
554 poolItem.status().setSuggested(
true );
557 _problem_items.clear();
559 for (
int i = 0; i < orphaned.count; ++i )
561 PoolItem poolItem(
getPoolItem( orphaned.elements[i] ) );
562 poolItem.status().setOrphaned(
true );
563 _problem_items.push_back( poolItem );
567 for (
int i = 0; i < unneeded.count; ++i )
569 PoolItem poolItem(
getPoolItem( unneeded.elements[i] ) );
570 poolItem.status().setUnneeded(
true );
573 queue_free(&recommendations);
574 queue_free(&suggestions);
575 queue_free(&orphaned);
576 queue_free(&unneeded);
579 Queue flags, solvableQueue;
582 queue_init(&solvableQueue);
584 CollectPseudoInstalled collectPseudoInstalled(&solvableQueue);
587 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
588 solver_trivial_installable(_satSolver, &solvableQueue, &flags );
589 for (
int i = 0; i < solvableQueue.count; i++) {
590 PoolItem item = _pool.find (sat::Solvable(solvableQueue.elements[i]));
591 item.status().setUndetermined();
593 if (flags.elements[i] == -1) {
594 item.status().setNonRelevant();
595 XDEBUG(
"SATSolutionToPool(" << item <<
" ) nonRelevant !");
596 }
else if (flags.elements[i] == 1) {
597 item.status().setSatisfied();
598 XDEBUG(
"SATSolutionToPool(" << item <<
" ) satisfied !");
599 }
else if (flags.elements[i] == 0) {
600 item.status().setBroken();
601 XDEBUG(
"SATSolutionToPool(" << item <<
" ) broken !");
604 queue_free(&(solvableQueue));
611 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
612 sat::WhatProvides rpmProviders(*iter);
613 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
614 PoolItem poolItem(*iter2);
615 if (poolItem.status().isToBeInstalled()) {
616 MIL <<
"User requirement " << *iter <<
" sets " << poolItem << endl;
621 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
622 sat::WhatProvides rpmProviders(*iter);
623 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
624 PoolItem poolItem(*iter2);
625 if (poolItem.status().isToBeUninstalled()) {
626 MIL <<
"User conflict " << *iter <<
" sets " << poolItem << endl;
632 if (solver_problem_count(_satSolver) > 0 )
634 ERR <<
"Solverrun finished with an ERROR" << endl;
643 SATResolver::solverInit(
const PoolItemList & weakItems)
646 MIL <<
"SATResolver::solverInit()" << endl;
650 queue_init( &_jobQueue );
654 SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
655 invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
658 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
659 Id
id = (*iter)->satSolvable().id();
661 ERR <<
"Weaken: " << *iter <<
" not found" << endl;
663 MIL <<
"Weaken dependencies of " << *iter << endl;
664 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
665 queue_push( &(_jobQueue),
id );
670 queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
672 queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
678 const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
681 for (
const auto & locale : trackedLocaleIds.added() )
683 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
687 for (
const auto & locale : trackedLocaleIds.removed() )
689 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS );
695 for (
const sat::Solvable & solv : myPool().multiversionList() )
697 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
698 queue_push( &(_jobQueue), solv.id() );
701 ::pool_add_userinstalled_jobs(_satPool,
sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
705 SATResolver::solverEnd()
710 solver_free(_satSolver);
712 queue_free( &(_jobQueue) );
718 SATResolver::resolvePool(
const CapabilitySet & requires_caps,
720 const PoolItemList & weakItems,
721 const std::set<Repository> & upgradeRepos)
723 MIL <<
"SATResolver::resolvePool()" << endl;
726 solverInit(weakItems);
728 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
729 Id
id = (*iter)->satSolvable().id();
731 ERR <<
"Install: " << *iter <<
" not found" << endl;
733 MIL <<
"Install " << *iter << endl;
734 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
735 queue_push( &(_jobQueue),
id );
739 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
740 Id
id = (*iter)->satSolvable().id();
742 ERR <<
"Delete: " << *iter <<
" not found" << endl;
744 MIL <<
"Delete " << *iter << endl;
745 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
746 queue_push( &(_jobQueue),
id);
750 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
752 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
753 queue_push( &(_jobQueue), iter->get()->repoid );
754 MIL <<
"Upgrade repo " << *iter << endl;
757 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
758 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
759 queue_push( &(_jobQueue), iter->id() );
760 MIL <<
"Requires " << *iter << endl;
763 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
764 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
765 queue_push( &(_jobQueue), iter->id() );
766 MIL <<
"Conflicts " << *iter << endl;
770 setSystemRequirements();
776 bool ret = solving(requires_caps, conflict_caps);
778 (ret?
MIL:
WAR) <<
"SATResolver::resolvePool() done. Ret:" << ret << endl;
785 const PoolItemList & weakItems)
787 MIL <<
"SATResolver::resolvQueue()" << endl;
790 solverInit(weakItems);
793 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
794 (*iter)->addRule(_jobQueue);
798 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
799 Id
id = (*iter)->satSolvable().id();
801 ERR <<
"Install: " << *iter <<
" not found" << endl;
803 MIL <<
"Install " << *iter << endl;
804 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
805 queue_push( &(_jobQueue),
id );
808 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
810 MIL <<
"Delete " << *iter << ident << endl;
811 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME |
MAYBE_CLEANDEPS );
812 queue_push( &(_jobQueue), ident);
816 setSystemRequirements();
822 bool ret = solving();
824 MIL <<
"SATResolver::resolveQueue() done. Ret:" << ret << endl;
829 void SATResolver::doUpdate()
831 MIL <<
"SATResolver::doUpdate()" << endl;
834 solverInit(PoolItemList());
837 setSystemRequirements();
842 _satSolver = solver_create( _satPool );
843 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
845 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
846 queue_push( &(_jobQueue), 0 );
849 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
850 queue_push( &(_jobQueue), 0 );
853 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
854 queue_push( &(_jobQueue), 0 );
856 if (_distupgrade_removeunsupported) {
857 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
858 queue_push( &(_jobQueue), 0 );
860 solverSetFocus( *_satSolver, _focus );
861 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
862 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
863 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
864 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
866 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
867 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
868 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
869 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED,
false);
870 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires);
875 MIL <<
"Starting solving for update...." << endl;
877 solver_solve( _satSolver, &(_jobQueue) );
878 MIL <<
"....Solver end" << endl;
885 queue_init(&decisionq);
886 solver_get_decisionqueue(_satSolver, &decisionq);
887 for (
int i = 0; i < decisionq.count; i++)
890 p = decisionq.elements[i];
891 if (p < 0 || !sat::Solvable(p))
893 if (sat::Solvable(p).repository().
get() == _satSolver->pool->installed)
896 PoolItem poolItem = _pool.find (sat::Solvable(p));
900 ERR <<
"id " << p <<
" not found in ZYPP pool." << endl;
903 queue_free(&decisionq);
906 for (
int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
908 if (solver_get_decisionlevel(_satSolver, i) > 0)
911 PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
914 CheckIfUpdate info( (sat::Solvable(i)) );
916 _pool.byIdentEnd( poolItem ),
917 resfilter::ByUninstalled(),
918 functor::functorRef<bool,PoolItem> (info) );
920 if (info.is_updated) {
926 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
929 MIL <<
"SATResolver::doUpdate() done" << endl;
949 : problemSolution (p)
956 problemSolution->addSingleAction (p, action);
989 std::vector<std::string> SATResolver::SATgetCompleteProblemInfoStrings ( Id problem )
991 std::vector<std::string> ret;
993 solver_findallproblemrules( _satSolver, problem, problems );
999 SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1000 if ( ruleClass != SolverRuleinfo::SOLVER_RULE_UPDATE && ruleClass != SolverRuleinfo::SOLVER_RULE_JOB ) {
1006 SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1007 if ( nobad && ( ruleClass == SolverRuleinfo::SOLVER_RULE_UPDATE || ruleClass == SolverRuleinfo::SOLVER_RULE_JOB ) ) {
1013 std::string pInfo = SATproblemRuleInfoString( problems[i], detail, ignore );
1016 if ( std::find( ret.begin(), ret.end(), pInfo ) == ret.end() )
1017 ret.push_back( pInfo );
1022 string SATResolver::SATprobleminfoString(Id problem,
string &detail, Id &ignoreId)
1026 Id probr = solver_findproblemrule(_satSolver, problem);
1027 return SATproblemRuleInfoString( probr, detail, ignoreId );
1030 std::string SATResolver::SATproblemRuleInfoString (Id probr, std::string &detail, Id &ignoreId)
1034 Id dep, source, target;
1035 SolverRuleinfo type = solver_ruleinfo(_satSolver, probr, &source, &target, &dep);
1039 sat::Solvable s = mapSolvable( source );
1040 sat::Solvable s2 = mapSolvable( target );
1047 case SOLVER_RULE_DISTUPGRADE:
1048 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.asString().c_str());
1050 case SOLVER_RULE_INFARCH:
1051 ret =
str::form (
_(
"%s has inferior architecture"), s.asString().c_str());
1053 case SOLVER_RULE_UPDATE:
1054 ret =
str::form (
_(
"problem with installed package %s"), s.asString().c_str());
1056 case SOLVER_RULE_JOB:
1057 ret =
_(
"conflicting requests");
1059 case SOLVER_RULE_PKG:
1060 ret =
_(
"some dependency problem");
1062 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1063 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
1064 detail +=
_(
"Have you enabled all requested repositories?");
1066 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1067 ret =
str::form (
_(
"package %s does not exist"), pool_dep2str(pool, dep));
1068 detail +=
_(
"Have you enabled all requested repositories?");
1070 case SOLVER_RULE_JOB_UNSUPPORTED:
1071 ret =
_(
"unsupported request");
1073 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1074 ret =
str::form (
_(
"%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1076 case SOLVER_RULE_PKG_NOT_INSTALLABLE:
1077 ret =
str::form (
_(
"%s is not installable"), s.asString().c_str());
1079 case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
1081 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1083 case SOLVER_RULE_PKG_SAME_NAME:
1084 ret =
str::form (
_(
"cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1086 case SOLVER_RULE_PKG_CONFLICTS:
1087 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1089 case SOLVER_RULE_PKG_OBSOLETES:
1090 ret =
str::form (
_(
"%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1092 case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
1093 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1095 case SOLVER_RULE_PKG_SELF_CONFLICT:
1096 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1098 case SOLVER_RULE_PKG_REQUIRES: {
1100 Capability cap(dep);
1101 sat::WhatProvides possibleProviders(cap);
1104 typedef list<PoolItem> ProviderList;
1105 ProviderList providerlistInstalled, providerlistUninstalled;
1106 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1110 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1113 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1114 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1120 if (provider1.status().isInstalled())
1121 providerlistInstalled.push_back(provider1);
1123 providerlistUninstalled.push_back(provider1);
1127 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1128 if (providerlistInstalled.size() > 0) {
1129 detail +=
_(
"deleted providers: ");
1130 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1131 if (iter == providerlistInstalled.begin())
1137 if (providerlistUninstalled.size() > 0) {
1138 if (detail.size() > 0)
1139 detail +=
_(
"\nnot installable providers: ");
1141 detail =
_(
"not installable providers: ");
1142 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1143 if (iter == providerlistUninstalled.begin())
1152 DBG <<
"Unknown rule type(" << type <<
") going to query libsolv for rule information." << endl;
1153 ret =
str::asString( ::solver_problemruleinfo2str( _satSolver, type, static_cast<Id>(s.id()), static_cast<Id>(s2.id()), dep ) );
1161 SATResolver::problems ()
1164 if (_satSolver && solver_problem_count(_satSolver)) {
1168 Id problem, solution, element;
1169 sat::Solvable s, sd;
1171 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1172 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1174 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1177 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1178 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1179 MIL <<
"====================================" << endl;
1182 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1183 MIL << whatString << endl;
1184 MIL <<
"------------------------------------" << endl;
1185 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail, SATgetCompleteProblemInfoStrings( problem ));
1188 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1190 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1191 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1192 if (p == SOLVER_SOLUTION_JOB) {
1194 what = _jobQueue.elements[rp];
1195 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1197 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1198 s = mapSolvable (what);
1199 PoolItem poolItem = _pool.find (s);
1201 if (pool->installed && s.get()->repo == pool->installed) {
1202 problemSolution->addSingleAction (poolItem, REMOVE);
1203 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.asString().c_str() );
1204 MIL << description << endl;
1205 problemSolution->addDescription (description);
1207 problemSolution->addSingleAction (poolItem, KEEP);
1208 string description =
str::form (
_(
"do not install %s"), s.asString().c_str());
1209 MIL << description << endl;
1210 problemSolution->addDescription (description);
1213 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1217 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1218 s = mapSolvable (what);
1219 PoolItem poolItem = _pool.find (s);
1221 if (pool->installed && s.get()->repo == pool->installed) {
1222 problemSolution->addSingleAction (poolItem, KEEP);
1223 string description =
str::form (
_(
"keep %s"), s.asString().c_str());
1224 MIL << description << endl;
1225 problemSolution->addDescription (description);
1227 problemSolution->addSingleAction (poolItem, UNLOCK);
1228 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1229 MIL << description << endl;
1230 problemSolution->addDescription (description);
1233 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1237 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1239 IdString ident( what );
1240 SolverQueueItemInstall_Ptr install =
1241 new SolverQueueItemInstall(_pool, ident.asString(), false );
1242 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1244 string description =
str::form (
_(
"do not install %s"), ident.c_str() );
1245 MIL << description << endl;
1246 problemSolution->addDescription (description);
1249 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1253 IdString ident( what );
1254 FindPackage info (problemSolution, KEEP);
1256 _pool.byIdentEnd( ident ),
1258 resfilter::ByTransact ()),
1259 functor::functorRef<bool,PoolItem> (info) );
1261 SolverQueueItemDelete_Ptr del =
1262 new SolverQueueItemDelete(_pool, ident.asString(), false );
1263 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1265 string description =
str::form (
_(
"keep %s"), ident.c_str());
1266 MIL << description << endl;
1267 problemSolution->addDescription (description);
1270 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1272 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1273 string description =
"";
1276 if (system_requires.find(Capability(what)) != system_requires.end()) {
1278 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1279 resolverProblem->setDescription(
_(
"This request will break your system!"));
1280 description =
_(
"ignore the warning of a broken system");
1281 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1282 MIL << description << endl;
1283 problemSolution->addFrontDescription (description);
1285 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1286 MIL << description << endl;
1287 problemSolution->addDescription (description);
1291 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1293 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1294 string description =
"";
1297 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1299 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1300 resolverProblem->setDescription(
_(
"This request will break your system!"));
1301 description =
_(
"ignore the warning of a broken system");
1302 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1303 MIL << description << endl;
1304 problemSolution->addFrontDescription (description);
1307 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1308 MIL << description << endl;
1309 problemSolution->addDescription (description);
1313 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1315 s = mapSolvable (what);
1316 PoolItem poolItem = _pool.find (s);
1318 if (pool->installed && s.get()->repo == pool->installed) {
1319 problemSolution->addSingleAction (poolItem, KEEP);
1320 string description =
str::form (
_(
"do not install most recent version of %s"), s.asString().c_str());
1321 MIL << description << endl;
1322 problemSolution->addDescription (description);
1324 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1327 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1332 MIL <<
"- do something different" << endl;
1333 ERR <<
"No valid solution available" << endl;
1336 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1337 s = mapSolvable (rp);
1338 PoolItem poolItem = _pool.find (s);
1339 if (pool->installed && s.get()->repo == pool->installed) {
1340 problemSolution->addSingleAction (poolItem, LOCK);
1341 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.asString().c_str());
1342 MIL << description << endl;
1343 problemSolution->addDescription (description);
1345 problemSolution->addSingleAction (poolItem, INSTALL);
1346 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.asString().c_str());
1347 MIL << description << endl;
1348 problemSolution->addDescription (description);
1350 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1351 s = mapSolvable (rp);
1352 PoolItem poolItem = _pool.find (s);
1353 if (pool->installed && s.get()->repo == pool->installed) {
1354 problemSolution->addSingleAction (poolItem, LOCK);
1355 string description =
str::form (
_(
"keep obsolete %s"), s.asString().c_str());
1356 MIL << description << endl;
1357 problemSolution->addDescription (description);
1359 problemSolution->addSingleAction (poolItem, INSTALL);
1360 string description =
str::form (
_(
"install %s from excluded repository"), s.asString().c_str());
1361 MIL << description << endl;
1362 problemSolution->addDescription (description);
1364 }
else if ( p == SOLVER_SOLUTION_BLACK ) {
1367 s = mapSolvable (rp);
1368 PoolItem poolItem = _pool.find (s);
1370 problemSolution->addSingleAction (poolItem, INSTALL);
1372 if ( s.isRetracted() ) {
1374 description = str::Format(
_(
"install %1% although it has been retracted")) % s.asString();
1375 }
else if ( s.isPtf() ) {
1377 description = str::Format(
_(
"allow to install the PTF %1%")) % s.asString();
1380 description = str::Format(
_(
"install %1% although it is blacklisted")) % s.asString();
1382 MIL << description << endl;
1383 problemSolution->addDescription( description );
1384 }
else if ( p > 0 ) {
1386 s = mapSolvable (p);
1387 PoolItem itemFrom = _pool.find (s);
1392 sd = mapSolvable (rp);
1393 PoolItem itemTo = _pool.find (sd);
1394 if (itemFrom && itemTo) {
1395 problemSolution->addSingleAction (itemTo, INSTALL);
1396 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1398 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1400 string description =
str::form (
_(
"downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1401 MIL << description << endl;
1402 problemSolution->addDescription (description);
1405 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1407 string description =
str::form (
_(
"architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1408 MIL << description << endl;
1409 problemSolution->addDescription (description);
1412 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1414 IdString s_vendor( s.vendor() );
1415 IdString sd_vendor( sd.vendor() );
1416 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1417 sd.asString().c_str(),
1418 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1419 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1420 MIL << description << endl;
1421 problemSolution->addDescription (description);
1425 string description =
str::form (
_(
"replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1426 MIL << description << endl;
1427 problemSolution->addDescription (description);
1430 ERR << s.asString() <<
" or " << sd.asString() <<
" not found" << endl;
1436 string description =
str::form (
_(
"deinstallation of %s"), s.asString().c_str());
1437 MIL << description << endl;
1438 problemSolution->addDescription (description);
1439 problemSolution->addSingleAction (itemFrom, REMOVE);
1445 INT <<
"Unknown solution " << p << endl;
1449 resolverProblem->addSolution (problemSolution,
1450 problemSolution->actionCount() > 1 ? true :
false);
1451 MIL <<
"------------------------------------" << endl;
1456 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1457 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1458 resolverProblem->addSolution (problemSolution,
1460 MIL <<
"ignore some dependencies of " << item << endl;
1461 MIL <<
"------------------------------------" << endl;
1465 resolverProblems.push_back (resolverProblem);
1468 return resolverProblems;
1472 { Resolver( _pool ).applySolutions( solutions ); }
1474 void SATResolver::setLocks()
1479 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1481 if (iter->status().isInstalled()) {
1483 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1484 queue_push( &(_jobQueue), ident );
1487 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1488 queue_push( &(_jobQueue), ident );
1491 MIL <<
"Locked " << icnt <<
" installed items and " << acnt <<
" NOT installed items." << endl;
1497 std::set<IdString> unifiedByName;
1498 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1499 IdString ident( (*iter)->satSolvable().ident() );
1500 if ( unifiedByName.insert( ident ).second )
1504 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1505 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1506 queue_push( &(_jobQueue), ident.id() );
1512 void SATResolver::setSystemRequirements()
1514 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1515 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1517 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1518 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1519 queue_push( &(_jobQueue), iter->id() );
1520 MIL <<
"SYSTEM Requires " << *iter << endl;
1523 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1524 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1525 queue_push( &(_jobQueue), iter->id() );
1526 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1534 IdString rpm(
"rpm" );
1535 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1537 if ( (*it)->isSystem() )
1540 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1541 queue_push( &(_jobQueue), archrule.id() );
1552 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1560 ::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.
sat::detail::SolvableIdType IdType
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.