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 55 #define XDEBUG(x) do { if (base::logger::isExcessive()) XXX << x << std::endl;} while (0) 64 inline bool HACKENV(
const char * var_r,
bool default_r )
67 const char * val = ::getenv( var_r );
71 if ( ret != default_r )
72 INT <<
"HACKENV " << var_r <<
" = " << ret << endl;
95 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
96 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
99 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 1 );
100 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
103 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
104 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 1 );
117 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0) 126 IdString(solvable2->vendor) ) ? 0 : 1;
133 return std::string();
136 std::string ret( slv.asString() );
137 if ( ! slv.isSystem() )
150 INT <<
"id " << id_r <<
" not found in ZYPP pool." << endl;
159 os <<
"<resolver>" << endl;
161 #define OUTS(X) os << " " << #X << "\t= " << solver_get_flag(_satSolver, SOLVER_FLAG_##X) << endl 162 OUTS( ALLOW_DOWNGRADE );
163 OUTS( ALLOW_ARCHCHANGE );
164 OUTS( ALLOW_VENDORCHANGE );
165 OUTS( ALLOW_NAMECHANGE );
166 OUTS( ALLOW_UNINSTALL );
167 OUTS( NO_UPDATEPROVIDE );
168 OUTS( SPLITPROVIDES );
169 OUTS( IGNORE_RECOMMENDED );
170 OUTS( ADD_ALREADY_RECOMMENDED );
171 OUTS( NO_INFARCHCHECK );
172 OUTS( KEEP_EXPLICIT_OBSOLETES );
173 OUTS( BEST_OBEY_POLICY );
174 OUTS( NO_AUTOTARGET );
175 OUTS( DUP_ALLOW_DOWNGRADE );
176 OUTS( DUP_ALLOW_ARCHCHANGE );
177 OUTS( DUP_ALLOW_VENDORCHANGE );
178 OUTS( DUP_ALLOW_NAMECHANGE );
179 OUTS( KEEP_ORPHANS );
180 OUTS( BREAK_ORPHANS );
181 OUTS( YUM_OBSOLETES );
183 os <<
" focus = " << _focus << endl;
184 os <<
" distupgrade = " << _distupgrade << endl;
185 os <<
" distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
186 os <<
" solveSrcPackages = " << _solveSrcPackages << endl;
187 os <<
" cleandepsOnRemove = " << _cleandepsOnRemove << endl;
188 os <<
" fixsystem = " << _fixsystem << endl;
192 return os <<
"<resolver/>" << endl;
204 , _allowdowngrade (
false )
205 , _allownamechange (
true )
206 , _allowarchchange (
false )
208 , _allowuninstall (
false )
209 , _updatesystem(
false)
210 , _noupdateprovide (
false )
211 , _dosplitprovides (
true )
213 , _ignorealreadyrecommended(
true)
214 , _distupgrade(
false)
215 , _distupgrade_removeunsupported(
false)
220 , _solveSrcPackages(
false)
226 SATResolver::~SATResolver()
234 SATResolver::pool (
void)
const 256 XDEBUG(
"SATSolutionToPool install returns " << item <<
", " << r);
260 XDEBUG(
"SATSolutionToPool upgrade returns " << item <<
", " << r);
264 XDEBUG(
"SATSolutionToPool remove returns " << item <<
", " << r);
285 PoolItemList & items_to_remove_r,
286 PoolItemList & items_to_lock_r,
287 PoolItemList & items_to_keep_r,
288 bool solveSrcPackages_r )
289 : _items_to_install( items_to_install_r )
290 , _items_to_remove( items_to_remove_r )
291 , _items_to_lock( items_to_lock_r )
292 , _items_to_keep( items_to_keep_r )
293 , _solveSrcPackages( solveSrcPackages_r )
295 _items_to_install.clear();
296 _items_to_remove.clear();
297 _items_to_lock.clear();
298 _items_to_keep.clear();
305 bool by_solver = ( itemStatus.isBySolver() || itemStatus.isByApplLow() );
320 switch ( itemStatus.getTransactValue() )
323 itemStatus.isUninstalled() ? _items_to_install.push_back( item_r )
324 : _items_to_remove.push_back( item_r );
break;
356 : is_updated( false )
357 , _installed( installed_r )
383 :solvableQueue (queue)
399 _satSolver = solver_create( _satPool );
400 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
402 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
403 queue_push( &(_jobQueue), 0 );
406 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
407 queue_push( &(_jobQueue), 0 );
410 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
411 queue_push( &(_jobQueue), 0 );
413 if (_distupgrade_removeunsupported) {
414 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
415 queue_push( &(_jobQueue), 0 );
417 solverSetFocus( *_satSolver, _focus );
418 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
419 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
420 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
421 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
423 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
424 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
425 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
426 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
432 #define HACKENV(X,D) solver_set_flag(_satSolver, X, env::HACKENV( #X, D ) ); 442 MIL <<
"Starting solving...." << endl;
444 solver_solve( _satSolver, &(_jobQueue) );
445 MIL <<
"....Solver end" << endl;
449 _result_items_to_install.clear();
450 _result_items_to_remove.clear();
454 queue_init(&decisionq);
455 solver_get_decisionqueue(_satSolver, &decisionq);
456 for (
int i = 0; i < decisionq.count; ++i )
464 _result_items_to_install.push_back( poolItem );
466 queue_free(&decisionq);
472 bool mustCheckObsoletes =
false;
475 if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
482 _pool.byIdentEnd( poolItem ),
484 functor::functorRef<bool,PoolItem> (info) );
490 if ( ! mustCheckObsoletes )
491 mustCheckObsoletes =
true;
493 _result_items_to_remove.push_back (poolItem);
495 if ( mustCheckObsoletes )
497 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
498 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
502 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
508 Queue recommendations;
512 queue_init(&recommendations);
513 queue_init(&suggestions);
514 queue_init(&orphaned);
515 queue_init(&unneeded);
516 solver_get_recommendations(_satSolver, &recommendations, &suggestions, 0);
517 solver_get_orphaned(_satSolver, &orphaned);
518 solver_get_unneeded(_satSolver, &unneeded, 1);
520 for (
int i = 0; i < recommendations.count; ++i )
527 for (
int i = 0; i < suggestions.count; ++i )
533 _problem_items.clear();
535 for (
int i = 0; i < orphaned.count; ++i )
539 _problem_items.push_back( poolItem );
543 for (
int i = 0; i < unneeded.count; ++i )
549 queue_free(&recommendations);
550 queue_free(&suggestions);
551 queue_free(&orphaned);
552 queue_free(&unneeded);
555 Queue flags, solvableQueue;
558 queue_init(&solvableQueue);
563 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
564 solver_trivial_installable(_satSolver, &solvableQueue, &flags );
565 for (
int i = 0; i < solvableQueue.count; i++) {
569 if (flags.elements[i] == -1) {
571 XDEBUG(
"SATSolutionToPool(" << item <<
" ) nonRelevant !");
572 }
else if (flags.elements[i] == 1) {
574 XDEBUG(
"SATSolutionToPool(" << item <<
" ) satisfied !");
575 }
else if (flags.elements[i] == 0) {
577 XDEBUG(
"SATSolutionToPool(" << item <<
" ) broken !");
580 queue_free(&(solvableQueue));
587 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
589 for_( iter2, rpmProviders.
begin(), rpmProviders.
end() ) {
592 MIL <<
"User requirement " << *iter <<
" sets " << poolItem << endl;
597 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
599 for_( iter2, rpmProviders.
begin(), rpmProviders.
end() ) {
602 MIL <<
"User conflict " << *iter <<
" sets " << poolItem << endl;
608 if (solver_problem_count(_satSolver) > 0 )
610 ERR <<
"Solverrun finished with an ERROR" << endl;
619 SATResolver::solverInit(
const PoolItemList & weakItems)
622 MIL <<
"SATResolver::solverInit()" << endl;
626 queue_init( &_jobQueue );
630 SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
631 invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
634 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
635 Id
id = (*iter)->satSolvable().id();
637 ERR <<
"Weaken: " << *iter <<
" not found" << endl;
639 MIL <<
"Weaken dependencies of " << *iter << endl;
640 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
641 queue_push( &(_jobQueue),
id );
646 queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
648 queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
654 const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
655 for (
const auto & locale : trackedLocaleIds.added() )
657 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
661 for (
const auto & locale : trackedLocaleIds.removed() )
663 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS );
668 for (
const sat::Solvable & solv : myPool().multiversionList() )
670 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
671 queue_push( &(_jobQueue), solv.id() );
680 if ( _protectPTFs ) {
682 if ( solv.isSystem() ) {
683 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
684 queue_push( &(_jobQueue), solv.id() );
690 ::pool_add_userinstalled_jobs(_satPool,
sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
696 MIL <<
"Checking droplists ..." << endl;
702 if ( (*it)->onSystem() )
709 dumpRangeLine(
MIL <<
"Droplist for " << (*it)->candidateObj() <<
": " << droplist.size() <<
" ", droplist.begin(), droplist.end() ) << endl;
710 for_( cap, droplist.begin(), droplist.end() )
712 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
713 queue_push( &_jobQueue, cap->id() );
720 MIL <<
"Droplist processing is disabled." << endl;
726 SATResolver::solverEnd()
731 solver_free(_satSolver);
733 queue_free( &(_jobQueue) );
739 SATResolver::resolvePool(
const CapabilitySet & requires_caps,
741 const PoolItemList & weakItems,
742 const std::set<Repository> & upgradeRepos)
744 MIL <<
"SATResolver::resolvePool()" << endl;
747 solverInit(weakItems);
749 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
750 Id
id = (*iter)->satSolvable().id();
752 ERR <<
"Install: " << *iter <<
" not found" << endl;
754 MIL <<
"Install " << *iter << endl;
755 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
756 queue_push( &(_jobQueue),
id );
760 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
761 Id
id = (*iter)->satSolvable().id();
763 ERR <<
"Delete: " << *iter <<
" not found" << endl;
765 MIL <<
"Delete " << *iter << endl;
766 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
767 queue_push( &(_jobQueue),
id);
771 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
773 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
774 queue_push( &(_jobQueue), iter->get()->repoid );
775 MIL <<
"Upgrade repo " << *iter << endl;
778 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
779 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
780 queue_push( &(_jobQueue), iter->id() );
781 MIL <<
"Requires " << *iter << endl;
784 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
785 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
786 queue_push( &(_jobQueue), iter->id() );
787 MIL <<
"Conflicts " << *iter << endl;
791 setSystemRequirements();
797 bool ret = solving(requires_caps, conflict_caps);
799 (ret?
MIL:
WAR) <<
"SATResolver::resolvePool() done. Ret:" << ret << endl;
806 const PoolItemList & weakItems)
808 MIL <<
"SATResolver::resolvQueue()" << endl;
811 solverInit(weakItems);
814 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
815 (*iter)->addRule(_jobQueue);
819 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
820 Id
id = (*iter)->satSolvable().id();
822 ERR <<
"Install: " << *iter <<
" not found" << endl;
824 MIL <<
"Install " << *iter << endl;
825 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
826 queue_push( &(_jobQueue),
id );
829 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
831 MIL <<
"Delete " << *iter << ident << endl;
832 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME |
MAYBE_CLEANDEPS );
833 queue_push( &(_jobQueue), ident);
837 setSystemRequirements();
843 bool ret = solving();
845 MIL <<
"SATResolver::resolveQueue() done. Ret:" << ret << endl;
850 void SATResolver::doUpdate()
852 MIL <<
"SATResolver::doUpdate()" << endl;
855 solverInit(PoolItemList());
858 setSystemRequirements();
863 _satSolver = solver_create( _satPool );
864 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
866 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
867 queue_push( &(_jobQueue), 0 );
870 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
871 queue_push( &(_jobQueue), 0 );
874 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
875 queue_push( &(_jobQueue), 0 );
877 if (_distupgrade_removeunsupported) {
878 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
879 queue_push( &(_jobQueue), 0 );
881 solverSetFocus( *_satSolver, _focus );
882 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
883 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
884 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
885 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
887 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
888 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
889 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
890 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
895 MIL <<
"Starting solving for update...." << endl;
897 solver_solve( _satSolver, &(_jobQueue) );
898 MIL <<
"....Solver end" << endl;
905 queue_init(&decisionq);
906 solver_get_decisionqueue(_satSolver, &decisionq);
907 for (
int i = 0; i < decisionq.count; i++)
910 p = decisionq.elements[i];
913 if (
sat::Solvable(p).repository().
get() == _satSolver->pool->installed)
920 ERR <<
"id " << p <<
" not found in ZYPP pool." << endl;
923 queue_free(&decisionq);
926 for (
int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
928 if (solver_get_decisionlevel(_satSolver, i) > 0)
936 _pool.byIdentEnd( poolItem ),
938 functor::functorRef<bool,PoolItem> (info) );
946 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
949 MIL <<
"SATResolver::doUpdate() done" << endl;
969 : problemSolution (p)
976 problemSolution->addSingleAction (p, action);
1009 string SATResolver::SATprobleminfoString(Id problem,
string &detail, Id &ignoreId)
1014 Id dep, source, target;
1021 probr = solver_findproblemrule(_satSolver, problem);
1022 switch (solver_ruleinfo(_satSolver, probr, &source, &target, &dep))
1024 case SOLVER_RULE_DISTUPGRADE:
1025 s = mapSolvable (source);
1026 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.
asString().c_str());
1028 case SOLVER_RULE_INFARCH:
1029 s = mapSolvable (source);
1032 case SOLVER_RULE_UPDATE:
1033 s = mapSolvable (source);
1036 case SOLVER_RULE_JOB:
1037 ret =
_(
"conflicting requests");
1039 case SOLVER_RULE_RPM:
1040 ret =
_(
"some dependency problem");
1042 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1043 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
1044 detail +=
_(
"Have you enabled all requested repositories?");
1046 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1047 ret =
str::form (
_(
"package %s does not exist"), pool_dep2str(pool, dep));
1048 detail +=
_(
"Have you enabled all requested repositories?");
1050 case SOLVER_RULE_JOB_UNSUPPORTED:
1051 ret =
_(
"unsupported request");
1053 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1054 ret =
str::form (
_(
"%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1056 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1057 s = mapSolvable (source);
1060 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1062 s = mapSolvable (source);
1063 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.
asString().c_str());
1065 case SOLVER_RULE_RPM_SAME_NAME:
1066 s = mapSolvable (source);
1067 s2 = mapSolvable (target);
1070 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1071 s = mapSolvable (source);
1072 s2 = mapSolvable (target);
1073 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.
asString().c_str(), pool_dep2str(pool, dep), s2.
asString().c_str());
1075 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1076 s = mapSolvable (source);
1077 s2 = mapSolvable (target);
1080 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1081 s = mapSolvable (source);
1082 s2 = mapSolvable (target);
1083 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.
asString().c_str(), pool_dep2str(pool, dep), s2.
asString().c_str());
1085 case SOLVER_RULE_RPM_SELF_CONFLICT:
1086 s = mapSolvable (source);
1087 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.
asString().c_str(), pool_dep2str(pool, dep));
1089 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1091 s = mapSolvable (source);
1096 typedef list<PoolItem> ProviderList;
1097 ProviderList providerlistInstalled, providerlistUninstalled;
1098 for_( iter1, possibleProviders.
begin(), possibleProviders.
end() ) {
1102 for_( iter2, possibleProviders.
begin(), possibleProviders.
end() ) {
1113 providerlistInstalled.push_back(provider1);
1115 providerlistUninstalled.push_back(provider1);
1119 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.
asString().c_str(), pool_dep2str(pool, dep));
1120 if (providerlistInstalled.size() > 0) {
1121 detail +=
_(
"deleted providers: ");
1122 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1123 if (iter == providerlistInstalled.begin())
1129 if (providerlistUninstalled.size() > 0) {
1130 if (detail.size() > 0)
1132 detail +=
_(
"\nuninstallable providers: ");
1135 detail =
_(
"uninstallable providers: ");
1136 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1137 if (iter == providerlistUninstalled.begin())
1157 void removePtf(
sat::Solvable slv_r,
bool showremoveProtectHint_r =
false )
1160 bool applies()
const 1161 {
return not
_ptf.empty(); }
1163 std::string description()
const {
1164 if ( not
_patch.empty() ) {
1167 << (
str::Format(
_(
"%1% is not yet fully integrated into %2%.") ) % printlist(
_ptf) % printlist(
_patch)) << endl
1168 <<
_(
"Typically you want to keep the PTF and choose to not install the maintenance patches.");
1174 const std::string & removeptfCommnd {
str::Format(
"zypper install -- -%1%") % printlist(
_ptf) };
1177 << (
str::Format(
_(
"Removing the installed %1% in this context will remove (not replace!) the included PTF-packages too." ) ) % printlist(
_ptf)) << endl
1178 << (
str::Format(
_(
"The PTF should be removed by calling '%1%'. This will update the included PTF-packages rather than removing them." ) ) % removeptfCommnd) << endl
1179 <<
_(
"Typically you want to keep the PTF or choose to cancel the action.");
1184 << (
str::Format(
_(
"The installed %1% blocks the desired action.") ) % printlist(
_ptf)) << endl
1185 <<
_(
"Typically you want to keep the PTF and choose to cancel the action.");
1189 static std::string printlist(
const std::vector<StoreType> & list_r )
1200 SATResolver::problems ()
1203 if (_satSolver && solver_problem_count(_satSolver)) {
1207 Id problem, solution, element;
1208 sat::Solvable s, sd;
1210 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1211 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1213 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1216 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1217 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1218 MIL <<
"====================================" << endl;
1221 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1222 MIL << whatString << endl;
1223 MIL <<
"------------------------------------" << endl;
1224 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail);
1226 PtfPatchHint ptfPatchHint;
1228 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1230 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1231 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1232 if (p == SOLVER_SOLUTION_JOB) {
1234 what = _jobQueue.elements[rp];
1235 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1237 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1238 s = mapSolvable (what);
1239 PoolItem poolItem = _pool.find (s);
1241 if (pool->installed && s.get()->repo == pool->installed) {
1242 problemSolution->addSingleAction (poolItem, REMOVE);
1243 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.asString().c_str() );
1244 MIL << description << endl;
1245 problemSolution->addDescription (description);
1246 if ( _protectPTFs && s.isPtfMaster() )
1247 ptfPatchHint.removePtf( s, _protectPTFs );
1249 problemSolution->addSingleAction (poolItem, KEEP);
1250 string description =
str::form (
_(
"do not install %s"), s.asString().c_str());
1251 MIL << description << endl;
1252 problemSolution->addDescription (description);
1253 if ( s.isKind<Patch>() )
1254 ptfPatchHint.notInstallPatch( s );
1257 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1261 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1262 s = mapSolvable (what);
1263 PoolItem poolItem = _pool.find (s);
1265 if (pool->installed && s.get()->repo == pool->installed) {
1266 problemSolution->addSingleAction (poolItem, KEEP);
1267 string description =
str::form (
_(
"keep %s"), s.asString().c_str());
1268 MIL << description << endl;
1269 problemSolution->addDescription (description);
1271 problemSolution->addSingleAction (poolItem, UNLOCK);
1272 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1273 MIL << description << endl;
1274 problemSolution->addDescription (description);
1277 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1281 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1283 IdString ident( what );
1284 SolverQueueItemInstall_Ptr install =
1285 new SolverQueueItemInstall(_pool, ident.asString(), false );
1286 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1288 string description =
str::form (
_(
"do not install %s"), ident.c_str() );
1289 MIL << description << endl;
1290 problemSolution->addDescription (description);
1293 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1297 IdString ident( what );
1298 FindPackage info (problemSolution, KEEP);
1300 _pool.byIdentEnd( ident ),
1302 resfilter::ByTransact ()),
1303 functor::functorRef<bool,PoolItem> (info) );
1305 SolverQueueItemDelete_Ptr del =
1306 new SolverQueueItemDelete(_pool, ident.asString(), false );
1307 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1309 string description =
str::form (
_(
"keep %s"), ident.c_str());
1310 MIL << description << endl;
1311 problemSolution->addDescription (description);
1314 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1316 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1317 string description =
"";
1320 if (system_requires.find(Capability(what)) != system_requires.end()) {
1322 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1323 resolverProblem->setDescription(
_(
"This request will break your system!"));
1324 description =
_(
"ignore the warning of a broken system");
1325 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1326 MIL << description << endl;
1327 problemSolution->addFrontDescription (description);
1329 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1330 MIL << description << endl;
1331 problemSolution->addDescription (description);
1335 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1337 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1338 string description =
"";
1341 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1343 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1344 resolverProblem->setDescription(
_(
"This request will break your system!"));
1345 description =
_(
"ignore the warning of a broken system");
1346 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1347 MIL << description << endl;
1348 problemSolution->addFrontDescription (description);
1351 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1352 MIL << description << endl;
1353 problemSolution->addDescription (description);
1357 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1359 s = mapSolvable (what);
1360 PoolItem poolItem = _pool.find (s);
1362 if (pool->installed && s.get()->repo == pool->installed) {
1363 problemSolution->addSingleAction (poolItem, KEEP);
1364 string description =
str::form (
_(
"do not install most recent version of %s"), s.asString().c_str());
1365 MIL << description << endl;
1366 problemSolution->addDescription (description);
1368 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1371 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1376 MIL <<
"- do something different" << endl;
1377 ERR <<
"No valid solution available" << endl;
1380 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1381 s = mapSolvable (rp);
1382 PoolItem poolItem = _pool.find (s);
1383 if (pool->installed && s.get()->repo == pool->installed) {
1384 problemSolution->addSingleAction (poolItem, LOCK);
1385 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.asString().c_str());
1386 MIL << description << endl;
1387 problemSolution->addDescription (description);
1389 problemSolution->addSingleAction (poolItem, INSTALL);
1390 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.asString().c_str());
1391 MIL << description << endl;
1392 problemSolution->addDescription (description);
1394 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1395 s = mapSolvable (rp);
1396 PoolItem poolItem = _pool.find (s);
1397 if (pool->installed && s.get()->repo == pool->installed) {
1398 problemSolution->addSingleAction (poolItem, LOCK);
1399 string description =
str::form (
_(
"keep obsolete %s"), s.asString().c_str());
1400 MIL << description << endl;
1401 problemSolution->addDescription (description);
1403 problemSolution->addSingleAction (poolItem, INSTALL);
1404 string description =
str::form (
_(
"install %s from excluded repository"), s.asString().c_str());
1405 MIL << description << endl;
1406 problemSolution->addDescription (description);
1408 }
else if ( p == SOLVER_SOLUTION_BLACK ) {
1411 s = mapSolvable (rp);
1412 PoolItem poolItem = _pool.find (s);
1414 problemSolution->addSingleAction (poolItem, INSTALL);
1415 std::string description;
1416 if ( s.isRetracted() ) {
1418 description = str::Format(
_(
"install %1% although it has been retracted")) % s.asString();
1419 }
else if ( s.isPtf() ) {
1421 description = str::Format(
_(
"allow to install the PTF %1%")) % s.asString();
1424 description = str::Format(
_(
"install %1% although it is blacklisted")) % s.asString();
1426 MIL << description << endl;
1427 problemSolution->addDescription( description );
1428 }
else if ( p > 0 ) {
1430 s = mapSolvable (p);
1431 PoolItem itemFrom = _pool.find (s);
1436 sd = mapSolvable (rp);
1437 PoolItem itemTo = _pool.find (sd);
1438 if (itemFrom && itemTo) {
1439 problemSolution->addSingleAction (itemTo, INSTALL);
1440 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1442 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1444 string description =
str::form (
_(
"downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1445 MIL << description << endl;
1446 problemSolution->addDescription (description);
1449 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1451 string description =
str::form (
_(
"architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1452 MIL << description << endl;
1453 problemSolution->addDescription (description);
1456 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1458 IdString s_vendor( s.vendor() );
1459 IdString sd_vendor( sd.vendor() );
1460 std::string description;
1462 description = str::Format(
_(
"install %s (with vendor change)\n %s --> %s") )
1463 % sd.asString().c_str()
1464 % ( s_vendor ? s_vendor.c_str() :
" (no vendor) " )
1465 % ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " );
1467 description = str::Format(
_(
"install %1% from vendor %2%\n replacing %3% from vendor %4%") )
1468 % sd.asString() % ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " )
1469 % s.asString() % ( s_vendor ? s_vendor.c_str() :
" (no vendor) " );
1471 MIL << description << endl;
1472 problemSolution->addDescription (description);
1476 string description =
str::form (
_(
"replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1477 MIL << description << endl;
1478 problemSolution->addDescription (description);
1481 ERR << s.asString() <<
" or " << sd.asString() <<
" not found" << endl;
1487 string description =
str::form (
_(
"deinstallation of %s"), s.asString().c_str());
1488 MIL << description << endl;
1489 problemSolution->addDescription (description);
1490 problemSolution->addSingleAction (itemFrom, REMOVE);
1491 if ( s.isPtfMaster() )
1492 ptfPatchHint.removePtf( s );
1498 INT <<
"Unknown solution " << p << endl;
1502 resolverProblem->addSolution (problemSolution,
1503 problemSolution->actionCount() > 1 ?
true :
false);
1504 MIL <<
"------------------------------------" << endl;
1509 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1510 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1511 resolverProblem->addSolution (problemSolution,
1513 MIL <<
"ignore some dependencies of " << item << endl;
1514 MIL <<
"------------------------------------" << endl;
1518 if ( ptfPatchHint.applies() ) {
1519 resolverProblem->setDescription( str::Str() << ptfPatchHint.description() << endl <<
"(" << resolverProblem->description() <<
")" );
1522 resolverProblems.push_back (resolverProblem);
1525 return resolverProblems;
1529 { Resolver( _pool ).applySolutions( solutions ); }
1531 void SATResolver::setLocks()
1533 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1535 if (iter->status().isInstalled()) {
1536 MIL <<
"Lock installed item " << *iter << endl;
1537 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1538 queue_push( &(_jobQueue), ident );
1540 MIL <<
"Lock NOT installed item " << *iter << endl;
1541 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1542 queue_push( &(_jobQueue), ident );
1550 std::set<IdString> unifiedByName;
1551 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1552 IdString ident( (*iter)->satSolvable().ident() );
1553 if ( unifiedByName.insert( ident ).second )
1557 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1558 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1559 queue_push( &(_jobQueue), ident.id() );
1565 void SATResolver::setSystemRequirements()
1567 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1568 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1570 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1571 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1572 queue_push( &(_jobQueue), iter->id() );
1573 MIL <<
"SYSTEM Requires " << *iter << endl;
1576 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1577 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1578 queue_push( &(_jobQueue), iter->id() );
1579 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1587 IdString rpm(
"rpm" );
1588 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1590 if ( (*it)->isSystem() )
1593 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1594 queue_push( &(_jobQueue), archrule.id() );
1605 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1613 ::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.
static const IdString ptfMasterToken
Indicator provides ptf()
const std::ostream & stream() const
A Solvable object within the sat Pool.
Container of Solvable providing a Capability (read only).
PoolItemList & _items_to_remove
Focus on updating requested packages and their dependencies as much as possible.
std::string alias() const
Short unique string to identify a repo.
IdString ident() const
The identifier.
bool isToBeUninstalledDueToUpgrade() const
size_type reposSize() const
Number of repos in Pool.
static ZConfig & instance()
Singleton ctor.
bool isToBeUninstalled() const
ProblemSolutionCombi * problemSolution
ResolverFocus
The resolvers general attitude.
bool operator()(PoolItem p)
bool _showremoveProtectHint
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)
Request the standard behavior (as defined in zypp.conf or 'Job')
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 isKind(const ResKind &kind_r) const
bool multiversionInstall() const
bool setToBeUninstalledDueToUpgrade(TransactByValue causer)
std::vector< StoreType > _patch
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)
::_Solver CSolver
Wrapped libsolv C data type exposed as backdoor.
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)
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\n ", const std::string &sep="\n ", const std::string &sfx="\n", const std::string &extro="}")
Print range defined by iterators (multiline style).
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
const_iterator begin() const
Iterator pointing to the first Solvable.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
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)
Focus on applying as little changes to the installed packages as needed.
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.
bool setToBeUninstalled(TransactByValue causer)
FindPackage(ProblemSolutionCombi *p, const TransactionKind act)
CollectPseudoInstalled(Queue *queue)
Select PoolItem by uninstalled.
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)
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).
bool operator()(PoolItem item)
Combining sat::Solvable and ResStatus.
IdType id() const
Expert backdoor.
static const IdString retractedToken
Indicator provides retracted-patch-package()
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.
Focus on installing the best version of the requested packages.
Container of packages providing ptf()
static const ResStatus toBeUninstalled
bool setToBeUninstalledDueToObsolete()
std::vector< StoreType > _ptf
void setSuggested(bool toVal_r=true)
static ResPool instance()
Singleton ctor.