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