Mailinglist Archive: zypp-commit (325 mails)

< Previous Next >
[zypp-commit] r7225 - in /trunk/libzypp: VERSION.cmake devel/devel.ma/Parse.cc package/libzypp.changes zypp/DiskUsageCounter.cc
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Wed, 12 Sep 2007 17:05:40 -0000
  • Message-id: <20070912170540.9A8D335F26@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Wed Sep 12 19:05:40 2007
New Revision: 7225

URL: http://svn.opensuse.org/viewcvs/zypp?rev=7225&view=rev
Log:
- Various disk space calculation fixes. Susetags, plaindir and rpmdb
  now provide more detailed disk usage information.
  Yum metadata don't, so we book the package size to '/'. (#308362)

Modified:
    trunk/libzypp/VERSION.cmake
    trunk/libzypp/devel/devel.ma/Parse.cc
    trunk/libzypp/package/libzypp.changes
    trunk/libzypp/zypp/DiskUsageCounter.cc

Modified: trunk/libzypp/VERSION.cmake
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=7225&r1=7224&r2=7225&view=diff
==============================================================================
--- trunk/libzypp/VERSION.cmake (original)
+++ trunk/libzypp/VERSION.cmake Wed Sep 12 19:05:40 2007
@@ -45,6 +45,6 @@
 #
 
 SET(LIBZYPP_MAJOR "3")
-SET(LIBZYPP_MINOR "22")
-SET(LIBZYPP_COMPATMINOR "21")
-SET(LIBZYPP_PATCH "8")
+SET(LIBZYPP_MINOR "23")
+SET(LIBZYPP_COMPATMINOR "23")
+SET(LIBZYPP_PATCH "0")

Modified: trunk/libzypp/devel/devel.ma/Parse.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Parse.cc?rev=7225&r1=7224&r2=7225&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/Parse.cc (original)
+++ trunk/libzypp/devel/devel.ma/Parse.cc Wed Sep 12 19:05:40 2007
@@ -83,7 +83,7 @@
 {
   bool operator()( const PoolItem & obj_r )
   {
-     handle( asKind<Package>( obj_r ) );
+//      handle( asKind<Package>( obj_r ) );
 //     handle( asKind<Patch>( obj_r ) );
 //     handle( asKind<Pattern>( obj_r ) );
 //     handle( asKind<Product>( obj_r ) );
@@ -372,6 +372,19 @@
 
 using namespace zypp;
 
+void tt( std::string dd )
+{
+  unsigned level = 3;
+  std::string::size_type pos = dd.find( "/" );
+  while ( --level && pos != std::string::npos )
+  {
+    pos = dd.find( "/", pos+1 );
+  }
+  if ( pos != std::string::npos )
+    dd.erase( pos+1 );
+  DBG << dd << "\t" << level << " " << pos << endl;
+}
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -386,6 +399,19 @@
   DigestReceive foo;
   KeyRingSignalsReceive baa;
 
+  DiskUsageCounter::MountPointSet fakePart;
+  fakePart.insert( DiskUsageCounter::MountPoint( "/",        1024, 10240, 5120, 0LL, false ) );
+//   fakePart.insert( DiskUsageCounter::MountPoint( "/usr",     1024, 10240, 5120, 0LL, false ) );
+  fakePart.insert( DiskUsageCounter::MountPoint( "/usr/lib", 1024, 10240, 5120, 0LL, false ) );
+  fakePart.insert( DiskUsageCounter::MountPoint( "/usr/bin", 1024, 10240, 5120, 0LL, false ) );
+  getZYpp()->setPartitions( fakePart );
+
+  ResPool pool( getZYpp()->pool() );
+  vdumpPoolStats( USR << "Initial pool:" << endl,
+                 pool.begin(),
+                 pool.end() ) << endl;
+
+
   RepoManager repoManager( makeRepoManager( "/Local/ROOT" ) );
   RepoInfoList repos = repoManager.knownRepositories();
   SEC << repos << endl;
@@ -409,11 +435,6 @@
     repos = repoManager.knownRepositories();
   }
 
-  ResPool pool( getZYpp()->pool() );
-  vdumpPoolStats( USR << "Initial pool:" << endl,
-                 pool.begin(),
-                 pool.end() ) << endl;
-
   for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
   {
     RepoInfo & nrepo( *it );
@@ -448,7 +469,7 @@
   if ( 1 )
   {
     {
-      zypp::base::LogControl::TmpLineWriter shutUp;
+       zypp::base::LogControl::TmpLineWriter shutUp;
       //getZYpp()->initTarget( sysRoot );
       getZYpp()->initTarget( "/" );
     }
@@ -457,10 +478,6 @@
 
   std::for_each( pool.begin(), pool.end(), Xprint() );
 
-  DiskUsageCounter::MountPointSet fakePart;
-  fakePart.insert( DiskUsageCounter::MountPoint( "/", 1024, 10240, 5120, 0LL, false ) );
-  getZYpp()->setPartitions( fakePart );
-
   USR << getZYpp()->getPartitions() << endl;
   INT << getZYpp()->diskUsage() << endl;
 
@@ -471,12 +488,31 @@
   dbgDu( sel );
 
   MIL << sel->set_status( ui::S_Update ) << endl;
+//   sel->installedPoolItem().status().setTransact( true, ResStatus::SOLVER );
+  dbgDu( sel );
+
+  MIL << sel->set_status( ui::S_KeepInstalled ) << endl;
+  dbgDu( sel );
+
+  sel = getSel<Package>( "balsa" );
+  dbgDu( sel );
+
+  MIL << sel->set_status( ui::S_Install ) << endl;
+  dbgDu( sel );
+
+  MIL << sel->set_status( ui::S_NoInst ) << endl;
+  dbgDu( sel );
+
+  sel = getSel<Package>( "libtunepimp" );
+  dbgDu( sel );
+
+  MIL << sel->set_status( ui::S_Del ) << endl;
   dbgDu( sel );
 
   MIL << sel->set_status( ui::S_KeepInstalled ) << endl;
   dbgDu( sel );
 
-  ///////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
   zypp::base::LogControl::instance().logNothing();
   return 0;

Modified: trunk/libzypp/package/libzypp.changes
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=7225&r1=7224&r2=7225&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Wed Sep 12 19:05:40 2007
@@ -1,8 +1,16 @@
 -------------------------------------------------------------------
+Wed Sep 12 18:48:00 CEST 2007 - ma@xxxxxxx
+
+- Various disk space calculation fixes. Susetags, plaindir and rpmdb
+  now provide more detailed disk usage information.
+  Yum metadata don't, so we book the package size to '/'. (#308362)
+- version 3.23.0
+
+-------------------------------------------------------------------
 Wed Sep 12 15:48:41 CEST 2007 - schubi@xxxxxxx
 
 - Regarding keep state while recycle old valid solver results. Bug 286889
-- r 7209 
+- r 7209
 
 -------------------------------------------------------------------
 Wed Sep 12 12:24:49 CEST 2007 - jkupec@xxxxxxx
@@ -15,7 +23,7 @@
 
 - Update: rename language packages --> take that package which fits to the
   selected language Bug 308098
-- r 7919 
+- r 7919
 
 -------------------------------------------------------------------
 Tue Sep 11 16:11:20 CEST 2007 - dmacvicar@xxxxxxx

Modified: trunk/libzypp/zypp/DiskUsageCounter.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/DiskUsageCounter.cc?rev=7225&r1=7224&r2=7225&view=diff
==============================================================================
--- trunk/libzypp/zypp/DiskUsageCounter.cc (original)
+++ trunk/libzypp/zypp/DiskUsageCounter.cc Wed Sep 12 19:05:40 2007
@@ -17,159 +17,70 @@
 #include <iostream>
 #include <fstream>
 
+#include "zypp/base/Easy.h"
 #include "zypp/base/Logger.h"
 #include "zypp/base/String.h"
 
 #include "zypp/DiskUsageCounter.h"
 #include "zypp/Package.h"
 
+using std::endl;
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
-  DiskUsageCounter::MountPointSet DiskUsageCounter::disk_usage(const ResPool &pool)
+  DiskUsageCounter::MountPointSet DiskUsageCounter::disk_usage( const ResPool & pool_r )
   {
-    MountPointSet result = mps;
+    DiskUsageCounter::MountPointSet result = mps;
 
-    if (mps.empty())
+    if ( result.empty() )
     {
       // partitioning is not set
       return result;
     }
 
     // set used size after commit to the current used size
-    for (MountPointSet::iterator mpit = result.begin();
-      mpit != result.end();
-      mpit++)
+    for_( it, result.begin(), result.end() )
     {
-      mpit->pkg_size = mpit->used_size;
+      it->pkg_size = it->used_size;
     }
 
-    // iterate through all packages
-    for (ResPool::byKind_iterator it = pool.byKindBegin(ResTraits<Package>::kind);
-      it != pool.byKindEnd(ResTraits<Package>::kind);
-      ++it)
+    // iterate through all items
+    for_( it, pool_r.begin(), pool_r.end() )
     {
-      bool inst = it->status().isToBeInstalled();
-      bool rem = it->status().isToBeUninstalled();
+      DiskUsage du( (*it)->diskusage() );
 
-      // if the package is not selected for installation or removing
-      // it can't affect disk usage
-      if (inst || rem)
+      // skip items without du info
+      if ( du.empty() )
+        continue; // or find some substitute info
+
+      // skip items that do not transact
+      if ( ! it->status().transacts() )
+        continue;
+
+      // traverse mountpoints in reverse order. This is done beacuse
+      // DiskUsage::extract computes the mountpoint size, and then
+      // removes the entry. So we must process leaves first.
+      for_( mpit, result.rbegin(), result.rend() )
       {
-       Package::constPtr pkg = asKind<Package>( it->resolvable() );
-       DiskUsage du = pkg->diskusage();
-       DiskUsage du_another_package;
-       Edition edition_another_package;
-
-       // the same package has been selected for installation
-       bool found_installed = false;
-       // the same package has been selected for uninstallation
-       bool found_to_install = false;
-
-       // the du is empty or the package is selected for installation (check whether the package is already installed)
-       if (du.size() == 0 || inst)
-       {
-           // disk usage is unknown for already installed packages
-           // find the same package from any installation source
-           std::string name = (*it)->name();
-
-           for (ResPool::byName_iterator nameit = pool.byNameBegin(name);
-             nameit != pool.byNameEnd(name);
-             ++nameit)
-           {
-               // is version and architecture same?
-               if (isKind<Package>(nameit->resolvable()))
-               {
-                   // found a package
-                   Package::constPtr pkg_from_source = asKind<Package>( nameit->resolvable() );
-
-                   if (nameit->status().isToBeInstalled())
-                   {
-                       found_to_install = true;
-                   }
-
-                   // check the version
-                   if ((*it)->edition() == (*nameit)->edition() && (*it)->arch() == (*nameit)->arch())
-                   {
-                       if (inst)
-                       {
-                           if (nameit->status().isInstalled() && !nameit->status().isToBeUninstalled())
-                           {
-                               found_installed = true;
-                               XXX << name << '-' << (*it)->edition() << ": found already installed package (" << (*nameit)->edition() << ")" << std::endl;
-                           }
-                       }
-                       else
-                       {
-                           // the package will be uninstalled and du is empty, try to use du from another object
-                           du = pkg_from_source->diskusage();
-                           if (du.size() > 0)
-                           {
-                               XXX << name << '-' << (*it)->edition() << ": using DiskUsage from another Package object (" << (*nameit)->edition() << ")" << std::endl;
-                               break;
-                           }
-                       }
-                   }
-                   else
-                   {
-                       if (inst && nameit->status().isInstalled() && !nameit->status().isToBeUninstalled())
-                       {
-                           // just freshen the package, don't change du statistics
-                           found_installed = true;
-                           XXX << name << '-' << (*it)->edition() << ": found already installed package (" << (*nameit)->edition() << ")" << std::endl;
-                       }
-                       else if (pkg_from_source->diskusage().size() > 0)
-                       {
-                           // found different version of the package, remember the disk usage
-                           // it will be used the same version is not found
-                           du_another_package = pkg_from_source->diskusage();
-                           edition_another_package = (*nameit)->edition();
-                       }
-                   }
-               }
-           }
-
-           // don't subtract the disk usage for updated package
-           if (du.size() == 0 && du_another_package.size() > 0 && !(rem && found_to_install))
-           {
-               XXX << name << '-' << (*it)->edition() << ": using DU info from version " << edition_another_package << std::endl;
-               du = du_another_package;
-           }
-       }
+        // Extract usage for the mount point
+        DiskUsage::Entry entry = du.extract( mpit->dir );
 
-       // don't modify du if the installed package is already installed (freshening)
-       if (du.size() > 0 && !(inst && found_installed))
-       {
-         // iterate trough all mount points, add usage to each directory
-         // directory tree must be processed from leaves to the root directory
-         // so iterate in reverse order so e.g. /usr is used before /
-         for (MountPointSet::reverse_iterator mpit = result.rbegin();
-           mpit != result.rend();
-           mpit++)
-         {
-           // get usage for the mount point
-           DiskUsage::Entry entry = du.extract(mpit->dir);
-
-           // add or subtract it to the current value
-           if (inst)
-           {
-               mpit->pkg_size += entry._size;
-           }
-           else // the package will be uninstalled
-           {
-               mpit->pkg_size -= entry._size;
-           }
-         }
-       }
+        // Adjust the data.
+        if ( it->status().isInstalled() )
+        {
+          mpit->pkg_size -= entry._size;
+        }
+        else
+        {
+          mpit->pkg_size += entry._size;
+        }
       }
     }
-
     return result;
   }
 
-
   DiskUsageCounter::MountPointSet DiskUsageCounter::detectMountPoints(const std::string &rootdir)
   {
     DiskUsageCounter::MountPointSet ret;
@@ -308,8 +219,8 @@
     str << "dir:[" << obj.dir << "] [ bs: " << obj.block_size
         << " ts: " << obj.total_size
         << " us: " << obj.used_size
-        << " +-: " << obj.pkg_size
-        << "]" << std::endl;
+        << " (+-: " << (obj.pkg_size-obj.used_size)
+        << ")]" << std::endl;
     return str;
   }
 

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages