}
- 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;
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;
{
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();
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();
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 );
}
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();
- 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)
{
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<MiniResolvable>::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<Package>::kind,
(*it).nvra,
(*it).deps );
void cache_write_test(const string &dir)
{
+ data::RecordId repository_id;
filesystem::TmpDir tmpdir;
{
Pathname nvra_list = Pathname(dir) + "package-set.txt.gz";
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<MiniResolvable>::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<Package>::kind,
(*it).nvra,
(*it).deps );
{
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();
ADD_SUBDIRECTORY( registration )
-ADD_SUBDIRECTORY( package-manager )
+ADD_SUBDIRECTORY( package-manager )
+ADD_SUBDIRECTORY( cachetools )
\ No newline at end of file
--- /dev/null
+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
--- /dev/null
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
+#include <iostream>
+
+#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;
+}
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();
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;
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();
}
// 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.
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(),
}
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(),
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();
Z->initializeTarget( "/" );
- query_pool( Z, filter, catalog );
+ query_pool( Z, filter, repository );
MIL << "END zypp-query-pool, result 0" << endl;
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
# cache/sqlite_detail/CapabilityQueryImpl.cc
# cache/sqlite_detail/QueryFactoryImpl.cc
cache/CacheStore.cpp
+ cache/CacheFSCK.cc
cache/Utils.cpp
)
cache/CacheTypes.h
cache/CacheInitializer.h
cache/CacheStore.h
+ cache/CacheFSCK.h
cache/ResolvableQuery.h
# cache/CapablityQuery.h
# cache/QueryFactory.h
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp2/cache/CacheFSCK.cc
+ *
+*/
+#include <iostream>
+#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<Impl>( 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
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp2/cache/CacheFSCK.h
+ *
+*/
+#ifndef ZYPP2_CACHE_CACHEFSCK_H
+#define ZYPP2_CACHE_CACHEFSCK_H
+
+#include <iosfwd>
+
+#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<Impl> _pimpl;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates CacheFSCK Stream output */
+ std::ostream & operator<<( std::ostream & str, const CacheFSCK & obj );
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace cache
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp2
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP2_CACHE_CACHEFSCK_H
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()
// 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);" ));
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;" ));
*/
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;
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;
_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<Package>::kind, NVRA( package->name, package->edition, package->arch ), package->deps );
+ RecordId pkgid = appendResolvable( repository_id, ResTraits<Package>::kind, NVRA( package->name, package->edition, package->arch ), package->deps );
consumeResObject( pkgid, package );
appendStringAttribute( pkgid, "Package", "checksum", package->repositoryLocation.fileChecksum.checksum() );
void CacheStore::consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr patch)
{
- RecordId id = appendResolvable( catalog_id, ResTraits<Patch>::kind, NVRA( patch->name, patch->edition, patch->arch ), patch->deps );
+ RecordId id = appendResolvable( repository_id, ResTraits<Patch>::kind, NVRA( patch->name, patch->edition, patch->arch ), patch->deps );
consumeResObject( id, patch );
DBG << "got patch " << patch->name << ", atoms: ";
if (atom)
{
DBG << atom->name << "(atom) ";
- consumePackageAtom(catalog_id, atom);
+ consumePackageAtom(repository_id, atom);
continue;
}
if (script)
{
DBG << script->name << "(script) ";
- consumeScript(catalog_id, script);
+ consumeScript(repository_id, script);
continue;
}
if (message)
{
DBG << message->name << "(message) ";
- consumeMessage(catalog_id, message);
+ consumeMessage(repository_id, message);
continue;
}
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<Atom>::kind, NVRA( atom->name, atom->edition, atom->arch ), atom->deps );
+ RecordId id = appendResolvable( repository_id, ResTraits<Atom>::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<Message>::kind, NVRA( message->name, message->edition, message->arch ), message->deps );
+ RecordId id = appendResolvable( repository_id, ResTraits<Message>::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<Script>::kind, NVRA( script->name, script->edition, script->arch ), script->deps );
+ RecordId id = appendResolvable( repository_id, ResTraits<Script>::kind, NVRA( script->name, script->edition, script->arch ), script->deps );
consumeResObject( id, script );
}
-void CacheStore::consumePattern( const data::RecordId &catalog_id, data::Pattern_Ptr pattern )
+void CacheStore::consumePattern( const data::RecordId &repository_id, data::Pattern_Ptr pattern )
{
- RecordId id = appendResolvable( catalog_id, ResTraits<Pattern>::kind, NVRA( pattern->name, pattern->edition, pattern->arch ), pattern->deps );
+ RecordId id = appendResolvable( repository_id, ResTraits<Pattern>::kind, NVRA( pattern->name, pattern->edition, pattern->arch ), pattern->deps );
consumeResObject( id, pattern );
}
-void CacheStore::consumeProduct( const data::RecordId &catalog_id, data::Product_Ptr product )
+void CacheStore::consumeProduct( const data::RecordId &repository_id, data::Product_Ptr product )
{
- RecordId id = appendResolvable( catalog_id, ResTraits<Product>::kind, NVRA( product->name, product->edition, product->arch ), product->deps );
+ RecordId id = appendResolvable( repository_id, ResTraits<Product>::kind, NVRA( product->name, product->edition, product->arch ), product->deps );
consumeResObject( id, product );
}
-void CacheStore::consumeChangelog( const data::RecordId &catalog_id, const data::Resolvable_Ptr & resolvable, const Changelog & changelog )
+void CacheStore::consumeChangelog( const data::RecordId &repository_id, const data::Resolvable_Ptr & resolvable, const Changelog & changelog )
{
// TODO
// maybe consumeChangelog(const data::RecordId & resolvable_id, Changelog changelog) will
// resolvable. (first, we'll see how fast is the inserting without remembering those ids)
}
-void CacheStore::consumeFilelist( const data::RecordId &catalog_id, const data::Resolvable_Ptr & resolvable, const data::Filenames & filenames )
+void CacheStore::consumeFilelist( const data::RecordId &repository_id, const data::Resolvable_Ptr & resolvable, const data::Filenames & filenames )
{
// TODO
// maybe consumeFilelist(const data::RecordId & resolvable_id, data::Filenames &) will
appendNumericAttribute( rid, "ResObject", "buildTime", res->buildTime );
}
-RecordId CacheStore::appendResolvable( const RecordId &catalog_id,
+RecordId CacheStore::appendResolvable( const RecordId &repository_id,
const Resolvable::Kind &kind,
const NVRA &nvra,
const data::Dependencies &deps )
_pimpl->append_resolvable_cmd->bind( ":epoch", static_cast<int>( nvra.edition.epoch() ) );
_pimpl->append_resolvable_cmd->bind( ":arch", lookupOrAppendType("arch", nvra.arch.asString()) );
_pimpl->append_resolvable_cmd->bind( ":kind", lookupOrAppendType("kind", kind.asString()) );
- _pimpl->append_resolvable_cmd->bind( ":catalog_id", catalog_id );
+ _pimpl->append_resolvable_cmd->bind( ":repository_id", repository_id );
_pimpl->append_resolvable_cmd->executenonquery();
appendDependencies( id, deps );
/*
- _pimpl->insert_resolvable_in_catalog_cmd->bind(":catalog_id", catalog_id);
- _pimpl->insert_resolvable_in_catalog_cmd->bind(":resolvable_id", id);
- _pimpl->insert_resolvable_in_catalog_cmd->executenonquery();*/
+ _pimpl->insert_resolvable_in_repository_cmd->bind(":repository_id", repository_id);
+ _pimpl->insert_resolvable_in_repository_cmd->bind(":resolvable_id", id);
+ _pimpl->insert_resolvable_in_repository_cmd->executenonquery();*/
return static_cast<RecordId>(id);
return 1;
const string &checksum,
const Date ×tamp )
{
- _pimpl->update_catalog_cmd->bind(":catalog_id", id);
- _pimpl->update_catalog_cmd->bind(":checksum", checksum);
- _pimpl->update_catalog_cmd->bind(":timestamp", static_cast<int>((Date::ValueType) timestamp) );
- _pimpl->insert_catalog_cmd->executenonquery();
+ _pimpl->update_repository_cmd->bind(":repository_id", id);
+ _pimpl->update_repository_cmd->bind(":checksum", checksum);
+ _pimpl->update_repository_cmd->bind(":timestamp", static_cast<int>((Date::ValueType) timestamp) );
+ _pimpl->insert_repository_cmd->executenonquery();
}
RecordId CacheStore::lookupOrAppendCatalog( const Url &url, const Pathname &path )
{
- _pimpl->select_catalog_cmd->bind(":url", url.asString());
- _pimpl->select_catalog_cmd->bind(":path", path.asString());
+ _pimpl->select_repository_cmd->bind(":url", url.asString());
+ _pimpl->select_repository_cmd->bind(":path", path.asString());
long long id = 0;
try {
- id = _pimpl->select_catalog_cmd->executeint64();
+ id = _pimpl->select_repository_cmd->executeint64();
}
catch ( const sqlite3x::database_error &e )
{
// does not exist
- _pimpl->insert_catalog_cmd->bind(":url", url.asString());
- _pimpl->insert_catalog_cmd->bind(":path", path.asString());
- _pimpl->insert_catalog_cmd->bind(":timestamp", static_cast<int>((Date::ValueType) Date::now()) );
- _pimpl->insert_catalog_cmd->executenonquery();
+ _pimpl->insert_repository_cmd->bind(":url", url.asString());
+ _pimpl->insert_repository_cmd->bind(":path", path.asString());
+ _pimpl->insert_repository_cmd->bind(":timestamp", static_cast<int>((Date::ValueType) Date::now()) );
+ _pimpl->insert_repository_cmd->executenonquery();
id = _pimpl->con.insertid();
return static_cast<RecordId>(id);
*
* \code
* CacheStore store("/path");
- * RecordId catalog_id =
+ * RecordId repository_id =
* store.lookupOrAppendCatalog("http://updates.novell.com", "/");
- * store.consumePackage( catalog_id, package_ptr );
+ * store.consumePackage( repository_id, package_ptr );
* store.commit();
* \endcode
*
* Implementation of the \ref ResolvableConsumer interface
*
* Consume a package, inserting it in the cache, under
- * \param catalog_id ownership.
+ * \param repository_id ownership.
* \param package Package data
*/
- virtual void consumePackage( const data::RecordId &catalog_id, data::Package_Ptr package);
+ virtual void consumePackage( const data::RecordId &repository_id, data::Package_Ptr package);
/**
* Implementation of the \ref ResolvableConsumer interface
* Implementation of the \ref ResolvableConsumer interface
*
* Consume a patch, inserting it in the cache, under
- * \param catalog_id ownership.
+ * \param repository_id ownership.
* \param patch Patch data
*/
- virtual void consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr patch);
+ virtual void consumePatch( const data::RecordId &repository_id, data::Patch_Ptr patch);
/**
* Implementation of the \ref ResolvableConsumer interface.
*
* Consume a package atom, inserting it in the cache, under
- * \a catalog_id ownership.
+ * \a repository_id ownership.
*
- * \param catalog_id record id of catalog to which to append the resolvable.
+ * \param repository_id record id of repository to which to append the resolvable.
* \param atom package atom data
*
* \note this is somewhat specific to current YUM patch metadata design
* and may change (to consumeAtom(data::RecordId,data::Atom)).
*/
- virtual void consumePackageAtom( const data::RecordId &catalog_id, const data::PackageAtom_Ptr & atom );
+ virtual void consumePackageAtom( const data::RecordId &repository_id, const data::PackageAtom_Ptr & atom );
/**
* Implementation of the \ref ResolvableConsumer interface
*
* Consume a message, inserting it in the cache, under
- * \param catalog_id ownership.
+ * \param repository_id ownership.
* \param message Message data
*/
- virtual void consumeMessage( const data::RecordId &catalog_id, data::Message_Ptr);
+ virtual void consumeMessage( const data::RecordId &repository_id, data::Message_Ptr);
/**
* Implementation of the \ref ResolvableConsumer interface
*
* Consume a script, inserting it in the cache, under
- * \param catalog_id ownership.
+ * \param repository_id ownership.
* \param script Script data
*/
- virtual void consumeScript( const data::RecordId &catalog_id, data::Script_Ptr);
+ virtual void consumeScript( const data::RecordId &repository_id, data::Script_Ptr);
/**
* Implementation of the \ref ResolvableConsumer interface
*
* Consume a pattern, inserting it in the cache, under
- * \param catalog_id ownership.
+ * \param repository_id ownership.
* \param pattern Pattern data
*/
- virtual void consumePattern( const data::RecordId &catalog_id, data::Pattern_Ptr pattern );
+ virtual void consumePattern( const data::RecordId &repository_id, data::Pattern_Ptr pattern );
/**
* Implementation of the \ref ResolvableConsumer interface
*
* Consume a product, inserting it in the cache, under
- * \param catalog_id ownership.
+ * \param repository_id ownership.
* \param pattern Pattern data
*/
- virtual void consumeProduct( const data::RecordId &catalog_id, data::Product_Ptr product );
+ virtual void consumeProduct( const data::RecordId &repository_id, data::Product_Ptr product );
/**
* Implementation of the \ref ResolvableConsumer interface
*
* Consume changelog of a resolvable, inserting it in the cache.
- * \param catalog_id ownership.
+ * \param repository_id ownership.
* \param resolvable resolvable for which the changelog data are to be saved
* \param changelog the changelog
*/
- virtual void consumeChangelog( const data::RecordId &catalog_id, const data::Resolvable_Ptr & resolvable, const Changelog & changelog );
+ virtual void consumeChangelog( const data::RecordId &repository_id, const data::Resolvable_Ptr & resolvable, const Changelog & changelog );
/**
* Implementation of the \ref ResolvableConsumer interface
*
* Consume filelist of a resolvable, inserting it in the cache.
- * \param catalog_id ownership.
+ * \param repository_id ownership.
* \param resolvable resolvable for which the filelist is to be saved
* \param filenames list of filenames the resolvable contains
*/
- virtual void consumeFilelist( const data::RecordId &catalog_id, const data::Resolvable_Ptr & resolvable, const data::Filenames & filenames );
+ virtual void consumeFilelist( const data::RecordId &repository_id, const data::Resolvable_Ptr & resolvable, const data::Filenames & filenames );
/**
* Appends a resolvable to the store.
* Optionaly you can pass a list of \c CapabilityImpl::Ptr
* as dependencies for the resolvable.
*
- * You have to specify the RecordId for the catalog owning
+ * You have to specify the RecordId for the repository owning
* this resolvable. Yuu can obtain it with
* \ref lookupOrAppendCatalog
*
* other properties.
*
*/
- data::RecordId appendResolvable( const data::RecordId &catalog_id,
+ data::RecordId appendResolvable( const data::RecordId &repository_id,
const Resolvable::Kind &kind,
const NVRA &nvra,
const data::Dependencies &deps );
const std::string &name );
/**
- * Returns the record id of a catalog (Source)
+ * Returns the record id of a repository (Source)
*
- * \param url Url of the catalog
- * \param path path of the catalog (relative to url)
+ * \param url Url of the repository
+ * \param path path of the repository (relative to url)
*
- * \note If the catalog entry does not exist, it will
+ * \note If the repository entry does not exist, it will
* be created and the new inserted entry's id will
* be returned.
*/
/**
- * Update a known catalog checksum and timestamp
+ * Update a known repository checksum and timestamp
*
* \note If you don't provide timestamp it defaults
* to now.
: _dbdir(dbdir)
, _type_cache(dbdir)
{
- _fields = "id, name, version, release, epoch, arch, kind, installed_size, archive_size, install_only, build_time, install_time, catalog_id";
+ _fields = "id, name, version, release, epoch, arch, kind, installed_size, archive_size, install_only, build_time, install_time, repository_id";
}
~Impl()
" , vendor TEXT"
" , size INTEGER"
" , archive_size INTEGER"
- " , catalog INTEGER"
- " , catalog_media_nr INTEGER"
+ " , repository INTEGER"
+ " , repository_media_nr INTEGER"
" , install_only INTEGER"
" , build_time INTEGER"
" , install_time INTEGER"
" , text TEXT"
");",
- "CREATE TABLE catalogs ("
+ "CREATE TABLE repositories ("
" id INTEGER"
" , alias TEXT NOT NULL"
" , url TEXT"
" , epoch INTEGER"
" , arch INTEGER"
" , relation INTEGER"
- " , catalog TEXT"
+ " , repository TEXT"
" , glob TEXT"
" , importance INTEGER"
" , importance_gteq INTEGER"
"CREATE INDEX package_details_resolvable_id ON package_details (resolvable_id);",
- "CREATE INDEX resolvable_catalog ON resolvables (catalog);",
+ "CREATE INDEX resolvable_repository ON resolvables (repository);",
- "CREATE TRIGGER remove_catalogs"
- " AFTER DELETE ON catalogs"
+ "CREATE TRIGGER remove_repositories"
+ " AFTER DELETE ON repositories"
" BEGIN"
- " DELETE FROM resolvables WHERE catalog = old.id;"
+ " DELETE FROM resolvables WHERE repository = old.id;"
" END;",
"CREATE TRIGGER remove_patch_packages_baseversions"
DROP TABLE IF EXISTS types;
DROP TABLE IF EXISTS text_attributes;
DROP TABLE IF EXISTS split_capabilities;
-DROP TABLE IF EXISTS resolvables_catalogs;
+DROP TABLE IF EXISTS resolvables_repositories;
DROP TABLE IF EXISTS resolvables;
DROP TABLE IF EXISTS patch_packages_baseversions;
DROP TABLE IF EXISTS patch_packages;
DROP TABLE IF EXISTS dir_names;
DROP TABLE IF EXISTS delta_packages;
DROP TABLE IF EXISTS db_info;
-DROP TABLE IF EXISTS catalogs;
+DROP TABLE IF EXISTS repositories;
DROP INDEX IF EXISTS types_class_name_index;
DROP INDEX IF EXISTS text_attributes_index;
DROP INDEX IF EXISTS numeric_attributes_index;
CREATE INDEX types_class_name_index ON types(class, name);
------------------------------------------------
--- Knew catalogs. They existed some day.
+-- Knew repositories. They existed some day.
------------------------------------------------
-CREATE TABLE catalogs (
+CREATE TABLE repositories (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
, url TEXT NOT NULL
, path TEXT NOT NULL
, epoch INTEGER
, arch INTEGER REFERENCES types(id)
, kind INTEGER REFERENCES types(id)
- , catalog_id INTEGER REFERENCES catalogs(id)
+ , repository_id INTEGER REFERENCES repositories(id)
, installed_size INTEGER
, archive_size INTEGER
, install_only INTEGER
, install_time INTEGER
, shared_id INTEGER DEFAULT NULL
);
-CREATE INDEX resolvable_catalog_id ON resolvables(catalog_id);
+CREATE INDEX resolvable_repository_id ON resolvables(repository_id);
------------------------------------------------
-- Do we need those here?
, epoch INTEGER
, arch INTEGER
, relation INTEGER
- , catalog TEXT
+ , repository TEXT
, glob TEXT
, importance INTEGER
, importance_gteq INTEGER
END;
------------------------------------------------
--- Associate resolvables and catalogs
+-- Associate resolvables and repositories
------------------------------------------------
-- FIXME do we want to allow same resolvable to
-- be listed twice in same source but different
-- medias? I think NOT.
-CREATE TABLE resolvables_catalogs (
+CREATE TABLE resolvables_repositories (
resolvable_id INTEGER REFERENCES resolvables (id)
- , catalog_id INTEGER REFERENCES catalogs (id)
- , catalog_media_nr INTEGER
- , PRIMARY KEY ( resolvable_id, catalog_id )
+ , repository_id INTEGER REFERENCES repositories (id)
+ , repository_media_nr INTEGER
+ , PRIMARY KEY ( resolvable_id, repository_id )
);
--- Auto clean catalogs
-CREATE TRIGGER remove_catalogs
- AFTER DELETE ON catalogs
+-- Auto clean repositories
+CREATE TRIGGER remove_repositories
+ AFTER DELETE ON repositories
BEGIN
- DELETE FROM resolvables WHERE catalog_id = old.id;
+ DELETE FROM resolvables WHERE repository_id = old.id;
END;
CREATE TRIGGER remove_patch_packages_baseversions
class RepoParser::Impl
{
public:
- Impl( const data::RecordId & catalogId_r,
+ Impl( const data::RecordId & repositoryId_r,
data::ResolvableDataConsumer & consumer_r,
const ProgressData::ReceiverFnc & fnc_r )
- : _catalogId( catalogId_r )
+ : _repositoryId( repositoryId_r )
, _consumer( consumer_r )
{
_ticks.sendTo( fnc_r );
{
SEC << "[Prod]" << data_r << endl;
_prodData = data_r;
- _consumer.consumeProduct( _catalogId, data_r );
+ _consumer.consumeProduct( _repositoryId, data_r );
}
void consumePkg( const data::Package_Ptr & data_r )
}
private:
- data::RecordId _catalogId;
+ data::RecordId _repositoryId;
data::ResolvableDataConsumer & _consumer;
ProgressData _ticks;
// METHOD NAME : RepoParser::RepoParser
// METHOD TYPE : Ctor
//
- RepoParser::RepoParser( const data::RecordId & catalogId_r,
+ RepoParser::RepoParser( const data::RecordId & repositoryId_r,
data::ResolvableDataConsumer & consumer_r,
const ProgressData::ReceiverFnc & fnc_r )
- : _pimpl( new Impl( catalogId_r, consumer_r, fnc_r ) )
+ : _pimpl( new Impl( repositoryId_r, consumer_r, fnc_r ) )
{}
///////////////////////////////////////////////////////////////////
public:
/** Ctor.
*
- * \param catalogId_r repository identifier
+ * \param repositoryId_r repository identifier
* \param consumer_r consumer of parsed data
* \param fnc_r progress reporting function
*/
- RepoParser( const data::RecordId & catalogId_r,
+ RepoParser( const data::RecordId & repositoryId_r,
data::ResolvableDataConsumer & consumer_r,
const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() );
/** Dtor */
YUMParser::YUMParser(
- const data::RecordId & catalog_id,
+ const data::RecordId & repository_id,
data::ResolvableDataConsumer & consumer,
const ProgressData::ReceiverFnc & progress)
:
- _consumer(consumer), _catalog_id(catalog_id)
+ _consumer(consumer), _repository_id(repository_id)
{
_ticks.name("YUMParser");
_ticks.sendTo(progress);
bool YUMParser::primary_CB(const data::Package_Ptr & package_r)
{
- _consumer.consumePackage( _catalog_id, package_r );
+ _consumer.consumePackage( _repository_id, package_r );
/* MIL << "got package "
<< package.name << package.edition << " "
bool YUMParser::patch_CB(const data::Patch_Ptr & patch)
{
- _consumer.consumePatch( _catalog_id, patch );
+ _consumer.consumePatch( _repository_id, patch );
MIL << "got patch "
<< patch->name << patch->edition << " "
bool YUMParser::other_CB(
const data::Resolvable_Ptr & res_ptr, const Changelog & changelog)
{
- _consumer.consumeChangelog(_catalog_id, res_ptr, changelog);
+ _consumer.consumeChangelog(_repository_id, res_ptr, changelog);
/*
DBG << "got changelog for "
<< res_ptr->name << res_ptr->edition << " "
bool YUMParser::filelist_CB(
const data::Resolvable_Ptr & res_ptr, const data::Filenames & filenames)
{
- _consumer.consumeFilelist(_catalog_id, res_ptr, filenames);
+ _consumer.consumeFilelist(_repository_id, res_ptr, filenames);
/*
DBG << "got filelist for "
<< res_ptr->name << res_ptr->edition << " "
bool YUMParser::pattern_CB(const data::Pattern_Ptr & product_ptr)
{
- _consumer.consumePattern(_catalog_id, product_ptr);
+ _consumer.consumePattern(_repository_id, product_ptr);
MIL << "got pattern " << product_ptr->name << endl;
bool YUMParser::product_CB(const data::Product_Ptr & product_ptr)
{
- _consumer.consumeProduct(_catalog_id, product_ptr);
+ _consumer.consumeProduct(_repository_id, product_ptr);
MIL << "got product " << product_ptr->name
<< "-" << product_ptr->edition << endl;
* \code
*
* cache::CacheStore store(dbdir);
- * data::RecordId catalog_id = store.lookupOrAppendCatalog(sourceurl, "/");
+ * data::RecordId repository_id = store.lookupOrAppendCatalog(sourceurl, "/");
*
- * YUMParser parser(catalog_id, store, &progress_function);
+ * YUMParser parser(repository_id, store, &progress_function);
* parser.start(source_cache_dir);
*
* store.commit();
/**
* CTOR
*
- * \param catalog_id repository identifier
+ * \param repository_id repository identifier
* \param consumer consumer of parsed data
* \param progress progress reporting function
*/
YUMParser(
- const data::RecordId & catalog_id,
+ const data::RecordId & repository_id,
data::ResolvableDataConsumer & consumer,
const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc()
);
/** Object for processing the read data */
data::ResolvableDataConsumer & _consumer;
- /** ID of the repository record in the DB (catalogs.id) */
- data::RecordId _catalog_id;
+ /** ID of the repository record in the DB (repositories.id) */
+ data::RecordId _repository_id;
/** List of parser jobs read from repomd.xml and patches.xml files. */
std::list<YUMParserJob> _jobs;
namespace cached
{ /////////////////////////////////////////////////////////////////
-CachedRepositoryImpl::CachedRepositoryImpl( const Pathname &dbdir)
- : _dbdir(dbdir)
- , _type_cache(dbdir)
+CachedRepositoryImpl::CachedRepositoryImpl( const Pathname &dbdir, const data::RecordId &repository_id )
+ : _dbdir(dbdir),
+ _type_cache(dbdir),
+ _repository_id(repository_id)
{
}
con.executenonquery("PRAGMA cache_size=8000;");
con.executenonquery("BEGIN;");
- sqlite3_command cmd( con, "select id,name,version,release,epoch,arch,kind from resolvables;");
+ sqlite3_command cmd( con, "select id,name,version,release,epoch,arch,kind from resolvables where repository_id=:repository_id;");
+ cmd.bind(":repository_id", _repository_id);
map<data::RecordId, NVRAD> nvras;
sqlite3_reader reader = cmd.executereader();
public:
/** Default ctor */
- CachedRepositoryImpl( const zypp::Pathname &dbdir );
+ CachedRepositoryImpl( const zypp::Pathname &dbdir, const data::RecordId &repository_id );
/** Dtor */
~CachedRepositoryImpl();
void read_capabilities( sqlite3x::sqlite3_connection &con, std::map<data::RecordId, NVRAD> &nvras );
cache::CacheTypes _type_cache;
+ data::RecordId _repository_id;
};
///////////////////////////////////////////////////////////////////