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