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