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_NAMECHANGE );
147 OUTS( ALLOW_UNINSTALL );
148 OUTS( NO_UPDATEPROVIDE );
149 OUTS( SPLITPROVIDES );
150 OUTS( IGNORE_RECOMMENDED );
151 OUTS( ADD_ALREADY_RECOMMENDED );
152 OUTS( NO_INFARCHCHECK );
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;
184 , _allowdowngrade (
false )
185 , _allownamechange (
true )
186 , _allowarchchange (
false )
188 , _allowuninstall (
false )
189 , _updatesystem(
false)
190 , _noupdateprovide (
false )
191 , _dosplitprovides (
true )
193 , _ignorealreadyrecommended(
true)
194 , _distupgrade(
false)
195 , _distupgrade_removeunsupported(
false)
200 , _solveSrcPackages(
false)
206 SATResolver::~SATResolver()
214 SATResolver::pool (
void)
const 236 XDEBUG(
"SATSolutionToPool install returns " << item <<
", " << r);
240 XDEBUG(
"SATSolutionToPool upgrade returns " << item <<
", " << r);
244 XDEBUG(
"SATSolutionToPool remove returns " << item <<
", " << r);
265 PoolItemList & items_to_remove_r,
266 PoolItemList & items_to_lock_r,
267 PoolItemList & items_to_keep_r,
268 bool solveSrcPackages_r )
269 : _items_to_install( items_to_install_r )
270 , _items_to_remove( items_to_remove_r )
271 , _items_to_lock( items_to_lock_r )
272 , _items_to_keep( items_to_keep_r )
273 , _solveSrcPackages( solveSrcPackages_r )
275 _items_to_install.clear();
276 _items_to_remove.clear();
277 _items_to_lock.clear();
278 _items_to_keep.clear();
285 bool by_solver = ( itemStatus.isBySolver() || itemStatus.isByApplLow() );
300 switch ( itemStatus.getTransactValue() )
303 itemStatus.isUninstalled() ? _items_to_install.push_back( item_r )
304 : _items_to_remove.push_back( item_r );
break;
336 : is_updated( false )
337 , _installed( installed_r )
363 :solvableQueue (queue)
379 _satSolver = solver_create( _satPool );
380 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
382 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
383 queue_push( &(_jobQueue), 0 );
386 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
387 queue_push( &(_jobQueue), 0 );
390 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
391 queue_push( &(_jobQueue), 0 );
393 if (_distupgrade_removeunsupported) {
394 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
395 queue_push( &(_jobQueue), 0 );
397 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
398 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
399 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
400 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
402 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
403 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
404 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
405 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
411 #define HACKENV(X,D) solver_set_flag(_satSolver, X, env::HACKENV( #X, D ) ); 421 MIL <<
"Starting solving...." << endl;
423 solver_solve( _satSolver, &(_jobQueue) );
424 MIL <<
"....Solver end" << endl;
428 _result_items_to_install.clear();
429 _result_items_to_remove.clear();
433 queue_init(&decisionq);
434 solver_get_decisionqueue(_satSolver, &decisionq);
435 for (
int i = 0; i < decisionq.count; ++i )
443 _result_items_to_install.push_back( poolItem );
445 queue_free(&decisionq);
451 bool mustCheckObsoletes =
false;
454 if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
461 _pool.byIdentEnd( poolItem ),
463 functor::functorRef<bool,PoolItem> (info) );
469 if ( ! mustCheckObsoletes )
470 mustCheckObsoletes =
true;
472 _result_items_to_remove.push_back (poolItem);
474 if ( mustCheckObsoletes )
476 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
477 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
481 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
487 Queue recommendations;
491 queue_init(&recommendations);
492 queue_init(&suggestions);
493 queue_init(&orphaned);
494 queue_init(&unneeded);
495 solver_get_recommendations(_satSolver, &recommendations, &suggestions, 0);
496 solver_get_orphaned(_satSolver, &orphaned);
497 solver_get_unneeded(_satSolver, &unneeded, 1);
499 for (
int i = 0; i < recommendations.count; ++i )
506 for (
int i = 0; i < suggestions.count; ++i )
512 _problem_items.clear();
514 for (
int i = 0; i < orphaned.count; ++i )
518 _problem_items.push_back( poolItem );
522 for (
int i = 0; i < unneeded.count; ++i )
528 queue_free(&recommendations);
529 queue_free(&suggestions);
530 queue_free(&orphaned);
531 queue_free(&unneeded);
534 Queue flags, solvableQueue;
537 queue_init(&solvableQueue);
542 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
543 solver_trivial_installable(_satSolver, &solvableQueue, &flags );
544 for (
int i = 0; i < solvableQueue.count; i++) {
548 if (flags.elements[i] == -1) {
550 XDEBUG(
"SATSolutionToPool(" << item <<
" ) nonRelevant !");
551 }
else if (flags.elements[i] == 1) {
553 XDEBUG(
"SATSolutionToPool(" << item <<
" ) satisfied !");
554 }
else if (flags.elements[i] == 0) {
556 XDEBUG(
"SATSolutionToPool(" << item <<
" ) broken !");
559 queue_free(&(solvableQueue));
566 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
568 for_( iter2, rpmProviders.
begin(), rpmProviders.
end() ) {
571 MIL <<
"User requirement " << *iter <<
" sets " << poolItem << endl;
576 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
578 for_( iter2, rpmProviders.
begin(), rpmProviders.
end() ) {
581 MIL <<
"User conflict " << *iter <<
" sets " << poolItem << endl;
587 if (solver_problem_count(_satSolver) > 0 )
589 ERR <<
"Solverrun finished with an ERROR" << endl;
598 SATResolver::solverInit(
const PoolItemList & weakItems)
601 MIL <<
"SATResolver::solverInit()" << endl;
605 queue_init( &_jobQueue );
609 SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
610 invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
613 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
614 Id
id = (*iter)->satSolvable().id();
616 ERR <<
"Weaken: " << *iter <<
" not found" << endl;
618 MIL <<
"Weaken dependencies of " << *iter << endl;
619 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
620 queue_push( &(_jobQueue),
id );
624 const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
625 for (
const auto & locale : trackedLocaleIds.added() )
627 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
631 for (
const auto & locale : trackedLocaleIds.removed() )
633 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS );
638 for (
const sat::Solvable & solv : myPool().multiversionList() )
640 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
641 queue_push( &(_jobQueue), solv.id() );
644 ::pool_add_userinstalled_jobs(_satPool,
sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
650 MIL <<
"Checking droplists ..." << endl;
656 if ( (*it)->onSystem() )
663 dumpRangeLine(
MIL <<
"Droplist for " << (*it)->candidateObj() <<
": " << droplist.size() <<
" ", droplist.begin(), droplist.end() ) << endl;
664 for_( cap, droplist.begin(), droplist.end() )
666 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
667 queue_push( &_jobQueue, cap->id() );
674 MIL <<
"Droplist processing is disabled." << endl;
680 SATResolver::solverEnd()
685 solver_free(_satSolver);
687 queue_free( &(_jobQueue) );
693 SATResolver::resolvePool(
const CapabilitySet & requires_caps,
695 const PoolItemList & weakItems,
696 const std::set<Repository> & upgradeRepos)
698 MIL <<
"SATResolver::resolvePool()" << endl;
701 solverInit(weakItems);
703 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
704 Id
id = (*iter)->satSolvable().id();
706 ERR <<
"Install: " << *iter <<
" not found" << endl;
708 MIL <<
"Install " << *iter << endl;
709 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
710 queue_push( &(_jobQueue),
id );
714 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
715 Id
id = (*iter)->satSolvable().id();
717 ERR <<
"Delete: " << *iter <<
" not found" << endl;
719 MIL <<
"Delete " << *iter << endl;
720 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
721 queue_push( &(_jobQueue),
id);
725 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
727 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
728 queue_push( &(_jobQueue), iter->get()->repoid );
729 MIL <<
"Upgrade repo " << *iter << endl;
732 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
733 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
734 queue_push( &(_jobQueue), iter->id() );
735 MIL <<
"Requires " << *iter << endl;
738 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
739 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
740 queue_push( &(_jobQueue), iter->id() );
741 MIL <<
"Conflicts " << *iter << endl;
745 setSystemRequirements();
751 bool ret = solving(requires_caps, conflict_caps);
753 (ret?
MIL:
WAR) <<
"SATResolver::resolvePool() done. Ret:" << ret << endl;
760 const PoolItemList & weakItems)
762 MIL <<
"SATResolver::resolvQueue()" << endl;
765 solverInit(weakItems);
768 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
769 (*iter)->addRule(_jobQueue);
773 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
774 Id
id = (*iter)->satSolvable().id();
776 ERR <<
"Install: " << *iter <<
" not found" << endl;
778 MIL <<
"Install " << *iter << endl;
779 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
780 queue_push( &(_jobQueue),
id );
783 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
785 MIL <<
"Delete " << *iter << ident << endl;
786 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME |
MAYBE_CLEANDEPS );
787 queue_push( &(_jobQueue), ident);
791 setSystemRequirements();
797 bool ret = solving();
799 MIL <<
"SATResolver::resolveQueue() done. Ret:" << ret << endl;
804 void SATResolver::doUpdate()
806 MIL <<
"SATResolver::doUpdate()" << endl;
809 solverInit(PoolItemList());
812 setSystemRequirements();
817 _satSolver = solver_create( _satPool );
818 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
820 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
821 queue_push( &(_jobQueue), 0 );
824 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
825 queue_push( &(_jobQueue), 0 );
828 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
829 queue_push( &(_jobQueue), 0 );
831 if (_distupgrade_removeunsupported) {
832 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
833 queue_push( &(_jobQueue), 0 );
835 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
836 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
837 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
838 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
840 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
841 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
842 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
843 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
848 MIL <<
"Starting solving for update...." << endl;
850 solver_solve( _satSolver, &(_jobQueue) );
851 MIL <<
"....Solver end" << endl;
858 queue_init(&decisionq);
859 solver_get_decisionqueue(_satSolver, &decisionq);
860 for (
int i = 0; i < decisionq.count; i++)
863 p = decisionq.elements[i];
866 if (
sat::Solvable(p).repository().
get() == _satSolver->pool->installed)
873 ERR <<
"id " << p <<
" not found in ZYPP pool." << endl;
876 queue_free(&decisionq);
879 for (
int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
881 if (solver_get_decisionlevel(_satSolver, i) > 0)
889 _pool.byIdentEnd( poolItem ),
891 functor::functorRef<bool,PoolItem> (info) );
899 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
902 MIL <<
"SATResolver::doUpdate() done" << endl;
922 : problemSolution (p)
929 problemSolution->addSingleAction (p, action);
962 string SATResolver::SATprobleminfoString(Id problem,
string &detail, Id &ignoreId)
967 Id dep, source, target;
974 probr = solver_findproblemrule(_satSolver, problem);
975 switch (solver_ruleinfo(_satSolver, probr, &source, &target, &dep))
977 case SOLVER_RULE_DISTUPGRADE:
978 s = mapSolvable (source);
979 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.
asString().c_str());
981 case SOLVER_RULE_INFARCH:
982 s = mapSolvable (source);
985 case SOLVER_RULE_UPDATE:
986 s = mapSolvable (source);
989 case SOLVER_RULE_JOB:
990 ret =
_(
"conflicting requests");
992 case SOLVER_RULE_RPM:
993 ret =
_(
"some dependency problem");
995 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
996 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
997 detail +=
_(
"Have you enabled all requested repositories?");
999 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1000 ret =
str::form (
_(
"package %s does not exist"), pool_dep2str(pool, dep));
1001 detail +=
_(
"Have you enabled all requested repositories?");
1003 case SOLVER_RULE_JOB_UNSUPPORTED:
1004 ret =
_(
"unsupported request");
1006 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1007 ret =
str::form (
_(
"%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1009 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1010 s = mapSolvable (source);
1013 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1015 s = mapSolvable (source);
1016 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.
asString().c_str());
1018 case SOLVER_RULE_RPM_SAME_NAME:
1019 s = mapSolvable (source);
1020 s2 = mapSolvable (target);
1023 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1024 s = mapSolvable (source);
1025 s2 = mapSolvable (target);
1026 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.
asString().c_str(), pool_dep2str(pool, dep), s2.
asString().c_str());
1028 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1029 s = mapSolvable (source);
1030 s2 = mapSolvable (target);
1033 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1034 s = mapSolvable (source);
1035 s2 = mapSolvable (target);
1036 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.
asString().c_str(), pool_dep2str(pool, dep), s2.
asString().c_str());
1038 case SOLVER_RULE_RPM_SELF_CONFLICT:
1039 s = mapSolvable (source);
1040 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.
asString().c_str(), pool_dep2str(pool, dep));
1042 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1044 s = mapSolvable (source);
1049 typedef list<PoolItem> ProviderList;
1050 ProviderList providerlistInstalled, providerlistUninstalled;
1051 for_( iter1, possibleProviders.
begin(), possibleProviders.
end() ) {
1055 for_( iter2, possibleProviders.
begin(), possibleProviders.
end() ) {
1066 providerlistInstalled.push_back(provider1);
1068 providerlistUninstalled.push_back(provider1);
1072 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.
asString().c_str(), pool_dep2str(pool, dep));
1073 if (providerlistInstalled.size() > 0) {
1074 detail +=
_(
"deleted providers: ");
1075 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1076 if (iter == providerlistInstalled.begin())
1082 if (providerlistUninstalled.size() > 0) {
1083 if (detail.size() > 0)
1084 detail +=
_(
"\nnot installable providers: ");
1086 detail =
_(
"not installable providers: ");
1087 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1088 if (iter == providerlistUninstalled.begin())
1101 SATResolver::problems ()
1104 if (_satSolver && solver_problem_count(_satSolver)) {
1108 Id problem, solution, element;
1111 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1112 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1114 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1117 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1118 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1119 MIL <<
"====================================" << endl;
1122 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1123 MIL << whatString << endl;
1124 MIL <<
"------------------------------------" << endl;
1125 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail);
1128 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1130 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1131 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1132 if (p == SOLVER_SOLUTION_JOB) {
1134 what = _jobQueue.elements[rp];
1135 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1137 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1138 s = mapSolvable (what);
1139 PoolItem poolItem = _pool.find (s);
1141 if (pool->installed && s.
get()->repo == pool->installed) {
1142 problemSolution->addSingleAction (poolItem, REMOVE);
1143 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.
asString().c_str() );
1144 MIL << description << endl;
1145 problemSolution->addDescription (description);
1147 problemSolution->addSingleAction (poolItem, KEEP);
1149 MIL << description << endl;
1150 problemSolution->addDescription (description);
1153 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.
asString() << endl;
1157 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1158 s = mapSolvable (what);
1159 PoolItem poolItem = _pool.find (s);
1161 if (pool->installed && s.
get()->repo == pool->installed) {
1162 problemSolution->addSingleAction (poolItem, KEEP);
1164 MIL << description << endl;
1165 problemSolution->addDescription (description);
1167 problemSolution->addSingleAction (poolItem, UNLOCK);
1168 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1169 MIL << description << endl;
1170 problemSolution->addDescription (description);
1173 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.
asString() << endl;
1177 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1180 SolverQueueItemInstall_Ptr install =
1182 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1184 string description =
str::form (
_(
"do not install %s"), ident.
c_str() );
1185 MIL << description << endl;
1186 problemSolution->addDescription (description);
1189 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1196 _pool.byIdentEnd( ident ),
1199 functor::functorRef<bool,PoolItem> (info) );
1201 SolverQueueItemDelete_Ptr del =
1203 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1206 MIL << description << endl;
1207 problemSolution->addDescription (description);
1210 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1212 problemSolution->addSingleAction (
Capability(what), REMOVE_EXTRA_REQUIRE);
1213 string description =
"";
1216 if (system_requires.find(
Capability(what)) != system_requires.end()) {
1218 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1219 resolverProblem->setDescription(
_(
"This request will break your system!"));
1220 description =
_(
"ignore the warning of a broken system");
1221 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1222 MIL << description << endl;
1223 problemSolution->addFrontDescription (description);
1225 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1226 MIL << description << endl;
1227 problemSolution->addDescription (description);
1231 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1233 problemSolution->addSingleAction (
Capability(what), REMOVE_EXTRA_CONFLICT);
1234 string description =
"";
1237 if (system_conflicts.find(
Capability(what)) != system_conflicts.end()) {
1239 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1240 resolverProblem->setDescription(
_(
"This request will break your system!"));
1241 description =
_(
"ignore the warning of a broken system");
1242 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1243 MIL << description << endl;
1244 problemSolution->addFrontDescription (description);
1247 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1248 MIL << description << endl;
1249 problemSolution->addDescription (description);
1253 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1255 s = mapSolvable (what);
1256 PoolItem poolItem = _pool.find (s);
1258 if (pool->installed && s.
get()->repo == pool->installed) {
1259 problemSolution->addSingleAction (poolItem, KEEP);
1260 string description =
str::form (
_(
"do not install most recent version of %s"), s.
asString().c_str());
1261 MIL << description << endl;
1262 problemSolution->addDescription (description);
1264 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1267 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.
asString() << endl;
1272 MIL <<
"- do something different" << endl;
1273 ERR <<
"No valid solution available" << endl;
1276 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1277 s = mapSolvable (rp);
1278 PoolItem poolItem = _pool.find (s);
1279 if (pool->installed && s.
get()->repo == pool->installed) {
1280 problemSolution->addSingleAction (poolItem, LOCK);
1281 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.
asString().c_str());
1282 MIL << description << endl;
1283 problemSolution->addDescription (description);
1285 problemSolution->addSingleAction (poolItem, INSTALL);
1286 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.
asString().c_str());
1287 MIL << description << endl;
1288 problemSolution->addDescription (description);
1290 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1291 s = mapSolvable (rp);
1292 PoolItem poolItem = _pool.find (s);
1293 if (pool->installed && s.
get()->repo == pool->installed) {
1294 problemSolution->addSingleAction (poolItem, LOCK);
1296 MIL << description << endl;
1297 problemSolution->addDescription (description);
1299 problemSolution->addSingleAction (poolItem, INSTALL);
1300 string description =
str::form (
_(
"install %s from excluded repository"), s.
asString().c_str());
1301 MIL << description << endl;
1302 problemSolution->addDescription (description);
1306 s = mapSolvable (p);
1307 PoolItem itemFrom = _pool.find (s);
1312 sd = mapSolvable (rp);
1314 if (itemFrom && itemTo) {
1315 problemSolution->addSingleAction (itemTo, INSTALL);
1316 int illegal = policy_is_illegal(_satSolver, s.
get(), sd.
get(), 0);
1318 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1321 MIL << description << endl;
1322 problemSolution->addDescription (description);
1325 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1328 MIL << description << endl;
1329 problemSolution->addDescription (description);
1332 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1336 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1338 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1339 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1340 MIL << description << endl;
1341 problemSolution->addDescription (description);
1346 MIL << description << endl;
1347 problemSolution->addDescription (description);
1357 MIL << description << endl;
1358 problemSolution->addDescription (description);
1359 problemSolution->addSingleAction (itemFrom, REMOVE);
1364 resolverProblem->addSolution (problemSolution,
1365 problemSolution->actionCount() > 1 ? true :
false);
1366 MIL <<
"------------------------------------" << endl;
1372 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1373 resolverProblem->addSolution (problemSolution,
1375 MIL <<
"ignore some dependencies of " << item << endl;
1376 MIL <<
"------------------------------------" << endl;
1380 resolverProblems.push_back (resolverProblem);
1383 return resolverProblems;
1389 void SATResolver::setLocks()
1391 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1393 if (iter->status().isInstalled()) {
1394 MIL <<
"Lock installed item " << *iter << endl;
1395 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1396 queue_push( &(_jobQueue), ident );
1398 MIL <<
"Lock NOT installed item " << *iter << endl;
1399 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1400 queue_push( &(_jobQueue), ident );
1408 std::set<IdString> unifiedByName;
1409 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1410 IdString ident( (*iter)->satSolvable().ident() );
1411 if ( unifiedByName.insert( ident ).second )
1415 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1416 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1417 queue_push( &(_jobQueue), ident.id() );
1423 void SATResolver::setSystemRequirements()
1425 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1426 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1428 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1429 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1430 queue_push( &(_jobQueue), iter->id() );
1431 MIL <<
"SYSTEM Requires " << *iter << endl;
1434 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1435 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1436 queue_push( &(_jobQueue), iter->id() );
1437 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1448 if ( (*it)->isSystem() )
1451 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1452 queue_push( &(_jobQueue), archrule.id() );
1463 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1471 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES );
bool setTransactByValue(TransactByValue causer)
std::list< ProblemSolution_Ptr > ProblemSolutionList
int IdType
Generic Id type.
A Solvable object within the sat Pool.
Container of Solvable providing a Capability (read only).
IdString vendor() const
The vendor.
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.
void setOrphaned(bool toVal_r=true)
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.
ResPool::instance().proxy();.
static void SATSolutionToPool(PoolItem item, const ResStatus &status, const ResStatus::TransactByValue causer)
bool setToBeUninstalledDueToUpgrade(TransactByValue causer)
Select PoolItem by installed.
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.
std::list< ResolverProblem_Ptr > ResolverProblemList
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
static Pool instance()
Singleton ctor.
Commit helper functor distributing PoolItem by status into lists.
bool operator()(const PoolItem &item)
Dependency resolver interface.
int vendorCheck(sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2)
const_iterator byKindEnd(const ResKind &kind_r) const
std::unary_function< PoolItem, bool > PoolItemFilterFunctor
bool HACKENV(const char *var_r, bool default_r)
IMPL_PTR_TYPE(Application)
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
bool multiversionInstall() const
PoolItemList & _items_to_lock
std::string asString() const
String representation "ident-edition.arch" or "noSolvable".
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.
Container of installed Solvable which would be obsoleted by the Solvable passed to the ctor...
bool operator()(const PoolItem &item_r)
const_iterator byKindBegin(const ResKind &kind_r) const
const char * c_str() const
Conversion to const char *
bool setToBeUninstalled(TransactByValue causer)
FindPackage(ProblemSolutionCombi *p, const TransactionKind act)
bool isSystem() const
Return whether this Solvable belongs to the system repo.
CollectPseudoInstalled(Queue *queue)
Select PoolItem by transact.
void applySolutions(const ProblemSolutionList &solutions)
Apply problem solutions.
Select PoolItem by uninstalled.
detail::CSolvable * get() const
Expert backdoor.
Libsolv Id queue wrapper.
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)
void setRecommended(bool toVal_r=true)
bool isToBeUninstalled() const
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
bool isUninstalled() const
Chain< TACondition, TBCondition > chain(TACondition conda_r, TBCondition condb_r)
Convenience function for creating a Chain from two conditions conda_r and condb_r.
bool setToBeInstalled(TransactByValue causer)
std::ostream & dumpRangeLine(std::ostream &str, TIterator begin, TIterator end)
Print range defined by iterators (single line style).
const_iterator begin() const
Iterator pointing to the first Solvable.
bool solvablesEmpty() const
Whether Repository contains solvables.
Describe a solver problem and offer solutions.
bool operator()(PoolItem item)
Combining sat::Solvable and ResStatus.
Pathname systemRoot() const
The target root directory.
byIdent_iterator byIdentEnd(const ByIdent &ident_r) const
std::string asString() const
Conversion to std::string
bool isKind(const ResKind &kind_r) const
static const VendorAttr & instance()
Singleton.
void setUnneeded(bool toVal_r=true)
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
const_iterator end() const
Iterator pointing behind the last Solvable.
bool setToBeUninstalledDueToObsolete()
byIdent_iterator byIdentBegin(const ByIdent &ident_r) const
bool isToBeUninstalledDueToUpgrade() const
void setSuggested(bool toVal_r=true)
static ResPool instance()
Singleton ctor.