Mailinglist Archive: zypp-commit (731 mails)

< Previous Next >
[zypp-commit] r6513 - in /trunk/libzypp: ./ package/ tests/cache/ zypp/ zypp/cache/ zypp/parser/susetags/ zypp/repo/cached/
  • From: dmacvicar@xxxxxxxxxxxxxxxx
  • Date: Tue, 07 Aug 2007 15:35:57 -0000
  • Message-id: <20070807153557.E45ABCDF82@xxxxxxxxxxxxxxxx>
Author: dmacvicar
Date: Tue Aug  7 17:35:57 2007
New Revision: 6513

URL: http://svn.opensuse.org/viewcvs/zypp?rev=6513&view=rev
Log:
merge

Modified:
    trunk/libzypp/VERSION.cmake
    trunk/libzypp/package/libzypp.changes
    trunk/libzypp/tests/cache/CacheStore_test.cc
    trunk/libzypp/zypp/DiskUsageCounter.cc
    trunk/libzypp/zypp/DiskUsageCounter.h
    trunk/libzypp/zypp/cache/CacheStore.cc
    trunk/libzypp/zypp/cache/ResolvableQuery.cc
    trunk/libzypp/zypp/cache/ResolvableQuery.h
    trunk/libzypp/zypp/parser/susetags/PackagesDuFileReader.cc
    trunk/libzypp/zypp/parser/susetags/RepoParser.cc
    trunk/libzypp/zypp/repo/cached/PackageImpl.cc
    trunk/libzypp/zypp/repo/cached/SrcPackageImpl.cc

Modified: trunk/libzypp/VERSION.cmake
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/VERSION.cmake (original)
+++ trunk/libzypp/VERSION.cmake Tue Aug  7 17:35:57 2007
@@ -47,4 +47,4 @@
 SET(LIBZYPP_MAJOR "3")
 SET(LIBZYPP_MINOR "13")
 SET(LIBZYPP_COMPATMINOR "13")
-SET(LIBZYPP_PATCH "13")
+SET(LIBZYPP_PATCH "14")

Modified: trunk/libzypp/package/libzypp.changes
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Tue Aug  7 17:35:57 2007
@@ -1,4 +1,15 @@
 -------------------------------------------------------------------
+Tue Aug  7 17:04:47 CEST 2007 - dmacvicar@xxxxxxx
+
+- implement susetags support for compressed metadata
+  and testcases. (feature #301916)
+- implement disk usage in cache. For installation requires
+  some changes in YaST to setup the ZYpp getPartitions()
+  before repos are cached. (bug #293039)
+- added testcases for diskusage
+- 3.13.14
+
+-------------------------------------------------------------------
 Mon Aug  6 10:19:12 CEST 2007 - jkupec@xxxxxxx
 
 - fixed YUM parser to properly create source packages

Modified: trunk/libzypp/tests/cache/CacheStore_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/cache/CacheStore_test.cc?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/tests/cache/CacheStore_test.cc (original)
+++ trunk/libzypp/tests/cache/CacheStore_test.cc Tue Aug  7 17:35:57 2007
@@ -28,6 +28,8 @@
 #include "zypp/Product.h"
 #include "zypp/Patch.h"
 
+#include "zypp/ZYppFactory.h"
+
 #include "zypp/detail/ImplConnect.h"
 
 using namespace std;
@@ -67,6 +69,8 @@
   BOOST_CHECK_EQUAL( p->location().medianr(), 1);
   BOOST_CHECK_EQUAL( p->size(), 38850584);
   BOOST_CHECK_EQUAL( p->location().downloadSize(), 16356019);
+  
+  BOOST_CHECK_EQUAL( p->diskusage().size(), 3);
 }
 
 /**
@@ -409,7 +413,14 @@
   test->add(BOOST_PARAM_TEST_CASE(&cache_write_yum_test,
                                  (std::string const*)params, params+1));
 
-
+  DiskUsageCounter::MountPointSet mounts;
+  mounts.insert( DiskUsageCounter::MountPoint("/") );
+  mounts.insert( DiskUsageCounter::MountPoint("/etc") );
+  mounts.insert( DiskUsageCounter::MountPoint("/opt/kde3/share/mimelnk/video") );
+  mounts.insert( DiskUsageCounter::MountPoint("/foo") );
+  mounts.insert( DiskUsageCounter::MountPoint("/bar") );
+  getZYpp()->setPartitions(mounts);
+  
   test->add(BOOST_PARAM_TEST_CASE(&cache_write_susetags_normal_test,
                                  (std::string const*)params, params+1));
   test->add(BOOST_PARAM_TEST_CASE(&cache_write_susetags_gz_test,

Modified: trunk/libzypp/zypp/DiskUsageCounter.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/DiskUsageCounter.cc?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/zypp/DiskUsageCounter.cc (original)
+++ trunk/libzypp/zypp/DiskUsageCounter.cc Tue Aug  7 17:35:57 2007
@@ -299,5 +299,11 @@
     return ret;
   }
 
+  std::ostream & operator<<( std::ostream & str, const DiskUsageCounter::MountPoint & obj )
+  {
+    str << "dir:[" << obj.dir << "] [ bs: " << obj.block_size << " ts: " << obj.total_size << "]" << std::endl;
+    return str;
+  }
+  
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////

Modified: trunk/libzypp/zypp/DiskUsageCounter.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/DiskUsageCounter.h?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/zypp/DiskUsageCounter.h (original)
+++ trunk/libzypp/zypp/DiskUsageCounter.h Tue Aug  7 17:35:57 2007
@@ -99,6 +99,10 @@
     MountPointSet mps;
   };
   ///////////////////////////////////////////////////////////////////
+  
+  /** \relates DiskUsageCounter::MountPoint Stream output */
+  std::ostream & operator<<( std::ostream & str, const DiskUsageCounter::MountPoint & obj );
+  
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////

Modified: trunk/libzypp/zypp/cache/CacheStore.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/CacheStore.cc?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/zypp/cache/CacheStore.cc (original)
+++ trunk/libzypp/zypp/cache/CacheStore.cc Tue Aug  7 17:35:57 2007
@@ -54,6 +54,7 @@
 {
   Impl( const Pathname &dbdir )
   : name_cache_hits(0)
+  , dir_cache_hits(0)
   {
     // let the initializer go out of scope after it executes
     {
@@ -206,7 +207,9 @@
 
   map<string, RecordId> name_cache;
   map< pair<string,string>, RecordId> type_cache;
+  map<string, RecordId> dir_cache;
   int name_cache_hits;
+  int dir_cache_hits;
 };
 
 
@@ -471,6 +474,7 @@
       ZYPP_RETHROW(e);
     }
   }
+  //MIL << "disk usage for " << resolvable_id << " consumed" << endl;
 }
 
 void CacheStore::updatePackageLang( const data::RecordId & resolvable_id,
@@ -1023,6 +1027,11 @@
 
 RecordId CacheStore::lookupOrAppendDirName( const string &name )
 {
+  if ( _pimpl->dir_cache.find(name) != _pimpl->dir_cache.end() )
+  {
+    _pimpl->dir_cache_hits++;
+    return _pimpl->dir_cache[name];
+  }
   long long id = 0;
   try
   {
@@ -1034,6 +1043,7 @@
       _pimpl->insert_dirname_cmd->bind(":name", name);
       _pimpl->insert_dirname_cmd->executenonquery();
       id = _pimpl->con.insertid();
+      _pimpl->dir_cache[name] = id;
       return id;
    }
    return reader.getint64(0);

Modified: trunk/libzypp/zypp/cache/ResolvableQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/ResolvableQuery.cc?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/zypp/cache/ResolvableQuery.cc (original)
+++ trunk/libzypp/zypp/cache/ResolvableQuery.cc Tue Aug  7 17:35:57 2007
@@ -24,6 +24,7 @@
   sqlite3_command_ptr _cmd_attr_str;
   sqlite3_command_ptr _cmd_attr_tstr;
   sqlite3_command_ptr _cmd_attr_num;
+  sqlite3_command_ptr _cmd_disk_usage;
 
   Impl( const Pathname &dbdir)
   : _dbdir(dbdir)
@@ -37,9 +38,10 @@
 
     _cmd_attr_str.reset( new sqlite3_command( _con, "select a.text from text_attributes a,types l,types t where a.weak_resolvable_id=:rid and a.lang_id=l.id and a.attr_id=t.id and l.class=:lclass and l.name=:lname and t.class=:tclass and t.name=:tname;"));
 
-
     _cmd_attr_num.reset( new sqlite3_command( _con, "select a.value from numeric_attributes a,types t where a.weak_resolvable_id=:rid and a.attr_id=t.id and t.class=:tclass and t.name=:tname;"));
 
+    _cmd_disk_usage.reset( new sqlite3_command( _con, "select d.name,du.size,du.files from resolvable_disk_usage du,dir_names d where du.resolvable_id=:rid and du.dir_name_id=d.id;"));
+    
     MIL << "Creating Resolvable query impl" << endl;
     _fields = "id, name, version, release, epoch, arch, kind, installed_size, archive_size, install_only, build_time, install_time, repository_id";
   }
@@ -143,6 +145,20 @@
     return queryNumericAttributeInternal( _con, record_id, klass, name, default_value);
   }
 
+  void queryDiskUsage( const data::RecordId &record_id, DiskUsage &du )
+  {
+    _cmd_disk_usage->bind(":rid", record_id);
+    sqlite3_reader reader = _cmd_disk_usage->executereader();
+
+    while ( reader.read() )
+    {
+      DiskUsage::Entry entry(reader.getstring(0),
+                             reader.getint(1),
+                             reader.getint(2) );
+      du.add(entry);
+    }
+  }
+  
 private:
 
   int queryNumericAttributeInternal( sqlite3_connection &con,
@@ -308,6 +324,11 @@
   return _pimpl->queryTranslatedStringAttribute(record_id, klass, name, default_value );
 }
 
+void ResolvableQuery::queryDiskUsage( const data::RecordId &record_id, DiskUsage &du )
+{
+  _pimpl->queryDiskUsage(record_id, du);
+}
+
 //////////////////////////////////////////////////////////////////////////////
 
 } } // namespace zypp::cache

Modified: trunk/libzypp/zypp/cache/ResolvableQuery.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/ResolvableQuery.h?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/zypp/cache/ResolvableQuery.h (original)
+++ trunk/libzypp/zypp/cache/ResolvableQuery.h Tue Aug  7 17:35:57 2007
@@ -215,6 +215,11 @@
 
 
 
+      /**
+       * \short Query disk usage for a resolvable
+       */
+      void queryDiskUsage( const data::RecordId &record_id,
+                           DiskUsage &du );
     private:
       /** Implementation. */
       class Impl;

Modified: trunk/libzypp/zypp/parser/susetags/PackagesDuFileReader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/PackagesDuFileReader.cc?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/susetags/PackagesDuFileReader.cc (original)
+++ trunk/libzypp/zypp/parser/susetags/PackagesDuFileReader.cc Tue Aug  7 17:35:57 2007
@@ -12,6 +12,7 @@
 #include <iostream>
 #include "zypp/base/Easy.h"
 #include "zypp/base/Logger.h"
+#include "zypp/ZYppFactory.h"
 
 #include "zypp/parser/susetags/PackagesDuFileReader.h"
 #include "zypp/parser/susetags/FileReaderBaseImpl.h"
@@ -40,10 +41,27 @@
        public:
          Impl( const PackagesDuFileReader & parent_r )
          : BaseImpl( parent_r )
-         {}
+          , _counted_entries(0)
+          , _discarded_entries(0)
+         {
+            _mounts = getZYpp()->getPartitions();
+            if (_mounts.empty() )
+              _mounts =  DiskUsageCounter::detectMountPoints();
+            
+            for ( DiskUsageCounter::MountPointSet::const_iterator it = _mounts.begin();
+                  it != _mounts.end();
+                  ++ it )
+            {
+              MIL << "Partition " << *it << endl;
+            }
+          
+          }
 
          virtual ~Impl()
-         {}
+         {
+            MIL << "DiskUsage: consumed:[ " << _counted_entries
+                << " ] discarded:[ " << _discarded_entries << " ]" << endl;
+          }
 
          bool hasPackage() const
          { return _pkgData; }
@@ -115,9 +133,51 @@
             {
               if ( str::regex_match( *it, what, sizeEntryRX, str::match_extra ) )
               {
-                _data->diskusage.add( what[1],
-                                      str::strtonum<unsigned>(what[2]) + str::strtonum<unsigned>(what[3]),
-                                      str::strtonum<unsigned>(what[4]) + str::strtonum<unsigned>(what[5]) );
+                bool skip = true;
+                
+                // add slash if it's missing
+                std::string dd(what[1]);
+                if (dd.size() > 1 && dd[0] != '/')
+                {
+                 dd.insert(dd.begin(), '/');
+                }
+                
+                DiskUsage::Entry entry(dd,
+                                       str::strtonum<unsigned>(what[2]) + str::strtonum<unsigned>(what[3]),
+                                       str::strtonum<unsigned>(what[4]) + str::strtonum<unsigned>(what[5]) );
+                
+                // iterate over important mounts in reverse order, from the leaves to
+                // the root
+                for ( DiskUsageCounter::MountPointSet::reverse_iterator mit = _mounts.rbegin();
+                  mit != _mounts.rend();
+                  ++ mit )
+                {
+                  // if the directory we are adding is below one of the mount points
+                  // just add the mount point so it gets summed.
+                  //MIL << "is '" << entry.path << "' == '" << (*mit).dir << "' ?" << endl;
+                  // FIXME make this more clear
+                  if ( entry.path == ( ((*mit).dir[(*mit).dir.size()-1] == '/') ? (*mit).dir : ((*mit).dir + '/' ) ) )
+                  {
+                    // entry is a mountpoint, so we need to keep it
+                    //MIL << "yes" << endl;
+                    // just discard it
+                    _discarded_entries++;
+                    skip = false;
+                    break;
+                  }
+                  else
+                  {
+                    //MIL << "no" << endl;
+                  }
+                }
+                
+                // try next entry
+                if ( skip )
+                  continue;
+                
+                MIL << "adding entry for " << entry.path << endl;
+                _data->diskusage.add(entry);
+                _counted_entries++;
               }
               else
               {
@@ -134,6 +194,9 @@
          data::Packagebase_Ptr   _data;
          data::Package_Ptr       _pkgData;
          data::SrcPackage_Ptr    _srcpkgData;
+          DiskUsageCounter::MountPointSet _mounts;
+          int _counted_entries;
+          int _discarded_entries;
       };
       ///////////////////////////////////////////////////////////////////
 

Modified: trunk/libzypp/zypp/parser/susetags/RepoParser.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/RepoParser.cc?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/susetags/RepoParser.cc (original)
+++ trunk/libzypp/zypp/parser/susetags/RepoParser.cc Tue Aug  7 17:35:57 2007
@@ -466,7 +466,7 @@
        parseLocaleIf( ZConfig::instance().textLocale() );
 
         // Now process packages.DU.
-        if ( 0 ) // remove the if to enable, but leave the {} around.
+        //if ( 0 ) // remove the if to enable, but leave the {} around.
         {
           Pathname inputfile( getOptionalFile( _descrdir / "packages.DU" ) );
           PackagesDuFileReader reader;

Modified: trunk/libzypp/zypp/repo/cached/PackageImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/cached/PackageImpl.cc?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/cached/PackageImpl.cc (original)
+++ trunk/libzypp/zypp/repo/cached/PackageImpl.cc Tue Aug  7 17:35:57 2007
@@ -196,7 +196,7 @@
   {
     // lazy init
     _diskusage.reset( new DiskUsage );
-#warning FILL DU DATA FROM DB
+    _repository->resolvableQuery().queryDiskUsage( _id, *_diskusage );
   }
   return *_diskusage;
 }

Modified: trunk/libzypp/zypp/repo/cached/SrcPackageImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/cached/SrcPackageImpl.cc?rev=6513&r1=6512&r2=6513&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/cached/SrcPackageImpl.cc (original)
+++ trunk/libzypp/zypp/repo/cached/SrcPackageImpl.cc Tue Aug  7 17:35:57 2007
@@ -117,7 +117,7 @@
   {
     // lazy init
     _diskusage.reset( new DiskUsage );
-#warning FILL DU DATA FROM DB
+    _repository->resolvableQuery().queryDiskUsage( _id, *_diskusage );
   }
   return *_diskusage;
 }

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

< Previous Next >
This Thread
  • No further messages