libzypp 17.37.17
Resolver.cc
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* Resolver.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 to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21#include <boost/static_assert.hpp>
22#include <utility>
23
24#define ZYPP_USE_RESOLVER_INTERNALS
25
26#include <zypp/base/LogTools.h>
27#include <zypp/base/Algorithm.h>
28
35
36#include <zypp/ZConfig.h>
38
39#define MAXSOLVERRUNS 5
40
41using std::endl;
42using std::make_pair;
43
44#undef ZYPP_BASE_LOGGER_LOGGROUP
45#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::solver"
46
48namespace zypp
49{
51 namespace solver
52 {
54 namespace detail
55 {
56
57
58//---------------------------------------------------------------------------
59
60
61std::ostream & Resolver::dumpOn( std::ostream & os ) const
62{
63 os << "<resolver>" << endl;
64 #define OUTS(t) os << " " << #t << ":\t" << t << endl;
65 OUTS( _upgradeMode );
66 OUTS( _updateMode );
67 OUTS( _verifying );
68 OUTS( _solveSrcPackages );
69 OUTS( _ignoreAlreadyRecommended );
70 #undef OUT
71 return os << "<resolver/>";
72}
73
74
75//---------------------------------------------------------------------------
76
77Resolver::Resolver (ResPool pool)
78 : _pool(std::move(pool))
79 , _satResolver(NULL)
80 , _poolchanged(_pool.serial() )
81 , _upgradeMode ( false )
82 , _updateMode ( false )
83 , _verifying ( false )
84 , _solveSrcPackages ( false )
85 , _ignoreAlreadyRecommended ( true )
86 , _applyDefault_focus ( true )
87 , _applyDefault_forceResolve ( true )
88 , _applyDefault_cleandepsOnRemove ( true )
89 , _applyDefault_onlyRequires ( true )
90 , _applyDefault_allowDowngrade ( true )
91 , _applyDefault_allowNameChange ( true )
92 , _applyDefault_allowArchChange ( true )
93 , _applyDefault_allowVendorChange ( true )
94 , _applyDefault_dupAllowDowngrade ( true )
95 , _applyDefault_dupAllowNameChange ( true )
96 , _applyDefault_dupAllowArchChange ( true )
97 , _applyDefault_dupAllowVendorChange ( true )
98{
99 sat::Pool satPool( sat::Pool::instance() );
100 _satResolver = new SATResolver(_pool, satPool.get());
101}
102
103
105{
106 delete _satResolver;
107}
108
110{ return _satResolver->get(); }
111
112
113void Resolver::setDefaultSolverFlags( bool all_r )
114{
115 MIL << "setDefaultSolverFlags all=" << all_r << endl;
116
117 if ( all_r || _applyDefault_focus ) setFocus( ResolverFocus::Default );
118
119#define ZOLV_FLAG_DEFAULT( ZSETTER, ZGETTER ) \
120 if ( all_r || _applyDefault_##ZGETTER ) ZSETTER( indeterminate )
121
122 ZOLV_FLAG_DEFAULT( setForceResolve ,forceResolve );
123 ZOLV_FLAG_DEFAULT( setCleandepsOnRemove ,cleandepsOnRemove );
124 ZOLV_FLAG_DEFAULT( setOnlyRequires ,onlyRequires );
125 ZOLV_FLAG_DEFAULT( setAllowDowngrade ,allowDowngrade );
126 ZOLV_FLAG_DEFAULT( setAllowNameChange ,allowNameChange );
127 ZOLV_FLAG_DEFAULT( setAllowArchChange ,allowArchChange );
128 ZOLV_FLAG_DEFAULT( setAllowVendorChange ,allowVendorChange );
129 ZOLV_FLAG_DEFAULT( dupSetAllowDowngrade ,dupAllowDowngrade );
130 ZOLV_FLAG_DEFAULT( dupSetAllowNameChange ,dupAllowNameChange );
131 ZOLV_FLAG_DEFAULT( dupSetAllowArchChange ,dupAllowArchChange );
132 ZOLV_FLAG_DEFAULT( dupSetAllowVendorChange ,dupAllowVendorChange );
133#undef ZOLV_FLAG_TRIBOOL
134}
135//---------------------------------------------------------------------------
136// forward flags too SATResolver
137void Resolver::setFocus( ResolverFocus focus_r ) {
138 _applyDefault_focus = ( focus_r == ResolverFocus::Default );
139 _satResolver->_focus = _applyDefault_focus ? ZConfig::instance().solver_focus() : focus_r;
140}
141ResolverFocus Resolver::focus() const { return _satResolver->_focus; }
142
143void Resolver::setRemoveOrphaned( bool yesno_r ) { _satResolver->_removeOrphaned = yesno_r; }
144bool Resolver::removeOrphaned() const { return _satResolver->_removeOrphaned; }
145
146void Resolver::setRemoveUnneeded( bool yesno_r ) { _satResolver->_removeUnneeded = yesno_r; }
147bool Resolver::removeUnneeded() const { return _satResolver->_removeUnneeded; }
148
149#define ZOLV_FLAG_TRIBOOL( ZSETTER, ZGETTER, ZVARDEFAULT, ZVARNAME ) \
150 void Resolver::ZSETTER( TriBool state_r ) \
151 { _applyDefault_##ZGETTER = indeterminate(state_r); \
152 bool newval = _applyDefault_##ZGETTER ? ZVARDEFAULT : bool(state_r); \
153 if ( ZVARNAME != newval ) { \
154 DBG << #ZGETTER << ": changed from " << (bool)ZVARNAME << " to " << newval << endl;\
155 ZVARNAME = newval; \
156 } \
157 } \
158 bool Resolver::ZGETTER() const \
159 { return ZVARNAME; } \
160
161// Flags stored here follow the naming convention,...
162// Flags down in _satResolver don't. Could match `_satResolver->_##ZGETTER`
163#define ZOLV_FLAG_SATSOLV( ZSETTER, ZGETTER, ZVARDEFAULT, ZVARNAME ) \
164 ZOLV_FLAG_TRIBOOL( ZSETTER, ZGETTER, ZVARDEFAULT, _satResolver->ZVARNAME )
165
166// NOTE: ZVARDEFAULT must be in sync with SATResolver ctor
167ZOLV_FLAG_SATSOLV( setForceResolve ,forceResolve ,false ,_allowuninstall )
168ZOLV_FLAG_SATSOLV( setCleandepsOnRemove ,cleandepsOnRemove ,ZConfig::instance().solver_cleandepsOnRemove() ,_cleandepsOnRemove )
169ZOLV_FLAG_SATSOLV( setOnlyRequires ,onlyRequires ,ZConfig::instance().solver_onlyRequires() ,_onlyRequires )
170ZOLV_FLAG_SATSOLV( setAllowDowngrade ,allowDowngrade ,false ,_allowdowngrade )
171ZOLV_FLAG_SATSOLV( setAllowNameChange ,allowNameChange ,true /*bsc#1071466*/ ,_allownamechange )
172ZOLV_FLAG_SATSOLV( setAllowArchChange ,allowArchChange ,false ,_allowarchchange )
173ZOLV_FLAG_SATSOLV( setAllowVendorChange ,allowVendorChange ,ZConfig::instance().solver_allowVendorChange() ,_allowvendorchange )
174ZOLV_FLAG_SATSOLV( dupSetAllowDowngrade ,dupAllowDowngrade ,ZConfig::instance().solver_dupAllowDowngrade() ,_dup_allowdowngrade )
175ZOLV_FLAG_SATSOLV( dupSetAllowNameChange ,dupAllowNameChange ,ZConfig::instance().solver_dupAllowNameChange() ,_dup_allownamechange )
176ZOLV_FLAG_SATSOLV( dupSetAllowArchChange ,dupAllowArchChange ,ZConfig::instance().solver_dupAllowArchChange() ,_dup_allowarchchange )
177ZOLV_FLAG_SATSOLV( dupSetAllowVendorChange ,dupAllowVendorChange ,ZConfig::instance().solver_dupAllowVendorChange() ,_dup_allowvendorchange )
178#undef ZOLV_FLAG_SATSOLV
179#undef ZOLV_FLAG_TRIBOOL
180//---------------------------------------------------------------------------
181
182ResPool Resolver::pool() const
183{ return _pool; }
184
185void Resolver::reset( bool keepExtras )
186{
187 _verifying = false;
188
189 if (!keepExtras) {
190 _extra_requires.clear();
191 _extra_conflicts.clear();
192 }
193
194 _isInstalledBy.clear();
195 _installs.clear();
196 _satifiedByInstalled.clear();
197 _installedSatisfied.clear();
198}
199
200PoolItemList Resolver::problematicUpdateItems() const
201{ return _satResolver->problematicUpdateItems(); }
202
203void Resolver::addExtraRequire( const Capability & capability )
204{ _extra_requires.insert (capability); }
205
206void Resolver::removeExtraRequire( const Capability & capability )
207{ _extra_requires.erase (capability); }
208
209void Resolver::addExtraConflict( const Capability & capability )
210{ _extra_conflicts.insert (capability); }
211
212void Resolver::removeExtraConflict( const Capability & capability )
213{ _extra_conflicts.erase (capability); }
214
215void Resolver::removeQueueItem( const SolverQueueItem_Ptr& item )
216{
217 bool found = false;
218 for (SolverQueueItemList::const_iterator iter = _added_queue_items.begin();
219 iter != _added_queue_items.end(); iter++) {
220 if (*iter == item) {
221 _added_queue_items.remove(*iter);
222 found = true;
223 break;
224 }
225 }
226 if (!found) {
227 _removed_queue_items.push_back (item);
228 _removed_queue_items.unique ();
229 }
230}
231
232void Resolver::addQueueItem( const SolverQueueItem_Ptr& item )
233{
234 bool found = false;
235 for (SolverQueueItemList::const_iterator iter = _removed_queue_items.begin();
236 iter != _removed_queue_items.end(); iter++) {
237 if (*iter == item) {
238 _removed_queue_items.remove(*iter);
239 found = true;
240 break;
241 }
242 }
243 if (!found) {
244 _added_queue_items.push_back (item);
245 _added_queue_items.unique ();
246 }
247}
248
249void Resolver::addWeak( const PoolItem & item )
250{ _addWeak.push_back( item ); }
251
252//---------------------------------------------------------------------------
253
255{
258 :resStatus(status)
259 { }
260
261 bool operator()( const PoolItem& item ) // only transacts() items go here
262 {
263 item.status().resetTransact( resStatus );// clear any solver/establish transactions
264 return true;
265 }
266};
267
268
270{
273 :resStatus(status)
274 { }
275
276 bool operator()( const PoolItem& item ) // only transacts() items go here
277 {
278 item.status().setTransact( true, resStatus );
279 return true;
280 }
281};
282
283//----------------------------------------------------------------------------
291{
293 {
294 const char *val = ::getenv("ZYPP_FULLLOG");
295 if ( val && str::strToTrue( val ) )
296 _resolver = &resolver_r;
297 }
298
300 {
301 if ( _resolver ) try {
302 Testcase testcase( "/var/log/YaST2/autoTestcase" );
303 testcase.createTestcase( *_resolver, dumpPool, false );
304 if ( dumpPool )
305 dumpPool = false;
306 } catch( ... ) {};
307 }
308
309private:
310 Resolver * _resolver = nullptr;
311 static bool dumpPool; // dump pool on the 1st invocation, later update control file only
312};
313
315
316//----------------------------------------------------------------------------
317// undo
318void Resolver::undo()
319{
321 MIL << "*** undo ***" << endl;
322 invokeOnEach ( _pool.begin(), _pool.end(),
323 resfilter::ByTransact( ), // collect transacts from Pool to resolver queue
324 std::ref(info) );
325 // Regard dependencies of the item weak onl
326 _addWeak.clear();
327
328 // Additional QueueItems which has to be regarded by the solver
329 _removed_queue_items.clear();
330 _added_queue_items.clear();
331
332 return;
333}
334
335void Resolver::solverInit()
336{
337 // Solving with libsolv
338 MIL << "-------------- Calling SAT Solver -------------------" << endl;
339
340 // update solver mode flags
341 _satResolver->setDistupgrade (_upgradeMode);
342 _satResolver->setUpdatesystem (_updateMode);
343 _satResolver->setFixsystem ( isVerifyingMode() );
344 _satResolver->setSolveSrcPackages ( solveSrcPackages() );
345 _satResolver->setIgnorealreadyrecommended ( ignoreAlreadyRecommended() );
346
347 if (_upgradeMode) {
348 // Maybe depend on ZConfig::solverUpgradeRemoveDroppedPackages.
349 // For sure right but a change in behavior for old distros.
350 // (Will disable weakremover processing in SATResolver)
351 // _satResolver->setRemoveOrphaned( ... );
352 }
353
354 // Resetting additional solver information
355 _isInstalledBy.clear();
356 _installs.clear();
357 _satifiedByInstalled.clear();
358 _installedSatisfied.clear();
359}
360
362{
363 DBG << "Resolver::verifySystem()" << endl;
364 _verifying = true;
365 UndoTransact resetting (ResStatus::APPL_HIGH);
366 invokeOnEach ( _pool.begin(), _pool.end(),
367 resfilter::ByTransact( ), // Resetting all transcations
368 std::ref(resetting) );
369 return resolvePool();
370}
371
372
374{
375 // Setting Resolver to upgrade mode. SAT solver will do the update
376 _upgradeMode = true;
377 return resolvePool();
378}
379
381{
382 ScopedAutoTestCaseWriter _raiiGuard( *this ); // Write a testcase if needed.
383 solverInit();
384 return _satResolver->resolvePool(_extra_requires, _extra_conflicts, _addWeak, _upgradeRepos );
385}
386
388{
389 ScopedAutoTestCaseWriter _raiiGuard( *this ); // Write a testcase if needed.
390 _updateMode = true;
391 solverInit();
392 return _satResolver->doUpdate();
393}
394
396{
397 ScopedAutoTestCaseWriter _raiiGuard( *this ); // Write a testcase if needed.
398 solverInit();
399
400 // add/remove additional SolverQueueItems
401 for (SolverQueueItemList::const_iterator iter = _removed_queue_items.begin();
402 iter != _removed_queue_items.end(); iter++) {
403 for (SolverQueueItemList::const_iterator iterQueue = queue.begin(); iterQueue != queue.end(); iterQueue++) {
404 if ( (*iterQueue)->cmp(*iter) == 0) {
405 MIL << "remove from queue" << *iter;
406 queue.remove(*iterQueue);
407 break;
408 }
409 }
410 }
411
412 for (SolverQueueItemList::const_iterator iter = _added_queue_items.begin();
413 iter != _added_queue_items.end(); iter++) {
414 bool found = false;
415 for (SolverQueueItemList::const_iterator iterQueue = queue.begin(); iterQueue != queue.end(); iterQueue++) {
416 if ( (*iterQueue)->cmp(*iter) == 0) {
417 found = true;
418 break;
419 }
420 }
421 if (!found) {
422 MIL << "add to queue" << *iter;
423 queue.push_back(*iter);
424 }
425 }
426
427 // The application has to take care to write these solutions back to e.g. selectables in order
428 // give the user a chance for changing these decisions again.
429 _removed_queue_items.clear();
430 _added_queue_items.clear();
431
432 return _satResolver->resolveQueue(queue, _addWeak);
433}
434
435sat::Transaction Resolver::getTransaction()
436{
437 // FIXME: That's an ugly way of pushing autoInstalled into the transaction.
438 sat::Transaction ret( sat::Transaction::loadFromPool );
439 ret.autoInstalled( _satResolver->autoInstalled() );
440 return ret;
441}
442
443
444//----------------------------------------------------------------------------
445// Getting more information about the solve results
446
448{
449 MIL << "Resolver::problems()" << endl;
450 return _satResolver->problems();
451}
452
453void Resolver::applySolutions( const ProblemSolutionList & solutions )
454{
455 for ( const ProblemSolution_Ptr& solution : solutions )
456 {
457 if ( ! applySolution( *solution ) )
458 break;
459 }
460}
461
462bool Resolver::applySolution( const ProblemSolution & solution )
463{
464 bool ret = true;
465 DBG << "apply solution " << solution << endl;
466 for ( const SolutionAction_Ptr& action : solution.actions() )
467 {
468 if ( ! action->execute( *this ) )
469 {
470 WAR << "apply solution action failed: " << action << endl;
471 ret = false;
472 break;
473 }
474 }
475 return ret;
476}
477
478//----------------------------------------------------------------------------
479
480void Resolver::collectResolverInfo()
481{
482 if ( _satResolver
483 && _isInstalledBy.empty()
484 && _installs.empty()) {
485
486 // generating new
487 PoolItemList itemsToInstall = _satResolver->resultItemsToInstall();
488
489 for (PoolItemList::const_iterator instIter = itemsToInstall.begin();
490 instIter != itemsToInstall.end(); instIter++) {
491 // Requires
492 for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::REQUIRES).begin(); capIt != (*instIter)->dep (Dep::REQUIRES).end(); ++capIt)
493 {
494 sat::WhatProvides possibleProviders(*capIt);
495 for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
496 PoolItem provider = ResPool::instance().find( *iter );
497
498 // searching if this provider will already be installed
499 bool found = false;
500 bool alreadySetForInstallation = false;
501 ItemCapKindMap::const_iterator pos = _isInstalledBy.find(provider);
502 while (pos != _isInstalledBy.end()
503 && pos->first == provider
504 && !found) {
505 alreadySetForInstallation = true;
506 ItemCapKind capKind = pos->second;
507 if (capKind.item() == *instIter) found = true;
508 pos++;
509 }
510
511 if (!found
512 && provider.status().isToBeInstalled()) {
513 if (provider.status().isBySolver()) {
514 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::REQUIRES, !alreadySetForInstallation );
515 _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
516 } else {
517 // no initial installation cause it has been set be e.g. user
518 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::REQUIRES, false );
519 _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
520 }
521 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::REQUIRES, !alreadySetForInstallation );
522 _installs.insert (make_pair( *instIter, capKindisInstalledBy));
523 }
524
525 if (provider.status().staysInstalled()) { // Is already satisfied by an item which is installed
526 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::REQUIRES, false );
527 _satifiedByInstalled.insert (make_pair( *instIter, capKindisInstalledBy));
528
529 ItemCapKind installedSatisfied( *instIter, *capIt, Dep::REQUIRES, false );
530 _installedSatisfied.insert (make_pair( provider, installedSatisfied));
531 }
532 }
533 }
534
535 if (!(_satResolver->onlyRequires())) {
536 //Recommends
537 for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::RECOMMENDS).begin(); capIt != (*instIter)->dep (Dep::RECOMMENDS).end(); ++capIt)
538 {
539 sat::WhatProvides possibleProviders(*capIt);
540 for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
541 PoolItem provider = ResPool::instance().find( *iter );
542
543 // searching if this provider will already be installed
544 bool found = false;
545 bool alreadySetForInstallation = false;
546 ItemCapKindMap::const_iterator pos = _isInstalledBy.find(provider);
547 while (pos != _isInstalledBy.end()
548 && pos->first == provider
549 && !found) {
550 alreadySetForInstallation = true;
551 ItemCapKind capKind = pos->second;
552 if (capKind.item() == *instIter) found = true;
553 pos++;
554 }
555
556 if (!found
557 && provider.status().isToBeInstalled()) {
558 if (provider.status().isBySolver()) {
559 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::RECOMMENDS, !alreadySetForInstallation );
560 _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
561 } else {
562 // no initial installation cause it has been set be e.g. user
563 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::RECOMMENDS, false );
564 _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
565 }
566 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::RECOMMENDS, !alreadySetForInstallation );
567 _installs.insert (make_pair( *instIter, capKindisInstalledBy));
568 }
569
570 if (provider.status().staysInstalled()) { // Is already satisfied by an item which is installed
571 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::RECOMMENDS, false );
572 _satifiedByInstalled.insert (make_pair( *instIter, capKindisInstalledBy));
573
574 ItemCapKind installedSatisfied( *instIter, *capIt, Dep::RECOMMENDS, false );
575 _installedSatisfied.insert (make_pair( provider, installedSatisfied));
576 }
577 }
578 }
579
580 //Supplements
581 for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::SUPPLEMENTS).begin(); capIt != (*instIter)->dep (Dep::SUPPLEMENTS).end(); ++capIt)
582 {
583 sat::WhatProvides possibleProviders(*capIt);
584 for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
585 PoolItem provider = ResPool::instance().find( *iter );
586 // searching if this item will already be installed
587 bool found = false;
588 bool alreadySetForInstallation = false;
589 ItemCapKindMap::const_iterator pos = _isInstalledBy.find(*instIter);
590 while (pos != _isInstalledBy.end()
591 && pos->first == *instIter
592 && !found) {
593 alreadySetForInstallation = true;
594 ItemCapKind capKind = pos->second;
595 if (capKind.item() == provider) found = true;
596 pos++;
597 }
598
599 if (!found
600 && instIter->status().isToBeInstalled()) {
601 if (instIter->status().isBySolver()) {
602 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::SUPPLEMENTS, !alreadySetForInstallation );
603 _isInstalledBy.insert (make_pair( *instIter, capKindisInstalledBy));
604 } else {
605 // no initial installation cause it has been set be e.g. user
606 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::SUPPLEMENTS, false );
607 _isInstalledBy.insert (make_pair( *instIter, capKindisInstalledBy));
608 }
609 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::SUPPLEMENTS, !alreadySetForInstallation );
610 _installs.insert (make_pair( provider, capKindisInstalledBy));
611 }
612
613 if (instIter->status().staysInstalled()) { // Is already satisfied by an item which is installed
614 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::SUPPLEMENTS, !alreadySetForInstallation );
615 _satifiedByInstalled.insert (make_pair( provider, capKindisInstalledBy));
616
617 ItemCapKind installedSatisfied( provider, *capIt, Dep::SUPPLEMENTS, false );
618 _installedSatisfied.insert (make_pair( *instIter, installedSatisfied));
619 }
620 }
621 }
622 }
623 }
624 }
625}
626
627
628ItemCapKindList Resolver::isInstalledBy( const PoolItem & item )
629{
630 ItemCapKindList ret;
631 collectResolverInfo();
632
633 for (ItemCapKindMap::const_iterator iter = _isInstalledBy.find(item); iter != _isInstalledBy.end();) {
634 ItemCapKind info = iter->second;
635 PoolItem iterItem = iter->first;
636 if (iterItem == item) {
637 ret.push_back(info);
638 iter++;
639 } else {
640 // exit
641 iter = _isInstalledBy.end();
642 }
643 }
644 return ret;
645}
646
647ItemCapKindList Resolver::installs( const PoolItem & item )
648{
649 ItemCapKindList ret;
650 collectResolverInfo();
651
652 for (ItemCapKindMap::const_iterator iter = _installs.find(item); iter != _installs.end();) {
653 ItemCapKind info = iter->second;
654 PoolItem iterItem = iter->first;
655 if (iterItem == item) {
656 ret.push_back(info);
657 iter++;
658 } else {
659 // exit
660 iter = _installs.end();
661 }
662 }
663 return ret;
664}
665
666ItemCapKindList Resolver::satifiedByInstalled( const PoolItem & item )
667{
668 ItemCapKindList ret;
669 collectResolverInfo();
670
671 for (ItemCapKindMap::const_iterator iter = _satifiedByInstalled.find(item); iter != _satifiedByInstalled.end();) {
672 ItemCapKind info = iter->second;
673 PoolItem iterItem = iter->first;
674 if (iterItem == item) {
675 ret.push_back(info);
676 iter++;
677 } else {
678 // exit
679 iter = _satifiedByInstalled.end();
680 }
681 }
682 return ret;
683}
684
685ItemCapKindList Resolver::installedSatisfied( const PoolItem & item )
686{
687 ItemCapKindList ret;
688 collectResolverInfo();
689
690 for (ItemCapKindMap::const_iterator iter = _installedSatisfied.find(item); iter != _installedSatisfied.end();) {
691 ItemCapKind info = iter->second;
692 PoolItem iterItem = iter->first;
693 if (iterItem == item) {
694 ret.push_back(info);
695 iter++;
696 } else {
697 // exit
698 iter = _installedSatisfied.end();
699 }
700 }
701 return ret;
702}
703
704
706 };// namespace detail
709 };// namespace solver
712};// namespace zypp
714
#define OUTS(V)
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
ResStatus & status() const
Returns the current status.
Definition PoolItem.cc:212
Global ResObject pool.
Definition ResPool.h:62
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
Definition ResPool.cc:74
static ResPool instance()
Singleton ctor.
Definition ResPool.cc:38
bool setTransact(bool toTansact_r, TransactByValue causer_r)
Toggle between TRANSACT and KEEP_STATE.
Definition ResStatus.h:438
bool resetTransact(TransactByValue causer_r)
Not the same as setTransact( false ).
Definition ResStatus.h:490
Dependency resolver interface.
Definition Resolver.h:45
bool resolveQueue(solver::detail::SolverQueueItemList &queue)
Resolve package dependencies:
Definition Resolver.cc:65
sat::detail::CSolver * get() const
Expert backdoor.
Definition Resolver.cc:56
void setRemoveOrphaned(bool yesno_r)
Set whether to remove unused orphans in 'upgrade' mode.
Definition Resolver.cc:105
void setDefaultSolverFlags(bool all_r=true)
Reset all solver flags to the systems default (e.g.
Definition Resolver.cc:53
ResolverProblemList problems()
Return the dependency problems found by the last call to resolveDependencies().
Definition Resolver.cc:71
sat::Transaction getTransaction()
Return the Transaction computed by the last solver run.
Definition Resolver.cc:77
void doUpdate()
Update to newest package.
Definition Resolver.cc:83
std::list< PoolItem > problematicUpdateItems() const
Unmaintained packages which does not fit to the updated system (broken dependencies) will be deleted.
Definition Resolver.cc:158
void applySolutions(const ProblemSolutionList &solutions)
Apply problem solutions.
Definition Resolver.cc:74
Resolver(const ResPool &pool)
Ctor.
Definition Resolver.cc:36
solver::detail::ItemCapKindList isInstalledBy(const PoolItem &item)
Gives information about WHO has pused an installation of an given item.
Definition Resolver.cc:167
solver::detail::ItemCapKindList installs(const PoolItem &item)
Gives information about WHICH additional items will be installed due the installation of an item.
Definition Resolver.cc:170
bool resolvePool()
Resolve package dependencies:
Definition Resolver.cc:62
void setFocus(ResolverFocus focus_r)
Define the resolver's general attitude when resolving jobs.
Definition Resolver.cc:86
void setRemoveUnneeded(bool yesno_r)
File weak remove jobs for unneeded installed packages.
Definition Resolver.cc:108
bool removeOrphaned() const
Definition Resolver.cc:106
bool verifySystem()
Resolve package dependencies:
Definition Resolver.cc:59
~Resolver() override
Dtor.
Definition Resolver.cc:45
bool doUpgrade()
Do an distribution upgrade (DUP)
Definition Resolver.cc:80
ResolverFocus focus() const
Definition Resolver.cc:87
bool removeUnneeded() const
Definition Resolver.cc:109
solver::detail::ItemCapKindList installedSatisfied(const PoolItem &item)
Gives information about WHICH items require an already installed item.
Definition Resolver.cc:176
solver::detail::ItemCapKindList satifiedByInstalled(const PoolItem &item)
Gives information about WHICH installed items are requested by the installation of an item.
Definition Resolver.cc:173
Interim helper class to collect global options and settings.
Definition ZConfig.h:69
ResolverFocus solver_focus() const
The resolver's general attitude when resolving jobs.
Definition ZConfig.cc:1254
static ZConfig & instance()
Singleton ctor.
Definition ZConfig.cc:940
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
static Pool instance()
Singleton ctor.
Definition Pool.h:55
static constexpr LoadFromPoolType loadFromPool
Definition Transaction.h:82
::s_Solver CSolver
Wrapped libsolv C data type exposed as backdoor.
Definition PoolMember.h:65
std::list< SolverQueueItem_Ptr > SolverQueueItemList
Definition Types.h:45
_onlyRequires dupAllowDowngrade
Definition Resolver.cc:174
std::list< ItemCapKind > ItemCapKindList
Definition Types.h:42
ZOLV_FLAG_SATSOLV(setCleandepsOnRemove, cleandepsOnRemove, ZConfig::instance().solver_cleandepsOnRemove(), _cleandepsOnRemove) ZOLV_FLAG_SATSOLV(setOnlyRequires
_onlyRequires _dup_allowdowngrade dupAllowArchChange
Definition Resolver.cc:176
bool strToTrue(const C_Str &str)
Parsing boolean from string.
Definition String.cc:66
Easy-to use interface to the ZYPP dependency resolver.
std::list< ProblemSolution_Ptr > ProblemSolutionList
@ Default
Request the standard behavior (as defined in zypp.conf or 'Job')
std::list< ResolverProblem_Ptr > ResolverProblemList
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
#define ZOLV_FLAG_SATSOLV(ZSETTER, ZGETTER, ZVARDEFAULT, ZVARNAME)
Definition Resolver.cc:163
#define ZOLV_FLAG_DEFAULT(ZSETTER, ZGETTER)
Select PoolItem by transact.
Definition ResFilters.h:295
ResStatus::TransactByValue resStatus
Definition Resolver.cc:271
DoTransact(const ResStatus::TransactByValue &status)
Definition Resolver.cc:272
bool operator()(const PoolItem &item)
Definition Resolver.cc:276
Write automatic testcases if ZYPP_FULLLOG=1 is set.
Definition Resolver.cc:291
bool operator()(const PoolItem &item)
Definition Resolver.cc:261
UndoTransact(const ResStatus::TransactByValue &status)
Definition Resolver.cc:257
ResStatus::TransactByValue resStatus
Definition Resolver.cc:256
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
#define DBG
Definition Logger.h:99
#define MIL
Definition Logger.h:100
#define WAR
Definition Logger.h:101