libzypp 17.37.10

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