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 (
false )
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);
401 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
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);
839 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
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)
1085 detail +=
_(
"\nuninstallable providers: ");
1088 detail =
_(
"uninstallable providers: ");
1089 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1090 if (iter == providerlistUninstalled.begin())
1103 SATResolver::problems ()
1106 if (_satSolver && solver_problem_count(_satSolver)) {
1110 Id problem, solution, element;
1113 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1114 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1116 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1119 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1120 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1121 MIL <<
"====================================" << endl;
1124 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1125 MIL << whatString << endl;
1126 MIL <<
"------------------------------------" << endl;
1127 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail);
1130 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1132 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1133 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1134 if (p == SOLVER_SOLUTION_JOB) {
1136 what = _jobQueue.elements[rp];
1137 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1139 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1140 s = mapSolvable (what);
1141 PoolItem poolItem = _pool.find (s);
1143 if (pool->installed && s.
get()->repo == pool->installed) {
1144 problemSolution->addSingleAction (poolItem, REMOVE);
1145 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.
asString().c_str() );
1146 MIL << description << endl;
1147 problemSolution->addDescription (description);
1149 problemSolution->addSingleAction (poolItem, KEEP);
1151 MIL << description << endl;
1152 problemSolution->addDescription (description);
1155 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.
asString() << endl;
1159 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1160 s = mapSolvable (what);
1161 PoolItem poolItem = _pool.find (s);
1163 if (pool->installed && s.
get()->repo == pool->installed) {
1164 problemSolution->addSingleAction (poolItem, KEEP);
1166 MIL << description << endl;
1167 problemSolution->addDescription (description);
1169 problemSolution->addSingleAction (poolItem, UNLOCK);
1170 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1171 MIL << description << endl;
1172 problemSolution->addDescription (description);
1175 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.
asString() << endl;
1179 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1182 SolverQueueItemInstall_Ptr install =
1184 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1186 string description =
str::form (
_(
"do not install %s"), ident.
c_str() );
1187 MIL << description << endl;
1188 problemSolution->addDescription (description);
1191 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1198 _pool.byIdentEnd( ident ),
1201 functor::functorRef<bool,PoolItem> (info) );
1203 SolverQueueItemDelete_Ptr del =
1205 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1208 MIL << description << endl;
1209 problemSolution->addDescription (description);
1212 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1214 problemSolution->addSingleAction (
Capability(what), REMOVE_EXTRA_REQUIRE);
1215 string description =
"";
1218 if (system_requires.find(
Capability(what)) != system_requires.end()) {
1220 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1221 resolverProblem->setDescription(
_(
"This request will break your system!"));
1222 description =
_(
"ignore the warning of a broken system");
1223 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1224 MIL << description << endl;
1225 problemSolution->addFrontDescription (description);
1227 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1228 MIL << description << endl;
1229 problemSolution->addDescription (description);
1233 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1235 problemSolution->addSingleAction (
Capability(what), REMOVE_EXTRA_CONFLICT);
1236 string description =
"";
1239 if (system_conflicts.find(
Capability(what)) != system_conflicts.end()) {
1241 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1242 resolverProblem->setDescription(
_(
"This request will break your system!"));
1243 description =
_(
"ignore the warning of a broken system");
1244 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1245 MIL << description << endl;
1246 problemSolution->addFrontDescription (description);
1249 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1250 MIL << description << endl;
1251 problemSolution->addDescription (description);
1255 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1257 s = mapSolvable (what);
1258 PoolItem poolItem = _pool.find (s);
1260 if (pool->installed && s.
get()->repo == pool->installed) {
1261 problemSolution->addSingleAction (poolItem, KEEP);
1262 string description =
str::form (
_(
"do not install most recent version of %s"), s.
asString().c_str());
1263 MIL << description << endl;
1264 problemSolution->addDescription (description);
1266 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1269 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.
asString() << endl;
1274 MIL <<
"- do something different" << endl;
1275 ERR <<
"No valid solution available" << endl;
1278 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1279 s = mapSolvable (rp);
1280 PoolItem poolItem = _pool.find (s);
1281 if (pool->installed && s.
get()->repo == pool->installed) {
1282 problemSolution->addSingleAction (poolItem, LOCK);
1283 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.
asString().c_str());
1284 MIL << description << endl;
1285 problemSolution->addDescription (description);
1287 problemSolution->addSingleAction (poolItem, INSTALL);
1288 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.
asString().c_str());
1289 MIL << description << endl;
1290 problemSolution->addDescription (description);
1292 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1293 s = mapSolvable (rp);
1294 PoolItem poolItem = _pool.find (s);
1295 if (pool->installed && s.
get()->repo == pool->installed) {
1296 problemSolution->addSingleAction (poolItem, LOCK);
1298 MIL << description << endl;
1299 problemSolution->addDescription (description);
1301 problemSolution->addSingleAction (poolItem, INSTALL);
1302 string description =
str::form (
_(
"install %s from excluded repository"), s.
asString().c_str());
1303 MIL << description << endl;
1304 problemSolution->addDescription (description);
1308 s = mapSolvable (p);
1309 PoolItem itemFrom = _pool.find (s);
1314 sd = mapSolvable (rp);
1316 if (itemFrom && itemTo) {
1317 problemSolution->addSingleAction (itemTo, INSTALL);
1318 int illegal = policy_is_illegal(_satSolver, s.
get(), sd.
get(), 0);
1320 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1323 MIL << description << endl;
1324 problemSolution->addDescription (description);
1327 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1330 MIL << description << endl;
1331 problemSolution->addDescription (description);
1334 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1338 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1340 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1341 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1342 MIL << description << endl;
1343 problemSolution->addDescription (description);
1348 MIL << description << endl;
1349 problemSolution->addDescription (description);
1359 MIL << description << endl;
1360 problemSolution->addDescription (description);
1361 problemSolution->addSingleAction (itemFrom, REMOVE);
1366 resolverProblem->addSolution (problemSolution,
1367 problemSolution->actionCount() > 1 ?
true :
false);
1368 MIL <<
"------------------------------------" << endl;
1374 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1375 resolverProblem->addSolution (problemSolution,
1377 MIL <<
"ignore some dependencies of " << item << endl;
1378 MIL <<
"------------------------------------" << endl;
1382 resolverProblems.push_back (resolverProblem);
1385 return resolverProblems;
1391 void SATResolver::setLocks()
1393 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1395 if (iter->status().isInstalled()) {
1396 MIL <<
"Lock installed item " << *iter << endl;
1397 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1398 queue_push( &(_jobQueue), ident );
1400 MIL <<
"Lock NOT installed item " << *iter << endl;
1401 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1402 queue_push( &(_jobQueue), ident );
1410 std::set<IdString> unifiedByName;
1411 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1412 IdString ident( (*iter)->satSolvable().ident() );
1413 if ( unifiedByName.insert( ident ).second )
1417 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1418 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1419 queue_push( &(_jobQueue), ident.id() );
1425 void SATResolver::setSystemRequirements()
1427 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1428 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1430 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1431 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1432 queue_push( &(_jobQueue), iter->id() );
1433 MIL <<
"SYSTEM Requires " << *iter << endl;
1436 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1437 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1438 queue_push( &(_jobQueue), iter->id() );
1439 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1450 if ( (*it)->isSystem() )
1453 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1454 queue_push( &(_jobQueue), archrule.id() );
1465 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1473 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES );
Repository repository() const
The Repository this Solvable belongs to.
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).
detail::CSolvable * get() const
Expert backdoor.
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)
const_iterator byKindBegin(const ResKind &kind_r) const
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)
std::string asString() const
String representation "ident-edition.arch" or "noSolvable".
bool isSystem() const
Return whether this Solvable belongs to the system repo.
bool isUninstalled() const
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
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.
byIdent_iterator byIdentEnd(const ByIdent &ident_r) const
ResPool::instance().proxy();.
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)
Select PoolItem by installed.
std::string asString() const
Conversion to std::string
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 should be treated as the same vendor.
CheckIfUpdate(const sat::Solvable &installed_r)
std::list< ResolverProblem_Ptr > ResolverProblemList
static Pool instance()
Singleton ctor.
Commit helper functor distributing PoolItem by status into lists.
bool operator()(const PoolItem &item)
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Dependency resolver interface.
const_iterator begin() const
Iterator pointing to the first Solvable.
const_iterator byKindEnd(const ResKind &kind_r) const
const_iterator end() const
Iterator pointing behind the last Solvable.
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)
IMPL_PTR_TYPE(Application)
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.
Container of installed Solvable which would be obsoleted by the Solvable passed to the ctor...
bool operator()(const PoolItem &item_r)
bool solvablesEmpty() const
Whether Repository contains solvables.
const char * c_str() const
Conversion to const char *
bool setToBeUninstalled(TransactByValue causer)
FindPackage(ProblemSolutionCombi *p, const TransactionKind act)
CollectPseudoInstalled(Queue *queue)
Select PoolItem by transact.
void applySolutions(const ProblemSolutionList &solutions)
Apply problem solutions.
Select PoolItem by uninstalled.
Libsolv Id queue wrapper.
PoolItemList & _items_to_keep
bool compareByNVR(const SolvableType< Derived > &lhs, const Solvable &rhs)
std::unordered_set< Capability > CapabilitySet
IdString vendor() const
The vendor.
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)
void setRecommended(bool toVal_r=true)
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.
void prepare() const
Update housekeeping data if necessary (e.g.
bool setToBeInstalled(TransactByValue causer)
std::ostream & dumpRangeLine(std::ostream &str, TIterator begin, TIterator end)
Print range defined by iterators (single line style).
Describe a solver problem and offer solutions.
bool operator()(PoolItem item)
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.
void setUnneeded(bool toVal_r=true)
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)
Easy-to use interface to the ZYPP dependency resolver.
byIdent_iterator byIdentBegin(const ByIdent &ident_r) const
static const ResStatus toBeUninstalled
bool setToBeUninstalledDueToObsolete()
void setSuggested(bool toVal_r=true)
static ResPool instance()
Singleton ctor.