- Fixed YUM parser, database schema, RepoImpl, PatchRpm and DeltaRpm
authorMichael Andres <ma@suse.de>
Fri, 14 Sep 2007 21:13:47 +0000 (21:13 +0000)
committerMichael Andres <ma@suse.de>
Fri, 14 Sep 2007 21:13:47 +0000 (21:13 +0000)
  to parse, store and provide patch/delta rpms name edition and architecture,
  filtering incomatible archs.
- Fixed DeltaCandidates to filter patch/delta rpms that done match the target
  packages NVRA.

13 files changed:
VERSION.cmake
devel/devel.ma/Parse.cc
package/libzypp.changes
tests/cache/CacheStore_test.cc
zypp/cache/CacheStore.cc
zypp/cache/schema/schema.sql
zypp/data/ResolvableData.cc
zypp/data/ResolvableData.h
zypp/parser/yum/PatchFileReader.cc
zypp/repo/DeltaCandidates.cc
zypp/repo/PackageDelta.cc
zypp/repo/PackageDelta.h
zypp/repo/cached/RepoImpl.cc

index 72f3c68..9c2d7f3 100644 (file)
@@ -45,6 +45,6 @@
 #
 
 SET(LIBZYPP_MAJOR "3")
-SET(LIBZYPP_MINOR "23")
-SET(LIBZYPP_COMPATMINOR "23")
-SET(LIBZYPP_PATCH "2")
+SET(LIBZYPP_MINOR "24")
+SET(LIBZYPP_COMPATMINOR "24")
+SET(LIBZYPP_PATCH "0")
index 08f3852..1f93913 100644 (file)
@@ -59,10 +59,17 @@ bool queryInstalledEditionHelper( const std::string & name_r,
                                   const Edition &     ed_r,
                                   const Arch &        arch_r )
 {
-  INT << name_r << "-" << ed_r << "." << arch_r << endl;
+  if ( ed_r == Edition::noedition )
+    return true;
+  if ( name_r == "kernel-default" && ed_r == Edition("2.6.22.5-10") )
+    return true;
+  if ( name_r == "update-test-affects-package-manager" && ed_r == Edition("1.1-6") )
+    return true;
+
   return false;
 }
 
+
 ManagedFile repoProvidePackage( const PoolItem & pi )
 {
   ResPool _pool( getZYpp()->pool() );
@@ -528,7 +535,8 @@ int main( int argc, char * argv[] )
        repoManager.cleanCache( nrepo );
       }
       SEC << "refreshMetadata" << endl;
-      repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced );
+      //repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced );
+      repoManager.refreshMetadata( nrepo );
       SEC << "buildCache" << endl;
       repoManager.buildCache( nrepo );
     }
@@ -545,7 +553,7 @@ int main( int argc, char * argv[] )
   USR << "pool: " << pool << endl;
   SEC << pool.knownRepositoriesSize() << endl;
 
-  if ( 1 )
+  if ( 0 )
   {
     {
        zypp::base::LogControl::TmpLineWriter shutUp;
@@ -563,9 +571,14 @@ int main( int argc, char * argv[] )
   DBG << "patch: " << deltas.patchRpms(0).size() << " " << deltas.patchRpms(0) << endl;
   DBG << "delta: " << deltas.deltaRpms(0).size() << " " << deltas.deltaRpms(0) << endl;
 
+  PoolItem pi( getPi<Package>( "kernel-default", Edition("2.6.22.5-12") ) );
+  USR << pi << endl;
+  USR << repoProvidePackage( pi ) << endl;
 
-  PoolItem pi( getPi<Package>( "kernel-default" ) );
+  pi = getPi<Package>( "update-test-affects-package-manager", Edition("99-99") );
   USR << pi << endl;
+  USR << repoProvidePackage( pi ) << endl;
+
 
  ///////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
index 5172e97..dc26eba 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Fri Sep 14 22:57:54 CEST 2007 - ma@suse.de
+
+- Enable using patch and delta rpms. (#309124)
+- version 3.24.0
+
+-------------------------------------------------------------------
 Thu Sep 13 17:59:55 CEST 2007 - ma@suse.de
 
 - On update do not delete unmaintained non-SuSE packages.
index 1cb356a..592ccb1 100644 (file)
@@ -467,7 +467,8 @@ void cache_delta_rpm_test(const string &dir)
   // 22 packages and 6 patches
   BOOST_CHECK_EQUAL( repositoryImpl->resolvables().size(), 42 );
   // 19 patch rpms
-  BOOST_CHECK_EQUAL( repositoryImpl->patchRpms().size(), 19 );
+  // but only 13 are compatible with x86_64_
+  BOOST_CHECK_EQUAL( repositoryImpl->patchRpms().size(), 13 );
   //check_tables_clean(tmpdir);
 }
 
index 112ea84..218c36b 100644 (file)
@@ -122,13 +122,13 @@ struct CacheStore::Impl
     count_shared_cmd.reset( new sqlite3_command( con, "select count(id) from resolvables where shared_id=:rid;" ));
 
     insert_patchrpm_cmd.reset( new sqlite3_command (con,
-      "insert into patch_packages (repository_id, media_nr, location, checksum, checksum_type, download_size, build_time) "
-      "values (:repository_id, :media_nr, :location, :checksum, :checksum_type, :download_size, :build_time);" ));
+      "insert into patch_packages (repository_id, name, version, release, epoch, arch, media_nr, location, checksum, checksum_type, download_size, build_time) "
+      "values (:repository_id, :name, :version, :release, :epoch, :arch, :media_nr, :location, :checksum, :checksum_type, :download_size, :build_time);" ));
     insert_deltarpm_cmd.reset( new sqlite3_command (con,
-      "insert into delta_packages (repository_id, media_nr, location, checksum, checksum_type, download_size, build_time, "
+      "insert into delta_packages (repository_id, name, version, release, epoch, arch, media_nr, location, checksum, checksum_type, download_size, build_time, "
         "baseversion_version, baseversion_release, baseversion_epoch, baseversion_checksum, "
         "baseversion_build_time, baseversion_sequence_info) "
-      "values (:repository_id, :media_nr, :location, :checksum, :checksum_type, :download_size, :build_time, "
+      "values (:repository_id, :name, :version, :release, :epoch, :arch, :media_nr, :location, :checksum, :checksum_type, :download_size, :build_time, "
         ":baseversion_version, :baseversion_release, :baseversion_epoch, :baseversion_checksum, "
         ":baseversion_build_time, :baseversion_sequence_info);" ));
     append_patch_baseversion_cmd.reset( new sqlite3_command (con,
@@ -743,12 +743,18 @@ RecordId CacheStore::appendPatchRpm(const zypp::data::RecordId &repository_id, c
 {
   RecordId id;
 
-  //! \todo what's this? _pimpl->insert_patchrpm_cmd->bind(":media_nr", ???);
   _pimpl->insert_patchrpm_cmd->bind(":repository_id", repository_id);
+
+  _pimpl->insert_patchrpm_cmd->bind(":name",    prpm->name);
+  _pimpl->insert_patchrpm_cmd->bind(":version", prpm->edition.version());
+  _pimpl->insert_patchrpm_cmd->bind(":release", prpm->edition.release());
+  _pimpl->insert_patchrpm_cmd->bind(":epoch",   (int) prpm->edition.epoch());
+  _pimpl->insert_patchrpm_cmd->bind(":arch",    lookupOrAppendType("arch", prpm->arch.asString()));
+
+  _pimpl->insert_patchrpm_cmd->bind(":media_nr", (int) prpm->location.medianr());
   _pimpl->insert_patchrpm_cmd->bind(":location", prpm->location.filename().asString());
   _pimpl->insert_patchrpm_cmd->bind(":checksum", prpm->location.checksum().checksum());
   _pimpl->insert_patchrpm_cmd->bind(":checksum_type", prpm->location.checksum().type());
-  //! \todo checksum type
   _pimpl->insert_patchrpm_cmd->bind(":download_size", static_cast<ByteCount::SizeType>(prpm->location.downloadSize()));
   _pimpl->insert_patchrpm_cmd->bind(":build_time", prpm->buildTime.asSeconds());
   _pimpl->insert_patchrpm_cmd->executenonquery();
@@ -774,13 +780,19 @@ RecordId CacheStore::appendDeltaRpm(const zypp::data::RecordId &repository_id, c
 {
   RecordId id;
 
-  //! \todo what's this? _pimpl->insert_deltarpm_cmd->bind(":media_nr", ???);
   _pimpl->insert_deltarpm_cmd->bind(":repository_id", repository_id);
+
+  _pimpl->insert_deltarpm_cmd->bind(":name",    drpm->name);
+  _pimpl->insert_deltarpm_cmd->bind(":version", drpm->edition.version());
+  _pimpl->insert_deltarpm_cmd->bind(":release", drpm->edition.release());
+  _pimpl->insert_deltarpm_cmd->bind(":epoch",   (int) drpm->edition.epoch());
+  _pimpl->insert_deltarpm_cmd->bind(":arch",    lookupOrAppendType("arch", drpm->arch.asString()));
+
+  _pimpl->insert_deltarpm_cmd->bind(":media_nr", (int) drpm->location.medianr());
   _pimpl->insert_deltarpm_cmd->bind(":location", drpm->location.filename().asString());
   _pimpl->insert_deltarpm_cmd->bind(":checksum", drpm->location.checksum().checksum());
   _pimpl->insert_deltarpm_cmd->bind(":checksum", drpm->location.checksum().checksum());
   _pimpl->insert_deltarpm_cmd->bind(":checksum_type", drpm->location.checksum().type());
-  //! \todo checksum type
   _pimpl->insert_deltarpm_cmd->bind(":download_size", static_cast<ByteCount::SizeType>(drpm->location.downloadSize()));
   _pimpl->insert_deltarpm_cmd->bind(":build_time", drpm->buildTime.asSeconds());
 
index a1be314..160e6a2 100644 (file)
@@ -166,6 +166,11 @@ CREATE TABLE locks (
 
 CREATE TABLE delta_packages (
     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
+  , name TEXT
+  , version TEXT
+  , release TEXT
+  , epoch INTEGER
+  , arch INTEGER REFERENCES types(id)
   , media_nr INTEGER
   , location TEXT
   , checksum TEXT
@@ -185,6 +190,11 @@ CREATE INDEX delta_package_repository_id ON delta_packages(repository_id);
 
 CREATE TABLE patch_packages (
     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
+  , name TEXT
+  , version TEXT
+  , release TEXT
+  , epoch INTEGER
+  , arch INTEGER REFERENCES types(id)
   , media_nr INTEGER
   , location TEXT
   , checksum TEXT
@@ -319,7 +329,7 @@ CREATE TRIGGER remove_resolvables
     DELETE FROM file_capabilities WHERE resolvable_id = old.id;
     DELETE FROM split_capabilities WHERE resolvable_id = old.id;
     DELETE FROM other_capabilities WHERE resolvable_id = old.id;
-    
+
     DELETE FROM text_attributes  WHERE weak_resolvable_id = old.id;
     DELETE FROM numeric_attributes  WHERE weak_resolvable_id = old.id;
     DELETE FROM resolvable_disk_usage WHERE resolvable_id = old.id;
index 233a117..4c75556 100644 (file)
@@ -49,5 +49,12 @@ std::ostream & ResObject::dumpOn( std::ostream & str ) const
 //       << "  enhances:" << endl << enhances << endl
 }
 
+
+std::ostream & RpmBase::dumpOn( std::ostream & str ) const
+{
+  str << "Patch/Delta[ " << name << " " << edition << " " << arch << " ]";
+  return str;
+}
+
 } // namespace cache
 } // namespace zypp
index 23c630c..e13eae4 100644 (file)
@@ -368,18 +368,16 @@ namespace data
   {
     // Base <patchrpm>/<deltarpm> element attributes
 
-    Arch attr_arch;
-    std::string attr_filename;
-    std::string attr_md5sum;
-    ByteCount attr_downloadSize;
-    Date attr_buildTime;
-
-    // Shared RPM data
-
+    std::string     name;     // target rpm name
+    Edition         edition;  // target rpm edition
+    Arch            arch;     // target rpm architecture
     OnMediaLocation location;
-    Date buildTime;
-    Date fileTime;
-    ByteCount archiveSize; // ??
+    Date            buildTime;
+    Date            fileTime;
+    ByteCount       archiveSize; // ??
+    protected:
+      /** Overload to realize std::ostream & operator\<\<. */
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
   };
 
   DEFINE_PTR_TYPE(PatchRpm);
index a0532e9..44545cb 100644 (file)
@@ -16,6 +16,7 @@
 #include "zypp/parser/yum/PatchFileReader.h"
 #include "zypp/parser/yum/FileReaderBaseImpl.h"
 
+#include "zypp/ZConfig.h"
 
 #undef ZYPP_BASE_LOGGER_LOGGROUP
 #define ZYPP_BASE_LOGGER_LOGGROUP "parser::yum"
@@ -481,8 +482,16 @@ namespace zypp
         data::PatchRpm_Ptr tmp;
         tmp.swap(_patchrpm);
         data::PackageAtom_Ptr patom_ptr = zypp::dynamic_pointer_cast<data::PackageAtom>(_tmpResObj);
-        if (patom_ptr)
+        if (patom_ptr && patom_ptr->arch.compatibleWith( ZConfig::instance().systemArchitecture() ))
+        {
+          // Patch and delta rpms are standalone objects.
+          // We must store the target packages NVRA.
+          // We don't store incompatible archs.
+          tmp->name    = patom_ptr->name;
+          tmp->edition = patom_ptr->edition;
+          tmp->arch    = patom_ptr->arch;
           patom_ptr->patchRpms.insert(tmp);
+        }
         toParentTag();
         return true;
       }
@@ -493,8 +502,16 @@ namespace zypp
         data::DeltaRpm_Ptr tmp;
         tmp.swap(_deltarpm);
         data::PackageAtom_Ptr patom_ptr = zypp::dynamic_pointer_cast<data::PackageAtom>(_tmpResObj);
-        if (patom_ptr)
+        if (patom_ptr && patom_ptr->arch.compatibleWith( ZConfig::instance().systemArchitecture() ))
+        {
+          // Patch and delta rpms are standalone objects.
+          // We must store the target packages NVRA.
+          // We don't store incompatible archs.
+          tmp->name    = patom_ptr->name;
+          tmp->edition = patom_ptr->edition;
+          tmp->arch    = patom_ptr->arch;
           patom_ptr->deltaRpms.insert(tmp);
+        }
         toParentTag();
         return true;
       }
index 2cd610b..0ad94b1 100644 (file)
@@ -27,18 +27,18 @@ namespace zypp
     {
 
     public:
-      
+
       Impl( const std::list<Repository> & repos )
         : repos(repos)
       {
-      
+
       }
 
       friend Impl * rwcowClone<Impl>( const Impl * rhs );
       /** clone for RWCOW_pointer */
       Impl * clone() const
       { return new Impl( *this ); }
-      
+
       std::list<Repository> repos;
     };
     ///////////////////////////////////////////////////////////////////
@@ -59,7 +59,7 @@ namespace zypp
     std::list<PatchRpm> DeltaCandidates::patchRpms(const Package::constPtr & package ) const
     {
       std::list<PatchRpm> candidates;
-      
+
       // query all repos
       for ( std::list<Repository>::const_iterator it = _pimpl->repos.begin();
             it != _pimpl->repos.end();
@@ -71,17 +71,22 @@ namespace zypp
               dit != candidates_in_repo.end();
               ++dit )
         {
-          PatchRpm delta(*dit);
-          candidates.push_back(delta);
+          if ( ! package
+               || (    package->name()    == dit->name()
+                    && package->edition() == dit->edition()
+                    && package->arch()    == dit->arch() ) )
+          {
+            candidates.push_back( *dit );
+          }
         }
       }
       return candidates;
     }
-    
+
     std::list<DeltaRpm> DeltaCandidates::deltaRpms(const Package::constPtr & package) const
     {
       std::list<DeltaRpm> candidates;
-      
+
       // query all repos
       for ( std::list<Repository>::const_iterator it = _pimpl->repos.begin();
             it != _pimpl->repos.end();
@@ -93,13 +98,18 @@ namespace zypp
               dit != candidates_in_repo.end();
               ++dit )
         {
-          DeltaRpm delta(*dit);
-          candidates.push_back(delta);
+           if ( ! package
+               || (    package->name()    == dit->name()
+                    && package->edition() == dit->edition()
+                    && package->arch()    == dit->arch() ) )
+          {
+            candidates.push_back( *dit );
+          }
         }
       }
       return candidates;
     }
-    
+
     std::ostream & operator<<( std::ostream & str, const DeltaCandidates & obj )
     {
       return str << *obj._pimpl;
index 5981b10..0299b6c 100644 (file)
@@ -28,7 +28,8 @@ namespace zypp
     std::ostream & operator<<( std::ostream & str, const PatchRpm & obj )
     {
       str
-      << "PatchRpm(" << obj.location()
+      << "PatchRpm[" << obj.name() << "-" << obj.edition() << "." << obj.arch()
+      << "](" << obj.location()
       << '|' << obj.buildtime()
       << '|';
       return dumpRangeLine( str, obj.baseversions().begin(), obj.baseversions().end() )
@@ -38,7 +39,8 @@ namespace zypp
     std::ostream & operator<<( std::ostream & str, const DeltaRpm & obj )
     {
       return str
-      << "DeltaRpm(" << obj.location()
+      << "DeltaRpm[" << obj.name() << "-" << obj.edition() << "." << obj.arch()
+      << "](" << obj.location()
       << '|' << obj.buildtime()
       << '|' << obj.baseversion().edition()
       << ',' << obj.baseversion().buildtime()
index 2a22a82..ecc0740 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "zypp/OnMediaLocation.h"
 #include "zypp/Edition.h"
+#include "zypp/Arch.h"
 #include "zypp/Date.h"
 
 ///////////////////////////////////////////////////////////////////
@@ -28,6 +29,7 @@ namespace zypp
 
     ///////////////////////////////////////////////////////////////////
 
+    /** \todo cheap copy! (switch to RWCOW) */
     class PatchRpm
     {
     public:
@@ -39,17 +41,29 @@ namespace zypp
       {}
 
     public:
+      /** \name Target package ident. */
+      //@{
+      const std::string &     name()         const { return _name; }
+      const Edition &         edition()      const { return _edition; }
+      const Arch &            arch()         const { return _arch; }
+      //@}
       const OnMediaLocation & location()     const { return _location; }
       const BaseVersions &    baseversions() const { return _baseversions; }
       const Date &            buildtime()    const { return _buildtime;}
 
     public:
+      PatchRpm & setName( const std::string & val_r )         { _name = val_r; return *this; }
+      PatchRpm & setEdition( const Edition & val_r )          { _edition = val_r; return *this; }
+      PatchRpm & setArch( const Arch & val_r )                { _arch = val_r; return *this; }
       PatchRpm & setLocation( const OnMediaLocation & val_r ) { _location = val_r; return *this; }
       PatchRpm & setBaseversions( const BaseVersions & val_r ){ _baseversions = val_r; return *this; }
       PatchRpm & addBaseversion( const BaseVersion & val_r )  { _baseversions.push_back( val_r ); return *this; }
       PatchRpm & setBuildtime( const Date & val_r )           { _buildtime = val_r; return *this; }
 
     private:
+      std::string     _name;
+      Edition         _edition;
+      Arch            _arch;
       OnMediaLocation _location;
       BaseVersions    _baseversions;
       Date            _buildtime;
@@ -60,6 +74,7 @@ namespace zypp
 
     ///////////////////////////////////////////////////////////////////
 
+    /** \todo cheap copy! (switch to RWCOW) */
     class DeltaRpm
     {
     public:
@@ -95,16 +110,28 @@ namespace zypp
       {}
 
     public:
+      /** \name Target package ident. */
+      //@{
+      const std::string &     name()         const { return _name; }
+      const Edition &         edition()      const { return _edition; }
+      const Arch &            arch()         const { return _arch; }
+      //@}
       const OnMediaLocation & location()     const { return _location; }
       const BaseVersion &     baseversion()  const { return _baseversion; }
       const Date &            buildtime()    const { return _buildtime;}
 
     public:
+      DeltaRpm & setName( const std::string & val_r )         { _name = val_r; return *this; }
+      DeltaRpm & setEdition( const Edition & val_r )          { _edition = val_r; return *this; }
+      DeltaRpm & setArch( const Arch & val_r )                { _arch = val_r; return *this; }
       DeltaRpm & setLocation( const OnMediaLocation & val_r ) { _location = val_r; return *this; }
       DeltaRpm & setBaseversion( const BaseVersion & val_r )  { _baseversion = val_r; return *this; }
       DeltaRpm & setBuildtime( const Date & val_r )           { _buildtime = val_r; return *this; }
 
     private:
+      std::string     _name;
+      Edition         _edition;
+      Arch            _arch;
       OnMediaLocation _location;
       BaseVersion     _baseversion;
       Date            _buildtime;
index 6a0d98c..6d7aa13 100644 (file)
@@ -187,59 +187,62 @@ void RepoImpl::createPatchAndDeltas()
     con.executenonquery("PRAGMA cache_size=8000;");
     con.executenonquery("BEGIN;");
 
-    string pp_query =
-   //     0       1          2         3        4              5 
-    "SELECT id, media_nr, location, checksum, checksum_type, download_size, build_time "
-    "FROM patch_packages WHERE repository_id=:repository_id;";
-
-    string pp_bv_query =
-    "SELECT version, release, epoch "
-    "FROM patch_packages_baseversions WHERE patch_package_id = :patch_package_id";
-
-    string delta_query =
-    //       0     1        2          3        4               5              6                      7                      8                 9                     10  11
-    "SELECT id, media_nr, location, checksum, checksum_type, download_size, build_time,  baseversion_version, baseversion_release, baseversion_epoch, baseversion_checksum, baseversion_checksum_type, baseversion_build_time "
-    //    11
-    ", baseversion_sequence_info "
-    "FROM delta_packages WHERE repository_id=:repository_id;";
-    
+    // Refer to the enum when retrieving the data from reader.
+
+    enum pp_query_val {    pp_id, pp_name, pp_version, pp_release, pp_epoch, pp_arch, pp_media_nr, pp_location, pp_checksum, pp_checksum_type, pp_download_size, pp_build_time };
+    string pp_query = "SELECT id,    name,    version,    release,    epoch,    arch,    media_nr,    location,    checksum,    checksum_type,    download_size,    build_time "
+
+                      "FROM patch_packages WHERE repository_id=:repository_id;";
+
+    enum pp_bv_query_val { pp_bv_version, pp_bv_release, pp_bv_epoch };
+    string pp_bv_query = "SELECT version,       release,       epoch "
+
+                         "FROM patch_packages_baseversions WHERE patch_package_id = :patch_package_id";
+
+    enum dp_query_val {    dp_id, dp_name, dp_version, dp_release, dp_epoch, dp_arch, dp_media_nr, dp_location, dp_checksum, dp_checksum_type, dp_download_size, dp_build_time,  dp_baseversion_version, dp_baseversion_release, dp_baseversion_epoch, dp_baseversion_checksum, dp_baseversion_checksum_type, dp_baseversion_build_time, dp_baseversion_sequence_info };
+    string dp_query = "SELECT id,    name,    version,    release,    epoch,    arch,    media_nr,    location,    checksum,    checksum_type,    download_size,    build_time,     baseversion_version,    baseversion_release,    baseversion_epoch,    baseversion_checksum,    baseversion_checksum_type,    baseversion_build_time,    baseversion_sequence_info "
+
+                      "FROM delta_packages WHERE repository_id=:repository_id;";
+
     {
       // bind the master repo id to the query
-      sqlite3_command deltas_cmd( con, delta_query);
+      sqlite3_command deltas_cmd( con, dp_query);
       deltas_cmd.bind(":repository_id", _options.repository_id);
       sqlite3_reader reader = deltas_cmd.executereader();
       while ( reader.read() )
       {
-        zypp::OnMediaLocation on_media( reader.getstring(2), reader.getint(1) );
-  
-        string checksum_string(reader.getstring(3));
-        CheckSum checksum(reader.getstring(4), reader.getstring(3));
+        zypp::OnMediaLocation on_media( reader.getstring(dp_location), reader.getint(dp_media_nr) );
+
+        CheckSum checksum(reader.getstring(dp_checksum_type), reader.getstring(dp_checksum));
         if ( checksum.empty() )
         {
           ERR << "Wrong checksum for delta, skipping..." << endl;
           continue;
         }
         on_media.setChecksum(checksum);
-        on_media.setDownloadSize(reader.getint(5));
-  
+        on_media.setDownloadSize(reader.getint(dp_download_size));
+
         packagedelta::DeltaRpm::BaseVersion baseversion;
-        baseversion.setEdition( Edition(reader.getstring(7), reader.getstring(8), reader.getstring(9) ) );
-  
-        checksum = CheckSum(reader.getstring(11), reader.getstring(10));
+        baseversion.setEdition( Edition(reader.getstring(dp_baseversion_version), reader.getstring(dp_baseversion_release), reader.getstring(dp_baseversion_epoch) ) );
+
+        checksum = CheckSum(reader.getstring(dp_baseversion_checksum_type), reader.getstring(dp_baseversion_checksum));
         if ( checksum.empty() )
         {
           ERR << "Wrong checksum for delta, skipping..." << endl;
           continue;
         }
         baseversion.setChecksum(checksum);
-        baseversion.setBuildtime(reader.getint(12));
-        baseversion.setSequenceinfo(reader.getstring(13));
-  
+        baseversion.setBuildtime(reader.getint(dp_baseversion_build_time));
+        baseversion.setSequenceinfo(reader.getstring(dp_baseversion_sequence_info));
+
         zypp::packagedelta::DeltaRpm delta;
+        delta.setName   ( reader.getstring(dp_name) );
+        delta.setEdition( Edition( reader.getstring(dp_version), reader.getstring(dp_release), reader.getint(dp_epoch) ) );
+        delta.setArch   ( _type_cache.archFor( reader.getint(dp_arch) ) );
         delta.setLocation( on_media );
         delta.setBaseversion( baseversion );
-        delta.setBuildtime(reader.getint(6));
-  
+        delta.setBuildtime(reader.getint(dp_build_time));
+
         _deltaRpms.push_back(delta);
       }
       reader.close();
@@ -252,40 +255,45 @@ void RepoImpl::createPatchAndDeltas()
       sqlite3_command pp_bv_cmd( con, pp_bv_query);
       pp_cmd.bind(":repository_id", _options.repository_id);
       sqlite3_reader reader = pp_cmd.executereader();
-  
+
       while ( reader.read() )
       {
         //MIL << "Addining patch rpm " << endl;
-        long long patch_package_id = reader.getint64(0);
-  
-        zypp::OnMediaLocation on_media( reader.getstring(2), reader.getint(1) );
-  
-        CheckSum checksum(reader.getstring(4), reader.getstring(3));
+        long long patch_package_id = reader.getint64(pp_id);
+
+        zypp::OnMediaLocation on_media( reader.getstring(pp_location), reader.getint(pp_media_nr) );
+
+        CheckSum checksum(reader.getstring(pp_checksum_type), reader.getstring(pp_checksum));
         if ( checksum.empty() )
         {
           ERR << "Wrong checksum for delta, skipping..." << endl;
           continue;
         }
         on_media.setChecksum(checksum);
-        on_media.setDownloadSize(reader.getint(5));
-  
+        on_media.setDownloadSize(reader.getint(pp_download_size));
+
         zypp::packagedelta::PatchRpm patch;
+        patch.setName   ( reader.getstring(pp_name) );
+        patch.setEdition( Edition( reader.getstring(pp_version), reader.getstring(pp_release), reader.getint(pp_epoch) ) );
+        patch.setArch   ( _type_cache.archFor( reader.getint(pp_arch) ) );
         patch.setLocation( on_media );
-        patch.setBuildtime(reader.getint(6));
-  
+        patch.setBuildtime(reader.getint(pp_build_time));
+
         pp_bv_cmd.bind( ":patch_package_id", patch_package_id );
-  
+
         sqlite3_reader bv_reader = pp_bv_cmd.executereader();
         while (bv_reader.read())
         {
           //MIL << "  * Adding baseversion " << endl;
-          packagedelta::PatchRpm::BaseVersion baseversion = packagedelta::PatchRpm::BaseVersion( bv_reader.getstring(0) , bv_reader.getstring(1), bv_reader.getint(2) );
+          packagedelta::PatchRpm::BaseVersion baseversion = packagedelta::PatchRpm::BaseVersion( bv_reader.getstring(pp_bv_version) ,
+                                                                                                 bv_reader.getstring(pp_bv_release),
+                                                                                                 bv_reader.getint(pp_bv_epoch) );
           patch.addBaseversion(baseversion);
         }
-  
+
         bv_reader.close();
-        
-        _patchRpms.push_back(patch);        
+
+        _patchRpms.push_back(patch);
       }
       reader.close();
       MIL << _patchRpms.size() << " patch rpms read." << endl;