Imported Upstream version 17.30.0 upstream/17.30.0
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 20 Sep 2022 06:40:55 +0000 (15:40 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 20 Sep 2022 06:40:55 +0000 (15:40 +0900)
VERSION.cmake
package/libzypp.changes
zypp/Resolver.cc
zypp/Resolver.h
zypp/ZConfig.cc
zypp/ZConfig.h
zypp/solver/detail/Resolver.cc
zypp/solver/detail/Resolver.h
zypp/target/TargetImpl.h
zypp/zypp_detail/ZYppImpl.cc
zypp/zypp_detail/ZYppImpl.h

index ac0296b..246d276 100644 (file)
@@ -60,9 +60,9 @@
 #
 SET(LIBZYPP_MAJOR "17")
 SET(LIBZYPP_COMPATMINOR "22")
-SET(LIBZYPP_MINOR "29")
-SET(LIBZYPP_PATCH "7")
+SET(LIBZYPP_MINOR "30")
+SET(LIBZYPP_PATCH "0")
 #
-# LAST RELEASED: 17.29.7 (22)
+# LAST RELEASED: 17.30.0 (22)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index 44269c4..7c2a680 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Fri Mar 25 17:08:46 CET 2022 - ma@suse.de
+
+- ZConfig: Update solver settings if target changes (bsc#1196368)
+- version 17.30.0 (22)
+
+-------------------------------------------------------------------
 Mon Mar 21 09:04:36 CET 2022 - ma@suse.de
 
 - Fix possible hang in singletrans mode (bsc#1197134)
@@ -8,7 +14,7 @@ Mon Mar 21 09:04:36 CET 2022 - ma@suse.de
 -------------------------------------------------------------------
 Mon Mar 14 15:40:04 CET 2022 - ma@suse.de
 
-- Fix package signature check (bsc#184501)
+- Fix package signature check (bsc#1184501)
   Pay attention that header and payload are secured by a valid
   signature and report more detailed which signature is missing.
 - Retry umount if device is busy (bsc#1196061, closes #381)
index 3df37dc..81d8bb6 100644 (file)
@@ -50,6 +50,9 @@ namespace zypp
   //   Resolver interface forwarded to implementation
   //
   ///////////////////////////////////////////////////////////////////
+  void Resolver::setDefaultSolverFlags( bool all_r )
+  { return _pimpl->setDefaultSolverFlags( all_r ); }
+
   sat::detail::CSolver * Resolver::get() const
   { return _pimpl->get(); }
 
index 4c706ed..0602d93 100644 (file)
@@ -51,6 +51,19 @@ namespace zypp
     virtual ~Resolver();
 
     /**
+     * Reset all solver flags to the systems default (e.g. from zypp.conf).
+     *
+     * Call this to discard all settings you explicitly applied here. All flags
+     * are adjusted to follow the current systems default. If you want to reset
+     * just a specific flag, call its 'setDefault...' method.
+     *
+     * Calling the method with \a all_r is set to \c false, is used internally.
+     * It updates only those flags which were not explicitly changed. E.g after
+     * switching to a target which uses different defaults in its zypp.conf..
+     */
+    void setDefaultSolverFlags( bool all_r = true );
+
+    /**
      * Resolve package dependencies:
      *
      * Enter \ref systemVerification mode to monitor and repair dependencies
index 5a71be8..5fd3265 100644 (file)
@@ -21,6 +21,7 @@ extern "C"
 }
 #include <iostream>
 #include <fstream>
+#include <optional>
 #include <zypp/base/LogTools.h>
 #include <zypp/base/IOStream.h>
 #include <zypp-core/base/InputStream>
@@ -315,9 +316,85 @@ namespace zypp
   {
     typedef std::set<std::string> MultiversionSpec;
 
+    /// Settings that follow a changed Target
+    struct TargetDefaults
+    {
+      TargetDefaults()
+      : solver_focus                        ( ResolverFocus::Default )
+      , solver_onlyRequires                 ( false )
+      , solver_allowVendorChange            ( false )
+      , solver_dupAllowDowngrade            ( true )
+      , solver_dupAllowNameChange           ( true )
+      , solver_dupAllowArchChange           ( true )
+      , solver_dupAllowVendorChange         ( true )
+      , solver_cleandepsOnRemove            ( false )
+      , solver_upgradeTestcasesToKeep       ( 2 )
+      , solverUpgradeRemoveDroppedPackages  ( true )
+      {}
+
+      bool consume( const std::string & entry, const std::string & value )
+      {
+        if ( entry == "solver.focus" )
+        {
+          fromString( value, solver_focus );
+        }
+        else if ( entry == "solver.onlyRequires" )
+        {
+          solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires ) );
+        }
+        else if ( entry == "solver.allowVendorChange" )
+        {
+          solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange ) );
+        }
+        else if ( entry == "solver.dupAllowDowngrade" )
+        {
+          solver_dupAllowDowngrade.set( str::strToBool( value, solver_dupAllowDowngrade ) );
+        }
+        else if ( entry == "solver.dupAllowNameChange" )
+        {
+          solver_dupAllowNameChange.set( str::strToBool( value, solver_dupAllowNameChange ) );
+        }
+        else if ( entry == "solver.dupAllowArchChange" )
+        {
+          solver_dupAllowArchChange.set( str::strToBool( value, solver_dupAllowArchChange ) );
+        }
+        else if ( entry == "solver.dupAllowVendorChange" )
+        {
+          solver_dupAllowVendorChange.set( str::strToBool( value, solver_dupAllowVendorChange ) );
+        }
+        else if ( entry == "solver.cleandepsOnRemove" )
+        {
+          solver_cleandepsOnRemove.set( str::strToBool( value, solver_cleandepsOnRemove ) );
+        }
+        else if ( entry == "solver.upgradeTestcasesToKeep" )
+        {
+          solver_upgradeTestcasesToKeep.set( str::strtonum<unsigned>( value ) );
+        }
+        else if ( entry == "solver.upgradeRemoveDroppedPackages" )
+        {
+          solverUpgradeRemoveDroppedPackages.restoreToDefault( str::strToBool( value, solverUpgradeRemoveDroppedPackages.getDefault() ) );
+        }
+        else
+          return false;
+
+        return true;
+      }
+
+      ResolverFocus       solver_focus;
+      Option<bool>        solver_onlyRequires;
+      Option<bool>        solver_allowVendorChange;
+      Option<bool>        solver_dupAllowDowngrade;
+      Option<bool>        solver_dupAllowNameChange;
+      Option<bool>        solver_dupAllowArchChange;
+      Option<bool>        solver_dupAllowVendorChange;
+      Option<bool>        solver_cleandepsOnRemove;
+      Option<unsigned>    solver_upgradeTestcasesToKeep;
+      DefaultOption<bool> solverUpgradeRemoveDroppedPackages;
+    };
+
     public:
-      Impl( const Pathname & override_r = Pathname() )
-        : _parsedZyppConf              ( override_r )
+      Impl()
+        : _parsedZyppConf              ( _autodetectZyppConfPath() )
         , cfg_arch                     ( defaultSystemArchitecture() )
         , cfg_textLocale               ( defaultTextLocale() )
         , cfg_cache_path               { "/var/cache/zypp" }
@@ -336,36 +413,10 @@ namespace zypp
         , gpgCheck                     ( true )
         , repoGpgCheck                 ( indeterminate )
         , pkgGpgCheck                  ( indeterminate )
-        , solver_focus                 ( ResolverFocus::Default )
-        , solver_onlyRequires          ( false )
-        , solver_allowVendorChange     ( false )
-        , solver_dupAllowDowngrade     ( true )
-        , solver_dupAllowNameChange    ( true )
-        , solver_dupAllowArchChange    ( true )
-        , solver_dupAllowVendorChange  ( true )
-        , solver_cleandepsOnRemove     ( false )
-        , solver_upgradeTestcasesToKeep        ( 2 )
-        , solverUpgradeRemoveDroppedPackages( true )
         , apply_locks_file             ( true )
         , pluginsPath                  ( "/usr/lib/zypp/plugins" )
       {
         MIL << "libzypp: " LIBZYPP_VERSION_STRING << endl;
-        // override_r has higest prio
-        // ZYPP_CONF might override /etc/zypp/zypp.conf
-        if ( _parsedZyppConf.empty() )
-        {
-          _parsedZyppConf = _autodetectZyppConfPath();
-        }
-        else
-        {
-          // Inject this into ZConfig. Be shure this is
-          // allocated via new.
-          // ma: override_r might not be needed anymore since the
-          //     Vendor_test is now able to initialize VendorAttr directly.
-          INT << "Reconfigure to " << _parsedZyppConf << endl;
-          ZConfig::instance()._pimpl.reset( this );
-        }
-
         if ( PathInfo(_parsedZyppConf).isExist() )
         {
           parser::IniDict dict( _parsedZyppConf );
@@ -388,6 +439,9 @@ namespace zypp
               //DBG << (*it).first << "=" << (*it).second << endl;
               if ( section == "main" )
               {
+                if ( _initialTargetDefaults.consume( entry, value ) )
+                  continue;
+
                 if ( entry == "arch" )
                 {
                   Arch carch( value );
@@ -492,46 +546,6 @@ namespace zypp
                 {
                   cfg_kernel_keep_spec = value;
                 }
-                else if ( entry == "solver.focus" )
-                {
-                  fromString( value, solver_focus );
-                }
-                else if ( entry == "solver.onlyRequires" )
-                {
-                  solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires ) );
-                }
-                else if ( entry == "solver.allowVendorChange" )
-                {
-                  solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange ) );
-                }
-                else if ( entry == "solver.dupAllowDowngrade" )
-                {
-                  solver_dupAllowDowngrade.set( str::strToBool( value, solver_dupAllowDowngrade ) );
-                }
-                else if ( entry == "solver.dupAllowNameChange" )
-                {
-                  solver_dupAllowNameChange.set( str::strToBool( value, solver_dupAllowNameChange ) );
-                }
-                else if ( entry == "solver.dupAllowArchChange" )
-                {
-                  solver_dupAllowArchChange.set( str::strToBool( value, solver_dupAllowArchChange ) );
-                }
-                else if ( entry == "solver.dupAllowVendorChange" )
-                {
-                  solver_dupAllowVendorChange.set( str::strToBool( value, solver_dupAllowVendorChange ) );
-                }
-                else if ( entry == "solver.cleandepsOnRemove" )
-                {
-                  solver_cleandepsOnRemove.set( str::strToBool( value, solver_cleandepsOnRemove ) );
-                }
-                else if ( entry == "solver.upgradeTestcasesToKeep" )
-                {
-                  solver_upgradeTestcasesToKeep.set( str::strtonum<unsigned>( value ) );
-                }
-                else if ( entry == "solver.upgradeRemoveDroppedPackages" )
-                {
-                  solverUpgradeRemoveDroppedPackages.restoreToDefault( str::strToBool( value, solverUpgradeRemoveDroppedPackages.getDefault() ) );
-                }
                 else if ( entry == "solver.checkSystemFile" )
                 {
                   solver_checkSystemFile = Pathname(value);
@@ -591,8 +605,6 @@ namespace zypp
               }
             }
           }
-          //
-
         }
         else
         {
@@ -616,6 +628,30 @@ namespace zypp
       ~Impl()
       {}
 
+      void notifyTargetChanged()
+      {
+        Pathname newRoot { _autodetectSystemRoot() };
+        MIL << "notifyTargetChanged (" << newRoot << ")" << endl;
+
+        if ( newRoot.emptyOrRoot() ) {
+          _currentTargetDefaults.reset(); // to initial settigns from /
+        }
+        else {
+          _currentTargetDefaults = TargetDefaults();
+
+          Pathname newConf { newRoot/_autodetectZyppConfPath() };
+          if ( PathInfo(newConf).isExist() ) {
+            parser::IniDict dict( newConf );
+            for ( const auto & [entry,value] : dict.entries( "main" ) ) {
+              (*_currentTargetDefaults).consume( entry, value );
+            }
+          }
+          else {
+            MIL << _parsedZyppConf << " not found, using defaults." << endl;
+          }
+        }
+      }
+
     public:
     /** Remember any parsed zypp.conf. */
     Pathname _parsedZyppConf;
@@ -660,17 +696,6 @@ namespace zypp
     DefaultOption<TriBool>     repoGpgCheck;
     DefaultOption<TriBool>     pkgGpgCheck;
 
-    ResolverFocus      solver_focus;
-    Option<bool>       solver_onlyRequires;
-    Option<bool>       solver_allowVendorChange;
-    Option<bool>       solver_dupAllowDowngrade;
-    Option<bool>       solver_dupAllowNameChange;
-    Option<bool>       solver_dupAllowArchChange;
-    Option<bool>       solver_dupAllowVendorChange;
-    Option<bool>       solver_cleandepsOnRemove;
-    Option<unsigned>   solver_upgradeTestcasesToKeep;
-    DefaultOption<bool> solverUpgradeRemoveDroppedPackages;
-
     Pathname solver_checkSystemFile;
     Pathname solver_checkSystemFileDir;
 
@@ -690,6 +715,14 @@ namespace zypp
     /* Other config singleton instances */
     MediaConfig &_mediaConf = MediaConfig::instance();
 
+
+  public:
+    const TargetDefaults & targetDefaults() const { return _currentTargetDefaults ? *_currentTargetDefaults : _initialTargetDefaults; }
+    TargetDefaults &       targetDefaults()       { return _currentTargetDefaults ? *_currentTargetDefaults : _initialTargetDefaults; }
+  private:
+    TargetDefaults                _initialTargetDefaults; ///< Initial TargetDefaults from /
+    std::optional<TargetDefaults> _currentTargetDefaults; ///< TargetDefaults while --root
+
   private:
     // HACK for bnc#906096: let pool re-evaluate multiversion spec
     // if target root changes. ZConfig returns data sensitive to
@@ -812,10 +845,12 @@ namespace zypp
   ZConfig::~ZConfig( )
   {}
 
+  void ZConfig::notifyTargetChanged()
+  { return _pimpl->notifyTargetChanged(); }
+
   Pathname ZConfig::systemRoot() const
   { return _autodetectSystemRoot(); }
 
-
   Pathname ZConfig::repoManagerRoot() const
   {
     return ( _pimpl->cfg_repo_mgr_root_path.empty()
@@ -1074,21 +1109,21 @@ namespace zypp
   void ZConfig::resetRepoGpgCheck()                    { _pimpl->repoGpgCheck.restoreToDefault(); }
   void ZConfig::resetPkgGpgCheck()                     { _pimpl->pkgGpgCheck.restoreToDefault(); }
 
-  ResolverFocus ZConfig::solver_focus() const          { return _pimpl->solver_focus; }
 
-  bool ZConfig::solver_onlyRequires() const
-  { return _pimpl->solver_onlyRequires; }
+  ResolverFocus ZConfig::solver_focus() const           { return _pimpl->targetDefaults().solver_focus; }
+  bool ZConfig::solver_onlyRequires() const             { return _pimpl->targetDefaults().solver_onlyRequires; }
+  bool ZConfig::solver_allowVendorChange() const        { return _pimpl->targetDefaults().solver_allowVendorChange; }
+  bool ZConfig::solver_dupAllowDowngrade() const        { return _pimpl->targetDefaults().solver_dupAllowDowngrade; }
+  bool ZConfig::solver_dupAllowNameChange() const       { return _pimpl->targetDefaults().solver_dupAllowNameChange; }
+  bool ZConfig::solver_dupAllowArchChange() const       { return _pimpl->targetDefaults().solver_dupAllowArchChange; }
+  bool ZConfig::solver_dupAllowVendorChange() const     { return _pimpl->targetDefaults().solver_dupAllowVendorChange; }
+  bool ZConfig::solver_cleandepsOnRemove() const        { return _pimpl->targetDefaults().solver_cleandepsOnRemove; }
+  unsigned ZConfig::solver_upgradeTestcasesToKeep() const { return _pimpl->targetDefaults().solver_upgradeTestcasesToKeep; }
 
-  bool ZConfig::solver_allowVendorChange() const
-  { return _pimpl->solver_allowVendorChange; }
+  bool ZConfig::solverUpgradeRemoveDroppedPackages() const          { return _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages; }
+  void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r ) { _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages.set( val_r ); }
+  void ZConfig::resetSolverUpgradeRemoveDroppedPackages()           { _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages.restoreToDefault(); }
 
-  bool ZConfig::solver_dupAllowDowngrade() const       { return _pimpl->solver_dupAllowDowngrade; }
-  bool ZConfig::solver_dupAllowNameChange() const      { return _pimpl->solver_dupAllowNameChange; }
-  bool ZConfig::solver_dupAllowArchChange() const      { return _pimpl->solver_dupAllowArchChange; }
-  bool ZConfig::solver_dupAllowVendorChange() const    { return _pimpl->solver_dupAllowVendorChange; }
-
-  bool ZConfig::solver_cleandepsOnRemove() const
-  { return _pimpl->solver_cleandepsOnRemove; }
 
   Pathname ZConfig::solver_checkSystemFile() const
   { return ( _pimpl->solver_checkSystemFile.empty()
@@ -1098,12 +1133,6 @@ namespace zypp
   { return ( _pimpl->solver_checkSystemFileDir.empty()
       ? (configPath()/"systemCheck.d") : _pimpl->solver_checkSystemFileDir ); }
 
-  unsigned ZConfig::solver_upgradeTestcasesToKeep() const
-  { return _pimpl->solver_upgradeTestcasesToKeep; }
-
-  bool ZConfig::solverUpgradeRemoveDroppedPackages() const             { return _pimpl->solverUpgradeRemoveDroppedPackages; }
-  void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r )    { _pimpl->solverUpgradeRemoveDroppedPackages.set( val_r ); }
-  void ZConfig::resetSolverUpgradeRemoveDroppedPackages()              { _pimpl->solverUpgradeRemoveDroppedPackages.restoreToDefault(); }
 
   namespace
   {
index 612244b..f26f500 100644 (file)
@@ -550,6 +550,8 @@ namespace zypp
       class Impl;
       /** Dtor */
       ~ZConfig();
+      void notifyTargetChanged();  ///< internal
+
   private:
       friend class RepoManager;
       /** The builtin config file value. */
index 6e87ffe..13fab24 100644 (file)
@@ -79,13 +79,25 @@ Resolver::Resolver (const ResPool & pool)
     : _pool(pool)
     , _satResolver(NULL)
     , _poolchanged(_pool.serial() )
-    , _upgradeMode             (false)
-    , _updateMode              (false)
-    , _verifying               (false)
-    , _onlyRequires            ( ZConfig::instance().solver_onlyRequires() )
-    , _solveSrcPackages                ( false )
-    , _cleandepsOnRemove       ( ZConfig::instance().solver_cleandepsOnRemove() )
-    , _ignoreAlreadyRecommended        ( true )
+    , _upgradeMode              ( false )
+    , _updateMode               ( false )
+    , _verifying                ( false )
+    , _onlyRequires             ( ZConfig::instance().solver_onlyRequires() )
+    , _solveSrcPackages         ( false )
+    , _cleandepsOnRemove        ( ZConfig::instance().solver_cleandepsOnRemove() )
+    , _ignoreAlreadyRecommended ( true )
+    , _applyDefault_focus                ( true )
+    , _applyDefault_forceResolve         ( true )
+    , _applyDefault_cleandepsOnRemove    ( true )
+    , _applyDefault_onlyRequires         ( true )
+    , _applyDefault_allowDowngrade       ( true )
+    , _applyDefault_allowNameChange      ( true )
+    , _applyDefault_allowArchChange      ( true )
+    , _applyDefault_allowVendorChange    ( true )
+    , _applyDefault_dupAllowDowngrade    ( true )
+    , _applyDefault_dupAllowNameChange   ( true )
+    , _applyDefault_dupAllowArchChange   ( true )
+    , _applyDefault_dupAllowVendorChange ( true )
 {
     sat::Pool satPool( sat::Pool::instance() );
     _satResolver = new SATResolver(_pool, satPool.get());
@@ -100,46 +112,75 @@ Resolver::~Resolver()
 sat::detail::CSolver * Resolver::get() const
 { return _satResolver->get(); }
 
+
+void Resolver::setDefaultSolverFlags( bool all_r )
+{
+  MIL << "setDefaultSolverFlags all=" << all_r << endl;
+
+  if ( all_r || _applyDefault_focus ) setFocus( ResolverFocus::Default );
+
+#define ZOLV_FLAG_DEFAULT( ZSETTER, ZGETTER )        \
+  if ( all_r || _applyDefault_##ZGETTER ) ZSETTER( indeterminate )
+
+  ZOLV_FLAG_DEFAULT( setForceResolve         ,forceResolve         );
+  ZOLV_FLAG_DEFAULT( setCleandepsOnRemove    ,cleandepsOnRemove    );
+  ZOLV_FLAG_DEFAULT( setOnlyRequires         ,onlyRequires         );
+  ZOLV_FLAG_DEFAULT( setAllowDowngrade       ,allowDowngrade       );
+  ZOLV_FLAG_DEFAULT( setAllowNameChange      ,allowNameChange      );
+  ZOLV_FLAG_DEFAULT( setAllowArchChange      ,allowArchChange      );
+  ZOLV_FLAG_DEFAULT( setAllowVendorChange    ,allowVendorChange    );
+  ZOLV_FLAG_DEFAULT( dupSetAllowDowngrade    ,dupAllowDowngrade    );
+  ZOLV_FLAG_DEFAULT( dupSetAllowNameChange   ,dupAllowNameChange   );
+  ZOLV_FLAG_DEFAULT( dupSetAllowArchChange   ,dupAllowArchChange   );
+  ZOLV_FLAG_DEFAULT( dupSetAllowVendorChange ,dupAllowVendorChange );
+#undef ZOLV_FLAG_TRIBOOL
+}
 //---------------------------------------------------------------------------
 // forward flags too SATResolver
-
-void Resolver::setFocus( ResolverFocus focus_r )       { _satResolver->_focus = ( focus_r == ResolverFocus::Default ) ? ZConfig::instance().solver_focus() : focus_r; }
+void Resolver::setFocus( ResolverFocus focus_r )       {
+  _applyDefault_focus = ( focus_r == ResolverFocus::Default );
+  _satResolver->_focus = _applyDefault_focus ? ZConfig::instance().solver_focus() : focus_r;
+}
 ResolverFocus Resolver::focus() const                  { return _satResolver->_focus; }
 
-#define ZOLV_FLAG_TRIBOOL( ZSETTER, ZGETTER, ZVARNAME, ZVARDEFAULT )                   \
+#define ZOLV_FLAG_TRIBOOL( ZSETTER, ZGETTER, ZVARDEFAULT, ZVARNAME )                   \
     void Resolver::ZSETTER( TriBool state_r )                                          \
-    { _satResolver->ZVARNAME = indeterminate(state_r) ? ZVARDEFAULT : bool(state_r); } \
+    { _applyDefault_##ZGETTER = indeterminate(state_r);                                        \
+      bool newval = _applyDefault_##ZGETTER ? ZVARDEFAULT : bool(state_r);             \
+      if ( ZVARNAME != newval ) {                                                      \
+        DBG << #ZGETTER << ": changed from " << (bool)ZVARNAME << " to " << newval << endl;\
+        ZVARNAME = newval;                                                             \
+      }                                                                                        \
+    }                                                                                  \
     bool Resolver::ZGETTER() const                                                     \
-    { return _satResolver->ZVARNAME; }                                                 \
-
-// NOTE: ZVARDEFAULT must be in sync with SATResolver ctor
-ZOLV_FLAG_TRIBOOL( setForceResolve,            forceResolve,           _allowuninstall,        false )
-
-ZOLV_FLAG_TRIBOOL( setAllowDowngrade,          allowDowngrade,         _allowdowngrade,        false )
-ZOLV_FLAG_TRIBOOL( setAllowNameChange,         allowNameChange,        _allownamechange,       true )  // bsc#1071466
-ZOLV_FLAG_TRIBOOL( setAllowArchChange,         allowArchChange,        _allowarchchange,       false )
-ZOLV_FLAG_TRIBOOL( setAllowVendorChange,       allowVendorChange,      _allowvendorchange,     ZConfig::instance().solver_allowVendorChange() )
+    { return ZVARNAME; }                                                               \
 
-ZOLV_FLAG_TRIBOOL( dupSetAllowDowngrade,       dupAllowDowngrade,      _dup_allowdowngrade,    ZConfig::instance().solver_dupAllowDowngrade() )
-ZOLV_FLAG_TRIBOOL( dupSetAllowNameChange,      dupAllowNameChange,     _dup_allownamechange,   ZConfig::instance().solver_dupAllowNameChange() )
-ZOLV_FLAG_TRIBOOL( dupSetAllowArchChange,      dupAllowArchChange,     _dup_allowarchchange,   ZConfig::instance().solver_dupAllowArchChange() )
-ZOLV_FLAG_TRIBOOL( dupSetAllowVendorChange,    dupAllowVendorChange,   _dup_allowvendorchange, ZConfig::instance().solver_dupAllowVendorChange() )
+// Flags stored here follow the naming convention,...
+// TODO: But why do we need them here? Probably too many layers and they can
+// go to _satResolver too.
+#define ZOLV_FLAG_LOCALTB( ZSETTER, ZGETTER, ZVARDEFAULT )                             \
+    ZOLV_FLAG_TRIBOOL( ZSETTER, ZGETTER, ZVARDEFAULT, _##ZGETTER )
+// Flags down in _satResolver don't (yet).
+#define ZOLV_FLAG_SATSOLV( ZSETTER, ZGETTER, ZVARDEFAULT, ZVARNAME )                   \
+    ZOLV_FLAG_TRIBOOL( ZSETTER, ZGETTER, ZVARDEFAULT, _satResolver->ZVARNAME )
 
+// NOTE: ZVARDEFAULT must be in sync with SATResolver ctor
+ZOLV_FLAG_SATSOLV( setForceResolve         ,forceResolve         ,false                                             ,_allowuninstall        )
+ZOLV_FLAG_LOCALTB( setCleandepsOnRemove    ,cleandepsOnRemove    ,ZConfig::instance().solver_cleandepsOnRemove()    )
+ZOLV_FLAG_LOCALTB( setOnlyRequires         ,onlyRequires         ,ZConfig::instance().solver_onlyRequires()         )
+ZOLV_FLAG_SATSOLV( setAllowDowngrade       ,allowDowngrade       ,false                                             ,_allowdowngrade        )
+ZOLV_FLAG_SATSOLV( setAllowNameChange      ,allowNameChange      ,true /*bsc#1071466*/                              ,_allownamechange       )
+ZOLV_FLAG_SATSOLV( setAllowArchChange      ,allowArchChange      ,false                                             ,_allowarchchange       )
+ZOLV_FLAG_SATSOLV( setAllowVendorChange    ,allowVendorChange    ,ZConfig::instance().solver_allowVendorChange()    ,_allowvendorchange     )
+ZOLV_FLAG_SATSOLV( dupSetAllowDowngrade    ,dupAllowDowngrade    ,ZConfig::instance().solver_dupAllowDowngrade()    ,_dup_allowdowngrade    )
+ZOLV_FLAG_SATSOLV( dupSetAllowNameChange   ,dupAllowNameChange   ,ZConfig::instance().solver_dupAllowNameChange()   ,_dup_allownamechange   )
+ZOLV_FLAG_SATSOLV( dupSetAllowArchChange   ,dupAllowArchChange   ,ZConfig::instance().solver_dupAllowArchChange()   ,_dup_allowarchchange   )
+ZOLV_FLAG_SATSOLV( dupSetAllowVendorChange ,dupAllowVendorChange ,ZConfig::instance().solver_dupAllowVendorChange() ,_dup_allowvendorchange )
+#undef ZOLV_FLAG_SATSOLV
+#undef ZOLV_FLAG_LOCALTB
 #undef ZOLV_FLAG_TRIBOOL
 //---------------------------------------------------------------------------
 
-void Resolver::setOnlyRequires( TriBool state_r )
-{
-  _onlyRequires = indeterminate(state_r) ? ZConfig::instance().solver_onlyRequires() : bool(state_r);
-}
-
-void Resolver::setCleandepsOnRemove( TriBool state_r )
-{
-  _cleandepsOnRemove = indeterminate(state_r) ? ZConfig::instance().solver_cleandepsOnRemove() : bool(state_r);
-}
-
-//---------------------------------------------------------------------------
-
 ResPool Resolver::pool() const
 { return _pool; }
 
index 6367a9f..61179b2 100644 (file)
@@ -77,16 +77,32 @@ class Resolver : private base::NonCopyable
 
     /** \name Solver flags */
     //@{
-    bool _upgradeMode;            // Resolver has been called with doUpgrade
-    bool _updateMode;            // Resolver has been called with doUpdate
-    bool _verifying;              // The system will be checked
-    bool _onlyRequires;          // do install required resolvables only
-                                  // no recommended resolvables, language
-                                  // packages, hardware packages (modalias)
-    bool _solveSrcPackages;    // whether to generate solver jobs for selected source packges.
-    bool _cleandepsOnRemove;   // whether removing a package should also remove no longer needed requirements
-
-    bool _ignoreAlreadyRecommended;   //ignore recommended packages that have already been recommended by the installed packages
+    bool _upgradeMode:1;              // Resolver has been called with doUpgrade
+    bool _updateMode:1;               // Resolver has been called with doUpdate
+    bool _verifying:1;                // The system will be checked
+    bool _onlyRequires:1;             // do install required resolvables only
+    bool _solveSrcPackages:1;         // whether to generate solver jobs for selected source packges.
+    bool _cleandepsOnRemove:1;        // whether removing a package should also remove no longer needed requirements
+    bool _ignoreAlreadyRecommended:1; // ignore recommended packages that have already been recommended by the installed packages
+    //@}
+
+    /** \name applyDefaults
+     * Remember whether global default or explicit settings are applied to SATResolver.
+     * Global defaults may change with the Target, explicit settings not.
+     */
+    //@{
+    bool _applyDefault_focus:1;
+    bool _applyDefault_forceResolve:1;
+    bool _applyDefault_cleandepsOnRemove:1;
+    bool _applyDefault_onlyRequires:1;
+    bool _applyDefault_allowDowngrade:1;
+    bool _applyDefault_allowNameChange:1;
+    bool _applyDefault_allowArchChange:1;
+    bool _applyDefault_allowVendorChange:1;
+    bool _applyDefault_dupAllowDowngrade:1;
+    bool _applyDefault_dupAllowNameChange:1;
+    bool _applyDefault_dupAllowArchChange:1;
+    bool _applyDefault_dupAllowVendorChange:1;
     //@}
 
     // Additional QueueItems which has to be regarded by the solver
@@ -127,6 +143,17 @@ class Resolver : private base::NonCopyable
     ResPool pool() const;
     void setPool( const ResPool & pool ) { _pool = pool; }
 
+    /**
+     * Reset all solver flags to the systems default (e.g. from zypp.conf).
+     *
+     * The information whether a \ref SATResolver setting was explicitly set or follows
+     * the targets default (zypp.conf) is stored here in the \ref Resolver.
+     * If \a all_r is \c false, only those settings are updated, which still follow
+     * the target defaults (e.g. after the target has changed). Otherwise all explicit
+     * settings are discarded and the defaults are applied.
+     */
+    void setDefaultSolverFlags( bool all_r );
+
     void addUpgradeRepo( Repository repo_r )           { if ( repo_r && ! repo_r.isSystemRepo() ) _upgradeRepos.insert( repo_r ); }
     bool upgradingRepo( Repository repo_r ) const      { return( _upgradeRepos.find( repo_r ) != _upgradeRepos.end() ); }
     void removeUpgradeRepo( Repository repo_r )                { _upgradeRepos.erase( repo_r ); }
@@ -159,9 +186,6 @@ class Resolver : private base::NonCopyable
     bool ignoreAlreadyRecommended() const      { return _ignoreAlreadyRecommended; }
     void setIgnoreAlreadyRecommended( bool yesno_r ) { _ignoreAlreadyRecommended = yesno_r; }
 
-    bool onlyRequires () const                 { return _onlyRequires; }
-    void setOnlyRequires( TriBool state_r );
-
     bool isUpgradeMode() const                         { return _upgradeMode; }// Resolver has been called with doUpgrade
     void setUpgradeMode( bool yesno_r )                { _upgradeMode = yesno_r; }
 
@@ -173,9 +197,6 @@ class Resolver : private base::NonCopyable
 
     bool solveSrcPackages() const              { return _solveSrcPackages; }
     void setSolveSrcPackages( TriBool state_r )        { _solveSrcPackages = indeterminate(state_r) ? false : bool(state_r); }
-
-    bool cleandepsOnRemove() const             { return _cleandepsOnRemove; }
-    void setCleandepsOnRemove( TriBool state_r );
     //@}
 
     void setFocus( ResolverFocus focus_r );
@@ -185,18 +206,17 @@ class Resolver : private base::NonCopyable
     void ZSETTER( TriBool state_r );           \
     bool ZGETTER() const;                      \
 
-    ZOLV_FLAG_TRIBOOL( setForceResolve,                forceResolve )
-
-    ZOLV_FLAG_TRIBOOL( setAllowDowngrade,      allowDowngrade )
-    ZOLV_FLAG_TRIBOOL( setAllowNameChange,     allowNameChange )
-    ZOLV_FLAG_TRIBOOL( setAllowArchChange,     allowArchChange )
-    ZOLV_FLAG_TRIBOOL( setAllowVendorChange,   allowVendorChange )
-
-    ZOLV_FLAG_TRIBOOL( dupSetAllowDowngrade,   dupAllowDowngrade )
-    ZOLV_FLAG_TRIBOOL( dupSetAllowNameChange,  dupAllowNameChange )
-    ZOLV_FLAG_TRIBOOL( dupSetAllowArchChange,  dupAllowArchChange )
-    ZOLV_FLAG_TRIBOOL( dupSetAllowVendorChange,        dupAllowVendorChange )
-
+    ZOLV_FLAG_TRIBOOL( setForceResolve          ,forceResolve         )
+    ZOLV_FLAG_TRIBOOL( setCleandepsOnRemove     ,cleandepsOnRemove    )
+    ZOLV_FLAG_TRIBOOL( setOnlyRequires          ,onlyRequires         )
+    ZOLV_FLAG_TRIBOOL( setAllowDowngrade        ,allowDowngrade       )
+    ZOLV_FLAG_TRIBOOL( setAllowNameChange       ,allowNameChange      )
+    ZOLV_FLAG_TRIBOOL( setAllowArchChange       ,allowArchChange      )
+    ZOLV_FLAG_TRIBOOL( setAllowVendorChange     ,allowVendorChange    )
+    ZOLV_FLAG_TRIBOOL( dupSetAllowDowngrade     ,dupAllowDowngrade    )
+    ZOLV_FLAG_TRIBOOL( dupSetAllowNameChange    ,dupAllowNameChange   )
+    ZOLV_FLAG_TRIBOOL( dupSetAllowArchChange    ,dupAllowArchChange   )
+    ZOLV_FLAG_TRIBOOL( dupSetAllowVendorChange  ,dupAllowVendorChange )
 #undef ZOLV_FLAG_TRIBOOL
 
     ResolverProblemList problems() const;
index 8eee15f..b6ea198 100644 (file)
@@ -134,9 +134,7 @@ namespace zypp
 
       /** Overload to realize stream output. */
       virtual std::ostream & dumpOn( std::ostream & str ) const
-      {
-        return str << "TargetImpl";
-      }
+      { return str << "Target(" << root() << ")"; }
 
       /** The RPM database */
       rpm::RpmDb & rpm();
index c74c45f..9e749ad 100644 (file)
@@ -116,7 +116,14 @@ namespace zypp
       if (! _target)
         ZYPP_THROW(Exception("Target not initialized."));
       return _target;
-     }
+    }
+
+    void ZYppImpl::changeTargetTo( Target_Ptr newtarget_r )
+    {
+      _target = newtarget_r;
+      ZConfig::instance().notifyTargetChanged();
+      resolver()->setDefaultSolverFlags( /*all_r*/false );  // just changed defaults
+    }
 
     void ZYppImpl::initializeTarget( const Pathname & root, bool doRebuild_r )
     {
@@ -126,11 +133,9 @@ namespace zypp
               MIL << "Repeated call to initializeTarget()" << endl;
               return;
           }
-
           _target->unload();
-
       }
-      _target = new Target( root, doRebuild_r );
+      changeTargetTo( new Target( root, doRebuild_r ) );
       _target->buildCache();
     }
 
@@ -139,7 +144,7 @@ namespace zypp
       if (_target)
           _target->unload();
 
-      _target = nullptr;
+      changeTargetTo( nullptr );
     }
 
     //------------------------------------------------------------------------
index bb9698b..ff2c6c1 100644 (file)
@@ -109,6 +109,10 @@ namespace zypp
       void setPartitions(const DiskUsageCounter::MountPointSet &mp);
       DiskUsageCounter::MountPointSet getPartitions() const;
 
+    public:
+      /** Hook for actions to trigger if the Target changes (initialize/finish) */
+      void changeTargetTo( Target_Ptr newtarget_r );
+
     private:
       /** */
       Target_Ptr _target;