sort uninstall correctly
authorKlaus Kaempf <kkaempf@suse.de>
Thu, 2 Feb 2006 17:53:13 +0000 (17:53 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Thu, 2 Feb 2006 17:53:13 +0000 (17:53 +0000)
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index a4ae17c..ddd0b00 100644 (file)
@@ -92,18 +92,34 @@ namespace zypp
        {
          to_install.push_back(*it);
        }
-       else if (it->status().isToBeUninstalled())
+       else if (it->status().isToBeUninstalled()
+                && !it->status().isToBeUninstalledDueToObsolete())     // leave out obsoletes
        {
          to_uninstall.push_back(*it);
        }
-       else if (it->status().isInstalled())
+       else if (it->status().staysInstalled())
        {
          installed.push_back(*it);
        }
       }
-      // first uninstall what is to be uninstalled
-#warning FIXME this orderding doesn't honor the dependencies for removals
-      commit(to_uninstall);
+
+      if (to_uninstall.size() > 0 ) {
+
+       // sort delete list...
+
+       InstallOrder order(pool_r, to_uninstall, installed);
+       order.init();
+       const PoolItemList & uninstallorder(order.getTopSorted());
+
+       to_uninstall.clear();
+       for (PoolItemList::const_reverse_iterator it = uninstallorder.rbegin(); it != uninstallorder.rend(); ++it ) {
+           to_uninstall.push_back (*it);
+       }
+
+       // first uninstall what is to be uninstalled
+       commit(to_uninstall);
+      }
+
       // now install what is to be installed
       InstallOrder order(pool_r, to_install, installed);
       order.init();
@@ -182,6 +198,17 @@ namespace zypp
     bool TargetImpl::providesFile (const std::string & name_str, const std::string & path_str) const
     { return _rpm.hasFile(path_str); }
 
+
+
+void
+TargetImpl::getResolvablesToInsDel ( ResPool pool_r,
+                                   PoolItemList & dellist_r,
+                                   PoolItemList & instlist_r,
+                                   PoolItemList & srclist_r )
+{
+}
+
+
     /////////////////////////////////////////////////////////////////
   } // namespace target
   ///////////////////////////////////////////////////////////////////
index 847f5f5..d212e21 100644 (file)
@@ -61,7 +61,13 @@ namespace zypp
       /** All resolvables in the target. */
       const ResStore & resolvables();
 
-      /** Comomit changes in the pool */
+      /** Sort according to prereqs and media numbers */
+      void getResolvablesToInsDel ( ResPool pool_r,
+                                   PoolItemList & dellist_r,
+                                   PoolItemList & instlist_r,
+                                   PoolItemList & srclist_r );
+
+      /** Commit changes in the pool */
 #warning Add support for multiple medias - eg. limit only to CD1
       void commit(ResPool pool_r);