23 #include <solv/repo_solv.h> 24 #include <solv/poolarch.h> 26 #include <solv/poolvendor.h> 27 #include <solv/policy.h> 28 #include <solv/bitmap.h> 29 #include <solv/queue.h> 32 #define ZYPP_USE_RESOLVER_INTERNALS 63 #define XDEBUG(x) do { if (base::logger::isExcessive()) XXX << x << std::endl;} while (0) 65 #undef ZYPP_BASE_LOGGER_LOGGROUP 66 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::solver" 75 inline bool HACKENV(
const char * var_r,
bool default_r )
78 const char * val = ::getenv( var_r );
82 if ( ret != default_r )
83 INT <<
"HACKENV " << var_r <<
" = " << ret << endl;
101 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0) 110 IdString(solvable2->vendor) ) ? 0 : 1;
117 return std::string();
120 std::string ret( slv.asString() );
121 if ( ! slv.isSystem() )
134 INT <<
"id " << id_r <<
" not found in ZYPP pool." << endl;
143 os <<
"<resolver>" << endl;
145 #define OUTS(X) os << " " << #X << "\t= " << solver_get_flag(_satSolver, SOLVER_FLAG_##X) << endl 146 OUTS( ALLOW_DOWNGRADE );
147 OUTS( ALLOW_ARCHCHANGE );
148 OUTS( ALLOW_VENDORCHANGE );
149 OUTS( ALLOW_NAMECHANGE );
150 OUTS( ALLOW_UNINSTALL );
151 OUTS( NO_UPDATEPROVIDE );
152 OUTS( SPLITPROVIDES );
153 OUTS( IGNORE_RECOMMENDED );
154 OUTS( ADD_ALREADY_RECOMMENDED );
155 OUTS( NO_INFARCHCHECK );
156 OUTS( KEEP_EXPLICIT_OBSOLETES );
157 OUTS( BEST_OBEY_POLICY );
158 OUTS( NO_AUTOTARGET );
159 OUTS( DUP_ALLOW_DOWNGRADE );
160 OUTS( DUP_ALLOW_ARCHCHANGE );
161 OUTS( DUP_ALLOW_VENDORCHANGE );
162 OUTS( DUP_ALLOW_NAMECHANGE );
163 OUTS( KEEP_ORPHANS );
164 OUTS( BREAK_ORPHANS );
165 OUTS( FOCUS_INSTALLED );
166 OUTS( YUM_OBSOLETES );
168 os <<
" distupgrade = " << _distupgrade << endl;
169 os <<
" distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
170 os <<
" solveSrcPackages = " << _solveSrcPackages << endl;
171 os <<
" cleandepsOnRemove = " << _cleandepsOnRemove << endl;
172 os <<
" fixsystem = " << _fixsystem << endl;
173 os <<
" inr namespace = " << _inr << endl;
177 return os <<
"<resolver/>" << endl;
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 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
402 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
403 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
404 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
406 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
407 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
408 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
409 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
415 #define HACKENV(X,D) solver_set_flag(_satSolver, X, env::HACKENV( #X, D ) ); 425 MIL <<
"Starting solving...." << endl;
427 solver_solve( _satSolver, &(_jobQueue) );
428 MIL <<
"....Solver end" << endl;
432 _result_items_to_install.clear();
433 _result_items_to_remove.clear();
437 queue_init(&decisionq);
438 solver_get_decisionqueue(_satSolver, &decisionq);
439 for (
int i = 0; i < decisionq.count; ++i )
441 sat::Solvable slv( decisionq.elements[i] );
442 if ( !slv || slv.isSystem() )
445 PoolItem poolItem( slv );
447 _result_items_to_install.push_back( poolItem );
449 queue_free(&decisionq);
453 if ( systemRepo && ! systemRepo.solvablesEmpty() )
455 bool mustCheckObsoletes =
false;
456 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
458 if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
462 CheckIfUpdate info( *it );
463 PoolItem poolItem( *it );
465 _pool.byIdentEnd( poolItem ),
466 resfilter::ByUninstalled(),
467 functor::functorRef<bool,PoolItem> (info) );
469 if (info.is_updated) {
473 if ( ! mustCheckObsoletes )
474 mustCheckObsoletes =
true;
476 _result_items_to_remove.push_back (poolItem);
478 if ( mustCheckObsoletes )
480 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
481 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
483 ResStatus & status( it->status() );
485 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
486 status.setToBeUninstalledDueToObsolete();
491 Queue recommendations;
495 queue_init(&recommendations);
496 queue_init(&suggestions);
497 queue_init(&orphaned);
498 queue_init(&unneeded);
499 solver_get_recommendations(_satSolver, &recommendations, &suggestions, 0);
500 solver_get_orphaned(_satSolver, &orphaned);
501 solver_get_unneeded(_satSolver, &unneeded, 1);
503 for (
int i = 0; i < recommendations.count; ++i )
505 PoolItem poolItem(
getPoolItem( recommendations.elements[i] ) );
506 poolItem.status().setRecommended(
true );
510 for (
int i = 0; i < suggestions.count; ++i )
512 PoolItem poolItem(
getPoolItem( suggestions.elements[i] ) );
513 poolItem.status().setSuggested(
true );
516 _problem_items.clear();
518 for (
int i = 0; i < orphaned.count; ++i )
520 PoolItem poolItem(
getPoolItem( orphaned.elements[i] ) );
521 poolItem.status().setOrphaned(
true );
522 _problem_items.push_back( poolItem );
526 for (
int i = 0; i < unneeded.count; ++i )
528 PoolItem poolItem(
getPoolItem( unneeded.elements[i] ) );
529 poolItem.status().setUnneeded(
true );
532 queue_free(&recommendations);
533 queue_free(&suggestions);
534 queue_free(&orphaned);
535 queue_free(&unneeded);
538 Queue flags, solvableQueue;
541 queue_init(&solvableQueue);
543 CollectPseudoInstalled collectPseudoInstalled(&solvableQueue);
546 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
547 solver_trivial_installable(_satSolver, &solvableQueue, &flags );
548 for (
int i = 0; i < solvableQueue.count; i++) {
549 PoolItem item = _pool.find (sat::Solvable(solvableQueue.elements[i]));
550 item.status().setUndetermined();
552 if (flags.elements[i] == -1) {
553 item.status().setNonRelevant();
554 XDEBUG(
"SATSolutionToPool(" << item <<
" ) nonRelevant !");
555 }
else if (flags.elements[i] == 1) {
556 item.status().setSatisfied();
557 XDEBUG(
"SATSolutionToPool(" << item <<
" ) satisfied !");
558 }
else if (flags.elements[i] == 0) {
559 item.status().setBroken();
560 XDEBUG(
"SATSolutionToPool(" << item <<
" ) broken !");
563 queue_free(&(solvableQueue));
570 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
571 sat::WhatProvides rpmProviders(*iter);
572 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
573 PoolItem poolItem(*iter2);
574 if (poolItem.status().isToBeInstalled()) {
575 MIL <<
"User requirement " << *iter <<
" sets " << poolItem << endl;
580 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
581 sat::WhatProvides rpmProviders(*iter);
582 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
583 PoolItem poolItem(*iter2);
584 if (poolItem.status().isToBeUninstalled()) {
585 MIL <<
"User conflict " << *iter <<
" sets " << poolItem << endl;
591 if (solver_problem_count(_satSolver) > 0 )
593 ERR <<
"Solverrun finished with an ERROR" << endl;
602 SATResolver::solverInit(
const PoolItemList & weakItems)
605 MIL <<
"SATResolver::solverInit()" << endl;
609 queue_init( &_jobQueue );
613 SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
614 invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
617 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
618 Id
id = (*iter)->satSolvable().id();
620 ERR <<
"Weaken: " << *iter <<
" not found" << endl;
622 MIL <<
"Weaken dependencies of " << *iter << endl;
623 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
624 queue_push( &(_jobQueue),
id );
628 const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
632 for (
const auto & locale : trackedLocaleIds.current() )
634 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
642 for (
const auto & locale : trackedLocaleIds.added() )
644 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
648 for (
const auto & locale : trackedLocaleIds.removed() )
650 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS );
656 for (
const sat::Solvable & solv : myPool().multiversionList() )
658 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
659 queue_push( &(_jobQueue), solv.id() );
662 ::pool_add_userinstalled_jobs(_satPool,
sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
668 MIL <<
"Checking droplists ..." << endl;
672 for_( it, proxy.byKindBegin<Product>(), proxy.byKindEnd<Product>() )
674 if ( (*it)->onSystem() )
681 dumpRangeLine(
MIL <<
"Droplist for " << (*it)->candidateObj() <<
": " << droplist.size() <<
" ", droplist.begin(), droplist.end() ) << endl;
682 for_( cap, droplist.begin(), droplist.end() )
684 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
685 queue_push( &_jobQueue, cap->id() );
692 MIL <<
"Droplist processing is disabled." << endl;
698 SATResolver::solverEnd()
703 solver_free(_satSolver);
705 queue_free( &(_jobQueue) );
711 SATResolver::resolvePool(
const CapabilitySet & requires_caps,
713 const PoolItemList & weakItems,
714 const std::set<Repository> & upgradeRepos)
716 MIL <<
"SATResolver::resolvePool()" << endl;
719 solverInit(weakItems);
721 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
722 Id
id = (*iter)->satSolvable().id();
724 ERR <<
"Install: " << *iter <<
" not found" << endl;
726 MIL <<
"Install " << *iter << endl;
727 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
728 queue_push( &(_jobQueue),
id );
732 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
733 Id
id = (*iter)->satSolvable().id();
735 ERR <<
"Delete: " << *iter <<
" not found" << endl;
737 MIL <<
"Delete " << *iter << endl;
738 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
739 queue_push( &(_jobQueue),
id);
743 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
745 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
746 queue_push( &(_jobQueue), iter->get()->repoid );
747 MIL <<
"Upgrade repo " << *iter << endl;
750 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
751 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
752 queue_push( &(_jobQueue), iter->id() );
753 MIL <<
"Requires " << *iter << endl;
756 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
757 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
758 queue_push( &(_jobQueue), iter->id() );
759 MIL <<
"Conflicts " << *iter << endl;
763 setSystemRequirements();
769 bool ret = solving(requires_caps, conflict_caps);
771 (ret?
MIL:
WAR) <<
"SATResolver::resolvePool() done. Ret:" << ret << endl;
778 const PoolItemList & weakItems)
780 MIL <<
"SATResolver::resolvQueue()" << endl;
783 solverInit(weakItems);
786 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
787 (*iter)->addRule(_jobQueue);
791 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
792 Id
id = (*iter)->satSolvable().id();
794 ERR <<
"Install: " << *iter <<
" not found" << endl;
796 MIL <<
"Install " << *iter << endl;
797 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
798 queue_push( &(_jobQueue),
id );
801 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
803 MIL <<
"Delete " << *iter << ident << endl;
804 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME |
MAYBE_CLEANDEPS );
805 queue_push( &(_jobQueue), ident);
809 setSystemRequirements();
815 bool ret = solving();
817 MIL <<
"SATResolver::resolveQueue() done. Ret:" << ret << endl;
822 void SATResolver::doUpdate()
824 MIL <<
"SATResolver::doUpdate()" << endl;
827 solverInit(PoolItemList());
830 setSystemRequirements();
835 _satSolver = solver_create( _satPool );
836 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
838 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
839 queue_push( &(_jobQueue), 0 );
842 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
843 queue_push( &(_jobQueue), 0 );
846 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
847 queue_push( &(_jobQueue), 0 );
849 if (_distupgrade_removeunsupported) {
850 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
851 queue_push( &(_jobQueue), 0 );
853 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
854 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
855 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
856 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
858 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
859 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
860 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
861 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
866 MIL <<
"Starting solving for update...." << endl;
868 solver_solve( _satSolver, &(_jobQueue) );
869 MIL <<
"....Solver end" << endl;
876 queue_init(&decisionq);
877 solver_get_decisionqueue(_satSolver, &decisionq);
878 for (
int i = 0; i < decisionq.count; i++)
881 p = decisionq.elements[i];
882 if (p < 0 || !sat::Solvable(p))
884 if (sat::Solvable(p).repository().get() == _satSolver->pool->installed)
887 PoolItem poolItem = _pool.find (sat::Solvable(p));
891 ERR <<
"id " << p <<
" not found in ZYPP pool." << endl;
894 queue_free(&decisionq);
897 for (
int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
899 if (solver_get_decisionlevel(_satSolver, i) > 0)
902 PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
905 CheckIfUpdate info( (sat::Solvable(i)) );
907 _pool.byIdentEnd( poolItem ),
908 resfilter::ByUninstalled(),
909 functor::functorRef<bool,PoolItem> (info) );
911 if (info.is_updated) {
917 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
920 MIL <<
"SATResolver::doUpdate() done" << endl;
940 : problemSolution (p)
947 problemSolution->addSingleAction (p, action);
980 string SATResolver::SATprobleminfoString(Id problem,
string &detail, Id &ignoreId)
985 Id dep, source, target;
992 probr = solver_findproblemrule(_satSolver, problem);
993 switch (solver_ruleinfo(_satSolver, probr, &source, &target, &dep))
995 case SOLVER_RULE_DISTUPGRADE:
996 s = mapSolvable (source);
997 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.asString().c_str());
999 case SOLVER_RULE_INFARCH:
1000 s = mapSolvable (source);
1001 ret =
str::form (
_(
"%s has inferior architecture"), s.asString().c_str());
1003 case SOLVER_RULE_UPDATE:
1004 s = mapSolvable (source);
1005 ret =
str::form (
_(
"problem with installed package %s"), s.asString().c_str());
1007 case SOLVER_RULE_JOB:
1008 ret =
_(
"conflicting requests");
1010 case SOLVER_RULE_RPM:
1011 ret =
_(
"some dependency problem");
1013 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1014 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
1015 detail +=
_(
"Have you enabled all requested repositories?");
1017 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1018 ret =
str::form (
_(
"package %s does not exist"), pool_dep2str(pool, dep));
1019 detail +=
_(
"Have you enabled all requested repositories?");
1021 case SOLVER_RULE_JOB_UNSUPPORTED:
1022 ret =
_(
"unsupported request");
1024 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1025 ret =
str::form (
_(
"%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1027 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1028 s = mapSolvable (source);
1029 ret =
str::form (
_(
"%s is not installable"), s.asString().c_str());
1031 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1033 s = mapSolvable (source);
1034 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1036 case SOLVER_RULE_RPM_SAME_NAME:
1037 s = mapSolvable (source);
1038 s2 = mapSolvable (target);
1039 ret =
str::form (
_(
"cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1041 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1042 s = mapSolvable (source);
1043 s2 = mapSolvable (target);
1044 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1046 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1047 s = mapSolvable (source);
1048 s2 = mapSolvable (target);
1049 ret =
str::form (
_(
"%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1051 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1052 s = mapSolvable (source);
1053 s2 = mapSolvable (target);
1054 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1056 case SOLVER_RULE_RPM_SELF_CONFLICT:
1057 s = mapSolvable (source);
1058 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1060 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1062 s = mapSolvable (source);
1063 Capability cap(dep);
1064 sat::WhatProvides possibleProviders(cap);
1067 typedef list<PoolItem> ProviderList;
1068 ProviderList providerlistInstalled, providerlistUninstalled;
1069 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1073 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1076 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1077 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1083 if (provider1.status().isInstalled())
1084 providerlistInstalled.push_back(provider1);
1086 providerlistUninstalled.push_back(provider1);
1090 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1091 if (providerlistInstalled.size() > 0) {
1092 detail +=
_(
"deleted providers: ");
1093 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1094 if (iter == providerlistInstalled.begin())
1100 if (providerlistUninstalled.size() > 0) {
1101 if (detail.size() > 0)
1102 detail +=
_(
"\nnot installable providers: ");
1104 detail =
_(
"not installable providers: ");
1105 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1106 if (iter == providerlistUninstalled.begin())
1119 SATResolver::problems ()
1122 if (_satSolver && solver_problem_count(_satSolver)) {
1126 Id problem, solution, element;
1127 sat::Solvable s, sd;
1129 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1130 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1132 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1135 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1136 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1137 MIL <<
"====================================" << endl;
1140 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1141 MIL << whatString << endl;
1142 MIL <<
"------------------------------------" << endl;
1143 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail);
1146 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1148 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1149 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1150 if (p == SOLVER_SOLUTION_JOB) {
1152 what = _jobQueue.elements[rp];
1153 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1155 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1156 s = mapSolvable (what);
1157 PoolItem poolItem = _pool.find (s);
1159 if (pool->installed && s.get()->repo == pool->installed) {
1160 problemSolution->addSingleAction (poolItem, REMOVE);
1161 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.asString().c_str() );
1162 MIL << description << endl;
1163 problemSolution->addDescription (description);
1165 problemSolution->addSingleAction (poolItem, KEEP);
1166 string description =
str::form (
_(
"do not install %s"), s.asString().c_str());
1167 MIL << description << endl;
1168 problemSolution->addDescription (description);
1171 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1175 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1176 s = mapSolvable (what);
1177 PoolItem poolItem = _pool.find (s);
1179 if (pool->installed && s.get()->repo == pool->installed) {
1180 problemSolution->addSingleAction (poolItem, KEEP);
1181 string description =
str::form (
_(
"keep %s"), s.asString().c_str());
1182 MIL << description << endl;
1183 problemSolution->addDescription (description);
1185 problemSolution->addSingleAction (poolItem, UNLOCK);
1186 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1187 MIL << description << endl;
1188 problemSolution->addDescription (description);
1191 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1195 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1197 IdString ident( what );
1198 SolverQueueItemInstall_Ptr install =
1199 new SolverQueueItemInstall(_pool, ident.asString(), false );
1200 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1202 string description =
str::form (
_(
"do not install %s"), ident.c_str() );
1203 MIL << description << endl;
1204 problemSolution->addDescription (description);
1207 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1211 IdString ident( what );
1212 FindPackage info (problemSolution, KEEP);
1214 _pool.byIdentEnd( ident ),
1216 resfilter::ByTransact ()),
1217 functor::functorRef<bool,PoolItem> (info) );
1219 SolverQueueItemDelete_Ptr del =
1220 new SolverQueueItemDelete(_pool, ident.asString(), false );
1221 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1223 string description =
str::form (
_(
"keep %s"), ident.c_str());
1224 MIL << description << endl;
1225 problemSolution->addDescription (description);
1228 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1230 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1231 string description =
"";
1234 if (system_requires.find(Capability(what)) != system_requires.end()) {
1236 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1237 resolverProblem->setDescription(
_(
"This request will break your system!"));
1238 description =
_(
"ignore the warning of a broken system");
1239 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1240 MIL << description << endl;
1241 problemSolution->addFrontDescription (description);
1243 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1244 MIL << description << endl;
1245 problemSolution->addDescription (description);
1249 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1251 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1252 string description =
"";
1255 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1257 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1258 resolverProblem->setDescription(
_(
"This request will break your system!"));
1259 description =
_(
"ignore the warning of a broken system");
1260 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1261 MIL << description << endl;
1262 problemSolution->addFrontDescription (description);
1265 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1266 MIL << description << endl;
1267 problemSolution->addDescription (description);
1271 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1273 s = mapSolvable (what);
1274 PoolItem poolItem = _pool.find (s);
1276 if (pool->installed && s.get()->repo == pool->installed) {
1277 problemSolution->addSingleAction (poolItem, KEEP);
1278 string description =
str::form (
_(
"do not install most recent version of %s"), s.asString().c_str());
1279 MIL << description << endl;
1280 problemSolution->addDescription (description);
1282 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1285 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1290 MIL <<
"- do something different" << endl;
1291 ERR <<
"No valid solution available" << endl;
1294 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1295 s = mapSolvable (rp);
1296 PoolItem poolItem = _pool.find (s);
1297 if (pool->installed && s.get()->repo == pool->installed) {
1298 problemSolution->addSingleAction (poolItem, LOCK);
1299 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.asString().c_str());
1300 MIL << description << endl;
1301 problemSolution->addDescription (description);
1303 problemSolution->addSingleAction (poolItem, INSTALL);
1304 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.asString().c_str());
1305 MIL << description << endl;
1306 problemSolution->addDescription (description);
1308 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1309 s = mapSolvable (rp);
1310 PoolItem poolItem = _pool.find (s);
1311 if (pool->installed && s.get()->repo == pool->installed) {
1312 problemSolution->addSingleAction (poolItem, LOCK);
1313 string description =
str::form (
_(
"keep obsolete %s"), s.asString().c_str());
1314 MIL << description << endl;
1315 problemSolution->addDescription (description);
1317 problemSolution->addSingleAction (poolItem, INSTALL);
1318 string description =
str::form (
_(
"install %s from excluded repository"), s.asString().c_str());
1319 MIL << description << endl;
1320 problemSolution->addDescription (description);
1324 s = mapSolvable (p);
1325 PoolItem itemFrom = _pool.find (s);
1330 sd = mapSolvable (rp);
1331 PoolItem itemTo = _pool.find (sd);
1332 if (itemFrom && itemTo) {
1333 problemSolution->addSingleAction (itemTo, INSTALL);
1334 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1336 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1338 string description =
str::form (
_(
"downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1339 MIL << description << endl;
1340 problemSolution->addDescription (description);
1343 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1345 string description =
str::form (
_(
"architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1346 MIL << description << endl;
1347 problemSolution->addDescription (description);
1350 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1352 IdString s_vendor( s.vendor() );
1353 IdString sd_vendor( sd.vendor() );
1354 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1355 sd.asString().c_str(),
1356 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1357 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1358 MIL << description << endl;
1359 problemSolution->addDescription (description);
1363 string description =
str::form (
_(
"replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1364 MIL << description << endl;
1365 problemSolution->addDescription (description);
1368 ERR << s.asString() <<
" or " << sd.asString() <<
" not found" << endl;
1374 string description =
str::form (
_(
"deinstallation of %s"), s.asString().c_str());
1375 MIL << description << endl;
1376 problemSolution->addDescription (description);
1377 problemSolution->addSingleAction (itemFrom, REMOVE);
1382 resolverProblem->addSolution (problemSolution,
1383 problemSolution->actionCount() > 1 ? true :
false);
1384 MIL <<
"------------------------------------" << endl;
1389 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1390 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1391 resolverProblem->addSolution (problemSolution,
1393 MIL <<
"ignore some dependencies of " << item << endl;
1394 MIL <<
"------------------------------------" << endl;
1398 resolverProblems.push_back (resolverProblem);
1401 return resolverProblems;
1405 { Resolver( _pool ).applySolutions( solutions ); }
1407 void SATResolver::setLocks()
1409 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1411 if (iter->status().isInstalled()) {
1412 MIL <<
"Lock installed item " << *iter << endl;
1413 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1414 queue_push( &(_jobQueue), ident );
1416 MIL <<
"Lock NOT installed item " << *iter << endl;
1417 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1418 queue_push( &(_jobQueue), ident );
1426 std::set<IdString> unifiedByName;
1427 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1428 IdString ident( (*iter)->satSolvable().ident() );
1429 if ( unifiedByName.insert( ident ).second )
1433 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1434 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1435 queue_push( &(_jobQueue), ident.id() );
1441 void SATResolver::setSystemRequirements()
1443 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1444 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1446 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1447 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1448 queue_push( &(_jobQueue), iter->id() );
1449 MIL <<
"SYSTEM Requires " << *iter << endl;
1452 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1453 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1454 queue_push( &(_jobQueue), iter->id() );
1455 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1463 IdString rpm(
"rpm" );
1464 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1466 if ( (*it)->isSystem() )
1469 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1470 queue_push( &(_jobQueue), archrule.id() );
1481 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1489 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES );
std::list< ProblemSolution_Ptr > ProblemSolutionList
int IdType
Generic Id type.
A Solvable object within the sat Pool.
IdType id() const
Expert backdoor.
PoolItemList & _items_to_remove
ResKind kind() const
The Solvables ResKind.
static ZConfig & instance()
Singleton ctor.
bool isToBeInstalled() const
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings should be treated as the same vendor.
ProblemSolutionCombi * problemSolution
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
bool operator()(PoolItem p)
ResStatus & status() const
Returns the current status.
static const ResStatus toBeInstalled
::_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
sat::Solvable buddy() const
Return the buddy we share our status object with.
Access to the sat-pools string space.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
bool sameNVRA(const SolvableType< Derived > &lhs, const Solvable &rhs)
bool resetTransact(TransactByValue causer_r)
Not the same as setTransact( false ).
TraitsType::constPtrType constPtr
std::list< SolverQueueItem_Ptr > SolverQueueItemList
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
static void SATSolutionToPool(PoolItem item, const ResStatus &status, const ResStatus::TransactByValue causer)
bool setToBeUninstalledDueToUpgrade(TransactByValue causer)
static const ResStatus toBeUninstalledDueToUpgrade
std::unary_function< ResObject::constPtr, bool > ResObjectFilterFunctor
void prepare() const
Update housekeeping data if necessary (e.g.
CheckIfUpdate(const sat::Solvable &installed_r)
Repository repository() const
The Repository this Solvable belongs to.
Queue StringQueue
Queue with String ids.
std::list< ResolverProblem_Ptr > ResolverProblemList
static Pool instance()
Singleton ctor.
Commit helper functor distributing PoolItem by status into lists.
bool operator()(const PoolItem &item)
int vendorCheck(sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2)
std::unary_function< PoolItem, bool > PoolItemFilterFunctor
bool HACKENV(const char *var_r, bool default_r)
bool multiversionInstall() const
PoolItemList & _items_to_lock
SATCollectTransact(PoolItemList &items_to_install_r, PoolItemList &items_to_remove_r, PoolItemList &items_to_lock_r, PoolItemList &items_to_keep_r, bool solveSrcPackages_r)
bool isPseudoInstalled(ResKind kind_r)
Those are denoted to be installed, if the solver verifies them as being satisfied.
bool operator()(const PoolItem &item_r)
bool setToBeUninstalled(TransactByValue causer)
FindPackage(ProblemSolutionCombi *p, const TransactionKind act)
CollectPseudoInstalled(Queue *queue)
PoolItemList & _items_to_keep
bool compareByNVR(const SolvableType< Derived > &lhs, const Solvable &rhs)
std::unordered_set< Capability > CapabilitySet
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
sat::Solvable mapBuddy(sat::Solvable item_r)
PoolItemList & _items_to_install
std::string alias() const
Short unique string to identify a repo.
PoolItem getPoolItem(Id id_r)
bool isToBeUninstalled() const
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Chain< TACondition, TBCondition > chain(TACondition conda_r, TBCondition condb_r)
Convenience function for creating a Chain from two conditions conda_r and condb_r.
bool setToBeInstalled(TransactByValue causer)
std::ostream & dumpRangeLine(std::ostream &str, TIterator begin, TIterator end)
Print range defined by iterators (single line style).
bool operator()(PoolItem item)
IMPL_PTR_TYPE(SATResolver)
Combining sat::Solvable and ResStatus.
Pathname systemRoot() const
The target root directory.
bool isKind(const ResKind &kind_r) const
static const VendorAttr & instance()
Singleton.
int invokeOnEach(TIterator begin_r, TIterator end_r, TFilter filter_r, TFunction fnc_r)
Iterate through [begin_r,end_r) and invoke fnc_r on each item that passes filter_r.
std::string itemToString(const PoolItem &item)
Easy-to use interface to the ZYPP dependency resolver.
Solvable satSolvable() const
Return the corresponding sat::Solvable.
static const ResStatus toBeUninstalled
bool isToBeUninstalledDueToUpgrade() const
static ResPool instance()
Singleton ctor.