limit commits to media, return uncommited PoolItems
authorKlaus Kaempf <kkaempf@suse.de>
Wed, 8 Feb 2006 13:06:58 +0000 (13:06 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Wed, 8 Feb 2006 13:06:58 +0000 (13:06 +0000)
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index 33143cb..cace53a 100644 (file)
@@ -105,53 +105,62 @@ namespace zypp
     }
 
 
-    void TargetImpl::commit(ResPool pool_r, int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r)
+    void TargetImpl::commit(ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r)
     {
       MIL << "TargetImpl::commit(<pool>, " << medianr << ")" << endl;
 
+      errors_r.clear();
+      remaining_r.clear();
+      srcremaining_r.clear();
+
       PoolItemList to_uninstall;
       PoolItemList to_install;
-      PoolItemList installed;
-      for (ResPool::const_iterator it = pool_r.begin();
-           it != pool_r.end(); it++)
-      {
-       if (it->status().isToBeInstalled())
-       {
-         to_install.push_back(*it);
-       }
-       else if (it->status().isToBeUninstalled()
-                && !it->status().isToBeUninstalledDueToObsolete())     // leave out obsoletes
-       {
-         to_uninstall.push_back(*it);
-       }
-       else if (it->status().staysInstalled())
-       {
-         installed.push_back(*it);
-       }
-      }
-
-      if (to_uninstall.size() > 0 ) {
+      PoolItemList to_srcinstall;
+      getResolvablesToInsDel( pool_r, to_uninstall, to_install, to_srcinstall );
 
-       // sort delete list...
+      if ( medianr ) {
+       MIL << "Restrict to media number " << medianr << endl;
+      }
 
-       InstallOrder order(pool_r, to_uninstall, installed);
-       order.init();
-       const PoolItemList & uninstallorder(order.getTopSorted());
+      commit (to_uninstall);
 
-       to_uninstall.clear();
-       for (PoolItemList::const_reverse_iterator it = uninstallorder.rbegin(); it != uninstallorder.rend(); ++it ) {
-           to_uninstall.push_back (*it);
+      if (medianr == 0) {                      // commit all
+       commit( to_install );
+       commit( to_srcinstall );
+      }
+      else {
+       PoolItemList current_install;
+
+       for (PoolItemList::iterator it = to_install.begin(); it != to_install.end(); ++it) {
+           Resolvable::constPtr res( it->resolvable() );
+           Package::constPtr pkg( asKind<Package>(res) );
+           if (pkg
+               && medianr != pkg->mediaId())                                                           // check medianr for packages only
+           {
+               MIL << "Package " << *pkg << ", wrong media " << pkg->mediaId() << endl;
+               remaining_r.push_back( *it );
+           }
+           else {
+               current_install.push_back( *it );
+           }
        }
-
-       // first uninstall what is to be uninstalled
-       commit(to_uninstall);
+       for (PoolItemList::iterator it = to_install.begin(); it != to_install.end(); ++it) {
+           Resolvable::constPtr res( it->resolvable() );
+           Package::constPtr pkg( asKind<Package>(res) );
+           if (pkg
+               && medianr != pkg->mediaId())                                                           // check medianr for packages only
+           {
+               MIL << "Package " << *pkg << ", wrong media " << pkg->mediaId() << endl;
+               srcremaining_r.push_back( *it );
+           }
+           else {
+               current_install.push_back( *it );
+           }
+       }
+       commit (current_install);
       }
 
-      // now install what is to be installed
-      InstallOrder order(pool_r, to_install, installed);
-      order.init();
-      const PoolItemList & installorder(order.getTopSorted());
-      commit(installorder);
+      return;
     }
 
 
index d5d5fe6..187d861 100644 (file)
@@ -72,7 +72,7 @@ namespace zypp
       /** Commit changes in the pool
          media = 0 means any/all medias
          media > 0 means limit commits to this media */
-      void commit( ResPool pool_r, int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r );
+      void commit( ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r );
 
       /** Commit ordered changes */
       void commit( const PoolItemList & items_r );