libzypp  17.31.31
SATResolver.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* SATResolver.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 the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19  * 02111-1307, USA.
20  */
21 extern "C"
22 {
23 #include <solv/repo_solv.h>
24 #include <solv/poolarch.h>
25 #include <solv/evr.h>
26 #include <solv/poolvendor.h>
27 #include <solv/policy.h>
28 #include <solv/bitmap.h>
29 #include <solv/queue.h>
30 }
31 
32 #define ZYPP_USE_RESOLVER_INTERNALS
33 
34 #include <zypp/base/LogTools.h>
35 #include <zypp/base/Gettext.h>
36 #include <zypp/base/Algorithm.h>
37 
38 #include <zypp/ZConfig.h>
39 #include <zypp/Product.h>
40 #include <zypp/AutoDispose.h>
41 #include <zypp/sat/WhatProvides.h>
42 #include <zypp/sat/WhatObsoletes.h>
43 #include <zypp/sat/detail/PoolImpl.h>
44 
45 #include <zypp/solver/detail/Resolver.h>
47 
55 using std::endl;
56 
57 #define XDEBUG(x) do { if (base::logger::isExcessive()) XXX << x << std::endl;} while (0)
58 
59 #undef ZYPP_BASE_LOGGER_LOGGROUP
60 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::solver"
61 
63 namespace zypp
64 {
65  namespace solver
67  {
68  namespace detail
70  {
71 
73  namespace
74  {
75  inline void solverSetFocus( sat::detail::CSolver & satSolver_r, const ResolverFocus & focus_r )
76  {
77  switch ( focus_r )
78  {
79  case ResolverFocus::Default: // fallthrough to Job
80  case ResolverFocus::Job:
81  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
82  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
83  break;
85  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 1 );
86  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
87  break;
89  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
90  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 1 );
91  break;
92  }
93  }
94 
98  inline sat::Queue collectPseudoInstalled( const ResPool & pool_r )
99  {
100  sat::Queue ret;
101  for ( const PoolItem & pi : pool_r )
102  if ( traits::isPseudoInstalled( pi.kind() ) ) ret.push( pi.id() );
103  return ret;
104  }
105 
109  inline void solverCopyBackWeak( sat::detail::CSolver & satSolver_r, PoolItemList & orphanedItems_r )
110  {
111  // NOTE: assert all items weak stati are reset (resetWeak was called)
112  {
113  sat::Queue recommendations;
114  sat::Queue suggestions;
115  ::solver_get_recommendations( &satSolver_r, recommendations, suggestions, 0 );
116  for ( sat::Queue::size_type i = 0; i < recommendations.size(); ++i )
117  PoolItem(sat::Solvable(recommendations[i])).status().setRecommended( true );
118  for ( sat::Queue::size_type i = 0; i < suggestions.size(); ++i )
119  PoolItem(sat::Solvable(suggestions[i])).status().setSuggested( true );
120  }
121  {
122  orphanedItems_r.clear(); // cached on the fly
123  sat::Queue orphaned;
124  ::solver_get_orphaned( &satSolver_r, orphaned );
125  for ( sat::Queue::size_type i = 0; i < orphaned.size(); ++i )
126  {
127  PoolItem pi { sat::Solvable(orphaned[i]) };
128  pi.status().setOrphaned( true );
129  orphanedItems_r.push_back( pi );
130  }
131  }
132  {
133  sat::Queue unneeded;
134  ::solver_get_unneeded( &satSolver_r, unneeded, 1 );
135  for ( sat::Queue::size_type i = 0; i < unneeded.size(); ++i )
136  PoolItem(sat::Solvable(unneeded[i])).status().setUnneeded( true );
137  }
138  }
139 
141  inline void solverCopyBackValidate( sat::detail::CSolver & satSolver_r, const ResPool & pool_r )
142  {
143  sat::Queue pseudoItems { collectPseudoInstalled( pool_r ) };
144  if ( ! pseudoItems.empty() )
145  {
146  sat::Queue pseudoFlags;
147  ::solver_trivial_installable( &satSolver_r, pseudoItems, pseudoFlags );
148 
149  for ( sat::Queue::size_type i = 0; i < pseudoItems.size(); ++i )
150  {
151  PoolItem pi { sat::Solvable(pseudoItems[i]) };
152  switch ( pseudoFlags[i] )
153  {
154  case 0: pi.status().setBroken(); break;
155  case 1: pi.status().setSatisfied(); break;
156  case -1: pi.status().setNonRelevant(); break;
157  default: pi.status().setUndetermined(); break;
158  }
159  }
160  }
161  }
162 
163  } //namespace
165 
166 
167 
168 IMPL_PTR_TYPE(SATResolver);
169 
170 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0)
171 
172 //---------------------------------------------------------------------------
173 // Callbacks for SAT policies
174 //---------------------------------------------------------------------------
175 
176 int vendorCheck( sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2 )
177 { return VendorAttr::instance().equivalent( IdString(solvable1->vendor), IdString(solvable2->vendor) ) ? 0 : 1; }
178 
179 int relaxedVendorCheck( sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2 )
180 { return VendorAttr::instance().relaxedEquivalent( IdString(solvable1->vendor), IdString(solvable2->vendor) ) ? 0 : 1; }
181 
186 void establish( sat::Queue & pseudoItems_r, sat::Queue & pseudoFlags_r )
187 {
188  pseudoItems_r = collectPseudoInstalled( ResPool::instance() );
189  if ( ! pseudoItems_r.empty() )
190  {
191  auto satPool = sat::Pool::instance();
192  MIL << "Establish..." << endl;
193  sat::detail::CPool * cPool { satPool.get() };
194  ::pool_set_custom_vendorcheck( cPool, &vendorCheck );
195 
196  sat::Queue jobQueue;
197  // Add rules for parallel installable resolvables with different versions
198  for ( const sat::Solvable & solv : satPool.multiversion() )
199  {
200  jobQueue.push( SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
201  jobQueue.push( solv.id() );
202  }
203 
204  AutoDispose<sat::detail::CSolver*> cSolver { ::solver_create( cPool ), ::solver_free };
205  satPool.prepare();
206  if ( ::solver_solve( cSolver, jobQueue ) != 0 )
207  INT << "How can establish fail?" << endl;
208 
209  ::solver_trivial_installable( cSolver, pseudoItems_r, pseudoFlags_r );
210 
211  for ( sat::Queue::size_type i = 0; i < pseudoItems_r.size(); ++i )
212  {
213  PoolItem pi { sat::Solvable(pseudoItems_r[i]) };
214  switch ( pseudoFlags_r[i] )
215  {
216  case 0: pi.status().setBroken(); break;
217  case 1: pi.status().setSatisfied(); break;
218  case -1: pi.status().setNonRelevant(); break;
219  default: pi.status().setUndetermined(); break;
220  }
221  }
222  MIL << "Establish DONE" << endl;
223  }
224  else
225  MIL << "Establish not needed." << endl;
226 }
227 
228 inline std::string itemToString( const PoolItem & item )
229 {
230  if ( !item )
231  return std::string();
232 
233  sat::Solvable slv( item.satSolvable() );
234  std::string ret( slv.asString() ); // n-v-r.a
235  if ( ! slv.isSystem() )
236  {
237  ret += "[";
238  ret += slv.repository().alias();
239  ret += "]";
240  }
241  return ret;
242 }
243 
244 //---------------------------------------------------------------------------
245 
246 std::ostream &
247 SATResolver::dumpOn( std::ostream & os ) const
248 {
249  os << "<resolver>" << endl;
250  if (_satSolver) {
251 #define OUTS(X) os << " " << #X << "\t= " << solver_get_flag(_satSolver, SOLVER_FLAG_##X) << endl
252  OUTS( ALLOW_DOWNGRADE );
253  OUTS( ALLOW_ARCHCHANGE );
254  OUTS( ALLOW_VENDORCHANGE );
255  OUTS( ALLOW_NAMECHANGE );
256  OUTS( ALLOW_UNINSTALL );
257  OUTS( NO_UPDATEPROVIDE );
258  OUTS( SPLITPROVIDES );
259  OUTS( ONLY_NAMESPACE_RECOMMENDED );
260  OUTS( ADD_ALREADY_RECOMMENDED );
261  OUTS( NO_INFARCHCHECK );
262  OUTS( KEEP_EXPLICIT_OBSOLETES );
263  OUTS( BEST_OBEY_POLICY );
264  OUTS( NO_AUTOTARGET );
265  OUTS( DUP_ALLOW_DOWNGRADE );
266  OUTS( DUP_ALLOW_ARCHCHANGE );
267  OUTS( DUP_ALLOW_VENDORCHANGE );
268  OUTS( DUP_ALLOW_NAMECHANGE );
269  OUTS( KEEP_ORPHANS );
270  OUTS( BREAK_ORPHANS );
271  OUTS( YUM_OBSOLETES );
272 #undef OUTS
273  os << " focus = " << _focus << endl;
274  os << " distupgrade = " << _distupgrade << endl;
275  os << " distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
276  os << " solveSrcPackages = " << _solveSrcPackages << endl;
277  os << " cleandepsOnRemove = " << _cleandepsOnRemove << endl;
278  os << " fixsystem = " << _fixsystem << endl;
279  } else {
280  os << "<NULL>";
281  }
282  return os << "<resolver/>" << endl;
283 }
284 
285 //---------------------------------------------------------------------------
286 
287 // NOTE: flag defaults must be in sync with ZVARDEFAULT in Resolver.cc
288 SATResolver::SATResolver (const ResPool & pool, sat::detail::CPool *satPool)
289  : _pool(pool)
290  , _satPool(satPool)
291  , _satSolver(NULL)
292  , _focus ( ZConfig::instance().solver_focus() )
293  , _fixsystem(false)
294  , _allowdowngrade ( false )
295  , _allownamechange ( true ) // bsc#1071466
296  , _allowarchchange ( false )
297  , _allowvendorchange ( ZConfig::instance().solver_allowVendorChange() )
298  , _allowuninstall ( false )
299  , _updatesystem(false)
300  , _noupdateprovide ( false )
301  , _dosplitprovides ( true )
302  , _onlyRequires (ZConfig::instance().solver_onlyRequires())
303  , _ignorealreadyrecommended(true)
304  , _distupgrade(false)
305  , _distupgrade_removeunsupported(false)
306  , _dup_allowdowngrade ( ZConfig::instance().solver_dupAllowDowngrade() )
307  , _dup_allownamechange ( ZConfig::instance().solver_dupAllowNameChange() )
308  , _dup_allowarchchange ( ZConfig::instance().solver_dupAllowArchChange() )
309  , _dup_allowvendorchange ( ZConfig::instance().solver_dupAllowVendorChange() )
310  , _solveSrcPackages(false)
311  , _cleandepsOnRemove(ZConfig::instance().solver_cleandepsOnRemove())
312 {
313 }
314 
315 
316 SATResolver::~SATResolver()
317 {
318  solverEnd();
319 }
320 
321 //---------------------------------------------------------------------------
322 
323 ResPool
324 SATResolver::pool (void) const
325 {
326  return _pool;
327 }
328 
329 //---------------------------------------------------------------------------
330 
331 // copy marked item from solution back to pool
332 // if data != NULL, set as APPL_LOW (from establishPool())
333 
334 static void
336 {
337  // resetting
338  item.status().resetTransact (causer);
339  item.status().resetWeak ();
340 
341  bool r;
342 
343  // installation/deletion
344  if (status.isToBeInstalled()) {
345  r = item.status().setToBeInstalled (causer);
346  XDEBUG("SATSolutionToPool install returns " << item << ", " << r);
347  }
348  else if (status.isToBeUninstalledDueToUpgrade()) {
349  r = item.status().setToBeUninstalledDueToUpgrade (causer);
350  XDEBUG("SATSolutionToPool upgrade returns " << item << ", " << r);
351  }
352  else if (status.isToBeUninstalled()) {
353  r = item.status().setToBeUninstalled (causer);
354  XDEBUG("SATSolutionToPool remove returns " << item << ", " << r);
355  }
356 
357  return;
358 }
359 
360 //----------------------------------------------------------------------------
361 //----------------------------------------------------------------------------
362 // solverInit
363 //----------------------------------------------------------------------------
364 //----------------------------------------------------------------------------
373 {
374  SATCollectTransact( PoolItemList & items_to_install_r,
375  PoolItemList & items_to_remove_r,
376  PoolItemList & items_to_lock_r,
377  PoolItemList & items_to_keep_r,
378  bool solveSrcPackages_r )
379  : _items_to_install( items_to_install_r )
380  , _items_to_remove( items_to_remove_r )
381  , _items_to_lock( items_to_lock_r )
382  , _items_to_keep( items_to_keep_r )
383  , _solveSrcPackages( solveSrcPackages_r )
384  {
385  _items_to_install.clear();
386  _items_to_remove.clear();
387  _items_to_lock.clear();
388  _items_to_keep.clear();
389  }
390 
391  bool operator()( const PoolItem & item_r )
392  {
393 
394  ResStatus & itemStatus( item_r.status() );
395  bool by_solver = ( itemStatus.isBySolver() || itemStatus.isByApplLow() );
396 
397  if ( by_solver )
398  {
399  // Clear former solver/establish resultd
400  itemStatus.resetTransact( ResStatus::APPL_LOW );
401  return true; // -> back out here, don't re-queue former results
402  }
403 
404  if ( !_solveSrcPackages && item_r.isKind<SrcPackage>() )
405  {
406  // Later we may continue on a per source package base.
407  return true; // dont process this source package.
408  }
409 
410  switch ( itemStatus.getTransactValue() )
411  {
412  case ResStatus::TRANSACT:
413  itemStatus.isUninstalled() ? _items_to_install.push_back( item_r )
414  : _items_to_remove.push_back( item_r ); break;
415  case ResStatus::LOCKED: _items_to_lock.push_back( item_r ); break;
416  case ResStatus::KEEP_STATE: _items_to_keep.push_back( item_r ); break;
417  }
418  return true;
419  }
420 
421 private:
422  PoolItemList & _items_to_install;
423  PoolItemList & _items_to_remove;
424  PoolItemList & _items_to_lock;
425  PoolItemList & _items_to_keep;
427 
428 };
430 
431 void
432 SATResolver::solverEnd()
433 {
434  // cleanup
435  if ( _satSolver )
436  {
437  solver_free(_satSolver);
438  _satSolver = NULL;
439  queue_free( &(_jobQueue) );
440  }
441 }
442 
443 void
444 SATResolver::solverInit(const PoolItemList & weakItems)
445 {
446  MIL << "SATResolver::solverInit()" << endl;
447 
448  // Remove old stuff and create a new jobqueue
449  solverEnd();
450  _satSolver = solver_create( _satPool );
451  queue_init( &_jobQueue );
452 
453  {
454  // bsc#1182629: in dup allow an available -release package providing 'dup-vendor-relax(suse)'
455  // to let (suse/opensuse) vendor being treated as being equivalent.
456  bool toRelax = false;
457  if ( _distupgrade ) {
458  for ( sat::Solvable solv : sat::WhatProvides( Capability("dup-vendor-relax(suse)") ) ) {
459  if ( ! solv.isSystem() ) {
460  MIL << "Relaxed vendor check requested by " << solv << endl;
461  toRelax = true;
462  break;
463  }
464  }
465  }
466  ::pool_set_custom_vendorcheck( _satPool, toRelax ? &relaxedVendorCheck : &vendorCheck );
467  }
468 
469  // Add rules for user/auto installed packages
470  ::pool_add_userinstalled_jobs(_satPool, sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
471 
472  // Collect PoolItem's tasks and cleanup Pool for solving.
473  // Todos are kept in _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep
474  {
475  SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
476  invokeOnEach ( _pool.begin(), _pool.end(), std::ref( collector ) );
477  }
478 
479  // Add rules for previous ProblemSolutions "break %s by ignoring some of its dependencies"
480  for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
481  Id id = iter->id();
482  if (id == ID_NULL) {
483  ERR << "Weaken: " << *iter << " not found" << endl;
484  }
485  MIL << "Weaken dependencies of " << *iter << endl;
486  queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
487  queue_push( &(_jobQueue), id );
488  }
489 
490  // Add rules for retracted patches and packages
491  {
492  queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
493  queue_push( &(_jobQueue), sat::Solvable::retractedToken.id() );
494  queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
495  queue_push( &(_jobQueue), sat::Solvable::ptfMasterToken.id() );
496  // bsc#1186503: ptfPackageToken should not be blacklisted
497  }
498 
499  // Add rules for changed requestedLocales
500  {
501  const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
502 
503  // just track changed locakes
504  for ( const auto & locale : trackedLocaleIds.added() )
505  {
506  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
507  queue_push( &(_jobQueue), Capability( ResolverNamespace::language, IdString(locale) ).id() );
508  }
509 
510  for ( const auto & locale : trackedLocaleIds.removed() )
511  {
512  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS ); // needs uncond. SOLVER_CLEANDEPS!
513  queue_push( &(_jobQueue), Capability( ResolverNamespace::language, IdString(locale) ).id() );
514  }
515  }
516 
517  // Add rules for parallel installable resolvables with different versions
518  for ( const sat::Solvable & solv : myPool().multiversionList() )
519  {
520  queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
521  queue_push( &(_jobQueue), solv.id() );
522  }
523 
524  // Add rules to protect PTF removal without repos (bsc#1203248)
525  // Removing a PTF its packages should be replaced by the official
526  // versions again. If just the system repo is present, they'd get
527  // removed instead.
528  {
529  _protectPTFs = sat::Pool::instance().reposSize() == 1;
530  if ( _protectPTFs ) {
531  for ( const auto & solv : sat::AllPTFs() ) {
532  if ( solv.isSystem() ) {
533  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
534  queue_push( &(_jobQueue), solv.id() );
535  }
536  }
537  }
538  }
539 
540  // set requirements for a running system
541  solverInitSetSystemRequirements();
542 
543  // set locks for the solver
544  solverInitSetLocks();
545 
546  // set mode (verify,up,dup) specific jobs and solver flags
547  solverInitSetModeJobsAndFlags();
548 }
549 
550 void SATResolver::solverInitSetSystemRequirements()
551 {
552  CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
553  CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
554 
555  for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
556  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
557  queue_push( &(_jobQueue), iter->id() );
558  MIL << "SYSTEM Requires " << *iter << endl;
559  }
560 
561  for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
562  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
563  queue_push( &(_jobQueue), iter->id() );
564  MIL << "SYSTEM Conflicts " << *iter << endl;
565  }
566 
567  // Lock the architecture of the running systems rpm
568  // package on distupgrade.
569  if ( _distupgrade && ZConfig::instance().systemRoot() == "/" )
570  {
571  ResPool pool( ResPool::instance() );
572  IdString rpm( "rpm" );
573  for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
574  {
575  if ( (*it)->isSystem() )
576  {
577  Capability archrule( (*it)->arch(), rpm.c_str(), Capability::PARSED );
578  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
579  queue_push( &(_jobQueue), archrule.id() );
580 
581  }
582  }
583  }
584 }
585 
586 void SATResolver::solverInitSetLocks()
587 {
588  unsigned icnt = 0;
589  unsigned acnt = 0;
590 
591  for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
592  sat::detail::SolvableIdType id( iter->id() );
593  if (iter->status().isInstalled()) {
594  ++icnt;
595  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
596  queue_push( &(_jobQueue), id );
597  } else {
598  ++acnt;
599  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
600  queue_push( &(_jobQueue), id );
601  }
602  }
603  MIL << "Locked " << icnt << " installed items and " << acnt << " NOT installed items." << endl;
604 
606  // Weak locks: Ignore if an item with this name is already installed.
607  // If it's not installed try to keep it this way using a weak delete
609  std::set<IdString> unifiedByName;
610  for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
611  IdString ident( iter->ident() );
612  if ( unifiedByName.insert( ident ).second )
613  {
614  if ( ! ui::Selectable::get( *iter )->hasInstalledObj() )
615  {
616  MIL << "Keep NOT installed name " << ident << " (" << *iter << ")" << endl;
617  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK | MAYBE_CLEANDEPS );
618  queue_push( &(_jobQueue), ident.id() );
619  }
620  }
621  }
622 }
623 
624 void SATResolver::solverInitSetModeJobsAndFlags()
625 {
626  if (_fixsystem) {
627  queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
628  queue_push( &(_jobQueue), 0 );
629  }
630  if (_updatesystem) {
631  queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
632  queue_push( &(_jobQueue), 0 );
633  }
634  if (_distupgrade) {
635  queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
636  queue_push( &(_jobQueue), 0 );
637  }
638  if (_distupgrade_removeunsupported) {
639  queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
640  queue_push( &(_jobQueue), 0 );
641  }
642 
643  solverSetFocus( *_satSolver, _focus );
644  solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
645  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
646  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
647  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
648  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
649  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
650  solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
651  solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
652  solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, false); // resolve recommended namespaces
653  solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires); //
654  solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, _dup_allowdowngrade );
655  solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_NAMECHANGE, _dup_allownamechange );
656  solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE, _dup_allowarchchange );
657  solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE, _dup_allowvendorchange );
658 }
659 
660 //----------------------------------------------------------------------------
661 //----------------------------------------------------------------------------
662 // solving.....
663 //----------------------------------------------------------------------------
664 //----------------------------------------------------------------------------
665 
667 {
668  public:
671 
672  CheckIfUpdate( const sat::Solvable & installed_r )
673  : is_updated( false )
674  , _installed( installed_r )
675  {}
676 
677  // check this item will be updated
678 
679  bool operator()( const PoolItem & item )
680  {
681  if ( item.status().isToBeInstalled() )
682  {
683  if ( ! item.multiversionInstall() || sameNVRA( _installed, item ) )
684  {
685  is_updated = true;
686  return false;
687  }
688  }
689  return true;
690  }
691 };
692 
693 
694 bool
695 SATResolver::solving(const CapabilitySet & requires_caps,
696  const CapabilitySet & conflict_caps)
697 {
699 
700  // Solve !
701  MIL << "Starting solving...." << endl;
702  MIL << *this;
703  if ( solver_solve( _satSolver, &(_jobQueue) ) == 0 )
704  {
705  // bsc#1155819: Weakremovers of future product not evaluated.
706  // Do a 2nd run to cleanup weakremovers() of to be installed
707  // Produtcs unless removeunsupported is active (cleans up all).
708  if ( _distupgrade )
709  {
710  if ( _distupgrade_removeunsupported )
711  MIL << "Droplist processing not needed. RemoveUnsupported is On." << endl;
712  else if ( ! ZConfig::instance().solverUpgradeRemoveDroppedPackages() )
713  MIL << "Droplist processing is disabled in ZConfig." << endl;
714  else
715  {
716  bool resolve = false;
717  MIL << "Checking droplists ..." << endl;
718  // get Solvables to be installed...
719  sat::SolvableQueue decisionq;
720  solver_get_decisionqueue( _satSolver, decisionq );
721  for ( sat::detail::IdType id : decisionq )
722  {
723  if ( id < 0 )
724  continue;
726  // get product buddies (they carry the weakremover)...
727  static const Capability productCap { "product()" };
728  if ( slv && slv.provides().matches( productCap ) )
729  {
730  CapabilitySet droplist { slv.valuesOfNamespace( "weakremover" ) };
731  MIL << "Droplist for " << slv << ": size " << droplist.size() << endl;
732  if ( !droplist.empty() )
733  {
734  for ( const auto & cap : droplist )
735  {
736  queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
737  queue_push( &_jobQueue, cap.id() );
738  }
739  // PIN product - a safety net to prevent cleanup from changing the decision for this product
740  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
741  queue_push( &(_jobQueue), id );
742  resolve = true;
743  }
744  }
745  }
746  if ( resolve )
747  solver_solve( _satSolver, &(_jobQueue) );
748  }
749  }
750  }
751  MIL << "....Solver end" << endl;
752 
753  // copying solution back to zypp pool
754  //-----------------------------------------
755  _result_items_to_install.clear();
756  _result_items_to_remove.clear();
757 
758  /* solvables to be installed */
759  Queue decisionq;
760  queue_init(&decisionq);
761  solver_get_decisionqueue(_satSolver, &decisionq);
762  for ( int i = 0; i < decisionq.count; ++i )
763  {
764  Id p = decisionq.elements[i];
765  if ( p < 0 )
766  continue;
767 
768  sat::Solvable slv { (sat::detail::SolvableIdType)p };
769  if ( ! slv || slv.isSystem() )
770  continue;
771 
772  PoolItem poolItem( slv );
774  _result_items_to_install.push_back( poolItem );
775  }
776  queue_free(&decisionq);
777 
778  /* solvables to be erased */
779  Repository systemRepo( sat::Pool::instance().findSystemRepo() ); // don't create if it does not exist
780  if ( systemRepo && ! systemRepo.solvablesEmpty() )
781  {
782  bool mustCheckObsoletes = false;
783  for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
784  {
785  if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
786  continue;
787 
788  // Check if this is an update
789  CheckIfUpdate info( *it );
790  PoolItem poolItem( *it );
791  invokeOnEach( _pool.byIdentBegin( poolItem ),
792  _pool.byIdentEnd( poolItem ),
793  resfilter::ByUninstalled(), // ByUninstalled
794  std::ref(info) );
795 
796  if (info.is_updated) {
798  } else {
800  if ( ! mustCheckObsoletes )
801  mustCheckObsoletes = true; // lazy check for UninstalledDueToObsolete
802  }
803  _result_items_to_remove.push_back (poolItem);
804  }
805  if ( mustCheckObsoletes )
806  {
807  sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
808  for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
809  {
810  ResStatus & status( it->status() );
811  // WhatObsoletes contains installed items only!
812  if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
813  status.setToBeUninstalledDueToObsolete();
814  }
815  }
816  }
817 
818  // copy back computed status values to pool
819  // (on the fly cache orphaned items for the UI)
820  solverCopyBackWeak( *_satSolver, _problem_items );
821  solverCopyBackValidate( *_satSolver, _pool );
822 
823  // Solvables which were selected due requirements which have been made by the user will
824  // be selected by APPL_LOW. We can't use any higher level, because this setting must
825  // not serve as a request for the next solver run. APPL_LOW is reset before solving.
826  for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
827  sat::WhatProvides rpmProviders(*iter);
828  for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
829  PoolItem poolItem(*iter2);
830  if (poolItem.status().isToBeInstalled()) {
831  MIL << "User requirement " << *iter << " sets " << poolItem << endl;
832  poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
833  }
834  }
835  }
836  for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
837  sat::WhatProvides rpmProviders(*iter);
838  for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
839  PoolItem poolItem(*iter2);
840  if (poolItem.status().isToBeUninstalled()) {
841  MIL << "User conflict " << *iter << " sets " << poolItem << endl;
842  poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
843  }
844  }
845  }
846 
847  if (solver_problem_count(_satSolver) > 0 )
848  {
849  ERR << "Solverrun finished with an ERROR" << endl;
850  return false;
851  }
852 
853  return true;
854 }
855 
856 void SATResolver::solverAddJobsFromPool()
857 {
858  for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
859  Id id = iter->id();
860  if (id == ID_NULL) {
861  ERR << "Install: " << *iter << " not found" << endl;
862  } else {
863  MIL << "Install " << *iter << endl;
864  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
865  queue_push( &(_jobQueue), id );
866  }
867  }
868 
869  for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
870  Id id = iter->id();
871  if (id == ID_NULL) {
872  ERR << "Delete: " << *iter << " not found" << endl;
873  } else {
874  MIL << "Delete " << *iter << endl;
875  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
876  queue_push( &(_jobQueue), id);
877  }
878  }
879 }
880 
881 void SATResolver::solverAddJobsFromExtraQueues( const CapabilitySet & requires_caps, const CapabilitySet & conflict_caps )
882 {
883  for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
884  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
885  queue_push( &(_jobQueue), iter->id() );
886  MIL << "Requires " << *iter << endl;
887  }
888 
889  for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
890  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
891  queue_push( &(_jobQueue), iter->id() );
892  MIL << "Conflicts " << *iter << endl;
893  }
894 }
895 
896 bool
897 SATResolver::resolvePool(const CapabilitySet & requires_caps,
898  const CapabilitySet & conflict_caps,
899  const PoolItemList & weakItems,
900  const std::set<Repository> & upgradeRepos)
901 {
902  MIL << "SATResolver::resolvePool()" << endl;
903 
904  // Initialize
905  solverInit(weakItems);
906 
907  // Add pool and extra jobs.
908  solverAddJobsFromPool();
909  solverAddJobsFromExtraQueues( requires_caps, conflict_caps );
910  // 'dup --from' jobs
911  for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
912  {
913  queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
914  queue_push( &(_jobQueue), iter->get()->repoid );
915  MIL << "Upgrade repo " << *iter << endl;
916  }
917 
918  // Solve!
919  bool ret = solving(requires_caps, conflict_caps);
920 
921  (ret?MIL:WAR) << "SATResolver::resolvePool() done. Ret:" << ret << endl;
922  return ret;
923 }
924 
925 
926 bool
927 SATResolver::resolveQueue(const SolverQueueItemList &requestQueue,
928  const PoolItemList & weakItems)
929 {
930  MIL << "SATResolver::resolvQueue()" << endl;
931 
932  // Initialize
933  solverInit(weakItems);
934 
935  // Add request queue's jobs.
936  for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
937  (*iter)->addRule(_jobQueue);
938  }
939 
940  // Add pool jobs; they do contain any problem resolutions.
941  solverAddJobsFromPool();
942 
943  // Solve!
944  bool ret = solving();
945 
946  (ret?MIL:WAR) << "SATResolver::resolveQueue() done. Ret:" << ret << endl;
947  return ret;
948 }
949 
950 
951 void SATResolver::doUpdate()
952 {
953  MIL << "SATResolver::doUpdate()" << endl;
954 
955  // Initialize
956  solverInit(PoolItemList());
957 
958  // By now, doUpdate has no additional jobs.
959  // It does not include any pool jobs, and so it does not create an conflicts.
960  // Combinations like patch_with_update are driven by resolvePool + _updatesystem.
961 
962  // TODO: Try to join the following with solving()
964 
965  // Solve!
966  MIL << "Starting solving for update...." << endl;
967  MIL << *this;
968  solver_solve( _satSolver, &(_jobQueue) );
969  MIL << "....Solver end" << endl;
970 
971  // copying solution back to zypp pool
972  //-----------------------------------------
973 
974  /* solvables to be installed */
975  Queue decisionq;
976  queue_init(&decisionq);
977  solver_get_decisionqueue(_satSolver, &decisionq);
978  for (int i = 0; i < decisionq.count; i++)
979  {
980  Id p = decisionq.elements[i];
981  if ( p < 0 )
982  continue;
983 
984  sat::Solvable solv { (sat::detail::SolvableIdType)p };
985  if ( ! solv || solv.isSystem() )
986  continue;
987 
989  }
990  queue_free(&decisionq);
991 
992  /* solvables to be erased */
993  if ( _satSolver->pool->installed ) {
994  for (int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
995  {
996  if (solver_get_decisionlevel(_satSolver, i) > 0)
997  continue;
998 
999  PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
1000  if (poolItem) {
1001  // Check if this is an update
1002  CheckIfUpdate info( (sat::Solvable(i)) );
1003  invokeOnEach( _pool.byIdentBegin( poolItem ),
1004  _pool.byIdentEnd( poolItem ),
1005  resfilter::ByUninstalled(), // ByUninstalled
1006  std::ref(info) );
1007 
1008  if (info.is_updated) {
1010  } else {
1012  }
1013  } else {
1014  ERR << "id " << i << " not found in ZYPP pool." << endl;
1015  }
1016  }
1017  }
1018 
1019  // copy back computed status values to pool
1020  // (on the fly cache orphaned items for the UI)
1021  solverCopyBackWeak( *_satSolver, _problem_items );
1022  solverCopyBackValidate( *_satSolver, _pool );
1023 
1024  MIL << "SATResolver::doUpdate() done" << endl;
1025 }
1026 
1027 
1028 
1029 //----------------------------------------------------------------------------
1030 //----------------------------------------------------------------------------
1031 // error handling
1032 //----------------------------------------------------------------------------
1033 //----------------------------------------------------------------------------
1034 
1035 //----------------------------------------------------------------------------
1036 // helper function
1037 //----------------------------------------------------------------------------
1038 
1040 {
1041  ProblemSolutionCombi *problemSolution;
1042  TransactionKind action;
1043  FindPackage (ProblemSolutionCombi *p, const TransactionKind act)
1044  : problemSolution (p)
1045  , action (act)
1046  {
1047  }
1048 
1050  {
1051  problemSolution->addSingleAction (p, action);
1052  return true;
1053  }
1054 };
1055 
1056 
1057 //----------------------------------------------------------------------------
1058 // Checking if this solvable/item has a buddy which reflect the real
1059 // user visible description of an item
1060 // e.g. The release package has a buddy to the concerning product item.
1061 // This user want's the message "Product foo conflicts with product bar" and
1062 // NOT "package release-foo conflicts with package release-bar"
1063 // (ma: that's why we should map just packages to buddies, not vice versa)
1064 //----------------------------------------------------------------------------
1065 inline sat::Solvable mapBuddy( const PoolItem & item_r )
1066 {
1067  if ( item_r.isKind<Package>() )
1068  {
1069  sat::Solvable buddy = item_r.buddy();
1070  if ( buddy )
1071  return buddy;
1072  }
1073  return item_r.satSolvable();
1074 }
1076 { return mapBuddy( PoolItem( item_r ) ); }
1077 
1078 PoolItem SATResolver::mapItem ( const PoolItem & item )
1079 { return PoolItem( mapBuddy( item ) ); }
1080 
1081 sat::Solvable SATResolver::mapSolvable ( const Id & id )
1082 { return mapBuddy( sat::Solvable(id) ); }
1083 
1084 std::vector<std::string> SATResolver::SATgetCompleteProblemInfoStrings ( Id problem )
1085 {
1086  std::vector<std::string> ret;
1087  sat::Queue problems;
1088  solver_findallproblemrules( _satSolver, problem, problems );
1089 
1090  bool nobad = false;
1091 
1092  //filter out generic rule information if more explicit ones are available
1093  for ( sat::Queue::size_type i = 0; i < problems.size(); i++ ) {
1094  SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1095  if ( ruleClass != SolverRuleinfo::SOLVER_RULE_UPDATE && ruleClass != SolverRuleinfo::SOLVER_RULE_JOB ) {
1096  nobad = true;
1097  break;
1098  }
1099  }
1100  for ( sat::Queue::size_type i = 0; i < problems.size(); i++ ) {
1101  SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1102  if ( nobad && ( ruleClass == SolverRuleinfo::SOLVER_RULE_UPDATE || ruleClass == SolverRuleinfo::SOLVER_RULE_JOB ) ) {
1103  continue;
1104  }
1105 
1106  std::string detail;
1107  Id ignore = 0;
1108  std::string pInfo = SATproblemRuleInfoString( problems[i], detail, ignore );
1109 
1110  //we get the same string multiple times, reduce the noise
1111  if ( std::find( ret.begin(), ret.end(), pInfo ) == ret.end() )
1112  ret.push_back( pInfo );
1113  }
1114  return ret;
1115 }
1116 
1117 std::string SATResolver::SATprobleminfoString(Id problem, std::string &detail, Id &ignoreId)
1118 {
1119  // FIXME: solver_findallproblemrules to get all rules for this problem
1120  // (the 'most relevabt' one returned by solver_findproblemrule is embedded
1121  Id probr = solver_findproblemrule(_satSolver, problem);
1122  return SATproblemRuleInfoString( probr, detail, ignoreId );
1123 }
1124 
1125 std::string SATResolver::SATproblemRuleInfoString (Id probr, std::string &detail, Id &ignoreId)
1126 {
1127  std::string ret;
1128  sat::detail::CPool *pool = _satSolver->pool;
1129  Id dep, source, target;
1130  SolverRuleinfo type = solver_ruleinfo(_satSolver, probr, &source, &target, &dep);
1131 
1132  ignoreId = 0;
1133 
1134  sat::Solvable s = mapSolvable( source );
1135  sat::Solvable s2 = mapSolvable( target );
1136 
1137  // @FIXME, these strings are a duplicate copied from the libsolv library
1138  // to provide translations. Instead of having duplicate code we should
1139  // translate those strings directly in libsolv
1140  switch ( type )
1141  {
1142  case SOLVER_RULE_DISTUPGRADE:
1143  if ( s.isSystem() )
1144  ret = str::Format(_("the installed %1% does not belong to a distupgrade repository and must be replaced") ) % s.asString();
1145  else /*just in case*/
1146  ret = str::Format(_("the to be installed %1% does not belong to a distupgrade repository") ) % s.asString();
1147  break;
1148  case SOLVER_RULE_INFARCH:
1149  if ( s.isSystem() )
1150  ret = str::Format(_("the installed %1% has inferior architecture") ) % s.asString();
1151  else
1152  ret = str::Format(_("the to be installed %1% has inferior architecture") ) % s.asString();
1153  break;
1154  case SOLVER_RULE_UPDATE:
1155  ret = str::Format(_("problem with the installed %1%") ) % s.asString();
1156  break;
1157  case SOLVER_RULE_JOB:
1158  ret = _("conflicting requests");
1159  break;
1160  case SOLVER_RULE_PKG:
1161  ret = _("some dependency problem");
1162  break;
1163  case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1164  ret = str::Format(_("nothing provides the requested '%1%'") ) % pool_dep2str(pool, dep);
1165  detail += _("Have you enabled all the required repositories?");
1166  break;
1167  case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1168  ret = str::Format(_("the requested package %1% does not exist") ) % pool_dep2str(pool, dep);
1169  detail += _("Have you enabled all the required repositories?");
1170  break;
1171  case SOLVER_RULE_JOB_UNSUPPORTED:
1172  ret = _("unsupported request");
1173  break;
1174  case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1175  ret = str::Format(_("'%1%' is provided by the system and cannot be erased") ) % pool_dep2str(pool, dep);
1176  break;
1177  case SOLVER_RULE_PKG_NOT_INSTALLABLE:
1178  ret = str::Format(_("%1% is not installable") ) % s.asString();
1179  break;
1180  case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
1181  ignoreId = source; // for setting weak dependencies
1182  if ( s.isSystem() )
1183  ret = str::Format(_("nothing provides '%1%' needed by the installed %2%") ) % pool_dep2str(pool, dep) % s.asString();
1184  else
1185  ret = str::Format(_("nothing provides '%1%' needed by the to be installed %2%") ) % pool_dep2str(pool, dep) % s.asString();
1186  break;
1187  case SOLVER_RULE_PKG_SAME_NAME:
1188  ret = str::Format(_("cannot install both %1% and %2%") ) % s.asString() % s2.asString();
1189  break;
1190  case SOLVER_RULE_PKG_CONFLICTS:
1191  if ( s.isSystem() ) {
1192  if ( s2.isSystem() )
1193  ret = str::Format(_("the installed %1% conflicts with '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1194  else
1195  ret = str::Format(_("the installed %1% conflicts with '%2%' provided by the to be installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1196  }
1197  else {
1198  if ( s2.isSystem() )
1199  ret = str::Format(_("the to be installed %1% conflicts with '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1200  else
1201  ret = str::Format(_("the to be installed %1% conflicts with '%2%' provided by the to be installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1202  }
1203  break;
1204  case SOLVER_RULE_PKG_OBSOLETES:
1205  case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
1206  if ( s.isSystem() ) {
1207  if ( s2.isSystem() )
1208  ret = str::Format(_("the installed %1% obsoletes '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1209  else
1210  ret = str::Format(_("the installed %1% obsoletes '%2%' provided by the to be installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1211  }
1212  else {
1213  if ( s2.isSystem() )
1214  ret = str::Format(_("the to be installed %1% obsoletes '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1215  else
1216  ret = str::Format(_("the to be installed %1% obsoletes '%2%' provided by the to be installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1217  }
1218  break;
1219  case SOLVER_RULE_PKG_SELF_CONFLICT:
1220  if ( s.isSystem() )
1221  ret = str::Format(_("the installed %1% conflicts with '%2%' provided by itself") ) % s.asString() % pool_dep2str(pool, dep);
1222  else
1223  ret = str::Format(_("the to be installed %1% conflicts with '%2%' provided by itself") ) % s.asString() % pool_dep2str(pool, dep);
1224  break;
1225  case SOLVER_RULE_PKG_REQUIRES: {
1226  ignoreId = source; // for setting weak dependencies
1227  Capability cap(dep);
1228  sat::WhatProvides possibleProviders(cap);
1229 
1230  // check, if a provider will be deleted
1231  typedef std::list<PoolItem> ProviderList;
1232  ProviderList providerlistInstalled, providerlistUninstalled;
1233  for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1234  PoolItem provider1 = ResPool::instance().find( *iter1 );
1235  // find pair of an installed/uninstalled item with the same NVR
1236  bool found = false;
1237  for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1238  PoolItem provider2 = ResPool::instance().find( *iter2 );
1239  if (compareByNVR (provider1,provider2) == 0
1240  && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1241  || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1242  found = true;
1243  break;
1244  }
1245  }
1246  if (!found) {
1247  if (provider1.status().isInstalled())
1248  providerlistInstalled.push_back(provider1);
1249  else
1250  providerlistUninstalled.push_back(provider1);
1251  }
1252  }
1253 
1254  if ( s.isSystem() )
1255  ret = str::Format(_("the installed %1% requires '%2%', but this requirement cannot be provided") ) % s.asString() % pool_dep2str(pool, dep);
1256  else
1257  ret = str::Format(_("the to be installed %1% requires '%2%', but this requirement cannot be provided") ) % s.asString() % pool_dep2str(pool, dep);
1258  if (providerlistInstalled.size() > 0) {
1259  detail += _("deleted providers: ");
1260  for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1261  if (iter == providerlistInstalled.begin())
1262  detail += itemToString( *iter );
1263  else
1264  detail += "\n " + itemToString( mapItem(*iter) );
1265  }
1266  }
1267  if (providerlistUninstalled.size() > 0) {
1268  if (detail.size() > 0)
1269  detail += _("\nnot installable providers: ");
1270  else
1271  detail = _("not installable providers: ");
1272  for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1273  if (iter == providerlistUninstalled.begin())
1274  detail += itemToString( *iter );
1275  else
1276  detail += "\n " + itemToString( mapItem(*iter) );
1277  }
1278  }
1279  break;
1280  }
1281  default: {
1282  DBG << "Unknown rule type(" << type << ") going to query libsolv for rule information." << endl;
1283  ret = str::asString( ::solver_problemruleinfo2str( _satSolver, type, static_cast<Id>(s.id()), static_cast<Id>(s2.id()), dep ) );
1284  break;
1285  }
1286  }
1287  return ret;
1288 }
1289 
1291 namespace {
1293  struct PtfPatchHint
1294  {
1295  void notInstallPatch( sat::Solvable slv_r )
1296  { _patch.push_back( slv_r.ident() ); }
1297 
1298  void removePtf( sat::Solvable slv_r, bool showremoveProtectHint_r = false )
1299  { _ptf.push_back( slv_r.ident() ); if ( showremoveProtectHint_r ) _showremoveProtectHint = true; }
1300 
1301  bool applies() const
1302  { return not _ptf.empty(); }
1303 
1304  std::string description() const {
1305  if ( not _patch.empty() ) {
1306  return str::Str()
1307  // translator: %1% is the name of a PTF, %2% the name of a patch.
1308  << (str::Format( _("%1% is not yet fully integrated into %2%.") ) % printlist(_ptf) % printlist(_patch)) << endl
1309  << _("Typically you want to keep the PTF and choose to not install the maintenance patches.");
1310  }
1311  //else: a common problem due to an installed ptf
1312 
1313  if ( _showremoveProtectHint ) { // bsc#1203248
1314  const std::string & removeptfCommand { str::Format("zypper removeptf %1%") % printlist(_ptf) };
1315  return str::Str()
1316  // translator: %1% is the name of a PTF.
1317  << (str::Format( _("Removing the installed %1% in this context will remove (not replace!) the included PTF-packages too." ) ) % printlist(_ptf)) << endl
1318  << (str::Format( _("The PTF should be removed by calling '%1%'. This will update the included PTF-packages rather than removing them." ) ) % removeptfCommand) << endl
1319  << _("Typically you want to keep the PTF or choose to cancel the action."); // ma: When translated, it should replace the '..and choose..' below too
1320  }
1321 
1322  return str::Str()
1323  // translator: %1% is the name of a PTF.
1324  << (str::Format( _("The installed %1% blocks the desired action.") ) % printlist(_ptf)) << endl
1325  << _("Typically you want to keep the PTF and choose to cancel the action.");
1326  }
1327  private:
1328  using StoreType = IdString;
1329  static std::string printlist( const std::vector<StoreType> & list_r )
1330  { str::Str ret; dumpRange( ret.stream(), list_r.begin(), list_r.end(), "", "", ", ", "", "" ); return ret; }
1331 
1332  std::vector<StoreType> _ptf;
1333  std::vector<StoreType> _patch;
1335  };
1336 }
1338 
1340 SATResolver::problems ()
1341 {
1342  ResolverProblemList resolverProblems;
1343  if (_satSolver && solver_problem_count(_satSolver)) {
1344  sat::detail::CPool *pool = _satSolver->pool;
1345  int pcnt;
1346  Id p, rp, what;
1347  Id problem, solution, element;
1348  sat::Solvable s, sd;
1349 
1350  CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1351  CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1352 
1353  MIL << "Encountered problems! Here are the solutions:\n" << endl;
1354  pcnt = 1;
1355  problem = 0;
1356  while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1357  MIL << "Problem " << pcnt++ << ":" << endl;
1358  MIL << "====================================" << endl;
1359  std::string detail;
1360  Id ignoreId;
1361  std::string whatString = SATprobleminfoString (problem,detail,ignoreId);
1362  MIL << whatString << endl;
1363  MIL << "------------------------------------" << endl;
1364  ResolverProblem_Ptr resolverProblem = new ResolverProblem (whatString, detail, SATgetCompleteProblemInfoStrings( problem ));
1365  PtfPatchHint ptfPatchHint; // bsc#1194848 hint on ptf<>patch conflicts
1366  solution = 0;
1367  while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1368  element = 0;
1369  ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi;
1370  while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1371  if (p == SOLVER_SOLUTION_JOB) {
1372  /* job, rp is index into job queue */
1373  what = _jobQueue.elements[rp];
1374  switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1375  {
1376  case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1377  s = mapSolvable (what);
1378  PoolItem poolItem = _pool.find (s);
1379  if (poolItem) {
1380  if (pool->installed && s.get()->repo == pool->installed) {
1381  problemSolution->addSingleAction (poolItem, REMOVE);
1382  std::string description = str::Format(_("remove lock to allow removal of %1%") ) % s.asString();
1383  MIL << description << endl;
1384  problemSolution->addDescription (description);
1385  if ( _protectPTFs && s.isPtfMaster() )
1386  ptfPatchHint.removePtf( s, _protectPTFs ); // bsc#1203248
1387  } else {
1388  problemSolution->addSingleAction (poolItem, KEEP);
1389  std::string description = str::Format(_("do not install %1%") ) % s.asString();
1390  MIL << description << endl;
1391  problemSolution->addDescription (description);
1392  if ( s.isKind<Patch>() )
1393  ptfPatchHint.notInstallPatch( s );
1394  }
1395  } else {
1396  ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1397  }
1398  }
1399  break;
1400  case SOLVER_ERASE | SOLVER_SOLVABLE: {
1401  s = mapSolvable (what);
1402  PoolItem poolItem = _pool.find (s);
1403  if (poolItem) {
1404  if (pool->installed && s.get()->repo == pool->installed) {
1405  problemSolution->addSingleAction (poolItem, KEEP);
1406  std::string description = str::Format(_("keep %1%") ) % s.asString();
1407  MIL << description << endl;
1408  problemSolution->addDescription (description);
1409  } else {
1410  problemSolution->addSingleAction (poolItem, UNLOCK);
1411  std::string description = str::Format(_("remove lock to allow installation of %1%") ) % itemToString( poolItem );
1412  MIL << description << endl;
1413  problemSolution->addDescription (description);
1414  }
1415  } else {
1416  ERR << "SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1417  }
1418  }
1419  break;
1420  case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1421  {
1422  IdString ident( what );
1423  SolverQueueItemInstall_Ptr install =
1424  new SolverQueueItemInstall(_pool, ident.asString(), false );
1425  problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1426 
1427  std::string description = str::Format(_("do not install %1%") ) % ident;
1428  MIL << description << endl;
1429  problemSolution->addDescription (description);
1430  }
1431  break;
1432  case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1433  {
1434  // As we do not know, if this request has come from resolvePool or
1435  // resolveQueue we will have to take care for both cases.
1436  IdString ident( what );
1437  FindPackage info (problemSolution, KEEP);
1438  invokeOnEach( _pool.byIdentBegin( ident ),
1439  _pool.byIdentEnd( ident ),
1440  functor::chain (resfilter::ByInstalled (), // ByInstalled
1441  resfilter::ByTransact ()), // will be deinstalled
1442  std::ref(info) );
1443 
1444  SolverQueueItemDelete_Ptr del =
1445  new SolverQueueItemDelete(_pool, ident.asString(), false );
1446  problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1447 
1448  std::string description = str::Format(_("keep %1%") ) % ident;
1449  MIL << description << endl;
1450  problemSolution->addDescription (description);
1451  }
1452  break;
1453  case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1454  {
1455  problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1456  std::string description = "";
1457 
1458  // Checking if this problem solution would break your system
1459  if (system_requires.find(Capability(what)) != system_requires.end()) {
1460  // Show a better warning
1461  resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1462  resolverProblem->setDescription(_("This request will break your system!"));
1463  description = _("ignore the warning of a broken system");
1464  description += std::string(" (requires:")+pool_dep2str(pool, what)+")";
1465  MIL << description << endl;
1466  problemSolution->addFrontDescription (description);
1467  } else {
1468  description = str::Format(_("do not ask to install a solvable providing %1%") ) % pool_dep2str(pool, what);
1469  MIL << description << endl;
1470  problemSolution->addDescription (description);
1471  }
1472  }
1473  break;
1474  case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1475  {
1476  problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1477  std::string description = "";
1478 
1479  // Checking if this problem solution would break your system
1480  if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1481  // Show a better warning
1482  resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1483  resolverProblem->setDescription(_("This request will break your system!"));
1484  description = _("ignore the warning of a broken system");
1485  description += std::string(" (conflicts:")+pool_dep2str(pool, what)+")";
1486  MIL << description << endl;
1487  problemSolution->addFrontDescription (description);
1488 
1489  } else {
1490  description = str::Format(_("do not ask to delete all solvables providing %1%") ) % pool_dep2str(pool, what);
1491  MIL << description << endl;
1492  problemSolution->addDescription (description);
1493  }
1494  }
1495  break;
1496  case SOLVER_UPDATE | SOLVER_SOLVABLE:
1497  {
1498  s = mapSolvable (what);
1499  PoolItem poolItem = _pool.find (s);
1500  if (poolItem) {
1501  if (pool->installed && s.get()->repo == pool->installed) {
1502  problemSolution->addSingleAction (poolItem, KEEP);
1503  std::string description = str::Format(_("do not install most recent version of %1%") ) % s.asString();
1504  MIL << description << endl;
1505  problemSolution->addDescription (description);
1506  } else {
1507  ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem << " is not selected for installation" << endl;
1508  }
1509  } else {
1510  ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1511  }
1512  }
1513  break;
1514  default:
1515  MIL << "- do something different" << endl;
1516  ERR << "No valid solution available" << endl;
1517  break;
1518  }
1519  } else if (p == SOLVER_SOLUTION_INFARCH) {
1520  s = mapSolvable (rp);
1521  PoolItem poolItem = _pool.find (s);
1522  if (pool->installed && s.get()->repo == pool->installed) {
1523  problemSolution->addSingleAction (poolItem, LOCK);
1524  std::string description = str::Format(_("keep %1% despite the inferior architecture") ) % s.asString();
1525  MIL << description << endl;
1526  problemSolution->addDescription (description);
1527  } else {
1528  problemSolution->addSingleAction (poolItem, INSTALL);
1529  std::string description = str::Format(_("install %1% despite the inferior architecture") ) % s.asString();
1530  MIL << description << endl;
1531  problemSolution->addDescription (description);
1532  }
1533  } else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1534  s = mapSolvable (rp);
1535  PoolItem poolItem = _pool.find (s);
1536  if (pool->installed && s.get()->repo == pool->installed) {
1537  problemSolution->addSingleAction (poolItem, LOCK);
1538  std::string description = str::Format(_("keep obsolete %1%") ) % s.asString();
1539  MIL << description << endl;
1540  problemSolution->addDescription (description);
1541  } else {
1542  problemSolution->addSingleAction (poolItem, INSTALL);
1543  std::string description = str::Format(_("install %1% from excluded repository") ) % s.asString();
1544  MIL << description << endl;
1545  problemSolution->addDescription (description);
1546  }
1547  } else if ( p == SOLVER_SOLUTION_BLACK ) {
1548  // Allow to install a blacklisted package (PTF, retracted,...).
1549  // For not-installed items only
1550  s = mapSolvable (rp);
1551  PoolItem poolItem = _pool.find (s);
1552 
1553  problemSolution->addSingleAction (poolItem, INSTALL);
1554  std::string description;
1555  if ( s.isRetracted() ) {
1556  // translator: %1% is a package name
1557  description = str::Format(_("install %1% although it has been retracted")) % s.asString();
1558  } else if ( s.isPtf() ) {
1559  // translator: %1% is a package name
1560  description = str::Format(_("allow installing the PTF %1%")) % s.asString();
1561  } else {
1562  // translator: %1% is a package name
1563  description = str::Format(_("install %1% although it is blacklisted")) % s.asString();
1564  }
1565  MIL << description << endl;
1566  problemSolution->addDescription( description );
1567  } else if ( p > 0 ) {
1568  /* policy, replace p with rp */
1569  s = mapSolvable (p);
1570  PoolItem itemFrom = _pool.find (s);
1571  if (rp)
1572  {
1573  int gotone = 0;
1574 
1575  sd = mapSolvable (rp);
1576  PoolItem itemTo = _pool.find (sd);
1577  if (itemFrom && itemTo) {
1578  problemSolution->addSingleAction (itemTo, INSTALL);
1579  int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1580 
1581  if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1582  {
1583  std::string description = str::Format(_("downgrade of %1% to %2%") ) % s.asString() % sd.asString();
1584  MIL << description << endl;
1585  problemSolution->addDescription (description);
1586  gotone = 1;
1587  }
1588  if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1589  {
1590  std::string description = str::Format(_("architecture change of %1% to %2%") ) % s.asString() % sd.asString();
1591  MIL << description << endl;
1592  problemSolution->addDescription (description);
1593  gotone = 1;
1594  }
1595  if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1596  {
1597  IdString s_vendor( s.vendor() );
1598  IdString sd_vendor( sd.vendor() );
1599  std::string description;
1600  if ( s == sd ) // FIXME? Actually .ident() must be eq. But the more verbose 'else' isn't bad either.
1601  description = str::Format(_("install %1% (with vendor change)\n %2% --> %3%") )
1602  % sd.asString()
1603  % ( s_vendor ? s_vendor.c_str() : " (no vendor) " )
1604  % ( sd_vendor ? sd_vendor.c_str() : " (no vendor) " );
1605  else
1606  description = str::Format(_("install %1% from vendor %2%\n replacing %3% from vendor %4%") )
1607  % sd.asString() % ( sd_vendor ? sd_vendor.c_str() : " (no vendor) " )
1608  % s.asString() % ( s_vendor ? s_vendor.c_str() : " (no vendor) " );
1609 
1610  MIL << description << endl;
1611  problemSolution->addDescription (description);
1612  gotone = 1;
1613  }
1614  if (!gotone) {
1615  std::string description = str::Format(_("replacement of %1% with %2%") ) % s.asString() % sd.asString();
1616  MIL << description << endl;
1617  problemSolution->addDescription (description);
1618  }
1619  } else {
1620  ERR << s.asString() << " or " << sd.asString() << " not found" << endl;
1621  }
1622  }
1623  else
1624  {
1625  if (itemFrom) {
1626  std::string description = str::Format(_("deinstallation of %1%") ) % s.asString();
1627  MIL << description << endl;
1628  problemSolution->addDescription (description);
1629  problemSolution->addSingleAction (itemFrom, REMOVE);
1630  if ( s.isPtfMaster() )
1631  ptfPatchHint.removePtf( s );
1632  }
1633  }
1634  }
1635  else
1636  {
1637  INT << "Unknown solution " << p << endl;
1638  }
1639 
1640  }
1641  resolverProblem->addSolution (problemSolution,
1642  problemSolution->actionCount() > 1 ? true : false); // Solutions with more than 1 action will be shown first.
1643  MIL << "------------------------------------" << endl;
1644  }
1645 
1646  if (ignoreId > 0) {
1647  // There is a possibility to ignore this error by setting weak dependencies
1648  PoolItem item = _pool.find (sat::Solvable(ignoreId));
1649  ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(item);
1650  resolverProblem->addSolution (problemSolution,
1651  false); // Solutions will be shown at the end
1652  MIL << "ignore some dependencies of " << item << endl;
1653  MIL << "------------------------------------" << endl;
1654  }
1655 
1656  // bsc#1194848 hint on ptf<>patch conflicts
1657  if ( ptfPatchHint.applies() ) {
1658  resolverProblem->setDescription( str::Str() << ptfPatchHint.description() << endl << "(" << resolverProblem->description() << ")" );
1659  }
1660  // save problem
1661  resolverProblems.push_back (resolverProblem);
1662  }
1663  }
1664  return resolverProblems;
1665 }
1666 
1667 void SATResolver::applySolutions( const ProblemSolutionList & solutions )
1668 { Resolver( _pool ).applySolutions( solutions ); }
1669 
1670 sat::StringQueue SATResolver::autoInstalled() const
1671 {
1672  sat::StringQueue ret;
1673  if ( _satSolver )
1674  ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
1675  return ret;
1676 }
1677 
1678 sat::StringQueue SATResolver::userInstalled() const
1679 {
1680  sat::StringQueue ret;
1681  if ( _satSolver )
1682  ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES );
1683  return ret;
1684 }
1685 
1686 
1688 };// namespace detail
1691  };// namespace solver
1694 };// namespace zypp
bool empty() const
Definition: Queue.cc:46
std::list< ProblemSolution_Ptr > ProblemSolutionList
Definition: ProblemTypes.h:43
#define MIL
Definition: Logger.h:96
int IdType
Generic Id type.
Definition: PoolMember.h:104
static const IdString ptfMasterToken
Indicator provides ptf()
Definition: Solvable.h:59
A Solvable object within the sat Pool.
Definition: Solvable.h:53
Container of Solvable providing a Capability (read only).
Definition: WhatProvides.h:87
Focus on updating requested packages and their dependencies as much as possible.
#define _(MSG)
Definition: Gettext.h:37
static ZConfig & instance()
Singleton ctor.
Definition: ZConfig.cc:922
bool isToBeInstalled() const
Definition: ResStatus.h:253
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings should be treated as the same vendor.
Definition: VendorAttr.cc:331
ProblemSolutionCombi * problemSolution
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
Definition: ResPool.cc:73
ResolverFocus
The resolver&#39;s general attitude.
Definition: ResolverFocus.h:21
bool _showremoveProtectHint
#define INT
Definition: Logger.h:100
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\ ", const std::string &sep="\ ", const std::string &sfx="\, const std::string &extro="}")
Print range defined by iterators (multiline style).
Definition: LogTools.h:107
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:211
static const ResStatus toBeInstalled
Definition: ResStatus.h:661
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolMember.h:125
sat::Solvable buddy() const
Return the buddy we share our status object with.
Definition: PoolItem.cc:214
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
Definition: String.h:139
#define OUTS(X)
Access to the sat-pools string space.
Definition: IdString.h:42
bool sameNVRA(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:232
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:484
std::list< SolverQueueItem_Ptr > SolverQueueItemList
Definition: Types.h:45
static void SATSolutionToPool(PoolItem item, const ResStatus &status, const ResStatus::TransactByValue causer)
Definition: SATResolver.cc:335
size_type reposSize() const
Number of repos in Pool.
Definition: Pool.cc:73
#define ERR
Definition: Logger.h:98
bool setToBeUninstalledDueToUpgrade(TransactByValue causer)
Definition: ResStatus.h:568
#define MAYBE_CLEANDEPS
Definition: SATResolver.cc:170
std::vector< StoreType > _patch
static const ResStatus toBeUninstalledDueToUpgrade
Definition: ResStatus.h:663
void prepare() const
Update housekeeping data if necessary (e.g.
Definition: Pool.cc:61
CheckIfUpdate(const sat::Solvable &installed_r)
Definition: SATResolver.cc:672
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:363
Queue StringQueue
Queue with String ids.
Definition: Queue.h:27
void push(value_type val_r)
Push a value to the end off the Queue.
Definition: Queue.cc:103
void establish(sat::Queue &pseudoItems_r, sat::Queue &pseudoFlags_r)
ResPool helper to compute the initial status of Patches etc.
Definition: SATResolver.cc:186
std::list< ResolverProblem_Ptr > ResolverProblemList
Definition: ProblemTypes.h:46
static Pool instance()
Singleton ctor.
Definition: Pool.h:55
Commit helper functor distributing PoolItem by status into lists.
Definition: SATResolver.cc:372
bool operator()(const PoolItem &item)
Definition: SATResolver.cc:679
int relaxedVendorCheck(sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2)
Definition: SATResolver.cc:179
unsigned size_type
Definition: Queue.h:37
int vendorCheck(sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2)
Definition: SATResolver.cc:176
Package interface.
Definition: Package.h:32
#define WAR
Definition: Logger.h:97
Focus on applying as little changes to the installed packages as needed.
bool multiversionInstall() const
Definition: SolvableType.h:82
bool relaxedEquivalent(const Vendor &lVendor, const Vendor &rVendor) const
Like equivalent but always unifies suse and openSUSE vendor.
Definition: VendorAttr.cc:344
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:580
SATCollectTransact(PoolItemList &items_to_install_r, PoolItemList &items_to_remove_r, PoolItemList &items_to_lock_r, PoolItemList &items_to_keep_r, bool solveSrcPackages_r)
Definition: SATResolver.cc:374
bool isPseudoInstalled(ResKind kind_r)
Those are denoted to be installed, if the solver verifies them as being satisfied.
Definition: ResTraits.h:28
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:61
bool operator()(const PoolItem &item_r)
Definition: SATResolver.cc:391
bool setToBeUninstalled(TransactByValue causer)
Definition: ResStatus.h:544
FindPackage(ProblemSolutionCombi *p, const TransactionKind act)
size_type size() const
Definition: Queue.cc:49
Libsolv Id queue wrapper.
Definition: Queue.h:34
bool compareByNVR(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:260
std::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
Definition: Selectable.cc:28
SrcPackage interface.
Definition: SrcPackage.h:29
sat::Solvable mapBuddy(sat::Solvable item_r)
std::string alias() const
Short unique string to identify a repo.
Definition: Repository.cc:59
::s_Solver CSolver
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:65
bool isToBeUninstalled() const
Definition: ResStatus.h:261
A sat capability.
Definition: Capability.h:62
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:93
Chain< TACondition, TBCondition > chain(TACondition conda_r, TBCondition condb_r)
Convenience function for creating a Chain from two conditions conda_r and condb_r.
Definition: Functional.h:185
bool setToBeInstalled(TransactByValue causer)
Definition: ResStatus.h:530
Status bitfield.
Definition: ResStatus.h:53
IMPL_PTR_TYPE(SATResolver)
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
Pathname systemRoot() const
The target root directory.
Definition: ZConfig.cc:950
static const IdString retractedToken
Indicator provides retracted-patch-package()
Definition: Solvable.h:58
bool isKind(const ResKind &kind_r) const
Definition: SolvableType.h:64
void resetWeak()
Definition: ResStatus.h:197
static const VendorAttr & instance()
(Pseudo)Singleton, mapped to the current Target::vendorAttr settings or to noTargetInstance.
Definition: VendorAttr.cc:230
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
std::string itemToString(const PoolItem &item)
Definition: SATResolver.cc:228
#define XDEBUG(x)
Definition: SATResolver.cc:57
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
Focus on installing the best version of the requested packages.
static const ResStatus toBeUninstalled
Definition: ResStatus.h:662
std::vector< StoreType > _ptf
bool isToBeUninstalledDueToUpgrade() const
Definition: ResStatus.h:318
#define DBG
Definition: Logger.h:95
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:37