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