Author: mlandres Date: Fri Sep 14 23:13:47 2007 New Revision: 7253 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7253&view=rev Log: - Fixed YUM parser, database schema, RepoImpl, PatchRpm and DeltaRpm 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. Modified: trunk/libzypp/VERSION.cmake trunk/libzypp/devel/devel.ma/Parse.cc trunk/libzypp/package/libzypp.changes trunk/libzypp/tests/cache/CacheStore_test.cc trunk/libzypp/zypp/cache/CacheStore.cc trunk/libzypp/zypp/cache/schema/schema.sql trunk/libzypp/zypp/data/ResolvableData.cc trunk/libzypp/zypp/data/ResolvableData.h trunk/libzypp/zypp/parser/yum/PatchFileReader.cc trunk/libzypp/zypp/repo/DeltaCandidates.cc trunk/libzypp/zypp/repo/PackageDelta.cc trunk/libzypp/zypp/repo/PackageDelta.h trunk/libzypp/zypp/repo/cached/RepoImpl.cc Modified: trunk/libzypp/VERSION.cmake URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/VERSION.cmake (original) +++ trunk/libzypp/VERSION.cmake Fri Sep 14 23:13:47 2007 @@ -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") Modified: trunk/libzypp/devel/devel.ma/Parse.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Parse.cc?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/Parse.cc (original) +++ trunk/libzypp/devel/devel.ma/Parse.cc Fri Sep 14 23:13:47 2007 @@ -59,10 +59,17 @@ 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 @@ 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 @@ USR << "pool: " << pool << endl; SEC << pool.knownRepositoriesSize() << endl; - if ( 1 ) + if ( 0 ) { { zypp::base::LogControl::TmpLineWriter shutUp; @@ -563,9 +571,14 @@ 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; Modified: trunk/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/package/libzypp.changes (original) +++ trunk/libzypp/package/libzypp.changes Fri Sep 14 23:13:47 2007 @@ -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. Modified: trunk/libzypp/tests/cache/CacheStore_test.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/cache/CacheStore_test.cc?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/tests/cache/CacheStore_test.cc (original) +++ trunk/libzypp/tests/cache/CacheStore_test.cc Fri Sep 14 23:13:47 2007 @@ -467,7 +467,8 @@ // 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); } Modified: trunk/libzypp/zypp/cache/CacheStore.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/CacheStore.cc?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/zypp/cache/CacheStore.cc (original) +++ trunk/libzypp/zypp/cache/CacheStore.cc Fri Sep 14 23:13:47 2007 @@ -122,13 +122,13 @@ 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 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 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()); Modified: trunk/libzypp/zypp/cache/schema/schema.sql URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/schema/schema.sql?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/zypp/cache/schema/schema.sql (original) +++ trunk/libzypp/zypp/cache/schema/schema.sql Fri Sep 14 23:13:47 2007 @@ -166,6 +166,11 @@ 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 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 @@ 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; Modified: trunk/libzypp/zypp/data/ResolvableData.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/data/ResolvableData.cc?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/zypp/data/ResolvableData.cc (original) +++ trunk/libzypp/zypp/data/ResolvableData.cc Fri Sep 14 23:13:47 2007 @@ -49,5 +49,12 @@ // << " enhances:" << endl << enhances << endl } + +std::ostream & RpmBase::dumpOn( std::ostream & str ) const +{ + str << "Patch/Delta[ " << name << " " << edition << " " << arch << " ]"; + return str; +} + } // namespace cache } // namespace zypp Modified: trunk/libzypp/zypp/data/ResolvableData.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/data/ResolvableData.h?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/zypp/data/ResolvableData.h (original) +++ trunk/libzypp/zypp/data/ResolvableData.h Fri Sep 14 23:13:47 2007 @@ -368,18 +368,16 @@ { // 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); Modified: trunk/libzypp/zypp/parser/yum/PatchFileReader.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/PatchFileReader.cc?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/zypp/parser/yum/PatchFileReader.cc (original) +++ trunk/libzypp/zypp/parser/yum/PatchFileReader.cc Fri Sep 14 23:13:47 2007 @@ -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 @@ 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 @@ 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; } Modified: trunk/libzypp/zypp/repo/DeltaCandidates.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/DeltaCandidates.cc?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/zypp/repo/DeltaCandidates.cc (original) +++ trunk/libzypp/zypp/repo/DeltaCandidates.cc Fri Sep 14 23:13:47 2007 @@ -27,18 +27,18 @@ { 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 @@ 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 @@ 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 @@ 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; Modified: trunk/libzypp/zypp/repo/PackageDelta.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/PackageDelta.cc?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/zypp/repo/PackageDelta.cc (original) +++ trunk/libzypp/zypp/repo/PackageDelta.cc Fri Sep 14 23:13:47 2007 @@ -28,7 +28,8 @@ 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 @@ 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() Modified: trunk/libzypp/zypp/repo/PackageDelta.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/PackageDelta.h?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/zypp/repo/PackageDelta.h (original) +++ trunk/libzypp/zypp/repo/PackageDelta.h Fri Sep 14 23:13:47 2007 @@ -17,6 +17,7 @@ #include "zypp/OnMediaLocation.h" #include "zypp/Edition.h" +#include "zypp/Arch.h" #include "zypp/Date.h" /////////////////////////////////////////////////////////////////// @@ -28,6 +29,7 @@ /////////////////////////////////////////////////////////////////// + /** \todo cheap copy! (switch to RWCOW) */ class PatchRpm { public: @@ -39,17 +41,29 @@ {} 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 @@ /////////////////////////////////////////////////////////////////// + /** \todo cheap copy! (switch to RWCOW) */ class DeltaRpm { public: @@ -95,16 +110,28 @@ {} 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; Modified: trunk/libzypp/zypp/repo/cached/RepoImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/cached/RepoImpl.cc?rev=7253&r1=7252&r2=7253&view=diff ============================================================================== --- trunk/libzypp/zypp/repo/cached/RepoImpl.cc (original) +++ trunk/libzypp/zypp/repo/cached/RepoImpl.cc Fri Sep 14 23:13:47 2007 @@ -187,59 +187,62 @@ 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 @@ 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; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org