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 56 #define XDEBUG(x) do { if (base::logger::isExcessive()) XXX << x << std::endl;} while (0) 58 #undef ZYPP_BASE_LOGGER_LOGGROUP 59 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::solver" 80 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
81 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
84 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 1 );
85 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
88 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
89 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 1 );
97 inline sat::Queue collectPseudoInstalled(
const ResPool & pool_r )
100 for (
const PoolItem & pi : pool_r )
108 inline void solverCopyBackWeak(
sat::detail::CSolver & satSolver_r, PoolItemList & orphanedItems_r )
112 sat::Queue recommendations;
113 sat::Queue suggestions;
114 ::solver_get_recommendations( &satSolver_r, recommendations, suggestions, 0 );
116 PoolItem(sat::Solvable(recommendations[i])).status().setRecommended(
true );
118 PoolItem(sat::Solvable(suggestions[i])).status().setSuggested(
true );
121 orphanedItems_r.clear();
123 ::solver_get_orphaned( &satSolver_r, orphaned );
126 PoolItem pi { sat::Solvable(orphaned[i]) };
127 pi.status().setOrphaned(
true );
128 orphanedItems_r.push_back( pi );
133 ::solver_get_unneeded( &satSolver_r, unneeded, 1 );
135 PoolItem(sat::Solvable(unneeded[i])).status().setUnneeded(
true );
140 inline void solverCopyBackValidate(
sat::detail::CSolver & satSolver_r,
const ResPool & pool_r )
142 sat::Queue pseudoItems { collectPseudoInstalled( pool_r ) };
143 if ( ! pseudoItems.empty() )
145 sat::Queue pseudoFlags;
146 ::solver_trivial_installable( &satSolver_r, pseudoItems, pseudoFlags );
150 PoolItem pi { sat::Solvable(pseudoItems[i]) };
151 switch ( pseudoFlags[i] )
153 case 0: pi.status().setBroken();
break;
154 case 1: pi.status().setSatisfied();
break;
155 case -1: pi.status().setNonRelevant();
break;
156 default: pi.status().setUndetermined();
break;
170 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0) 179 IdString(solvable2->vendor) ) ? 0 : 1;
189 if ( ! pseudoItems_r.
empty() )
191 MIL <<
"Establish..." << endl;
193 ::pool_set_custom_vendorcheck( cPool, &
vendorCheck );
199 jobQueue.
push( SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
200 jobQueue.
push( solv.id() );
205 if ( ::solver_solve( cSolver, jobQueue ) != 0 )
206 INT <<
"How can establish fail?" << endl;
208 ::solver_trivial_installable( cSolver, pseudoItems_r, pseudoFlags_r );
213 switch ( pseudoFlags_r[i] )
215 case 0: pi.status().setBroken();
break;
216 case 1: pi.status().setSatisfied();
break;
217 case -1: pi.status().setNonRelevant();
break;
218 default: pi.status().setUndetermined();
break;
221 MIL <<
"Establish DONE" << endl;
224 MIL <<
"Establish not needed." << endl;
230 return std::string();
233 std::string ret( slv.asString() );
234 if ( ! slv.isSystem() )
248 os <<
"<resolver>" << endl;
250 #define OUTS(X) os << " " << #X << "\t= " << solver_get_flag(_satSolver, SOLVER_FLAG_##X) << endl 251 OUTS( ALLOW_DOWNGRADE );
252 OUTS( ALLOW_ARCHCHANGE );
253 OUTS( ALLOW_VENDORCHANGE );
254 OUTS( ALLOW_NAMECHANGE );
255 OUTS( ALLOW_UNINSTALL );
256 OUTS( NO_UPDATEPROVIDE );
257 OUTS( SPLITPROVIDES );
258 OUTS( IGNORE_RECOMMENDED );
259 OUTS( ADD_ALREADY_RECOMMENDED );
260 OUTS( NO_INFARCHCHECK );
261 OUTS( KEEP_EXPLICIT_OBSOLETES );
262 OUTS( BEST_OBEY_POLICY );
263 OUTS( NO_AUTOTARGET );
264 OUTS( DUP_ALLOW_DOWNGRADE );
265 OUTS( DUP_ALLOW_ARCHCHANGE );
266 OUTS( DUP_ALLOW_VENDORCHANGE );
267 OUTS( DUP_ALLOW_NAMECHANGE );
268 OUTS( KEEP_ORPHANS );
269 OUTS( BREAK_ORPHANS );
270 OUTS( YUM_OBSOLETES );
272 os <<
" focus = " << _focus << endl;
273 os <<
" distupgrade = " << _distupgrade << endl;
274 os <<
" distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
275 os <<
" solveSrcPackages = " << _solveSrcPackages << endl;
276 os <<
" cleandepsOnRemove = " << _cleandepsOnRemove << endl;
277 os <<
" fixsystem = " << _fixsystem << endl;
281 return os <<
"<resolver/>" << endl;
291 , _focus ( ZConfig::instance().solver_focus() )
293 , _allowdowngrade ( false )
294 , _allownamechange ( true )
295 , _allowarchchange ( false )
297 , _allowuninstall ( false )
298 , _updatesystem(false)
299 , _noupdateprovide ( false )
300 , _dosplitprovides ( true )
301 , _onlyRequires (ZConfig::instance().solver_onlyRequires())
302 , _ignorealreadyrecommended(true)
303 , _distupgrade(false)
304 , _distupgrade_removeunsupported(false)
309 , _solveSrcPackages(false)
310 , _cleandepsOnRemove(ZConfig::instance().solver_cleandepsOnRemove())
315 SATResolver::~SATResolver()
323 SATResolver::pool (
void)
const 345 XDEBUG(
"SATSolutionToPool install returns " << item <<
", " << r);
349 XDEBUG(
"SATSolutionToPool upgrade returns " << item <<
", " << r);
353 XDEBUG(
"SATSolutionToPool remove returns " << item <<
", " << r);
374 PoolItemList & items_to_remove_r,
375 PoolItemList & items_to_lock_r,
376 PoolItemList & items_to_keep_r,
377 bool solveSrcPackages_r )
378 : _items_to_install( items_to_install_r )
379 , _items_to_remove( items_to_remove_r )
380 , _items_to_lock( items_to_lock_r )
381 , _items_to_keep( items_to_keep_r )
382 , _solveSrcPackages( solveSrcPackages_r )
384 _items_to_install.clear();
385 _items_to_remove.clear();
386 _items_to_lock.clear();
387 _items_to_keep.clear();
394 bool by_solver = ( itemStatus.isBySolver() || itemStatus.isByApplLow() );
409 switch ( itemStatus.getTransactValue() )
412 itemStatus.isUninstalled() ? _items_to_install.push_back( item_r )
413 : _items_to_remove.push_back( item_r );
break;
445 : is_updated( false )
446 , _installed( installed_r )
470 _satSolver = solver_create( _satPool );
471 ::pool_set_custom_vendorcheck( _satPool, &
vendorCheck );
473 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
474 queue_push( &(_jobQueue), 0 );
477 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
478 queue_push( &(_jobQueue), 0 );
481 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
482 queue_push( &(_jobQueue), 0 );
484 if (_distupgrade_removeunsupported) {
485 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
486 queue_push( &(_jobQueue), 0 );
488 solverSetFocus( *_satSolver, _focus );
489 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
490 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
491 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
492 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
494 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
495 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
496 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
497 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED,
false);
498 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires);
507 MIL <<
"Starting solving...." << endl;
509 if ( solver_solve( _satSolver, &(_jobQueue) ) == 0 )
516 if ( _distupgrade_removeunsupported )
517 MIL <<
"Droplist processing not needed. RemoveUnsupported is On." << endl;
519 MIL <<
"Droplist processing is disabled in ZConfig." << endl;
522 bool resolve =
false;
523 MIL <<
"Checking droplists ..." << endl;
526 solver_get_decisionqueue( _satSolver, decisionq );
533 static const Capability productCap {
"product()" };
534 if ( slv && slv.provides().matches( productCap ) )
536 CapabilitySet droplist { slv.valuesOfNamespace(
"weakremover" ) };
537 MIL <<
"Droplist for " << slv <<
": size " << droplist.size() << endl;
538 if ( !droplist.empty() )
540 for (
const auto & cap : droplist )
542 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
543 queue_push( &_jobQueue, cap.id() );
546 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
547 queue_push( &(_jobQueue),
id );
553 solver_solve( _satSolver, &(_jobQueue) );
557 MIL <<
"....Solver end" << endl;
561 _result_items_to_install.clear();
562 _result_items_to_remove.clear();
566 queue_init(&decisionq);
567 solver_get_decisionqueue(_satSolver, &decisionq);
568 for (
int i = 0; i < decisionq.count; ++i )
570 Id p = decisionq.elements[i];
575 if ( ! slv || slv.isSystem() )
578 PoolItem poolItem( slv );
580 _result_items_to_install.push_back( poolItem );
582 queue_free(&decisionq);
586 if ( systemRepo && ! systemRepo.solvablesEmpty() )
588 bool mustCheckObsoletes =
false;
589 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
591 if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
595 CheckIfUpdate info( *it );
596 PoolItem poolItem( *it );
598 _pool.byIdentEnd( poolItem ),
599 resfilter::ByUninstalled(),
600 functor::functorRef<bool,PoolItem> (info) );
602 if (info.is_updated) {
606 if ( ! mustCheckObsoletes )
607 mustCheckObsoletes =
true;
609 _result_items_to_remove.push_back (poolItem);
611 if ( mustCheckObsoletes )
613 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
614 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
616 ResStatus & status( it->status() );
618 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
619 status.setToBeUninstalledDueToObsolete();
626 solverCopyBackWeak( *_satSolver, _problem_items );
627 solverCopyBackValidate( *_satSolver, _pool );
632 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
633 sat::WhatProvides rpmProviders(*iter);
634 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
635 PoolItem poolItem(*iter2);
636 if (poolItem.status().isToBeInstalled()) {
637 MIL <<
"User requirement " << *iter <<
" sets " << poolItem << endl;
642 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
643 sat::WhatProvides rpmProviders(*iter);
644 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
645 PoolItem poolItem(*iter2);
646 if (poolItem.status().isToBeUninstalled()) {
647 MIL <<
"User conflict " << *iter <<
" sets " << poolItem << endl;
653 if (solver_problem_count(_satSolver) > 0 )
655 ERR <<
"Solverrun finished with an ERROR" << endl;
664 SATResolver::solverInit(
const PoolItemList & weakItems)
667 MIL <<
"SATResolver::solverInit()" << endl;
671 queue_init( &_jobQueue );
675 SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
676 invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
679 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
680 Id
id = (*iter)->satSolvable().id();
682 ERR <<
"Weaken: " << *iter <<
" not found" << endl;
684 MIL <<
"Weaken dependencies of " << *iter << endl;
685 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
686 queue_push( &(_jobQueue),
id );
691 queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
693 queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
699 const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
702 for (
const auto & locale : trackedLocaleIds.added() )
704 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
708 for (
const auto & locale : trackedLocaleIds.removed() )
710 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS );
716 for (
const sat::Solvable & solv : myPool().multiversionList() )
718 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
719 queue_push( &(_jobQueue), solv.id() );
722 ::pool_add_userinstalled_jobs(_satPool,
sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
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,
false);
891 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires);
896 MIL <<
"Starting solving for update...." << endl;
898 solver_solve( _satSolver, &(_jobQueue) );
899 MIL <<
"....Solver end" << endl;
906 queue_init(&decisionq);
907 solver_get_decisionqueue(_satSolver, &decisionq);
908 for (
int i = 0; i < decisionq.count; i++)
910 Id p = decisionq.elements[i];
915 if ( ! solv || solv.isSystem() )
920 queue_free(&decisionq);
923 for (
int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
925 if (solver_get_decisionlevel(_satSolver, i) > 0)
928 PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
931 CheckIfUpdate info( (sat::Solvable(i)) );
933 _pool.byIdentEnd( poolItem ),
934 resfilter::ByUninstalled(),
935 functor::functorRef<bool,PoolItem> (info) );
937 if (info.is_updated) {
943 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
949 solverCopyBackWeak( *_satSolver, _problem_items );
950 solverCopyBackValidate( *_satSolver, _pool );
952 MIL <<
"SATResolver::doUpdate() done" << endl;
972 : problemSolution (p)
979 problemSolution->addSingleAction (p, action);
1012 std::vector<std::string> SATResolver::SATgetCompleteProblemInfoStrings ( Id problem )
1014 std::vector<std::string> ret;
1015 sat::Queue problems;
1016 solver_findallproblemrules( _satSolver, problem, problems );
1022 SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1023 if ( ruleClass != SolverRuleinfo::SOLVER_RULE_UPDATE && ruleClass != SolverRuleinfo::SOLVER_RULE_JOB ) {
1029 SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1030 if ( nobad && ( ruleClass == SolverRuleinfo::SOLVER_RULE_UPDATE || ruleClass == SolverRuleinfo::SOLVER_RULE_JOB ) ) {
1036 std::string pInfo = SATproblemRuleInfoString( problems[i], detail, ignore );
1039 if ( std::find( ret.begin(), ret.end(), pInfo ) == ret.end() )
1040 ret.push_back( pInfo );
1045 string SATResolver::SATprobleminfoString(Id problem,
string &detail, Id &ignoreId)
1049 Id probr = solver_findproblemrule(_satSolver, problem);
1050 return SATproblemRuleInfoString( probr, detail, ignoreId );
1053 std::string SATResolver::SATproblemRuleInfoString (Id probr, std::string &detail, Id &ignoreId)
1057 Id dep, source, target;
1058 SolverRuleinfo type = solver_ruleinfo(_satSolver, probr, &source, &target, &dep);
1062 sat::Solvable s = mapSolvable( source );
1063 sat::Solvable s2 = mapSolvable( target );
1070 case SOLVER_RULE_DISTUPGRADE:
1071 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.asString().c_str());
1073 case SOLVER_RULE_INFARCH:
1074 ret =
str::form (
_(
"%s has inferior architecture"), s.asString().c_str());
1076 case SOLVER_RULE_UPDATE:
1077 ret =
str::form (
_(
"problem with installed package %s"), s.asString().c_str());
1079 case SOLVER_RULE_JOB:
1080 ret =
_(
"conflicting requests");
1082 case SOLVER_RULE_PKG:
1083 ret =
_(
"some dependency problem");
1085 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1086 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
1087 detail +=
_(
"Have you enabled all requested repositories?");
1089 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1090 ret =
str::form (
_(
"package %s does not exist"), pool_dep2str(pool, dep));
1091 detail +=
_(
"Have you enabled all requested repositories?");
1093 case SOLVER_RULE_JOB_UNSUPPORTED:
1094 ret =
_(
"unsupported request");
1096 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1097 ret =
str::form (
_(
"%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1099 case SOLVER_RULE_PKG_NOT_INSTALLABLE:
1100 ret =
str::form (
_(
"%s is not installable"), s.asString().c_str());
1102 case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
1104 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1106 case SOLVER_RULE_PKG_SAME_NAME:
1107 ret =
str::form (
_(
"cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1109 case SOLVER_RULE_PKG_CONFLICTS:
1110 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1112 case SOLVER_RULE_PKG_OBSOLETES:
1113 ret =
str::form (
_(
"%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1115 case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
1116 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1118 case SOLVER_RULE_PKG_SELF_CONFLICT:
1119 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1121 case SOLVER_RULE_PKG_REQUIRES: {
1123 Capability cap(dep);
1124 sat::WhatProvides possibleProviders(cap);
1127 typedef list<PoolItem> ProviderList;
1128 ProviderList providerlistInstalled, providerlistUninstalled;
1129 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1133 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1136 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1137 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1143 if (provider1.status().isInstalled())
1144 providerlistInstalled.push_back(provider1);
1146 providerlistUninstalled.push_back(provider1);
1150 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1151 if (providerlistInstalled.size() > 0) {
1152 detail +=
_(
"deleted providers: ");
1153 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1154 if (iter == providerlistInstalled.begin())
1160 if (providerlistUninstalled.size() > 0) {
1161 if (detail.size() > 0)
1162 detail +=
_(
"\nnot installable providers: ");
1164 detail =
_(
"not installable providers: ");
1165 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1166 if (iter == providerlistUninstalled.begin())
1175 DBG <<
"Unknown rule type(" << type <<
") going to query libsolv for rule information." << endl;
1176 ret =
str::asString( ::solver_problemruleinfo2str( _satSolver, type, static_cast<Id>(s.id()), static_cast<Id>(s2.id()), dep ) );
1184 SATResolver::problems ()
1187 if (_satSolver && solver_problem_count(_satSolver)) {
1191 Id problem, solution, element;
1192 sat::Solvable s, sd;
1194 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1195 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1197 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1200 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1201 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1202 MIL <<
"====================================" << endl;
1205 string whatString = SATprobleminfoString (problem,detail,ignoreId);
1206 MIL << whatString << endl;
1207 MIL <<
"------------------------------------" << endl;
1208 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail, SATgetCompleteProblemInfoStrings( problem ));
1211 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1213 ProblemSolutionCombi *problemSolution =
new ProblemSolutionCombi;
1214 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1215 if (p == SOLVER_SOLUTION_JOB) {
1217 what = _jobQueue.elements[rp];
1218 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1220 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1221 s = mapSolvable (what);
1222 PoolItem poolItem = _pool.find (s);
1224 if (pool->installed && s.get()->repo == pool->installed) {
1225 problemSolution->addSingleAction (poolItem, REMOVE);
1226 string description =
str::form (
_(
"remove lock to allow removal of %s"), s.asString().c_str() );
1227 MIL << description << endl;
1228 problemSolution->addDescription (description);
1230 problemSolution->addSingleAction (poolItem, KEEP);
1231 string description =
str::form (
_(
"do not install %s"), s.asString().c_str());
1232 MIL << description << endl;
1233 problemSolution->addDescription (description);
1236 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1240 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1241 s = mapSolvable (what);
1242 PoolItem poolItem = _pool.find (s);
1244 if (pool->installed && s.get()->repo == pool->installed) {
1245 problemSolution->addSingleAction (poolItem, KEEP);
1246 string description =
str::form (
_(
"keep %s"), s.asString().c_str());
1247 MIL << description << endl;
1248 problemSolution->addDescription (description);
1250 problemSolution->addSingleAction (poolItem, UNLOCK);
1251 string description =
str::form (
_(
"remove lock to allow installation of %s"),
itemToString( poolItem ).c_str());
1252 MIL << description << endl;
1253 problemSolution->addDescription (description);
1256 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1260 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1263 SolverQueueItemInstall_Ptr install =
1264 new SolverQueueItemInstall(_pool, ident.asString(), false );
1265 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1267 string description =
str::form (
_(
"do not install %s"), ident.c_str() );
1268 MIL << description << endl;
1269 problemSolution->addDescription (description);
1272 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1277 FindPackage info (problemSolution, KEEP);
1279 _pool.byIdentEnd( ident ),
1281 resfilter::ByTransact ()),
1282 functor::functorRef<bool,PoolItem> (info) );
1284 SolverQueueItemDelete_Ptr del =
1285 new SolverQueueItemDelete(_pool, ident.asString(), false );
1286 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1288 string description =
str::form (
_(
"keep %s"), ident.c_str());
1289 MIL << description << endl;
1290 problemSolution->addDescription (description);
1293 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1295 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1296 string description =
"";
1299 if (system_requires.find(Capability(what)) != system_requires.end()) {
1301 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1302 resolverProblem->setDescription(
_(
"This request will break your system!"));
1303 description =
_(
"ignore the warning of a broken system");
1304 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1305 MIL << description << endl;
1306 problemSolution->addFrontDescription (description);
1308 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1309 MIL << description << endl;
1310 problemSolution->addDescription (description);
1314 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1316 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1317 string description =
"";
1320 if (system_conflicts.find(Capability(what)) != system_conflicts.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(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1326 MIL << description << endl;
1327 problemSolution->addFrontDescription (description);
1330 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1331 MIL << description << endl;
1332 problemSolution->addDescription (description);
1336 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1338 s = mapSolvable (what);
1339 PoolItem poolItem = _pool.find (s);
1341 if (pool->installed && s.get()->repo == pool->installed) {
1342 problemSolution->addSingleAction (poolItem, KEEP);
1343 string description =
str::form (
_(
"do not install most recent version of %s"), s.asString().c_str());
1344 MIL << description << endl;
1345 problemSolution->addDescription (description);
1347 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1350 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1355 MIL <<
"- do something different" << endl;
1356 ERR <<
"No valid solution available" << endl;
1359 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1360 s = mapSolvable (rp);
1361 PoolItem poolItem = _pool.find (s);
1362 if (pool->installed && s.get()->repo == pool->installed) {
1363 problemSolution->addSingleAction (poolItem, LOCK);
1364 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.asString().c_str());
1365 MIL << description << endl;
1366 problemSolution->addDescription (description);
1368 problemSolution->addSingleAction (poolItem, INSTALL);
1369 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.asString().c_str());
1370 MIL << description << endl;
1371 problemSolution->addDescription (description);
1373 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1374 s = mapSolvable (rp);
1375 PoolItem poolItem = _pool.find (s);
1376 if (pool->installed && s.get()->repo == pool->installed) {
1377 problemSolution->addSingleAction (poolItem, LOCK);
1378 string description =
str::form (
_(
"keep obsolete %s"), s.asString().c_str());
1379 MIL << description << endl;
1380 problemSolution->addDescription (description);
1382 problemSolution->addSingleAction (poolItem, INSTALL);
1383 string description =
str::form (
_(
"install %s from excluded repository"), s.asString().c_str());
1384 MIL << description << endl;
1385 problemSolution->addDescription (description);
1387 }
else if ( p == SOLVER_SOLUTION_BLACK ) {
1390 s = mapSolvable (rp);
1391 PoolItem poolItem = _pool.find (s);
1393 problemSolution->addSingleAction (poolItem, INSTALL);
1395 if ( s.isRetracted() ) {
1397 description = str::Format(
_(
"install %1% although it has been retracted")) % s.asString();
1398 }
else if ( s.isPtf() ) {
1400 description = str::Format(
_(
"allow to install the PTF %1%")) % s.asString();
1403 description = str::Format(
_(
"install %1% although it is blacklisted")) % s.asString();
1405 MIL << description << endl;
1406 problemSolution->addDescription( description );
1407 }
else if ( p > 0 ) {
1409 s = mapSolvable (p);
1410 PoolItem itemFrom = _pool.find (s);
1415 sd = mapSolvable (rp);
1416 PoolItem itemTo = _pool.find (sd);
1417 if (itemFrom && itemTo) {
1418 problemSolution->addSingleAction (itemTo, INSTALL);
1419 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1421 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1423 string description =
str::form (
_(
"downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1424 MIL << description << endl;
1425 problemSolution->addDescription (description);
1428 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1430 string description =
str::form (
_(
"architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1431 MIL << description << endl;
1432 problemSolution->addDescription (description);
1435 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1439 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1440 sd.asString().c_str(),
1441 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1442 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1443 MIL << description << endl;
1444 problemSolution->addDescription (description);
1448 string description =
str::form (
_(
"replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1449 MIL << description << endl;
1450 problemSolution->addDescription (description);
1453 ERR << s.asString() <<
" or " << sd.asString() <<
" not found" << endl;
1459 string description =
str::form (
_(
"deinstallation of %s"), s.asString().c_str());
1460 MIL << description << endl;
1461 problemSolution->addDescription (description);
1462 problemSolution->addSingleAction (itemFrom, REMOVE);
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 resolverProblems.push_back (resolverProblem);
1491 return resolverProblems;
1495 { Resolver( _pool ).applySolutions( solutions ); }
1497 void SATResolver::setLocks()
1502 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1504 if (iter->status().isInstalled()) {
1506 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1507 queue_push( &(_jobQueue), ident );
1510 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE |
MAYBE_CLEANDEPS );
1511 queue_push( &(_jobQueue), ident );
1514 MIL <<
"Locked " << icnt <<
" installed items and " << acnt <<
" NOT installed items." << endl;
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;
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 );
std::list< ProblemSolution_Ptr > ProblemSolutionList
int IdType
Generic Id type.
A Solvable object within the sat Pool.
PoolItemList & _items_to_remove
Focus on updating requested packages and their dependencies as much as possible.
static ZConfig & instance()
Singleton ctor.
bool isToBeInstalled() const
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings should be treated as the same vendor.
static const IdString ptfToken
Indicator provides ptf()
ProblemSolutionCombi * problemSolution
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
ResolverFocus
The resolvers general attitude.
bool operator()(PoolItem p)
Queue SolvableQueue
Queue with Solvable ids.
ResStatus & status() const
Returns the current status.
static const ResStatus toBeInstalled
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
sat::Solvable buddy() const
Return the buddy we share our status object with.
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
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 ).
std::list< SolverQueueItem_Ptr > SolverQueueItemList
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
static void SATSolutionToPool(PoolItem item, const ResStatus &status, const ResStatus::TransactByValue causer)
bool setToBeUninstalledDueToUpgrade(TransactByValue causer)
static const ResStatus toBeUninstalledDueToUpgrade
std::unary_function< ResObject::constPtr, bool > ResObjectFilterFunctor
void prepare() const
Update housekeeping data if necessary (e.g.
CheckIfUpdate(const sat::Solvable &installed_r)
Repository repository() const
The Repository this Solvable belongs to.
Queue StringQueue
Queue with String ids.
void push(value_type val_r)
Push a value to the end off the Queue.
void establish(sat::Queue &pseudoItems_r, sat::Queue &pseudoFlags_r)
ResPool helper to compute the initial status of Patches etc.
std::list< ResolverProblem_Ptr > ResolverProblemList
static Pool instance()
Singleton ctor.
Commit helper functor distributing PoolItem by status into lists.
bool operator()(const PoolItem &item)
int vendorCheck(sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2)
std::unary_function< PoolItem, bool > PoolItemFilterFunctor
Focus on applying as little changes to the installed packages as needed.
bool multiversionInstall() const
detail::CPool * get() const
Expert backdoor.
PoolItemList & _items_to_lock
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.
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
bool operator()(const PoolItem &item_r)
bool setToBeUninstalled(TransactByValue causer)
FindPackage(ProblemSolutionCombi *p, const TransactionKind act)
Libsolv Id queue wrapper.
PoolItemList & _items_to_keep
bool compareByNVR(const SolvableType< Derived > &lhs, const Solvable &rhs)
std::unordered_set< Capability > CapabilitySet
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
sat::Solvable mapBuddy(sat::Solvable item_r)
PoolItemList & _items_to_install
std::string alias() const
Short unique string to identify a repo.
::s_Solver CSolver
Wrapped libsolv C data type exposed as backdoor.
bool isToBeUninstalled() const
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Chain< TACondition, TBCondition > chain(TACondition conda_r, TBCondition condb_r)
Convenience function for creating a Chain from two conditions conda_r and condb_r.
bool setToBeInstalled(TransactByValue causer)
IMPL_PTR_TYPE(SATResolver)
Combining sat::Solvable and ResStatus.
Pathname systemRoot() const
The target root directory.
static const IdString retractedToken
Indicator provides retracted-patch-package()
bool isKind(const ResKind &kind_r) const
static const VendorAttr & instance()
Singleton.
int invokeOnEach(TIterator begin_r, TIterator end_r, TFilter filter_r, TFunction fnc_r)
Iterate through [begin_r,end_r) and invoke fnc_r on each item that passes filter_r.
std::string itemToString(const PoolItem &item)
Easy-to use interface to the ZYPP dependency resolver.
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Focus on installing the best version of the requested packages.
static const ResStatus toBeUninstalled
bool isToBeUninstalledDueToUpgrade() const
static ResPool instance()
Singleton ctor.