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