flag if the solver regards required packages only
authorStefan Schubert <schubi@suse.de>
Fri, 28 Mar 2008 14:56:27 +0000 (14:56 +0000)
committerStefan Schubert <schubi@suse.de>
Fri, 28 Mar 2008 14:56:27 +0000 (14:56 +0000)
- defined in zypp.conf
- can be overwritten in the API

zypp.conf
zypp/Resolver.cc
zypp/Resolver.h
zypp/ZConfig.cc
zypp/ZConfig.h
zypp/sat/SATResolver.cc
zypp/sat/SATResolver.h
zypp/solver/detail/Resolver.cc
zypp/solver/detail/Resolver.h

index fea1890..21fcb9f 100644 (file)
--- a/zypp.conf
+++ b/zypp.conf
 ##
 # 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
index 290e4ed..a0b15ed 100644 (file)
@@ -12,6 +12,7 @@
 #include <iostream>
 
 #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 ); }
index 8898d62..4c0fe34 100644 (file)
@@ -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
      *
      */
index 01546d0..88e7f60 100644 (file)
@@ -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
 ///////////////////////////////////////////////////////////////////
index e2d90bf..fd22798 100644 (file)
@@ -138,6 +138,11 @@ namespace zypp
        */
       Pathname vendorPath() const;
 
+      /**
+       * Solver regards required packages,patterns,... only
+       */      
+      bool solver_onlyRequires() const;
+
     public:
       class Impl;
       /** Dtor */
index 4a10bc3..36821b2 100644 (file)
@@ -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();
 
index 9a77fe9..43210de 100644 (file)
@@ -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);
 };
index d44ae77..a967772 100644 (file)
@@ -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);
index b9db4c7..c057e22 100644 (file)
@@ -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();