00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <map>
00023 #include <sstream>
00024
00025 #include "zypp/solver/detail/ResolverInfo.h"
00026 #include "zypp/solver/detail/ResolverInfoMisc.h"
00027 #include "zypp/base/String.h"
00028 #include "zypp/base/Logger.h"
00029 #include "zypp/base/Gettext.h"
00030
00032 namespace zypp
00033 {
00034
00035 namespace solver
00036 {
00037
00038 namespace detail
00039 {
00040
00041 using namespace std;
00042
00043 IMPL_PTR_TYPE(ResolverInfoMisc);
00044
00045
00046
00047
00048 std::ostream &
00049 ResolverInfoMisc::dumpOn( std::ostream & os ) const
00050 {
00051 ResolverInfo::dumpOn (os);
00052
00053 os << ">>" << message() << "<<";
00054 os << itemsToString(true);
00055 if (!_action.empty()) {
00056 os << _(", Action: ") << _action << endl;
00057 }
00058 os << _(", Trigger: ");
00059 switch (_trigger) {
00060 case ResolverInfoMisc::NONE: os << "none"; break;
00061 case ResolverInfoMisc::OBSOLETE: os << "obsoletes"; break;
00062 case ResolverInfoMisc::REQUIRE: os << "requires"; break;
00063 case ResolverInfoMisc::CONFLICT: os << "conflicts"; break;
00064 }
00065 os << endl;
00066 return os;
00067 }
00068
00069
00070
00071 ResolverInfoMisc::ResolverInfoMisc (ResolverInfoType detailedtype, PoolItem_Ref affected, int priority, const Capability & capability)
00072 : ResolverInfoContainer (detailedtype, affected, priority)
00073 , _capability (capability)
00074 , _trigger (NONE)
00075 {
00076 }
00077
00078
00079 ResolverInfoMisc::~ResolverInfoMisc ()
00080 {
00081 }
00082
00083
00084
00085 static string
00086 translateResTraits (const Resolvable::Kind & kind)
00087 {
00088 if (kind == ResTraits<Package>::kind) {
00089
00090 return _( "package" );
00091 }
00092 else if (kind == ResTraits<Selection>::kind) {
00093
00094 return _( "selection" );
00095 }
00096 else if (kind == ResTraits<Pattern>::kind) {
00097
00098 return _( "pattern" );
00099 }
00100 else if (kind == ResTraits<Product>::kind) {
00101
00102 return _( "product" );
00103 }
00104 else if (kind == ResTraits<Patch>::kind) {
00105
00106 return _( "patch" );
00107 }
00108 else if (kind == ResTraits<Script>::kind) {
00109
00110 return _( "script" );
00111 }
00112 else if (kind == ResTraits<Message>::kind) {
00113
00114 return _( "message" );
00115 }
00116 else if (kind == ResTraits<Atom>::kind) {
00117
00118 return _( "atom" );
00119 }
00120 else if (kind == ResTraits<SystemResObject>::kind) {
00121
00122 return _( "system" );
00123 }
00124
00125
00126 return _("Resolvable");
00127 }
00128
00129
00130 std::string
00131 ResolverInfoMisc::message (void) const
00132 {
00133 string msg;
00134
00135 string affected_str = ResolverInfo::toString(affected());
00136
00137 switch (type()) {
00138
00139
00140
00141
00142 case RESOLVER_INFO_TYPE_INVALID_SOLUTION: {
00143
00144 msg = _("Marking this resolution attempt as invalid.");
00145 }
00146 break;
00147
00148 case RESOLVER_INFO_TYPE_UNINSTALLABLE: {
00149
00150
00151 msg = str::form (_("Marking resolvable %s as uninstallable"),
00152 affected_str.c_str());
00153 }
00154 break;
00155
00156 case RESOLVER_INFO_TYPE_REJECT_INSTALL: {
00157
00158
00159 msg = str::form (_("%s is scheduled to be installed, but this is not possible because of dependency problems."),
00160 affected_str.c_str());
00161 }
00162 break;
00163
00164 case RESOLVER_INFO_TYPE_INSTALL_TO_BE_UNINSTALLED: {
00165
00166
00167 msg = str::form (_("Can't install %s since it is already marked as needing to be uninstalled"),
00168 affected_str.c_str());
00169 }
00170 break;
00171
00172 case RESOLVER_INFO_TYPE_INSTALL_UNNEEDED: {
00173
00174
00175
00176
00177
00178
00179 msg = str::form (_("Can't install %s since it is does not apply to this system."),
00180 affected_str.c_str());
00181 }
00182 break;
00183
00184 case RESOLVER_INFO_TYPE_INSTALL_PARALLEL: {
00185
00186
00187
00188
00189
00190 msg = str::form (_("Can't install %s, since %s is already marked as needing to be installed"),
00191 affected_str.c_str(),
00192 toString (other()).c_str());
00193 }
00194 break;
00195
00196 case RESOLVER_INFO_TYPE_INCOMPLETES: {
00197
00198 msg = str::form (_("This would invalidate %s."),
00199 affected_str.c_str());
00200 }
00201 break;
00202
00203
00204
00205
00206
00207
00208 case RESOLVER_INFO_TYPE_ESTABLISHING: {
00209
00210
00211
00212
00213
00214 msg = str::form (_("Establishing %s"), affected_str.c_str());
00215 }
00216 break;
00217
00218
00219
00220
00221
00222
00223
00224
00225 case RESOLVER_INFO_TYPE_INSTALLING: {
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235 msg = str::form (_("Installing %s"),
00236 affected_str.c_str());
00237 }
00238 break;
00239
00240
00241
00242
00243 case RESOLVER_INFO_TYPE_UPDATING: {
00244
00245
00246
00247
00248
00249
00250
00251
00252 msg = str::form (_("Updating %s to %s"),
00253 ResolverInfo::toString (other()).c_str(),
00254 affected_str.c_str());
00255 }
00256 break;
00257
00258
00259
00260
00261 case RESOLVER_INFO_TYPE_SKIPPING: {
00262
00263
00264
00265
00266
00267
00268
00269
00270 msg = str::form (_("Skipping %s: already installed"), affected_str.c_str());
00271 }
00272 break;
00273
00274
00275
00276
00277
00278
00279
00280 case RESOLVER_INFO_TYPE_NO_OTHER_PROVIDER: {
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 msg = str::form (_("There are no alternative installed providers of %s"), ResolverInfo::toString (_capability).c_str());
00293 if (affected()) {
00294 msg += " ";
00295
00296
00297
00298 msg += str::form (_("for %s"), affected_str.c_str());
00299 }
00300 }
00301 break;
00302
00303
00304
00305
00306 case RESOLVER_INFO_TYPE_NO_PROVIDER: {
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 msg = str::form (_("There are no installable providers of %s"), ResolverInfo::toString (_capability).c_str());
00318 if (affected()) {
00319 msg += " ";
00320
00321
00322
00323 msg += str::form (_("for %s"), affected_str.c_str());
00324 }
00325 }
00326 break;
00327
00328
00329
00330
00331 case RESOLVER_INFO_TYPE_NO_UPGRADE: {
00332
00333
00334
00335
00336
00337 string other_str = ResolverInfo::toString(other());
00338
00339
00340
00341 msg = str::form (_("Upgrade to %s to avoid removing %s is not possible."),
00342 other_str.c_str(),
00343 affected_str.c_str());
00344 }
00345 break;
00346
00347
00348
00349
00350 case RESOLVER_INFO_TYPE_UNINSTALL_PROVIDER: {
00351
00352
00353
00354
00355
00356 string other_str = ResolverInfo::toString(other());
00357 string cap_str = ResolverInfo::toString (_capability);
00358
00359 msg = str::form (_("%s provides %s, but is scheduled to be uninstalled."),
00360 other_str.c_str(),
00361 cap_str.c_str());
00362 }
00363 break;
00364
00365
00366
00367
00368 case RESOLVER_INFO_TYPE_PARALLEL_PROVIDER: {
00369
00370
00371
00372
00373
00374 string other_str = ResolverInfo::toString(other());
00375 string cap_str = ResolverInfo::toString (_capability);
00376
00377 msg = str::form (_("%s provides %s, but another version of that %s is already installed."),
00378 other_str.c_str(),
00379 cap_str.c_str(),
00380 translateResTraits(other()->kind()).c_str());
00381 }
00382 break;
00383
00384
00385
00386
00387 case RESOLVER_INFO_TYPE_NOT_INSTALLABLE_PROVIDER: {
00388
00389
00390
00391
00392
00393 string other_str = ResolverInfo::toString(other());
00394 string cap_str = ResolverInfo::toString (_capability);
00395
00396 msg = str::form (_("%s provides %s, but it is uninstallable. Try installing it on its own for more details."),
00397 other_str.c_str(),
00398 cap_str.c_str());
00399 }
00400 break;
00401
00402
00403
00404
00405 case RESOLVER_INFO_TYPE_LOCKED_PROVIDER: {
00406
00407
00408
00409
00410
00411 string other_str = ResolverInfo::toString(other());
00412 string cap_str = ResolverInfo::toString (_capability);
00413
00414 msg = str::form (_("%s provides %s, but it is locked."),
00415 other_str.c_str(),
00416 cap_str.c_str());
00417 }
00418 break;
00419
00420
00421
00422
00423 case RESOLVER_INFO_TYPE_KEEP_PROVIDER: {
00424
00425
00426
00427
00428
00429 string other_str = ResolverInfo::toString(other());
00430 string cap_str = ResolverInfo::toString (_capability);
00431
00432 msg = str::form (_("%s provides %s, but is scheduled to be kept."),
00433 other_str.c_str(),
00434 cap_str.c_str());
00435 }
00436 break;
00437
00438
00439
00440
00441
00442 case RESOLVER_INFO_TYPE_OTHER_ARCH_PROVIDER: {
00443
00444
00445
00446
00447
00448 string other_str = ResolverInfo::toString(other());
00449 string cap_str = ResolverInfo::toString (_capability);
00450
00451 msg = str::form (_("%s provides %s, but has another architecture."),
00452 other_str.c_str(),
00453 cap_str.c_str());
00454 }
00455 break;
00456
00457
00458
00459
00460
00461 case RESOLVER_INFO_TYPE_CANT_SATISFY: {
00462
00463
00464
00465
00466
00467 string cap_str = ResolverInfo::toString (_capability);
00468
00469 msg = str::form (_("Can't satisfy requirement %s for %s"),
00470 cap_str.c_str(),
00471 affected_str.c_str());
00472 }
00473 break;
00474
00475
00476
00477
00478
00479
00480
00481 case RESOLVER_INFO_TYPE_UNINSTALL_TO_BE_INSTALLED: {
00482
00483
00484
00485
00486
00487
00488
00489
00490 msg = str::form (_("%s is required by other to-be-installed resolvable, so it won't be unlinked."),
00491 affected_str.c_str());
00492 }
00493 break;
00494
00495
00496
00497
00498 case RESOLVER_INFO_TYPE_UNINSTALL_INSTALLED: {
00499
00500
00501
00502
00503
00504
00505
00506
00507 msg = str::form (_("%s is required by other installed resolvable, so it won't be unlinked."),
00508 affected_str.c_str());
00509 }
00510 break;
00511
00512
00513
00514
00515 case RESOLVER_INFO_TYPE_UNINSTALL_LOCKED: {
00516
00517
00518
00519
00520
00521
00522
00523
00524 msg = str::form (_("%s is locked and cannot be uninstalled."),
00525 affected_str.c_str());
00526 }
00527 break;
00528
00529
00530
00531
00532
00533
00534
00535 case RESOLVER_INFO_TYPE_CONFLICT_CANT_INSTALL: {
00536
00537
00538
00539
00540
00541
00542
00543 msg = str::form(_("A conflict over %s (%s) requires the removal of to-be-installed %s"),
00544 ResolverInfo::toString (_capability).c_str(),
00545 ResolverInfo::toString (_other_capability).c_str(),
00546 affected_str.c_str());
00547 }
00548 break;
00549
00550
00551
00552
00553 case RESOLVER_INFO_TYPE_CONFLICT_UNINSTALLABLE: {
00554
00555
00556
00557
00558
00559
00560
00561 msg = str::form (_("Marking %s as uninstallable due to conflicts over %s"),
00562 affected_str.c_str(),
00563 ResolverInfo::toString (_capability).c_str());
00564 PoolItem_Ref issuer = other();
00565 if (issuer) {
00566 msg += " ";
00567
00568
00569 msg += str::form (_("from %s"),
00570 ResolverInfo::toString (issuer).c_str());
00571 }
00572 }
00573 break;
00574
00575
00576
00577
00578 default:
00579 WAR << "Not an InfoMisc type: " << type() << endl;
00580
00581 break;
00582 }
00583 return msg;
00584 }
00585
00586
00587
00588 bool
00589 ResolverInfoMisc::merge (ResolverInfoContainer_Ptr info)
00590 {
00591 bool res;
00592 ResolverInfoMisc_Ptr to_be_merged = dynamic_pointer_cast<ResolverInfoMisc>(info);
00593
00594 res = ResolverInfo::merge(to_be_merged);
00595 if (!res) return res;
00596
00597 if (type() == to_be_merged->type()
00598 && affected() == to_be_merged->affected()
00599 && _capability == to_be_merged->_capability) {
00600
00601 return true;
00602 }
00603
00604 return false;
00605 }
00606
00607
00608 ResolverInfo_Ptr
00609 ResolverInfoMisc::copy (void) const
00610 {
00611 ResolverInfoMisc_Ptr cpy = new ResolverInfoMisc(type(), affected(), priority(), _capability);
00612
00613 ((ResolverInfoContainer_Ptr)cpy)->copy (this);
00614 cpy->_other_item = _other_item;
00615 cpy->_other_capability = _other_capability;
00616 cpy->_action = _action;
00617 cpy->_trigger = _trigger;
00618
00619 return cpy;
00620 }
00621
00622
00623
00624 void
00625 ResolverInfoMisc::addAction (const std::string & action_msg)
00626 {
00627 _action = action_msg;
00628 }
00629
00630
00631 void
00632 ResolverInfoMisc::addTrigger (const TriggerReason & trigger)
00633 {
00634 _trigger = trigger;
00635 }
00636
00637 void
00638 ResolverInfoMisc::setOtherPoolItem (PoolItem_Ref other)
00639 {
00640 _other_item = other;
00641 }
00642
00643 void
00644 ResolverInfoMisc::setOtherCapability (const Capability & capability)
00645 {
00646 _other_capability = capability;
00647 }
00648
00650 };
00653 };
00656 };
00658