libzypp: zypp/solver/detail/SATResolver.cc Source File

libzypp 17.25.10

SATResolver.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* SATResolver.cc
3 *
4 * Copyright (C) 2000-2002 Ximian, Inc.
5 * Copyright (C) 2005 SUSE Linux Products GmbH
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21 extern "C"
22 {
23 #include <solv/repo_solv.h>
24 #include <solv/poolarch.h>
25 #include <solv/evr.h>
26 #include <solv/poolvendor.h>
27 #include <solv/policy.h>
28 #include <solv/bitmap.h>
29 #include <solv/queue.h>
30 }
31
32 #define ZYPP_USE_RESOLVER_INTERNALS
33
34 #include <zypp/base/LogTools.h>
35 #include <zypp/base/Gettext.h>
36 #include <zypp/base/Algorithm.h>
37
38 #include <zypp/ZConfig.h>
39 #include <zypp/Product.h>
40 #include <zypp/AutoDispose.h>
41 #include <zypp/sat/WhatProvides.h>
42 #include <zypp/sat/WhatObsoletes.h>
43 #include <zypp/sat/detail/PoolImpl.h>
44
45 #include <zypp/solver/detail/Resolver.h>
46 #include <zypp/solver/detail/SATResolver.h>
47
48 #include <zypp/solver/detail/ProblemSolutionCombi.h>
49 #include <zypp/solver/detail/ProblemSolutionIgnore.h>
50 #include <zypp/solver/detail/SolverQueueItemInstall.h>
51 #include <zypp/solver/detail/SolverQueueItemDelete.h>
52 #include <zypp/solver/detail/SystemCheck.h>
53 #include <zypp/solver/detail/SolutionAction.h>
54 #include <zypp/solver/detail/SolverQueueItem.h>
55
56 using std::endl;
57
58 #define XDEBUG(x) do { if (base::logger::isExcessive()) XXX << x << std::endl;} while (0)
59
60 #undef ZYPP_BASE_LOGGER_LOGGROUP
61 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::solver"
62
64 namespace zypp
65 {
67 namespace solver
68 {
70 namespace detail
71 {
72
74 namespace
75 {
76 inline void solverSetFocus( sat::detail::CSolver & satSolver_r, const ResolverFocus & focus_r )
77 {
78 switch ( focus_r )
79 {
80 case ResolverFocus::Default: // fallthrough to Job
81 case ResolverFocus::Job:
82 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
83 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
84 break;
85 case ResolverFocus::Installed:
86 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 1 );
87 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
88 break;
89 case ResolverFocus::Update:
90 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
91 solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 1 );
92 break;
93 }
94 }
95
99 inline sat::Queue collectPseudoInstalled( const ResPool & pool_r )
100 {
101 sat::Queue ret;
102 for ( const PoolItem & pi : pool_r )
103 if ( traits::isPseudoInstalled( pi.kind() ) ) ret.push( pi.id() );
104 return ret;
105 }
106
110 inline void solverCopyBackWeak( sat::detail::CSolver & satSolver_r, PoolItemList & orphanedItems_r )
111 {
112 // NOTE: assert all items weak stati are reset (resetWeak was called)
113 {
114 sat::Queue recommendations;
115 sat::Queue suggestions;
116 ::solver_get_recommendations( &satSolver_r, recommendations, suggestions, 0 );
117 for ( sat::Queue::size_type i = 0; i < recommendations.size(); ++i )
118 PoolItem(sat::Solvable(recommendations[i])).status().setRecommended( true );
119 for ( sat::Queue::size_type i = 0; i < suggestions.size(); ++i )
120 PoolItem(sat::Solvable(suggestions[i])).status().setSuggested( true );
121 }
122 {
123 orphanedItems_r.clear(); // cached on the fly
124 sat::Queue orphaned;
125 ::solver_get_orphaned( &satSolver_r, orphaned );
126 for ( sat::Queue::size_type i = 0; i < orphaned.size(); ++i )
127 {
128 PoolItem pi { sat::Solvable(orphaned[i]) };
129 pi.status().setOrphaned( true );
130 orphanedItems_r.push_back( pi );
131 }
132 }
133 {
134 sat::Queue unneeded;
135 ::solver_get_unneeded( &satSolver_r, unneeded, 1 );
136 for ( sat::Queue::size_type i = 0; i < unneeded.size(); ++i )
137 PoolItem(sat::Solvable(unneeded[i])).status().setUnneeded( true );
138 }
139 }
140
142 inline void solverCopyBackValidate( sat::detail::CSolver & satSolver_r, const ResPool & pool_r )
143 {
144 sat::Queue pseudoItems { collectPseudoInstalled( pool_r ) };
145 if ( ! pseudoItems.empty() )
146 {
147 sat::Queue pseudoFlags;
148 ::solver_trivial_installable( &satSolver_r, pseudoItems, pseudoFlags );
149
150 for ( sat::Queue::size_type i = 0; i < pseudoItems.size(); ++i )
151 {
152 PoolItem pi { sat::Solvable(pseudoItems[i]) };
153 switch ( pseudoFlags[i] )
154 {
155 case 0: pi.status().setBroken(); break;
156 case 1: pi.status().setSatisfied(); break;
157 case -1: pi.status().setNonRelevant(); break;
158 default: pi.status().setUndetermined(); break;
159 }
160 }
161 }
162 }
163
164 } //namespace
166
167
168
169 IMPL_PTR_TYPE(SATResolver);
170
171 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0)
172
173 //---------------------------------------------------------------------------
174 // Callbacks for SAT policies
175 //---------------------------------------------------------------------------
176
177 int vendorCheck( sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2 )
178 { return VendorAttr::instance().equivalent( IdString(solvable1->vendor), IdString(solvable2->vendor) ) ? 0 : 1; }
179
180 int relaxedVendorCheck( sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2 )
181 { return VendorAttr::instance().relaxedEquivalent( IdString(solvable1->vendor), IdString(solvable2->vendor) ) ? 0 : 1; }
182
187 void establish( sat::Queue & pseudoItems_r, sat::Queue & pseudoFlags_r )
188 {
189 pseudoItems_r = collectPseudoInstalled( ResPool::instance() );
190 if ( ! pseudoItems_r.empty() )
191 {
192 MIL << "Establish..." << endl;
193 sat::detail::CPool * cPool { sat::Pool::instance().get() };
194 ::pool_set_custom_vendorcheck( cPool, &vendorCheck );
195
196 sat::Queue jobQueue;
197 // Add rules for parallel installable resolvables with different versions
198 for ( const sat::Solvable & solv : sat::Pool::instance().multiversion() )
199 {
200 jobQueue.push( SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
201 jobQueue.push( solv.id() );
202 }
203
204 AutoDispose<sat::detail::CSolver*> cSolver { ::solver_create( cPool ), ::solver_free };
205 sat::Pool::instance().prepare();
206 if ( ::solver_solve( cSolver, jobQueue ) != 0 )
207 INT << "How can establish fail?" << endl;
208
209 ::solver_trivial_installable( cSolver, pseudoItems_r, pseudoFlags_r );
210
211 for ( sat::Queue::size_type i = 0; i < pseudoItems_r.size(); ++i )
212 {
213 PoolItem pi { sat::Solvable(pseudoItems_r[i]) };
214 switch ( pseudoFlags_r[i] )
215 {
216 case 0: pi.status().setBroken(); break;
217 case 1: pi.status().setSatisfied(); break;
218 case -1: pi.status().setNonRelevant(); break;
219 default: pi.status().setUndetermined(); break;
220 }
221 }
222 MIL << "Establish DONE" << endl;
223 }
224 else
225 MIL << "Establish not needed." << endl;
226 }
227
228 inline std::string itemToString( const PoolItem & item )
229 {
230 if ( !item )
231 return std::string();
232
233 sat::Solvable slv( item.satSolvable() );
234 std::string ret( slv.asString() ); // n-v-r.a
235 if ( ! slv.isSystem() )
236 {
237 ret += "[";
238 ret += slv.repository().alias();
239 ret += "]";
240 }
241 return ret;
242 }
243
244 //---------------------------------------------------------------------------
245
246 std::ostream &
247 SATResolver::dumpOn( std::ostream & os ) const
248 {
249 os << "<resolver>" << endl;
250 if (_satSolver) {
251 #define OUTS(X) os << " " << #X << "\t= " << solver_get_flag(_satSolver, SOLVER_FLAG_##X) << endl
252 OUTS( ALLOW_DOWNGRADE );
253 OUTS( ALLOW_ARCHCHANGE );
254 OUTS( ALLOW_VENDORCHANGE );
255 OUTS( ALLOW_NAMECHANGE );
256 OUTS( ALLOW_UNINSTALL );
257 OUTS( NO_UPDATEPROVIDE );
258 OUTS( SPLITPROVIDES );
259 OUTS( IGNORE_RECOMMENDED );
260 OUTS( ADD_ALREADY_RECOMMENDED );
261 OUTS( NO_INFARCHCHECK );
262 OUTS( KEEP_EXPLICIT_OBSOLETES );
263 OUTS( BEST_OBEY_POLICY );
264 OUTS( NO_AUTOTARGET );
265 OUTS( DUP_ALLOW_DOWNGRADE );
266 OUTS( DUP_ALLOW_ARCHCHANGE );
267 OUTS( DUP_ALLOW_VENDORCHANGE );
268 OUTS( DUP_ALLOW_NAMECHANGE );
269 OUTS( KEEP_ORPHANS );
270 OUTS( BREAK_ORPHANS );
271 OUTS( YUM_OBSOLETES );
272 #undef OUTS
273 os << " focus = " << _focus << endl;
274 os << " distupgrade = " << _distupgrade << endl;
275 os << " distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
276 os << " solveSrcPackages = " << _solveSrcPackages << endl;
277 os << " cleandepsOnRemove = " << _cleandepsOnRemove << endl;
278 os << " fixsystem = " << _fixsystem << endl;
279 } else {
280 os << "<NULL>";
281 }
282 return os << "<resolver/>" << endl;
283 }
284
285 //---------------------------------------------------------------------------
286
287 // NOTE: flag defaults must be in sync with ZVARDEFAULT in Resolver.cc
288 SATResolver::SATResolver (const ResPool & pool, sat::detail::CPool *satPool)
289 : _pool(pool)
290 , _satPool(satPool)
291 , _satSolver(NULL)
292 , _focus ( ZConfig::instance().solver_focus() )
293 , _fixsystem(false)
294 , _allowdowngrade ( false )
295 , _allownamechange ( true ) // bsc#1071466
296 , _allowarchchange ( false )
297 , _allowvendorchange ( ZConfig::instance().solver_allowVendorChange() )
298 , _allowuninstall ( false )
299 , _updatesystem(false)
300 , _noupdateprovide ( false )
301 , _dosplitprovides ( true )
302 , _onlyRequires (ZConfig::instance().solver_onlyRequires())
303 , _ignorealreadyrecommended(true)
304 , _distupgrade(false)
305 , _distupgrade_removeunsupported(false)
306 , _dup_allowdowngrade ( ZConfig::instance().solver_dupAllowDowngrade() )
307 , _dup_allownamechange ( ZConfig::instance().solver_dupAllowNameChange() )
308 , _dup_allowarchchange ( ZConfig::instance().solver_dupAllowArchChange() )
309 , _dup_allowvendorchange ( ZConfig::instance().solver_dupAllowVendorChange() )
310 , _solveSrcPackages(false)
311 , _cleandepsOnRemove(ZConfig::instance().solver_cleandepsOnRemove())
312 {
313 }
314
315
316 SATResolver::~SATResolver()
317 {
318 solverEnd();
319 }
320
321 //---------------------------------------------------------------------------
322
323 ResPool
324 SATResolver::pool (void) const
325 {
326 return _pool;
327 }
328
329 //---------------------------------------------------------------------------
330
331 // copy marked item from solution back to pool
332 // if data != NULL, set as APPL_LOW (from establishPool())
333
334 static void
335 SATSolutionToPool (PoolItem item, const ResStatus & status, const ResStatus::TransactByValue causer)
336 {
337 // resetting
338 item.status().resetTransact (causer);
339 item.status().resetWeak ();
340
341 bool r;
342
343 // installation/deletion
344 if (status.isToBeInstalled()) {
345 r = item.status().setToBeInstalled (causer);
346 XDEBUG("SATSolutionToPool install returns " << item << ", " << r);
347 }
348 else if (status.isToBeUninstalledDueToUpgrade()) {
349 r = item.status().setToBeUninstalledDueToUpgrade (causer);
350 XDEBUG("SATSolutionToPool upgrade returns " << item << ", " << r);
351 }
352 else if (status.isToBeUninstalled()) {
353 r = item.status().setToBeUninstalled (causer);
354 XDEBUG("SATSolutionToPool remove returns " << item << ", " << r);
355 }
356
357 return;
358 }
359
360 //----------------------------------------------------------------------------
361 //----------------------------------------------------------------------------
362 // resolvePool
363 //----------------------------------------------------------------------------
364 //----------------------------------------------------------------------------
372 struct SATCollectTransact : public resfilter::PoolItemFilterFunctor
373 {
374 SATCollectTransact( PoolItemList & items_to_install_r,
375 PoolItemList & items_to_remove_r,
376 PoolItemList & items_to_lock_r,
377 PoolItemList & items_to_keep_r,
378 bool solveSrcPackages_r )
379 : _items_to_install( items_to_install_r )
380 , _items_to_remove( items_to_remove_r )
381 , _items_to_lock( items_to_lock_r )
382 , _items_to_keep( items_to_keep_r )
383 , _solveSrcPackages( solveSrcPackages_r )
384 {
385 _items_to_install.clear();
386 _items_to_remove.clear();
387 _items_to_lock.clear();
388 _items_to_keep.clear();
389 }
390
391 bool operator()( const PoolItem & item_r )
392 {
393
394 ResStatus & itemStatus( item_r.status() );
395 bool by_solver = ( itemStatus.isBySolver() || itemStatus.isByApplLow() );
396
397 if ( by_solver )
398 {
399 // Clear former solver/establish resultd
400 itemStatus.resetTransact( ResStatus::APPL_LOW );
401 return true; // -> back out here, don't re-queue former results
402 }
403
404 if ( !_solveSrcPackages && item_r.isKind<SrcPackage>() )
405 {
406 // Later we may continue on a per source package base.
407 return true; // dont process this source package.
408 }
409
410 switch ( itemStatus.getTransactValue() )
411 {
412 case ResStatus::TRANSACT:
413 itemStatus.isUninstalled() ? _items_to_install.push_back( item_r )
414 : _items_to_remove.push_back( item_r ); break;
415 case ResStatus::LOCKED: _items_to_lock.push_back( item_r ); break;
416 case ResStatus::KEEP_STATE: _items_to_keep.push_back( item_r ); break;
417 }
418 return true;
419 }
420
421 private:
422 PoolItemList & _items_to_install;
423 PoolItemList & _items_to_remove;
424 PoolItemList & _items_to_lock;
425 PoolItemList & _items_to_keep;
426 bool _solveSrcPackages;
427
428 };
430
431
432 //----------------------------------------------------------------------------
433 //----------------------------------------------------------------------------
434 // solving.....
435 //----------------------------------------------------------------------------
436 //----------------------------------------------------------------------------
437
438
439 class CheckIfUpdate : public resfilter::PoolItemFilterFunctor
440 {
441 public:
442 bool is_updated;
443 sat::Solvable _installed;
444
445 CheckIfUpdate( const sat::Solvable & installed_r )
446 : is_updated( false )
447 , _installed( installed_r )
448 {}
449
450 // check this item will be updated
451
452 bool operator()( const PoolItem & item )
453 {
454 if ( item.status().isToBeInstalled() )
455 {
456 if ( ! item.multiversionInstall() || sameNVRA( _installed, item ) )
457 {
458 is_updated = true;
459 return false;
460 }
461 }
462 return true;
463 }
464 };
465
466
467 bool
468 SATResolver::solving(const CapabilitySet & requires_caps,
469 const CapabilitySet & conflict_caps)
470 {
471 if (_fixsystem) {
472 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
473 queue_push( &(_jobQueue), 0 );
474 }
475 if (_updatesystem) {
476 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
477 queue_push( &(_jobQueue), 0 );
478 }
479 if (_distupgrade) {
480 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
481 queue_push( &(_jobQueue), 0 );
482 }
483 if (_distupgrade_removeunsupported) {
484 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
485 queue_push( &(_jobQueue), 0 );
486 }
487 solverSetFocus( *_satSolver, _focus );
488 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
489 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
490 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
491 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
492 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
493 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
494 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
495 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
496 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, false); // resolve recommended namespaces
497 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires); //
498 solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, _dup_allowdowngrade );
499 solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_NAMECHANGE, _dup_allownamechange );
500 solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE, _dup_allowarchchange );
501 solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE, _dup_allowvendorchange );
502
503 sat::Pool::instance().prepare();
504
505 // Solve !
506 MIL << "Starting solving...." << endl;
507 MIL << *this;
508 if ( solver_solve( _satSolver, &(_jobQueue) ) == 0 )
509 {
510 // bsc#1155819: Weakremovers of future product not evaluated.
511 // Do a 2nd run to cleanup weakremovers() of to be installed
512 // Produtcs unless removeunsupported is active (cleans up all).
513 if ( _distupgrade )
514 {
515 if ( _distupgrade_removeunsupported )
516 MIL << "Droplist processing not needed. RemoveUnsupported is On." << endl;
517 else if ( ! ZConfig::instance().solverUpgradeRemoveDroppedPackages() )
518 MIL << "Droplist processing is disabled in ZConfig." << endl;
519 else
520 {
521 bool resolve = false;
522 MIL << "Checking droplists ..." << endl;
523 // get Solvables to be installed...
524 sat::SolvableQueue decisionq;
525 solver_get_decisionqueue( _satSolver, decisionq );
526 for ( sat::detail::IdType id : decisionq )
527 {
528 if ( id < 0 )
529 continue;
530 sat::Solvable slv { (sat::detail::SolvableIdType)id };
531 // get product buddies (they carry the weakremover)...
532 static const Capability productCap { "product()" };
533 if ( slv && slv.provides().matches( productCap ) )
534 {
535 CapabilitySet droplist { slv.valuesOfNamespace( "weakremover" ) };
536 MIL << "Droplist for " << slv << ": size " << droplist.size() << endl;
537 if ( !droplist.empty() )
538 {
539 for ( const auto & cap : droplist )
540 {
541 queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
542 queue_push( &_jobQueue, cap.id() );
543 }
544 // PIN product - a safety net to prevent cleanup from changing the decision for this product
545 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
546 queue_push( &(_jobQueue), id );
547 resolve = true;
548 }
549 }
550 }
551 if ( resolve )
552 solver_solve( _satSolver, &(_jobQueue) );
553 }
554 }
555 }
556 MIL << "....Solver end" << endl;
557
558 // copying solution back to zypp pool
559 //-----------------------------------------
560 _result_items_to_install.clear();
561 _result_items_to_remove.clear();
562
563 /* solvables to be installed */
564 Queue decisionq;
565 queue_init(&decisionq);
566 solver_get_decisionqueue(_satSolver, &decisionq);
567 for ( int i = 0; i < decisionq.count; ++i )
568 {
569 Id p = decisionq.elements[i];
570 if ( p < 0 )
571 continue;
572
573 sat::Solvable slv { (sat::detail::SolvableIdType)p };
574 if ( ! slv || slv.isSystem() )
575 continue;
576
577 PoolItem poolItem( slv );
578 SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
579 _result_items_to_install.push_back( poolItem );
580 }
581 queue_free(&decisionq);
582
583 /* solvables to be erased */
584 Repository systemRepo( sat::Pool::instance().findSystemRepo() ); // don't create if it does not exist
585 if ( systemRepo && ! systemRepo.solvablesEmpty() )
586 {
587 bool mustCheckObsoletes = false;
588 for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
589 {
590 if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
591 continue;
592
593 // Check if this is an update
594 CheckIfUpdate info( *it );
595 PoolItem poolItem( *it );
596 invokeOnEach( _pool.byIdentBegin( poolItem ),
597 _pool.byIdentEnd( poolItem ),
598 resfilter::ByUninstalled(), // ByUninstalled
599 functor::functorRef<bool,PoolItem> (info) );
600
601 if (info.is_updated) {
602 SATSolutionToPool( poolItem, ResStatus::toBeUninstalledDueToUpgrade, ResStatus::SOLVER );
603 } else {
604 SATSolutionToPool( poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER );
605 if ( ! mustCheckObsoletes )
606 mustCheckObsoletes = true; // lazy check for UninstalledDueToObsolete
607 }
608 _result_items_to_remove.push_back (poolItem);
609 }
610 if ( mustCheckObsoletes )
611 {
612 sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
613 for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
614 {
615 ResStatus & status( it->status() );
616 // WhatObsoletes contains installed items only!
617 if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
618 status.setToBeUninstalledDueToObsolete();
619 }
620 }
621 }
622
623 // copy back computed status values to pool
624 // (on the fly cache orphaned items for the UI)
625 solverCopyBackWeak( *_satSolver, _problem_items );
626 solverCopyBackValidate( *_satSolver, _pool );
627
628 // Solvables which were selected due requirements which have been made by the user will
629 // be selected by APPL_LOW. We can't use any higher level, because this setting must
630 // not serve as a request for the next solver run. APPL_LOW is reset before solving.
631 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
632 sat::WhatProvides rpmProviders(*iter);
633 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
634 PoolItem poolItem(*iter2);
635 if (poolItem.status().isToBeInstalled()) {
636 MIL << "User requirement " << *iter << " sets " << poolItem << endl;
637 poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
638 }
639 }
640 }
641 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
642 sat::WhatProvides rpmProviders(*iter);
643 for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
644 PoolItem poolItem(*iter2);
645 if (poolItem.status().isToBeUninstalled()) {
646 MIL << "User conflict " << *iter << " sets " << poolItem << endl;
647 poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
648 }
649 }
650 }
651
652 if (solver_problem_count(_satSolver) > 0 )
653 {
654 ERR << "Solverrun finished with an ERROR" << endl;
655 return false;
656 }
657
658 return true;
659 }
660
661
662 void
663 SATResolver::solverInit(const PoolItemList & weakItems)
664 {
665
666 MIL << "SATResolver::solverInit()" << endl;
667
668 // remove old stuff
669 solverEnd();
670 _satSolver = solver_create( _satPool );
671 {
672 // bsc#1182629: in dup allow an available -release package providing 'dup-vendor-relax(suse)'
673 // to let (suse/opensuse) vendor being treated as being equivalent.
674 bool toRelax = false;
675 if ( _distupgrade ) {
676 for ( sat::Solvable solv : sat::WhatProvides( Capability("dup-vendor-relax(suse)") ) ) {
677 if ( ! solv.isSystem() ) {
678 MIL << "Relaxed vendor check requested by " << solv << endl;
679 toRelax = true;
680 break;
681 }
682 }
683 }
684 ::pool_set_custom_vendorcheck( _satPool, toRelax ? &relaxedVendorCheck : &vendorCheck );
685 }
686
687 queue_init( &_jobQueue );
688
689 // clear and rebuild: _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep
690 {
691 SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
692 invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
693 }
694
695 for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
696 Id id = (*iter)->satSolvable().id();
697 if (id == ID_NULL) {
698 ERR << "Weaken: " << *iter << " not found" << endl;
699 }
700 MIL << "Weaken dependencies of " << *iter << endl;
701 queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
702 queue_push( &(_jobQueue), id );
703 }
704
705 // Ad rules for retracted patches and packages
706 {
707 queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
708 queue_push( &(_jobQueue), sat::Solvable::retractedToken.id() );
709 queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
710 queue_push( &(_jobQueue), sat::Solvable::ptfToken.id() );
711 }
712
713 // Ad rules for changed requestedLocales
714 {
715 const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
716
717 // just track changed locakes
718 for ( const auto & locale : trackedLocaleIds.added() )
719 {
720 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
721 queue_push( &(_jobQueue), Capability( ResolverNamespace::language, IdString(locale) ).id() );
722 }
723
724 for ( const auto & locale : trackedLocaleIds.removed() )
725 {
726 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS ); // needs uncond. SOLVER_CLEANDEPS!
727 queue_push( &(_jobQueue), Capability( ResolverNamespace::language, IdString(locale) ).id() );
728 }
729 }
730
731 // Add rules for parallel installable resolvables with different versions
732 for ( const sat::Solvable & solv : myPool().multiversionList() )
733 {
734 queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
735 queue_push( &(_jobQueue), solv.id() );
736 }
737
738 ::pool_add_userinstalled_jobs(_satPool, sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
739 }
740
741 void
742 SATResolver::solverEnd()
743 {
744 // cleanup
745 if ( _satSolver )
746 {
747 solver_free(_satSolver);
748 _satSolver = NULL;
749 queue_free( &(_jobQueue) );
750 }
751 }
752
753
754 bool
755 SATResolver::resolvePool(const CapabilitySet & requires_caps,
756 const CapabilitySet & conflict_caps,
757 const PoolItemList & weakItems,
758 const std::set<Repository> & upgradeRepos)
759 {
760 MIL << "SATResolver::resolvePool()" << endl;
761
762 // initialize
763 solverInit(weakItems);
764
765 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
766 Id id = (*iter)->satSolvable().id();
767 if (id == ID_NULL) {
768 ERR << "Install: " << *iter << " not found" << endl;
769 } else {
770 MIL << "Install " << *iter << endl;
771 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
772 queue_push( &(_jobQueue), id );
773 }
774 }
775
776 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
777 Id id = (*iter)->satSolvable().id();
778 if (id == ID_NULL) {
779 ERR << "Delete: " << *iter << " not found" << endl;
780 } else {
781 MIL << "Delete " << *iter << endl;
782 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
783 queue_push( &(_jobQueue), id);
784 }
785 }
786
787 for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
788 {
789 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
790 queue_push( &(_jobQueue), iter->get()->repoid );
791 MIL << "Upgrade repo " << *iter << endl;
792 }
793
794 for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
795 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
796 queue_push( &(_jobQueue), iter->id() );
797 MIL << "Requires " << *iter << endl;
798 }
799
800 for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
801 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
802 queue_push( &(_jobQueue), iter->id() );
803 MIL << "Conflicts " << *iter << endl;
804 }
805
806 // set requirements for a running system
807 setSystemRequirements();
808
809 // set locks for the solver
810 setLocks();
811
812 // solving
813 bool ret = solving(requires_caps, conflict_caps);
814
815 (ret?MIL:WAR) << "SATResolver::resolvePool() done. Ret:" << ret << endl;
816 return ret;
817 }
818
819
820 bool
821 SATResolver::resolveQueue(const SolverQueueItemList &requestQueue,
822 const PoolItemList & weakItems)
823 {
824 MIL << "SATResolver::resolvQueue()" << endl;
825
826 // initialize
827 solverInit(weakItems);
828
829 // generate solver queue
830 for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
831 (*iter)->addRule(_jobQueue);
832 }
833
834 // Add addition item status to the resolve-queue cause these can be set by problem resolutions
835 for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
836 Id id = (*iter)->satSolvable().id();
837 if (id == ID_NULL) {
838 ERR << "Install: " << *iter << " not found" << endl;
839 } else {
840 MIL << "Install " << *iter << endl;
841 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
842 queue_push( &(_jobQueue), id );
843 }
844 }
845 for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
846 sat::detail::IdType ident( (*iter)->satSolvable().ident().id() );
847 MIL << "Delete " << *iter << ident << endl;
848 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | MAYBE_CLEANDEPS );
849 queue_push( &(_jobQueue), ident);
850 }
851
852 // set requirements for a running system
853 setSystemRequirements();
854
855 // set locks for the solver
856 setLocks();
857
858 // solving
859 bool ret = solving();
860
861 MIL << "SATResolver::resolveQueue() done. Ret:" << ret << endl;
862 return ret;
863 }
864
866 void SATResolver::doUpdate()
867 {
868 MIL << "SATResolver::doUpdate()" << endl;
869
870 // initialize
871 solverInit(PoolItemList());
872
873 // set requirements for a running system
874 setSystemRequirements();
875
876 // set locks for the solver
877 setLocks();
878
879 if (_fixsystem) {
880 queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
881 queue_push( &(_jobQueue), 0 );
882 }
883 if (1) {
884 queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
885 queue_push( &(_jobQueue), 0 );
886 }
887 if (_distupgrade) {
888 queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
889 queue_push( &(_jobQueue), 0 );
890 }
891 if (_distupgrade_removeunsupported) {
892 queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
893 queue_push( &(_jobQueue), 0 );
894 }
895 solverSetFocus( *_satSolver, _focus );
896 solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
897 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
898 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
899 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
900 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
901 solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
902 solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
903 solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
904 solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, false); // resolve recommended namespaces
905 solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires); //
906
907 sat::Pool::instance().prepare();
908
909 // Solve !
910 MIL << "Starting solving for update...." << endl;
911 MIL << *this;
912 solver_solve( _satSolver, &(_jobQueue) );
913 MIL << "....Solver end" << endl;
914
915 // copying solution back to zypp pool
916 //-----------------------------------------
917
918 /* solvables to be installed */
919 Queue decisionq;
920 queue_init(&decisionq);
921 solver_get_decisionqueue(_satSolver, &decisionq);
922 for (int i = 0; i < decisionq.count; i++)
923 {
924 Id p = decisionq.elements[i];
925 if ( p < 0 )
926 continue;
927
928 sat::Solvable solv { (sat::detail::SolvableIdType)p };
929 if ( ! solv || solv.isSystem() )
930 continue;
931
932 SATSolutionToPool( PoolItem(solv), ResStatus::toBeInstalled, ResStatus::SOLVER );
933 }
934 queue_free(&decisionq);
935
936 /* solvables to be erased */
937 if ( _satSolver->pool->installed ) {
938 for (int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
939 {
940 if (solver_get_decisionlevel(_satSolver, i) > 0)
941 continue;
942
943 PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
944 if (poolItem) {
945 // Check if this is an update
946 CheckIfUpdate info( (sat::Solvable(i)) );
947 invokeOnEach( _pool.byIdentBegin( poolItem ),
948 _pool.byIdentEnd( poolItem ),
949 resfilter::ByUninstalled(), // ByUninstalled
950 functor::functorRef<bool,PoolItem> (info) );
951
952 if (info.is_updated) {
953 SATSolutionToPool (poolItem, ResStatus::toBeUninstalledDueToUpgrade , ResStatus::SOLVER);
954 } else {
955 SATSolutionToPool (poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER);
956 }
957 } else {
958 ERR << "id " << i << " not found in ZYPP pool." << endl;
959 }
960 }
961 }
962
963 // copy back computed status values to pool
964 // (on the fly cache orphaned items for the UI)
965 solverCopyBackWeak( *_satSolver, _problem_items );
966 solverCopyBackValidate( *_satSolver, _pool );
967
968 MIL << "SATResolver::doUpdate() done" << endl;
969 }
970
971
972
973 //----------------------------------------------------------------------------
974 //----------------------------------------------------------------------------
975 // error handling
976 //----------------------------------------------------------------------------
977 //----------------------------------------------------------------------------
978
979 //----------------------------------------------------------------------------
980 // helper function
981 //----------------------------------------------------------------------------
982
983 struct FindPackage : public resfilter::ResObjectFilterFunctor
984 {
985 ProblemSolutionCombi *problemSolution;
986 TransactionKind action;
987 FindPackage (ProblemSolutionCombi *p, const TransactionKind act)
988 : problemSolution (p)
989 , action (act)
990 {
991 }
992
993 bool operator()( PoolItem p)
994 {
995 problemSolution->addSingleAction (p, action);
996 return true;
997 }
998 };
999
1000
1001 //----------------------------------------------------------------------------
1002 // Checking if this solvable/item has a buddy which reflect the real
1003 // user visible description of an item
1004 // e.g. The release package has a buddy to the concerning product item.
1005 // This user want's the message "Product foo conflicts with product bar" and
1006 // NOT "package release-foo conflicts with package release-bar"
1007 // (ma: that's why we should map just packages to buddies, not vice versa)
1008 //----------------------------------------------------------------------------
1009 inline sat::Solvable mapBuddy( const PoolItem & item_r )
1010 {
1011 if ( item_r.satSolvable().isKind<Package>() )
1012 {
1013 sat::Solvable buddy = item_r.buddy();
1014 if ( buddy )
1015 return buddy;
1016 }
1017 return item_r.satSolvable();
1018 }
1019 inline sat::Solvable mapBuddy( sat::Solvable item_r )
1020 { return mapBuddy( PoolItem( item_r ) ); }
1021
1022 PoolItem SATResolver::mapItem ( const PoolItem & item )
1023 { return PoolItem( mapBuddy( item ) ); }
1024
1025 sat::Solvable SATResolver::mapSolvable ( const Id & id )
1026 { return mapBuddy( sat::Solvable(id) ); }
1027
1028 std::vector<std::string> SATResolver::SATgetCompleteProblemInfoStrings ( Id problem )
1029 {
1030 std::vector<std::string> ret;
1031 sat::Queue problems;
1032 solver_findallproblemrules( _satSolver, problem, problems );
1033
1034 bool nobad = false;
1035
1036 //filter out generic rule information if more explicit ones are available
1037 for ( sat::Queue::size_type i = 0; i < problems.size(); i++ ) {
1038 SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1039 if ( ruleClass != SolverRuleinfo::SOLVER_RULE_UPDATE && ruleClass != SolverRuleinfo::SOLVER_RULE_JOB ) {
1040 nobad = true;
1041 break;
1042 }
1043 }
1044 for ( sat::Queue::size_type i = 0; i < problems.size(); i++ ) {
1045 SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1046 if ( nobad && ( ruleClass == SolverRuleinfo::SOLVER_RULE_UPDATE || ruleClass == SolverRuleinfo::SOLVER_RULE_JOB ) ) {
1047 continue;
1048 }
1049
1050 std::string detail;
1051 Id ignore = 0;
1052 std::string pInfo = SATproblemRuleInfoString( problems[i], detail, ignore );
1053
1054 //we get the same string multiple times, reduce the noise
1055 if ( std::find( ret.begin(), ret.end(), pInfo ) == ret.end() )
1056 ret.push_back( pInfo );
1057 }
1058 return ret;
1059 }
1060
1061 std::string SATResolver::SATprobleminfoString(Id problem, std::string &detail, Id &ignoreId)
1062 {
1063 // FIXME: solver_findallproblemrules to get all rules for this problem
1064 // (the 'most relevabt' one returned by solver_findproblemrule is embedded
1065 Id probr = solver_findproblemrule(_satSolver, problem);
1066 return SATproblemRuleInfoString( probr, detail, ignoreId );
1067 }
1068
1069 #ifdef ZYPPNEWSPPSWENPPYZ
1070 #warning New texts in SP preview - still to be translated...
1071 std::string SATResolver::SATproblemRuleInfoString (Id probr, std::string &detail, Id &ignoreId)
1072 {
1073 std::string ret;
1074 sat::detail::CPool *pool = _satSolver->pool;
1075 Id dep, source, target;
1076 SolverRuleinfo type = solver_ruleinfo(_satSolver, probr, &source, &target, &dep);
1077
1078 ignoreId = 0;
1079
1080 sat::Solvable s = mapSolvable( source );
1081 sat::Solvable s2 = mapSolvable( target );
1082
1083 // @FIXME, these strings are a duplicate copied from the libsolv library
1084 // to provide translations. Instead of having duplicate code we should
1085 // translate those strings directly in libsolv
1086 switch ( type )
1087 {
1088 case SOLVER_RULE_DISTUPGRADE:
1089 if ( s.isSystem() )
1090 ret = str::Format(_("the installed %1% does not belong to a distupgrade repository and must be replaced") ) % s.asString();
1091 else /*just in case*/
1092 ret = str::Format(_("the to be installed %1% does not belong to a distupgrade repository") ) % s.asString();
1093 break;
1094 case SOLVER_RULE_INFARCH:
1095 if ( s.isSystem() )
1096 ret = str::Format(_("the installed %1% has inferior architecture") ) % s.asString();
1097 else
1098 ret = str::Format(_("the to be installed %1% has inferior architecture") ) % s.asString();
1099 break;
1100 case SOLVER_RULE_UPDATE:
1101 ret = str::Format(_("problem with the installed %1%") ) % s.asString();
1102 break;
1103 case SOLVER_RULE_JOB:
1104 ret = _("conflicting requests");
1105 break;
1106 case SOLVER_RULE_PKG:
1107 ret = _("some dependency problem");
1108 break;
1109 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1110 ret = str::Format(_("nothing provides the requested '%1%'") ) % pool_dep2str(pool, dep);
1111 detail += _("Have you enabled all the required repositories?");
1112 break;
1113 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1114 ret = str::Format(_("the requested package %1% does not exist") ) % pool_dep2str(pool, dep);
1115 detail += _("Have you enabled all the required repositories?");
1116 break;
1117 case SOLVER_RULE_JOB_UNSUPPORTED:
1118 ret = _("unsupported request");
1119 break;
1120 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1121 ret = str::Format(_("'%1%' is provided by the system and cannot be erased") ) % pool_dep2str(pool, dep);
1122 break;
1123 case SOLVER_RULE_PKG_NOT_INSTALLABLE:
1124 ret = str::Format(_("%1% is not installable") ) % s.asString();
1125 break;
1126 case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
1127 ignoreId = source; // for setting weak dependencies
1128 if ( s.isSystem() )
1129 ret = str::Format(_("nothing provides '%1%' needed by the installed %2%") ) % pool_dep2str(pool, dep) % s.asString();
1130 else
1131 ret = str::Format(_("nothing provides '%1%' needed by the to be installed %2%") ) % pool_dep2str(pool, dep) % s.asString();
1132 break;
1133 case SOLVER_RULE_PKG_SAME_NAME:
1134 ret = str::Format(_("cannot install both %1% and %2%") ) % s.asString() % s2.asString();
1135 break;
1136 case SOLVER_RULE_PKG_CONFLICTS:
1137 if ( s.isSystem() ) {
1138 if ( s2.isSystem() )
1139 ret = str::Format(_("the installed %1% conflicts with '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1140 else
1141 ret = str::Format(_("the installed %1% conflicts with '%2%' provided by the to be installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1142 }
1143 else {
1144 if ( s2.isSystem() )
1145 ret = str::Format(_("the to be installed %1% conflicts with '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1146 else
1147 ret = str::Format(_("the to be installed %1% conflicts with '%2%' provided by the to be installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1148 }
1149 break;
1150 case SOLVER_RULE_PKG_OBSOLETES:
1151 case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
1152 if ( s.isSystem() ) {
1153 if ( s2.isSystem() )
1154 ret = str::Format(_("the installed %1% obsoletes '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1155 else
1156 ret = str::Format(_("the installed %1% obsoletes '%2%' provided by the to be installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1157 }
1158 else {
1159 if ( s2.isSystem() )
1160 ret = str::Format(_("the to be installed %1% obsoletes '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1161 else
1162 ret = str::Format(_("the to be installed %1% obsoletes '%2%' provided by the to be installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1163 }
1164 break;
1165 case SOLVER_RULE_PKG_SELF_CONFLICT:
1166 if ( s.isSystem() )
1167 ret = str::Format(_("the installed %1% conflicts with '%2%' provided by itself") ) % s.asString() % pool_dep2str(pool, dep);
1168 else
1169 ret = str::Format(_("the to be installed %1% conflicts with '%2%' provided by itself") ) % s.asString() % pool_dep2str(pool, dep);
1170 break;
1171 case SOLVER_RULE_PKG_REQUIRES: {
1172 ignoreId = source; // for setting weak dependencies
1173 Capability cap(dep);
1174 sat::WhatProvides possibleProviders(cap);
1175
1176 // check, if a provider will be deleted
1177 typedef std::list<PoolItem> ProviderList;
1178 ProviderList providerlistInstalled, providerlistUninstalled;
1179 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1180 PoolItem provider1 = ResPool::instance().find( *iter1 );
1181 // find pair of an installed/uninstalled item with the same NVR
1182 bool found = false;
1183 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1184 PoolItem provider2 = ResPool::instance().find( *iter2 );
1185 if (compareByNVR (provider1,provider2) == 0
1186 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1187 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1188 found = true;
1189 break;
1190 }
1191 }
1192 if (!found) {
1193 if (provider1.status().isInstalled())
1194 providerlistInstalled.push_back(provider1);
1195 else
1196 providerlistUninstalled.push_back(provider1);
1197 }
1198 }
1199
1200 if ( s.isSystem() )
1201 ret = str::Format(_("the installed %1% requires '%2%', but this requirement cannot be provided") ) % s.asString() % pool_dep2str(pool, dep);
1202 else
1203 ret = str::Format(_("the to be installed %1% requires '%2%', but this requirement cannot be provided") ) % s.asString() % pool_dep2str(pool, dep);
1204 if (providerlistInstalled.size() > 0) {
1205 detail += _("deleted providers: ");
1206 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1207 if (iter == providerlistInstalled.begin())
1208 detail += itemToString( *iter );
1209 else
1210 detail += "\n " + itemToString( mapItem(*iter) );
1211 }
1212 }
1213 if (providerlistUninstalled.size() > 0) {
1214 if (detail.size() > 0)
1215 detail += _("\nnot installable providers: ");
1216 else
1217 detail = _("not installable providers: ");
1218 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1219 if (iter == providerlistUninstalled.begin())
1220 detail += itemToString( *iter );
1221 else
1222 detail += "\n " + itemToString( mapItem(*iter) );
1223 }
1224 }
1225 break;
1226 }
1227 default: {
1228 DBG << "Unknown rule type(" << type << ") going to query libsolv for rule information." << endl;
1229 ret = str::asString( ::solver_problemruleinfo2str( _satSolver, type, static_cast<Id>(s.id()), static_cast<Id>(s2.id()), dep ) );
1230 break;
1231 }
1232 }
1233 return ret;
1234 }
1235
1236 ResolverProblemList
1237 SATResolver::problems ()
1238 {
1239 ResolverProblemList resolverProblems;
1240 if (_satSolver && solver_problem_count(_satSolver)) {
1241 sat::detail::CPool *pool = _satSolver->pool;
1242 int pcnt;
1243 Id p, rp, what;
1244 Id problem, solution, element;
1245 sat::Solvable s, sd;
1246
1247 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1248 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1249
1250 MIL << "Encountered problems! Here are the solutions:\n" << endl;
1251 pcnt = 1;
1252 problem = 0;
1253 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1254 MIL << "Problem " << pcnt++ << ":" << endl;
1255 MIL << "====================================" << endl;
1256 std::string detail;
1257 Id ignoreId;
1258 std::string whatString = SATprobleminfoString (problem,detail,ignoreId);
1259 MIL << whatString << endl;
1260 MIL << "------------------------------------" << endl;
1261 ResolverProblem_Ptr resolverProblem = new ResolverProblem (whatString, detail, SATgetCompleteProblemInfoStrings( problem ));
1262
1263 solution = 0;
1264 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1265 element = 0;
1266 ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi;
1267 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1268 if (p == SOLVER_SOLUTION_JOB) {
1269 /* job, rp is index into job queue */
1270 what = _jobQueue.elements[rp];
1271 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1272 {
1273 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1274 s = mapSolvable (what);
1275 PoolItem poolItem = _pool.find (s);
1276 if (poolItem) {
1277 if (pool->installed && s.get()->repo == pool->installed) {
1278 problemSolution->addSingleAction (poolItem, REMOVE);
1279 std::string description = str::Format(_("remove lock to allow removal of %1%") ) % s.asString();
1280 MIL << description << endl;
1281 problemSolution->addDescription (description);
1282 } else {
1283 problemSolution->addSingleAction (poolItem, KEEP);
1284 std::string description = str::Format(_("do not install %1%") ) % s.asString();
1285 MIL << description << endl;
1286 problemSolution->addDescription (description);
1287 }
1288 } else {
1289 ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1290 }
1291 }
1292 break;
1293 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1294 s = mapSolvable (what);
1295 PoolItem poolItem = _pool.find (s);
1296 if (poolItem) {
1297 if (pool->installed && s.get()->repo == pool->installed) {
1298 problemSolution->addSingleAction (poolItem, KEEP);
1299 std::string description = str::Format(_("keep %1%") ) % s.asString();
1300 MIL << description << endl;
1301 problemSolution->addDescription (description);
1302 } else {
1303 problemSolution->addSingleAction (poolItem, UNLOCK);
1304 std::string description = str::Format(_("remove lock to allow installation of %1%") ) % itemToString( poolItem );
1305 MIL << description << endl;
1306 problemSolution->addDescription (description);
1307 }
1308 } else {
1309 ERR << "SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1310 }
1311 }
1312 break;
1313 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1314 {
1315 IdString ident( what );
1316 SolverQueueItemInstall_Ptr install =
1317 new SolverQueueItemInstall(_pool, ident.asString(), false );
1318 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1319
1320 std::string description = str::Format(_("do not install %1%") ) % ident;
1321 MIL << description << endl;
1322 problemSolution->addDescription (description);
1323 }
1324 break;
1325 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1326 {
1327 // As we do not know, if this request has come from resolvePool or
1328 // resolveQueue we will have to take care for both cases.
1329 IdString ident( what );
1330 FindPackage info (problemSolution, KEEP);
1331 invokeOnEach( _pool.byIdentBegin( ident ),
1332 _pool.byIdentEnd( ident ),
1333 functor::chain (resfilter::ByInstalled (), // ByInstalled
1334 resfilter::ByTransact ()), // will be deinstalled
1335 functor::functorRef<bool,PoolItem> (info) );
1336
1337 SolverQueueItemDelete_Ptr del =
1338 new SolverQueueItemDelete(_pool, ident.asString(), false );
1339 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1340
1341 std::string description = str::Format(_("keep %1%") ) % ident;
1342 MIL << description << endl;
1343 problemSolution->addDescription (description);
1344 }
1345 break;
1346 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1347 {
1348 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1349 std::string description = "";
1350
1351 // Checking if this problem solution would break your system
1352 if (system_requires.find(Capability(what)) != system_requires.end()) {
1353 // Show a better warning
1354 resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1355 resolverProblem->setDescription(_("This request will break your system!"));
1356 description = _("ignore the warning of a broken system");
1357 description += std::string(" (requires:")+pool_dep2str(pool, what)+")";
1358 MIL << description << endl;
1359 problemSolution->addFrontDescription (description);
1360 } else {
1361 description = str::Format(_("do not ask to install a solvable providing %1%") ) % pool_dep2str(pool, what);
1362 MIL << description << endl;
1363 problemSolution->addDescription (description);
1364 }
1365 }
1366 break;
1367 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1368 {
1369 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1370 std::string description = "";
1371
1372 // Checking if this problem solution would break your system
1373 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1374 // Show a better warning
1375 resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1376 resolverProblem->setDescription(_("This request will break your system!"));
1377 description = _("ignore the warning of a broken system");
1378 description += std::string(" (conflicts:")+pool_dep2str(pool, what)+")";
1379 MIL << description << endl;
1380 problemSolution->addFrontDescription (description);
1381
1382 } else {
1383 description = str::Format(_("do not ask to delete all solvables providing %1%") ) % pool_dep2str(pool, what);
1384 MIL << description << endl;
1385 problemSolution->addDescription (description);
1386 }
1387 }
1388 break;
1389 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1390 {
1391 s = mapSolvable (what);
1392 PoolItem poolItem = _pool.find (s);
1393 if (poolItem) {
1394 if (pool->installed && s.get()->repo == pool->installed) {
1395 problemSolution->addSingleAction (poolItem, KEEP);
1396 std::string description = str::Format(_("do not install most recent version of %1%") ) % s.asString();
1397 MIL << description << endl;
1398 problemSolution->addDescription (description);
1399 } else {
1400 ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem << " is not selected for installation" << endl;
1401 }
1402 } else {
1403 ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1404 }
1405 }
1406 break;
1407 default:
1408 MIL << "- do something different" << endl;
1409 ERR << "No valid solution available" << endl;
1410 break;
1411 }
1412 } else if (p == SOLVER_SOLUTION_INFARCH) {
1413 s = mapSolvable (rp);
1414 PoolItem poolItem = _pool.find (s);
1415 if (pool->installed && s.get()->repo == pool->installed) {
1416 problemSolution->addSingleAction (poolItem, LOCK);
1417 std::string description = str::Format(_("keep %1% despite the inferior architecture") ) % s.asString();
1418 MIL << description << endl;
1419 problemSolution->addDescription (description);
1420 } else {
1421 problemSolution->addSingleAction (poolItem, INSTALL);
1422 std::string description = str::Format(_("install %1% despite the inferior architecture") ) % s.asString();
1423 MIL << description << endl;
1424 problemSolution->addDescription (description);
1425 }
1426 } else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1427 s = mapSolvable (rp);
1428 PoolItem poolItem = _pool.find (s);
1429 if (pool->installed && s.get()->repo == pool->installed) {
1430 problemSolution->addSingleAction (poolItem, LOCK);
1431 std::string description = str::Format(_("keep obsolete %1%") ) % s.asString();
1432 MIL << description << endl;
1433 problemSolution->addDescription (description);
1434 } else {
1435 problemSolution->addSingleAction (poolItem, INSTALL);
1436 std::string description = str::Format(_("install %1% from excluded repository") ) % s.asString();
1437 MIL << description << endl;
1438 problemSolution->addDescription (description);
1439 }
1440 } else if ( p == SOLVER_SOLUTION_BLACK ) {
1441 // Allow to install a blacklisted package (PTF, retracted,...).
1442 // For not-installed items only
1443 s = mapSolvable (rp);
1444 PoolItem poolItem = _pool.find (s);
1445
1446 problemSolution->addSingleAction (poolItem, INSTALL);
1447 std::string description;
1448 if ( s.isRetracted() ) {
1449 // translator: %1% is a package name
1450 description = str::Format(_("install %1% although it has been retracted")) % s.asString();
1451 } else if ( s.isPtf() ) {
1452 // translator: %1% is a package name
1453 description = str::Format(_("allow to install the PTF %1%")) % s.asString();
1454 } else {
1455 // translator: %1% is a package name
1456 description = str::Format(_("install %1% although it is blacklisted")) % s.asString();
1457 }
1458 MIL << description << endl;
1459 problemSolution->addDescription( description );
1460 } else if ( p > 0 ) {
1461 /* policy, replace p with rp */
1462 s = mapSolvable (p);
1463 PoolItem itemFrom = _pool.find (s);
1464 if (rp)
1465 {
1466 int gotone = 0;
1467
1468 sd = mapSolvable (rp);
1469 PoolItem itemTo = _pool.find (sd);
1470 if (itemFrom && itemTo) {
1471 problemSolution->addSingleAction (itemTo, INSTALL);
1472 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1473
1474 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1475 {
1476 std::string description = str::Format(_("downgrade of %1% to %2%") ) % s.asString() % sd.asString();
1477 MIL << description << endl;
1478 problemSolution->addDescription (description);
1479 gotone = 1;
1480 }
1481 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1482 {
1483 std::string description = str::Format(_("architecture change of %1% to %2%") ) % s.asString() % sd.asString();
1484 MIL << description << endl;
1485 problemSolution->addDescription (description);
1486 gotone = 1;
1487 }
1488 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1489 {
1490 IdString s_vendor( s.vendor() );
1491 IdString sd_vendor( sd.vendor() );
1492 std::string description = str::Format(_("install %1% (with vendor change)\n %2% --> %3%") ) % sd.asString() % ( s_vendor ? s_vendor.c_str() : " (no vendor) " ) % ( sd_vendor ? sd_vendor.c_str() : " (no vendor) " );
1493 MIL << description << endl;
1494 problemSolution->addDescription (description);
1495 gotone = 1;
1496 }
1497 if (!gotone) {
1498 std::string description = str::Format(_("replacement of %1% with %2%") ) % s.asString() % sd.asString();
1499 MIL << description << endl;
1500 problemSolution->addDescription (description);
1501 }
1502 } else {
1503 ERR << s.asString() << " or " << sd.asString() << " not found" << endl;
1504 }
1505 }
1506 else
1507 {
1508 if (itemFrom) {
1509 std::string description = str::Format(_("deinstallation of %1%") ) % s.asString();
1510 MIL << description << endl;
1511 problemSolution->addDescription (description);
1512 problemSolution->addSingleAction (itemFrom, REMOVE);
1513 }
1514 }
1515 }
1516 else
1517 {
1518 INT << "Unknown solution " << p << endl;
1519 }
1520
1521 }
1522 resolverProblem->addSolution (problemSolution,
1523 problemSolution->actionCount() > 1 ? true : false); // Solutions with more than 1 action will be shown first.
1524 MIL << "------------------------------------" << endl;
1525 }
1526
1527 if (ignoreId > 0) {
1528 // There is a possibility to ignore this error by setting weak dependencies
1529 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1530 ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(item);
1531 resolverProblem->addSolution (problemSolution,
1532 false); // Solutions will be shown at the end
1533 MIL << "ignore some dependencies of " << item << endl;
1534 MIL << "------------------------------------" << endl;
1535 }
1536
1537 // save problem
1538 resolverProblems.push_back (resolverProblem);
1539 }
1540 }
1541 return resolverProblems;
1542 }
1543 #else // no ZYPPNEWSPPSWENPPYZ
1544 #warning Legacy texts
1545 std::string SATResolver::SATproblemRuleInfoString (Id probr, std::string &detail, Id &ignoreId)
1546 {
1547 std::string ret;
1548 sat::detail::CPool *pool = _satSolver->pool;
1549 Id dep, source, target;
1550 SolverRuleinfo type = solver_ruleinfo(_satSolver, probr, &source, &target, &dep);
1551
1552 ignoreId = 0;
1553
1554 sat::Solvable s = mapSolvable( source );
1555 sat::Solvable s2 = mapSolvable( target );
1556
1557 // @FIXME, these strings are a duplicate copied from the libsolv library
1558 // to provide translations. Instead of having duplicate code we should
1559 // translate those strings directly in libsolv
1560 switch ( type )
1561 {
1562 case SOLVER_RULE_DISTUPGRADE:
1563 ret = str::form (_("%s does not belong to a distupgrade repository"), s.asString().c_str());
1564 break;
1565 case SOLVER_RULE_INFARCH:
1566 ret = str::form (_("%s has inferior architecture"), s.asString().c_str());
1567 break;
1568 case SOLVER_RULE_UPDATE:
1569 ret = str::form (_("problem with installed package %s"), s.asString().c_str());
1570 break;
1571 case SOLVER_RULE_JOB:
1572 ret = _("conflicting requests");
1573 break;
1574 case SOLVER_RULE_PKG:
1575 ret = _("some dependency problem");
1576 break;
1577 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1578 ret = str::form (_("nothing provides requested %s"), pool_dep2str(pool, dep));
1579 detail += _("Have you enabled all requested repositories?");
1580 break;
1581 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1582 ret = str::form (_("package %s does not exist"), pool_dep2str(pool, dep));
1583 detail += _("Have you enabled all requested repositories?");
1584 break;
1585 case SOLVER_RULE_JOB_UNSUPPORTED:
1586 ret = _("unsupported request");
1587 break;
1588 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1589 ret = str::form (_("%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1590 break;
1591 case SOLVER_RULE_PKG_NOT_INSTALLABLE:
1592 ret = str::form (_("%s is not installable"), s.asString().c_str());
1593 break;
1594 case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
1595 ignoreId = source; // for setting weak dependencies
1596 ret = str::form (_("nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1597 break;
1598 case SOLVER_RULE_PKG_SAME_NAME:
1599 ret = str::form (_("cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1600 break;
1601 case SOLVER_RULE_PKG_CONFLICTS:
1602 ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1603 break;
1604 case SOLVER_RULE_PKG_OBSOLETES:
1605 ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1606 break;
1607 case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
1608 ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1609 break;
1610 case SOLVER_RULE_PKG_SELF_CONFLICT:
1611 ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1612 break;
1613 case SOLVER_RULE_PKG_REQUIRES: {
1614 ignoreId = source; // for setting weak dependencies
1615 Capability cap(dep);
1616 sat::WhatProvides possibleProviders(cap);
1617
1618 // check, if a provider will be deleted
1619 typedef std::list<PoolItem> ProviderList;
1620 ProviderList providerlistInstalled, providerlistUninstalled;
1621 for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1622 PoolItem provider1 = ResPool::instance().find( *iter1 );
1623 // find pair of an installed/uninstalled item with the same NVR
1624 bool found = false;
1625 for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1626 PoolItem provider2 = ResPool::instance().find( *iter2 );
1627 if (compareByNVR (provider1,provider2) == 0
1628 && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1629 || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1630 found = true;
1631 break;
1632 }
1633 }
1634 if (!found) {
1635 if (provider1.status().isInstalled())
1636 providerlistInstalled.push_back(provider1);
1637 else
1638 providerlistUninstalled.push_back(provider1);
1639 }
1640 }
1641
1642 ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1643 if (providerlistInstalled.size() > 0) {
1644 detail += _("deleted providers: ");
1645 for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1646 if (iter == providerlistInstalled.begin())
1647 detail += itemToString( *iter );
1648 else
1649 detail += "\n " + itemToString( mapItem(*iter) );
1650 }
1651 }
1652 if (providerlistUninstalled.size() > 0) {
1653 if (detail.size() > 0)
1654 detail += _("\nnot installable providers: ");
1655 else
1656 detail = _("not installable providers: ");
1657 for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1658 if (iter == providerlistUninstalled.begin())
1659 detail += itemToString( *iter );
1660 else
1661 detail += "\n " + itemToString( mapItem(*iter) );
1662 }
1663 }
1664 break;
1665 }
1666 default: {
1667 DBG << "Unknown rule type(" << type << ") going to query libsolv for rule information." << endl;
1668 ret = str::asString( ::solver_problemruleinfo2str( _satSolver, type, static_cast<Id>(s.id()), static_cast<Id>(s2.id()), dep ) );
1669 break;
1670 }
1671 }
1672 return ret;
1673 }
1674
1675 ResolverProblemList
1676 SATResolver::problems ()
1677 {
1678 ResolverProblemList resolverProblems;
1679 if (_satSolver && solver_problem_count(_satSolver)) {
1680 sat::detail::CPool *pool = _satSolver->pool;
1681 int pcnt;
1682 Id p, rp, what;
1683 Id problem, solution, element;
1684 sat::Solvable s, sd;
1685
1686 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1687 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1688
1689 MIL << "Encountered problems! Here are the solutions:\n" << endl;
1690 pcnt = 1;
1691 problem = 0;
1692 while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1693 MIL << "Problem " << pcnt++ << ":" << endl;
1694 MIL << "====================================" << endl;
1695 std::string detail;
1696 Id ignoreId;
1697 std::string whatString = SATprobleminfoString (problem,detail,ignoreId);
1698 MIL << whatString << endl;
1699 MIL << "------------------------------------" << endl;
1700 ResolverProblem_Ptr resolverProblem = new ResolverProblem (whatString, detail, SATgetCompleteProblemInfoStrings( problem ));
1701
1702 solution = 0;
1703 while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1704 element = 0;
1705 ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi;
1706 while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1707 if (p == SOLVER_SOLUTION_JOB) {
1708 /* job, rp is index into job queue */
1709 what = _jobQueue.elements[rp];
1710 switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1711 {
1712 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1713 s = mapSolvable (what);
1714 PoolItem poolItem = _pool.find (s);
1715 if (poolItem) {
1716 if (pool->installed && s.get()->repo == pool->installed) {
1717 problemSolution->addSingleAction (poolItem, REMOVE);
1718 std::string description = str::form (_("remove lock to allow removal of %s"), s.asString().c_str() );
1719 MIL << description << endl;
1720 problemSolution->addDescription (description);
1721 } else {
1722 problemSolution->addSingleAction (poolItem, KEEP);
1723 std::string description = str::form (_("do not install %s"), s.asString().c_str());
1724 MIL << description << endl;
1725 problemSolution->addDescription (description);
1726 }
1727 } else {
1728 ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1729 }
1730 }
1731 break;
1732 case SOLVER_ERASE | SOLVER_SOLVABLE: {
1733 s = mapSolvable (what);
1734 PoolItem poolItem = _pool.find (s);
1735 if (poolItem) {
1736 if (pool->installed && s.get()->repo == pool->installed) {
1737 problemSolution->addSingleAction (poolItem, KEEP);
1738 std::string description = str::form (_("keep %s"), s.asString().c_str());
1739 MIL << description << endl;
1740 problemSolution->addDescription (description);
1741 } else {
1742 problemSolution->addSingleAction (poolItem, UNLOCK);
1743 std::string description = str::form (_("remove lock to allow installation of %s"), itemToString( poolItem ).c_str());
1744 MIL << description << endl;
1745 problemSolution->addDescription (description);
1746 }
1747 } else {
1748 ERR << "SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1749 }
1750 }
1751 break;
1752 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1753 {
1754 IdString ident( what );
1755 SolverQueueItemInstall_Ptr install =
1756 new SolverQueueItemInstall(_pool, ident.asString(), false );
1757 problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1758
1759 std::string description = str::form (_("do not install %s"), ident.c_str() );
1760 MIL << description << endl;
1761 problemSolution->addDescription (description);
1762 }
1763 break;
1764 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1765 {
1766 // As we do not know, if this request has come from resolvePool or
1767 // resolveQueue we will have to take care for both cases.
1768 IdString ident( what );
1769 FindPackage info (problemSolution, KEEP);
1770 invokeOnEach( _pool.byIdentBegin( ident ),
1771 _pool.byIdentEnd( ident ),
1772 functor::chain (resfilter::ByInstalled (), // ByInstalled
1773 resfilter::ByTransact ()), // will be deinstalled
1774 functor::functorRef<bool,PoolItem> (info) );
1775
1776 SolverQueueItemDelete_Ptr del =
1777 new SolverQueueItemDelete(_pool, ident.asString(), false );
1778 problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1779
1780 std::string description = str::form (_("keep %s"), ident.c_str());
1781 MIL << description << endl;
1782 problemSolution->addDescription (description);
1783 }
1784 break;
1785 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1786 {
1787 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1788 std::string description = "";
1789
1790 // Checking if this problem solution would break your system
1791 if (system_requires.find(Capability(what)) != system_requires.end()) {
1792 // Show a better warning
1793 resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1794 resolverProblem->setDescription(_("This request will break your system!"));
1795 description = _("ignore the warning of a broken system");
1796 description += std::string(" (requires:")+pool_dep2str(pool, what)+")";
1797 MIL << description << endl;
1798 problemSolution->addFrontDescription (description);
1799 } else {
1800 description = str::form (_("do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1801 MIL << description << endl;
1802 problemSolution->addDescription (description);
1803 }
1804 }
1805 break;
1806 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1807 {
1808 problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1809 std::string description = "";
1810
1811 // Checking if this problem solution would break your system
1812 if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1813 // Show a better warning
1814 resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1815 resolverProblem->setDescription(_("This request will break your system!"));
1816 description = _("ignore the warning of a broken system");
1817 description += std::string(" (conflicts:")+pool_dep2str(pool, what)+")";
1818 MIL << description << endl;
1819 problemSolution->addFrontDescription (description);
1820
1821 } else {
1822 description = str::form (_("do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1823 MIL << description << endl;
1824 problemSolution->addDescription (description);
1825 }
1826 }
1827 break;
1828 case SOLVER_UPDATE | SOLVER_SOLVABLE:
1829 {
1830 s = mapSolvable (what);
1831 PoolItem poolItem = _pool.find (s);
1832 if (poolItem) {
1833 if (pool->installed && s.get()->repo == pool->installed) {
1834 problemSolution->addSingleAction (poolItem, KEEP);
1835 std::string description = str::form (_("do not install most recent version of %s"), s.asString().c_str());
1836 MIL << description << endl;
1837 problemSolution->addDescription (description);
1838 } else {
1839 ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem << " is not selected for installation" << endl;
1840 }
1841 } else {
1842 ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1843 }
1844 }
1845 break;
1846 default:
1847 MIL << "- do something different" << endl;
1848 ERR << "No valid solution available" << endl;
1849 break;
1850 }
1851 } else if (p == SOLVER_SOLUTION_INFARCH) {
1852 s = mapSolvable (rp);
1853 PoolItem poolItem = _pool.find (s);
1854 if (pool->installed && s.get()->repo == pool->installed) {
1855 problemSolution->addSingleAction (poolItem, LOCK);
1856 std::string description = str::form (_("keep %s despite the inferior architecture"), s.asString().c_str());
1857 MIL << description << endl;
1858 problemSolution->addDescription (description);
1859 } else {
1860 problemSolution->addSingleAction (poolItem, INSTALL);
1861 std::string description = str::form (_("install %s despite the inferior architecture"), s.asString().c_str());
1862 MIL << description << endl;
1863 problemSolution->addDescription (description);
1864 }
1865 } else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1866 s = mapSolvable (rp);
1867 PoolItem poolItem = _pool.find (s);
1868 if (pool->installed && s.get()->repo == pool->installed) {
1869 problemSolution->addSingleAction (poolItem, LOCK);
1870 std::string description = str::form (_("keep obsolete %s"), s.asString().c_str());
1871 MIL << description << endl;
1872 problemSolution->addDescription (description);
1873 } else {
1874 problemSolution->addSingleAction (poolItem, INSTALL);
1875 std::string description = str::form (_("install %s from excluded repository"), s.asString().c_str());
1876 MIL << description << endl;
1877 problemSolution->addDescription (description);
1878 }
1879 } else if ( p == SOLVER_SOLUTION_BLACK ) {
1880 // Allow to install a blacklisted package (PTF, retracted,...).
1881 // For not-installed items only
1882 s = mapSolvable (rp);
1883 PoolItem poolItem = _pool.find (s);
1884
1885 problemSolution->addSingleAction (poolItem, INSTALL);
1886 std::string description;
1887 if ( s.isRetracted() ) {
1888 // translator: %1% is a package name
1889 description = str::Format(_("install %1% although it has been retracted")) % s.asString();
1890 } else if ( s.isPtf() ) {
1891 // translator: %1% is a package name
1892 description = str::Format(_("allow to install the PTF %1%")) % s.asString();
1893 } else {
1894 // translator: %1% is a package name
1895 description = str::Format(_("install %1% although it is blacklisted")) % s.asString();
1896 }
1897 MIL << description << endl;
1898 problemSolution->addDescription( description );
1899 } else if ( p > 0 ) {
1900 /* policy, replace p with rp */
1901 s = mapSolvable (p);
1902 PoolItem itemFrom = _pool.find (s);
1903 if (rp)
1904 {
1905 int gotone = 0;
1906
1907 sd = mapSolvable (rp);
1908 PoolItem itemTo = _pool.find (sd);
1909 if (itemFrom && itemTo) {
1910 problemSolution->addSingleAction (itemTo, INSTALL);
1911 int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1912
1913 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1914 {
1915 std::string description = str::form (_("downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1916 MIL << description << endl;
1917 problemSolution->addDescription (description);
1918 gotone = 1;
1919 }
1920 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1921 {
1922 std::string description = str::form (_("architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1923 MIL << description << endl;
1924 problemSolution->addDescription (description);
1925 gotone = 1;
1926 }
1927 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1928 {
1929 IdString s_vendor( s.vendor() );
1930 IdString sd_vendor( sd.vendor() );
1931 std::string description = str::form (_("install %s (with vendor change)\n %s --> %s") ,
1932 sd.asString().c_str(),
1933 ( s_vendor ? s_vendor.c_str() : " (no vendor) " ),
1934 ( sd_vendor ? sd_vendor.c_str() : " (no vendor) " ) );
1935 MIL << description << endl;
1936 problemSolution->addDescription (description);
1937 gotone = 1;
1938 }
1939 if (!gotone) {
1940 std::string description = str::form (_("replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1941 MIL << description << endl;
1942 problemSolution->addDescription (description);
1943 }
1944 } else {
1945 ERR << s.asString() << " or " << sd.asString() << " not found" << endl;
1946 }
1947 }
1948 else
1949 {
1950 if (itemFrom) {
1951 std::string description = str::form (_("deinstallation of %s"), s.asString().c_str());
1952 MIL << description << endl;
1953 problemSolution->addDescription (description);
1954 problemSolution->addSingleAction (itemFrom, REMOVE);
1955 }
1956 }
1957 }
1958 else
1959 {
1960 INT << "Unknown solution " << p << endl;
1961 }
1962
1963 }
1964 resolverProblem->addSolution (problemSolution,
1965 problemSolution->actionCount() > 1 ? true : false); // Solutions with more than 1 action will be shown first.
1966 MIL << "------------------------------------" << endl;
1967 }
1968
1969 if (ignoreId > 0) {
1970 // There is a possibility to ignore this error by setting weak dependencies
1971 PoolItem item = _pool.find (sat::Solvable(ignoreId));
1972 ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(item);
1973 resolverProblem->addSolution (problemSolution,
1974 false); // Solutions will be shown at the end
1975 MIL << "ignore some dependencies of " << item << endl;
1976 MIL << "------------------------------------" << endl;
1977 }
1978
1979 // save problem
1980 resolverProblems.push_back (resolverProblem);
1981 }
1982 }
1983 return resolverProblems;
1984 }
1985 #endif // ZYPPNEWSPPSWENPPYZ
1986
1987 void SATResolver::applySolutions( const ProblemSolutionList & solutions )
1988 { Resolver( _pool ).applySolutions( solutions ); }
1989
1990 void SATResolver::setLocks()
1991 {
1992 unsigned icnt = 0;
1993 unsigned acnt = 0;
1994
1995 for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1996 sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
1997 if (iter->status().isInstalled()) {
1998 ++icnt;
1999 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
2000 queue_push( &(_jobQueue), ident );
2001 } else {
2002 ++acnt;
2003 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
2004 queue_push( &(_jobQueue), ident );
2005 }
2006 }
2007 MIL << "Locked " << icnt << " installed items and " << acnt << " NOT installed items." << endl;
2008
2010 // Weak locks: Ignore if an item with this name is already installed.
2011 // If it's not installed try to keep it this way using a weak delete
2013 std::set<IdString> unifiedByName;
2014 for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
2015 IdString ident( (*iter)->satSolvable().ident() );
2016 if ( unifiedByName.insert( ident ).second )
2017 {
2018 if ( ! ui::Selectable::get( *iter )->hasInstalledObj() )
2019 {
2020 MIL << "Keep NOT installed name " << ident << " (" << *iter << ")" << endl;
2021 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK | MAYBE_CLEANDEPS );
2022 queue_push( &(_jobQueue), ident.id() );
2023 }
2024 }
2025 }
2026 }
2027
2028 void SATResolver::setSystemRequirements()
2029 {
2030 CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
2031 CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
2032
2033 for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
2034 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
2035 queue_push( &(_jobQueue), iter->id() );
2036 MIL << "SYSTEM Requires " << *iter << endl;
2037 }
2038
2039 for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
2040 queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
2041 queue_push( &(_jobQueue), iter->id() );
2042 MIL << "SYSTEM Conflicts " << *iter << endl;
2043 }
2044
2045 // Lock the architecture of the running systems rpm
2046 // package on distupgrade.
2047 if ( _distupgrade && ZConfig::instance().systemRoot() == "/" )
2048 {
2049 ResPool pool( ResPool::instance() );
2050 IdString rpm( "rpm" );
2051 for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
2052 {
2053 if ( (*it)->isSystem() )
2054 {
2055 Capability archrule( (*it)->arch(), rpm.c_str(), Capability::PARSED );
2056 queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
2057 queue_push( &(_jobQueue), archrule.id() );
2058
2059 }
2060 }
2061 }
2062 }
2063
2064 sat::StringQueue SATResolver::autoInstalled() const
2065 {
2066 sat::StringQueue ret;
2067 if ( _satSolver )
2068 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
2069 return ret;
2070 }
2071
2072 sat::StringQueue SATResolver::userInstalled() const
2073 {
2074 sat::StringQueue ret;
2075 if ( _satSolver )
2076 ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES );
2077 return ret;
2078 }
2079
2080
2082 };// namespace detail
2085 };// namespace solver
2088 };// namespace zypp
2090
2091 #if 0
2092 // Legacy translations we want to keep for now:
2093
2094 // - Rule infos:
2095 case SOLVER_RULE_DISTUPGRADE:
2096 ret = str::form (_("%s does not belong to a distupgrade repository"), s.asString().c_str());
2097 case SOLVER_RULE_INFARCH:
2098 ret = str::form (_("%s has inferior architecture"), s.asString().c_str());
2099 case SOLVER_RULE_UPDATE:
2100 ret = str::form (_("problem with installed package %s"), s.asString().c_str());
2101 case SOLVER_RULE_JOB:
2102 ret = _("conflicting requests");
2103 case SOLVER_RULE_PKG:
2104 ret = _("some dependency problem");
2105 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
2106 ret = str::form (_("nothing provides requested %s"), pool_dep2str(pool, dep));
2107 detail += _("Have you enabled all requested repositories?");
2108 case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
2109 ret = str::form (_("package %s does not exist"), pool_dep2str(pool, dep));
2110 detail += _("Have you enabled all requested repositories?");
2111 case SOLVER_RULE_JOB_UNSUPPORTED:
2112 ret = _("unsupported request");
2113 case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
2114 ret = str::form (_("%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
2115 case SOLVER_RULE_PKG_NOT_INSTALLABLE:
2116 ret = str::form (_("%s is not installable"), s.asString().c_str());
2117 case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
2118 ignoreId = source; // for setting weak dependencies
2119 ret = str::form (_("nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
2120 case SOLVER_RULE_PKG_SAME_NAME:
2121 ret = str::form (_("cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
2122 case SOLVER_RULE_PKG_CONFLICTS:
2123 ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
2124 case SOLVER_RULE_PKG_OBSOLETES:
2125 ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
2126 case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
2127 ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
2128 case SOLVER_RULE_PKG_SELF_CONFLICT:
2129 ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
2130 case SOLVER_RULE_PKG_REQUIRES: {
2131 ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
2132 if (providerlistInstalled.size() > 0) {
2133 detail += _("deleted providers: ");
2134 detail += _("\nnot installable providers: ");
2135 detail = _("not installable providers: ");
2136
2137 // - Solution infos:
2138 if (p == SOLVER_SOLUTION_JOB) {
2139 case SOLVER_INSTALL | SOLVER_SOLVABLE: {
2140 std::string description = str::form (_("remove lock to allow removal of %s"), s.asString().c_str() );
2141 std::string description = str::form (_("do not install %s"), s.asString().c_str());
2142 case SOLVER_ERASE | SOLVER_SOLVABLE: {
2143 std::string description = str::form (_("keep %s"), s.asString().c_str());
2144 std::string description = str::form (_("remove lock to allow installation of %s"), itemToString( poolItem ).c_str());
2145 case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
2146 std::string description = str::form (_("do not install %s"), ident.c_str() );
2147 case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
2148 std::string description = str::form (_("keep %s"), ident.c_str());
2149 case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
2150 resolverProblem->setDescription(_("This request will break your system!"));
2151 description = _("ignore the warning of a broken system");
2152 description = str::form (_("do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
2153 case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
2154 resolverProblem->setDescription(_("This request will break your system!"));
2155 description = _("ignore the warning of a broken system");
2156 description = str::form (_("do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
2157 case SOLVER_UPDATE | SOLVER_SOLVABLE:
2158 std::string description = str::form (_("do not install most recent version of %s"), s.asString().c_str());
2159
2160 } else if (p == SOLVER_SOLUTION_INFARCH) {
2161 std::string description = str::form (_("keep %s despite the inferior architecture"), s.asString().c_str());
2162 std::string description = str::form (_("install %s despite the inferior architecture"), s.asString().c_str());
2163
2164 } else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
2165 std::string description = str::form (_("keep obsolete %s"), s.asString().c_str());
2166 std::string description = str::form (_("install %s from excluded repository"), s.asString().c_str());
2167
2168 } else if ( p == SOLVER_SOLUTION_BLACK ) {
2169 description = str::Format(_("install %1% although it has been retracted")) % s.asString();
2170 description = str::Format(_("allow to install the PTF %1%")) % s.asString();
2171 description = str::Format(_("install %1% although it is blacklisted")) % s.asString();
2172
2173 } else if ( p > 0 ) {
2174 std::string description = str::form (_("downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
2175 std::string description = str::form (_("architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
2176 std::string description = str::form (_("install %s (with vendor change)\n %s --> %s") ,
2177 std::string description = str::form (_("replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
2178
2179 std::string description = str::form (_("deinstallation of %s"), s.asString().c_str());
2180 #endif
Algorithm.h
AutoDispose.h
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
Gettext.h
Interface to gettext.
_
#define _(MSG)
Definition: Gettext.h:37
LogTools.h
DBG
#define DBG
Definition: Logger.h:90
MIL
#define MIL
Definition: Logger.h:91
ERR
#define ERR
Definition: Logger.h:93
WAR
#define WAR
Definition: Logger.h:92
INT
#define INT
Definition: Logger.h:95
ProblemSolutionCombi.h
ProblemSolutionIgnore.h
Product.h
MAYBE_CLEANDEPS
#define MAYBE_CLEANDEPS
Definition: SATResolver.cc:171
OUTS
#define OUTS(X)
XDEBUG
#define XDEBUG(x)
Definition: SATResolver.cc:58
SATResolver.h
SolutionAction.h
SolverQueueItemDelete.h
SolverQueueItemInstall.h
SolverQueueItem.h
SystemCheck.h
WhatObsoletes.h
WhatProvides.h
ZConfig.h
zypp::AutoDispose
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:93
zypp::Capability::PARSED
@ PARSED
Definition: Capability.h:62
zypp::IdString
Access to the sat-pools string space.
Definition: IdString.h:43
zypp::Package
Package interface.
Definition: Package.h:33
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:51
zypp::PoolItem::status
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:204
zypp::PoolItem::buddy
sat::Solvable buddy() const
Return the buddy we share our status object with.
Definition: PoolItem.cc:206
zypp::Repository::alias
std::string alias() const
Short unique string to identify a repo.
Definition: Repository.cc:59
zypp::ResPool::find
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
Definition: ResPool.cc:73
zypp::ResPool::instance
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:37
zypp::ResStatus
Status bitfield.
Definition: ResStatus.h:54
zypp::ResStatus::toBeInstalled
static const ResStatus toBeInstalled
Definition: ResStatus.h:662
zypp::ResStatus::setToBeUninstalled
bool setToBeUninstalled(TransactByValue causer)
Definition: ResStatus.h:545
zypp::ResStatus::isByApplLow
bool isByApplLow() const
Definition: ResStatus.h:293
zypp::ResStatus::isToBeInstalled
bool isToBeInstalled() const
Definition: ResStatus.h:253
zypp::ResStatus::setToBeInstalled
bool setToBeInstalled(TransactByValue causer)
Definition: ResStatus.h:531
zypp::ResStatus::resetWeak
void resetWeak()
Definition: ResStatus.h:197
zypp::ResStatus::getTransactValue
TransactValue getTransactValue() const
Definition: ResStatus.h:279
zypp::ResStatus::toBeUninstalledDueToUpgrade
static const ResStatus toBeUninstalledDueToUpgrade
Definition: ResStatus.h:664
zypp::ResStatus::TransactByValue
TransactByValue
Definition: ResStatus.h:107
zypp::ResStatus::APPL_LOW
@ APPL_LOW
Definition: ResStatus.h:109
zypp::ResStatus::SOLVER
@ SOLVER
Definition: ResStatus.h:108
zypp::ResStatus::toBeUninstalled
static const ResStatus toBeUninstalled
Definition: ResStatus.h:663
zypp::ResStatus::isToBeUninstalled
bool isToBeUninstalled() const
Definition: ResStatus.h:261
zypp::ResStatus::isToBeUninstalledDueToUpgrade
bool isToBeUninstalledDueToUpgrade() const
Definition: ResStatus.h:318
zypp::ResStatus::resetTransact
bool resetTransact(TransactByValue causer_r)
Not the same as setTransact( false ).
Definition: ResStatus.h:485
zypp::ResStatus::isBySolver
bool isBySolver() const
Definition: ResStatus.h:290
zypp::ResStatus::setToBeUninstalledDueToUpgrade
bool setToBeUninstalledDueToUpgrade(TransactByValue causer)
Definition: ResStatus.h:569
zypp::ResStatus::LOCKED
@ LOCKED
Definition: ResStatus.h:103
zypp::ResStatus::TRANSACT
@ TRANSACT
Definition: ResStatus.h:104
zypp::ResStatus::KEEP_STATE
@ KEEP_STATE
Definition: ResStatus.h:102
zypp::ResStatus::isUninstalled
bool isUninstalled() const
Definition: ResStatus.h:243
zypp::SrcPackage
SrcPackage interface.
Definition: SrcPackage.h:30
zypp::VendorAttr::equivalent
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings should be treated as the same vendor.
Definition: VendorAttr.cc:331
zypp::VendorAttr::relaxedEquivalent
bool relaxedEquivalent(const Vendor &lVendor, const Vendor &rVendor) const
Like equivalent but always unifies suse and openSUSE vendor.
Definition: VendorAttr.cc:344
zypp::VendorAttr::instance
static const VendorAttr & instance()
(Pseudo)Singleton, mapped to the current Target::vendorAttr settings or to noTargetInstance.
Definition: VendorAttr.cc:230
zypp::ZConfig::instance
static ZConfig & instance()
Singleton ctor.
Definition: Resolver.cc:126
zypp::sat::Pool::instance
static Pool instance()
Singleton ctor.
Definition: Pool.h:55
zypp::sat::Pool::prepare
void prepare() const
Update housekeeping data if necessary (e.g.
Definition: Pool.cc:61
zypp::sat::Pool::get
detail::CPool * get() const
Expert backdoor.
Definition: Pool.cc:49
zypp::sat::Queue
Libsolv Id queue wrapper.
Definition: Queue.h:35
zypp::sat::Queue::size
size_type size() const
Definition: Queue.cc:49
zypp::sat::Queue::size_type
unsigned size_type
Definition: Queue.h:37
zypp::sat::Queue::empty
bool empty() const
Definition: Queue.cc:46
zypp::sat::Queue::push
void push(value_type val_r)
Push a value to the end off the Queue.
Definition: Queue.cc:103
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition: Solvable.h:54
zypp::sat::Solvable::asString
std::string asString() const
String representation "ident-edition.arch" or "noSolvable".
Definition: Solvable.cc:433
zypp::sat::Solvable::isSystem
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition: Solvable.cc:372
zypp::sat::Solvable::ptfToken
static const IdString ptfToken
Indicator provides ptf()
Definition: Solvable.h:59
zypp::sat::Solvable::retractedToken
static const IdString retractedToken
Indicator provides retracted-patch-package()
Definition: Solvable.h:58
zypp::sat::Solvable::isKind
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:301
zypp::sat::Solvable::repository
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:362
zypp::solver::detail::CheckIfUpdate
Definition: SATResolver.cc:440
zypp::solver::detail::CheckIfUpdate::_installed
sat::Solvable _installed
Definition: SATResolver.cc:443
zypp::solver::detail::CheckIfUpdate::operator()
bool operator()(const PoolItem &item)
Definition: SATResolver.cc:452
zypp::solver::detail::CheckIfUpdate::is_updated
bool is_updated
Definition: SATResolver.cc:442
zypp::solver::detail::CheckIfUpdate::CheckIfUpdate
CheckIfUpdate(const sat::Solvable &installed_r)
Definition: SATResolver.cc:445
zypp::ui::Selectable::get
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
Definition: Selectable.cc:28
std::dumpOn
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
Definition: PtrTypes.h:151
zypp::functor::chain
Chain< TACondition, TBCondition > chain(TACondition conda_r, TBCondition condb_r)
Convenience function for creating a Chain from two conditions conda_r and condb_r.
Definition: Functional.h:346
zypp::resfilter::PoolItemFilterFunctor
std::unary_function< PoolItem, bool > PoolItemFilterFunctor
Definition: ResFilters.h:285
zypp::resfilter::ResObjectFilterFunctor
std::unary_function< ResObject::constPtr, bool > ResObjectFilterFunctor
Definition: ResFilters.h:151
zypp::sat::detail::CSolver
::s_Solver CSolver
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:65
zypp::sat::detail::IdType
int IdType
Generic Id type.
Definition: PoolMember.h:104
zypp::sat::detail::CPool
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:61
zypp::sat::detail::SolvableIdType
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolMember.h:125
zypp::sat::compareByNVR
bool compareByNVR(const SolvableType< Derived > &lhs, const Solvable &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: SolvableType.h:256
zypp::sat::SolvableQueue
Queue SolvableQueue
Queue with Solvable ids.
Definition: Queue.h:25
zypp::sat::StringQueue
Queue StringQueue
Queue with String ids.
Definition: Queue.h:27
zypp::sat::sameNVRA
bool sameNVRA(const SolvableType< Derived > &lhs, const Solvable &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: SolvableType.h:228
zypp::solver::detail::SATSolutionToPool
static void SATSolutionToPool(PoolItem item, const ResStatus &status, const ResStatus::TransactByValue causer)
Definition: SATResolver.cc:335
zypp::solver::detail::_dup_allowdowngrade
_dup_allowdowngrade
Definition: Resolver.cc:123
zypp::solver::detail::_allowvendorchange
_allowvendorchange
Definition: Resolver.cc:121
zypp::solver::detail::vendorCheck
int vendorCheck(sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2)
Definition: SATResolver.cc:177
zypp::solver::detail::mapBuddy
sat::Solvable mapBuddy(sat::Solvable item_r)
Definition: SATResolver.cc:1019
zypp::solver::detail::establish
void establish(sat::Queue &pseudoItems_r, sat::Queue &pseudoFlags_r)
ResPool helper to compute the initial status of Patches etc.
Definition: SATResolver.cc:187
zypp::solver::detail::_dup_allownamechange
_dup_allownamechange
Definition: Resolver.cc:124
zypp::solver::detail::relaxedVendorCheck
int relaxedVendorCheck(sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2)
Definition: SATResolver.cc:180
zypp::solver::detail::IMPL_PTR_TYPE
IMPL_PTR_TYPE(SATResolver)
zypp::solver::detail::_dup_allowarchchange
_dup_allowarchchange
Definition: Resolver.cc:125
zypp::solver::detail::SolverQueueItemList
std::list< SolverQueueItem_Ptr > SolverQueueItemList
Definition: Types.h:45
zypp::solver::detail::itemToString
std::string itemToString(const PoolItem &item)
Definition: SATResolver.cc:228
zypp::solver::detail::_dup_allowvendorchange
_dup_allowvendorchange
Definition: Resolver.cc:126
zypp::str::asString
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
Definition: String.h:136
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
zypp::traits::isPseudoInstalled
bool isPseudoInstalled(ResKind kind_r)
Those are denoted to be installed, if the solver verifies them as being satisfied.
Definition: ResTraits.h:28
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::CapabilitySet
std::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
zypp::ResolverNamespace::language
@ language
language support
zypp::ResolverFocus
ResolverFocus
The resolvers general attitude.
Definition: ResolverFocus.h:22
zypp::ResolverFocus::Update
@ Update
Focus on updating requested packages and their dependencies as much as possible.
zypp::ResolverFocus::Default
@ Default
Request the standard behavior (as defined in zypp.conf or 'Job')
zypp::ResolverFocus::Installed
@ Installed
Focus on applying as little changes to the installed packages as needed.
zypp::ResolverFocus::Job
@ Job
Focus on installing the best version of the requested packages.
zypp::ResolverProblemList
std::list< ResolverProblem_Ptr > ResolverProblemList
Definition: ProblemTypes.h:46
zypp::ProblemSolutionList
std::list< ProblemSolution_Ptr > ProblemSolutionList
Definition: ProblemTypes.h:43
zypp::invokeOnEach
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.
Definition: Algorithm.h:30
PoolImpl.h
Resolver.h
zypp::sat::SolvableType::isKind
bool isKind(const ResKind &kind_r) const
Definition: SolvableType.h:64
zypp::sat::SolvableType::satSolvable
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
zypp::sat::SolvableType::asString
std::string asString() const
Definition: SolvableType.h:90
zypp::sat::SolvableType::multiversionInstall
bool multiversionInstall() const
Definition: SolvableType.h:82
zypp::solver::detail::FindPackage
Definition: SATResolver.cc:984
zypp::solver::detail::FindPackage::operator()
bool operator()(PoolItem p)
Definition: SATResolver.cc:993
zypp::solver::detail::FindPackage::FindPackage
FindPackage(ProblemSolutionCombi *p, const TransactionKind act)
Definition: SATResolver.cc:987
zypp::solver::detail::FindPackage::action
TransactionKind action
Definition: SATResolver.cc:986
zypp::solver::detail::FindPackage::problemSolution
ProblemSolutionCombi * problemSolution
Definition: SATResolver.cc:985
zypp::solver::detail::SATCollectTransact
Commit helper functor distributing PoolItem by status into lists.
Definition: SATResolver.cc:373
zypp::solver::detail::SATCollectTransact::_items_to_lock
PoolItemList & _items_to_lock
Definition: SATResolver.cc:424
zypp::solver::detail::SATCollectTransact::SATCollectTransact
SATCollectTransact(PoolItemList &items_to_install_r, PoolItemList &items_to_remove_r, PoolItemList &items_to_lock_r, PoolItemList &items_to_keep_r, bool solveSrcPackages_r)
Definition: SATResolver.cc:374
zypp::solver::detail::SATCollectTransact::_items_to_install
PoolItemList & _items_to_install
Definition: SATResolver.cc:422
zypp::solver::detail::SATCollectTransact::_items_to_remove
PoolItemList & _items_to_remove
Definition: SATResolver.cc:423
zypp::solver::detail::SATCollectTransact::_items_to_keep
PoolItemList & _items_to_keep
Definition: SATResolver.cc:425
zypp::solver::detail::SATCollectTransact::_solveSrcPackages
bool _solveSrcPackages
Definition: SATResolver.cc:426
zypp::solver::detail::SATCollectTransact::operator()
bool operator()(const PoolItem &item_r)
Definition: SATResolver.cc:391