libzypp  17.25.8
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>
44 
47 
55 
56 using std::endl;
57 
58 #define XDEBUG(x) do { if (base::logger::isExcessive()) XXX << x << std::endl;} while (0)
59 
60 #undef ZYPP_BASE_LOGGER_LOGGROUP
61 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::solver"
62 
64 namespace zypp
65 {
66  namespace solver
68  {
69  namespace detail
71  {
72 
74  namespace
75  {
76  inline void solverSetFocus( sat::detail::CSolver & satSolver_r, const ResolverFocus & focus_r )
77  {
78  switch ( focus_r )
79  {
80  case ResolverFocus::Default: // fallthrough to Job
81  case ResolverFocus::Job:
82  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
83  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
84  break;
86  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 1 );
87  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 0 );
88  break;
90  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_INSTALLED, 0 );
91  solver_set_flag( &satSolver_r, SOLVER_FLAG_FOCUS_BEST, 1 );
92  break;
93  }
94  }
95 
99  inline sat::Queue collectPseudoInstalled( const ResPool & pool_r )
100  {
101  sat::Queue ret;
102  for ( const PoolItem & pi : pool_r )
103  if ( traits::isPseudoInstalled( pi.kind() ) ) ret.push( pi.id() );
104  return ret;
105  }
106 
110  inline void solverCopyBackWeak( sat::detail::CSolver & satSolver_r, PoolItemList & orphanedItems_r )
111  {
112  // NOTE: assert all items weak stati are reset (resetWeak was called)
113  {
114  sat::Queue recommendations;
115  sat::Queue suggestions;
116  ::solver_get_recommendations( &satSolver_r, recommendations, suggestions, 0 );
117  for ( sat::Queue::size_type i = 0; i < recommendations.size(); ++i )
118  PoolItem(sat::Solvable(recommendations[i])).status().setRecommended( true );
119  for ( sat::Queue::size_type i = 0; i < suggestions.size(); ++i )
120  PoolItem(sat::Solvable(suggestions[i])).status().setSuggested( true );
121  }
122  {
123  orphanedItems_r.clear(); // cached on the fly
124  sat::Queue orphaned;
125  ::solver_get_orphaned( &satSolver_r, orphaned );
126  for ( sat::Queue::size_type i = 0; i < orphaned.size(); ++i )
127  {
128  PoolItem pi { sat::Solvable(orphaned[i]) };
129  pi.status().setOrphaned( true );
130  orphanedItems_r.push_back( pi );
131  }
132  }
133  {
134  sat::Queue unneeded;
135  ::solver_get_unneeded( &satSolver_r, unneeded, 1 );
136  for ( sat::Queue::size_type i = 0; i < unneeded.size(); ++i )
137  PoolItem(sat::Solvable(unneeded[i])).status().setUnneeded( true );
138  }
139  }
140 
142  inline void solverCopyBackValidate( sat::detail::CSolver & satSolver_r, const ResPool & pool_r )
143  {
144  sat::Queue pseudoItems { collectPseudoInstalled( pool_r ) };
145  if ( ! pseudoItems.empty() )
146  {
147  sat::Queue pseudoFlags;
148  ::solver_trivial_installable( &satSolver_r, pseudoItems, pseudoFlags );
149 
150  for ( sat::Queue::size_type i = 0; i < pseudoItems.size(); ++i )
151  {
152  PoolItem pi { sat::Solvable(pseudoItems[i]) };
153  switch ( pseudoFlags[i] )
154  {
155  case 0: pi.status().setBroken(); break;
156  case 1: pi.status().setSatisfied(); break;
157  case -1: pi.status().setNonRelevant(); break;
158  default: pi.status().setUndetermined(); break;
159  }
160  }
161  }
162  }
163 
164  } //namespace
166 
167 
168 
169 IMPL_PTR_TYPE(SATResolver);
170 
171 #define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0)
172 
173 //---------------------------------------------------------------------------
174 // Callbacks for SAT policies
175 //---------------------------------------------------------------------------
176 
177 int vendorCheck( sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2 )
178 { return VendorAttr::instance().equivalent( IdString(solvable1->vendor), IdString(solvable2->vendor) ) ? 0 : 1; }
179 
180 int relaxedVendorCheck( sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2 )
181 { return VendorAttr::instance().relaxedEquivalent( IdString(solvable1->vendor), IdString(solvable2->vendor) ) ? 0 : 1; }
182 
187 void establish( sat::Queue & pseudoItems_r, sat::Queue & pseudoFlags_r )
188 {
189  pseudoItems_r = collectPseudoInstalled( ResPool::instance() );
190  if ( ! pseudoItems_r.empty() )
191  {
192  MIL << "Establish..." << endl;
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 : sat::Pool::instance().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 };
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( IGNORE_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 // resolvePool
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 
432 //----------------------------------------------------------------------------
433 //----------------------------------------------------------------------------
434 // solving.....
435 //----------------------------------------------------------------------------
436 //----------------------------------------------------------------------------
437 
438 
440 {
441  public:
444 
445  CheckIfUpdate( const sat::Solvable & installed_r )
446  : is_updated( false )
447  , _installed( installed_r )
448  {}
449 
450  // check this item will be updated
451 
452  bool operator()( const PoolItem & item )
453  {
454  if ( item.status().isToBeInstalled() )
455  {
456  if ( ! item.multiversionInstall() || sameNVRA( _installed, item ) )
457  {
458  is_updated = true;
459  return false;
460  }
461  }
462  return true;
463  }
464 };
465 
466 
467 bool
468 SATResolver::solving(const CapabilitySet & requires_caps,
469  const CapabilitySet & conflict_caps)
470 {
471  if (_fixsystem) {
472  queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
473  queue_push( &(_jobQueue), 0 );
474  }
475  if (_updatesystem) {
476  queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
477  queue_push( &(_jobQueue), 0 );
478  }
479  if (_distupgrade) {
480  queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
481  queue_push( &(_jobQueue), 0 );
482  }
483  if (_distupgrade_removeunsupported) {
484  queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
485  queue_push( &(_jobQueue), 0 );
486  }
487  solverSetFocus( *_satSolver, _focus );
488  solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
489  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
490  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
491  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
492  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
493  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
494  solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
495  solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
496  solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, false); // resolve recommended namespaces
497  solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires); //
498  solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, _dup_allowdowngrade );
499  solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_NAMECHANGE, _dup_allownamechange );
500  solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE, _dup_allowarchchange );
501  solver_set_flag(_satSolver, SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE, _dup_allowvendorchange );
502 
504 
505  // Solve !
506  MIL << "Starting solving...." << endl;
507  MIL << *this;
508  if ( solver_solve( _satSolver, &(_jobQueue) ) == 0 )
509  {
510  // bsc#1155819: Weakremovers of future product not evaluated.
511  // Do a 2nd run to cleanup weakremovers() of to be installed
512  // Produtcs unless removeunsupported is active (cleans up all).
513  if ( _distupgrade )
514  {
515  if ( _distupgrade_removeunsupported )
516  MIL << "Droplist processing not needed. RemoveUnsupported is On." << endl;
517  else if ( ! ZConfig::instance().solverUpgradeRemoveDroppedPackages() )
518  MIL << "Droplist processing is disabled in ZConfig." << endl;
519  else
520  {
521  bool resolve = false;
522  MIL << "Checking droplists ..." << endl;
523  // get Solvables to be installed...
524  sat::SolvableQueue decisionq;
525  solver_get_decisionqueue( _satSolver, decisionq );
526  for ( sat::detail::IdType id : decisionq )
527  {
528  if ( id < 0 )
529  continue;
530  sat::Solvable slv { (sat::detail::SolvableIdType)id };
531  // get product buddies (they carry the weakremover)...
532  static const Capability productCap { "product()" };
533  if ( slv && slv.provides().matches( productCap ) )
534  {
535  CapabilitySet droplist { slv.valuesOfNamespace( "weakremover" ) };
536  MIL << "Droplist for " << slv << ": size " << droplist.size() << endl;
537  if ( !droplist.empty() )
538  {
539  for ( const auto & cap : droplist )
540  {
541  queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
542  queue_push( &_jobQueue, cap.id() );
543  }
544  // PIN product - a safety net to prevent cleanup from changing the decision for this product
545  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
546  queue_push( &(_jobQueue), id );
547  resolve = true;
548  }
549  }
550  }
551  if ( resolve )
552  solver_solve( _satSolver, &(_jobQueue) );
553  }
554  }
555  }
556  MIL << "....Solver end" << endl;
557 
558  // copying solution back to zypp pool
559  //-----------------------------------------
560  _result_items_to_install.clear();
561  _result_items_to_remove.clear();
562 
563  /* solvables to be installed */
564  Queue decisionq;
565  queue_init(&decisionq);
566  solver_get_decisionqueue(_satSolver, &decisionq);
567  for ( int i = 0; i < decisionq.count; ++i )
568  {
569  Id p = decisionq.elements[i];
570  if ( p < 0 )
571  continue;
572 
573  sat::Solvable slv { (sat::detail::SolvableIdType)p };
574  if ( ! slv || slv.isSystem() )
575  continue;
576 
577  PoolItem poolItem( slv );
579  _result_items_to_install.push_back( poolItem );
580  }
581  queue_free(&decisionq);
582 
583  /* solvables to be erased */
584  Repository systemRepo( sat::Pool::instance().findSystemRepo() ); // don't create if it does not exist
585  if ( systemRepo && ! systemRepo.solvablesEmpty() )
586  {
587  bool mustCheckObsoletes = false;
588  for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
589  {
590  if (solver_get_decisionlevel(_satSolver, it->id()) > 0)
591  continue;
592 
593  // Check if this is an update
594  CheckIfUpdate info( *it );
595  PoolItem poolItem( *it );
596  invokeOnEach( _pool.byIdentBegin( poolItem ),
597  _pool.byIdentEnd( poolItem ),
598  resfilter::ByUninstalled(), // ByUninstalled
599  functor::functorRef<bool,PoolItem> (info) );
600 
601  if (info.is_updated) {
603  } else {
605  if ( ! mustCheckObsoletes )
606  mustCheckObsoletes = true; // lazy check for UninstalledDueToObsolete
607  }
608  _result_items_to_remove.push_back (poolItem);
609  }
610  if ( mustCheckObsoletes )
611  {
612  sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
613  for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
614  {
615  ResStatus & status( it->status() );
616  // WhatObsoletes contains installed items only!
617  if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
618  status.setToBeUninstalledDueToObsolete();
619  }
620  }
621  }
622 
623  // copy back computed status values to pool
624  // (on the fly cache orphaned items for the UI)
625  solverCopyBackWeak( *_satSolver, _problem_items );
626  solverCopyBackValidate( *_satSolver, _pool );
627 
628  // Solvables which were selected due requirements which have been made by the user will
629  // be selected by APPL_LOW. We can't use any higher level, because this setting must
630  // not serve as a request for the next solver run. APPL_LOW is reset before solving.
631  for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
632  sat::WhatProvides rpmProviders(*iter);
633  for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
634  PoolItem poolItem(*iter2);
635  if (poolItem.status().isToBeInstalled()) {
636  MIL << "User requirement " << *iter << " sets " << poolItem << endl;
637  poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
638  }
639  }
640  }
641  for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
642  sat::WhatProvides rpmProviders(*iter);
643  for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
644  PoolItem poolItem(*iter2);
645  if (poolItem.status().isToBeUninstalled()) {
646  MIL << "User conflict " << *iter << " sets " << poolItem << endl;
647  poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
648  }
649  }
650  }
651 
652  if (solver_problem_count(_satSolver) > 0 )
653  {
654  ERR << "Solverrun finished with an ERROR" << endl;
655  return false;
656  }
657 
658  return true;
659 }
660 
661 
662 void
663 SATResolver::solverInit(const PoolItemList & weakItems)
664 {
665 
666  MIL << "SATResolver::solverInit()" << endl;
667 
668  // remove old stuff
669  solverEnd();
670  _satSolver = solver_create( _satPool );
671  {
672  // bsc#1182629: in dup allow an available -release package providing 'dup-vendor-relax(suse)'
673  // to let (suse/opensuse) vendor being treated as being equivalent.
674  bool toRelax = false;
675  if ( _distupgrade ) {
676  for ( sat::Solvable solv : sat::WhatProvides( Capability("dup-vendor-relax(suse)") ) ) {
677  if ( ! solv.isSystem() ) {
678  MIL << "Relaxed vendor check requested by " << solv << endl;
679  toRelax = true;
680  break;
681  }
682  }
683  }
684  ::pool_set_custom_vendorcheck( _satPool, toRelax ? &relaxedVendorCheck : &vendorCheck );
685  }
686 
687  queue_init( &_jobQueue );
688 
689  // clear and rebuild: _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep
690  {
691  SATCollectTransact collector( _items_to_install, _items_to_remove, _items_to_lock, _items_to_keep, solveSrcPackages() );
692  invokeOnEach ( _pool.begin(), _pool.end(), functor::functorRef<bool,PoolItem>( collector ) );
693  }
694 
695  for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
696  Id id = (*iter)->satSolvable().id();
697  if (id == ID_NULL) {
698  ERR << "Weaken: " << *iter << " not found" << endl;
699  }
700  MIL << "Weaken dependencies of " << *iter << endl;
701  queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
702  queue_push( &(_jobQueue), id );
703  }
704 
705  // Ad rules for retracted patches and packages
706  {
707  queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
708  queue_push( &(_jobQueue), sat::Solvable::retractedToken.id() );
709  queue_push( &(_jobQueue), SOLVER_BLACKLIST|SOLVER_SOLVABLE_PROVIDES );
710  queue_push( &(_jobQueue), sat::Solvable::ptfToken.id() );
711  }
712 
713  // Ad rules for changed requestedLocales
714  {
715  const auto & trackedLocaleIds( myPool().trackedLocaleIds() );
716 
717  // just track changed locakes
718  for ( const auto & locale : trackedLocaleIds.added() )
719  {
720  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
721  queue_push( &(_jobQueue), Capability( ResolverNamespace::language, IdString(locale) ).id() );
722  }
723 
724  for ( const auto & locale : trackedLocaleIds.removed() )
725  {
726  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | SOLVER_CLEANDEPS ); // needs uncond. SOLVER_CLEANDEPS!
727  queue_push( &(_jobQueue), Capability( ResolverNamespace::language, IdString(locale) ).id() );
728  }
729  }
730 
731  // Add rules for parallel installable resolvables with different versions
732  for ( const sat::Solvable & solv : myPool().multiversionList() )
733  {
734  queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
735  queue_push( &(_jobQueue), solv.id() );
736  }
737 
738  ::pool_add_userinstalled_jobs(_satPool, sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
739 }
740 
741 void
742 SATResolver::solverEnd()
743 {
744  // cleanup
745  if ( _satSolver )
746  {
747  solver_free(_satSolver);
748  _satSolver = NULL;
749  queue_free( &(_jobQueue) );
750  }
751 }
752 
753 
754 bool
755 SATResolver::resolvePool(const CapabilitySet & requires_caps,
756  const CapabilitySet & conflict_caps,
757  const PoolItemList & weakItems,
758  const std::set<Repository> & upgradeRepos)
759 {
760  MIL << "SATResolver::resolvePool()" << endl;
761 
762  // initialize
763  solverInit(weakItems);
764 
765  for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
766  Id id = (*iter)->satSolvable().id();
767  if (id == ID_NULL) {
768  ERR << "Install: " << *iter << " not found" << endl;
769  } else {
770  MIL << "Install " << *iter << endl;
771  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
772  queue_push( &(_jobQueue), id );
773  }
774  }
775 
776  for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
777  Id id = (*iter)->satSolvable().id();
778  if (id == ID_NULL) {
779  ERR << "Delete: " << *iter << " not found" << endl;
780  } else {
781  MIL << "Delete " << *iter << endl;
782  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
783  queue_push( &(_jobQueue), id);
784  }
785  }
786 
787  for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
788  {
789  queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
790  queue_push( &(_jobQueue), iter->get()->repoid );
791  MIL << "Upgrade repo " << *iter << endl;
792  }
793 
794  for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
795  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
796  queue_push( &(_jobQueue), iter->id() );
797  MIL << "Requires " << *iter << endl;
798  }
799 
800  for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
801  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
802  queue_push( &(_jobQueue), iter->id() );
803  MIL << "Conflicts " << *iter << endl;
804  }
805 
806  // set requirements for a running system
807  setSystemRequirements();
808 
809  // set locks for the solver
810  setLocks();
811 
812  // solving
813  bool ret = solving(requires_caps, conflict_caps);
814 
815  (ret?MIL:WAR) << "SATResolver::resolvePool() done. Ret:" << ret << endl;
816  return ret;
817 }
818 
819 
820 bool
821 SATResolver::resolveQueue(const SolverQueueItemList &requestQueue,
822  const PoolItemList & weakItems)
823 {
824  MIL << "SATResolver::resolvQueue()" << endl;
825 
826  // initialize
827  solverInit(weakItems);
828 
829  // generate solver queue
830  for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
831  (*iter)->addRule(_jobQueue);
832  }
833 
834  // Add addition item status to the resolve-queue cause these can be set by problem resolutions
835  for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
836  Id id = (*iter)->satSolvable().id();
837  if (id == ID_NULL) {
838  ERR << "Install: " << *iter << " not found" << endl;
839  } else {
840  MIL << "Install " << *iter << endl;
841  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
842  queue_push( &(_jobQueue), id );
843  }
844  }
845  for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
846  sat::detail::IdType ident( (*iter)->satSolvable().ident().id() );
847  MIL << "Delete " << *iter << ident << endl;
848  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | MAYBE_CLEANDEPS );
849  queue_push( &(_jobQueue), ident);
850  }
851 
852  // set requirements for a running system
853  setSystemRequirements();
854 
855  // set locks for the solver
856  setLocks();
857 
858  // solving
859  bool ret = solving();
860 
861  MIL << "SATResolver::resolveQueue() done. Ret:" << ret << endl;
862  return ret;
863 }
864 
866 void SATResolver::doUpdate()
867 {
868  MIL << "SATResolver::doUpdate()" << endl;
869 
870  // initialize
871  solverInit(PoolItemList());
872 
873  // set requirements for a running system
874  setSystemRequirements();
875 
876  // set locks for the solver
877  setLocks();
878 
879  if (_fixsystem) {
880  queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
881  queue_push( &(_jobQueue), 0 );
882  }
883  if (1) {
884  queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
885  queue_push( &(_jobQueue), 0 );
886  }
887  if (_distupgrade) {
888  queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
889  queue_push( &(_jobQueue), 0 );
890  }
891  if (_distupgrade_removeunsupported) {
892  queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
893  queue_push( &(_jobQueue), 0 );
894  }
895  solverSetFocus( *_satSolver, _focus );
896  solver_set_flag(_satSolver, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
897  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
898  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_NAMECHANGE, _allownamechange);
899  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
900  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
901  solver_set_flag(_satSolver, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
902  solver_set_flag(_satSolver, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
903  solver_set_flag(_satSolver, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
904  solver_set_flag(_satSolver, SOLVER_FLAG_IGNORE_RECOMMENDED, false); // resolve recommended namespaces
905  solver_set_flag(_satSolver, SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, _onlyRequires); //
906 
908 
909  // Solve !
910  MIL << "Starting solving for update...." << endl;
911  MIL << *this;
912  solver_solve( _satSolver, &(_jobQueue) );
913  MIL << "....Solver end" << endl;
914 
915  // copying solution back to zypp pool
916  //-----------------------------------------
917 
918  /* solvables to be installed */
919  Queue decisionq;
920  queue_init(&decisionq);
921  solver_get_decisionqueue(_satSolver, &decisionq);
922  for (int i = 0; i < decisionq.count; i++)
923  {
924  Id p = decisionq.elements[i];
925  if ( p < 0 )
926  continue;
927 
928  sat::Solvable solv { (sat::detail::SolvableIdType)p };
929  if ( ! solv || solv.isSystem() )
930  continue;
931 
933  }
934  queue_free(&decisionq);
935 
936  /* solvables to be erased */
937  for (int i = _satSolver->pool->installed->start; i < _satSolver->pool->installed->start + _satSolver->pool->installed->nsolvables; i++)
938  {
939  if (solver_get_decisionlevel(_satSolver, i) > 0)
940  continue;
941 
942  PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
943  if (poolItem) {
944  // Check if this is an update
945  CheckIfUpdate info( (sat::Solvable(i)) );
946  invokeOnEach( _pool.byIdentBegin( poolItem ),
947  _pool.byIdentEnd( poolItem ),
948  resfilter::ByUninstalled(), // ByUninstalled
949  functor::functorRef<bool,PoolItem> (info) );
950 
951  if (info.is_updated) {
953  } else {
955  }
956  } else {
957  ERR << "id " << i << " not found in ZYPP pool." << endl;
958  }
959  }
960 
961  // copy back computed status values to pool
962  // (on the fly cache orphaned items for the UI)
963  solverCopyBackWeak( *_satSolver, _problem_items );
964  solverCopyBackValidate( *_satSolver, _pool );
965 
966  MIL << "SATResolver::doUpdate() done" << endl;
967 }
968 
969 
970 
971 //----------------------------------------------------------------------------
972 //----------------------------------------------------------------------------
973 // error handling
974 //----------------------------------------------------------------------------
975 //----------------------------------------------------------------------------
976 
977 //----------------------------------------------------------------------------
978 // helper function
979 //----------------------------------------------------------------------------
980 
982 {
983  ProblemSolutionCombi *problemSolution;
984  TransactionKind action;
985  FindPackage (ProblemSolutionCombi *p, const TransactionKind act)
986  : problemSolution (p)
987  , action (act)
988  {
989  }
990 
992  {
993  problemSolution->addSingleAction (p, action);
994  return true;
995  }
996 };
997 
998 
999 //----------------------------------------------------------------------------
1000 // Checking if this solvable/item has a buddy which reflect the real
1001 // user visible description of an item
1002 // e.g. The release package has a buddy to the concerning product item.
1003 // This user want's the message "Product foo conflicts with product bar" and
1004 // NOT "package release-foo conflicts with package release-bar"
1005 // (ma: that's why we should map just packages to buddies, not vice versa)
1006 //----------------------------------------------------------------------------
1007 inline sat::Solvable mapBuddy( const PoolItem & item_r )
1008 {
1009  if ( item_r.satSolvable().isKind<Package>() )
1010  {
1011  sat::Solvable buddy = item_r.buddy();
1012  if ( buddy )
1013  return buddy;
1014  }
1015  return item_r.satSolvable();
1016 }
1018 { return mapBuddy( PoolItem( item_r ) ); }
1019 
1020 PoolItem SATResolver::mapItem ( const PoolItem & item )
1021 { return PoolItem( mapBuddy( item ) ); }
1022 
1023 sat::Solvable SATResolver::mapSolvable ( const Id & id )
1024 { return mapBuddy( sat::Solvable(id) ); }
1025 
1026 std::vector<std::string> SATResolver::SATgetCompleteProblemInfoStrings ( Id problem )
1027 {
1028  std::vector<std::string> ret;
1029  sat::Queue problems;
1030  solver_findallproblemrules( _satSolver, problem, problems );
1031 
1032  bool nobad = false;
1033 
1034  //filter out generic rule information if more explicit ones are available
1035  for ( sat::Queue::size_type i = 0; i < problems.size(); i++ ) {
1036  SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1037  if ( ruleClass != SolverRuleinfo::SOLVER_RULE_UPDATE && ruleClass != SolverRuleinfo::SOLVER_RULE_JOB ) {
1038  nobad = true;
1039  break;
1040  }
1041  }
1042  for ( sat::Queue::size_type i = 0; i < problems.size(); i++ ) {
1043  SolverRuleinfo ruleClass = solver_ruleclass( _satSolver, problems[i]);
1044  if ( nobad && ( ruleClass == SolverRuleinfo::SOLVER_RULE_UPDATE || ruleClass == SolverRuleinfo::SOLVER_RULE_JOB ) ) {
1045  continue;
1046  }
1047 
1048  std::string detail;
1049  Id ignore = 0;
1050  std::string pInfo = SATproblemRuleInfoString( problems[i], detail, ignore );
1051 
1052  //we get the same string multiple times, reduce the noise
1053  if ( std::find( ret.begin(), ret.end(), pInfo ) == ret.end() )
1054  ret.push_back( pInfo );
1055  }
1056  return ret;
1057 }
1058 
1059 std::string SATResolver::SATprobleminfoString(Id problem, std::string &detail, Id &ignoreId)
1060 {
1061  // FIXME: solver_findallproblemrules to get all rules for this problem
1062  // (the 'most relevabt' one returned by solver_findproblemrule is embedded
1063  Id probr = solver_findproblemrule(_satSolver, problem);
1064  return SATproblemRuleInfoString( probr, detail, ignoreId );
1065 }
1066 
1067 #ifdef ZYPPNEWSPPSWENPPYZ
1068 #warning New texts in SP preview - still to be translated...
1069 std::string SATResolver::SATproblemRuleInfoString (Id probr, std::string &detail, Id &ignoreId)
1070 {
1071  std::string ret;
1072  sat::detail::CPool *pool = _satSolver->pool;
1073  Id dep, source, target;
1074  SolverRuleinfo type = solver_ruleinfo(_satSolver, probr, &source, &target, &dep);
1075 
1076  ignoreId = 0;
1077 
1078  sat::Solvable s = mapSolvable( source );
1079  sat::Solvable s2 = mapSolvable( target );
1080 
1081  // @FIXME, these strings are a duplicate copied from the libsolv library
1082  // to provide translations. Instead of having duplicate code we should
1083  // translate those strings directly in libsolv
1084  switch ( type )
1085  {
1086  case SOLVER_RULE_DISTUPGRADE:
1087  if ( s.isSystem() )
1088  ret = str::Format(_("the installed %1% does not belong to a distupgrade repository and must be replaced") ) % s.asString();
1089  else /*just in case*/
1090  ret = str::Format(_("the to be installed %1% does not belong to a distupgrade repository") ) % s.asString();
1091  break;
1092  case SOLVER_RULE_INFARCH:
1093  if ( s.isSystem() )
1094  ret = str::Format(_("the installed %1% has inferior architecture") ) % s.asString();
1095  else
1096  ret = str::Format(_("the to be installed %1% has inferior architecture") ) % s.asString();
1097  break;
1098  case SOLVER_RULE_UPDATE:
1099  ret = str::Format(_("problem with the installed %1%") ) % s.asString();
1100  break;
1101  case SOLVER_RULE_JOB:
1102  ret = _("conflicting requests");
1103  break;
1104  case SOLVER_RULE_PKG:
1105  ret = _("some dependency problem");
1106  break;
1107  case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1108  ret = str::Format(_("nothing provides the requested '%1%'") ) % pool_dep2str(pool, dep);
1109  detail += _("Have you enabled all the required repositories?");
1110  break;
1111  case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1112  ret = str::Format(_("the requested package %1% does not exist") ) % pool_dep2str(pool, dep);
1113  detail += _("Have you enabled all the required repositories?");
1114  break;
1115  case SOLVER_RULE_JOB_UNSUPPORTED:
1116  ret = _("unsupported request");
1117  break;
1118  case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1119  ret = str::Format(_("'%1%' is provided by the system and cannot be erased") ) % pool_dep2str(pool, dep);
1120  break;
1121  case SOLVER_RULE_PKG_NOT_INSTALLABLE:
1122  ret = str::Format(_("%1% is not installable") ) % s.asString();
1123  break;
1124  case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
1125  ignoreId = source; // for setting weak dependencies
1126  if ( s.isSystem() )
1127  ret = str::Format(_("nothing provides '%1%' needed by the installed %2%") ) % pool_dep2str(pool, dep) % s.asString();
1128  else
1129  ret = str::Format(_("nothing provides '%1%' needed by the to be installed %2%") ) % pool_dep2str(pool, dep) % s.asString();
1130  break;
1131  case SOLVER_RULE_PKG_SAME_NAME:
1132  ret = str::Format(_("cannot install both %1% and %2%") ) % s.asString() % s2.asString();
1133  break;
1134  case SOLVER_RULE_PKG_CONFLICTS:
1135  if ( s.isSystem() ) {
1136  if ( s2.isSystem() )
1137  ret = str::Format(_("the installed %1% conflicts with '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1138  else
1139  ret = str::Format(_("the installed %1% conflicts with '%2%' provided by the to be installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1140  }
1141  else {
1142  if ( s2.isSystem() )
1143  ret = str::Format(_("the to be installed %1% conflicts with '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1144  else
1145  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();
1146  }
1147  break;
1148  case SOLVER_RULE_PKG_OBSOLETES:
1149  case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
1150  if ( s.isSystem() ) {
1151  if ( s2.isSystem() )
1152  ret = str::Format(_("the installed %1% obsoletes '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1153  else
1154  ret = str::Format(_("the installed %1% obsoletes '%2%' provided by the to be installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1155  }
1156  else {
1157  if ( s2.isSystem() )
1158  ret = str::Format(_("the to be installed %1% obsoletes '%2%' provided by the installed %3%") ) % s.asString() % pool_dep2str(pool, dep) % s2.asString();
1159  else
1160  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();
1161  }
1162  break;
1163  case SOLVER_RULE_PKG_SELF_CONFLICT:
1164  if ( s.isSystem() )
1165  ret = str::Format(_("the installed %1% conflicts with '%2%' provided by itself") ) % s.asString() % pool_dep2str(pool, dep);
1166  else
1167  ret = str::Format(_("the to be installed %1% conflicts with '%2%' provided by itself") ) % s.asString() % pool_dep2str(pool, dep);
1168  break;
1169  case SOLVER_RULE_PKG_REQUIRES: {
1170  ignoreId = source; // for setting weak dependencies
1171  Capability cap(dep);
1172  sat::WhatProvides possibleProviders(cap);
1173 
1174  // check, if a provider will be deleted
1175  typedef std::list<PoolItem> ProviderList;
1176  ProviderList providerlistInstalled, providerlistUninstalled;
1177  for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1178  PoolItem provider1 = ResPool::instance().find( *iter1 );
1179  // find pair of an installed/uninstalled item with the same NVR
1180  bool found = false;
1181  for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1182  PoolItem provider2 = ResPool::instance().find( *iter2 );
1183  if (compareByNVR (provider1,provider2) == 0
1184  && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1185  || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1186  found = true;
1187  break;
1188  }
1189  }
1190  if (!found) {
1191  if (provider1.status().isInstalled())
1192  providerlistInstalled.push_back(provider1);
1193  else
1194  providerlistUninstalled.push_back(provider1);
1195  }
1196  }
1197 
1198  if ( s.isSystem() )
1199  ret = str::Format(_("the installed %1% requires '%2%', but this requirement cannot be provided") ) % s.asString() % pool_dep2str(pool, dep);
1200  else
1201  ret = str::Format(_("the to be installed %1% requires '%2%', but this requirement cannot be provided") ) % s.asString() % pool_dep2str(pool, dep);
1202  if (providerlistInstalled.size() > 0) {
1203  detail += _("deleted providers: ");
1204  for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1205  if (iter == providerlistInstalled.begin())
1206  detail += itemToString( *iter );
1207  else
1208  detail += "\n " + itemToString( mapItem(*iter) );
1209  }
1210  }
1211  if (providerlistUninstalled.size() > 0) {
1212  if (detail.size() > 0)
1213  detail += _("\nnot installable providers: ");
1214  else
1215  detail = _("not installable providers: ");
1216  for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1217  if (iter == providerlistUninstalled.begin())
1218  detail += itemToString( *iter );
1219  else
1220  detail += "\n " + itemToString( mapItem(*iter) );
1221  }
1222  }
1223  break;
1224  }
1225  default: {
1226  DBG << "Unknown rule type(" << type << ") going to query libsolv for rule information." << endl;
1227  ret = str::asString( ::solver_problemruleinfo2str( _satSolver, type, static_cast<Id>(s.id()), static_cast<Id>(s2.id()), dep ) );
1228  break;
1229  }
1230  }
1231  return ret;
1232 }
1233 
1235 SATResolver::problems ()
1236 {
1237  ResolverProblemList resolverProblems;
1238  if (_satSolver && solver_problem_count(_satSolver)) {
1239  sat::detail::CPool *pool = _satSolver->pool;
1240  int pcnt;
1241  Id p, rp, what;
1242  Id problem, solution, element;
1243  sat::Solvable s, sd;
1244 
1245  CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1246  CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1247 
1248  MIL << "Encountered problems! Here are the solutions:\n" << endl;
1249  pcnt = 1;
1250  problem = 0;
1251  while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1252  MIL << "Problem " << pcnt++ << ":" << endl;
1253  MIL << "====================================" << endl;
1254  std::string detail;
1255  Id ignoreId;
1256  std::string whatString = SATprobleminfoString (problem,detail,ignoreId);
1257  MIL << whatString << endl;
1258  MIL << "------------------------------------" << endl;
1259  ResolverProblem_Ptr resolverProblem = new ResolverProblem (whatString, detail, SATgetCompleteProblemInfoStrings( problem ));
1260 
1261  solution = 0;
1262  while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1263  element = 0;
1264  ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi;
1265  while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1266  if (p == SOLVER_SOLUTION_JOB) {
1267  /* job, rp is index into job queue */
1268  what = _jobQueue.elements[rp];
1269  switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1270  {
1271  case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1272  s = mapSolvable (what);
1273  PoolItem poolItem = _pool.find (s);
1274  if (poolItem) {
1275  if (pool->installed && s.get()->repo == pool->installed) {
1276  problemSolution->addSingleAction (poolItem, REMOVE);
1277  std::string description = str::Format(_("remove lock to allow removal of %1%") ) % s.asString();
1278  MIL << description << endl;
1279  problemSolution->addDescription (description);
1280  } else {
1281  problemSolution->addSingleAction (poolItem, KEEP);
1282  std::string description = str::Format(_("do not install %1%") ) % s.asString();
1283  MIL << description << endl;
1284  problemSolution->addDescription (description);
1285  }
1286  } else {
1287  ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1288  }
1289  }
1290  break;
1291  case SOLVER_ERASE | SOLVER_SOLVABLE: {
1292  s = mapSolvable (what);
1293  PoolItem poolItem = _pool.find (s);
1294  if (poolItem) {
1295  if (pool->installed && s.get()->repo == pool->installed) {
1296  problemSolution->addSingleAction (poolItem, KEEP);
1297  std::string description = str::Format(_("keep %1%") ) % s.asString();
1298  MIL << description << endl;
1299  problemSolution->addDescription (description);
1300  } else {
1301  problemSolution->addSingleAction (poolItem, UNLOCK);
1302  std::string description = str::Format(_("remove lock to allow installation of %1%") ) % itemToString( poolItem );
1303  MIL << description << endl;
1304  problemSolution->addDescription (description);
1305  }
1306  } else {
1307  ERR << "SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1308  }
1309  }
1310  break;
1311  case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1312  {
1313  IdString ident( what );
1314  SolverQueueItemInstall_Ptr install =
1315  new SolverQueueItemInstall(_pool, ident.asString(), false );
1316  problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1317 
1318  std::string description = str::Format(_("do not install %1%") ) % ident;
1319  MIL << description << endl;
1320  problemSolution->addDescription (description);
1321  }
1322  break;
1323  case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1324  {
1325  // As we do not know, if this request has come from resolvePool or
1326  // resolveQueue we will have to take care for both cases.
1327  IdString ident( what );
1328  FindPackage info (problemSolution, KEEP);
1329  invokeOnEach( _pool.byIdentBegin( ident ),
1330  _pool.byIdentEnd( ident ),
1331  functor::chain (resfilter::ByInstalled (), // ByInstalled
1332  resfilter::ByTransact ()), // will be deinstalled
1333  functor::functorRef<bool,PoolItem> (info) );
1334 
1335  SolverQueueItemDelete_Ptr del =
1336  new SolverQueueItemDelete(_pool, ident.asString(), false );
1337  problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1338 
1339  std::string description = str::Format(_("keep %1%") ) % ident;
1340  MIL << description << endl;
1341  problemSolution->addDescription (description);
1342  }
1343  break;
1344  case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1345  {
1346  problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1347  std::string description = "";
1348 
1349  // Checking if this problem solution would break your system
1350  if (system_requires.find(Capability(what)) != system_requires.end()) {
1351  // Show a better warning
1352  resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1353  resolverProblem->setDescription(_("This request will break your system!"));
1354  description = _("ignore the warning of a broken system");
1355  description += std::string(" (requires:")+pool_dep2str(pool, what)+")";
1356  MIL << description << endl;
1357  problemSolution->addFrontDescription (description);
1358  } else {
1359  description = str::Format(_("do not ask to install a solvable providing %1%") ) % pool_dep2str(pool, what);
1360  MIL << description << endl;
1361  problemSolution->addDescription (description);
1362  }
1363  }
1364  break;
1365  case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1366  {
1367  problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1368  std::string description = "";
1369 
1370  // Checking if this problem solution would break your system
1371  if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1372  // Show a better warning
1373  resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1374  resolverProblem->setDescription(_("This request will break your system!"));
1375  description = _("ignore the warning of a broken system");
1376  description += std::string(" (conflicts:")+pool_dep2str(pool, what)+")";
1377  MIL << description << endl;
1378  problemSolution->addFrontDescription (description);
1379 
1380  } else {
1381  description = str::Format(_("do not ask to delete all solvables providing %1%") ) % pool_dep2str(pool, what);
1382  MIL << description << endl;
1383  problemSolution->addDescription (description);
1384  }
1385  }
1386  break;
1387  case SOLVER_UPDATE | SOLVER_SOLVABLE:
1388  {
1389  s = mapSolvable (what);
1390  PoolItem poolItem = _pool.find (s);
1391  if (poolItem) {
1392  if (pool->installed && s.get()->repo == pool->installed) {
1393  problemSolution->addSingleAction (poolItem, KEEP);
1394  std::string description = str::Format(_("do not install most recent version of %1%") ) % s.asString();
1395  MIL << description << endl;
1396  problemSolution->addDescription (description);
1397  } else {
1398  ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem << " is not selected for installation" << endl;
1399  }
1400  } else {
1401  ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1402  }
1403  }
1404  break;
1405  default:
1406  MIL << "- do something different" << endl;
1407  ERR << "No valid solution available" << endl;
1408  break;
1409  }
1410  } else if (p == SOLVER_SOLUTION_INFARCH) {
1411  s = mapSolvable (rp);
1412  PoolItem poolItem = _pool.find (s);
1413  if (pool->installed && s.get()->repo == pool->installed) {
1414  problemSolution->addSingleAction (poolItem, LOCK);
1415  std::string description = str::Format(_("keep %1% despite the inferior architecture") ) % s.asString();
1416  MIL << description << endl;
1417  problemSolution->addDescription (description);
1418  } else {
1419  problemSolution->addSingleAction (poolItem, INSTALL);
1420  std::string description = str::Format(_("install %1% despite the inferior architecture") ) % s.asString();
1421  MIL << description << endl;
1422  problemSolution->addDescription (description);
1423  }
1424  } else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1425  s = mapSolvable (rp);
1426  PoolItem poolItem = _pool.find (s);
1427  if (pool->installed && s.get()->repo == pool->installed) {
1428  problemSolution->addSingleAction (poolItem, LOCK);
1429  std::string description = str::Format(_("keep obsolete %1%") ) % s.asString();
1430  MIL << description << endl;
1431  problemSolution->addDescription (description);
1432  } else {
1433  problemSolution->addSingleAction (poolItem, INSTALL);
1434  std::string description = str::Format(_("install %1% from excluded repository") ) % s.asString();
1435  MIL << description << endl;
1436  problemSolution->addDescription (description);
1437  }
1438  } else if ( p == SOLVER_SOLUTION_BLACK ) {
1439  // Allow to install a blacklisted package (PTF, retracted,...).
1440  // For not-installed items only
1441  s = mapSolvable (rp);
1442  PoolItem poolItem = _pool.find (s);
1443 
1444  problemSolution->addSingleAction (poolItem, INSTALL);
1445  std::string description;
1446  if ( s.isRetracted() ) {
1447  // translator: %1% is a package name
1448  description = str::Format(_("install %1% although it has been retracted")) % s.asString();
1449  } else if ( s.isPtf() ) {
1450  // translator: %1% is a package name
1451  description = str::Format(_("allow to install the PTF %1%")) % s.asString();
1452  } else {
1453  // translator: %1% is a package name
1454  description = str::Format(_("install %1% although it is blacklisted")) % s.asString();
1455  }
1456  MIL << description << endl;
1457  problemSolution->addDescription( description );
1458  } else if ( p > 0 ) {
1459  /* policy, replace p with rp */
1460  s = mapSolvable (p);
1461  PoolItem itemFrom = _pool.find (s);
1462  if (rp)
1463  {
1464  int gotone = 0;
1465 
1466  sd = mapSolvable (rp);
1467  PoolItem itemTo = _pool.find (sd);
1468  if (itemFrom && itemTo) {
1469  problemSolution->addSingleAction (itemTo, INSTALL);
1470  int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1471 
1472  if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1473  {
1474  std::string description = str::Format(_("downgrade of %1% to %2%") ) % s.asString() % sd.asString();
1475  MIL << description << endl;
1476  problemSolution->addDescription (description);
1477  gotone = 1;
1478  }
1479  if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1480  {
1481  std::string description = str::Format(_("architecture change of %1% to %2%") ) % s.asString() % sd.asString();
1482  MIL << description << endl;
1483  problemSolution->addDescription (description);
1484  gotone = 1;
1485  }
1486  if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1487  {
1488  IdString s_vendor( s.vendor() );
1489  IdString sd_vendor( sd.vendor() );
1490  std::string description = str::Format(_("install %1% (with vendor change)\n %2% --> %3%") ) % sd.asString() % ( s_vendor ? s_vendor.c_str() : " (no vendor) " ) % ( sd_vendor ? sd_vendor.c_str() : " (no vendor) " );
1491  MIL << description << endl;
1492  problemSolution->addDescription (description);
1493  gotone = 1;
1494  }
1495  if (!gotone) {
1496  std::string description = str::Format(_("replacement of %1% with %2%") ) % s.asString() % sd.asString();
1497  MIL << description << endl;
1498  problemSolution->addDescription (description);
1499  }
1500  } else {
1501  ERR << s.asString() << " or " << sd.asString() << " not found" << endl;
1502  }
1503  }
1504  else
1505  {
1506  if (itemFrom) {
1507  std::string description = str::Format(_("deinstallation of %1%") ) % s.asString();
1508  MIL << description << endl;
1509  problemSolution->addDescription (description);
1510  problemSolution->addSingleAction (itemFrom, REMOVE);
1511  }
1512  }
1513  }
1514  else
1515  {
1516  INT << "Unknown solution " << p << endl;
1517  }
1518 
1519  }
1520  resolverProblem->addSolution (problemSolution,
1521  problemSolution->actionCount() > 1 ? true : false); // Solutions with more than 1 action will be shown first.
1522  MIL << "------------------------------------" << endl;
1523  }
1524 
1525  if (ignoreId > 0) {
1526  // There is a possibility to ignore this error by setting weak dependencies
1527  PoolItem item = _pool.find (sat::Solvable(ignoreId));
1528  ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(item);
1529  resolverProblem->addSolution (problemSolution,
1530  false); // Solutions will be shown at the end
1531  MIL << "ignore some dependencies of " << item << endl;
1532  MIL << "------------------------------------" << endl;
1533  }
1534 
1535  // save problem
1536  resolverProblems.push_back (resolverProblem);
1537  }
1538  }
1539  return resolverProblems;
1540 }
1541 #else // no ZYPPNEWSPPSWENPPYZ
1542 #warning Legacy texts
1543 std::string SATResolver::SATproblemRuleInfoString (Id probr, std::string &detail, Id &ignoreId)
1544 {
1545  std::string ret;
1546  sat::detail::CPool *pool = _satSolver->pool;
1547  Id dep, source, target;
1548  SolverRuleinfo type = solver_ruleinfo(_satSolver, probr, &source, &target, &dep);
1549 
1550  ignoreId = 0;
1551 
1552  sat::Solvable s = mapSolvable( source );
1553  sat::Solvable s2 = mapSolvable( target );
1554 
1555  // @FIXME, these strings are a duplicate copied from the libsolv library
1556  // to provide translations. Instead of having duplicate code we should
1557  // translate those strings directly in libsolv
1558  switch ( type )
1559  {
1560  case SOLVER_RULE_DISTUPGRADE:
1561  ret = str::form (_("%s does not belong to a distupgrade repository"), s.asString().c_str());
1562  break;
1563  case SOLVER_RULE_INFARCH:
1564  ret = str::form (_("%s has inferior architecture"), s.asString().c_str());
1565  break;
1566  case SOLVER_RULE_UPDATE:
1567  ret = str::form (_("problem with installed package %s"), s.asString().c_str());
1568  break;
1569  case SOLVER_RULE_JOB:
1570  ret = _("conflicting requests");
1571  break;
1572  case SOLVER_RULE_PKG:
1573  ret = _("some dependency problem");
1574  break;
1575  case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1576  ret = str::form (_("nothing provides requested %s"), pool_dep2str(pool, dep));
1577  detail += _("Have you enabled all requested repositories?");
1578  break;
1579  case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1580  ret = str::form (_("package %s does not exist"), pool_dep2str(pool, dep));
1581  detail += _("Have you enabled all requested repositories?");
1582  break;
1583  case SOLVER_RULE_JOB_UNSUPPORTED:
1584  ret = _("unsupported request");
1585  break;
1586  case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1587  ret = str::form (_("%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1588  break;
1589  case SOLVER_RULE_PKG_NOT_INSTALLABLE:
1590  ret = str::form (_("%s is not installable"), s.asString().c_str());
1591  break;
1592  case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
1593  ignoreId = source; // for setting weak dependencies
1594  ret = str::form (_("nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1595  break;
1596  case SOLVER_RULE_PKG_SAME_NAME:
1597  ret = str::form (_("cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1598  break;
1599  case SOLVER_RULE_PKG_CONFLICTS:
1600  ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1601  break;
1602  case SOLVER_RULE_PKG_OBSOLETES:
1603  ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1604  break;
1605  case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
1606  ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1607  break;
1608  case SOLVER_RULE_PKG_SELF_CONFLICT:
1609  ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1610  break;
1611  case SOLVER_RULE_PKG_REQUIRES: {
1612  ignoreId = source; // for setting weak dependencies
1613  Capability cap(dep);
1614  sat::WhatProvides possibleProviders(cap);
1615 
1616  // check, if a provider will be deleted
1617  typedef std::list<PoolItem> ProviderList;
1618  ProviderList providerlistInstalled, providerlistUninstalled;
1619  for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1620  PoolItem provider1 = ResPool::instance().find( *iter1 );
1621  // find pair of an installed/uninstalled item with the same NVR
1622  bool found = false;
1623  for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1624  PoolItem provider2 = ResPool::instance().find( *iter2 );
1625  if (compareByNVR (provider1,provider2) == 0
1626  && ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1627  || (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1628  found = true;
1629  break;
1630  }
1631  }
1632  if (!found) {
1633  if (provider1.status().isInstalled())
1634  providerlistInstalled.push_back(provider1);
1635  else
1636  providerlistUninstalled.push_back(provider1);
1637  }
1638  }
1639 
1640  ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1641  if (providerlistInstalled.size() > 0) {
1642  detail += _("deleted providers: ");
1643  for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1644  if (iter == providerlistInstalled.begin())
1645  detail += itemToString( *iter );
1646  else
1647  detail += "\n " + itemToString( mapItem(*iter) );
1648  }
1649  }
1650  if (providerlistUninstalled.size() > 0) {
1651  if (detail.size() > 0)
1652  detail += _("\nnot installable providers: ");
1653  else
1654  detail = _("not installable providers: ");
1655  for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1656  if (iter == providerlistUninstalled.begin())
1657  detail += itemToString( *iter );
1658  else
1659  detail += "\n " + itemToString( mapItem(*iter) );
1660  }
1661  }
1662  break;
1663  }
1664  default: {
1665  DBG << "Unknown rule type(" << type << ") going to query libsolv for rule information." << endl;
1666  ret = str::asString( ::solver_problemruleinfo2str( _satSolver, type, static_cast<Id>(s.id()), static_cast<Id>(s2.id()), dep ) );
1667  break;
1668  }
1669  }
1670  return ret;
1671 }
1672 
1674 SATResolver::problems ()
1675 {
1676  ResolverProblemList resolverProblems;
1677  if (_satSolver && solver_problem_count(_satSolver)) {
1678  sat::detail::CPool *pool = _satSolver->pool;
1679  int pcnt;
1680  Id p, rp, what;
1681  Id problem, solution, element;
1682  sat::Solvable s, sd;
1683 
1684  CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1685  CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1686 
1687  MIL << "Encountered problems! Here are the solutions:\n" << endl;
1688  pcnt = 1;
1689  problem = 0;
1690  while ((problem = solver_next_problem(_satSolver, problem)) != 0) {
1691  MIL << "Problem " << pcnt++ << ":" << endl;
1692  MIL << "====================================" << endl;
1693  std::string detail;
1694  Id ignoreId;
1695  std::string whatString = SATprobleminfoString (problem,detail,ignoreId);
1696  MIL << whatString << endl;
1697  MIL << "------------------------------------" << endl;
1698  ResolverProblem_Ptr resolverProblem = new ResolverProblem (whatString, detail, SATgetCompleteProblemInfoStrings( problem ));
1699 
1700  solution = 0;
1701  while ((solution = solver_next_solution(_satSolver, problem, solution)) != 0) {
1702  element = 0;
1703  ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi;
1704  while ((element = solver_next_solutionelement(_satSolver, problem, solution, element, &p, &rp)) != 0) {
1705  if (p == SOLVER_SOLUTION_JOB) {
1706  /* job, rp is index into job queue */
1707  what = _jobQueue.elements[rp];
1708  switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1709  {
1710  case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1711  s = mapSolvable (what);
1712  PoolItem poolItem = _pool.find (s);
1713  if (poolItem) {
1714  if (pool->installed && s.get()->repo == pool->installed) {
1715  problemSolution->addSingleAction (poolItem, REMOVE);
1716  std::string description = str::form (_("remove lock to allow removal of %s"), s.asString().c_str() );
1717  MIL << description << endl;
1718  problemSolution->addDescription (description);
1719  } else {
1720  problemSolution->addSingleAction (poolItem, KEEP);
1721  std::string description = str::form (_("do not install %s"), s.asString().c_str());
1722  MIL << description << endl;
1723  problemSolution->addDescription (description);
1724  }
1725  } else {
1726  ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1727  }
1728  }
1729  break;
1730  case SOLVER_ERASE | SOLVER_SOLVABLE: {
1731  s = mapSolvable (what);
1732  PoolItem poolItem = _pool.find (s);
1733  if (poolItem) {
1734  if (pool->installed && s.get()->repo == pool->installed) {
1735  problemSolution->addSingleAction (poolItem, KEEP);
1736  std::string description = str::form (_("keep %s"), s.asString().c_str());
1737  MIL << description << endl;
1738  problemSolution->addDescription (description);
1739  } else {
1740  problemSolution->addSingleAction (poolItem, UNLOCK);
1741  std::string description = str::form (_("remove lock to allow installation of %s"), itemToString( poolItem ).c_str());
1742  MIL << description << endl;
1743  problemSolution->addDescription (description);
1744  }
1745  } else {
1746  ERR << "SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1747  }
1748  }
1749  break;
1750  case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1751  {
1752  IdString ident( what );
1753  SolverQueueItemInstall_Ptr install =
1754  new SolverQueueItemInstall(_pool, ident.asString(), false );
1755  problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1756 
1757  std::string description = str::form (_("do not install %s"), ident.c_str() );
1758  MIL << description << endl;
1759  problemSolution->addDescription (description);
1760  }
1761  break;
1762  case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1763  {
1764  // As we do not know, if this request has come from resolvePool or
1765  // resolveQueue we will have to take care for both cases.
1766  IdString ident( what );
1767  FindPackage info (problemSolution, KEEP);
1768  invokeOnEach( _pool.byIdentBegin( ident ),
1769  _pool.byIdentEnd( ident ),
1770  functor::chain (resfilter::ByInstalled (), // ByInstalled
1771  resfilter::ByTransact ()), // will be deinstalled
1772  functor::functorRef<bool,PoolItem> (info) );
1773 
1774  SolverQueueItemDelete_Ptr del =
1775  new SolverQueueItemDelete(_pool, ident.asString(), false );
1776  problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1777 
1778  std::string description = str::form (_("keep %s"), ident.c_str());
1779  MIL << description << endl;
1780  problemSolution->addDescription (description);
1781  }
1782  break;
1783  case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1784  {
1785  problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1786  std::string description = "";
1787 
1788  // Checking if this problem solution would break your system
1789  if (system_requires.find(Capability(what)) != system_requires.end()) {
1790  // Show a better warning
1791  resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1792  resolverProblem->setDescription(_("This request will break your system!"));
1793  description = _("ignore the warning of a broken system");
1794  description += std::string(" (requires:")+pool_dep2str(pool, what)+")";
1795  MIL << description << endl;
1796  problemSolution->addFrontDescription (description);
1797  } else {
1798  description = str::form (_("do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1799  MIL << description << endl;
1800  problemSolution->addDescription (description);
1801  }
1802  }
1803  break;
1804  case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1805  {
1806  problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1807  std::string description = "";
1808 
1809  // Checking if this problem solution would break your system
1810  if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1811  // Show a better warning
1812  resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1813  resolverProblem->setDescription(_("This request will break your system!"));
1814  description = _("ignore the warning of a broken system");
1815  description += std::string(" (conflicts:")+pool_dep2str(pool, what)+")";
1816  MIL << description << endl;
1817  problemSolution->addFrontDescription (description);
1818 
1819  } else {
1820  description = str::form (_("do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1821  MIL << description << endl;
1822  problemSolution->addDescription (description);
1823  }
1824  }
1825  break;
1826  case SOLVER_UPDATE | SOLVER_SOLVABLE:
1827  {
1828  s = mapSolvable (what);
1829  PoolItem poolItem = _pool.find (s);
1830  if (poolItem) {
1831  if (pool->installed && s.get()->repo == pool->installed) {
1832  problemSolution->addSingleAction (poolItem, KEEP);
1833  std::string description = str::form (_("do not install most recent version of %s"), s.asString().c_str());
1834  MIL << description << endl;
1835  problemSolution->addDescription (description);
1836  } else {
1837  ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem << " is not selected for installation" << endl;
1838  }
1839  } else {
1840  ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1841  }
1842  }
1843  break;
1844  default:
1845  MIL << "- do something different" << endl;
1846  ERR << "No valid solution available" << endl;
1847  break;
1848  }
1849  } else if (p == SOLVER_SOLUTION_INFARCH) {
1850  s = mapSolvable (rp);
1851  PoolItem poolItem = _pool.find (s);
1852  if (pool->installed && s.get()->repo == pool->installed) {
1853  problemSolution->addSingleAction (poolItem, LOCK);
1854  std::string description = str::form (_("keep %s despite the inferior architecture"), s.asString().c_str());
1855  MIL << description << endl;
1856  problemSolution->addDescription (description);
1857  } else {
1858  problemSolution->addSingleAction (poolItem, INSTALL);
1859  std::string description = str::form (_("install %s despite the inferior architecture"), s.asString().c_str());
1860  MIL << description << endl;
1861  problemSolution->addDescription (description);
1862  }
1863  } else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1864  s = mapSolvable (rp);
1865  PoolItem poolItem = _pool.find (s);
1866  if (pool->installed && s.get()->repo == pool->installed) {
1867  problemSolution->addSingleAction (poolItem, LOCK);
1868  std::string description = str::form (_("keep obsolete %s"), s.asString().c_str());
1869  MIL << description << endl;
1870  problemSolution->addDescription (description);
1871  } else {
1872  problemSolution->addSingleAction (poolItem, INSTALL);
1873  std::string description = str::form (_("install %s from excluded repository"), s.asString().c_str());
1874  MIL << description << endl;
1875  problemSolution->addDescription (description);
1876  }
1877  } else if ( p == SOLVER_SOLUTION_BLACK ) {
1878  // Allow to install a blacklisted package (PTF, retracted,...).
1879  // For not-installed items only
1880  s = mapSolvable (rp);
1881  PoolItem poolItem = _pool.find (s);
1882 
1883  problemSolution->addSingleAction (poolItem, INSTALL);
1884  std::string description;
1885  if ( s.isRetracted() ) {
1886  // translator: %1% is a package name
1887  description = str::Format(_("install %1% although it has been retracted")) % s.asString();
1888  } else if ( s.isPtf() ) {
1889  // translator: %1% is a package name
1890  description = str::Format(_("allow to install the PTF %1%")) % s.asString();
1891  } else {
1892  // translator: %1% is a package name
1893  description = str::Format(_("install %1% although it is blacklisted")) % s.asString();
1894  }
1895  MIL << description << endl;
1896  problemSolution->addDescription( description );
1897  } else if ( p > 0 ) {
1898  /* policy, replace p with rp */
1899  s = mapSolvable (p);
1900  PoolItem itemFrom = _pool.find (s);
1901  if (rp)
1902  {
1903  int gotone = 0;
1904 
1905  sd = mapSolvable (rp);
1906  PoolItem itemTo = _pool.find (sd);
1907  if (itemFrom && itemTo) {
1908  problemSolution->addSingleAction (itemTo, INSTALL);
1909  int illegal = policy_is_illegal(_satSolver, s.get(), sd.get(), 0);
1910 
1911  if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1912  {
1913  std::string description = str::form (_("downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1914  MIL << description << endl;
1915  problemSolution->addDescription (description);
1916  gotone = 1;
1917  }
1918  if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1919  {
1920  std::string description = str::form (_("architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1921  MIL << description << endl;
1922  problemSolution->addDescription (description);
1923  gotone = 1;
1924  }
1925  if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1926  {
1927  IdString s_vendor( s.vendor() );
1928  IdString sd_vendor( sd.vendor() );
1929  std::string description = str::form (_("install %s (with vendor change)\n %s --> %s") ,
1930  sd.asString().c_str(),
1931  ( s_vendor ? s_vendor.c_str() : " (no vendor) " ),
1932  ( sd_vendor ? sd_vendor.c_str() : " (no vendor) " ) );
1933  MIL << description << endl;
1934  problemSolution->addDescription (description);
1935  gotone = 1;
1936  }
1937  if (!gotone) {
1938  std::string description = str::form (_("replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1939  MIL << description << endl;
1940  problemSolution->addDescription (description);
1941  }
1942  } else {
1943  ERR << s.asString() << " or " << sd.asString() << " not found" << endl;
1944  }
1945  }
1946  else
1947  {
1948  if (itemFrom) {
1949  std::string description = str::form (_("deinstallation of %s"), s.asString().c_str());
1950  MIL << description << endl;
1951  problemSolution->addDescription (description);
1952  problemSolution->addSingleAction (itemFrom, REMOVE);
1953  }
1954  }
1955  }
1956  else
1957  {
1958  INT << "Unknown solution " << p << endl;
1959  }
1960 
1961  }
1962  resolverProblem->addSolution (problemSolution,
1963  problemSolution->actionCount() > 1 ? true : false); // Solutions with more than 1 action will be shown first.
1964  MIL << "------------------------------------" << endl;
1965  }
1966 
1967  if (ignoreId > 0) {
1968  // There is a possibility to ignore this error by setting weak dependencies
1969  PoolItem item = _pool.find (sat::Solvable(ignoreId));
1970  ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(item);
1971  resolverProblem->addSolution (problemSolution,
1972  false); // Solutions will be shown at the end
1973  MIL << "ignore some dependencies of " << item << endl;
1974  MIL << "------------------------------------" << endl;
1975  }
1976 
1977  // save problem
1978  resolverProblems.push_back (resolverProblem);
1979  }
1980  }
1981  return resolverProblems;
1982 }
1983 #endif // ZYPPNEWSPPSWENPPYZ
1984 
1985 void SATResolver::applySolutions( const ProblemSolutionList & solutions )
1986 { Resolver( _pool ).applySolutions( solutions ); }
1987 
1988 void SATResolver::setLocks()
1989 {
1990  unsigned icnt = 0;
1991  unsigned acnt = 0;
1992 
1993  for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1994  sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
1995  if (iter->status().isInstalled()) {
1996  ++icnt;
1997  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1998  queue_push( &(_jobQueue), ident );
1999  } else {
2000  ++acnt;
2001  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
2002  queue_push( &(_jobQueue), ident );
2003  }
2004  }
2005  MIL << "Locked " << icnt << " installed items and " << acnt << " NOT installed items." << endl;
2006 
2008  // Weak locks: Ignore if an item with this name is already installed.
2009  // If it's not installed try to keep it this way using a weak delete
2011  std::set<IdString> unifiedByName;
2012  for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
2013  IdString ident( (*iter)->satSolvable().ident() );
2014  if ( unifiedByName.insert( ident ).second )
2015  {
2016  if ( ! ui::Selectable::get( *iter )->hasInstalledObj() )
2017  {
2018  MIL << "Keep NOT installed name " << ident << " (" << *iter << ")" << endl;
2019  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK | MAYBE_CLEANDEPS );
2020  queue_push( &(_jobQueue), ident.id() );
2021  }
2022  }
2023  }
2024 }
2025 
2026 void SATResolver::setSystemRequirements()
2027 {
2028  CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
2029  CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
2030 
2031  for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
2032  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
2033  queue_push( &(_jobQueue), iter->id() );
2034  MIL << "SYSTEM Requires " << *iter << endl;
2035  }
2036 
2037  for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
2038  queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
2039  queue_push( &(_jobQueue), iter->id() );
2040  MIL << "SYSTEM Conflicts " << *iter << endl;
2041  }
2042 
2043  // Lock the architecture of the running systems rpm
2044  // package on distupgrade.
2045  if ( _distupgrade && ZConfig::instance().systemRoot() == "/" )
2046  {
2047  ResPool pool( ResPool::instance() );
2048  IdString rpm( "rpm" );
2049  for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
2050  {
2051  if ( (*it)->isSystem() )
2052  {
2053  Capability archrule( (*it)->arch(), rpm.c_str(), Capability::PARSED );
2054  queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
2055  queue_push( &(_jobQueue), archrule.id() );
2056 
2057  }
2058  }
2059  }
2060 }
2061 
2062 sat::StringQueue SATResolver::autoInstalled() const
2063 {
2064  sat::StringQueue ret;
2065  if ( _satSolver )
2066  ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED );
2067  return ret;
2068 }
2069 
2070 sat::StringQueue SATResolver::userInstalled() const
2071 {
2072  sat::StringQueue ret;
2073  if ( _satSolver )
2074  ::solver_get_userinstalled( _satSolver, ret, GET_USERINSTALLED_NAMES );
2075  return ret;
2076 }
2077 
2078 
2080 };// namespace detail
2083  };// namespace solver
2086 };// namespace zypp
2088 
2089 #if 0
2090 // Legacy translations we want to keep for now:
2091 
2092 // - Rule infos:
2093  case SOLVER_RULE_DISTUPGRADE:
2094  ret = str::form (_("%s does not belong to a distupgrade repository"), s.asString().c_str());
2095  case SOLVER_RULE_INFARCH:
2096  ret = str::form (_("%s has inferior architecture"), s.asString().c_str());
2097  case SOLVER_RULE_UPDATE:
2098  ret = str::form (_("problem with installed package %s"), s.asString().c_str());
2099  case SOLVER_RULE_JOB:
2100  ret = _("conflicting requests");
2101  case SOLVER_RULE_PKG:
2102  ret = _("some dependency problem");
2103  case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
2104  ret = str::form (_("nothing provides requested %s"), pool_dep2str(pool, dep));
2105  detail += _("Have you enabled all requested repositories?");
2106  case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
2107  ret = str::form (_("package %s does not exist"), pool_dep2str(pool, dep));
2108  detail += _("Have you enabled all requested repositories?");
2109  case SOLVER_RULE_JOB_UNSUPPORTED:
2110  ret = _("unsupported request");
2111  case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
2112  ret = str::form (_("%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
2113  case SOLVER_RULE_PKG_NOT_INSTALLABLE:
2114  ret = str::form (_("%s is not installable"), s.asString().c_str());
2115  case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
2116  ignoreId = source; // for setting weak dependencies
2117  ret = str::form (_("nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
2118  case SOLVER_RULE_PKG_SAME_NAME:
2119  ret = str::form (_("cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
2120  case SOLVER_RULE_PKG_CONFLICTS:
2121  ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
2122  case SOLVER_RULE_PKG_OBSOLETES:
2123  ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
2124  case SOLVER_RULE_PKG_INSTALLED_OBSOLETES:
2125  ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
2126  case SOLVER_RULE_PKG_SELF_CONFLICT:
2127  ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
2128  case SOLVER_RULE_PKG_REQUIRES: {
2129  ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
2130  if (providerlistInstalled.size() > 0) {
2131  detail += _("deleted providers: ");
2132  detail += _("\nnot installable providers: ");
2133  detail = _("not installable providers: ");
2134 
2135 // - Solution infos:
2136  if (p == SOLVER_SOLUTION_JOB) {
2137  case SOLVER_INSTALL | SOLVER_SOLVABLE: {
2138  std::string description = str::form (_("remove lock to allow removal of %s"), s.asString().c_str() );
2139  std::string description = str::form (_("do not install %s"), s.asString().c_str());
2140  case SOLVER_ERASE | SOLVER_SOLVABLE: {
2141  std::string description = str::form (_("keep %s"), s.asString().c_str());
2142  std::string description = str::form (_("remove lock to allow installation of %s"), itemToString( poolItem ).c_str());
2143  case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
2144  std::string description = str::form (_("do not install %s"), ident.c_str() );
2145  case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
2146  std::string description = str::form (_("keep %s"), ident.c_str());
2147  case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
2148  resolverProblem->setDescription(_("This request will break your system!"));
2149  description = _("ignore the warning of a broken system");
2150  description = str::form (_("do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
2151  case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
2152  resolverProblem->setDescription(_("This request will break your system!"));
2153  description = _("ignore the warning of a broken system");
2154  description = str::form (_("do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
2155  case SOLVER_UPDATE | SOLVER_SOLVABLE:
2156  std::string description = str::form (_("do not install most recent version of %s"), s.asString().c_str());
2157 
2158  } else if (p == SOLVER_SOLUTION_INFARCH) {
2159  std::string description = str::form (_("keep %s despite the inferior architecture"), s.asString().c_str());
2160  std::string description = str::form (_("install %s despite the inferior architecture"), s.asString().c_str());
2161 
2162  } else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
2163  std::string description = str::form (_("keep obsolete %s"), s.asString().c_str());
2164  std::string description = str::form (_("install %s from excluded repository"), s.asString().c_str());
2165 
2166  } else if ( p == SOLVER_SOLUTION_BLACK ) {
2167  description = str::Format(_("install %1% although it has been retracted")) % s.asString();
2168  description = str::Format(_("allow to install the PTF %1%")) % s.asString();
2169  description = str::Format(_("install %1% although it is blacklisted")) % s.asString();
2170 
2171  } else if ( p > 0 ) {
2172  std::string description = str::form (_("downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
2173  std::string description = str::form (_("architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
2174  std::string description = str::form (_("install %s (with vendor change)\n %s --> %s") ,
2175  std::string description = str::form (_("replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
2176 
2177  std::string description = str::form (_("deinstallation of %s"), s.asString().c_str());
2178 #endif
bool empty() const
Definition: Queue.cc:46
Interface to gettext.
std::list< ProblemSolution_Ptr > ProblemSolutionList
Definition: ProblemTypes.h:43
#define MIL
Definition: Logger.h:79
int IdType
Generic Id type.
Definition: PoolMember.h:104
A Solvable object within the sat Pool.
Definition: Solvable.h:53
Focus on updating requested packages and their dependencies as much as possible.
static ZConfig & instance()
Singleton ctor.
Definition: Resolver.cc:126
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
static const IdString ptfToken
Indicator provides ptf()
Definition: Solvable.h:59
ProblemSolutionCombi * problemSolution
Definition: SATResolver.cc:983
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
Definition: ResPool.cc:73
ResolverFocus
The resolvers general attitude.
Definition: ResolverFocus.h:21
Queue SolvableQueue
Queue with Solvable ids.
Definition: Queue.h:25
#define INT
Definition: Logger.h:83
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:204
static const ResStatus toBeInstalled
Definition: ResStatus.h:662
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
Definition: PtrTypes.h:151
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolMember.h:125
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:301
sat::Solvable buddy() const
Return the buddy we share our status object with.
Definition: PoolItem.cc:206
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
Definition: String.h:136
#define OUTS(X)
Access to the sat-pools string space.
Definition: IdString.h:42
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
bool sameNVRA(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:228
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:485
std::list< SolverQueueItem_Ptr > SolverQueueItemList
Definition: Types.h:45
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
static void SATSolutionToPool(PoolItem item, const ResStatus &status, const ResStatus::TransactByValue causer)
Definition: SATResolver.cc:335
#define ERR
Definition: Logger.h:81
bool setToBeUninstalledDueToUpgrade(TransactByValue causer)
Definition: ResStatus.h:569
#define MAYBE_CLEANDEPS
Definition: SATResolver.cc:171
static const ResStatus toBeUninstalledDueToUpgrade
Definition: ResStatus.h:664
std::unary_function< ResObject::constPtr, bool > ResObjectFilterFunctor
Definition: ResFilters.h:151
void prepare() const
Update housekeeping data if necessary (e.g.
Definition: Pool.cc:61
CheckIfUpdate(const sat::Solvable &installed_r)
Definition: SATResolver.cc:445
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:362
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:187
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:452
int relaxedVendorCheck(sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2)
Definition: SATResolver.cc:180
unsigned size_type
Definition: Queue.h:37
int vendorCheck(sat::detail::CPool *pool, Solvable *solvable1, Solvable *solvable2)
Definition: SATResolver.cc:177
Package interface.
Definition: Package.h:32
std::unary_function< PoolItem, bool > PoolItemFilterFunctor
Definition: ResFilters.h:285
#define WAR
Definition: Logger.h:80
Focus on applying as little changes to the installed packages as needed.
bool multiversionInstall() const
Definition: SolvableType.h:82
detail::CPool * get() const
Expert backdoor.
Definition: Pool.cc:49
bool relaxedEquivalent(const Vendor &lVendor, const Vendor &rVendor) const
Like equivalent but always unifies suse and openSUSE vendor.
Definition: VendorAttr.cc:344
#define _(MSG)
Definition: Gettext.h:37
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:545
FindPackage(ProblemSolutionCombi *p, const TransactionKind act)
Definition: SATResolver.cc:985
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:256
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
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:92
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:346
bool setToBeInstalled(TransactByValue causer)
Definition: ResStatus.h:531
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:824
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:58
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:663
bool isToBeUninstalledDueToUpgrade() const
Definition: ResStatus.h:318
#define DBG
Definition: Logger.h:78
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:37