Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / solver / detail / SATResolver.h
index a2d2bc2..2eb5715 100644 (file)
 
 #ifndef ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H
 #define ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H
+#ifndef ZYPP_USE_RESOLVER_INTERNALS
+#error Do not directly include this file!
+#else
+extern "C"
+{
+#include <solv/solver.h>
+#include <solv/pool.h>
+}
 
 #include <iosfwd>
 #include <list>
 #include "zypp/ProblemSolution.h"
 #include "zypp/Capability.h"
 #include "zypp/solver/detail/SolverQueueItem.h"
-extern "C" {
-#include "satsolver/solver.h"
-#include "satsolver/pool.h"
-}
 
+#include "zypp/sat/detail/PoolMember.h"
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
 { ///////////////////////////////////////////////////////////////////////
+
+  namespace sat
+  {
+    class Transaction;
+  }
+
   ///////////////////////////////////////////////////////////////////////
   namespace solver
   { /////////////////////////////////////////////////////////////////////
@@ -56,14 +67,22 @@ namespace zypp
 ///////////////////////////////////////////////////////////////////
 //
 //     CLASS NAME : SATResolver
-
-class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
+/**
+ * \todo The way solver options are passed as individual booleans from Resolver
+ * via solver::detail::Resolver to SATResolver is pedestrian and error prone.
+ * Introdce a dedicated solver option structure which is passed down as a whole.
+*/
+class SATResolver : public base::ReferenceCounted, private base::NonCopyable, private sat::detail::PoolMember
+{
 
   private:
     ResPool _pool;
-    Pool *_SATPool;
-    Solver *_solv;
-    Queue _jobQueue;
+    sat::detail::CPool *_satPool;
+    sat::detail::CSolver *_satSolver;
+    sat::detail::CQueue _jobQueue;
+
+    // list of problematic items (orphaned)
+    PoolItemList _problem_items;
 
     // list populated by calls to addPoolItemTo*()
     PoolItemList _items_to_install;
@@ -74,40 +93,55 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
     // solve results
     PoolItemList _result_items_to_install;
     PoolItemList _result_items_to_remove;
+  public:
+    bool _fixsystem:1;                 // repair errors in rpm dependency graph
+    bool _allowdowngrade:1;            // allow to downgrade installed solvable
+    bool _allowarchchange:1;           // allow to change architecture of installed solvables
+    bool _allowvendorchange:1;         // allow to change vendor of installed solvables
+    bool _allowuninstall:1;            // allow removal of installed solvables
+    bool _updatesystem:1;              // update
+    bool _noupdateprovide:1;           // true: update packages needs not to provide old package
+    bool _dosplitprovides:1;           // true: consider legacy split provides
+    bool _onlyRequires:1;              // true: consider required packages only
+    bool _ignorealreadyrecommended:1;  // true: ignore recommended packages that were already recommended by the installed packages
+    bool _distupgrade:1;
+    bool _distupgrade_removeunsupported:1;
+    bool _dup_allowdowngrade:1;                // dup mode: allow to downgrade installed solvable
+    bool _dup_allownamechange:1;       // dup mode: allow to change name of installed solvable
+    bool _dup_allowarchchange:1;       // dup mode: allow to change architecture of installed solvables
+    bool _dup_allowvendorchange:1;     // dup mode: allow to change vendor of installed solvables
+    bool _solveSrcPackages:1;          // false: generate no job rule for source packages selected in the pool
+    bool _cleandepsOnRemove:1;         // whether removing a package should also remove no longer needed requirements
 
-    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
-    bool _ignorealreadyrecommended;    // true: ignore recommended packages that were already recommended by the installed packages
-    
+  private:
     // ---------------------------------- methods
     std::string SATprobleminfoString (Id problem, std::string &detail, Id &ignoreId);
     void resetItemTransaction (PoolItem item);
 
-    // Create a SAT solver and reset solver selection in the pool (Collecting 
-    void solverInit(const PoolItemList & weakItems,
-                   const CapabilitySet & noObsoletesCapability,
-                   const PoolItemSet & noObsoletesItem,
-                   const ObsoleteStrings & noObsoletesString);
+    // Create a SAT solver and reset solver selection in the pool (Collecting
+    void solverInit(const PoolItemList & weakItems);
     // common solver run with the _jobQueue; Save results back to pool
-    bool solving();
+    bool solving(const CapabilitySet & requires_caps = CapabilitySet(),
+                const CapabilitySet & conflict_caps = CapabilitySet());
     // cleanup solver
     void solverEnd();
     // set locks for the solver
     void setLocks();
     // set requirements for a running system
     void setSystemRequirements();
-    
+
+   // Checking if this solvable/item has a buddy which reflect the real
+   // user visible description of an item
+   // e.g. The release package has a buddy to the concerning product item.
+   // This user want's the message "Product foo conflicts with product bar" and
+   // NOT "package release-foo conflicts with package release-bar"
+   // So these functions return the concerning buddy (e.g. product item)
+    sat::Solvable mapSolvable (const Id &id);
+    PoolItem mapItem (const PoolItem &item);
+
   public:
 
-    SATResolver (const ResPool & pool, Pool *SATPool);
+    SATResolver (const ResPool & pool, sat::detail::CPool *satPool);
     virtual ~SATResolver();
 
     // ---------------------------------- I/O
@@ -123,16 +157,11 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
     bool resolvePool(const CapabilitySet & requires_caps,
                     const CapabilitySet & conflict_caps,
                     const PoolItemList & weakItems,
-                    const CapabilitySet & noObsoletesCapability,
-                    const PoolItemSet & noObsoletesItem,
-                    const ObsoleteStrings & noObsoletesString
+                    const std::set<Repository> & upgradeRepos
                     );
     // solver run with the given request queue
     bool resolveQueue(const SolverQueueItemList &requestQueue,
-                     const PoolItemList & weakItems,
-                     const CapabilitySet & noObsoletesCapability,
-                     const PoolItemSet & noObsoletesItem,
-                     const ObsoleteStrings & noObsoletesString               
+                     const PoolItemList & weakItems
                      );
     // searching for new packages
     void doUpdate();
@@ -140,21 +169,18 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
     ResolverProblemList problems ();
     void applySolutions (const ProblemSolutionList &solutions);
 
-    void addPoolItemToInstall (PoolItem item);
-    void addPoolItemsToInstallFromList (PoolItemList & rl);
-
-    void addPoolItemToLock (PoolItem item);
-    void addPoolItemToKeep (PoolItem item);    
-
-    void addPoolItemToRemove (PoolItem item);
-    void addPoolItemsToRemoveFromList (PoolItemList & rl);
-
     bool fixsystem () const {return _fixsystem;}
     void setFixsystem ( const bool fixsystem) { _fixsystem = fixsystem;}
 
     bool ignorealreadyrecommended () const {return _ignorealreadyrecommended;}
     void setIgnorealreadyrecommended ( const bool ignorealreadyrecommended) { _ignorealreadyrecommended = ignorealreadyrecommended;}
 
+    bool distupgrade () const {return _distupgrade;}
+    void setDistupgrade ( const bool distupgrade) { _distupgrade = distupgrade;}
+
+    bool distupgrade_removeunsupported () const {return _distupgrade_removeunsupported;}
+    void setDistupgrade_removeunsupported ( const bool distupgrade_removeunsupported) { _distupgrade_removeunsupported = distupgrade_removeunsupported;}
+
     bool allowdowngrade () const {return _allowdowngrade;}
     void setAllowdowngrade ( const bool allowdowngrade) { _allowdowngrade = allowdowngrade;}
 
@@ -163,30 +189,36 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
 
     bool allowvendorchange () const {return _allowvendorchange;}
     void setAllowvendorchange ( const bool allowvendorchange) { _allowvendorchange = allowvendorchange;}
-    
+
     bool allowuninstall () const {return _allowuninstall;}
     void setAllowuninstall ( const bool allowuninstall) { _allowuninstall = allowuninstall;}
 
     bool updatesystem () const {return _updatesystem;}
     void setUpdatesystem ( const bool updatesystem) { _updatesystem = updatesystem;}
-    
-    bool allowvirtualconflicts () const {return _allowvirtualconflicts;}
-    void setAllowvirtualconflicts ( const bool allowvirtualconflicts) { _allowvirtualconflicts = allowvirtualconflicts;}
-    
+
     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);
+    bool solveSrcPackages() const              { return _solveSrcPackages; }
+    void setSolveSrcPackages( bool state_r )   { _solveSrcPackages = state_r; }
+
+    bool cleandepsOnRemove() const             { return _cleandepsOnRemove; }
+    void setCleandepsOnRemove( bool state_r )  { _cleandepsOnRemove = state_r; }
+
+    PoolItemList problematicUpdateItems( void ) const { return _problem_items; }
+    PoolItemList problematicUpdateItems() { return _problem_items; }
 
     PoolItemList resultItemsToInstall () { return _result_items_to_install; }
     PoolItemList resultItemsToRemove () { return _result_items_to_remove; }
-    
+
+    sat::StringQueue autoInstalled() const;
+    sat::StringQueue userInstalled() const;
 };
 
 ///////////////////////////////////////////////////////////////////
@@ -198,5 +230,5 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
   ///////////////////////////////////////////////////////////////////////
 };// namespace zypp
 /////////////////////////////////////////////////////////////////////////
-
+#endif // ZYPP_USE_RESOLVER_INTERNALS
 #endif // ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H