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)
1081 detail +=
_(
"\nuninstallable providers: ");
1084 detail =
_(
"uninstallable providers: ");
1085 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1086 if (iter == providerlistUninstalled.begin())
1099 SATResolver::problems ()
1102 if (_satSolver && solver_problem_count(_satSolver)) {
1106 Id problem, solution, element;
1107 sat::Solvable s, sd;
1109 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1110 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1112 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1115 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1116 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1117 MIL <<
"====================================" << endl;
1120 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1121 MIL << whatString << endl;
1122 MIL <<
"------------------------------------" << endl;
1123 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail);
1126 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1128 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1129 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1130 if (p == SOLVER_SOLUTION_JOB) {
1132 what = _jobQueue.elements[rp];
1133 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1135 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1136 s = mapSolvable (what);
1137 PoolItem poolItem = _pool.find (s);
1139 if (pool->installed && s.get()->repo == pool->installed) {
1140 problemSolution->addSingleAction (poolItem, REMOVE);
1141 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.asString().c_str() );
1142 MIL << description << endl;
1143 problemSolution->addDescription (description);
1145 problemSolution->addSingleAction (poolItem, KEEP);
1146 string description =
str::form (
_(
"do not install %s"), s.asString().c_str());
1147 MIL << description << endl;
1148 problemSolution->addDescription (description);
1151 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1155 case SOLVER_ERASE | 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, KEEP);
1161 string description =
str::form (
_(
"keep %s"), s.asString().c_str());
1162 MIL << description << endl;
1163 problemSolution->addDescription (description);
1165 problemSolution->addSingleAction (poolItem, UNLOCK);
1166 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1167 MIL << description << endl;
1168 problemSolution->addDescription (description);
1171 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1175 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1177 IdString ident( what );
1178 SolverQueueItemInstall_Ptr install =
1179 new SolverQueueItemInstall(_pool, ident.asString(), false );
1180 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1182 string description =
str::form (
_(
"do not install %s"), ident.c_str() );
1183 MIL << description << endl;
1184 problemSolution->addDescription (description);
1187 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1191 IdString ident( what );
1192 FindPackage info (problemSolution, KEEP);
1194 _pool.byIdentEnd( ident ),
1196 resfilter::ByTransact ()),
1197 functor::functorRef<bool,PoolItem> (info) );
1199 SolverQueueItemDelete_Ptr del =
1200 new SolverQueueItemDelete(_pool, ident.asString(), false );
1201 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1203 string description =
str::form (
_(
"keep %s"), ident.c_str());
1204 MIL << description << endl;
1205 problemSolution->addDescription (description);
1208 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1210 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1211 string description =
"";
1214 if (system_requires.find(Capability(what)) != system_requires.end()) {
1216 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1217 resolverProblem->setDescription(
_(
"This request will break your system!"));
1218 description =
_(
"ignore the warning of a broken system");
1219 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1220 MIL << description << endl;
1221 problemSolution->addFrontDescription (description);
1223 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1224 MIL << description << endl;
1225 problemSolution->addDescription (description);
1229 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1231 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1232 string description =
"";
1235 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1237 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1238 resolverProblem->setDescription(
_(
"This request will break your system!"));
1239 description =
_(
"ignore the warning of a broken system");
1240 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1241 MIL << description << endl;
1242 problemSolution->addFrontDescription (description);
1245 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1246 MIL << description << endl;
1247 problemSolution->addDescription (description);
1251 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1253 s = mapSolvable (what);
1254 PoolItem poolItem = _pool.find (s);
1256 if (pool->installed && s.get()->repo == pool->installed) {
1257 problemSolution->addSingleAction (poolItem, KEEP);
1258 string description =
str::form (
_(
"do not install most recent version of %s"), s.asString().c_str());
1259 MIL << description << endl;
1260 problemSolution->addDescription (description);
1262 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1265 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1270 MIL <<
"- do something different" << endl;
1271 ERR <<
"No valid solution available" << endl;
1274 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1275 s = mapSolvable (rp);
1276 PoolItem poolItem = _pool.find (s);
1277 if (pool->installed && s.get()->repo == pool->installed) {
1278 problemSolution->addSingleAction (poolItem, LOCK);
1279 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.asString().c_str());
1280 MIL << description << endl;
1281 problemSolution->addDescription (description);
1283 problemSolution->addSingleAction (poolItem, INSTALL);
1284 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.asString().c_str());
1285 MIL << description << endl;
1286 problemSolution->addDescription (description);
1288 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1289 s = mapSolvable (rp);
1290 PoolItem poolItem = _pool.find (s);
1291 if (pool->installed && s.get()->repo == pool->installed) {
1292 problemSolution->addSingleAction (poolItem, LOCK);
1293 string description =
str::form (
_(
"keep obsolete %s"), s.asString().c_str());
1294 MIL << description << endl;
1295 problemSolution->addDescription (description);
1297 problemSolution->addSingleAction (poolItem, INSTALL);
1298 string description =
str::form (
_(
"install %s from excluded repository"), s.asString().c_str());
1299 MIL << description << endl;
1300 problemSolution->addDescription (description);
1304 s = mapSolvable (p);
1305 PoolItem itemFrom = _pool.find (s);
1310 sd = mapSolvable (rp);
1311 PoolItem itemTo = _pool.find (sd);
1312 if (itemFrom && itemTo) {
1313 problemSolution->addSingleAction (itemTo, INSTALL);
1314 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1316 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1318 string description =
str::form (
_(
"downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1319 MIL << description << endl;
1320 problemSolution->addDescription (description);
1323 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1325 string description =
str::form (
_(
"architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1326 MIL << description << endl;
1327 problemSolution->addDescription (description);
1330 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1332 IdString s_vendor( s.vendor() );
1333 IdString sd_vendor( sd.vendor() );
1334 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1335 sd.asString().c_str(),
1336 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1337 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1338 MIL << description << endl;
1339 problemSolution->addDescription (description);
1343 string description =
str::form (
_(
"replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1344 MIL << description << endl;
1345 problemSolution->addDescription (description);
1348 ERR << s.asString() <<
" or " << sd.asString() <<
" not found" << endl;
1354 string description =
str::form (
_(
"deinstallation of %s"), s.asString().c_str());
1355 MIL << description << endl;
1356 problemSolution->addDescription (description);
1357 problemSolution->addSingleAction (itemFrom, REMOVE);
1362 resolverProblem->addSolution (problemSolution,
1363 problemSolution->actionCount() > 1 ?
true :
false);
1364 MIL <<
"------------------------------------" << endl;
1369 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1370 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1371 resolverProblem->addSolution (problemSolution,
1373 MIL <<
"ignore some dependencies of " << item << endl;
1374 MIL <<
"------------------------------------" << endl;
1378 resolverProblems.push_back (resolverProblem);
1381 return resolverProblems;
1385 { Resolver( _pool ).applySolutions( solutions ); }
1387 void SATResolver::setLocks()
1389 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1391 if (iter->status().isInstalled()) {
1392 MIL <<
"Lock installed item " << *iter << endl;
1393 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1394 queue_push( &(_jobQueue), ident );
1396 MIL <<
"Lock NOT installed item " << *iter << endl;
1397 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1398 queue_push( &(_jobQueue), ident );
1406 std::set<IdString> unifiedByName;
1407 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1408 IdString ident( (*iter)->satSolvable().ident() );
1409 if ( unifiedByName.insert( ident ).second )
1413 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1414 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1415 queue_push( &(_jobQueue), ident.id() );
1421 void SATResolver::setSystemRequirements()
1423 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1424 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1426 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1427 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1428 queue_push( &(_jobQueue), iter->id() );
1429 MIL <<
"SYSTEM Requires " << *iter << endl;
1432 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1433 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1434 queue_push( &(_jobQueue), iter->id() );
1435 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1443 IdString rpm(
"rpm" );
1444 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1446 if ( (*it)->isSystem() )
1449 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1450 queue_push( &(_jobQueue), archrule.id() );
1461 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1469 ::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.