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