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