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() );
674 ::pool_add_userinstalled_jobs(_satPool,
sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
680 MIL <<
"Checking droplists ..." << endl;
686 if ( (*it)->onSystem() )
693 dumpRangeLine(
MIL <<
"Droplist for " << (*it)->candidateObj() <<
": " << droplist.size() <<
" ", droplist.begin(), droplist.end() ) << endl;
694 for_( cap, droplist.begin(), droplist.end() )
696 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
697 queue_push( &_jobQueue, cap->id() );
704 MIL <<
"Droplist processing is disabled." << endl;
710 SATResolver::solverEnd()
715 solver_free(_satSolver);
717 queue_free( &(_jobQueue) );
723 SATResolver::resolvePool(
const CapabilitySet & requires_caps,
725 const PoolItemList & weakItems,
726 const std::set<Repository> & upgradeRepos)
728 MIL <<
"SATResolver::resolvePool()" << endl;
731 solverInit(weakItems);
733 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
734 Id
id = (*iter)->satSolvable().id();
736 ERR <<
"Install: " << *iter <<
" not found" << endl;
738 MIL <<
"Install " << *iter << endl;
739 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
740 queue_push( &(_jobQueue),
id );
744 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
745 Id
id = (*iter)->satSolvable().id();
747 ERR <<
"Delete: " << *iter <<
" not found" << endl;
749 MIL <<
"Delete " << *iter << endl;
750 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
751 queue_push( &(_jobQueue),
id);
755 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
757 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
758 queue_push( &(_jobQueue), iter->get()->repoid );
759 MIL <<
"Upgrade repo " << *iter << endl;
762 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
763 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
764 queue_push( &(_jobQueue), iter->id() );
765 MIL <<
"Requires " << *iter << endl;
768 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
769 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
770 queue_push( &(_jobQueue), iter->id() );
771 MIL <<
"Conflicts " << *iter << endl;
775 setSystemRequirements();
781 bool ret = solving(requires_caps, conflict_caps);
783 (ret?
MIL:
WAR) <<
"SATResolver::resolvePool() done. Ret:" << ret << endl;
790 const PoolItemList & weakItems)
792 MIL <<
"SATResolver::resolvQueue()" << endl;
795 solverInit(weakItems);
798 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
799 (*iter)->addRule(_jobQueue);
803 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
804 Id
id = (*iter)->satSolvable().id();
806 ERR <<
"Install: " << *iter <<
" not found" << endl;
808 MIL <<
"Install " << *iter << endl;
809 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
810 queue_push( &(_jobQueue),
id );
813 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
815 MIL <<
"Delete " << *iter << ident << endl;
816 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME |
MAYBE_CLEANDEPS );
817 queue_push( &(_jobQueue), ident);
821 setSystemRequirements();
827 bool ret = solving();
829 MIL <<
"SATResolver::resolveQueue() done. Ret:" << ret << endl;
834 void SATResolver::doUpdate()
836 MIL <<
"SATResolver::doUpdate()" << endl;
839 solverInit(PoolItemList());
842 setSystemRequirements();
847 _satSolver = solver_create( _satPool );
848 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
850 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
851 queue_push( &(_jobQueue), 0 );
854 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
855 queue_push( &(_jobQueue), 0 );
858 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
859 queue_push( &(_jobQueue), 0 );
861 if (_distupgrade_removeunsupported) {
862 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
863 queue_push( &(_jobQueue), 0 );
865 solverSetFocus( *_satSolver, _focus );
866 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
867 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
868 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
869 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
871 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
872 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
873 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
874 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
879 MIL <<
"Starting solving for update...." << endl;
881 solver_solve( _satSolver, &(_jobQueue) );
882 MIL <<
"....Solver end" << endl;
889 queue_init(&decisionq);
890 solver_get_decisionqueue(_satSolver, &decisionq);
891 for (
int i = 0; i < decisionq.count; i++)
894 p = decisionq.elements[i];
897 if (
sat::Solvable(p).repository().
get() == _satSolver->pool->installed)
904 ERR <<
"id " << p <<
" not found in ZYPP pool." << endl;
907 queue_free(&decisionq);
910 for (
int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
912 if (solver_get_decisionlevel(_satSolver, i) > 0)
920 _pool.byIdentEnd( poolItem ),
922 functor::functorRef<bool,PoolItem> (info) );
930 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
933 MIL <<
"SATResolver::doUpdate() done" << endl;
953 : problemSolution (p)
960 problemSolution->addSingleAction (p, action);
993 string SATResolver::SATprobleminfoString(Id problem,
string &detail, Id &ignoreId)
998 Id dep, source, target;
1005 probr = solver_findproblemrule(_satSolver, problem);
1006 switch (solver_ruleinfo(_satSolver, probr, &source, &target, &dep))
1008 case SOLVER_RULE_DISTUPGRADE:
1009 s = mapSolvable (source);
1010 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.
asString().c_str());
1012 case SOLVER_RULE_INFARCH:
1013 s = mapSolvable (source);
1016 case SOLVER_RULE_UPDATE:
1017 s = mapSolvable (source);
1020 case SOLVER_RULE_JOB:
1021 ret =
_(
"conflicting requests");
1023 case SOLVER_RULE_RPM:
1024 ret =
_(
"some dependency problem");
1026 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1027 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
1028 detail +=
_(
"Have you enabled all requested repositories?");
1030 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1031 ret =
str::form (
_(
"package %s does not exist"), pool_dep2str(pool, dep));
1032 detail +=
_(
"Have you enabled all requested repositories?");
1034 case SOLVER_RULE_JOB_UNSUPPORTED:
1035 ret =
_(
"unsupported request");
1037 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1038 ret =
str::form (
_(
"%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1040 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1041 s = mapSolvable (source);
1044 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1046 s = mapSolvable (source);
1047 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.
asString().c_str());
1049 case SOLVER_RULE_RPM_SAME_NAME:
1050 s = mapSolvable (source);
1051 s2 = mapSolvable (target);
1054 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1055 s = mapSolvable (source);
1056 s2 = mapSolvable (target);
1057 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.
asString().c_str(), pool_dep2str(pool, dep), s2.
asString().c_str());
1059 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1060 s = mapSolvable (source);
1061 s2 = mapSolvable (target);
1064 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1065 s = mapSolvable (source);
1066 s2 = mapSolvable (target);
1067 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.
asString().c_str(), pool_dep2str(pool, dep), s2.
asString().c_str());
1069 case SOLVER_RULE_RPM_SELF_CONFLICT:
1070 s = mapSolvable (source);
1071 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.
asString().c_str(), pool_dep2str(pool, dep));
1073 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1075 s = mapSolvable (source);
1080 typedef list<PoolItem> ProviderList;
1081 ProviderList providerlistInstalled, providerlistUninstalled;
1082 for_( iter1, possibleProviders.
begin(), possibleProviders.
end() ) {
1086 for_( iter2, possibleProviders.
begin(), possibleProviders.
end() ) {
1097 providerlistInstalled.push_back(provider1);
1099 providerlistUninstalled.push_back(provider1);
1103 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.
asString().c_str(), pool_dep2str(pool, dep));
1104 if (providerlistInstalled.size() > 0) {
1105 detail +=
_(
"deleted providers: ");
1106 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1107 if (iter == providerlistInstalled.begin())
1113 if (providerlistUninstalled.size() > 0) {
1114 if (detail.size() > 0)
1116 detail +=
_(
"\nuninstallable providers: ");
1119 detail =
_(
"uninstallable providers: ");
1120 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1121 if (iter == providerlistUninstalled.begin())
1138 void notInstallPatch(
sat::Solvable slv_r,
unsigned solution_r )
1144 bool applies()
const 1145 {
return not
_ptf.empty(); }
1147 std::string description()
const {
1148 if ( not
_patch.empty() ) {
1151 << (
str::Format(
_(
"%1% is not yet fully integrated into %2%.") ) % printlist(
_ptf) % printlist(
_patch)) << endl
1152 <<
_(
"Typically you want to keep the PTF and choose to not install the maintenance patches.");
1157 << (
str::Format(
_(
"The installed %1% blocks the desired action.") ) % printlist(
_ptf)) << endl
1158 <<
_(
"Typically you want to keep the PTF and choose to cancel the action.");
1162 static std::string printlist(
const std::vector<StoreType> & list_r )
1172 SATResolver::problems ()
1175 if (_satSolver && solver_problem_count(_satSolver)) {
1179 Id problem, solution, element;
1180 sat::Solvable s, sd;
1182 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1183 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1185 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1188 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1189 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1190 MIL <<
"====================================" << endl;
1193 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1194 MIL << whatString << endl;
1195 MIL <<
"------------------------------------" << endl;
1196 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail);
1198 PtfPatchHint ptfPatchHint;
1200 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1202 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1203 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1204 if (p == SOLVER_SOLUTION_JOB) {
1206 what = _jobQueue.elements[rp];
1207 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1209 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1210 s = mapSolvable (what);
1211 PoolItem poolItem = _pool.find (s);
1213 if (pool->installed && s.get()->repo == pool->installed) {
1214 problemSolution->addSingleAction (poolItem, REMOVE);
1215 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.asString().c_str() );
1216 MIL << description << endl;
1217 problemSolution->addDescription (description);
1219 problemSolution->addSingleAction (poolItem, KEEP);
1220 string description =
str::form (
_(
"do not install %s"), s.asString().c_str());
1221 MIL << description << endl;
1222 problemSolution->addDescription (description);
1223 if ( s.isKind<Patch>() )
1224 ptfPatchHint.notInstallPatch( s, resolverProblem->solutions().size() );
1227 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1231 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1232 s = mapSolvable (what);
1233 PoolItem poolItem = _pool.find (s);
1235 if (pool->installed && s.get()->repo == pool->installed) {
1236 problemSolution->addSingleAction (poolItem, KEEP);
1237 string description =
str::form (
_(
"keep %s"), s.asString().c_str());
1238 MIL << description << endl;
1239 problemSolution->addDescription (description);
1241 problemSolution->addSingleAction (poolItem, UNLOCK);
1242 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1243 MIL << description << endl;
1244 problemSolution->addDescription (description);
1247 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1251 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1253 IdString ident( what );
1254 SolverQueueItemInstall_Ptr install =
1255 new SolverQueueItemInstall(_pool, ident.asString(), false );
1256 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1258 string description =
str::form (
_(
"do not install %s"), ident.c_str() );
1259 MIL << description << endl;
1260 problemSolution->addDescription (description);
1263 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1267 IdString ident( what );
1268 FindPackage info (problemSolution, KEEP);
1270 _pool.byIdentEnd( ident ),
1272 resfilter::ByTransact ()),
1273 functor::functorRef<bool,PoolItem> (info) );
1275 SolverQueueItemDelete_Ptr del =
1276 new SolverQueueItemDelete(_pool, ident.asString(), false );
1277 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1279 string description =
str::form (
_(
"keep %s"), ident.c_str());
1280 MIL << description << endl;
1281 problemSolution->addDescription (description);
1284 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1286 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1287 string description =
"";
1290 if (system_requires.find(Capability(what)) != system_requires.end()) {
1292 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1293 resolverProblem->setDescription(
_(
"This request will break your system!"));
1294 description =
_(
"ignore the warning of a broken system");
1295 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1296 MIL << description << endl;
1297 problemSolution->addFrontDescription (description);
1299 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1300 MIL << description << endl;
1301 problemSolution->addDescription (description);
1305 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1307 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1308 string description =
"";
1311 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1313 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1314 resolverProblem->setDescription(
_(
"This request will break your system!"));
1315 description =
_(
"ignore the warning of a broken system");
1316 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1317 MIL << description << endl;
1318 problemSolution->addFrontDescription (description);
1321 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1322 MIL << description << endl;
1323 problemSolution->addDescription (description);
1327 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1329 s = mapSolvable (what);
1330 PoolItem poolItem = _pool.find (s);
1332 if (pool->installed && s.get()->repo == pool->installed) {
1333 problemSolution->addSingleAction (poolItem, KEEP);
1334 string description =
str::form (
_(
"do not install most recent version of %s"), s.asString().c_str());
1335 MIL << description << endl;
1336 problemSolution->addDescription (description);
1338 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1341 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1346 MIL <<
"- do something different" << endl;
1347 ERR <<
"No valid solution available" << endl;
1350 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1351 s = mapSolvable (rp);
1352 PoolItem poolItem = _pool.find (s);
1353 if (pool->installed && s.get()->repo == pool->installed) {
1354 problemSolution->addSingleAction (poolItem, LOCK);
1355 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.asString().c_str());
1356 MIL << description << endl;
1357 problemSolution->addDescription (description);
1359 problemSolution->addSingleAction (poolItem, INSTALL);
1360 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.asString().c_str());
1361 MIL << description << endl;
1362 problemSolution->addDescription (description);
1364 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1365 s = mapSolvable (rp);
1366 PoolItem poolItem = _pool.find (s);
1367 if (pool->installed && s.get()->repo == pool->installed) {
1368 problemSolution->addSingleAction (poolItem, LOCK);
1369 string description =
str::form (
_(
"keep obsolete %s"), s.asString().c_str());
1370 MIL << description << endl;
1371 problemSolution->addDescription (description);
1373 problemSolution->addSingleAction (poolItem, INSTALL);
1374 string description =
str::form (
_(
"install %s from excluded repository"), s.asString().c_str());
1375 MIL << description << endl;
1376 problemSolution->addDescription (description);
1378 }
else if ( p == SOLVER_SOLUTION_BLACK ) {
1381 s = mapSolvable (rp);
1382 PoolItem poolItem = _pool.find (s);
1384 problemSolution->addSingleAction (poolItem, INSTALL);
1385 std::string description;
1386 if ( s.isRetracted() ) {
1388 description = str::Format(
_(
"install %1% although it has been retracted")) % s.asString();
1389 }
else if ( s.isPtf() ) {
1391 description = str::Format(
_(
"allow to install the PTF %1%")) % s.asString();
1394 description = str::Format(
_(
"install %1% although it is blacklisted")) % s.asString();
1396 MIL << description << endl;
1397 problemSolution->addDescription( description );
1398 }
else if ( p > 0 ) {
1400 s = mapSolvable (p);
1401 PoolItem itemFrom = _pool.find (s);
1406 sd = mapSolvable (rp);
1407 PoolItem itemTo = _pool.find (sd);
1408 if (itemFrom && itemTo) {
1409 problemSolution->addSingleAction (itemTo, INSTALL);
1410 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1412 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1414 string description =
str::form (
_(
"downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1415 MIL << description << endl;
1416 problemSolution->addDescription (description);
1419 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1421 string description =
str::form (
_(
"architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1422 MIL << description << endl;
1423 problemSolution->addDescription (description);
1426 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1428 IdString s_vendor( s.vendor() );
1429 IdString sd_vendor( sd.vendor() );
1430 std::string description;
1432 description = str::Format(
_(
"install %s (with vendor change)\n %s --> %s") )
1433 % sd.asString().c_str()
1434 % ( s_vendor ? s_vendor.c_str() :
" (no vendor) " )
1435 % ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " );
1437 description = str::Format(
_(
"install %1% from vendor %2%\n replacing %3% from vendor %4%") )
1438 % sd.asString() % ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " )
1439 % s.asString() % ( s_vendor ? s_vendor.c_str() :
" (no vendor) " );
1441 MIL << description << endl;
1442 problemSolution->addDescription (description);
1446 string description =
str::form (
_(
"replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1447 MIL << description << endl;
1448 problemSolution->addDescription (description);
1451 ERR << s.asString() <<
" or " << sd.asString() <<
" not found" << endl;
1457 string description =
str::form (
_(
"deinstallation of %s"), s.asString().c_str());
1458 MIL << description << endl;
1459 problemSolution->addDescription (description);
1460 problemSolution->addSingleAction (itemFrom, REMOVE);
1461 if ( s.isPtfMaster() )
1462 ptfPatchHint.removePtf( s, resolverProblem->solutions().size() );
1468 INT <<
"Unknown solution " << p << endl;
1472 resolverProblem->addSolution (problemSolution,
1473 problemSolution->actionCount() > 1 ?
true :
false);
1474 MIL <<
"------------------------------------" << endl;
1479 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1480 ProblemSolutionIgnore *problemSolution =
new ProblemSolutionIgnore(item);
1481 resolverProblem->addSolution (problemSolution,
1483 MIL <<
"ignore some dependencies of " << item << endl;
1484 MIL <<
"------------------------------------" << endl;
1488 if ( ptfPatchHint.applies() ) {
1489 resolverProblem->setDescription( str::Str() << ptfPatchHint.description() << endl <<
"(" << resolverProblem->description() <<
")" );
1492 resolverProblems.push_back (resolverProblem);
1495 return resolverProblems;
1499 { Resolver( _pool ).applySolutions( solutions ); }
1501 void SATResolver::setLocks()
1503 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1505 if (iter->status().isInstalled()) {
1506 MIL <<
"Lock installed item " << *iter << endl;
1507 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1508 queue_push( &(_jobQueue), ident );
1510 MIL <<
"Lock NOT installed item " << *iter << endl;
1511 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1512 queue_push( &(_jobQueue), ident );
1520 std::set<IdString> unifiedByName;
1521 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1522 IdString ident( (*iter)->satSolvable().ident() );
1523 if ( unifiedByName.insert( ident ).second )
1527 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1528 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK |
MAYBE_CLEANDEPS );
1529 queue_push( &(_jobQueue), ident.id() );
1535 void SATResolver::setSystemRequirements()
1537 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1538 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1540 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1541 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1542 queue_push( &(_jobQueue), iter->id() );
1543 MIL <<
"SYSTEM Requires " << *iter << endl;
1546 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1547 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES |
MAYBE_CLEANDEPS );
1548 queue_push( &(_jobQueue), iter->id() );
1549 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1557 IdString rpm(
"rpm" );
1558 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1560 if ( (*it)->isSystem() )
1563 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1564 queue_push( &(_jobQueue), archrule.id() );
1575 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1583 ::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
static ZConfig & instance()
Singleton ctor.
bool isToBeUninstalled() const
ProblemSolutionCombi * problemSolution
ResolverFocus
The resolvers general attitude.
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)
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.
static const ResStatus toBeUninstalled
bool setToBeUninstalledDueToObsolete()
std::vector< StoreType > _ptf
void setSuggested(bool toVal_r=true)
static ResPool instance()
Singleton ctor.