libzypp  17.35.16
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 
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 {
50  namespace solver
52  {
53  namespace detail
55  {
56 
57 
58 //---------------------------------------------------------------------------
59 
60 
61 std::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 
105 {
106  delete _satResolver;
107 }
108 
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 }
141 ResolverFocus 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 
200 PoolItemList 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 
255 {
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 
270 {
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 //----------------------------------------------------------------------------
284 // undo
285 void Resolver::undo()
286 {
287  UndoTransact info(ResStatus::APPL_LOW);
288  MIL << "*** undo ***" << endl;
289  invokeOnEach ( _pool.begin(), _pool.end(),
290  resfilter::ByTransact( ), // collect transacts from Pool to resolver queue
291  std::ref(info) );
292  // Regard dependencies of the item weak onl
293  _addWeak.clear();
294 
295  // Additional QueueItems which has to be regarded by the solver
296  _removed_queue_items.clear();
297  _added_queue_items.clear();
298 
299  return;
300 }
301 
302 void Resolver::solverInit()
303 {
304  // Solving with libsolv
305  static bool poolDumped = false;
306  MIL << "-------------- Calling SAT Solver -------------------" << endl;
307  if ( getenv("ZYPP_FULLLOG") and get() ) { // libzypp/issues/317: get() to make sure a satsolver instance is actually present
308  Testcase testcase("/var/log/YaST2/autoTestcase");
309  if (!poolDumped) {
310  testcase.createTestcase (*this, true, false); // dump pool
311  poolDumped = true;
312  } else {
313  testcase.createTestcase (*this, false, false); // write control file only
314  }
315  }
316 
317  // update solver mode flags
318  _satResolver->setDistupgrade (_upgradeMode);
319  _satResolver->setUpdatesystem (_updateMode);
320  _satResolver->setFixsystem ( isVerifyingMode() );
321  _satResolver->setSolveSrcPackages ( solveSrcPackages() );
322  _satResolver->setIgnorealreadyrecommended ( ignoreAlreadyRecommended() );
323 
324  if (_upgradeMode) {
325  // Maybe depend on ZConfig::solverUpgradeRemoveDroppedPackages.
326  // For sure right but a change in behavior for old distros.
327  // (Will disable weakremover processing in SATResolver)
328  // _satResolver->setRemoveOrphaned( ... );
329  }
330 
331  // Resetting additional solver information
332  _isInstalledBy.clear();
333  _installs.clear();
334  _satifiedByInstalled.clear();
335  _installedSatisfied.clear();
336 }
337 
339 {
340  DBG << "Resolver::verifySystem()" << endl;
341  _verifying = true;
342  UndoTransact resetting (ResStatus::APPL_HIGH);
343  invokeOnEach ( _pool.begin(), _pool.end(),
344  resfilter::ByTransact( ), // Resetting all transcations
345  std::ref(resetting) );
346  return resolvePool();
347 }
348 
349 
350 bool Resolver::doUpgrade()
351 {
352  // Setting Resolver to upgrade mode. SAT solver will do the update
353  _upgradeMode = true;
354  return resolvePool();
355 }
356 
358 {
359  solverInit();
360  return _satResolver->resolvePool(_extra_requires, _extra_conflicts, _addWeak, _upgradeRepos );
361 }
362 
363 void Resolver::doUpdate()
364 {
365  _updateMode = true;
366  solverInit();
367  return _satResolver->doUpdate();
368 }
369 
371 {
372  solverInit();
373 
374  // add/remove additional SolverQueueItems
375  for (SolverQueueItemList::const_iterator iter = _removed_queue_items.begin();
376  iter != _removed_queue_items.end(); iter++) {
377  for (SolverQueueItemList::const_iterator iterQueue = queue.begin(); iterQueue != queue.end(); iterQueue++) {
378  if ( (*iterQueue)->cmp(*iter) == 0) {
379  MIL << "remove from queue" << *iter;
380  queue.remove(*iterQueue);
381  break;
382  }
383  }
384  }
385 
386  for (SolverQueueItemList::const_iterator iter = _added_queue_items.begin();
387  iter != _added_queue_items.end(); iter++) {
388  bool found = false;
389  for (SolverQueueItemList::const_iterator iterQueue = queue.begin(); iterQueue != queue.end(); iterQueue++) {
390  if ( (*iterQueue)->cmp(*iter) == 0) {
391  found = true;
392  break;
393  }
394  }
395  if (!found) {
396  MIL << "add to queue" << *iter;
397  queue.push_back(*iter);
398  }
399  }
400 
401  // The application has to take care to write these solutions back to e.g. selectables in order
402  // give the user a chance for changing these decisions again.
403  _removed_queue_items.clear();
404  _added_queue_items.clear();
405 
406  return _satResolver->resolveQueue(queue, _addWeak);
407 }
408 
409 sat::Transaction Resolver::getTransaction()
410 {
411  // FIXME: That's an ugly way of pushing autoInstalled into the transaction.
412  sat::Transaction ret( sat::Transaction::loadFromPool );
413  ret.autoInstalled( _satResolver->autoInstalled() );
414  return ret;
415 }
416 
417 
418 //----------------------------------------------------------------------------
419 // Getting more information about the solve results
420 
422 {
423  MIL << "Resolver::problems()" << endl;
424  return _satResolver->problems();
425 }
426 
427 void Resolver::applySolutions( const ProblemSolutionList & solutions )
428 {
429  for ( const ProblemSolution_Ptr& solution : solutions )
430  {
431  if ( ! applySolution( *solution ) )
432  break;
433  }
434 }
435 
436 bool Resolver::applySolution( const ProblemSolution & solution )
437 {
438  bool ret = true;
439  DBG << "apply solution " << solution << endl;
440  for ( const SolutionAction_Ptr& action : solution.actions() )
441  {
442  if ( ! action->execute( *this ) )
443  {
444  WAR << "apply solution action failed: " << action << endl;
445  ret = false;
446  break;
447  }
448  }
449  return ret;
450 }
451 
452 //----------------------------------------------------------------------------
453 
454 void Resolver::collectResolverInfo()
455 {
456  if ( _satResolver
457  && _isInstalledBy.empty()
458  && _installs.empty()) {
459 
460  // generating new
461  PoolItemList itemsToInstall = _satResolver->resultItemsToInstall();
462 
463  for (PoolItemList::const_iterator instIter = itemsToInstall.begin();
464  instIter != itemsToInstall.end(); instIter++) {
465  // Requires
466  for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::REQUIRES).begin(); capIt != (*instIter)->dep (Dep::REQUIRES).end(); ++capIt)
467  {
468  sat::WhatProvides possibleProviders(*capIt);
469  for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
470  PoolItem provider = ResPool::instance().find( *iter );
471 
472  // searching if this provider will already be installed
473  bool found = false;
474  bool alreadySetForInstallation = false;
475  ItemCapKindMap::const_iterator pos = _isInstalledBy.find(provider);
476  while (pos != _isInstalledBy.end()
477  && pos->first == provider
478  && !found) {
479  alreadySetForInstallation = true;
480  ItemCapKind capKind = pos->second;
481  if (capKind.item() == *instIter) found = true;
482  pos++;
483  }
484 
485  if (!found
486  && provider.status().isToBeInstalled()) {
487  if (provider.status().isBySolver()) {
488  ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::REQUIRES, !alreadySetForInstallation );
489  _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
490  } else {
491  // no initial installation cause it has been set be e.g. user
492  ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::REQUIRES, false );
493  _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
494  }
495  ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::REQUIRES, !alreadySetForInstallation );
496  _installs.insert (make_pair( *instIter, capKindisInstalledBy));
497  }
498 
499  if (provider.status().staysInstalled()) { // Is already satisfied by an item which is installed
500  ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::REQUIRES, false );
501  _satifiedByInstalled.insert (make_pair( *instIter, capKindisInstalledBy));
502 
503  ItemCapKind installedSatisfied( *instIter, *capIt, Dep::REQUIRES, false );
504  _installedSatisfied.insert (make_pair( provider, installedSatisfied));
505  }
506  }
507  }
508 
509  if (!(_satResolver->onlyRequires())) {
510  //Recommends
511  for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::RECOMMENDS).begin(); capIt != (*instIter)->dep (Dep::RECOMMENDS).end(); ++capIt)
512  {
513  sat::WhatProvides possibleProviders(*capIt);
514  for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
515  PoolItem provider = ResPool::instance().find( *iter );
516 
517  // searching if this provider will already be installed
518  bool found = false;
519  bool alreadySetForInstallation = false;
520  ItemCapKindMap::const_iterator pos = _isInstalledBy.find(provider);
521  while (pos != _isInstalledBy.end()
522  && pos->first == provider
523  && !found) {
524  alreadySetForInstallation = true;
525  ItemCapKind capKind = pos->second;
526  if (capKind.item() == *instIter) found = true;
527  pos++;
528  }
529 
530  if (!found
531  && provider.status().isToBeInstalled()) {
532  if (provider.status().isBySolver()) {
533  ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::RECOMMENDS, !alreadySetForInstallation );
534  _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
535  } else {
536  // no initial installation cause it has been set be e.g. user
537  ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::RECOMMENDS, false );
538  _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
539  }
540  ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::RECOMMENDS, !alreadySetForInstallation );
541  _installs.insert (make_pair( *instIter, capKindisInstalledBy));
542  }
543 
544  if (provider.status().staysInstalled()) { // Is already satisfied by an item which is installed
545  ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::RECOMMENDS, false );
546  _satifiedByInstalled.insert (make_pair( *instIter, capKindisInstalledBy));
547 
548  ItemCapKind installedSatisfied( *instIter, *capIt, Dep::RECOMMENDS, false );
549  _installedSatisfied.insert (make_pair( provider, installedSatisfied));
550  }
551  }
552  }
553 
554  //Supplements
555  for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::SUPPLEMENTS).begin(); capIt != (*instIter)->dep (Dep::SUPPLEMENTS).end(); ++capIt)
556  {
557  sat::WhatProvides possibleProviders(*capIt);
558  for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
559  PoolItem provider = ResPool::instance().find( *iter );
560  // searching if this item will already be installed
561  bool found = false;
562  bool alreadySetForInstallation = false;
563  ItemCapKindMap::const_iterator pos = _isInstalledBy.find(*instIter);
564  while (pos != _isInstalledBy.end()
565  && pos->first == *instIter
566  && !found) {
567  alreadySetForInstallation = true;
568  ItemCapKind capKind = pos->second;
569  if (capKind.item() == provider) found = true;
570  pos++;
571  }
572 
573  if (!found
574  && instIter->status().isToBeInstalled()) {
575  if (instIter->status().isBySolver()) {
576  ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::SUPPLEMENTS, !alreadySetForInstallation );
577  _isInstalledBy.insert (make_pair( *instIter, capKindisInstalledBy));
578  } else {
579  // no initial installation cause it has been set be e.g. user
580  ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::SUPPLEMENTS, false );
581  _isInstalledBy.insert (make_pair( *instIter, capKindisInstalledBy));
582  }
583  ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::SUPPLEMENTS, !alreadySetForInstallation );
584  _installs.insert (make_pair( provider, capKindisInstalledBy));
585  }
586 
587  if (instIter->status().staysInstalled()) { // Is already satisfied by an item which is installed
588  ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::SUPPLEMENTS, !alreadySetForInstallation );
589  _satifiedByInstalled.insert (make_pair( provider, capKindisInstalledBy));
590 
591  ItemCapKind installedSatisfied( provider, *capIt, Dep::SUPPLEMENTS, false );
592  _installedSatisfied.insert (make_pair( *instIter, installedSatisfied));
593  }
594  }
595  }
596  }
597  }
598  }
599 }
600 
601 
602 ItemCapKindList Resolver::isInstalledBy( const PoolItem & item )
603 {
604  ItemCapKindList ret;
605  collectResolverInfo();
606 
607  for (ItemCapKindMap::const_iterator iter = _isInstalledBy.find(item); iter != _isInstalledBy.end();) {
608  ItemCapKind info = iter->second;
609  PoolItem iterItem = iter->first;
610  if (iterItem == item) {
611  ret.push_back(info);
612  iter++;
613  } else {
614  // exit
615  iter = _isInstalledBy.end();
616  }
617  }
618  return ret;
619 }
620 
621 ItemCapKindList Resolver::installs( const PoolItem & item )
622 {
623  ItemCapKindList ret;
624  collectResolverInfo();
625 
626  for (ItemCapKindMap::const_iterator iter = _installs.find(item); iter != _installs.end();) {
627  ItemCapKind info = iter->second;
628  PoolItem iterItem = iter->first;
629  if (iterItem == item) {
630  ret.push_back(info);
631  iter++;
632  } else {
633  // exit
634  iter = _installs.end();
635  }
636  }
637  return ret;
638 }
639 
640 ItemCapKindList Resolver::satifiedByInstalled( const PoolItem & item )
641 {
642  ItemCapKindList ret;
643  collectResolverInfo();
644 
645  for (ItemCapKindMap::const_iterator iter = _satifiedByInstalled.find(item); iter != _satifiedByInstalled.end();) {
646  ItemCapKind info = iter->second;
647  PoolItem iterItem = iter->first;
648  if (iterItem == item) {
649  ret.push_back(info);
650  iter++;
651  } else {
652  // exit
653  iter = _satifiedByInstalled.end();
654  }
655  }
656  return ret;
657 }
658 
659 ItemCapKindList Resolver::installedSatisfied( const PoolItem & item )
660 {
661  ItemCapKindList ret;
662  collectResolverInfo();
663 
664  for (ItemCapKindMap::const_iterator iter = _installedSatisfied.find(item); iter != _installedSatisfied.end();) {
665  ItemCapKind info = iter->second;
666  PoolItem iterItem = iter->first;
667  if (iterItem == item) {
668  ret.push_back(info);
669  iter++;
670  } else {
671  // exit
672  iter = _installedSatisfied.end();
673  }
674  }
675  return ret;
676 }
677 
678 
680  };// namespace detail
683  };// namespace solver
686 };// namespace zypp
688 
void doUpdate()
Update to newest package.
Definition: Resolver.cc:83
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
#define MIL
Definition: Logger.h:100
bool resolvePool()
Resolve package dependencies:
Definition: Resolver.cc:62
sat::Transaction getTransaction()
Return the Transaction computed by the last solver run.
Definition: Resolver.cc:77
::s_Solver CSolver
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:65
void setRemoveOrphaned(bool yesno_r)
Set whether to remove unused orphans in &#39;upgrade&#39; mode.
Definition: Resolver.cc:105
static ZConfig & instance()
Singleton ctor.
Definition: ZConfig.cc:925
#define OUTS(t)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
Definition: ResPool.cc:74
ResolverFocus
The resolver&#39;s general attitude.
Definition: ResolverFocus.h:23
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:212
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
UndoTransact(const ResStatus::TransactByValue &status)
Definition: Resolver.cc:257
ZOLV_FLAG_SATSOLV(setCleandepsOnRemove, cleandepsOnRemove, ZConfig::instance().solver_cleandepsOnRemove(), _cleandepsOnRemove) ZOLV_FLAG_SATSOLV(setOnlyRequires
void undo()
Definition: Resolver.cc:68
bool doUpgrade()
Do an distribution upgrade (DUP)
Definition: Resolver.cc:80
Request the standard behavior (as defined in zypp.conf or &#39;Job&#39;)
bool resetTransact(TransactByValue causer_r)
Not the same as setTransact( false ).
Definition: ResStatus.h:490
solver::detail::ItemCapKindList isInstalledBy(const PoolItem &item)
Gives information about WHO has pused an installation of an given item.
Definition: Resolver.cc:167
~Resolver() override
Dtor.
Definition: Resolver.cc:45
bool resolveQueue(solver::detail::SolverQueueItemList &queue)
Resolve package dependencies:
Definition: Resolver.cc:65
bool operator()(const PoolItem &item)
Definition: Resolver.cc:261
ResolverProblemList problems()
Return the dependency problems found by the last call to resolveDependencies().
Definition: Resolver.cc:71
void reset()
Definition: Resolver.cc:179
_onlyRequires _dup_allowdowngrade dupAllowArchChange
Definition: Resolver.cc:176
solver::detail::ItemCapKindList installedSatisfied(const PoolItem &item)
Gives information about WHICH items require an already installed item.
Definition: Resolver.cc:176
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
static Pool instance()
Singleton ctor.
Definition: Pool.h:55
void setRemoveUnneeded(bool yesno_r)
File weak remove jobs for unneeded installed packages.
Definition: Resolver.cc:108
std::list< ItemCapKind > ItemCapKindList
Definition: Types.h:42
#define ZOLV_FLAG_DEFAULT(ZSETTER, ZGETTER)
std::list< PoolItem > problematicUpdateItems() const
Unmaintained packages which does not fit to the updated system (broken dependencies) will be deleted...
Definition: Resolver.cc:158
ResolverFocus focus() const
Definition: Resolver.cc:87
bool operator()(const PoolItem &item)
Definition: Resolver.cc:276
ResStatus::TransactByValue resStatus
Definition: Resolver.cc:256
bool removeUnneeded() const
Definition: Resolver.cc:109
Interim helper class to collect global options and settings.
Definition: ZConfig.h:68
#define WAR
Definition: Logger.h:101
std::list< SolverQueueItem_Ptr > SolverQueueItemList
Definition: Types.h:45
Select PoolItem by transact.
Definition: ResFilters.h:294
bool setTransact(bool toTansact_r, TransactByValue causer_r)
Toggle between TRANSACT and KEEP_STATE.
Definition: ResStatus.h:438
void applySolutions(const ProblemSolutionList &solutions)
Apply problem solutions.
Definition: Resolver.cc:74
static constexpr LoadFromPoolType loadFromPool
Definition: Transaction.h:82
_onlyRequires dupAllowDowngrade
Definition: Resolver.cc:174
Global ResObject pool.
Definition: ResPool.h:61
ResolverFocus solver_focus() const
The resolver&#39;s general attitude when resolving jobs.
Definition: ZConfig.cc:1227
void setDefaultSolverFlags(bool all_r=true)
Reset all solver flags to the systems default (e.g.
Definition: Resolver.cc:53
std::list< ResolverProblem_Ptr > ResolverProblemList
Definition: ProblemTypes.h:46
ResStatus::TransactByValue resStatus
Definition: Resolver.cc:271
sat::detail::CSolver * get() const
Expert backdoor.
Definition: Resolver.cc:56
bool verifySystem()
Resolve package dependencies:
Definition: Resolver.cc:59
DoTransact(const ResStatus::TransactByValue &status)
Definition: Resolver.cc:272
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
void setFocus(ResolverFocus focus_r)
Define the resolver&#39;s general attitude when resolving jobs.
Definition: Resolver.cc:86
bool removeOrphaned() const
Definition: Resolver.cc:106
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
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
#define DBG
Definition: Logger.h:99
Resolver(const ResPool &pool)
Ctor.
Definition: Resolver.cc:36
std::list< ProblemSolution_Ptr > ProblemSolutionList
Definition: ProblemTypes.h:43
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:38