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>
71 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0)
77 int vendorCheck( Pool *pool, Solvable *solvable1, Solvable *solvable2 )
80 IdString(solvable2->vendor) ) ? 0 : 1;
90 std::string ret( slv.asString() );
91 if ( ! slv.isSystem() )
104 INT <<
"id " << id_r <<
" not found in ZYPP pool." << endl;
113 os <<
"<resolver>" << endl;
117 os <<
" allowdowngrade = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_DOWNGRADE) << endl;
118 os <<
" allowarchchange = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_ARCHCHANGE) << endl;
119 os <<
" allowvendorchange = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_VENDORCHANGE) << endl;
120 os <<
" allowuninstall = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_UNINSTALL) << endl;
121 os <<
" noupdateprovide = " << solver_get_flag(_solv, SOLVER_FLAG_NO_UPDATEPROVIDE) << endl;
122 os <<
" dosplitprovides = " << solver_get_flag(_solv, SOLVER_FLAG_SPLITPROVIDES) << endl;
123 os <<
" onlyRequires = " << solver_get_flag(_solv, SOLVER_FLAG_IGNORE_RECOMMENDED) << endl;
124 os <<
" ignorealreadyrecommended = " << !solver_get_flag(_solv, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED) << endl;
125 os <<
" distupgrade = " << _distupgrade << endl;
126 os <<
" distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
127 os <<
" solveSrcPackages = " << _solveSrcPackages << endl;
128 os <<
" cleandepsOnRemove = " << _cleandepsOnRemove << endl;
132 return os <<
"<resolver/>" << endl;
142 , _allowdowngrade(false)
143 , _allowarchchange(false)
144 , _allowvendorchange(
ZConfig::instance().solver_allowVendorChange())
145 , _allowuninstall(false)
146 , _updatesystem(false)
147 , _noupdateprovide(false)
148 , _dosplitprovides(false)
149 , _onlyRequires(
ZConfig::instance().solver_onlyRequires())
150 , _ignorealreadyrecommended(false)
151 , _distupgrade(false)
152 , _distupgrade_removeunsupported(false)
153 , _solveSrcPackages(false)
154 , _cleandepsOnRemove(
ZConfig::instance().solver_cleandepsOnRemove())
229 for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
247 for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
285 _XDEBUG(
"SATSolutionToPool install returns " << item <<
", " << r);
289 _XDEBUG(
"SATSolutionToPool upgrade returns " << item <<
", " << r);
293 _XDEBUG(
"SATSolutionToPool remove returns " << item <<
", " << r);
427 queue_push( &(
_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
431 queue_push( &(
_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
435 queue_push( &(
_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
439 queue_push( &(
_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
454 MIL <<
"Starting solving...." << endl;
457 MIL <<
"....Solver end" << endl;
466 queue_init(&decisionq);
467 solver_get_decisionqueue(
_solv, &decisionq);
468 for (
int i = 0; i < decisionq.count; ++i )
478 queue_free(&decisionq);
484 bool mustCheckObsoletes =
false;
487 if (solver_get_decisionlevel(
_solv, it->id()) > 0)
496 functor::functorRef<bool,PoolItem> (info) );
502 if ( ! mustCheckObsoletes )
503 mustCheckObsoletes =
true;
507 if ( mustCheckObsoletes )
510 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
514 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
520 Queue recommendations;
524 queue_init(&recommendations);
525 queue_init(&suggestions);
526 queue_init(&orphaned);
527 queue_init(&unneeded);
528 solver_get_recommendations(
_solv, &recommendations, &suggestions, 0);
529 solver_get_orphaned(
_solv, &orphaned);
530 solver_get_unneeded(
_solv, &unneeded, 1);
532 for (
int i = 0; i < recommendations.count; ++i )
539 for (
int i = 0; i < suggestions.count; ++i )
547 for (
int i = 0; i < orphaned.count; ++i )
555 for (
int i = 0; i < unneeded.count; ++i )
561 queue_free(&recommendations);
562 queue_free(&suggestions);
563 queue_free(&orphaned);
564 queue_free(&unneeded);
567 Queue flags, solvableQueue;
570 queue_init(&solvableQueue);
575 functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
576 solver_trivial_installable(
_solv, &solvableQueue, &flags );
577 for (
int i = 0; i < solvableQueue.count; i++) {
581 if (flags.elements[i] == -1) {
583 _XDEBUG(
"SATSolutionToPool(" << item <<
" ) nonRelevant !");
584 }
else if (flags.elements[i] == 1) {
586 _XDEBUG(
"SATSolutionToPool(" << item <<
" ) satisfied !");
587 }
else if (flags.elements[i] == 0) {
589 _XDEBUG(
"SATSolutionToPool(" << item <<
" ) broken !");
592 queue_free(&(solvableQueue));
599 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
601 for_( iter2, rpmProviders.
begin(), rpmProviders.
end() ) {
604 MIL <<
"User requirement " << *iter <<
" sets " << poolItem << endl;
609 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
611 for_( iter2, rpmProviders.
begin(), rpmProviders.
end() ) {
614 MIL <<
"User conflict " << *iter <<
" sets " << poolItem << endl;
620 if (solver_problem_count(
_solv) > 0 )
622 ERR <<
"Solverrun finished with an ERROR" << endl;
635 MIL <<
"SATResolver::solverInit()" << endl;
647 functor::functorRef<bool,PoolItem>(info) );
649 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
650 Id
id = (*iter)->satSolvable().id();
652 ERR <<
"Weaken: " << *iter <<
" not found" << endl;
654 MIL <<
"Weaken dependencies of " << *iter << endl;
655 queue_push( &(
_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
662 queue_push( &(
_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE_NAME );
671 queue_push( &(
_jobQueue), SOLVER_USERINSTALLED | SOLVER_SOLVABLE_NAME );
680 MIL <<
"Checking droplists ..." << endl;
686 if ( (*it)->onSystem() )
689 if ( ! prodCand || (*it)->identicalInstalledCandidate() )
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 );
704 MIL <<
"Droplist processing is disabled." << endl;
726 const std::set<Repository> & upgradeRepos)
728 MIL <<
"SATResolver::resolvePool()" << endl;
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 );
745 Id
id = (*iter)->satSolvable().id();
747 ERR <<
"Delete: " << *iter <<
" not found" << endl;
749 MIL <<
"Delete " << *iter << endl;
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 );
765 MIL <<
"Requires " << *iter << endl;
768 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
771 MIL <<
"Conflicts " << *iter << endl;
781 bool ret =
solving(requires_caps, conflict_caps);
783 (ret?
MIL:
WAR) <<
"SATResolver::resolvePool() done. Ret:" << ret << endl;
792 MIL <<
"SATResolver::resolvQueue()" << endl;
798 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.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 );
815 MIL <<
"Delete " << *iter << ident << endl;
829 MIL <<
"SATResolver::resolveQueue() done. Ret:" << ret << endl;
836 MIL <<
"SATResolver::doUpdate()" << endl;
850 queue_push( &(
_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
854 queue_push( &(
_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
858 queue_push( &(
_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
862 queue_push( &(
_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
877 MIL <<
"Starting solving for update...." << endl;
880 MIL <<
"....Solver end" << endl;
887 queue_init(&decisionq);
888 solver_get_decisionqueue(
_solv, &decisionq);
889 for (
int i = 0; i < decisionq.count; i++)
892 p = decisionq.elements[i];
902 ERR <<
"id " << p <<
" not found in ZYPP pool." << endl;
905 queue_free(&decisionq);
908 for (
int i =
_solv->pool->installed->start; i < _solv->
pool->installed->start +
_solv->pool->installed->nsolvables; i++)
910 if (solver_get_decisionlevel(
_solv, i) > 0)
920 functor::functorRef<bool,PoolItem> (info) );
928 ERR <<
"id " << i <<
" not found in ZYPP pool." << endl;
931 MIL <<
"SATResolver::doUpdate() done" << endl;
996 Id dep, source, target;
1000 probr = solver_findproblemrule(
_solv, problem);
1001 switch (solver_ruleinfo(
_solv, probr, &source, &target, &dep))
1003 case SOLVER_RULE_DISTUPGRADE:
1005 ret =
str::form (
_(
"%s does not belong to a distupgrade repository"), s.
asString().c_str());
1007 case SOLVER_RULE_INFARCH:
1011 case SOLVER_RULE_UPDATE:
1015 case SOLVER_RULE_JOB:
1016 ret =
_(
"conflicting requests");
1018 case SOLVER_RULE_RPM:
1019 ret =
_(
"some dependency problem");
1021 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1022 ret =
str::form (
_(
"nothing provides requested %s"), pool_dep2str(pool, dep));
1023 detail +=
_(
"Have you enabled all requested repositories?");
1025 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1029 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1032 ret =
str::form (
_(
"nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.
asString().c_str());
1034 case SOLVER_RULE_RPM_SAME_NAME:
1039 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1042 ret =
str::form (
_(
"%s conflicts with %s provided by %s"), s.
asString().c_str(), pool_dep2str(pool, dep), s2.
asString().c_str());
1044 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1049 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1052 ret =
str::form (
_(
"installed %s obsoletes %s provided by %s"), s.
asString().c_str(), pool_dep2str(pool, dep), s2.
asString().c_str());
1054 case SOLVER_RULE_RPM_SELF_CONFLICT:
1056 ret =
str::form (
_(
"solvable %s conflicts with %s provided by itself"), s.
asString().c_str(), pool_dep2str(pool, dep));
1058 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1065 typedef list<PoolItem> ProviderList;
1066 ProviderList providerlistInstalled, providerlistUninstalled;
1067 for_( iter1, possibleProviders.
begin(), possibleProviders.
end() ) {
1071 for_( iter2, possibleProviders.
begin(), possibleProviders.
end() ) {
1082 providerlistInstalled.push_back(provider1);
1084 providerlistUninstalled.push_back(provider1);
1088 ret =
str::form (
_(
"%s requires %s, but this requirement cannot be provided"), s.
asString().c_str(), pool_dep2str(pool, dep));
1089 if (providerlistInstalled.size() > 0) {
1090 detail +=
_(
"deleted providers: ");
1091 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1092 if (iter == providerlistInstalled.begin())
1098 if (providerlistUninstalled.size() > 0) {
1099 if (detail.size() > 0)
1100 detail +=
_(
"\nuninstallable providers: ");
1102 detail =
_(
"uninstallable providers: ");
1103 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1104 if (iter == providerlistUninstalled.begin())
1124 Id problem, solution, element;
1130 MIL <<
"Encountered problems! Here are the solutions:\n" << endl;
1133 while ((problem = solver_next_problem(
_solv, problem)) != 0) {
1134 MIL <<
"Problem " << pcnt++ <<
":" << endl;
1135 MIL <<
"====================================" << endl;
1139 MIL << whatString << endl;
1140 MIL <<
"------------------------------------" << endl;
1141 ResolverProblem_Ptr resolverProblem =
new ResolverProblem (whatString, detail);
1144 while ((solution = solver_next_solution(
_solv, problem, solution)) != 0) {
1147 while ((element = solver_next_solutionelement(
_solv, problem, solution, element, &p, &rp)) != 0) {
1148 if (p == SOLVER_SOLUTION_JOB) {
1151 switch (
_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1153 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1157 if (pool->installed && s.
get()->repo == pool->installed) {
1159 string description =
str::form (
_(
"do not keep %s installed"), s.
asString().c_str() );
1160 MIL << description << endl;
1165 MIL << description << endl;
1169 ERR <<
"SOLVER_INSTALL_SOLVABLE: No item found for " << s.
asString() << endl;
1173 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1177 if (pool->installed && s.
get()->repo == pool->installed) {
1180 MIL << description << endl;
1184 string description =
str::form (
_(
"do not forbid installation of %s"),
itemToString( poolItem ).c_str());
1185 MIL << description << endl;
1189 ERR <<
"SOLVER_ERASE_SOLVABLE: No item found for " << s.
asString() << endl;
1193 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1196 SolverQueueItemInstall_Ptr install =
1200 string description =
str::form (
_(
"do not install %s"), ident.
c_str() );
1201 MIL << description << endl;
1205 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1215 functor::functorRef<bool,PoolItem> (info) );
1217 SolverQueueItemDelete_Ptr del =
1222 MIL << description << endl;
1226 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1229 string description =
"";
1232 if (system_requires.find(
Capability(what)) != system_requires.end()) {
1234 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1235 resolverProblem->setDescription(
_(
"This request will break your system!"));
1236 description =
_(
"ignore the warning of a broken system");
1237 description += string(
" (requires:")+pool_dep2str(pool, what)+
")";
1238 MIL << description << endl;
1241 description =
str::form (
_(
"do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1242 MIL << description << endl;
1247 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1250 string description =
"";
1253 if (system_conflicts.find(
Capability(what)) != system_conflicts.end()) {
1255 resolverProblem->setDetails( resolverProblem->description() +
"\n" + resolverProblem->details() );
1256 resolverProblem->setDescription(
_(
"This request will break your system!"));
1257 description =
_(
"ignore the warning of a broken system");
1258 description += string(
" (conflicts:")+pool_dep2str(pool, what)+
")";
1259 MIL << description << endl;
1263 description =
str::form (
_(
"do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1264 MIL << description << endl;
1269 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1274 if (pool->installed && s.
get()->repo == pool->installed) {
1276 string description =
str::form (
_(
"do not install most recent version of %s"), s.
asString().c_str());
1277 MIL << description << endl;
1280 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem <<
" is not selected for installation" << endl;
1283 ERR <<
"SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.
asString() << endl;
1288 MIL <<
"- do something different" << endl;
1289 ERR <<
"No valid solution available" << endl;
1292 }
else if (p == SOLVER_SOLUTION_INFARCH) {
1295 if (pool->installed && s.
get()->repo == pool->installed) {
1297 string description =
str::form (
_(
"keep %s despite the inferior architecture"), s.
asString().c_str());
1298 MIL << description << endl;
1302 string description =
str::form (
_(
"install %s despite the inferior architecture"), s.
asString().c_str());
1303 MIL << description << endl;
1306 }
else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1309 if (pool->installed && s.
get()->repo == pool->installed) {
1312 MIL << description << endl;
1316 string description =
str::form (
_(
"install %s from excluded repository"), s.
asString().c_str());
1317 MIL << description << endl;
1330 if (itemFrom && itemTo) {
1332 int illegal = policy_is_illegal(
_solv, s.
get(), sd.
get(), 0);
1334 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1337 MIL << description << endl;
1341 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1344 MIL << description << endl;
1348 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1352 string description =
str::form (
_(
"install %s (with vendor change)\n %s --> %s") ,
1354 ( s_vendor ? s_vendor.c_str() :
" (no vendor) " ),
1355 ( sd_vendor ? sd_vendor.c_str() :
" (no vendor) " ) );
1356 MIL << description << endl;
1362 MIL << description << endl;
1373 MIL << description << endl;
1380 resolverProblem->addSolution (problemSolution,
1381 problemSolution->
actionCount() > 1 ?
true :
false);
1382 MIL <<
"------------------------------------" << endl;
1389 resolverProblem->addSolution (problemSolution,
1391 MIL <<
"ignore some dependencies of " << item << endl;
1392 MIL <<
"------------------------------------" << endl;
1396 resolverProblems.push_back (resolverProblem);
1399 return resolverProblems;
1405 for (ProblemSolutionList::const_iterator iter = solutions.begin();
1406 iter != solutions.end(); ++iter) {
1407 ProblemSolution_Ptr solution = *iter;
1409 if (!solution->apply (dummyResolver))
1418 if (iter->status().isInstalled()) {
1419 MIL <<
"Lock installed item " << *iter << endl;
1420 queue_push( &(
_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1423 MIL <<
"Lock NOT installed item " << *iter << endl;
1433 std::set<IdString> unifiedByName;
1435 IdString ident( (*iter)->satSolvable().ident() );
1436 if ( unifiedByName.insert( ident ).second )
1440 MIL <<
"Keep NOT installed name " << ident <<
" (" << *iter <<
")" << endl;
1453 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1454 queue_push( &(
_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1456 MIL <<
"SYSTEM Requires " << *iter << endl;
1459 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1462 MIL <<
"SYSTEM Conflicts " << *iter << endl;
1473 if ( (*it)->isSystem() )
1476 queue_push( &(
_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1477 queue_push( &(
_jobQueue), archrule.id() );