libzypp 17.31.6
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
194{
195 // Setting Resolver to upgrade mode. SAT solver will do the update
196 _upgradeMode = true;
197 return resolvePool();
198}
199
201{
202 _updateMode = true;
203 return _satResolver->doUpdate();
204}
205
206PoolItemList Resolver::problematicUpdateItems() const
207{ return _satResolver->problematicUpdateItems(); }
208
209void Resolver::addExtraRequire( const Capability & capability )
210{ _extra_requires.insert (capability); }
211
212void Resolver::removeExtraRequire( const Capability & capability )
213{ _extra_requires.erase (capability); }
214
215void Resolver::addExtraConflict( const Capability & capability )
216{ _extra_conflicts.insert (capability); }
217
218void Resolver::removeExtraConflict( const Capability & capability )
219{ _extra_conflicts.erase (capability); }
220
221void Resolver::removeQueueItem( SolverQueueItem_Ptr item )
222{
223 bool found = false;
224 for (SolverQueueItemList::const_iterator iter = _added_queue_items.begin();
225 iter != _added_queue_items.end(); iter++) {
226 if (*iter == item) {
227 _added_queue_items.remove(*iter);
228 found = true;
229 break;
230 }
231 }
232 if (!found) {
233 _removed_queue_items.push_back (item);
234 _removed_queue_items.unique ();
235 }
236}
237
238void Resolver::addQueueItem( SolverQueueItem_Ptr item )
239{
240 bool found = false;
241 for (SolverQueueItemList::const_iterator iter = _removed_queue_items.begin();
242 iter != _removed_queue_items.end(); iter++) {
243 if (*iter == item) {
244 _removed_queue_items.remove(*iter);
245 found = true;
246 break;
247 }
248 }
249 if (!found) {
250 _added_queue_items.push_back (item);
251 _added_queue_items.unique ();
252 }
253}
254
255void Resolver::addWeak( const PoolItem & item )
256{ _addWeak.push_back( item ); }
257
258//---------------------------------------------------------------------------
259
261{
264 :resStatus(status)
265 { }
266
267 bool operator()( PoolItem item ) // only transacts() items go here
268 {
269 item.status().resetTransact( resStatus );// clear any solver/establish transactions
270 return true;
271 }
272};
273
274
276{
279 :resStatus(status)
280 { }
281
282 bool operator()( PoolItem item ) // only transacts() items go here
283 {
284 item.status().setTransact( true, resStatus );
285 return true;
286 }
287};
288
289
291{
292 UndoTransact resetting (ResStatus::APPL_HIGH);
293
294 DBG << "Resolver::verifySystem()" << endl;
295
296 _verifying = true;
297
298 invokeOnEach ( _pool.begin(), _pool.end(),
299 resfilter::ByTransact( ), // Resetting all transcations
300 std::ref(resetting) );
301
302 return resolvePool();
303}
304
305
306//----------------------------------------------------------------------------
307// undo
308void Resolver::undo()
309{
310 UndoTransact info(ResStatus::APPL_LOW);
311 MIL << "*** undo ***" << endl;
312 invokeOnEach ( _pool.begin(), _pool.end(),
313 resfilter::ByTransact( ), // collect transacts from Pool to resolver queue
314 std::ref(info) );
315 // Regard dependencies of the item weak onl
316 _addWeak.clear();
317
318 // Additional QueueItems which has to be regarded by the solver
319 _removed_queue_items.clear();
320 _added_queue_items.clear();
321
322 return;
323}
324
325void Resolver::solverInit()
326{
327 // Solving with libsolv
328 static bool poolDumped = false;
329 MIL << "-------------- Calling SAT Solver -------------------" << endl;
330 if ( getenv("ZYPP_FULLLOG") and get() ) { // libzypp/issues/317: get() to make sure a satsolver instance is actually present
331 Testcase testcase("/var/log/YaST2/autoTestcase");
332 if (!poolDumped) {
333 testcase.createTestcase (*this, true, false); // dump pool
334 poolDumped = true;
335 } else {
336 testcase.createTestcase (*this, false, false); // write control file only
337 }
338 }
339
340 _satResolver->setFixsystem ( isVerifyingMode() );
341 _satResolver->setIgnorealreadyrecommended ( ignoreAlreadyRecommended() );
342 _satResolver->setUpdatesystem (_updateMode);
343 _satResolver->setSolveSrcPackages ( solveSrcPackages() );
344
345 _satResolver->setDistupgrade (_upgradeMode);
346 if (_upgradeMode) {
347 // may overwrite some settings
348 _satResolver->setDistupgrade_removeunsupported (false);
349 }
350
351 // Resetting additional solver information
352 _isInstalledBy.clear();
353 _installs.clear();
354 _satifiedByInstalled.clear();
355 _installedSatisfied.clear();
356}
357
359{
360 solverInit();
361 return _satResolver->resolvePool(_extra_requires, _extra_conflicts, _addWeak, _upgradeRepos );
362}
363
365{
366 solverInit();
367
368 // add/remove additional SolverQueueItems
369 for (SolverQueueItemList::const_iterator iter = _removed_queue_items.begin();
370 iter != _removed_queue_items.end(); iter++) {
371 for (SolverQueueItemList::const_iterator iterQueue = queue.begin(); iterQueue != queue.end(); iterQueue++) {
372 if ( (*iterQueue)->cmp(*iter) == 0) {
373 MIL << "remove from queue" << *iter;
374 queue.remove(*iterQueue);
375 break;
376 }
377 }
378 }
379
380 for (SolverQueueItemList::const_iterator iter = _added_queue_items.begin();
381 iter != _added_queue_items.end(); iter++) {
382 bool found = false;
383 for (SolverQueueItemList::const_iterator iterQueue = queue.begin(); iterQueue != queue.end(); iterQueue++) {
384 if ( (*iterQueue)->cmp(*iter) == 0) {
385 found = true;
386 break;
387 }
388 }
389 if (!found) {
390 MIL << "add to queue" << *iter;
391 queue.push_back(*iter);
392 }
393 }
394
395 // The application has to take care to write these solutions back to e.g. selectables in order
396 // give the user a chance for changing these decisions again.
397 _removed_queue_items.clear();
398 _added_queue_items.clear();
399
400 return _satResolver->resolveQueue(queue, _addWeak);
401}
402
403sat::Transaction Resolver::getTransaction()
404{
405 // FIXME: That's an ugly way of pushing autoInstalled into the transaction.
406 sat::Transaction ret( sat::Transaction::loadFromPool );
407 ret.autoInstalled( _satResolver->autoInstalled() );
408 return ret;
409}
410
411
412//----------------------------------------------------------------------------
413// Getting more information about the solve results
414
416{
417 MIL << "Resolver::problems()" << endl;
418 return _satResolver->problems();
419}
420
421void Resolver::applySolutions( const ProblemSolutionList & solutions )
422{
423 for ( ProblemSolution_Ptr solution : solutions )
424 {
425 if ( ! applySolution( *solution ) )
426 break;
427 }
428}
429
430bool Resolver::applySolution( const ProblemSolution & solution )
431{
432 bool ret = true;
433 DBG << "apply solution " << solution << endl;
434 for ( SolutionAction_Ptr action : solution.actions() )
435 {
436 if ( ! action->execute( *this ) )
437 {
438 WAR << "apply solution action failed: " << action << endl;
439 ret = false;
440 break;
441 }
442 }
443 return ret;
444}
445
446//----------------------------------------------------------------------------
447
448void Resolver::collectResolverInfo()
449{
450 if ( _satResolver
451 && _isInstalledBy.empty()
452 && _installs.empty()) {
453
454 // generating new
455 PoolItemList itemsToInstall = _satResolver->resultItemsToInstall();
456
457 for (PoolItemList::const_iterator instIter = itemsToInstall.begin();
458 instIter != itemsToInstall.end(); instIter++) {
459 // Requires
460 for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::REQUIRES).begin(); capIt != (*instIter)->dep (Dep::REQUIRES).end(); ++capIt)
461 {
462 sat::WhatProvides possibleProviders(*capIt);
463 for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
464 PoolItem provider = ResPool::instance().find( *iter );
465
466 // searching if this provider will already be installed
467 bool found = false;
468 bool alreadySetForInstallation = false;
469 ItemCapKindMap::const_iterator pos = _isInstalledBy.find(provider);
470 while (pos != _isInstalledBy.end()
471 && pos->first == provider
472 && !found) {
473 alreadySetForInstallation = true;
474 ItemCapKind capKind = pos->second;
475 if (capKind.item() == *instIter) found = true;
476 pos++;
477 }
478
479 if (!found
480 && provider.status().isToBeInstalled()) {
481 if (provider.status().isBySolver()) {
482 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::REQUIRES, !alreadySetForInstallation );
483 _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
484 } else {
485 // no initial installation cause it has been set be e.g. user
486 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::REQUIRES, false );
487 _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
488 }
489 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::REQUIRES, !alreadySetForInstallation );
490 _installs.insert (make_pair( *instIter, capKindisInstalledBy));
491 }
492
493 if (provider.status().staysInstalled()) { // Is already satisfied by an item which is installed
494 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::REQUIRES, false );
495 _satifiedByInstalled.insert (make_pair( *instIter, capKindisInstalledBy));
496
497 ItemCapKind installedSatisfied( *instIter, *capIt, Dep::REQUIRES, false );
498 _installedSatisfied.insert (make_pair( provider, installedSatisfied));
499 }
500 }
501 }
502
503 if (!(_satResolver->onlyRequires())) {
504 //Recommends
505 for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::RECOMMENDS).begin(); capIt != (*instIter)->dep (Dep::RECOMMENDS).end(); ++capIt)
506 {
507 sat::WhatProvides possibleProviders(*capIt);
508 for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
509 PoolItem provider = ResPool::instance().find( *iter );
510
511 // searching if this provider will already be installed
512 bool found = false;
513 bool alreadySetForInstallation = false;
514 ItemCapKindMap::const_iterator pos = _isInstalledBy.find(provider);
515 while (pos != _isInstalledBy.end()
516 && pos->first == provider
517 && !found) {
518 alreadySetForInstallation = true;
519 ItemCapKind capKind = pos->second;
520 if (capKind.item() == *instIter) found = true;
521 pos++;
522 }
523
524 if (!found
525 && provider.status().isToBeInstalled()) {
526 if (provider.status().isBySolver()) {
527 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::RECOMMENDS, !alreadySetForInstallation );
528 _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
529 } else {
530 // no initial installation cause it has been set be e.g. user
531 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::RECOMMENDS, false );
532 _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
533 }
534 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::RECOMMENDS, !alreadySetForInstallation );
535 _installs.insert (make_pair( *instIter, capKindisInstalledBy));
536 }
537
538 if (provider.status().staysInstalled()) { // Is already satisfied by an item which is installed
539 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::RECOMMENDS, false );
540 _satifiedByInstalled.insert (make_pair( *instIter, capKindisInstalledBy));
541
542 ItemCapKind installedSatisfied( *instIter, *capIt, Dep::RECOMMENDS, false );
543 _installedSatisfied.insert (make_pair( provider, installedSatisfied));
544 }
545 }
546 }
547
548 //Supplements
549 for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::SUPPLEMENTS).begin(); capIt != (*instIter)->dep (Dep::SUPPLEMENTS).end(); ++capIt)
550 {
551 sat::WhatProvides possibleProviders(*capIt);
552 for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
553 PoolItem provider = ResPool::instance().find( *iter );
554 // searching if this item will already be installed
555 bool found = false;
556 bool alreadySetForInstallation = false;
557 ItemCapKindMap::const_iterator pos = _isInstalledBy.find(*instIter);
558 while (pos != _isInstalledBy.end()
559 && pos->first == *instIter
560 && !found) {
561 alreadySetForInstallation = true;
562 ItemCapKind capKind = pos->second;
563 if (capKind.item() == provider) found = true;
564 pos++;
565 }
566
567 if (!found
568 && instIter->status().isToBeInstalled()) {
569 if (instIter->status().isBySolver()) {
570 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::SUPPLEMENTS, !alreadySetForInstallation );
571 _isInstalledBy.insert (make_pair( *instIter, capKindisInstalledBy));
572 } else {
573 // no initial installation cause it has been set be e.g. user
574 ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::SUPPLEMENTS, false );
575 _isInstalledBy.insert (make_pair( *instIter, capKindisInstalledBy));
576 }
577 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::SUPPLEMENTS, !alreadySetForInstallation );
578 _installs.insert (make_pair( provider, capKindisInstalledBy));
579 }
580
581 if (instIter->status().staysInstalled()) { // Is already satisfied by an item which is installed
582 ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::SUPPLEMENTS, !alreadySetForInstallation );
583 _satifiedByInstalled.insert (make_pair( provider, capKindisInstalledBy));
584
585 ItemCapKind installedSatisfied( provider, *capIt, Dep::SUPPLEMENTS, false );
586 _installedSatisfied.insert (make_pair( *instIter, installedSatisfied));
587 }
588 }
589 }
590 }
591 }
592 }
593}
594
595
596ItemCapKindList Resolver::isInstalledBy( const PoolItem & item )
597{
598 ItemCapKindList ret;
599 collectResolverInfo();
600
601 for (ItemCapKindMap::const_iterator iter = _isInstalledBy.find(item); iter != _isInstalledBy.end();) {
602 ItemCapKind info = iter->second;
603 PoolItem iterItem = iter->first;
604 if (iterItem == item) {
605 ret.push_back(info);
606 iter++;
607 } else {
608 // exit
609 iter = _isInstalledBy.end();
610 }
611 }
612 return ret;
613}
614
615ItemCapKindList Resolver::installs( const PoolItem & item )
616{
617 ItemCapKindList ret;
618 collectResolverInfo();
619
620 for (ItemCapKindMap::const_iterator iter = _installs.find(item); iter != _installs.end();) {
621 ItemCapKind info = iter->second;
622 PoolItem iterItem = iter->first;
623 if (iterItem == item) {
624 ret.push_back(info);
625 iter++;
626 } else {
627 // exit
628 iter = _installs.end();
629 }
630 }
631 return ret;
632}
633
634ItemCapKindList Resolver::satifiedByInstalled( const PoolItem & item )
635{
636 ItemCapKindList ret;
637 collectResolverInfo();
638
639 for (ItemCapKindMap::const_iterator iter = _satifiedByInstalled.find(item); iter != _satifiedByInstalled.end();) {
640 ItemCapKind info = iter->second;
641 PoolItem iterItem = iter->first;
642 if (iterItem == item) {
643 ret.push_back(info);
644 iter++;
645 } else {
646 // exit
647 iter = _satifiedByInstalled.end();
648 }
649 }
650 return ret;
651}
652
653ItemCapKindList Resolver::installedSatisfied( const PoolItem & item )
654{
655 ItemCapKindList ret;
656 collectResolverInfo();
657
658 for (ItemCapKindMap::const_iterator iter = _installedSatisfied.find(item); iter != _installedSatisfied.end();) {
659 ItemCapKind info = iter->second;
660 PoolItem iterItem = iter->first;
661 if (iterItem == item) {
662 ret.push_back(info);
663 iter++;
664 } else {
665 // exit
666 iter = _installedSatisfied.end();
667 }
668 }
669 return ret;
670}
671
672
674 };// namespace detail
677 };// namespace solver
680};// namespace zypp
682
#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:1134
static ZConfig & instance()
Singleton ctor.
Definition: ZConfig.cc:832
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:277
bool operator()(PoolItem item)
Definition: Resolver.cc:282
DoTransact(const ResStatus::TransactByValue &status)
Definition: Resolver.cc:278
bool operator()(PoolItem item)
Definition: Resolver.cc:267
UndoTransact(const ResStatus::TransactByValue &status)
Definition: Resolver.cc:263
ResStatus::TransactByValue resStatus
Definition: Resolver.cc:262
#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