1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4
* Copyright (C) 2000-2002 Ximian, Inc.
5
* Copyright (C) 2005 SUSE Linux Products GmbH
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.
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.
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
23
#include <solv/repo_solv.h>
24
#include <solv/poolarch.h>
26
#include <solv/poolvendor.h>
27
#include <solv/policy.h>
28
#include <solv/bitmap.h>
29
#include <solv/queue.h>
32
#include "zypp/solver/detail/Helper.h"
33
#include "zypp/base/String.h"
34
#include "zypp/Product.h"
35
#include "zypp/Capability.h"
36
#include "zypp/ResStatus.h"
37
#include "zypp/VendorAttr.h"
38
#include "zypp/base/LogTools.h"
39
#include "zypp/base/String.h"
40
#include "zypp/base/Gettext.h"
41
#include "zypp/base/Algorithm.h"
42
#include "zypp/ResPool.h"
43
#include "zypp/ResFilters.h"
44
#include "zypp/ZConfig.h"
45
#include "zypp/sat/Pool.h"
46
#include "zypp/sat/WhatProvides.h"
47
#include "zypp/sat/WhatObsoletes.h"
48
#include "zypp/solver/detail/SATResolver.h"
49
#include "zypp/solver/detail/ProblemSolutionCombi.h"
50
#include "zypp/solver/detail/ProblemSolutionIgnore.h"
51
#include "zypp/solver/detail/SolverQueueItemInstall.h"
52
#include "zypp/solver/detail/SolverQueueItemDelete.h"
53
#include "zypp/solver/detail/SystemCheck.h"
54
#include "zypp/sat/Transaction.h"
55
#include "zypp/sat/Queue.h"
57
/////////////////////////////////////////////////////////////////////////
59
{ ///////////////////////////////////////////////////////////////////////
60
///////////////////////////////////////////////////////////////////////
62
{ /////////////////////////////////////////////////////////////////////
63
/////////////////////////////////////////////////////////////////////
65
{ ///////////////////////////////////////////////////////////////////
69
IMPL_PTR_TYPE(SATResolver);
71
#define MAYBE_CLEANDEPS (cleandepsOnRemove()?SOLVER_CLEANDEPS:0)
73
//---------------------------------------------------------------------------
74
// Callbacks for SAT policies
75
//---------------------------------------------------------------------------
77
int vendorCheck( Pool *pool, Solvable *solvable1, Solvable *solvable2 )
79
return VendorAttr::instance().equivalent( IdString(solvable1->vendor),
80
IdString(solvable2->vendor) ) ? 0 : 1;
84
inline std::string itemToString( const PoolItem & item )
89
sat::Solvable slv( item.satSolvable() );
90
std::string ret( slv.asString() ); // n-v-r.a
91
if ( ! slv.isSystem() )
94
ret += slv.repository().alias();
100
inline PoolItem getPoolItem( Id id_r )
102
PoolItem ret( (sat::Solvable( id_r )) );
104
INT << "id " << id_r << " not found in ZYPP pool." << endl;
108
//---------------------------------------------------------------------------
111
SATResolver::dumpOn( std::ostream & os ) const
113
os << "<resolver>" << endl;
115
// os << " fixsystem = " << _solv->fixsystem << endl;
116
// os << " updatesystem = " << _solv->updatesystem << endl;
117
os << " allowdowngrade = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_DOWNGRADE) << endl;
118
os << " allowarchchange = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_ARCHCHANGE) << endl;
119
os << " allowvendorchange = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_VENDORCHANGE) << endl;
120
os << " allowuninstall = " << solver_get_flag(_solv, SOLVER_FLAG_ALLOW_UNINSTALL) << endl;
121
os << " noupdateprovide = " << solver_get_flag(_solv, SOLVER_FLAG_NO_UPDATEPROVIDE) << endl;
122
os << " dosplitprovides = " << solver_get_flag(_solv, SOLVER_FLAG_SPLITPROVIDES) << endl;
123
os << " onlyRequires = " << solver_get_flag(_solv, SOLVER_FLAG_IGNORE_RECOMMENDED) << endl;
124
os << " ignorealreadyrecommended = " << !solver_get_flag(_solv, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED) << endl;
125
os << " distupgrade = " << _distupgrade << endl;
126
os << " distupgrade_removeunsupported = " << _distupgrade_removeunsupported << endl;
127
os << " solveSrcPackages = " << _solveSrcPackages << endl;
128
os << " cleandepsOnRemove = " << _cleandepsOnRemove << endl;
132
return os << "<resolver/>" << endl;
135
//---------------------------------------------------------------------------
137
SATResolver::SATResolver (const ResPool & pool, Pool *SATPool)
142
, _allowdowngrade(false)
143
, _allowarchchange(false)
144
, _allowvendorchange(ZConfig::instance().solver_allowVendorChange())
145
, _allowuninstall(false)
146
, _updatesystem(false)
147
, _noupdateprovide(false)
148
, _dosplitprovides(false)
149
, _onlyRequires(ZConfig::instance().solver_onlyRequires())
150
, _ignorealreadyrecommended(false)
151
, _distupgrade(false)
152
, _distupgrade_removeunsupported(false)
153
, _solveSrcPackages(false)
154
, _cleandepsOnRemove(ZConfig::instance().solver_cleandepsOnRemove())
159
SATResolver::~SATResolver()
164
//---------------------------------------------------------------------------
167
SATResolver::pool (void) const
173
SATResolver::resetItemTransaction (PoolItem item)
176
for (PoolItemList::const_iterator iter = _items_to_remove.begin();
177
iter != _items_to_remove.end(); ++iter) {
179
_items_to_remove.remove(*iter);
185
for (PoolItemList::const_iterator iter = _items_to_install.begin();
186
iter != _items_to_install.end(); ++iter) {
188
_items_to_install.remove(*iter);
195
for (PoolItemList::const_iterator iter = _items_to_keep.begin();
196
iter != _items_to_keep.end(); ++iter) {
198
_items_to_keep.remove(*iter);
205
for (PoolItemList::const_iterator iter = _items_to_lock.begin();
206
iter != _items_to_lock.end(); ++iter) {
208
_items_to_lock.remove(*iter);
218
SATResolver::addPoolItemToInstall (PoolItem item)
220
resetItemTransaction (item);
221
_items_to_install.push_back (item);
222
_items_to_install.unique ();
227
SATResolver::addPoolItemsToInstallFromList (PoolItemList & rl)
229
for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
230
addPoolItemToInstall (*iter);
236
SATResolver::addPoolItemToRemove (PoolItem item)
238
resetItemTransaction (item);
239
_items_to_remove.push_back (item);
240
_items_to_remove.unique ();
245
SATResolver::addPoolItemsToRemoveFromList (PoolItemList & rl)
247
for (PoolItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) {
248
addPoolItemToRemove (*iter);
253
SATResolver::addPoolItemToLock (PoolItem item)
255
resetItemTransaction (item);
256
_items_to_lock.push_back (item);
257
_items_to_lock.unique ();
261
SATResolver::addPoolItemToKeep (PoolItem item)
263
resetItemTransaction (item);
264
_items_to_keep.push_back (item);
265
_items_to_keep.unique ();
268
//---------------------------------------------------------------------------
270
// copy marked item from solution back to pool
271
// if data != NULL, set as APPL_LOW (from establishPool())
274
SATSolutionToPool (PoolItem item, const ResStatus & status, const ResStatus::TransactByValue causer)
277
item.status().resetTransact (causer);
278
item.status().resetWeak ();
282
// installation/deletion
283
if (status.isToBeInstalled()) {
284
r = item.status().setToBeInstalled (causer);
285
_XDEBUG("SATSolutionToPool install returns " << item << ", " << r);
287
else if (status.isToBeUninstalledDueToUpgrade()) {
288
r = item.status().setToBeUninstalledDueToUpgrade (causer);
289
_XDEBUG("SATSolutionToPool upgrade returns " << item << ", " << r);
291
else if (status.isToBeUninstalled()) {
292
r = item.status().setToBeUninstalled (causer);
293
_XDEBUG("SATSolutionToPool remove returns " << item << ", " << r);
299
//----------------------------------------------------------------------------
300
//----------------------------------------------------------------------------
302
//----------------------------------------------------------------------------
303
//----------------------------------------------------------------------------
305
//----------------------------------------------------------------------------
306
// Helper functions for the ZYPP-Pool
307
//----------------------------------------------------------------------------
310
//------------------------------------------------------------------------------------------------------------
311
// This function loops over the pool and grabs all items
312
// It clears all previous bySolver() states also
314
// Every toBeInstalled is passed to zypp::solver:detail::Resolver.addPoolItemToInstall()
315
// Every toBeUninstalled is passed to zypp::solver:detail::Resolver.addPoolItemToRemove()
317
// Solver results must be written back to the pool.
318
//------------------------------------------------------------------------------------------------------------
321
struct SATCollectTransact : public resfilter::PoolItemFilterFunctor
323
SATResolver & resolver;
325
SATCollectTransact (SATResolver & r)
329
bool operator()( PoolItem item ) // only transacts() items go here
331
ResStatus status = item.status();
332
bool by_solver = (status.isBySolver() || status.isByApplLow());
335
item.status().resetTransact( ResStatus::APPL_LOW );// clear any solver/establish transactions
336
return true; // back out here, dont re-queue former solver result
339
if ( item.satSolvable().isKind<SrcPackage>() && ! resolver.solveSrcPackages() )
341
// Later we may continue on a per source package base.
342
return true; // dont process this source package.
345
if (status.isToBeInstalled()) {
346
resolver.addPoolItemToInstall(item); // -> install!
348
else if (status.isToBeUninstalled()) {
349
resolver.addPoolItemToRemove(item); // -> remove !
351
else if (status.isLocked()
353
resolver.addPoolItemToLock (item);
355
else if (status.isKept()
357
resolver.addPoolItemToKeep (item);
365
//----------------------------------------------------------------------------
366
//----------------------------------------------------------------------------
368
//----------------------------------------------------------------------------
369
//----------------------------------------------------------------------------
372
class CheckIfUpdate : public resfilter::PoolItemFilterFunctor
377
sat::Solvable _installed;
379
CheckIfUpdate( sat::Solvable installed_r )
380
: is_updated( false )
381
, multiversion( installed_r.multiversionInstall() )
382
, _installed( installed_r )
385
// check this item will be updated
387
bool operator()( PoolItem item )
389
if ( item.status().isToBeInstalled() )
391
if ( ! multiversion || sameNVRA( _installed, item ) )
402
class CollectPseudoInstalled : public resfilter::PoolItemFilterFunctor
405
Queue *solvableQueue;
407
CollectPseudoInstalled( Queue *queue )
408
:solvableQueue (queue)
411
// collecting PseudoInstalled items
412
bool operator()( PoolItem item )
414
if ( traits::isPseudoInstalled( item.satSolvable().kind() ) )
415
queue_push( solvableQueue, item.satSolvable().id() );
421
SATResolver::solving(const CapabilitySet & requires_caps,
422
const CapabilitySet & conflict_caps)
424
_solv = solver_create( _SATPool );
425
::pool_set_custom_vendorcheck( _SATPool, &vendorCheck );
427
queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
428
queue_push( &(_jobQueue), 0 );
431
queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
432
queue_push( &(_jobQueue), 0 );
435
queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
436
queue_push( &(_jobQueue), 0 );
438
if (_distupgrade_removeunsupported) {
439
queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
440
queue_push( &(_jobQueue), 0 );
442
solver_set_flag(_solv, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
443
solver_set_flag(_solv, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
444
solver_set_flag(_solv, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
445
solver_set_flag(_solv, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
446
solver_set_flag(_solv, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
447
solver_set_flag(_solv, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
448
solver_set_flag(_solv, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
449
solver_set_flag(_solv, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
451
sat::Pool::instance().prepareForSolving();
454
MIL << "Starting solving...." << endl;
456
solver_solve( _solv, &(_jobQueue) );
457
MIL << "....Solver end" << endl;
459
// copying solution back to zypp pool
460
//-----------------------------------------
461
_result_items_to_install.clear();
462
_result_items_to_remove.clear();
464
/* solvables to be installed */
466
queue_init(&decisionq);
467
solver_get_decisionqueue(_solv, &decisionq);
468
for ( int i = 0; i < decisionq.count; ++i )
470
sat::Solvable slv( decisionq.elements[i] );
471
if ( !slv || slv.isSystem() )
474
PoolItem poolItem( slv );
475
SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
476
_result_items_to_install.push_back (poolItem);
478
queue_free(&decisionq);
480
/* solvables to be erased */
481
Repository systemRepo( sat::Pool::instance().findSystemRepo() ); // don't create if it does not exist
482
if ( systemRepo && ! systemRepo.solvablesEmpty() )
484
bool mustCheckObsoletes = false;
485
for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
487
if (solver_get_decisionlevel(_solv, it->id()) > 0)
490
// Check if this is an update
491
CheckIfUpdate info( *it );
492
PoolItem poolItem( *it );
493
invokeOnEach( _pool.byIdentBegin( poolItem ),
494
_pool.byIdentEnd( poolItem ),
495
resfilter::ByUninstalled(), // ByUninstalled
496
functor::functorRef<bool,PoolItem> (info) );
498
if (info.is_updated) {
499
SATSolutionToPool( poolItem, ResStatus::toBeUninstalledDueToUpgrade, ResStatus::SOLVER );
501
SATSolutionToPool( poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER );
502
if ( ! mustCheckObsoletes )
503
mustCheckObsoletes = true; // lazy check for UninstalledDueToObsolete
505
_result_items_to_remove.push_back (poolItem);
507
if ( mustCheckObsoletes )
509
sat::WhatObsoletes obsoleted( _result_items_to_install.begin(), _result_items_to_install.end() );
510
for_( it, obsoleted.poolItemBegin(), obsoleted.poolItemEnd() )
512
ResStatus & status( it->status() );
513
// WhatObsoletes contains installed items only!
514
if ( status.transacts() && ! status.isToBeUninstalledDueToUpgrade() )
515
status.setToBeUninstalledDueToObsolete();
520
Queue recommendations;
524
queue_init(&recommendations);
525
queue_init(&suggestions);
526
queue_init(&orphaned);
527
queue_init(&unneeded);
528
solver_get_recommendations(_solv, &recommendations, &suggestions, 0);
529
solver_get_orphaned(_solv, &orphaned);
530
solver_get_unneeded(_solv, &unneeded, 1);
531
/* solvables which are recommended */
532
for ( int i = 0; i < recommendations.count; ++i )
534
PoolItem poolItem( getPoolItem( recommendations.elements[i] ) );
535
poolItem.status().setRecommended( true );
538
/* solvables which are suggested */
539
for ( int i = 0; i < suggestions.count; ++i )
541
PoolItem poolItem( getPoolItem( suggestions.elements[i] ) );
542
poolItem.status().setSuggested( true );
545
_problem_items.clear();
546
/* solvables which are orphaned */
547
for ( int i = 0; i < orphaned.count; ++i )
549
PoolItem poolItem( getPoolItem( orphaned.elements[i] ) );
550
poolItem.status().setOrphaned( true );
551
_problem_items.push_back( poolItem );
554
/* solvables which are unneeded */
555
for ( int i = 0; i < unneeded.count; ++i )
557
PoolItem poolItem( getPoolItem( unneeded.elements[i] ) );
558
poolItem.status().setUnneeded( true );
561
queue_free(&recommendations);
562
queue_free(&suggestions);
563
queue_free(&orphaned);
564
queue_free(&unneeded);
566
/* Write validation state back to pool */
567
Queue flags, solvableQueue;
570
queue_init(&solvableQueue);
572
CollectPseudoInstalled collectPseudoInstalled(&solvableQueue);
573
invokeOnEach( _pool.begin(),
575
functor::functorRef<bool,PoolItem> (collectPseudoInstalled) );
576
solver_trivial_installable(_solv, &solvableQueue, &flags );
577
for (int i = 0; i < solvableQueue.count; i++) {
578
PoolItem item = _pool.find (sat::Solvable(solvableQueue.elements[i]));
579
item.status().setUndetermined();
581
if (flags.elements[i] == -1) {
582
item.status().setNonRelevant();
583
_XDEBUG("SATSolutionToPool(" << item << " ) nonRelevant !");
584
} else if (flags.elements[i] == 1) {
585
item.status().setSatisfied();
586
_XDEBUG("SATSolutionToPool(" << item << " ) satisfied !");
587
} else if (flags.elements[i] == 0) {
588
item.status().setBroken();
589
_XDEBUG("SATSolutionToPool(" << item << " ) broken !");
592
queue_free(&(solvableQueue));
596
// Solvables which were selected due requirements which have been made by the user will
597
// be selected by APPL_LOW. We can't use any higher level, because this setting must
598
// not serve as a request for the next solver run. APPL_LOW is reset before solving.
599
for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
600
sat::WhatProvides rpmProviders(*iter);
601
for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
602
PoolItem poolItem(*iter2);
603
if (poolItem.status().isToBeInstalled()) {
604
MIL << "User requirement " << *iter << " sets " << poolItem << endl;
605
poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
609
for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
610
sat::WhatProvides rpmProviders(*iter);
611
for_( iter2, rpmProviders.begin(), rpmProviders.end() ) {
612
PoolItem poolItem(*iter2);
613
if (poolItem.status().isToBeUninstalled()) {
614
MIL << "User conflict " << *iter << " sets " << poolItem << endl;
615
poolItem.status().setTransactByValue (ResStatus::APPL_LOW);
620
if (solver_problem_count(_solv) > 0 )
622
ERR << "Solverrun finished with an ERROR" << endl;
631
SATResolver::solverInit(const PoolItemList & weakItems)
633
SATCollectTransact info (*this);
635
MIL << "SATResolver::solverInit()" << endl;
640
queue_init( &_jobQueue );
641
_items_to_install.clear();
642
_items_to_remove.clear();
643
_items_to_lock.clear();
644
_items_to_keep.clear();
646
invokeOnEach ( _pool.begin(), _pool.end(),
647
functor::functorRef<bool,PoolItem>(info) );
649
for (PoolItemList::const_iterator iter = weakItems.begin(); iter != weakItems.end(); iter++) {
650
Id id = (*iter)->satSolvable().id();
652
ERR << "Weaken: " << *iter << " not found" << endl;
654
MIL << "Weaken dependencies of " << *iter << endl;
655
queue_push( &(_jobQueue), SOLVER_WEAKENDEPS | SOLVER_SOLVABLE );
656
queue_push( &(_jobQueue), id );
659
// Add rules for parallel installable resolvables with different versions
660
for_( it, sat::Pool::instance().multiversionBegin(), sat::Pool::instance().multiversionEnd() )
662
queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE_NAME );
663
queue_push( &(_jobQueue), it->id() );
666
if ( cleandepsOnRemove() )
668
// Add all items known to be installed by user request (not solver selected).
669
for_( it, sat::Pool::instance().onSystemByUserBegin(), sat::Pool::instance().onSystemByUserEnd() )
671
queue_push( &(_jobQueue), SOLVER_USERINSTALLED | SOLVER_SOLVABLE_NAME );
672
queue_push( &(_jobQueue), it->id() );
678
if ( ZConfig::instance().solverUpgradeRemoveDroppedPackages() )
680
MIL << "Checking droplists ..." << endl;
681
// Dropped packages: look for 'weakremover()' provides
682
// in dup candidates of installed products.
683
ResPoolProxy proxy( ResPool::instance().proxy() );
684
for_( it, proxy.byKindBegin<Product>(), proxy.byKindEnd<Product>() )
686
if ( (*it)->onSystem() ) // (to install) or (not to delete)
688
Product::constPtr prodCand( (*it)->candidateAsKind<Product>() );
690
continue; // product no longer available
692
CapabilitySet droplist( prodCand->droplist() );
693
dumpRangeLine( MIL << "Droplist for " << (*it)->candidateObj() << ": " << droplist.size() << " ", droplist.begin(), droplist.end() ) << endl;
694
for_( cap, droplist.begin(), droplist.end() )
696
queue_push( &_jobQueue, SOLVER_DROP_ORPHANED | SOLVER_SOLVABLE_NAME );
697
queue_push( &_jobQueue, cap->id() );
704
MIL << "Droplist processing is disabled." << endl;
710
SATResolver::solverEnd()
717
queue_free( &(_jobQueue) );
723
SATResolver::resolvePool(const CapabilitySet & requires_caps,
724
const CapabilitySet & conflict_caps,
725
const PoolItemList & weakItems,
726
const std::set<Repository> & upgradeRepos)
728
MIL << "SATResolver::resolvePool()" << endl;
731
solverInit(weakItems);
733
for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
734
Id id = (*iter)->satSolvable().id();
736
ERR << "Install: " << *iter << " not found" << endl;
738
MIL << "Install " << *iter << endl;
739
queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
740
queue_push( &(_jobQueue), id );
744
for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
745
Id id = (*iter)->satSolvable().id();
747
ERR << "Delete: " << *iter << " not found" << endl;
749
MIL << "Delete " << *iter << endl;
750
queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
751
queue_push( &(_jobQueue), id);
755
for_( iter, upgradeRepos.begin(), upgradeRepos.end() )
757
queue_push( &(_jobQueue), SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_REPO );
758
queue_push( &(_jobQueue), iter->get()->repoid );
759
MIL << "Upgrade repo " << *iter << endl;
762
for (CapabilitySet::const_iterator iter = requires_caps.begin(); iter != requires_caps.end(); iter++) {
763
queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
764
queue_push( &(_jobQueue), iter->id() );
765
MIL << "Requires " << *iter << endl;
768
for (CapabilitySet::const_iterator iter = conflict_caps.begin(); iter != conflict_caps.end(); iter++) {
769
queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
770
queue_push( &(_jobQueue), iter->id() );
771
MIL << "Conflicts " << *iter << endl;
774
// set requirements for a running system
775
setSystemRequirements();
777
// set locks for the solver
781
bool ret = solving(requires_caps, conflict_caps);
783
(ret?MIL:WAR) << "SATResolver::resolvePool() done. Ret:" << ret << endl;
789
SATResolver::resolveQueue(const SolverQueueItemList &requestQueue,
790
const PoolItemList & weakItems)
792
MIL << "SATResolver::resolvQueue()" << endl;
795
solverInit(weakItems);
797
// generate solver queue
798
for (SolverQueueItemList::const_iterator iter = requestQueue.begin(); iter != requestQueue.end(); iter++) {
799
(*iter)->addRule(_jobQueue);
802
// Add addition item status to the resolve-queue cause these can be set by problem resolutions
803
for (PoolItemList::const_iterator iter = _items_to_install.begin(); iter != _items_to_install.end(); iter++) {
804
Id id = (*iter)->satSolvable().id();
806
ERR << "Install: " << *iter << " not found" << endl;
808
MIL << "Install " << *iter << endl;
809
queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
810
queue_push( &(_jobQueue), id );
813
for (PoolItemList::const_iterator iter = _items_to_remove.begin(); iter != _items_to_remove.end(); iter++) {
814
sat::detail::IdType ident( (*iter)->satSolvable().ident().id() );
815
MIL << "Delete " << *iter << ident << endl;
816
queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | MAYBE_CLEANDEPS );
817
queue_push( &(_jobQueue), ident);
820
// set requirements for a running system
821
setSystemRequirements();
823
// set locks for the solver
827
bool ret = solving();
829
MIL << "SATResolver::resolveQueue() done. Ret:" << ret << endl;
833
/** \todo duplicate code to be joined with \ref solving. */
834
void SATResolver::doUpdate()
836
MIL << "SATResolver::doUpdate()" << endl;
839
solverInit(PoolItemList());
841
// set requirements for a running system
842
setSystemRequirements();
844
// set locks for the solver
847
_solv = solver_create( _SATPool );
848
::pool_set_custom_vendorcheck( _SATPool, &vendorCheck );
850
queue_push( &(_jobQueue), SOLVER_VERIFY|SOLVER_SOLVABLE_ALL);
851
queue_push( &(_jobQueue), 0 );
854
queue_push( &(_jobQueue), SOLVER_UPDATE|SOLVER_SOLVABLE_ALL);
855
queue_push( &(_jobQueue), 0 );
858
queue_push( &(_jobQueue), SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL);
859
queue_push( &(_jobQueue), 0 );
861
if (_distupgrade_removeunsupported) {
862
queue_push( &(_jobQueue), SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_ALL);
863
queue_push( &(_jobQueue), 0 );
865
solver_set_flag(_solv, SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, !_ignorealreadyrecommended);
866
solver_set_flag(_solv, SOLVER_FLAG_ALLOW_DOWNGRADE, _allowdowngrade);
867
solver_set_flag(_solv, SOLVER_FLAG_ALLOW_UNINSTALL, _allowuninstall);
868
solver_set_flag(_solv, SOLVER_FLAG_ALLOW_ARCHCHANGE, _allowarchchange);
869
solver_set_flag(_solv, SOLVER_FLAG_ALLOW_VENDORCHANGE, _allowvendorchange);
870
solver_set_flag(_solv, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
871
solver_set_flag(_solv, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
872
solver_set_flag(_solv, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
874
sat::Pool::instance().prepareForSolving();
877
MIL << "Starting solving for update...." << endl;
879
solver_solve( _solv, &(_jobQueue) );
880
MIL << "....Solver end" << endl;
882
// copying solution back to zypp pool
883
//-----------------------------------------
885
/* solvables to be installed */
887
queue_init(&decisionq);
888
solver_get_decisionqueue(_solv, &decisionq);
889
for (int i = 0; i < decisionq.count; i++)
892
p = decisionq.elements[i];
893
if (p < 0 || !sat::Solvable(p))
895
if (sat::Solvable(p).repository().get() == _solv->pool->installed)
898
PoolItem poolItem = _pool.find (sat::Solvable(p));
900
SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
902
ERR << "id " << p << " not found in ZYPP pool." << endl;
905
queue_free(&decisionq);
907
/* solvables to be erased */
908
for (int i = _solv->pool->installed->start; i < _solv->pool->installed->start + _solv->pool->installed->nsolvables; i++)
910
if (solver_get_decisionlevel(_solv, i) > 0)
913
PoolItem poolItem( _pool.find( sat::Solvable(i) ) );
915
// Check if this is an update
916
CheckIfUpdate info( (sat::Solvable(i)) );
917
invokeOnEach( _pool.byIdentBegin( poolItem ),
918
_pool.byIdentEnd( poolItem ),
919
resfilter::ByUninstalled(), // ByUninstalled
920
functor::functorRef<bool,PoolItem> (info) );
922
if (info.is_updated) {
923
SATSolutionToPool (poolItem, ResStatus::toBeUninstalledDueToUpgrade , ResStatus::SOLVER);
925
SATSolutionToPool (poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER);
928
ERR << "id " << i << " not found in ZYPP pool." << endl;
931
MIL << "SATResolver::doUpdate() done" << endl;
936
//----------------------------------------------------------------------------
937
//----------------------------------------------------------------------------
939
//----------------------------------------------------------------------------
940
//----------------------------------------------------------------------------
942
//----------------------------------------------------------------------------
944
//----------------------------------------------------------------------------
946
struct FindPackage : public resfilter::ResObjectFilterFunctor
948
ProblemSolutionCombi *problemSolution;
949
TransactionKind action;
950
FindPackage (ProblemSolutionCombi *p, const TransactionKind act)
951
: problemSolution (p)
956
bool operator()( PoolItem p)
958
problemSolution->addSingleAction (p, action);
964
//----------------------------------------------------------------------------
965
// Checking if this solvable/item has a buddy which reflect the real
966
// user visible description of an item
967
// e.g. The release package has a buddy to the concerning product item.
968
// This user want's the message "Product foo conflicts with product bar" and
969
// NOT "package release-foo conflicts with package release-bar"
970
// (ma: that's why we should map just packages to buddies, not vice versa)
971
//----------------------------------------------------------------------------
972
inline sat::Solvable mapBuddy( const PoolItem & item_r )
974
if ( item_r.satSolvable().isKind<Package>() )
976
sat::Solvable buddy = item_r.buddy();
980
return item_r.satSolvable();
982
inline sat::Solvable mapBuddy( sat::Solvable item_r )
983
{ return mapBuddy( PoolItem( item_r ) ); }
985
PoolItem SATResolver::mapItem ( const PoolItem & item )
986
{ return PoolItem( mapBuddy( item ) ); }
988
sat::Solvable SATResolver::mapSolvable ( const Id & id )
989
{ return mapBuddy( sat::Solvable(id) ); }
991
string SATResolver::SATprobleminfoString(Id problem, string &detail, Id &ignoreId)
994
Pool *pool = _solv->pool;
996
Id dep, source, target;
1000
probr = solver_findproblemrule(_solv, problem);
1001
switch (solver_ruleinfo(_solv, probr, &source, &target, &dep))
1003
case SOLVER_RULE_DISTUPGRADE:
1004
s = mapSolvable (source);
1005
ret = str::form (_("%s does not belong to a distupgrade repository"), s.asString().c_str());
1007
case SOLVER_RULE_INFARCH:
1008
s = mapSolvable (source);
1009
ret = str::form (_("%s has inferior architecture"), s.asString().c_str());
1011
case SOLVER_RULE_UPDATE:
1012
s = mapSolvable (source);
1013
ret = str::form (_("problem with installed package %s"), s.asString().c_str());
1015
case SOLVER_RULE_JOB:
1016
ret = _("conflicting requests");
1018
case SOLVER_RULE_RPM:
1019
ret = _("some dependency problem");
1021
case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
1022
ret = str::form (_("nothing provides requested %s"), pool_dep2str(pool, dep));
1023
detail += _("Have you enabled all requested repositories?");
1025
case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
1026
ret = str::form (_("package %s does not exist"), pool_dep2str(pool, dep));
1027
detail += _("Have you enabled all requested repositories?");
1029
case SOLVER_RULE_JOB_UNSUPPORTED:
1030
ret = _("unsupported request");
1032
case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
1033
ret = str::form (_("%s is provided by the system and cannot be erased"), pool_dep2str(pool, dep));
1035
case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1036
s = mapSolvable (source);
1037
ret = str::form (_("%s is not installable"), s.asString().c_str());
1039
case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1040
ignoreId = source; // for setting weak dependencies
1041
s = mapSolvable (source);
1042
ret = str::form (_("nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
1044
case SOLVER_RULE_RPM_SAME_NAME:
1045
s = mapSolvable (source);
1046
s2 = mapSolvable (target);
1047
ret = str::form (_("cannot install both %s and %s"), s.asString().c_str(), s2.asString().c_str());
1049
case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1050
s = mapSolvable (source);
1051
s2 = mapSolvable (target);
1052
ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1054
case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1055
s = mapSolvable (source);
1056
s2 = mapSolvable (target);
1057
ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1059
case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1060
s = mapSolvable (source);
1061
s2 = mapSolvable (target);
1062
ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
1064
case SOLVER_RULE_RPM_SELF_CONFLICT:
1065
s = mapSolvable (source);
1066
ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
1068
case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1069
ignoreId = source; // for setting weak dependencies
1070
s = mapSolvable (source);
1071
Capability cap(dep);
1072
sat::WhatProvides possibleProviders(cap);
1074
// check, if a provider will be deleted
1075
typedef list<PoolItem> ProviderList;
1076
ProviderList providerlistInstalled, providerlistUninstalled;
1077
for_( iter1, possibleProviders.begin(), possibleProviders.end() ) {
1078
PoolItem provider1 = ResPool::instance().find( *iter1 );
1079
// find pair of an installed/uninstalled item with the same NVR
1081
for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
1082
PoolItem provider2 = ResPool::instance().find( *iter2 );
1083
if (compareByNVR (provider1.resolvable(),provider2.resolvable()) == 0
1084
&& ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
1085
|| (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
1091
if (provider1.status().isInstalled())
1092
providerlistInstalled.push_back(provider1);
1094
providerlistUninstalled.push_back(provider1);
1098
ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
1099
if (providerlistInstalled.size() > 0) {
1100
detail += _("deleted providers: ");
1101
for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
1102
if (iter == providerlistInstalled.begin())
1103
detail += itemToString( *iter );
1105
detail += "\n " + itemToString( mapItem(*iter) );
1108
if (providerlistUninstalled.size() > 0) {
1109
if (detail.size() > 0)
1110
detail += _("\nuninstallable providers: ");
1112
detail = _("uninstallable providers: ");
1113
for (ProviderList::const_iterator iter = providerlistUninstalled.begin(); iter != providerlistUninstalled.end(); iter++) {
1114
if (iter == providerlistUninstalled.begin())
1115
detail += itemToString( *iter );
1117
detail += "\n " + itemToString( mapItem(*iter) );
1127
SATResolver::problems ()
1129
ResolverProblemList resolverProblems;
1130
if (_solv && solver_problem_count(_solv)) {
1131
Pool *pool = _solv->pool;
1134
Id problem, solution, element;
1135
sat::Solvable s, sd;
1137
CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1138
CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1140
MIL << "Encountered problems! Here are the solutions:\n" << endl;
1143
while ((problem = solver_next_problem(_solv, problem)) != 0) {
1144
MIL << "Problem " << pcnt++ << ":" << endl;
1145
MIL << "====================================" << endl;
1148
string whatString = SATprobleminfoString (problem,detail,ignoreId);
1149
MIL << whatString << endl;
1150
MIL << "------------------------------------" << endl;
1151
ResolverProblem_Ptr resolverProblem = new ResolverProblem (whatString, detail);
1154
while ((solution = solver_next_solution(_solv, problem, solution)) != 0) {
1156
ProblemSolutionCombi *problemSolution = new ProblemSolutionCombi(resolverProblem);
1157
while ((element = solver_next_solutionelement(_solv, problem, solution, element, &p, &rp)) != 0) {
1158
if (p == SOLVER_SOLUTION_JOB) {
1159
/* job, rp is index into job queue */
1160
what = _jobQueue.elements[rp];
1161
switch (_jobQueue.elements[rp-1]&(SOLVER_SELECTMASK|SOLVER_JOBMASK))
1163
case SOLVER_INSTALL | SOLVER_SOLVABLE: {
1164
s = mapSolvable (what);
1165
PoolItem poolItem = _pool.find (s);
1167
if (pool->installed && s.get()->repo == pool->installed) {
1168
problemSolution->addSingleAction (poolItem, REMOVE);
1169
string description = str::form (_("do not keep %s installed"), s.asString().c_str() );
1170
MIL << description << endl;
1171
problemSolution->addDescription (description);
1173
problemSolution->addSingleAction (poolItem, KEEP);
1174
string description = str::form (_("do not install %s"), s.asString().c_str());
1175
MIL << description << endl;
1176
problemSolution->addDescription (description);
1179
ERR << "SOLVER_INSTALL_SOLVABLE: No item found for " << s.asString() << endl;
1183
case SOLVER_ERASE | SOLVER_SOLVABLE: {
1184
s = mapSolvable (what);
1185
PoolItem poolItem = _pool.find (s);
1187
if (pool->installed && s.get()->repo == pool->installed) {
1188
problemSolution->addSingleAction (poolItem, KEEP);
1189
string description = str::form (_("keep %s"), s.asString().c_str());
1190
MIL << description << endl;
1191
problemSolution->addDescription (description);
1193
problemSolution->addSingleAction (poolItem, UNLOCK);
1194
string description = str::form (_("do not forbid installation of %s"), itemToString( poolItem ).c_str());
1195
MIL << description << endl;
1196
problemSolution->addDescription (description);
1199
ERR << "SOLVER_ERASE_SOLVABLE: No item found for " << s.asString() << endl;
1203
case SOLVER_INSTALL | SOLVER_SOLVABLE_NAME:
1205
IdString ident( what );
1206
SolverQueueItemInstall_Ptr install =
1207
new SolverQueueItemInstall(_pool, ident.asString(), false );
1208
problemSolution->addSingleAction (install, REMOVE_SOLVE_QUEUE_ITEM);
1210
string description = str::form (_("do not install %s"), ident.c_str() );
1211
MIL << description << endl;
1212
problemSolution->addDescription (description);
1215
case SOLVER_ERASE | SOLVER_SOLVABLE_NAME:
1217
// As we do not know, if this request has come from resolvePool or
1218
// resolveQueue we will have to take care for both cases.
1219
IdString ident( what );
1220
FindPackage info (problemSolution, KEEP);
1221
invokeOnEach( _pool.byIdentBegin( ident ),
1222
_pool.byIdentEnd( ident ),
1223
functor::chain (resfilter::ByInstalled (), // ByInstalled
1224
resfilter::ByTransact ()), // will be deinstalled
1225
functor::functorRef<bool,PoolItem> (info) );
1227
SolverQueueItemDelete_Ptr del =
1228
new SolverQueueItemDelete(_pool, ident.asString(), false );
1229
problemSolution->addSingleAction (del, REMOVE_SOLVE_QUEUE_ITEM);
1231
string description = str::form (_("keep %s"), ident.c_str());
1232
MIL << description << endl;
1233
problemSolution->addDescription (description);
1236
case SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES:
1238
problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_REQUIRE);
1239
string description = "";
1241
// Checking if this problem solution would break your system
1242
if (system_requires.find(Capability(what)) != system_requires.end()) {
1243
// Show a better warning
1244
resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1245
resolverProblem->setDescription(_("This request will break your system!"));
1246
description = _("ignore the warning of a broken system");
1247
description += string(" (requires:")+pool_dep2str(pool, what)+")";
1248
MIL << description << endl;
1249
problemSolution->addFrontDescription (description);
1251
description = str::form (_("do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
1252
MIL << description << endl;
1253
problemSolution->addDescription (description);
1257
case SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES:
1259
problemSolution->addSingleAction (Capability(what), REMOVE_EXTRA_CONFLICT);
1260
string description = "";
1262
// Checking if this problem solution would break your system
1263
if (system_conflicts.find(Capability(what)) != system_conflicts.end()) {
1264
// Show a better warning
1265
resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
1266
resolverProblem->setDescription(_("This request will break your system!"));
1267
description = _("ignore the warning of a broken system");
1268
description += string(" (conflicts:")+pool_dep2str(pool, what)+")";
1269
MIL << description << endl;
1270
problemSolution->addFrontDescription (description);
1273
description = str::form (_("do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
1274
MIL << description << endl;
1275
problemSolution->addDescription (description);
1279
case SOLVER_UPDATE | SOLVER_SOLVABLE:
1281
s = mapSolvable (what);
1282
PoolItem poolItem = _pool.find (s);
1284
if (pool->installed && s.get()->repo == pool->installed) {
1285
problemSolution->addSingleAction (poolItem, KEEP);
1286
string description = str::form (_("do not install most recent version of %s"), s.asString().c_str());
1287
MIL << description << endl;
1288
problemSolution->addDescription (description);
1290
ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE " << poolItem << " is not selected for installation" << endl;
1293
ERR << "SOLVER_INSTALL_SOLVABLE_UPDATE: No item found for " << s.asString() << endl;
1298
MIL << "- do something different" << endl;
1299
ERR << "No valid solution available" << endl;
1302
} else if (p == SOLVER_SOLUTION_INFARCH) {
1303
s = mapSolvable (rp);
1304
PoolItem poolItem = _pool.find (s);
1305
if (pool->installed && s.get()->repo == pool->installed) {
1306
problemSolution->addSingleAction (poolItem, LOCK);
1307
string description = str::form (_("keep %s despite the inferior architecture"), s.asString().c_str());
1308
MIL << description << endl;
1309
problemSolution->addDescription (description);
1311
problemSolution->addSingleAction (poolItem, INSTALL);
1312
string description = str::form (_("install %s despite the inferior architecture"), s.asString().c_str());
1313
MIL << description << endl;
1314
problemSolution->addDescription (description);
1316
} else if (p == SOLVER_SOLUTION_DISTUPGRADE) {
1317
s = mapSolvable (rp);
1318
PoolItem poolItem = _pool.find (s);
1319
if (pool->installed && s.get()->repo == pool->installed) {
1320
problemSolution->addSingleAction (poolItem, LOCK);
1321
string description = str::form (_("keep obsolete %s"), s.asString().c_str());
1322
MIL << description << endl;
1323
problemSolution->addDescription (description);
1325
problemSolution->addSingleAction (poolItem, INSTALL);
1326
string description = str::form (_("install %s from excluded repository"), s.asString().c_str());
1327
MIL << description << endl;
1328
problemSolution->addDescription (description);
1331
/* policy, replace p with rp */
1332
s = mapSolvable (p);
1333
PoolItem itemFrom = _pool.find (s);
1338
sd = mapSolvable (rp);
1339
PoolItem itemTo = _pool.find (sd);
1340
if (itemFrom && itemTo) {
1341
problemSolution->addSingleAction (itemTo, INSTALL);
1342
int illegal = policy_is_illegal(_solv, s.get(), sd.get(), 0);
1344
if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
1346
string description = str::form (_("downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1347
MIL << description << endl;
1348
problemSolution->addDescription (description);
1351
if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
1353
string description = str::form (_("architecture change of %s to %s"), s.asString().c_str(), sd.asString().c_str());
1354
MIL << description << endl;
1355
problemSolution->addDescription (description);
1358
if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
1360
IdString s_vendor( s.vendor() );
1361
IdString sd_vendor( sd.vendor() );
1362
string description = str::form (_("install %s (with vendor change)\n %s --> %s") ,
1363
sd.asString().c_str(),
1364
( s_vendor ? s_vendor.c_str() : " (no vendor) " ),
1365
( sd_vendor ? sd_vendor.c_str() : " (no vendor) " ) );
1366
MIL << description << endl;
1367
problemSolution->addDescription (description);
1371
string description = str::form (_("replacement of %s with %s"), s.asString().c_str(), sd.asString().c_str());
1372
MIL << description << endl;
1373
problemSolution->addDescription (description);
1376
ERR << s.asString() << " or " << sd.asString() << " not found" << endl;
1382
string description = str::form (_("deinstallation of %s"), s.asString().c_str());
1383
MIL << description << endl;
1384
problemSolution->addDescription (description);
1385
problemSolution->addSingleAction (itemFrom, REMOVE);
1390
resolverProblem->addSolution (problemSolution,
1391
problemSolution->actionCount() > 1 ? true : false); // Solutions with more than 1 action will be shown first.
1392
MIL << "------------------------------------" << endl;
1396
// There is a possibility to ignore this error by setting weak dependencies
1397
PoolItem item = _pool.find (sat::Solvable(ignoreId));
1398
ProblemSolutionIgnore *problemSolution = new ProblemSolutionIgnore(resolverProblem, item);
1399
resolverProblem->addSolution (problemSolution,
1400
false); // Solutions will be shown at the end
1401
MIL << "ignore some dependencies of " << item << endl;
1402
MIL << "------------------------------------" << endl;
1406
resolverProblems.push_back (resolverProblem);
1409
return resolverProblems;
1413
SATResolver::applySolutions (const ProblemSolutionList & solutions)
1415
for (ProblemSolutionList::const_iterator iter = solutions.begin();
1416
iter != solutions.end(); ++iter) {
1417
ProblemSolution_Ptr solution = *iter;
1418
Resolver dummyResolver(_pool);
1419
if (!solution->apply (dummyResolver))
1424
void SATResolver::setLocks()
1426
for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); ++iter) {
1427
sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
1428
if (iter->status().isInstalled()) {
1429
MIL << "Lock installed item " << *iter << endl;
1430
queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
1431
queue_push( &(_jobQueue), ident );
1433
MIL << "Lock NOT installed item " << *iter << endl;
1434
queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
1435
queue_push( &(_jobQueue), ident );
1439
///////////////////////////////////////////////////////////////////
1440
// Weak locks: Ignore if an item with this name is already installed.
1441
// If it's not installed try to keep it this way using a weak delete
1442
///////////////////////////////////////////////////////////////////
1443
std::set<IdString> unifiedByName;
1444
for (PoolItemList::const_iterator iter = _items_to_keep.begin(); iter != _items_to_keep.end(); ++iter) {
1445
IdString ident( (*iter)->satSolvable().ident() );
1446
if ( unifiedByName.insert( ident ).second )
1448
if ( ! ui::Selectable::get( *iter )->hasInstalledObj() )
1450
MIL << "Keep NOT installed name " << ident << " (" << *iter << ")" << endl;
1451
queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK | MAYBE_CLEANDEPS );
1452
queue_push( &(_jobQueue), ident.id() );
1458
void SATResolver::setSystemRequirements()
1460
CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap();
1461
CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap();
1463
for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); ++iter) {
1464
queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES );
1465
queue_push( &(_jobQueue), iter->id() );
1466
MIL << "SYSTEM Requires " << *iter << endl;
1469
for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); ++iter) {
1470
queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE_PROVIDES | MAYBE_CLEANDEPS );
1471
queue_push( &(_jobQueue), iter->id() );
1472
MIL << "SYSTEM Conflicts " << *iter << endl;
1475
// Lock the architecture of the running systems rpm
1476
// package on distupgrade.
1477
if ( _distupgrade && ZConfig::instance().systemRoot() == "/" )
1479
ResPool pool( ResPool::instance() );
1480
IdString rpm( "rpm" );
1481
for_( it, pool.byIdentBegin(rpm), pool.byIdentEnd(rpm) )
1483
if ( (*it)->isSystem() )
1485
Capability archrule( (*it)->arch(), rpm.c_str(), Capability::PARSED );
1486
queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_ESSENTIAL );
1487
queue_push( &(_jobQueue), archrule.id() );
1495
///////////////////////////////////////////////////////////////////
1496
};// namespace detail
1497
/////////////////////////////////////////////////////////////////////
1498
/////////////////////////////////////////////////////////////////////
1499
};// namespace solver
1500
///////////////////////////////////////////////////////////////////////
1501
///////////////////////////////////////////////////////////////////////
1503
/////////////////////////////////////////////////////////////////////////