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