From 7a57589884d97946f3f19947502f3705f82862c3 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Fri, 28 Mar 2008 14:56:27 +0000 Subject: [PATCH] flag if the solver regards required packages only - defined in zypp.conf - can be overwritten in the API --- zypp.conf | 9 +++++++++ zypp/Resolver.cc | 18 ++++++++++++++++++ zypp/Resolver.h | 9 +++++++++ zypp/ZConfig.cc | 21 +++++++++++++++------ zypp/ZConfig.h | 5 +++++ zypp/sat/SATResolver.cc | 3 +++ zypp/sat/SATResolver.h | 24 ++++++++++++++---------- zypp/solver/detail/Resolver.cc | 11 +++++++++++ zypp/solver/detail/Resolver.h | 25 ++++++++++++++++++++----- 9 files changed, 104 insertions(+), 21 deletions(-) diff --git a/zypp.conf b/zypp.conf index fea1890..21fcb9f 100644 --- a/zypp.conf +++ b/zypp.conf @@ -133,3 +133,12 @@ ## # vendordir = /etc/zypp/vendors.d +## +## Whether required packages are installed ONLY +## So recommended packages, language packages and packages which depend +## on hardware (modalias) will not be regarded. +## +## Valid values: boolean +## Default value: false +## +# solver.onlyRequires = false \ No newline at end of file diff --git a/zypp/Resolver.cc b/zypp/Resolver.cc index 290e4ed..a0b15ed 100644 --- a/zypp/Resolver.cc +++ b/zypp/Resolver.cc @@ -12,6 +12,7 @@ #include #include "zypp/Resolver.h" +#include "zypp/ZConfig.h" #include "zypp/UpgradeStatistics.h" #include "zypp/solver/detail/Resolver.h" #include "zypp/solver/detail/Testcase.h" @@ -22,6 +23,8 @@ using namespace std; namespace zypp { ///////////////////////////////////////////////////////////////// + using namespace solver; + IMPL_PTR_TYPE(Resolver); #if 0 Resolver_Ptr Resolver::_resolver = NULL; @@ -72,6 +75,21 @@ namespace zypp { _pimpl->setForceResolve( force ); } bool Resolver::forceResolve() { return _pimpl->forceResolve(); } + void Resolver::setOnlyRequires( const bool onlyRequires ) + { onlyRequires ? _pimpl->setOnlyRequires( TRUE ) : _pimpl->setOnlyRequires( FALSE ); } + void Resolver::resetOnlyRequires() + { _pimpl->setOnlyRequires( DEFAULT ); } + bool Resolver::onlyRequires() + { + switch (_pimpl->onlyRequires()) { + case DEFAULT: + return ZConfig::instance().solver_onlyRequires(); + case TRUE: + return true; + case FALSE: + return false; + }; + } void Resolver::addRequire (const Capability & capability) { _pimpl->addExtraRequire( capability ); } diff --git a/zypp/Resolver.h b/zypp/Resolver.h index 8898d62..4c0fe34 100644 --- a/zypp/Resolver.h +++ b/zypp/Resolver.h @@ -122,6 +122,15 @@ namespace zypp bool forceResolve(); /** + * Setting whether required packages are installed ONLY + * So recommended packages, language packages and packages which depend + * on hardware (modalias) will not be regarded. + **/ + void setOnlyRequires (const bool onlyRequires); + void resetOnlyRequires(); // set back to default (described in zypp.conf) + bool onlyRequires(); + + /** * Adding additional requirement * */ diff --git a/zypp/ZConfig.cc b/zypp/ZConfig.cc index 01546d0..88e7f60 100644 --- a/zypp/ZConfig.cc +++ b/zypp/ZConfig.cc @@ -142,12 +142,13 @@ namespace zypp { public: Impl( const Pathname & override_r = Pathname() ) - : cfg_arch ( defaultSystemArchitecture() ) - , cfg_textLocale ( defaultTextLocale() ) - , repo_add_probe ( false ) - , repo_refresh_delay ( 10 ) - , download_use_patchrpm ( true ) - , download_use_deltarpm ( true ) + : cfg_arch ( defaultSystemArchitecture() ) + , cfg_textLocale ( defaultTextLocale() ) + , repo_add_probe ( false ) + , repo_refresh_delay ( 10 ) + , download_use_patchrpm ( true ) + , download_use_deltarpm ( true ) + , solver_onlyRequires ( false ) { MIL << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl; @@ -232,6 +233,10 @@ namespace zypp { cfg_packages_path = Pathname(value); } + else if ( entry == "solver.onlyRequires" ) + { + solver_onlyRequires = str::strToBool( value, solver_onlyRequires ); + } } } } @@ -276,6 +281,7 @@ namespace zypp bool download_use_patchrpm; bool download_use_deltarpm; + bool solver_onlyRequires; }; /////////////////////////////////////////////////////////////////// @@ -418,6 +424,9 @@ namespace zypp ? Pathname("/etc/zypp/vendors.d") : _pimpl->cfg_vendor_path ); } + bool ZConfig::solver_onlyRequires() const + { return _pimpl->solver_onlyRequires; } + ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// diff --git a/zypp/ZConfig.h b/zypp/ZConfig.h index e2d90bf..fd22798 100644 --- a/zypp/ZConfig.h +++ b/zypp/ZConfig.h @@ -138,6 +138,11 @@ namespace zypp */ Pathname vendorPath() const; + /** + * Solver regards required packages,patterns,... only + */ + bool solver_onlyRequires() const; + public: class Impl; /** Dtor */ diff --git a/zypp/sat/SATResolver.cc b/zypp/sat/SATResolver.cc index 4a10bc3..36821b2 100644 --- a/zypp/sat/SATResolver.cc +++ b/zypp/sat/SATResolver.cc @@ -30,6 +30,7 @@ #include "zypp/base/Algorithm.h" #include "zypp/ResPool.h" #include "zypp/ResFilters.h" +#include "zypp/ZConfig.h" #include "zypp/sat/SATResolver.h" #include "zypp/sat/Pool.h" #include "zypp/sat/WhatProvides.h" @@ -121,6 +122,7 @@ SATResolver::SATResolver (const ResPool & pool, Pool *SATPool) , _allowvirtualconflicts(false) , _noupdateprovide(false) , _dosplitprovides(false) + , _onlyRequires(ZConfig::instance().solver_onlyRequires()) { } @@ -453,6 +455,7 @@ SATResolver::resolvePool(const CapabilitySet & requires_caps, _solv->allowarchchange = _allowarchchange; _solv->dosplitprovides = _dosplitprovides; _solv->noupdateprovide = _noupdateprovide; + _solv->dontinstallrecommended = _onlyRequires; sat::Pool::instance().prepare(); diff --git a/zypp/sat/SATResolver.h b/zypp/sat/SATResolver.h index 9a77fe9..43210de 100644 --- a/zypp/sat/SATResolver.h +++ b/zypp/sat/SATResolver.h @@ -69,15 +69,16 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable { PoolItemList _items_to_remove; PoolItemList _items_to_lock; - bool _fixsystem; /* repair errors in rpm dependency graph */ - bool _allowdowngrade; /* allow to downgrade installed solvable */ - bool _allowarchchange; /* allow to change architecture of installed solvables */ - bool _allowvendorchange; /* allow to change vendor of installed solvables */ - bool _allowuninstall; /* allow removal of installed solvables */ - bool _updatesystem; /* distupgrade */ - bool _allowvirtualconflicts; /* false: conflicts on package name, true: conflicts on package provides */ - bool _noupdateprovide; /* true: update packages needs not to provide old package */ - bool _dosplitprovides; /* true: consider legacy split provides */ + bool _fixsystem; // repair errors in rpm dependency graph + bool _allowdowngrade; // allow to downgrade installed solvable + bool _allowarchchange; // allow to change architecture of installed solvables + bool _allowvendorchange; // allow to change vendor of installed solvables + bool _allowuninstall; // allow removal of installed solvables + bool _updatesystem; // distupgrade + bool _allowvirtualconflicts; // false: conflicts on package name, true: conflicts on package provides + bool _noupdateprovide; // true: update packages needs not to provide old package + bool _dosplitprovides; // true: consider legacy split provides + bool _onlyRequires; // true: consider required packages only // ---------------------------------- methods std::string SATprobleminfoString (Id problem, std::string &detail); @@ -133,9 +134,12 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable { bool noupdateprovide () const {return _noupdateprovide;} void setNoupdateprovide ( const bool noupdateprovide) { _noupdateprovide = noupdateprovide;} - + bool dosplitprovides () const {return _dosplitprovides;} void setDosplitprovides ( const bool dosplitprovides) { _dosplitprovides = dosplitprovides;} + + bool onlyRequires () const {return _onlyRequires;} + void setOnlyRequires ( const bool onlyRequires) { _onlyRequires = onlyRequires;} bool doesObsoleteItem (PoolItem candidate, PoolItem installed); }; diff --git a/zypp/solver/detail/Resolver.cc b/zypp/solver/detail/Resolver.cc index d44ae77..a967772 100644 --- a/zypp/solver/detail/Resolver.cc +++ b/zypp/solver/detail/Resolver.cc @@ -25,6 +25,7 @@ #include "zypp/solver/detail/Testcase.h" #include "zypp/Capabilities.h" +#include "zypp/ZConfig.h" #include "zypp/base/Logger.h" #include "zypp/base/String.h" #include "zypp/base/Gettext.h" @@ -71,6 +72,7 @@ Resolver::Resolver (const ResPool & pool) , _forceResolve(false) , _upgradeMode(false) , _verifying(false) + , _onlyRequires(DEFAULT) { sat::Pool satPool( sat::Pool::instance() ); @@ -287,6 +289,15 @@ Resolver::resolvePool() if (_forceResolve) _satResolver->setAllowuninstall(true); + + switch (_onlyRequires) { + case DEFAULT: + _satResolver->setOnlyRequires(ZConfig::instance().solver_onlyRequires()); + case TRUE: + _satResolver->setOnlyRequires(true); + case FALSE: + _satResolver->setOnlyRequires(false); + } if (_verifying) _satResolver->setFixsystem(true); diff --git a/zypp/solver/detail/Resolver.h b/zypp/solver/detail/Resolver.h index b9db4c7..c057e22 100644 --- a/zypp/solver/detail/Resolver.h +++ b/zypp/solver/detail/Resolver.h @@ -50,6 +50,14 @@ namespace zypp namespace solver { ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// + + enum TriState + { + FALSE, + TRUE, + DEFAULT + }; + namespace detail { /////////////////////////////////////////////////////////////////// @@ -95,11 +103,14 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable { PoolItemList _ignoreVendorItem; - bool _forceResolve; // remove items which are conflicts with others or - // have unfulfilled requirements. - // This behaviour is favourited by ZMD - bool _upgradeMode; // Resolver has been called with doUpgrade - bool _verifying; // The system will be checked + bool _forceResolve; // remove items which are conflicts with others or + // have unfulfilled requirements. + // This behaviour is favourited by ZMD + bool _upgradeMode; // Resolver has been called with doUpgrade + bool _verifying; // The system will be checked + TriState _onlyRequires; // do install required resolvables only + // no recommended resolvables, language + // packages, hardware packages (modalias) // helpers bool doesObsoleteCapability (PoolItem candidate, const Capability & cap); @@ -146,6 +157,10 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable { void setForceResolve (const bool force) { _forceResolve = force; } bool forceResolve() { return _forceResolve; } + void setOnlyRequires (const TriState state) + { _onlyRequires = state; } + TriState onlyRequires () { return _onlyRequires; } + bool verifySystem (); bool resolvePool(); -- 2.7.4