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)
72 inline bool HACKENV(
const char * var_r,
bool default_r )
75 const char * val = ::getenv( var_r );
79 if ( ret != default_r )
80 INT <<
"HACKENV " << var_r <<
" = " << ret << endl;
98 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0)
107 IdString(solvable2->vendor) ) ? 0 : 1;
114 return std::string();
117 std::string ret( slv.asString() );
118 if ( ! slv.isSystem() )
131 INT <<
"id " << id_r <<
" not found in ZYPP pool." << endl;
140 os <<
"<resolver>" << endl;
142 #define OUTS(X) os << " " << #X << "\t= " << solver_get_flag(_satSolver, SOLVER_FLAG_##X) << endl
143 OUTS( ALLOW_DOWNGRADE );
144 OUTS( ALLOW_ARCHCHANGE );
145 OUTS( ALLOW_VENDORCHANGE );
146 OUTS( ALLOW_UNINSTALL );
147 OUTS( NO_UPDATEPROVIDE );
148 OUTS( SPLITPROVIDES );
149 OUTS( IGNORE_RECOMMENDED );
150 OUTS( ADD_ALREADY_RECOMMENDED );
151 OUTS( NO_INFARCHCHECK );
152 OUTS( ALLOW_NAMECHANGE );
153 OUTS( KEEP_EXPLICIT_OBSOLETES );
154 OUTS( BEST_OBEY_POLICY );
155 OUTS( NO_AUTOTARGET );
156 OUTS( DUP_ALLOW_DOWNGRADE );
157 OUTS( DUP_ALLOW_ARCHCHANGE );
158 OUTS( DUP_ALLOW_VENDORCHANGE );
159 OUTS( DUP_ALLOW_NAMECHANGE );
160 OUTS( KEEP_ORPHANS );
161 OUTS( BREAK_ORPHANS );
162 OUTS( FOCUS_INSTALLED );
163 OUTS( YUM_OBSOLETES );
165 os <<
" distupgrade = " << _distupgrade << endl;
166 os <<
" distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
167 os <<
" solveSrcPackages = " << _solveSrcPackages << endl;
168 os <<
" cleandepsOnRemove = " << _cleandepsOnRemove << endl;
169 os <<
" fixsystem = " << _fixsystem << endl;
173 return os <<
"<resolver/>" << endl;
183 , _allowdowngrade(false)
184 , _allowarchchange(false)
185 , _allowvendorchange(ZConfig::instance().solver_allowVendorChange())
186 , _allowuninstall(false)
187 , _updatesystem(false)
188 , _noupdateprovide(false)
189 , _dosplitprovides(true)
190 , _onlyRequires(ZConfig::instance().solver_onlyRequires())
191 , _ignorealreadyrecommended(true)
192 , _distupgrade(false)
193 , _distupgrade_removeunsupported(false)
194 , _dup_allowdowngrade ( ZConfig::instance().solver_dupAllowDowngrade() )
198 , _solveSrcPackages(false)
199 , _cleandepsOnRemove(ZConfig::instance().solver_cleandepsOnRemove())
204 SATResolver::~SATResolver()
212 SATResolver::pool (
void)
const
234 XDEBUG(
"SATSolutionToPool install returns " << item <<
", " << r);
238 XDEBUG(
"SATSolutionToPool upgrade returns " << item <<
", " << r);
242 XDEBUG(
"SATSolutionToPool remove returns " << item <<
", " << r);
263 PoolItemList & items_to_remove_r,
264 PoolItemList & items_to_lock_r,
265 PoolItemList & items_to_keep_r,
266 bool solveSrcPackages_r )
267 : _items_to_install( items_to_install_r )
268 , _items_to_remove( items_to_remove_r )
269 , _items_to_lock( items_to_lock_r )
270 , _items_to_keep( items_to_keep_r )
271 , _solveSrcPackages( solveSrcPackages_r )
273 _items_to_install.clear();
274 _items_to_remove.clear();
275 _items_to_lock.clear();
276 _items_to_keep.clear();
283 bool by_solver = ( itemStatus.isBySolver() || itemStatus.isByApplLow() );
298 switch ( itemStatus.getTransactValue() )
301 itemStatus.isUninstalled() ? _items_to_install.push_back( item_r )
302 : _items_to_remove.push_back( item_r );
break;
334 : is_updated( false )
335 , _installed( installed_r )
361 :solvableQueue (queue)
377 _satSolver = solver_create( _satPool );
378 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
380 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
381 queue_push( &(_jobQueue), 0 );
384 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
385 queue_push( &(_jobQueue), 0 );
388 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
389 queue_push( &(_jobQueue), 0 );
391 if (_distupgrade_removeunsupported) {
392 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
393 queue_push( &(_jobQueue), 0 );
395 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
396 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
397 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
398 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
399 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
400 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
401 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
402 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
403 solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, _dup_allowdowngrade );
408 #define HACKENV(X,D) solver_set_flag(_satSolver, X, env::HACKENV( #X, D ) );
409 HACKENV( SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, _dup_allowdowngrade );
418 MIL <<
"Starting solving...." << endl;
420 solver_solve( _satSolver, &(_jobQueue) );
421 MIL <<
"....Solver end" << endl;
425 _result_items_to_install.clear();
426 _result_items_to_remove.clear();
430 queue_init(&decisionq);
431 solver_get_decisionqueue(_satSolver, &decisionq);
432 for (
int i = 0; i < decisionq.count; ++i )
434 sat::Solvable slv( decisionq.elements[i] );
435 if ( !slv || slv.isSystem() )
438 PoolItem poolItem( slv );
440 _result_items_to_install.push_back( poolItem );
442 queue_free(&decisionq);
446 if ( systemRepo && ! systemRepo.solvablesEmpty() )
448 bool mustCheckObsoletes =
false;
449 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
451 if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
455 CheckIfUpdate info( *it );
456 PoolItem poolItem( *it );
458 _pool.byIdentEnd( poolItem ),
459 resfilter::ByUninstalled(),
460 functor::functorRef<bool,PoolItem> (info) );
462 if (info.is_updated) {
466 if ( ! mustCheckObsoletes )
467 mustCheckObsoletes =
true;
469 _result_items_to_remove.push_back (poolItem);
471 if ( mustCheckObsoletes )
473 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
474 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
476 ResStatus & status( it->status() );
478 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
479 status.setToBeUninstalledDueToObsolete();
484 Queue recommendations;
488 queue_init(&recommendations);
489 queue_init(&suggestions);
490 queue_init(&orphaned);
491 queue_init(&unneeded);
492 solver_get_recommendations(_satSolver, &recommendations, &suggestions, 0);
493 solver_get_orphaned(_satSolver, &orphaned);
494 solver_get_unneeded(_satSolver, &unneeded, 1);
496 for (
int i = 0; i < recommendations.count; ++i )
498 PoolItem poolItem(
getPoolItem( recommendations.elements[i] ) );
499 poolItem.status().setRecommended(
true );
503 for (
int i = 0; i < suggestions.count; ++i )
505 PoolItem poolItem(
getPoolItem( suggestions.elements[i] ) );
506 poolItem.status().setSuggested(
true );
509 _problem_items.clear();
511 for (
int i = 0; i < orphaned.count; ++i )
513 PoolItem poolItem(
getPoolItem( orphaned.elements[i] ) );
514 poolItem.status().setOrphaned(
true );
515 _problem_items.push_back( poolItem );
519 for (
int i = 0; i < unneeded.count; ++i )
521 PoolItem poolItem(
getPoolItem( unneeded.elements[i] ) );
522 poolItem.status().setUnneeded(
true );
525 queue_free(&recommendations);
526 queue_free(&suggestions);
527 queue_free(&orphaned);
528 queue_free(&unneeded);
531 Queue flags, solvableQueue;
534 queue_init(&solvableQueue);
536 CollectPseudoInstalled collectPseudoInstalled(&solvableQueue);
539 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
540 solver_trivial_installable(_satSolver, &solvableQueue, &flags );
541 for (
int i = 0; i < solvableQueue.count; i++) {
542 PoolItem item = _pool.find (sat::Solvable(solvableQueue.elements[i]));
543 item.status().setUndetermined();
545 if (flags.elements[i] == -1) {
546 item.status().setNonRelevant();
547 XDEBUG(
"SATSolutionToPool(" << item <<
" ) nonRelevant !");
548 }
else if (flags.elements[i] == 1) {
549 item.status().setSatisfied();
550 XDEBUG(
"SATSolutionToPool(" << item <<
" ) satisfied !");
551 }
else if (flags.elements[i] == 0) {
552 item.status().setBroken();
553 XDEBUG(
"SATSolutionToPool(" << item <<
" ) broken !");
556 queue_free(&(solvableQueue));
563 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
564 sat::WhatProvides rpmProviders(*iter);
565 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
566 PoolItem poolItem(*iter2);
567 if (poolItem.status().isToBeInstalled()) {
568 MIL <<
"User requirement " << *iter <<
" sets " << poolItem << endl;
573 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
574 sat::WhatProvides rpmProviders(*iter);
575 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
576 PoolItem poolItem(*iter2);
577 if (poolItem.status().isToBeUninstalled()) {
578 MIL <<
"User conflict " << *iter <<
" sets " << poolItem << endl;
584 if (solver_problem_count(_satSolver) > 0 )
586 ERR <<
"Solverrun finished with an ERROR" << endl;
595 SATResolver::solverInit(
const PoolItemList & weakItems)
598 MIL <<
"SATResolver::solverInit()" << endl;
602 queue_init( &_jobQueue );
606 SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
607 invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
610 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
611 Id
id = (*iter)->satSolvable().id();
613 ERR <<
"Weaken: " << *iter <<
" not found" << endl;
615 MIL <<
"Weaken dependencies of " << *iter << endl;
616 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
617 queue_push( &(_jobQueue),
id );
621 const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
622 for (
const auto & locale : trackedLocaleIds.added() )
624 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
628 for (
const auto & locale : trackedLocaleIds.removed() )
630 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS );
635 for (
const sat::Solvable & solv : myPool().multiversionList() )
637 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
638 queue_push( &(_jobQueue), solv.id() );
641 ::pool_add_userinstalled_jobs(_satPool,
sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
647 MIL <<
"Checking droplists ..." << endl;
651 for_( it, proxy.byKindBegin<Product>(), proxy.byKindEnd<Product>() )
653 if ( (*it)->onSystem() )
660 dumpRangeLine(
MIL <<
"Droplist for " << (*it)->candidateObj() <<
": " << droplist.size() <<
" ", droplist.begin(), droplist.end() ) << endl;
661 for_( cap, droplist.begin(), droplist.end() )
663 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
664 queue_push( &_jobQueue, cap->id() );
671 MIL <<
"Droplist processing is disabled." << endl;
677 SATResolver::solverEnd()
682 solver_free(_satSolver);
684 queue_free( &(_jobQueue) );
690 SATResolver::resolvePool(
const CapabilitySet & requires_caps,
692 const PoolItemList & weakItems,
693 const std::set<Repository> & upgradeRepos)
695 MIL <<
"SATResolver::resolvePool()" << endl;
698 solverInit(weakItems);
700 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
701 Id
id = (*iter)->satSolvable().id();
703 ERR <<
"Install: " << *iter <<
" not found" << endl;
705 MIL <<
"Install " << *iter << endl;
706 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
707 queue_push( &(_jobQueue),
id );
711 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
712 Id
id = (*iter)->satSolvable().id();
714 ERR <<
"Delete: " << *iter <<
" not found" << endl;
716 MIL <<
"Delete " << *iter << endl;
717 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
718 queue_push( &(_jobQueue),
id);
722 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
724 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
725 queue_push( &(_jobQueue), iter->get()->repoid );
726 MIL <<
"Upgrade repo " << *iter << endl;
729 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
730 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
731 queue_push( &(_jobQueue), iter->id() );
732 MIL <<
"Requires " << *iter << endl;
735 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
736 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
737 queue_push( &(_jobQueue), iter->id() );
738 MIL <<
"Conflicts " << *iter << endl;
742 setSystemRequirements();
748 bool ret = solving(requires_caps, conflict_caps);
750 (ret?
MIL:
WAR) <<
"SATResolver::resolvePool() done. Ret:" << ret << endl;
757 const PoolItemList & weakItems)
759 MIL <<
"SATResolver::resolvQueue()" << endl;
762 solverInit(weakItems);
765 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
766 (*iter)->addRule(_jobQueue);
770 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
771 Id
id = (*iter)->satSolvable().id();
773 ERR <<
"Install: " << *iter <<
" not found" << endl;
775 MIL <<
"Install " << *iter << endl;
776 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
777 queue_push( &(_jobQueue),
id );
780 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
782 MIL <<
"Delete " << *iter << ident << endl;
783 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME |
MAYBE_CLEANDEPS );
784 queue_push( &(_jobQueue), ident);
788 setSystemRequirements();
794 bool ret = solving();
796 MIL <<
"SATResolver::resolveQueue() done. Ret:" << ret << endl;
801 void SATResolver::doUpdate()
803 MIL <<
"SATResolver::doUpdate()" << endl;
806 solverInit(PoolItemList());
809 setSystemRequirements();
814 _satSolver = solver_create( _satPool );
815 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
817 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
818 queue_push( &(_jobQueue), 0 );
821 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
822 queue_push( &(_jobQueue), 0 );
825 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
826 queue_push( &(_jobQueue), 0 );
828 if (_distupgrade_removeunsupported) {
829 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
830 queue_push( &(_jobQueue), 0 );
832 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
833 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
834 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
835 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
836 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
837 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
838 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
839 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
844 MIL <<
"Starting solving for update...." << endl;
846 solver_solve( _satSolver, &(_jobQueue) );
847 MIL <<
"....Solver end" << endl;
854 queue_init(&decisionq);
855 solver_get_decisionqueue(_satSolver, &decisionq);
856 for (
int i = 0; i < decisionq.count; i++)
859 p = decisionq.elements[i];
860 if (p < 0 || !sat::Solvable(p))
862 if (sat::Solvable(p).repository().
get() == _satSolver->pool->installed)
865 PoolItem poolItem = _pool.find (sat::Solvable(p));
869 ERR <<
"id " << p <<
" not found in ZYPP pool." << endl;
872 queue_free(&decisionq);
875 for (
int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
877 if (solver_get_decisionlevel(_satSolver, i) > 0)
880 PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
883 CheckIfUpdate info( (sat::Solvable(i)) );
885 _pool.byIdentEnd( poolItem ),
886 resfilter::ByUninstalled(),
887 functor::functorRef<bool,PoolItem> (info) );
889 if (info.is_updated) {
895 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
898 MIL <<
"SATResolver::doUpdate() done" << endl;
918 : problemSolution (p)
925 problemSolution->addSingleAction (p, action);
958 string SATResolver::SATprobleminfoString(Id problem,
string &detail, Id &ignoreId)
963 Id dep, source, target;
970 probr = solver_findproblemrule(_satSolver, problem);
971 switch (solver_ruleinfo(_satSolver, probr, &source, &target, &dep))
973 case SOLVER_RULE_DISTUPGRADE:
974 s = mapSolvable (source);
975 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.asString().c_str());
977 case SOLVER_RULE_INFARCH:
978 s = mapSolvable (source);
979 ret =
str::form (
_(
"%s has inferior architecture"), s.asString().c_str());
981 case SOLVER_RULE_UPDATE:
982 s = mapSolvable (source);
983 ret =
str::form (
_(
"problem with installed package %s"), s.asString().c_str());
985 case SOLVER_RULE_JOB:
986 ret =
_(
"conflicting requests");
988 case SOLVER_RULE_RPM:
989 ret =
_(
"some dependency problem");
991 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
992 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
993 detail +=
_(
"Have you enabled all requested repositories?");
995 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
996 ret =
str::form (
_(
"package %s does not exist"), pool_dep2str(pool, dep));
997 detail +=
_(
"Have you enabled all requested repositories?");
999 case SOLVER_RULE_JOB_UNSUPPORTED:
1000 ret =
_(
"unsupported request");
1002 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1003 ret =
str::form (
_(
"%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1005 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1006 s = mapSolvable (source);
1007 ret =
str::form (
_(
"%s is not installable"), s.asString().c_str());
1009 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1011 s = mapSolvable (source);
1012 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1014 case SOLVER_RULE_RPM_SAME_NAME:
1015 s = mapSolvable (source);
1016 s2 = mapSolvable (target);
1017 ret =
str::form (
_(
"cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1019 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1020 s = mapSolvable (source);
1021 s2 = mapSolvable (target);
1022 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1024 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1025 s = mapSolvable (source);
1026 s2 = mapSolvable (target);
1027 ret =
str::form (
_(
"%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1029 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1030 s = mapSolvable (source);
1031 s2 = mapSolvable (target);
1032 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1034 case SOLVER_RULE_RPM_SELF_CONFLICT:
1035 s = mapSolvable (source);
1036 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1038 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1040 s = mapSolvable (source);
1041 Capability cap(dep);
1042 sat::WhatProvides possibleProviders(cap);
1045 typedef list<PoolItem> ProviderList;
1046 ProviderList providerlistInstalled, providerlistUninstalled;
1047 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1051 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1054 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1055 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1061 if (provider1.status().isInstalled())
1062 providerlistInstalled.push_back(provider1);
1064 providerlistUninstalled.push_back(provider1);
1068 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1069 if (providerlistInstalled.size() > 0) {
1070 detail +=
_(
"deleted providers: ");
1071 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1072 if (iter == providerlistInstalled.begin())
1078 if (providerlistUninstalled.size() > 0) {
1079 if (detail.size() > 0)
1080 detail +=
_(
"\nuninstallable providers: ");
1082 detail =
_(
"uninstallable providers: ");
1083 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1084 if (iter == providerlistUninstalled.begin())
1097 SATResolver::problems ()
1100 if (_satSolver && solver_problem_count(_satSolver)) {
1104 Id problem, solution, element;
1105 sat::Solvable s, sd;
1107 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1108 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1110 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1113 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1114 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1115 MIL <<
"====================================" << endl;
1118 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1119 MIL << whatString << endl;
1120 MIL <<
"------------------------------------" << endl;
1121 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail);
1124 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1126 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1127 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1128 if (p == SOLVER_SOLUTION_JOB) {
1130 what = _jobQueue.elements[rp];
1131 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1133 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1134 s = mapSolvable (what);
1135 PoolItem poolItem = _pool.find (s);
1137 if (pool->installed && s.get()->repo == pool->installed) {
1138 problemSolution->addSingleAction (poolItem, REMOVE);
1139 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.asString().c_str() );
1140 MIL << description << endl;
1141 problemSolution->addDescription (description);
1143 problemSolution->addSingleAction (poolItem, KEEP);
1144 string description =
str::form (
_(
"do not install %s"), s.asString().c_str());
1145 MIL << description << endl;
1146 problemSolution->addDescription (description);
1149 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1153 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1154 s = mapSolvable (what);
1155 PoolItem poolItem = _pool.find (s);
1157 if (pool->installed && s.get()->repo == pool->installed) {
1158 problemSolution->addSingleAction (poolItem, KEEP);
1159 string description =
str::form (
_(
"keep %s"), s.asString().c_str());
1160 MIL << description << endl;
1161 problemSolution->addDescription (description);
1163 problemSolution->addSingleAction (poolItem, UNLOCK);
1164 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1165 MIL << description << endl;
1166 problemSolution->addDescription (description);
1169 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1173 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1175 IdString ident( what );
1176 SolverQueueItemInstall_Ptr install =
1177 new SolverQueueItemInstall(_pool, ident.asString(), false );
1178 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1180 string description =
str::form (
_(
"do not install %s"), ident.c_str() );
1181 MIL << description << endl;
1182 problemSolution->addDescription (description);
1185 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1189 IdString ident( what );
1190 FindPackage info (problemSolution, KEEP);
1192 _pool.byIdentEnd( ident ),
1194 resfilter::ByTransact ()),
1195 functor::functorRef<bool,PoolItem> (info) );
1197 SolverQueueItemDelete_Ptr del =
1198 new SolverQueueItemDelete(_pool, ident.asString(), false );
1199 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1201 string description =
str::form (
_(
"keep %s"), ident.c_str());
1202 MIL << description << endl;
1203 problemSolution->addDescription (description);
1206 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1208 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1209 string description =
"";
1212 if (system_requires.find(Capability(what)) != system_requires.end()) {
1214 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1215 resolverProblem->setDescription(
_(
"This request will break your system!"));
1216 description =
_(
"ignore the warning of a broken system");
1217 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1218 MIL << description << endl;
1219 problemSolution->addFrontDescription (description);
1221 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1222 MIL << description << endl;
1223 problemSolution->addDescription (description);
1227 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1229 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1230 string description =
"";
1233 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1235 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1236 resolverProblem->setDescription(
_(
"This request will break your system!"));
1237 description =
_(
"ignore the warning of a broken system");
1238 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1239 MIL << description << endl;
1240 problemSolution->addFrontDescription (description);
1243 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1244 MIL << description << endl;
1245 problemSolution->addDescription (description);
1249 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1251 s = mapSolvable (what);
1252 PoolItem poolItem = _pool.find (s);
1254 if (pool->installed && s.get()->repo == pool->installed) {
1255 problemSolution->addSingleAction (poolItem, KEEP);
1256 string description =
str::form (
_(
"do not install most recent version of %s"), s.asString().c_str());
1257 MIL << description << endl;
1258 problemSolution->addDescription (description);
1260 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1263 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1268 MIL <<
"- do something different" << endl;
1269 ERR <<
"No valid solution available" << endl;
1272 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1273 s = mapSolvable (rp);
1274 PoolItem poolItem = _pool.find (s);
1275 if (pool->installed && s.get()->repo == pool->installed) {
1276 problemSolution->addSingleAction (poolItem, LOCK);
1277 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.asString().c_str());
1278 MIL << description << endl;
1279 problemSolution->addDescription (description);
1281 problemSolution->addSingleAction (poolItem, INSTALL);
1282 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.asString().c_str());
1283 MIL << description << endl;
1284 problemSolution->addDescription (description);
1286 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1287 s = mapSolvable (rp);
1288 PoolItem poolItem = _pool.find (s);
1289 if (pool->installed && s.get()->repo == pool->installed) {
1290 problemSolution->addSingleAction (poolItem, LOCK);
1291 string description =
str::form (
_(
"keep obsolete %s"), s.asString().c_str());
1292 MIL << description << endl;
1293 problemSolution->addDescription (description);
1295 problemSolution->addSingleAction (poolItem, INSTALL);
1296 string description =
str::form (
_(
"install %s from excluded repository"), s.asString().c_str());
1297 MIL << description << endl;
1298 problemSolution->addDescription (description);
1302 s = mapSolvable (p);
1303 PoolItem itemFrom = _pool.find (s);
1308 sd = mapSolvable (rp);
1309 PoolItem itemTo = _pool.find (sd);
1310 if (itemFrom && itemTo) {
1311 problemSolution->addSingleAction (itemTo, INSTALL);
1312 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1314 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1316 string description =
str::form (
_(
"downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1317 MIL << description << endl;
1318 problemSolution->addDescription (description);
1321 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1323 string description =
str::form (
_(
"architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1324 MIL << description << endl;
1325 problemSolution->addDescription (description);
1328 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1330 IdString s_vendor( s.vendor() );
1331 IdString sd_vendor( sd.vendor() );
1332 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1333 sd.asString().c_str(),
1334 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1335 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1336 MIL << description << endl;
1337 problemSolution->addDescription (description);
1341 string description =
str::form (
_(
"replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1342 MIL << description << endl;
1343 problemSolution->addDescription (description);
1346 ERR << s.asString() <<
" or " << sd.asString() <<
" not found" << endl;
1352 string description =
str::form (
_(
"deinstallation of %s"), s.asString().c_str());
1353 MIL << description << endl;
1354 problemSolution->addDescription (description);
1355 problemSolution->addSingleAction (itemFrom, REMOVE);
1360 resolverProblem->addSolution (problemSolution,
1361 problemSolution->actionCount() > 1 ?
true :
false);
1362 MIL <<
"------------------------------------" << endl;
1367 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1368 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1369 resolverProblem->addSolution (problemSolution,
1371 MIL <<
"ignore some dependencies of " << item << endl;
1372 MIL <<
"------------------------------------" << endl;
1376 resolverProblems.push_back (resolverProblem);
1379 return resolverProblems;
1383 { Resolver( _pool ).applySolutions( solutions ); }
1385 void SATResolver::setLocks()
1387 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1389 if (iter->status().isInstalled()) {
1390 MIL <<
"Lock installed item " << *iter << endl;
1391 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1392 queue_push( &(_jobQueue), ident );
1394 MIL <<
"Lock NOT installed item " << *iter << endl;
1395 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1396 queue_push( &(_jobQueue), ident );
1404 std::set<IdString> unifiedByName;
1405 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1406 IdString ident( (*iter)->satSolvable().ident() );
1407 if ( unifiedByName.insert( ident ).second )
1411 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1412 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1413 queue_push( &(_jobQueue), ident.id() );
1419 void SATResolver::setSystemRequirements()
1421 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1422 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1424 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1425 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1426 queue_push( &(_jobQueue), iter->id() );
1427 MIL <<
"SYSTEM Requires " << *iter << endl;
1430 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1431 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1432 queue_push( &(_jobQueue), iter->id() );
1433 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1441 IdString rpm(
"rpm" );
1442 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1444 if ( (*it)->isSystem() )
1447 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1448 queue_push( &(_jobQueue), archrule.id() );
1459 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1467 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES );
Repository repository() const
The Repository this Solvable belongs to.
std::list< ProblemSolution_Ptr > ProblemSolutionList
int IdType
Generic Id type.
A Solvable object within the sat Pool.
PoolItemList & _items_to_remove
std::string alias() const
Short unique string to identify a repo.
bool isToBeUninstalledDueToUpgrade() const
static ZConfig & instance()
Singleton ctor.
bool isToBeUninstalled() const
ProblemSolutionCombi * problemSolution
bool operator()(PoolItem p)
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.
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 isKind(const ResKind &kind_r) const
bool multiversionInstall() const
bool setToBeUninstalledDueToUpgrade(TransactByValue causer)
static const ResStatus toBeUninstalledDueToUpgrade
std::unary_function< ResObject::constPtr, bool > ResObjectFilterFunctor
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings shold be treated as the same vendor.
CheckIfUpdate(const sat::Solvable &installed_r)
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)
PoolItemList & _items_to_lock
ResStatus & status() const
Returns the current status.
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
ResKind kind() const
The Solvables ResKind.
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
sat::Solvable mapBuddy(sat::Solvable item_r)
PoolItemList & _items_to_install
sat::Solvable buddy() const
Return the buddy we share our status object with.
Pathname systemRoot() const
The target root directory.
PoolItem getPoolItem(Id id_r)
bool isToBeInstalled() const
Solvable satSolvable() const
Return the corresponding sat::Solvable.
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.
IdType id() const
Expert backdoor.
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
static const VendorAttr & instance()
Singleton.
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
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)
static const ResStatus toBeUninstalled
void prepareForSolving() const
prepare plus some expensive checks done before solving only.
static ResPool instance()
Singleton ctor.