enhance system repo handling
authorMichael Andres <ma@suse.de>
Thu, 23 Oct 2008 15:21:32 +0000 (15:21 +0000)
committerMichael Andres <ma@suse.de>
Thu, 23 Oct 2008 15:21:32 +0000 (15:21 +0000)
zypp/sat/Pool.cc
zypp/sat/Pool.h
zypp/sat/detail/PoolImpl.h
zypp/solver/detail/SATResolver.cc

index f0b7fac..cd8ec4c 100644 (file)
@@ -124,6 +124,18 @@ namespace zypp
       return Repository();
     }
 
+    Repository Pool::findSystemRepo() const
+    {
+      return Repository( myPool().systemRepo() );
+    }
+
+    Repository Pool::systemRepo()
+    {
+      if ( myPool().systemRepo() )
+        return Repository( myPool().systemRepo() );
+      return reposInsert( systemRepoAlias() );
+    }
+
     Repository Pool::addRepoSolv( const Pathname & file_r, const std::string & alias_r )
     {
       // Using a temporay repo! (The additional parenthesis are required.)
index ceb14d0..b6f14d2 100644 (file)
@@ -100,12 +100,10 @@ namespace zypp
         static const std::string & systemRepoAlias();
 
         /** Return the system repository if it is on the pool. */
-        Repository findSystemRepo() const
-        { return reposFind( systemRepoAlias() ); }
+        Repository findSystemRepo() const;
 
         /** Return the system repository, create it if missing. */
-        Repository systemRepo()
-        { return reposInsert( systemRepoAlias() ); }
+        Repository systemRepo();
 
       public:
         /** Load \ref Solvables from a solv-file into a \ref Repository named \c name_r.
index db774c7..2bbd6d1 100644 (file)
@@ -88,6 +88,9 @@ namespace zypp
           bool isSystemRepo( ::_Repo * repo_r ) const
           { return repo_r && _pool->installed == repo_r; }
 
+          ::_Repo * systemRepo() const
+          { return _pool->installed; }
+
         public:
           /** \name Actions invalidating housekeeping data.
            *
index d789102..2bd2a49 100644 (file)
@@ -466,12 +466,10 @@ SATResolver::solving()
     {
       Id p;
       p = _solv->decisionq.elements[i];
-      if (p < 0 || !sat::Solvable(p))
-       continue;
-      if (sat::Solvable(p).repository().get() == _solv->installed)
+      if (p < 0 || !sat::Solvable(p) || sat::Solvable(p).isSystem())
        continue;
 
-      PoolItem poolItem = _pool.find (sat::Solvable(p));
+      PoolItem poolItem((sat::Solvable(p)));
       if (poolItem) {
          SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
          _result_items_to_install.push_back (poolItem);
@@ -481,30 +479,26 @@ SATResolver::solving()
     }
 
     /* solvables to be erased */
-    if (_solv->installed)
-    for (int i = _solv->installed->start; i < _solv->installed->start + _solv->installed->nsolvables; i++)
+    Repository systemRepo( sat::Pool::instance().findSystemRepo() ); // don't create if it does not exist
+    for_( it, systemRepo.solvablesBegin(), systemRepo.solvablesEnd() )
     {
-      if (_solv->decisionmap[i] > 0)
-       continue;
-
-      PoolItem poolItem = _pool.find (sat::Solvable(i));
-      if (poolItem) {
-         // Check if this is an update
-         CheckIfUpdate info;
-         invokeOnEach( _pool.byIdentBegin( poolItem ),
-                       _pool.byIdentEnd( poolItem ),
-                       resfilter::ByUninstalled(),                     // ByUninstalled
-                       functor::functorRef<bool,PoolItem> (info) );
-
-         if (info.is_updated) {
-             SATSolutionToPool (poolItem, ResStatus::toBeUninstalledDueToUpgrade , ResStatus::SOLVER);
-         } else {
-             SATSolutionToPool (poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER);
-         }
-         _result_items_to_remove.push_back (poolItem);
+      if (_solv->decisionmap[it->id()] > 0)
+        continue;
+
+      PoolItem poolItem( *it );
+      // Check if this is an update
+      CheckIfUpdate info;
+      invokeOnEach( _pool.byIdentBegin( poolItem ),
+                    _pool.byIdentEnd( poolItem ),
+                    resfilter::ByUninstalled(),                        // ByUninstalled
+                    functor::functorRef<bool,PoolItem> (info) );
+
+      if (info.is_updated) {
+          SATSolutionToPool (poolItem, ResStatus::toBeUninstalledDueToUpgrade , ResStatus::SOLVER);
       } else {
-         ERR << "id " << i << " not found in ZYPP pool." << endl;
+          SATSolutionToPool (poolItem, ResStatus::toBeUninstalled, ResStatus::SOLVER);
       }
+      _result_items_to_remove.push_back (poolItem);
     }
 
     /*  solvables which are recommended */