From 77d3ac22256f32a4737e48be36f6da1c382f33d5 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Thu, 24 May 2007 15:00:53 +0000 Subject: [PATCH] - fsck tool for cache - cached source is per-repository - catalog->repository --- devel/devel.dmacvicar/YUMReader_tp.cc | 14 +-- devel/devel.jkupec/YUMParser_test.cc | 8 +- devel/devel.ma/Parse.cc | 12 +-- libzypp.spec.cmake | 2 +- tests/cache/CacheQuery_test.cc | 4 +- tests/cache/CacheStore_test.cc | 7 +- tools/CMakeLists.txt | 3 +- tools/cachetools/CMakeLists.txt | 12 +++ tools/cachetools/zypp-cache.cc | 54 ++++++++++ tools/registration/zypp-query-pool.cc | 30 +++--- zypp/data/ResolvableDataConsumer.h | 22 ++--- zypp2/CMakeLists.txt | 2 + zypp2/cache/CacheFSCK.cc | 125 ++++++++++++++++++++++++ zypp2/cache/CacheFSCK.h | 71 ++++++++++++++ zypp2/cache/CacheInitializer.cpp | 2 +- zypp2/cache/CacheStore.cpp | 86 ++++++++-------- zypp2/cache/CacheStore.h | 56 +++++------ zypp2/cache/ResolvableQuery.cc | 2 +- zypp2/cache/schema/schema.h | 16 +-- zypp2/cache/schema/schema.sql | 32 +++--- zypp2/parser/susetags/RepoParser.cc | 12 +-- zypp2/parser/susetags/RepoParser.h | 4 +- zypp2/parser/yum/YUMParser.cc | 16 +-- zypp2/parser/yum/YUMParser.h | 12 +-- zypp2/repository/cached/CachedRepositoryImpl.cc | 10 +- zypp2/repository/cached/CachedRepositoryImpl.h | 3 +- 26 files changed, 443 insertions(+), 174 deletions(-) create mode 100644 tools/cachetools/CMakeLists.txt create mode 100644 tools/cachetools/zypp-cache.cc create mode 100644 zypp2/cache/CacheFSCK.cc create mode 100644 zypp2/cache/CacheFSCK.h diff --git a/devel/devel.dmacvicar/YUMReader_tp.cc b/devel/devel.dmacvicar/YUMReader_tp.cc index 788f40e..cb55f2c 100644 --- a/devel/devel.dmacvicar/YUMReader_tp.cc +++ b/devel/devel.dmacvicar/YUMReader_tp.cc @@ -57,7 +57,7 @@ class ResolvableConsumer : public data::ResolvableDataConsumer } - virtual void consumePackage( const data::RecordId &catalog_id, data::Package_Ptr ptr ) + virtual void consumePackage( const data::RecordId &repository_id, data::Package_Ptr ptr ) { PkgImplPtr impl = PkgImplPtr( new DPackageImpl(ptr) ); Dependencies deps; @@ -66,28 +66,28 @@ class ResolvableConsumer : public data::ResolvableDataConsumer Package::Ptr pkg = detail::makeResolvableFromImpl( NVRAD( ptr->name, ptr->edition, ptr->arch, deps), impl ); _store.insert(pkg); } - virtual void consumeProduct( const data::RecordId &catalog_id, data::Product_Ptr ) + virtual void consumeProduct( const data::RecordId &repository_id, data::Product_Ptr ) { } - virtual void consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr ) + virtual void consumePatch( const data::RecordId &repository_id, data::Patch_Ptr ) { } - virtual void consumeMessage( const data::RecordId &catalog_id, data::Message_Ptr ) + virtual void consumeMessage( const data::RecordId &repository_id, data::Message_Ptr ) { } - virtual void consumeScript( const data::RecordId &catalog_id, data::Script_Ptr ) + virtual void consumeScript( const data::RecordId &repository_id, data::Script_Ptr ) { } - virtual void consumeChangelog( const data::RecordId & catalog_id, const data::Resolvable_Ptr &, const Changelog & ) + virtual void consumeChangelog( const data::RecordId & repository_id, const data::Resolvable_Ptr &, const Changelog & ) { } - virtual void consumeFilelist( const data::RecordId & catalog_id, const data::Resolvable_Ptr &, const data::Filenames & ) + virtual void consumeFilelist( const data::RecordId & repository_id, const data::Resolvable_Ptr &, const data::Filenames & ) {} //virtual void consumeSourcePackage( const data::SrcPackage_Ptr ) = 0; diff --git a/devel/devel.jkupec/YUMParser_test.cc b/devel/devel.jkupec/YUMParser_test.cc index db46c9c..721073d 100644 --- a/devel/devel.jkupec/YUMParser_test.cc +++ b/devel/devel.jkupec/YUMParser_test.cc @@ -36,17 +36,17 @@ int main(int argc, char **argv) { ZYpp::Ptr z = getZYpp(); - Measure open_catalog_timer("CacheStore: lookupOrAppendCatalog"); + Measure open_repository_timer("CacheStore: lookupOrAppendCatalog"); cache::CacheStore store(getenv("PWD")); - data::RecordId catalog_id = store.lookupOrAppendCatalog( Url("http://some.url"), "/"); + data::RecordId repository_id = store.lookupOrAppendCatalog( Url("http://some.url"), "/"); - open_catalog_timer.stop(); + open_repository_timer.stop(); MIL << "creating PrimaryFileParser" << endl; Measure parse_primary_timer("primary.xml.gz parsing"); - parser::yum::YUMParser parser( catalog_id, store, &progress_function); + parser::yum::YUMParser parser( repository_id, store, &progress_function); parser.start(argv[1]); store.commit(); parse_primary_timer.stop(); diff --git a/devel/devel.ma/Parse.cc b/devel/devel.ma/Parse.cc index 513b024..b7da041 100644 --- a/devel/devel.ma/Parse.cc +++ b/devel/devel.ma/Parse.cc @@ -202,11 +202,11 @@ int main( int argc, char * argv[] ) Pathname reporoot( "lmd" ); cache::CacheStore store( dbdir ); - data::RecordId catalogId = store.lookupOrAppendCatalog( Url("dir:///"), "/" ); + data::RecordId repositoryId = store.lookupOrAppendCatalog( Url("dir:///"), "/" ); { Measure x( "XXXXXXXXXXXXX" ); - parser::susetags::RepoParser repo( catalogId, store ); + parser::susetags::RepoParser repo( repositoryId, store ); repo.parse( reporoot ); store.commit(); @@ -230,9 +230,9 @@ int main( int argc, char * argv[] ) Pathname metadir( "lmd" ); cache::CacheStore store( dbdir ); - data::RecordId catalogId = store.lookupOrAppendCatalog( Url("http://www.google.com"), "/" ); + data::RecordId repositoryId = store.lookupOrAppendCatalog( Url("http://www.google.com"), "/" ); - RepoParser( metadir, catalogId, store ); + RepoParser( metadir, repositoryId, store ); } @@ -243,9 +243,9 @@ int main( int argc, char * argv[] ) Pathname dbfile( "data.db" ); cache::CacheStore store(getenv("PWD")); - data::RecordId catalog_id = store.lookupOrAppendCatalog( Url("http://www.google.com"), "/"); + data::RecordId repository_id = store.lookupOrAppendCatalog( Url("http://www.google.com"), "/"); - PackagesParser parser( catalog_id, store); + PackagesParser parser( repository_id, store); Measure m; parser.start(argv[1], &progress_function); m.elapsed(); diff --git a/libzypp.spec.cmake b/libzypp.spec.cmake index a5d7959..903b522 100644 --- a/libzypp.spec.cmake +++ b/libzypp.spec.cmake @@ -355,7 +355,7 @@ cd .. - release last used source at end of commit (#155002) - rev 2277 * Fri Mar 03 2006 - kkaempf@suse.de -- cope with NULL values in zmd catalogs table (#153584) +- cope with NULL values in zmd repositorys table (#153584) - set YAST_IS_RUNNING in transact zmd helper (#154820) - run SuSEconfig after transact zmd helper (#154820) - add softTransact to honor user vs. soft requirements (#154650) diff --git a/tests/cache/CacheQuery_test.cc b/tests/cache/CacheQuery_test.cc index 38a4b7e..e681686 100644 --- a/tests/cache/CacheQuery_test.cc +++ b/tests/cache/CacheQuery_test.cc @@ -49,12 +49,12 @@ void resolvable_query_test(const string &dir) { cache::CacheStore store(tmpdir.path()); - data::RecordId catalog_id = store.lookupOrAppendCatalog( Url("http://novell.com"), "/"); + data::RecordId repository_id = store.lookupOrAppendCatalog( Url("http://novell.com"), "/"); zypp::debug::Measure cap_parse_timer("store resolvables"); for ( list::iterator it = res_list.begin(); it != res_list.end(); it++) { - data::RecordId id = store.appendResolvable( catalog_id, + data::RecordId id = store.appendResolvable( repository_id, ResTraits::kind, (*it).nvra, (*it).deps ); diff --git a/tests/cache/CacheStore_test.cc b/tests/cache/CacheStore_test.cc index a7035c3..95ce2cd 100644 --- a/tests/cache/CacheStore_test.cc +++ b/tests/cache/CacheStore_test.cc @@ -30,6 +30,7 @@ using namespace boost::unit_test; void cache_write_test(const string &dir) { + data::RecordId repository_id; filesystem::TmpDir tmpdir; { Pathname nvra_list = Pathname(dir) + "package-set.txt.gz"; @@ -39,12 +40,12 @@ void cache_write_test(const string &dir) cache::CacheStore store(tmpdir.path()); - data::RecordId catalog_id = store.lookupOrAppendCatalog( Url("http://novell.com"), "/"); + repository_id = store.lookupOrAppendCatalog( Url("http://novell.com"), "/"); zypp::debug::Measure cap_parse_timer("store resolvables"); for ( list::iterator it = res_list.begin(); it != res_list.end(); it++) { - data::RecordId id = store.appendResolvable( catalog_id, + data::RecordId id = store.appendResolvable( repository_id, ResTraits::kind, (*it).nvra, (*it).deps ); @@ -53,7 +54,7 @@ void cache_write_test(const string &dir) { MIL << "now read resolvables" << endl; - CachedRepositoryImpl *repositoryImpl = new CachedRepositoryImpl(tmpdir.path()); + CachedRepositoryImpl *repositoryImpl = new CachedRepositoryImpl(tmpdir.path(), repository_id); //RepositoryFactory factory; //Repository_Ref repository = factory.createFrom(repositoryImpl); repositoryImpl->createResolvables(); diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 29b6b91..9b43154 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,2 +1,3 @@ ADD_SUBDIRECTORY( registration ) -ADD_SUBDIRECTORY( package-manager ) +ADD_SUBDIRECTORY( package-manager ) +ADD_SUBDIRECTORY( cachetools ) \ No newline at end of file diff --git a/tools/cachetools/CMakeLists.txt b/tools/cachetools/CMakeLists.txt new file mode 100644 index 0000000..b7a557e --- /dev/null +++ b/tools/cachetools/CMakeLists.txt @@ -0,0 +1,12 @@ +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) + +SET( zyppcache_SRC +zypp-cache.cc +) + +ADD_EXECUTABLE( zypp-cache ${zyppcache_SRC} ) +TARGET_LINK_LIBRARIES( zypp-cache zypp ) +TARGET_LINK_LIBRARIES( zypp-cache zypp2 ) +TARGET_LINK_LIBRARIES( zypp-cache xml2 ) + +#INSTALL(TARGETS zypp-query-pool RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/zypp ) \ No newline at end of file diff --git a/tools/cachetools/zypp-cache.cc b/tools/cachetools/zypp-cache.cc new file mode 100644 index 0000000..6ffd9fa --- /dev/null +++ b/tools/cachetools/zypp-cache.cc @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +#include + +#include "zypp/base/Logger.h" +#include "zypp/ZYpp.h" +#include "zypp/zypp_detail/ZYppReadOnlyHack.h" +#include "zypp/ZYppFactory.h" +#include "zypp2/cache/CacheFSCK.h" + +#undef ZYPP_BASE_LOGGER_LOGGROUP +#define ZYPP_BASE_LOGGER_LOGGROUP "zypp-cache" + + +using namespace std; +using namespace zypp; + +static void cache_fsck( const Pathname &dir ) +{ + cache::CacheFSCK fsck(dir); + fsck.start(); +} + +void usage() +{ + cout << "Commands:" << endl; + cout << "fsck dbdir" << endl; +} + +//----------------------------------------------------------------------------- + +int +main (int argc, char **argv) +{ + MIL << "-------------------------------------" << endl; + + if (argc > 2) + { + if ( string(argv[1]) == "fsck" ) + { + cache_fsck(argv[2]); + } + else + { + usage(); + } + } + else + { + usage(); + } + + return 0; +} diff --git a/tools/registration/zypp-query-pool.cc b/tools/registration/zypp-query-pool.cc index 1f3232f..766b1a6 100644 --- a/tools/registration/zypp-query-pool.cc +++ b/tools/registration/zypp-query-pool.cc @@ -24,16 +24,16 @@ using namespace zypp; class PrintItem : public resfilter::PoolItemFilterFunctor { public: - string _catalog; + string _repository; - PrintItem( const string & catalog ) - : _catalog( catalog ) + PrintItem( const string & repository ) + : _repository( repository ) { } bool operator()( PoolItem_Ref item ) { - if (_catalog.empty() - || _catalog == item->source().alias()) + if (_repository.empty() + || _repository == item->source().alias()) { cout << (item.status().isInstalled() ? "i" : " "); cout << "|" << item->kind(); @@ -59,7 +59,7 @@ public: static void -query_pool( ZYpp::Ptr Z, const string & filter, const string & catalog) +query_pool( ZYpp::Ptr Z, const string & filter, const string & repository) { Resolvable::Kind kind; @@ -76,9 +76,9 @@ query_pool( ZYpp::Ptr Z, const string & filter, const string & catalog) exit( 1 ); } - bool system = (catalog == "@system"); + bool system = (repository == "@system"); - MIL << "query_pool kind '" << kind << "', catalog '" << catalog << "'" << endl; + MIL << "query_pool kind '" << kind << "', repository '" << repository << "'" << endl; SourceManager_Ptr manager = SourceManager::sourceManager(); @@ -113,7 +113,7 @@ query_pool( ZYpp::Ptr Z, const string & filter, const string & catalog) } // add all non-installed (cached sources) resolvables to the pool - // remark: If only the systems resolvables should be shown (catalog == "@system") + // remark: If only the systems resolvables should be shown (repository == "@system") // then the SourceManager is not initialized (see approx. 20 lines above) // and the following loop is not run at all. @@ -129,7 +129,7 @@ query_pool( ZYpp::Ptr Z, const string & filter, const string & catalog) if (filter.empty() || filter == FILTER_ALL) { - PrintItem printitem( system ? "" : catalog ); + PrintItem printitem( system ? "" : repository ); if (system) zypp::invokeOnEach( Z->pool().begin(), Z->pool().end(), // all kinds zypp::resfilter::ByInstalled(), @@ -141,7 +141,7 @@ query_pool( ZYpp::Ptr Z, const string & filter, const string & catalog) } else { - PrintItem printitem( system ? "" : catalog ); + PrintItem printitem( system ? "" : repository ); if (system) zypp::invokeOnEach( Z->pool().byKindBegin( kind ), Z->pool().byKindEnd( kind ), // filter kind zypp::resfilter::ByInstalled(), @@ -162,11 +162,11 @@ main (int argc, char **argv) string filter; if (argc > 1) filter = argv[1]; - string catalog; + string repository; if (argc > 2) - catalog = argv[2]; + repository = argv[2]; - MIL << "START zypp-query-pool " << filter << " " << catalog << endl; + MIL << "START zypp-query-pool " << filter << " " << repository << endl; zypp::zypp_readonly_hack::IWantIt(); ZYpp::Ptr Z = zypp::getZYpp(); @@ -176,7 +176,7 @@ main (int argc, char **argv) Z->initializeTarget( "/" ); - query_pool( Z, filter, catalog ); + query_pool( Z, filter, repository ); MIL << "END zypp-query-pool, result 0" << endl; diff --git a/zypp/data/ResolvableDataConsumer.h b/zypp/data/ResolvableDataConsumer.h index 140be9a..b0bc2a4 100644 --- a/zypp/data/ResolvableDataConsumer.h +++ b/zypp/data/ResolvableDataConsumer.h @@ -28,17 +28,17 @@ namespace data ResolvableDataConsumer(); virtual ~ResolvableDataConsumer(); - virtual void consumePackage( const data::RecordId &catalog_id, data::Package_Ptr ) = 0; - virtual void consumeSourcePackage( const data::RecordId &catalog_id, data::SrcPackage_Ptr ) = 0; - virtual void consumeProduct( const data::RecordId &catalog_id, data::Product_Ptr ) = 0; - virtual void consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr ) = 0; - virtual void consumePackageAtom( const data::RecordId &catalog_id, const data::PackageAtom_Ptr & ) = 0; - virtual void consumeMessage( const data::RecordId &catalog_id, data::Message_Ptr ) = 0; - virtual void consumeScript( const data::RecordId &catalog_id, data::Script_Ptr ) = 0; - virtual void consumePattern( const data::RecordId &catalog_id, data::Pattern_Ptr ) = 0; - - virtual void consumeChangelog( const data::RecordId & catalog_id, const data::Resolvable_Ptr &, const Changelog & ) = 0; - virtual void consumeFilelist( const data::RecordId & catalog_id, const data::Resolvable_Ptr &, const data::Filenames & ) = 0; + virtual void consumePackage( const data::RecordId &repository_id, data::Package_Ptr ) = 0; + virtual void consumeSourcePackage( const data::RecordId &repository_id, data::SrcPackage_Ptr ) = 0; + virtual void consumeProduct( const data::RecordId &repository_id, data::Product_Ptr ) = 0; + virtual void consumePatch( const data::RecordId &repository_id, data::Patch_Ptr ) = 0; + virtual void consumePackageAtom( const data::RecordId &repository_id, const data::PackageAtom_Ptr & ) = 0; + virtual void consumeMessage( const data::RecordId &repository_id, data::Message_Ptr ) = 0; + virtual void consumeScript( const data::RecordId &repository_id, data::Script_Ptr ) = 0; + virtual void consumePattern( const data::RecordId &repository_id, data::Pattern_Ptr ) = 0; + + virtual void consumeChangelog( const data::RecordId & repository_id, const data::Resolvable_Ptr &, const Changelog & ) = 0; + virtual void consumeFilelist( const data::RecordId & repository_id, const data::Resolvable_Ptr &, const data::Filenames & ) = 0; }; } // namespace parser diff --git a/zypp2/CMakeLists.txt b/zypp2/CMakeLists.txt index 45956bc..49b672c 100644 --- a/zypp2/CMakeLists.txt +++ b/zypp2/CMakeLists.txt @@ -45,6 +45,7 @@ SET( zypp2_cache_SRCS # cache/sqlite_detail/CapabilityQueryImpl.cc # cache/sqlite_detail/QueryFactoryImpl.cc cache/CacheStore.cpp + cache/CacheFSCK.cc cache/Utils.cpp ) @@ -53,6 +54,7 @@ SET( zypp2_cache_HEADERS cache/CacheTypes.h cache/CacheInitializer.h cache/CacheStore.h + cache/CacheFSCK.h cache/ResolvableQuery.h # cache/CapablityQuery.h # cache/QueryFactory.h diff --git a/zypp2/cache/CacheFSCK.cc b/zypp2/cache/CacheFSCK.cc new file mode 100644 index 0000000..2383526 --- /dev/null +++ b/zypp2/cache/CacheFSCK.cc @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp2/cache/CacheFSCK.cc + * +*/ +#include +#include "zypp/base/Logger.h" +#include "zypp/base/Exception.h" +#include "zypp2/cache/CacheFSCK.h" +#include "zypp2/cache/sqlite3x/sqlite3x.hpp" + +using namespace zypp; +using namespace zypp::cache; +using namespace std; +using namespace sqlite3x; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace cache + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : CacheFSCK::Impl + // + /** CacheFSCK implementation. */ + struct CacheFSCK::Impl + { + + public: + + Impl( const Pathname &dbdir ) + : _dbdir(dbdir) + { + + } + + void start() + { + try + { + sqlite3_connection con((_dbdir + "zypp.db").asString().c_str()); + //con.executenonquery("BEGIN;"); + + sqlite3_command cmd( con, "PRAGMA integrity_check;"); + sqlite3_reader reader = cmd.executereader(); + while(reader.read()) + { + cout << reader.getstring(0) << endl; + } + } + catch( const std::exception &e ) + { + ZYPP_RETHROW(Exception(e.what())); + } + } + + private: + friend Impl * rwcowClone( const Impl * rhs ); + /** clone for RWCOW_pointer */ + Impl * clone() const + { return new Impl( *this ); } + + Pathname _dbdir; + }; + /////////////////////////////////////////////////////////////////// + + /** \relates CacheFSCK::Impl Stream output */ + inline std::ostream & operator<<( std::ostream & str, const CacheFSCK::Impl & obj ) + { + return str << "CacheFSCK::Impl"; + } + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : CacheFSCK + // + /////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : CacheFSCK::CacheFSCK + // METHOD TYPE : Ctor + // + CacheFSCK::CacheFSCK( const Pathname &dbdir ) + : _pimpl( new Impl(dbdir) ) + {} + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : CacheFSCK::~CacheFSCK + // METHOD TYPE : Dtor + // + CacheFSCK::~CacheFSCK() + {} + + void CacheFSCK::start() + { + _pimpl->start(); + } + + /****************************************************************** + ** + ** FUNCTION NAME : operator<< + ** FUNCTION TYPE : std::ostream & + */ + std::ostream & operator<<( std::ostream & str, const CacheFSCK & obj ) + { + return str << *obj._pimpl; + } + + ///////////////////////////////////////////////////////////////// + } // namespace cache + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp2 +/////////////////////////////////////////////////////////////////// diff --git a/zypp2/cache/CacheFSCK.h b/zypp2/cache/CacheFSCK.h new file mode 100644 index 0000000..ade9be1 --- /dev/null +++ b/zypp2/cache/CacheFSCK.h @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp2/cache/CacheFSCK.h + * +*/ +#ifndef ZYPP2_CACHE_CACHEFSCK_H +#define ZYPP2_CACHE_CACHEFSCK_H + +#include + +#include "zypp/base/PtrTypes.h" +#include "zypp/Pathname.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace cache + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : CacheFSCK + // + /** + * Check for consistency of the cache + **/ + class CacheFSCK + { + friend std::ostream & operator<<( std::ostream & str, const CacheFSCK & obj ); + + public: + /** Implementation */ + class Impl; + + public: + /** + * Default ctor + * + * \param dbdir Cache directory + */ + CacheFSCK( const Pathname &dbdir ); + + void start(); + /** Dtor */ + ~CacheFSCK(); + + public: + + private: + /** Pointer to implementation */ + RWCOW_pointer _pimpl; + }; + /////////////////////////////////////////////////////////////////// + + /** \relates CacheFSCK Stream output */ + std::ostream & operator<<( std::ostream & str, const CacheFSCK & obj ); + + ///////////////////////////////////////////////////////////////// + } // namespace cache + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp2 +/////////////////////////////////////////////////////////////////// +#endif // ZYPP2_CACHE_CACHEFSCK_H diff --git a/zypp2/cache/CacheInitializer.cpp b/zypp2/cache/CacheInitializer.cpp index ef6a773..9f7d308 100644 --- a/zypp2/cache/CacheInitializer.cpp +++ b/zypp2/cache/CacheInitializer.cpp @@ -88,7 +88,7 @@ bool CacheInitializer::tablesCreated() const Measure timer("Check tables exist"); unsigned int count = _pimpl->con->executeint("select count(*) from sqlite_master where type='table';"); timer.elapsed(); - return ( count == 26 ); + return ( count > 0 ); } void CacheInitializer::createTables() diff --git a/zypp2/cache/CacheStore.cpp b/zypp2/cache/CacheStore.cpp index 604840f..1f414f0 100644 --- a/zypp2/cache/CacheStore.cpp +++ b/zypp2/cache/CacheStore.cpp @@ -55,12 +55,12 @@ struct CacheStore::Impl // initialize all pre-compiled statements - insert_resolvable_in_catalog_cmd.reset( new sqlite3_command( con, "insert into resolvables_catalogs (resolvable_id, catalog_id) values (:resolvable_id, :catalog_id);" )); + insert_resolvable_in_repository_cmd.reset( new sqlite3_command( con, "insert into resolvables_repositories (resolvable_id, repository_id) values (:resolvable_id, :repository_id);" )); - update_catalog_cmd.reset( new sqlite3_command( con, "update catalogs set checksum=:checksum, timestamp=:timestamp where id=:catalog_id;" )); + update_repository_cmd.reset( new sqlite3_command( con, "update repositories set checksum=:checksum, timestamp=:timestamp where id=:repository_id;" )); - select_catalog_cmd.reset( new sqlite3_command( con, "select id from catalogs where url=:url and path=:path;" )); - insert_catalog_cmd.reset( new sqlite3_command( con, "insert into catalogs (url,path,timestamp) values (:url,:path,:timestamp);" )); + select_repository_cmd.reset( new sqlite3_command( con, "select id from repositories where url=:url and path=:path;" )); + insert_repository_cmd.reset( new sqlite3_command( con, "insert into repositories (url,path,timestamp) values (:url,:path,:timestamp);" )); select_name_cmd.reset( new sqlite3_command( con, "select id from names where name=:name;" )); insert_name_cmd.reset( new sqlite3_command( con, "insert into names (name) values (:name);" )); @@ -92,7 +92,7 @@ struct CacheStore::Impl append_other_dependency_cmd.reset( new sqlite3_command( con, "insert into other_capabilities ( resolvable_id, dependency_type, refers_kind, value ) values ( :resolvable_id, :dependency_type, :refers_kind, :value );" )); - append_resolvable_cmd.reset( new sqlite3_command( con, "insert into resolvables ( name, version, release, epoch, arch, kind, catalog_id ) values ( :name, :version, :release, :epoch, :arch, :kind, :catalog_id );" )); + append_resolvable_cmd.reset( new sqlite3_command( con, "insert into resolvables ( name, version, release, epoch, arch, kind, repository_id ) values ( :name, :version, :release, :epoch, :arch, :kind, :repository_id );" )); count_shared_cmd.reset( new sqlite3_command( con, "select count(id) from resolvables where shared_id=:rid;" )); @@ -118,8 +118,8 @@ struct CacheStore::Impl */ sqlite3_connection con; - sqlite3_command_ptr update_catalog_cmd; - sqlite3_command_ptr insert_resolvable_in_catalog_cmd; + sqlite3_command_ptr update_repository_cmd; + sqlite3_command_ptr insert_resolvable_in_repository_cmd; sqlite3_command_ptr select_name_cmd; sqlite3_command_ptr insert_name_cmd; @@ -130,8 +130,8 @@ struct CacheStore::Impl sqlite3_command_ptr select_filename_cmd; sqlite3_command_ptr insert_filename_cmd; - sqlite3_command_ptr select_catalog_cmd; - sqlite3_command_ptr insert_catalog_cmd; + sqlite3_command_ptr select_repository_cmd; + sqlite3_command_ptr insert_repository_cmd; sqlite3_command_ptr select_file_cmd; sqlite3_command_ptr insert_file_cmd; @@ -184,9 +184,9 @@ void CacheStore::commit() _pimpl->con.executenonquery("COMMIT;"); } -void CacheStore::consumePackage( const RecordId &catalog_id, data::Package_Ptr package ) +void CacheStore::consumePackage( const RecordId &repository_id, data::Package_Ptr package ) { - RecordId pkgid = appendResolvable( catalog_id, ResTraits::kind, NVRA( package->name, package->edition, package->arch ), package->deps ); + RecordId pkgid = appendResolvable( repository_id, ResTraits::kind, NVRA( package->name, package->edition, package->arch ), package->deps ); consumeResObject( pkgid, package ); appendStringAttribute( pkgid, "Package", "checksum", package->repositoryLocation.fileChecksum.checksum() ); @@ -213,7 +213,7 @@ void CacheStore::consumeSourcePackage( const data::RecordId &catalog_id, data::S void CacheStore::consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr patch) { - RecordId id = appendResolvable( catalog_id, ResTraits::kind, NVRA( patch->name, patch->edition, patch->arch ), patch->deps ); + RecordId id = appendResolvable( repository_id, ResTraits::kind, NVRA( patch->name, patch->edition, patch->arch ), patch->deps ); consumeResObject( id, patch ); DBG << "got patch " << patch->name << ", atoms: "; @@ -225,7 +225,7 @@ void CacheStore::consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr if (atom) { DBG << atom->name << "(atom) "; - consumePackageAtom(catalog_id, atom); + consumePackageAtom(repository_id, atom); continue; } @@ -233,7 +233,7 @@ void CacheStore::consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr if (script) { DBG << script->name << "(script) "; - consumeScript(catalog_id, script); + consumeScript(repository_id, script); continue; } @@ -241,7 +241,7 @@ void CacheStore::consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr if (message) { DBG << message->name << "(message) "; - consumeMessage(catalog_id, message); + consumeMessage(repository_id, message); continue; } @@ -253,37 +253,37 @@ void CacheStore::consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr DBG << endl; } -void CacheStore::consumePackageAtom( const data::RecordId &catalog_id, const data::PackageAtom_Ptr & atom ) +void CacheStore::consumePackageAtom( const data::RecordId &repository_id, const data::PackageAtom_Ptr & atom ) { - RecordId id = appendResolvable( catalog_id, ResTraits::kind, NVRA( atom->name, atom->edition, atom->arch ), atom->deps ); + RecordId id = appendResolvable( repository_id, ResTraits::kind, NVRA( atom->name, atom->edition, atom->arch ), atom->deps ); consumeResObject( id, atom ); } -void CacheStore::consumeMessage( const data::RecordId &catalog_id, data::Message_Ptr message ) +void CacheStore::consumeMessage( const data::RecordId &repository_id, data::Message_Ptr message ) { - RecordId id = appendResolvable( catalog_id, ResTraits::kind, NVRA( message->name, message->edition, message->arch ), message->deps ); + RecordId id = appendResolvable( repository_id, ResTraits::kind, NVRA( message->name, message->edition, message->arch ), message->deps ); consumeResObject( id, message ); } -void CacheStore::consumeScript( const data::RecordId &catalog_id, data::Script_Ptr script ) +void CacheStore::consumeScript( const data::RecordId &repository_id, data::Script_Ptr script ) { - RecordId id = appendResolvable( catalog_id, ResTraits