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" 67 inline bool HACKENV(
const char * var_r,
bool default_r )
70 const char * val = ::getenv( var_r );
74 if ( ret != default_r )
75 INT <<
"HACKENV " << var_r <<
" = " << ret << endl;
98 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
99 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
102 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 1 );
103 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
106 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
107 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 1 );
120 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0) 129 IdString(solvable2->vendor) ) ? 0 : 1;
136 return std::string();
139 std::string ret( slv.asString() );
140 if ( ! slv.isSystem() )
153 INT <<
"id " << id_r <<
" not found in ZYPP pool." << endl;
162 os <<
"<resolver>" << endl;
164 #define OUTS(X) os << " " << #X << "\t= " << solver_get_flag(_satSolver, SOLVER_FLAG_##X) << endl 165 OUTS( ALLOW_DOWNGRADE );
166 OUTS( ALLOW_ARCHCHANGE );
167 OUTS( ALLOW_VENDORCHANGE );
168 OUTS( ALLOW_NAMECHANGE );
169 OUTS( ALLOW_UNINSTALL );
170 OUTS( NO_UPDATEPROVIDE );
171 OUTS( SPLITPROVIDES );
172 OUTS( IGNORE_RECOMMENDED );
173 OUTS( ADD_ALREADY_RECOMMENDED );
174 OUTS( NO_INFARCHCHECK );
175 OUTS( KEEP_EXPLICIT_OBSOLETES );
176 OUTS( BEST_OBEY_POLICY );
177 OUTS( NO_AUTOTARGET );
178 OUTS( DUP_ALLOW_DOWNGRADE );
179 OUTS( DUP_ALLOW_ARCHCHANGE );
180 OUTS( DUP_ALLOW_VENDORCHANGE );
181 OUTS( DUP_ALLOW_NAMECHANGE );
182 OUTS( KEEP_ORPHANS );
183 OUTS( BREAK_ORPHANS );
184 OUTS( YUM_OBSOLETES );
186 os <<
" focus = " << _focus << endl;
187 os <<
" distupgrade = " << _distupgrade << endl;
188 os <<
" distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
189 os <<
" solveSrcPackages = " << _solveSrcPackages << endl;
190 os <<
" cleandepsOnRemove = " << _cleandepsOnRemove << endl;
191 os <<
" fixsystem = " << _fixsystem << endl;
195 return os <<
"<resolver/>" << endl;
205 , _focus ( ZConfig::instance().solver_focus() )
207 , _allowdowngrade ( false )
208 , _allownamechange ( true )
209 , _allowarchchange ( false )
211 , _allowuninstall ( false )
212 , _updatesystem(false)
213 , _noupdateprovide ( false )
214 , _dosplitprovides ( true )
215 , _onlyRequires (ZConfig::instance().solver_onlyRequires())
216 , _ignorealreadyrecommended(true)
217 , _distupgrade(false)
218 , _distupgrade_removeunsupported(false)
223 , _solveSrcPackages(false)
224 , _cleandepsOnRemove(ZConfig::instance().solver_cleandepsOnRemove())
229 SATResolver::~SATResolver()
237 SATResolver::pool (
void)
const 259 XDEBUG(
"SATSolutionToPool install returns " << item <<
", " << r);
263 XDEBUG(
"SATSolutionToPool upgrade returns " << item <<
", " << r);
267 XDEBUG(
"SATSolutionToPool remove returns " << item <<
", " << r);
288 PoolItemList & items_to_remove_r,
289 PoolItemList & items_to_lock_r,
290 PoolItemList & items_to_keep_r,
291 bool solveSrcPackages_r )
292 : _items_to_install( items_to_install_r )
293 , _items_to_remove( items_to_remove_r )
294 , _items_to_lock( items_to_lock_r )
295 , _items_to_keep( items_to_keep_r )
296 , _solveSrcPackages( solveSrcPackages_r )
298 _items_to_install.clear();
299 _items_to_remove.clear();
300 _items_to_lock.clear();
301 _items_to_keep.clear();
308 bool by_solver = ( itemStatus.isBySolver() || itemStatus.isByApplLow() );
323 switch ( itemStatus.getTransactValue() )
326 itemStatus.isUninstalled() ? _items_to_install.push_back( item_r )
327 : _items_to_remove.push_back( item_r );
break;
359 : is_updated( false )
360 , _installed( installed_r )
386 :solvableQueue (queue)
402 _satSolver = solver_create( _satPool );
403 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
405 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
406 queue_push( &(_jobQueue), 0 );
409 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
410 queue_push( &(_jobQueue), 0 );
413 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
414 queue_push( &(_jobQueue), 0 );
416 if (_distupgrade_removeunsupported) {
417 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
418 queue_push( &(_jobQueue), 0 );
420 solverSetFocus( *_satSolver, _focus );
421 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
422 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
423 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
424 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
426 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
427 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
428 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
429 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED,
false);
430 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires);
436 #define HACKENV(X,D) solver_set_flag(_satSolver, X, env::HACKENV( #X, D ) ); 446 MIL <<
"Starting solving...." << endl;
448 solver_solve( _satSolver, &(_jobQueue) );
449 MIL <<
"....Solver end" << endl;
453 _result_items_to_install.clear();
454 _result_items_to_remove.clear();
458 queue_init(&decisionq);
459 solver_get_decisionqueue(_satSolver, &decisionq);
460 for (
int i = 0; i < decisionq.count; ++i )
462 sat::Solvable slv( decisionq.elements[i] );
463 if ( !slv || slv.isSystem() )
466 PoolItem poolItem( slv );
468 _result_items_to_install.push_back( poolItem );
470 queue_free(&decisionq);
474 if ( systemRepo && ! systemRepo.solvablesEmpty() )
476 bool mustCheckObsoletes =
false;
477 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
479 if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
483 CheckIfUpdate info( *it );
484 PoolItem poolItem( *it );
486 _pool.byIdentEnd( poolItem ),
487 resfilter::ByUninstalled(),
488 functor::functorRef<bool,PoolItem> (info) );
490 if (info.is_updated) {
494 if ( ! mustCheckObsoletes )
495 mustCheckObsoletes =
true;
497 _result_items_to_remove.push_back (poolItem);
499 if ( mustCheckObsoletes )
501 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
502 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
504 ResStatus & status( it->status() );
506 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
507 status.setToBeUninstalledDueToObsolete();
512 Queue recommendations;
516 queue_init(&recommendations);
517 queue_init(&suggestions);
518 queue_init(&orphaned);
519 queue_init(&unneeded);
520 solver_get_recommendations(_satSolver, &recommendations, &suggestions, 0);
521 solver_get_orphaned(_satSolver, &orphaned);
522 solver_get_unneeded(_satSolver, &unneeded, 1);
524 for (
int i = 0; i < recommendations.count; ++i )
526 PoolItem poolItem(
getPoolItem( recommendations.elements[i] ) );
527 poolItem.status().setRecommended(
true );
531 for (
int i = 0; i < suggestions.count; ++i )
533 PoolItem poolItem(
getPoolItem( suggestions.elements[i] ) );
534 poolItem.status().setSuggested(
true );
537 _problem_items.clear();
539 for (
int i = 0; i < orphaned.count; ++i )
541 PoolItem poolItem(
getPoolItem( orphaned.elements[i] ) );
542 poolItem.status().setOrphaned(
true );
543 _problem_items.push_back( poolItem );
547 for (
int i = 0; i < unneeded.count; ++i )
549 PoolItem poolItem(
getPoolItem( unneeded.elements[i] ) );
550 poolItem.status().setUnneeded(
true );
553 queue_free(&recommendations);
554 queue_free(&suggestions);
555 queue_free(&orphaned);
556 queue_free(&unneeded);
559 Queue flags, solvableQueue;
562 queue_init(&solvableQueue);
564 CollectPseudoInstalled collectPseudoInstalled(&solvableQueue);
567 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
568 solver_trivial_installable(_satSolver, &solvableQueue, &flags );
569 for (
int i = 0; i < solvableQueue.count; i++) {
570 PoolItem item = _pool.find (sat::Solvable(solvableQueue.elements[i]));
571 item.status().setUndetermined();
573 if (flags.elements[i] == -1) {
574 item.status().setNonRelevant();
575 XDEBUG(
"SATSolutionToPool(" << item <<
" ) nonRelevant !");
576 }
else if (flags.elements[i] == 1) {
577 item.status().setSatisfied();
578 XDEBUG(
"SATSolutionToPool(" << item <<
" ) satisfied !");
579 }
else if (flags.elements[i] == 0) {
580 item.status().setBroken();
581 XDEBUG(
"SATSolutionToPool(" << item <<
" ) broken !");
584 queue_free(&(solvableQueue));
591 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
592 sat::WhatProvides rpmProviders(*iter);
593 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
594 PoolItem poolItem(*iter2);
595 if (poolItem.status().isToBeInstalled()) {
596 MIL <<
"User requirement " << *iter <<
" sets " << poolItem << endl;
601 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
602 sat::WhatProvides rpmProviders(*iter);
603 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
604 PoolItem poolItem(*iter2);
605 if (poolItem.status().isToBeUninstalled()) {
606 MIL <<
"User conflict " << *iter <<
" sets " << poolItem << endl;
612 if (solver_problem_count(_satSolver) > 0 )
614 ERR <<
"Solverrun finished with an ERROR" << endl;
623 SATResolver::solverInit(
const PoolItemList & weakItems)
626 MIL <<
"SATResolver::solverInit()" << endl;
630 queue_init( &_jobQueue );
634 SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
635 invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
638 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
639 Id
id = (*iter)->satSolvable().id();
641 ERR <<
"Weaken: " << *iter <<
" not found" << endl;
643 MIL <<
"Weaken dependencies of " << *iter << endl;
644 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
645 queue_push( &(_jobQueue),
id );
650 const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
653 for (
const auto & locale : trackedLocaleIds.added() )
655 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
659 for (
const auto & locale : trackedLocaleIds.removed() )
661 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS );
667 for (
const sat::Solvable & solv : myPool().multiversionList() )
669 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
670 queue_push( &(_jobQueue), solv.id() );
673 ::pool_add_userinstalled_jobs(_satPool,
sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
679 MIL <<
"Checking droplists ..." << endl;
683 for_( it, proxy.byKindBegin<Product>(), proxy.byKindEnd<Product>() )
685 if ( (*it)->onSystem() )
692 dumpRangeLine(
MIL <<
"Droplist for " << (*it)->candidateObj() <<
": " << droplist.size() <<
" ", droplist.begin(), droplist.end() ) << endl;
693 for_( cap, droplist.begin(), droplist.end() )
695 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
696 queue_push( &_jobQueue, cap->id() );
703 MIL <<
"Droplist processing is disabled." << endl;
709 SATResolver::solverEnd()
714 solver_free(_satSolver);
716 queue_free( &(_jobQueue) );
722 SATResolver::resolvePool(
const CapabilitySet & requires_caps,
724 const PoolItemList & weakItems,
725 const std::set<Repository> & upgradeRepos)
727 MIL <<
"SATResolver::resolvePool()" << endl;
730 solverInit(weakItems);
732 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
733 Id
id = (*iter)->satSolvable().id();
735 ERR <<
"Install: " << *iter <<
" not found" << endl;
737 MIL <<
"Install " << *iter << endl;
738 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
739 queue_push( &(_jobQueue),
id );
743 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
744 Id
id = (*iter)->satSolvable().id();
746 ERR <<
"Delete: " << *iter <<
" not found" << endl;
748 MIL <<
"Delete " << *iter << endl;
749 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
750 queue_push( &(_jobQueue),
id);
754 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
756 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
757 queue_push( &(_jobQueue), iter->get()->repoid );
758 MIL <<
"Upgrade repo " << *iter << endl;
761 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
762 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
763 queue_push( &(_jobQueue), iter->id() );
764 MIL <<
"Requires " << *iter << endl;
767 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
768 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
769 queue_push( &(_jobQueue), iter->id() );
770 MIL <<
"Conflicts " << *iter << endl;
774 setSystemRequirements();
780 bool ret = solving(requires_caps, conflict_caps);
782 (ret?
MIL:
WAR) <<
"SATResolver::resolvePool() done. Ret:" << ret << endl;
789 const PoolItemList & weakItems)
791 MIL <<
"SATResolver::resolvQueue()" << endl;
794 solverInit(weakItems);
797 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
798 (*iter)->addRule(_jobQueue);
802 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
803 Id
id = (*iter)->satSolvable().id();
805 ERR <<
"Install: " << *iter <<
" not found" << endl;
807 MIL <<
"Install " << *iter << endl;
808 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
809 queue_push( &(_jobQueue),
id );
812 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
814 MIL <<
"Delete " << *iter << ident << endl;
815 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME |
MAYBE_CLEANDEPS );
816 queue_push( &(_jobQueue), ident);
820 setSystemRequirements();
826 bool ret = solving();
828 MIL <<
"SATResolver::resolveQueue() done. Ret:" << ret << endl;
833 void SATResolver::doUpdate()
835 MIL <<
"SATResolver::doUpdate()" << endl;
838 solverInit(PoolItemList());
841 setSystemRequirements();
846 _satSolver = solver_create( _satPool );
847 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
849 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
850 queue_push( &(_jobQueue), 0 );
853 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
854 queue_push( &(_jobQueue), 0 );
857 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
858 queue_push( &(_jobQueue), 0 );
860 if (_distupgrade_removeunsupported) {
861 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
862 queue_push( &(_jobQueue), 0 );
864 solverSetFocus( *_satSolver, _focus );
865 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
866 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
867 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
868 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
870 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
871 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
872 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
873 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED,
false);
874 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires);
879 MIL <<
"Starting solving for update...." << endl;
881 solver_solve( _satSolver, &(_jobQueue) );
882 MIL <<
"....Solver end" << endl;
889 queue_init(&decisionq);
890 solver_get_decisionqueue(_satSolver, &decisionq);
891 for (
int i = 0; i < decisionq.count; i++)
894 p = decisionq.elements[i];
895 if (p < 0 || !sat::Solvable(p))
897 if (sat::Solvable(p).repository().
get() == _satSolver->pool->installed)
900 PoolItem poolItem = _pool.find (sat::Solvable(p));
904 ERR <<
"id " << p <<
" not found in ZYPP pool." << endl;
907 queue_free(&decisionq);
910 for (
int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
912 if (solver_get_decisionlevel(_satSolver, i) > 0)
915 PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
918 CheckIfUpdate info( (sat::Solvable(i)) );
920 _pool.byIdentEnd( poolItem ),
921 resfilter::ByUninstalled(),
922 functor::functorRef<bool,PoolItem> (info) );
924 if (info.is_updated) {
930 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
933 MIL <<
"SATResolver::doUpdate() done" << endl;
953 : problemSolution (p)
960 problemSolution->addSingleAction (p, action);
993 std::vector<std::string> SATResolver::SATgetCompleteProblemInfoStrings ( Id problem )
995 std::vector<std::string> ret;
997 solver_findallproblemrules( _satSolver, problem, problems );
1003 SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1004 if ( ruleClass != SolverRuleinfo::SOLVER_RULE_UPDATE && ruleClass != SolverRuleinfo::SOLVER_RULE_JOB ) {
1010 SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1011 if ( nobad && ( ruleClass == SolverRuleinfo::SOLVER_RULE_UPDATE || ruleClass == SolverRuleinfo::SOLVER_RULE_JOB ) ) {
1017 std::string pInfo = SATproblemRuleInfoString( problems[i], detail, ignore );
1020 if ( std::find( ret.begin(), ret.end(), pInfo ) == ret.end() )
1021 ret.push_back( pInfo );
1026 string SATResolver::SATprobleminfoString(Id problem,
string &detail, Id &ignoreId)
1030 Id probr = solver_findproblemrule(_satSolver, problem);
1031 return SATproblemRuleInfoString( probr, detail, ignoreId );
1034 std::string SATResolver::SATproblemRuleInfoString (Id probr, std::string &detail, Id &ignoreId)
1038 Id dep, source, target;
1039 SolverRuleinfo type = solver_ruleinfo(_satSolver, probr, &source, &target, &dep);
1043 sat::Solvable s = mapSolvable( source );
1044 sat::Solvable s2 = mapSolvable( target );
1051 case SOLVER_RULE_DISTUPGRADE:
1052 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.asString().c_str());
1054 case SOLVER_RULE_INFARCH:
1055 ret =
str::form (
_(
"%s has inferior architecture"), s.asString().c_str());
1057 case SOLVER_RULE_UPDATE:
1058 ret =
str::form (
_(
"problem with installed package %s"), s.asString().c_str());
1060 case SOLVER_RULE_JOB:
1061 ret =
_(
"conflicting requests");
1063 case SOLVER_RULE_PKG:
1064 ret =
_(
"some dependency problem");
1066 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1067 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
1068 detail +=
_(
"Have you enabled all requested repositories?");
1070 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1071 ret =
str::form (
_(
"package %s does not exist"), pool_dep2str(pool, dep));
1072 detail +=
_(
"Have you enabled all requested repositories?");
1074 case SOLVER_RULE_JOB_UNSUPPORTED:
1075 ret =
_(
"unsupported request");
1077 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1078 ret =
str::form (
_(
"%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1080 case SOLVER_RULE_PKG_NOT_INSTALLABLE:
1081 ret =
str::form (
_(
"%s is not installable"), s.asString().c_str());
1083 case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
1085 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1087 case SOLVER_RULE_PKG_SAME_NAME:
1088 ret =
str::form (
_(
"cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1090 case SOLVER_RULE_PKG_CONFLICTS:
1091 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1093 case SOLVER_RULE_PKG_OBSOLETES:
1094 ret =
str::form (
_(
"%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1096 case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
1097 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1099 case SOLVER_RULE_PKG_SELF_CONFLICT:
1100 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1102 case SOLVER_RULE_PKG_REQUIRES: {
1104 Capability cap(dep);
1105 sat::WhatProvides possibleProviders(cap);
1108 typedef list<PoolItem> ProviderList;
1109 ProviderList providerlistInstalled, providerlistUninstalled;
1110 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1114 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1117 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1118 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1124 if (provider1.status().isInstalled())
1125 providerlistInstalled.push_back(provider1);
1127 providerlistUninstalled.push_back(provider1);
1131 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1132 if (providerlistInstalled.size() > 0) {
1133 detail +=
_(
"deleted providers: ");
1134 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1135 if (iter == providerlistInstalled.begin())
1141 if (providerlistUninstalled.size() > 0) {
1142 if (detail.size() > 0)
1143 detail +=
_(
"\nnot installable providers: ");
1145 detail =
_(
"not installable providers: ");
1146 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1147 if (iter == providerlistUninstalled.begin())
1156 DBG <<
"Unknown rule type(" << type <<
") going to query libsolv for rule information." << endl;
1157 ret =
str::asString( ::solver_problemruleinfo2str( _satSolver, type, static_cast<Id>(s.id()), static_cast<Id>(s2.id()), dep ) );
1165 SATResolver::problems ()
1168 if (_satSolver && solver_problem_count(_satSolver)) {
1172 Id problem, solution, element;
1173 sat::Solvable s, sd;
1175 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1176 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1178 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1181 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1182 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1183 MIL <<
"====================================" << endl;
1186 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1187 MIL << whatString << endl;
1188 MIL <<
"------------------------------------" << endl;
1189 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail, SATgetCompleteProblemInfoStrings( problem ));
1192 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1194 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1195 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1196 if (p == SOLVER_SOLUTION_JOB) {
1198 what = _jobQueue.elements[rp];
1199 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1201 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1202 s = mapSolvable (what);
1203 PoolItem poolItem = _pool.find (s);
1205 if (pool->installed && s.get()->repo == pool->installed) {
1206 problemSolution->addSingleAction (poolItem, REMOVE);
1207 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.asString().c_str() );
1208 MIL << description << endl;
1209 problemSolution->addDescription (description);
1211 problemSolution->addSingleAction (poolItem, KEEP);
1212 string description =
str::form (
_(
"do not install %s"), s.asString().c_str());
1213 MIL << description << endl;
1214 problemSolution->addDescription (description);
1217 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1221 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1222 s = mapSolvable (what);
1223 PoolItem poolItem = _pool.find (s);
1225 if (pool->installed && s.get()->repo == pool->installed) {
1226 problemSolution->addSingleAction (poolItem, KEEP);
1227 string description =
str::form (
_(
"keep %s"), s.asString().c_str());
1228 MIL << description << endl;
1229 problemSolution->addDescription (description);
1231 problemSolution->addSingleAction (poolItem, UNLOCK);
1232 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1233 MIL << description << endl;
1234 problemSolution->addDescription (description);
1237 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1241 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1243 IdString ident( what );
1244 SolverQueueItemInstall_Ptr install =
1245 new SolverQueueItemInstall(_pool, ident.asString(), false );
1246 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1248 string description =
str::form (
_(
"do not install %s"), ident.c_str() );
1249 MIL << description << endl;
1250 problemSolution->addDescription (description);
1253 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1257 IdString ident( what );
1258 FindPackage info (problemSolution, KEEP);
1260 _pool.byIdentEnd( ident ),
1262 resfilter::ByTransact ()),
1263 functor::functorRef<bool,PoolItem> (info) );
1265 SolverQueueItemDelete_Ptr del =
1266 new SolverQueueItemDelete(_pool, ident.asString(), false );
1267 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1269 string description =
str::form (
_(
"keep %s"), ident.c_str());
1270 MIL << description << endl;
1271 problemSolution->addDescription (description);
1274 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1276 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1277 string description =
"";
1280 if (system_requires.find(Capability(what)) != system_requires.end()) {
1282 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1283 resolverProblem->setDescription(
_(
"This request will break your system!"));
1284 description =
_(
"ignore the warning of a broken system");
1285 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1286 MIL << description << endl;
1287 problemSolution->addFrontDescription (description);
1289 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1290 MIL << description << endl;
1291 problemSolution->addDescription (description);
1295 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1297 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1298 string description =
"";
1301 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1303 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1304 resolverProblem->setDescription(
_(
"This request will break your system!"));
1305 description =
_(
"ignore the warning of a broken system");
1306 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1307 MIL << description << endl;
1308 problemSolution->addFrontDescription (description);
1311 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1312 MIL << description << endl;
1313 problemSolution->addDescription (description);
1317 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1319 s = mapSolvable (what);
1320 PoolItem poolItem = _pool.find (s);
1322 if (pool->installed && s.get()->repo == pool->installed) {
1323 problemSolution->addSingleAction (poolItem, KEEP);
1324 string description =
str::form (
_(
"do not install most recent version of %s"), s.asString().c_str());
1325 MIL << description << endl;
1326 problemSolution->addDescription (description);
1328 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1331 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1336 MIL <<
"- do something different" << endl;
1337 ERR <<
"No valid solution available" << endl;
1340 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1341 s = mapSolvable (rp);
1342 PoolItem poolItem = _pool.find (s);
1343 if (pool->installed && s.get()->repo == pool->installed) {
1344 problemSolution->addSingleAction (poolItem, LOCK);
1345 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.asString().c_str());
1346 MIL << description << endl;
1347 problemSolution->addDescription (description);
1349 problemSolution->addSingleAction (poolItem, INSTALL);
1350 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.asString().c_str());
1351 MIL << description << endl;
1352 problemSolution->addDescription (description);
1354 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1355 s = mapSolvable (rp);
1356 PoolItem poolItem = _pool.find (s);
1357 if (pool->installed && s.get()->repo == pool->installed) {
1358 problemSolution->addSingleAction (poolItem, LOCK);
1359 string description =
str::form (
_(
"keep obsolete %s"), s.asString().c_str());
1360 MIL << description << endl;
1361 problemSolution->addDescription (description);
1363 problemSolution->addSingleAction (poolItem, INSTALL);
1364 string description =
str::form (
_(
"install %s from excluded repository"), s.asString().c_str());
1365 MIL << description << endl;
1366 problemSolution->addDescription (description);
1370 s = mapSolvable (p);
1371 PoolItem itemFrom = _pool.find (s);
1376 sd = mapSolvable (rp);
1377 PoolItem itemTo = _pool.find (sd);
1378 if (itemFrom && itemTo) {
1379 problemSolution->addSingleAction (itemTo, INSTALL);
1380 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1382 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1384 string description =
str::form (
_(
"downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1385 MIL << description << endl;
1386 problemSolution->addDescription (description);
1389 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1391 string description =
str::form (
_(
"architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1392 MIL << description << endl;
1393 problemSolution->addDescription (description);
1396 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1398 IdString s_vendor( s.vendor() );
1399 IdString sd_vendor( sd.vendor() );
1400 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1401 sd.asString().c_str(),
1402 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1403 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1404 MIL << description << endl;
1405 problemSolution->addDescription (description);
1409 string description =
str::form (
_(
"replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1410 MIL << description << endl;
1411 problemSolution->addDescription (description);
1414 ERR << s.asString() <<
" or " << sd.asString() <<
" not found" << endl;
1420 string description =
str::form (
_(
"deinstallation of %s"), s.asString().c_str());
1421 MIL << description << endl;
1422 problemSolution->addDescription (description);
1423 problemSolution->addSingleAction (itemFrom, REMOVE);
1428 resolverProblem->addSolution (problemSolution,
1429 problemSolution->actionCount() > 1 ? true :
false);
1430 MIL <<
"------------------------------------" << endl;
1435 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1436 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1437 resolverProblem->addSolution (problemSolution,
1439 MIL <<
"ignore some dependencies of " << item << endl;
1440 MIL <<
"------------------------------------" << endl;
1444 resolverProblems.push_back (resolverProblem);
1447 return resolverProblems;
1451 { Resolver( _pool ).applySolutions( solutions ); }
1453 void SATResolver::setLocks()
1458 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1460 if (iter->status().isInstalled()) {
1462 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1463 queue_push( &(_jobQueue), ident );
1466 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1467 queue_push( &(_jobQueue), ident );
1470 MIL <<
"Locked " << icnt <<
" installed items and " << acnt <<
" NOT installed items." << endl;
1476 std::set<IdString> unifiedByName;
1477 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1478 IdString ident( (*iter)->satSolvable().ident() );
1479 if ( unifiedByName.insert( ident ).second )
1483 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1484 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1485 queue_push( &(_jobQueue), ident.id() );
1491 void SATResolver::setSystemRequirements()
1493 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1494 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1496 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1497 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1498 queue_push( &(_jobQueue), iter->id() );
1499 MIL <<
"SYSTEM Requires " << *iter << endl;
1502 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1503 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1504 queue_push( &(_jobQueue), iter->id() );
1505 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1513 IdString rpm(
"rpm" );
1514 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1516 if ( (*it)->isSystem() )
1519 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1520 queue_push( &(_jobQueue), archrule.id() );
1531 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1539 ::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.
ProblemSolutionCombi * problemSolution
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
ResolverFocus
The resolvers general attitude.
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.
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 ).
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)
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
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.
Focus on installing the best version of the requested packages.
static const ResStatus toBeUninstalled
bool isToBeUninstalledDueToUpgrade() const
static ResPool instance()
Singleton ctor.