Unmaintained packages which does not fit to the updated system
authorStefan Schubert <schubi@suse.de>
Fri, 22 Feb 2008 08:56:35 +0000 (08:56 +0000)
committerStefan Schubert <schubi@suse.de>
Fri, 22 Feb 2008 08:56:35 +0000 (08:56 +0000)
(broken dependencies) will be deleted.

zypp/ProblemSolution.h
zypp/solver/detail/Resolver.cc
zypp/solver/detail/Resolver.h
zypp/solver/detail/ResolverUpgrade.cc

index fe357f0..5bedec3 100644 (file)
@@ -106,6 +106,8 @@ namespace zypp
         **/ 
        void addAction( solver::detail::SolutionAction_constPtr action );
 
+       solver::detail::CSolutionActionList actions() {return _actions;}
+
     };
 
 
index c785d5a..3e063e4 100644 (file)
@@ -36,6 +36,8 @@
 #include "zypp/sat/Solvable.h"
 #include "zypp/sat/SATResolver.h"
 
+#define MAXSOLVERRUNS 5
+
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
 { ///////////////////////////////////////////////////////////////////////
@@ -295,6 +297,82 @@ Resolver::resolvePool()
 
 
 ///////////////////////////////////////////////////////////////////
+//
+//
+//     METHOD NAME : Resolver::checkUnmaintainedItems
+//     METHOD TYPE : 
+//
+//     DESCRIPTION : Unmaintained packages which does not fit to 
+//                    the updated system (broken dependencies) will be
+//                    deleted.
+//
+void Resolver::checkUnmaintainedItems () {
+    int solverRuns = 1;
+    MIL << "Checking unmaintained items....." << endl;
+
+    while (!resolvePool() && solverRuns++ < MAXSOLVERRUNS) {
+       ResolverProblemList problemList = problems();
+       ProblemSolutionList solutionList;
+       PoolItemList problemItemList;   
+
+       for (ResolverProblemList::iterator iter = problemList.begin(); iter != problemList.end(); ++iter) {
+           ResolverProblem problem = **iter;
+           DBG << "Problem:" << endl;
+           DBG << problem.description() << endl;
+           DBG << problem.details() << endl;
+
+           ProblemSolutionList solutions = problem.solutions();
+           for (ProblemSolutionList::const_iterator iterSolution = solutions.begin();
+                iterSolution != solutions.end(); ++iter) {
+               ProblemSolution_Ptr solution = *iterSolution;
+               DBG << "   Solution:" << endl;
+               DBG << "      " << solution->description() << endl;
+               DBG << "      " << solution->details() << endl;         
+               solver::detail::CSolutionActionList actionList = solution->actions();
+               bool fitUnmaintained = false;
+               PoolItemList deletedItems;
+               for (CSolutionActionList::const_iterator iterActions = actionList.begin();
+                    iterActions != actionList.end(); ++iterActions) {
+                   TransactionSolutionAction_constPtr transactionAction = dynamic_pointer_cast<const TransactionSolutionAction>(*iterActions);
+                   if (transactionAction &&
+                       transactionAction->action() == REMOVE
+                       && _unmaintained_items.find(transactionAction->item()) != _unmaintained_items.end()) {
+                       // The solution contains unmaintained items ONLY which will be deleted. So take this solution
+                       fitUnmaintained = true;
+                       deletedItems.push_back (transactionAction->item());
+                   } else {
+                       fitUnmaintained = false;
+                   }
+               }
+               if (fitUnmaintained) {
+                   MIL << "Problem:" << endl;
+                   MIL << problem.description() << endl;
+                   MIL << problem.details() << endl;
+                   MIL << "Will be solved by removing unmaintained package(s)............" << endl;
+                   MIL << "   Solution:" << endl;
+                   MIL << "      " << solution->description() << endl;
+                   MIL << "      " << solution->details() << endl;                                 
+                   solutionList.push_back (solution);
+                   problemItemList.insert (problemItemList.end(), deletedItems.begin(), deletedItems.end() );
+                   break; // not regarding the other solutions
+               }
+           }
+       }
+
+       if (!solutionList.empty()) {
+           applySolutions (solutionList);
+           // list of problematic items after doUpgrade() which is show to the user
+           _problem_items.insert (_problem_items.end(), problemItemList.begin(), problemItemList.end());
+           _problem_items.unique();
+       } else {
+           // break cause there is no other solution available by the next run
+           solverRuns = MAXSOLVERRUNS;
+       }
+    }
+}
+
+
+///////////////////////////////////////////////////////////////////
     };// namespace detail
     /////////////////////////////////////////////////////////////////////
     /////////////////////////////////////////////////////////////////////
index 410bfce..b9db4c7 100644 (file)
@@ -72,7 +72,7 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable {
     PoolItemList _problem_items;
 
     // list of not supported packages
-    PoolItemList _unmaintained_items;    
+    PoolItemSet _unmaintained_items;    
 
     CapabilitySet _extra_requires;
     CapabilitySet _extra_conflicts;
@@ -105,6 +105,9 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable {
     bool doesObsoleteCapability (PoolItem candidate, const Capability & cap);
     bool doesObsoleteItem (PoolItem candidate, PoolItem installed);
 
+    // Unmaintained packages which does not fit to the updated system
+    // (broken dependencies) will be deleted.
+    void checkUnmaintainedItems ();
 
   public:
 
index 0a4beeb..9caf623 100644 (file)
 #include "zypp/solver/detail/Helper.h"
 #include "zypp/solver/detail/Resolver.h"
 #include "zypp/solver/detail/Testcase.h"
+#include "zypp/ResolverProblem.h"
+#include "zypp/ProblemSolution.h"
 #include "zypp/Target.h"
 #include "zypp/sat/SATResolver.h"
 
+
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
 { ///////////////////////////////////////////////////////////////////////
@@ -215,8 +218,6 @@ Resolver::doUpgrade( UpgradeStatistics & opt_stats_r )
   TodoMap     addProvided;
   TodoMap     addMultiProvided;
 
-  sat::Pool::instance().prepare();  
-
   Target_Ptr target;
   try {
        target = getZYpp()->target();
@@ -420,6 +421,7 @@ Resolver::doUpgrade( UpgradeStatistics & opt_stats_r )
       // Remember new package for 2nd pass.
 
       Capability installedCap( installed->name(), Rel::EQ, installed->edition(), installed->kind());
+      
       // find ALL providers
       sat::WhatProvides possibleProviders(installedCap);
 
@@ -513,7 +515,7 @@ Resolver::doUpgrade( UpgradeStatistics & opt_stats_r )
     ///////////////////////////////////////////////////////////////////
 
     if ( can_be_dropped ) {
-      _unmaintained_items.push_back( installed );
+      _unmaintained_items.insert( installed );
     }
 
   } // pass 1 end
@@ -627,8 +629,14 @@ Resolver::doUpgrade( UpgradeStatistics & opt_stats_r )
 
   // Setting Resolver to upgrade mode
   _upgradeMode = true;
+
+  // Unmaintained packages which does not fit to the updated system
+  // (broken dependencies) will be deleted.
+  checkUnmaintainedItems ();  
+  
 }
 
+
 ///////////////////////////////////////////////////////////////////
     };// namespace detail
     /////////////////////////////////////////////////////////////////////