Zypp Commits
Threads by month
- ----- 2024 -----
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
June 2007
- 7 participants
- 204 discussions
[zypp-commit] r5659 - in /trunk/libzypp: devel/devel.jkupec/ zypp/data/ zypp2/cache/ zypp2/repo/cached/
by jkupec@svn.opensuse.org 03 Jun '07
by jkupec@svn.opensuse.org 03 Jun '07
03 Jun '07
Author: jkupec
Date: Mon Jun 4 01:11:45 2007
New Revision: 5659
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5659&view=rev
Log:
- storing almost all resolvable data
- cleaned-up ResolvableDataConsumer interface
Added:
trunk/libzypp/devel/devel.jkupec/dbqueries.sql
Modified:
trunk/libzypp/devel/devel.jkupec/CMakeLists.txt
trunk/libzypp/zypp/data/ResolvableDataConsumer.h
trunk/libzypp/zypp2/cache/CacheStore.cpp
trunk/libzypp/zypp2/cache/CacheStore.h
trunk/libzypp/zypp2/cache/ResolvableQuery.cc
trunk/libzypp/zypp2/cache/ResolvableQuery.h
trunk/libzypp/zypp2/repo/cached/PackageImpl.cc
Modified: trunk/libzypp/devel/devel.jkupec/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.jkupec/CMake…
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/CMakeLists.txt (original)
+++ trunk/libzypp/devel/devel.jkupec/CMakeLists.txt Mon Jun 4 01:11:45 2007
@@ -1,5 +1,3 @@
-INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
-
ADD_DEFINITIONS(-DSRC_DIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\")
#ADD_EXECUTABLE(sourcedownload sourcedownload.cc)
@@ -24,4 +22,3 @@
ADD_EXECUTABLE( bridge ${bridge_SRCS} )
TARGET_LINK_LIBRARIES( bridge zypp zypp2)
-
Added: trunk/libzypp/devel/devel.jkupec/dbqueries.sql
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.jkupec/dbque…
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/dbqueries.sql (added)
+++ trunk/libzypp/devel/devel.jkupec/dbqueries.sql Mon Jun 4 01:11:45 2007
@@ -0,0 +1,43 @@
+-- what kinds of resolvables have been read?
+select * from types where class = 'kind';
+
+-- what languages have been encountered?
+select * from types where class = 'lang';
+
+-- what architectures have been read?
+select * from types where class = 'arch';
+
+-- what types of dependencies have been encountered?
+select * from types where class = 'deptype';
+
+-- ----------------------------------------------------------------------------
+
+-- how many packages have been read?
+select count(*) from resolvables r, types t where t.class = 'kind' and t.name = 'package' and t.id = r.kind;
+
+-- print resolvable kind -> count table
+select t.name, count(*) from resolvables r, types t where t.class = 'kind' and t.id = r.kind group by t.name;
+
+-- what patches have been read? print id, name, and version
+select r.id, r.name, r.version from resolvables r, types t where t.class = 'kind' and t.name = 'patch' and t.id = r.kind;
+
+-- ----------------------------------------------------------------------------
+
+-- print all text and numeric attributes of resolvable with id = 2
+select a.weak_resolvable_id "res-id", t.class "attr-class", t.name "attr-name", a.text "value"
+ from text_attributes a, types t
+ where t.id = a.attr_id and a.weak_resolvable_id = 2
+union
+select a.weak_resolvable_id "res-id", t.class "attr-class", t.name "attr-name", a.value "value"
+ from numeric_attributes a, types t
+ where t.id = a.attr_id and a.weak_resolvable_id = 2
+order by t.class
+
+-- print all named dependencies of resolvable with id = 2
+select dt.name "dtype", kt.name "kind", n.name "name", rt.name "rel", c.version "version"
+ from named_capabilities c, types dt, types kt, types rt, names n
+ where c.dependency_type = dt.id
+ and c.refers_kind= kt.id
+ and c.relation = rt.id
+ and c.name_id = n.id
+ and resolvable_id = 2;
Modified: trunk/libzypp/zypp/data/ResolvableDataConsumer.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/data/ResolvableData…
==============================================================================
--- trunk/libzypp/zypp/data/ResolvableDataConsumer.h (original)
+++ trunk/libzypp/zypp/data/ResolvableDataConsumer.h Mon Jun 4 01:11:45 2007
@@ -28,14 +28,14 @@
ResolvableDataConsumer();
virtual ~ResolvableDataConsumer();
- 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 consumePackage( const data::RecordId &repository_id, const data::Package_Ptr &) = 0;
+ virtual void consumeSourcePackage( const data::RecordId &repository_id, const data::SrcPackage_Ptr &) = 0;
+ virtual void consumeProduct( const data::RecordId &repository_id, const data::Product_Ptr &) = 0;
+ virtual void consumePatch( const data::RecordId &repository_id, const 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 consumeMessage( const data::RecordId &repository_id, const data::Message_Ptr &) = 0;
+ virtual void consumeScript( const data::RecordId &repository_id, const data::Script_Ptr &) = 0;
+ virtual void consumePattern( const data::RecordId &repository_id, const 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;
Modified: trunk/libzypp/zypp2/cache/CacheStore.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.c…
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.cpp (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.cpp Mon Jun 4 01:11:45 2007
@@ -97,6 +97,19 @@
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 (media_nr, location, checksum, download_size, build_time) "
+ "values (:media_nr, :location, :checksum, :download_size, :build_time);" ));
+ insert_deltarpm_cmd.reset( new sqlite3_command (con,
+ "insert into delta_packages (media_nr, location, checksum, download_size, build_time, "
+ "baseversion_version, baseversion_release, baseversion_epoch, baseversion_checksum, "
+ "baseversion_build_time, baseversion_sequence_info) "
+ "values (:media_nr, :location, :checksum, :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,
+ "insert into patch_packages_baseversions (patch_package_id, version, release, epoch) "
+ "values (:patch_package_id, :version, :release, :epoch)" ));
// disable autocommit
@@ -157,6 +170,10 @@
sqlite3_command_ptr count_shared_cmd;
+ sqlite3_command_ptr insert_patchrpm_cmd;
+ sqlite3_command_ptr insert_deltarpm_cmd;
+ sqlite3_command_ptr append_patch_baseversion_cmd;
+
map<string, RecordId> name_cache;
map< pair<string,string>, RecordId> type_cache;
int name_cache_hits;
@@ -185,19 +202,24 @@
_pimpl->con.executenonquery("COMMIT;");
}
-void CacheStore::consumeResObject( const data::RecordId &rid, data::ResObject_Ptr res )
+void CacheStore::appendResObjectAttributes( const data::RecordId &rid,
+ const data::ResObject_Ptr & res )
{
appendTranslatedStringAttribute( rid, "ResObject", "description", res->description );
appendTranslatedStringAttribute( rid, "ResObject", "summary", res->summary );
appendNumericAttribute( rid, "ResObject", "installedSize", res->installedSize );
appendNumericAttribute( rid, "ResObject", "buildTime", res->buildTime );
+ appendBooleanAttribute( rid, "ResObject", "installOnly", res->installOnly );
+ appendStringAttribute( rid, "ResObject", "vendor", res->vendor );
+ appendTranslatedStringAttribute( rid, "ResObject", "licenseToConfirm", res->licenseToConfirm );
+ appendTranslatedStringAttribute( rid, "ResObject", "insnotify", res->insnotify );
+ appendTranslatedStringAttribute( rid, "ResObject", "delnotify", res->delnotify );
}
-void CacheStore::consumePackage( const RecordId &repository_id, data::Package_Ptr package )
-{
- RecordId pkgid = appendResolvable( repository_id, ResTraits<Package>::kind, NVRA( package->name, package->edition, package->arch ), package->deps );
- consumeResObject( pkgid, package );
+void CacheStore::appendPackageBaseAttributes( const RecordId & pkgid,
+ const data::Packagebase_Ptr & package )
+{
appendStringAttribute( pkgid, "Package", "checksum", package->repositoryLocation.fileChecksum.checksum() );
appendStringAttribute( pkgid, "Package", "buildhost", package->buildhost );
appendStringAttribute( pkgid, "Package", "distribution", package->distribution );
@@ -215,15 +237,40 @@
appendStringAttribute( pkgid, "Package", "location", package->repositoryLocation.filePath.asString() );
}
-void CacheStore::consumeSourcePackage( const data::RecordId &repository_id, data::SrcPackage_Ptr srcpackage )
+void CacheStore::consumePackage( const RecordId & repository_id,
+ const data::Package_Ptr & package )
{
+ RecordId pkgid = appendResolvable( repository_id, ResTraits<Package>::kind,
+ NVRA( package->name, package->edition, package->arch ), package->deps );
+ appendResObjectAttributes( pkgid, package );
+ appendPackageBaseAttributes( pkgid, package );
+}
+
+void CacheStore::consumeSourcePackage( const data::RecordId & repository_id,
+ const data::SrcPackage_Ptr & package )
+{
+ RecordId pkgid = appendResolvable( repository_id, ResTraits<SrcPackage>::kind,
+ NVRA( package->name, package->edition, package->arch ), package->deps );
+ appendResObjectAttributes( pkgid, package );
+ appendPackageBaseAttributes( pkgid, package );
#warning TBD
}
-void CacheStore::consumePatch( const data::RecordId &repository_id, data::Patch_Ptr patch)
+void CacheStore::consumePatch( const data::RecordId & repository_id,
+ const data::Patch_Ptr & patch)
{
- RecordId id = appendResolvable( repository_id, ResTraits<Patch>::kind, NVRA( patch->name, patch->edition, patch->arch ), patch->deps );
- consumeResObject( id, patch );
+ RecordId id = appendResolvable(
+ repository_id, ResTraits<Patch>::kind,
+ NVRA( patch->name, patch->edition, patch->arch ), patch->deps );
+
+ appendResObjectAttributes( id, patch );
+
+ // patch attributes
+ appendNumericAttribute( id, "Patch", "timestamp", patch->timestamp );
+ appendStringAttribute( id, "Patch", "category", patch->category );
+ appendBooleanAttribute( id, "Patch", "rebootNeeded", patch->rebootNeeded );
+ appendBooleanAttribute( id, "Patch", "affectsPkgManager", patch->affectsPkgManager );
+
DBG << "got patch " << patch->name << ", atoms: ";
// cosume atoms
@@ -262,45 +309,95 @@
DBG << endl;
}
-void CacheStore::consumePackageAtom( const data::RecordId &repository_id, const data::PackageAtom_Ptr & atom )
+void CacheStore::consumePackageAtom( const data::RecordId & repository_id,
+ const data::PackageAtom_Ptr & atom )
{
- RecordId id = appendResolvable( repository_id, ResTraits<Atom>::kind, NVRA( atom->name, atom->edition, atom->arch ), atom->deps );
- consumeResObject( id, atom );
+ RecordId id = appendResolvable( repository_id, ResTraits<Atom>::kind,
+ NVRA( atom->name, atom->edition, atom->arch ), atom->deps );
+ appendResObjectAttributes( id, atom );
+ appendPackageBaseAttributes( id, atom );
+
+ for (set<data::PatchRpm_Ptr>::const_iterator p = atom->patchRpms.begin();
+ p != atom->patchRpms.end(); ++p)
+ appendPatchRpm(*p);
+
+ for (set<data::DeltaRpm_Ptr>::const_iterator d = atom->deltaRpms.begin();
+ d != atom->deltaRpms.end(); ++d)
+ appendDeltaRpm(*d);
}
-void CacheStore::consumeMessage( const data::RecordId &repository_id, data::Message_Ptr message )
+void CacheStore::consumeMessage( const data::RecordId & repository_id,
+ const data::Message_Ptr & message )
{
- RecordId id = appendResolvable( repository_id, ResTraits<Message>::kind, NVRA( message->name, message->edition, message->arch ), message->deps );
- consumeResObject( id, message );
+ RecordId id = appendResolvable( repository_id, ResTraits<Message>::kind,
+ NVRA( message->name, message->edition, message->arch ), message->deps );
+ appendResObjectAttributes( id, message );
+
+ appendTranslatedStringAttribute( id, "Message", "text", message->text );
}
-void CacheStore::consumeScript( const data::RecordId &repository_id, data::Script_Ptr script )
+void CacheStore::consumeScript( const data::RecordId & repository_id,
+ const data::Script_Ptr & script )
{
- RecordId id = appendResolvable( repository_id, ResTraits<Script>::kind, NVRA( script->name, script->edition, script->arch ), script->deps );
- consumeResObject( id, script );
+ RecordId id = appendResolvable( repository_id, ResTraits<Script>::kind,
+ NVRA( script->name, script->edition, script->arch ), script->deps );
+ appendResObjectAttributes( id, script );
+
+ appendStringAttribute( id, "Script", "doScript", script->doScript );
+ appendStringAttribute( id, "Script", "doScriptLocation", script->doScriptLocation.filePath.asString() );
+ appendStringAttribute( id, "Script", "doScriptChecksum", script->doScriptLocation.fileChecksum.checksum() );
+ //! \todo what about checksum type?
+ appendStringAttribute( id, "Script", "undoScript", script->undoScript );
+ appendStringAttribute( id, "Script", "undoScriptLocation", script->undoScriptLocation.filePath.asString() );
+ appendStringAttribute( id, "Script", "undoScriptChecksum", script->undoScriptLocation.fileChecksum.checksum() );
+ //! \todo what about checksum type?
}
-void CacheStore::consumePattern( const data::RecordId &repository_id, data::Pattern_Ptr pattern )
+void CacheStore::consumePattern( const data::RecordId & repository_id,
+ const data::Pattern_Ptr & pattern )
{
- RecordId id = appendResolvable( repository_id, ResTraits<Pattern>::kind, NVRA( pattern->name, pattern->edition, pattern->arch ), pattern->deps );
- consumeResObject( id, pattern );
+ RecordId id = appendResolvable( repository_id, ResTraits<Pattern>::kind,
+ NVRA( pattern->name, pattern->edition, pattern->arch ), pattern->deps );
+ appendResObjectAttributes( id, pattern );
+
+ appendBooleanAttribute( id, "Pattern", "isDefault", pattern->isDefault );
+ appendBooleanAttribute( id, "Pattern", "userVisible", pattern->userVisible );
+ appendTranslatedStringAttribute( id, "Pattern", "category", pattern->category );
+ appendStringAttribute( id, "Pattern", "icon", pattern->icon );
+ appendStringAttribute( id, "Pattern", "order", pattern->order );
}
-void CacheStore::consumeProduct( const data::RecordId &repository_id, data::Product_Ptr product )
+void CacheStore::consumeProduct( const data::RecordId & repository_id,
+ const data::Product_Ptr & product )
{
- RecordId id = appendResolvable( repository_id, ResTraits<Product>::kind, NVRA( product->name, product->edition, product->arch ), product->deps );
- consumeResObject( id, product );
+ RecordId id = appendResolvable( repository_id, ResTraits<Product>::kind,
+ NVRA( product->name, product->edition, product->arch ), product->deps );
+ appendResObjectAttributes( id, product );
+
+ appendTranslatedStringAttribute( id, "Product", "shortName", product->shortName );
+ appendTranslatedStringAttribute( id, "Product", "longName", product->longName );
+ //! \todo std::list<std::string> flags;
+ appendStringAttribute( id, "Pattern", "releasenotesUrl", product->releasenotesUrl.asString() );
+ //! \todo std::list<Url> updateUrls;
+ //! \todo std::list<Url> extraUrls;
+ //! \todo std::list<Url> optionalUrls;
+ appendStringAttribute( id, "Pattern", "distributionName", product->distributionName );
+ appendStringAttribute( id, "Pattern", "distributionEdition", product->distributionEdition.asString() );
}
-void CacheStore::consumeChangelog( const data::RecordId &repository_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
+ // maybe appendChangelog(const data::RecordId & resolvable_id, Changelog changelog) will
// be needed for inserting the changelog using in-memory record id of corresponding
// resolvable. (first, we'll see how fast is the inserting without remembering those ids)
}
-void CacheStore::consumeFilelist( const data::RecordId &repository_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
@@ -308,9 +405,9 @@
}
RecordId CacheStore::appendResolvable( const RecordId &repository_id,
- const Resolvable::Kind &kind,
- const NVRA &nvra,
- const data::Dependencies &deps )
+ const Resolvable::Kind &kind,
+ const NVRA &nvra,
+ const data::Dependencies &deps )
{
_pimpl->append_resolvable_cmd->bind( ":name", nvra.name );
_pimpl->append_resolvable_cmd->bind( ":version", nvra.edition.version() );
@@ -508,6 +605,59 @@
}
+/** \todo lookupOrAppend ? */
+RecordId CacheStore::appendPatchRpm(const data::PatchRpm_Ptr & prpm)
+{
+ RecordId id;
+
+ //! \todo what's this? _pimpl->insert_patchrpm_cmd->bind(":media_nr", ???);
+ _pimpl->insert_patchrpm_cmd->bind(":location", prpm->location.filePath.asString());
+ _pimpl->insert_patchrpm_cmd->bind(":checksum", prpm->location.fileChecksum.checksum());
+ _pimpl->insert_patchrpm_cmd->bind(":download_size", static_cast<ByteCount::SizeType>(prpm->location.fileSize));
+ _pimpl->insert_patchrpm_cmd->bind(":build_time", prpm->buildTime.asSeconds());
+ _pimpl->insert_patchrpm_cmd->executenonquery();
+
+ id = _pimpl->con.insertid();
+
+ for (set<data::BaseVersion_Ptr>::const_iterator bv = prpm->baseVersions.begin();
+ bv != prpm->baseVersions.end(); ++bv)
+ {
+ _pimpl->append_patch_baseversion_cmd->bind(":patch_package_id", id);
+ _pimpl->append_patch_baseversion_cmd->bind(":version", (*bv)->edition.version());
+ _pimpl->append_patch_baseversion_cmd->bind(":release", (*bv)->edition.release());
+ _pimpl->append_patch_baseversion_cmd->bind(":epoch", (int) (*bv)->edition.epoch());
+ _pimpl->append_patch_baseversion_cmd->executenonquery();
+ }
+
+ return id;
+}
+
+
+/** \todo lookupOrAppend ? */
+RecordId CacheStore::appendDeltaRpm(const data::DeltaRpm_Ptr & drpm)
+{
+ RecordId id;
+
+ //! \todo what's this? _pimpl->insert_deltarpm_cmd->bind(":media_nr", ???);
+ _pimpl->insert_deltarpm_cmd->bind(":location", drpm->location.filePath.asString());
+ _pimpl->insert_deltarpm_cmd->bind(":checksum", drpm->location.fileChecksum.checksum());
+ _pimpl->insert_deltarpm_cmd->bind(":download_size", static_cast<ByteCount::SizeType>(drpm->location.fileSize));
+ _pimpl->insert_deltarpm_cmd->bind(":build_time", drpm->buildTime.asSeconds());
+
+ _pimpl->insert_deltarpm_cmd->bind(":baseversion_version", drpm->baseVersion.edition.version());
+ _pimpl->insert_deltarpm_cmd->bind(":baseversion_release", drpm->baseVersion.edition.release());
+ _pimpl->insert_deltarpm_cmd->bind(":baseversion_epoch", (int) drpm->baseVersion.edition.epoch());
+ _pimpl->insert_deltarpm_cmd->bind(":baseversion_build_time", drpm->baseVersion.buildTime.asSeconds());
+ _pimpl->insert_deltarpm_cmd->bind(":baseversion_checksum", drpm->baseVersion.checkSum.checksum());
+ _pimpl->insert_deltarpm_cmd->bind(":baseversion_sequence_info", drpm->baseVersion.sequenceInfo);
+
+ _pimpl->insert_deltarpm_cmd->executenonquery();
+ id = _pimpl->con.insertid();
+
+ return id;
+}
+
+
// RecordId CacheStore::appendDependencyEntry( const RecordId &resolvable_id, zypp::Dep deptype, const Resolvable::Kind &refers )
// {
// //DBG << "rid: " << resolvable_id << " deptype: " << deptype << " " << "refers: " << refers << endl;
@@ -744,6 +894,15 @@
_pimpl->set_shared_flag_cmd->executenonquery();
}
+void CacheStore::appendBooleanAttribute( const data::RecordId & resolvable_id,
+ const std::string & klass,
+ const std::string & name,
+ bool value)
+{
+ RecordId type_id = lookupOrAppendType( klass, name );
+ appendNumericAttribute( resolvable_id, type_id, value ? 1 : 0 );
+}
+
void CacheStore::appendNumericAttribute( const data::RecordId &resolvable_id,
const std::string &klass,
const std::string &name,
@@ -786,7 +945,11 @@
const std::string &name,
const std::string &text )
{
- RecordId lang_id = lookupOrAppendType("lang", locale.code() );
+ // don't bother with writing if the string is empty
+ if (text.empty()) return;
+
+ RecordId lang_id = lookupOrAppendType("lang",
+ locale.code().empty() ? "none" : locale.code() );
RecordId type_id = lookupOrAppendType( klass, name );
appendStringAttribute( resolvable_id, lang_id, type_id, text );
}
@@ -813,6 +976,9 @@
const RecordId &type_id,
const string &value )
{
+ // don't bother with writing if the string is empty
+ if (value.empty()) return;
+
// weak resolvable_id
_pimpl->append_text_attribute_cmd->bind(":rid", resolvable_id );
_pimpl->append_text_attribute_cmd->bind(":lang_id", lang_id );
Modified: trunk/libzypp/zypp2/cache/CacheStore.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.h…
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.h (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.h Mon Jun 4 01:11:45 2007
@@ -77,7 +77,8 @@
* \param repository_id ownership.
* \param package Package data
*/
- virtual void consumePackage( const data::RecordId &repository_id, data::Package_Ptr package);
+ virtual void consumePackage(const data::RecordId &repository_id,
+ const data::Package_Ptr & package);
/**
* Implementation of the \ref ResolvableConsumer interface
@@ -86,7 +87,9 @@
* \param catalog_id ownership.
* \param srcpackage Source package data
*/
- virtual void consumeSourcePackage( const data::RecordId &catalog_id, data::SrcPackage_Ptr srcpackage );
+ virtual void consumeSourcePackage(
+ const data::RecordId &catalog_id,
+ const data::SrcPackage_Ptr & srcpackage );
/**
* Implementation of the \ref ResolvableConsumer interface
@@ -95,7 +98,8 @@
* \param repository_id ownership.
* \param patch Patch data
*/
- virtual void consumePatch( const data::RecordId &repository_id, data::Patch_Ptr patch);
+ virtual void consumePatch( const data::RecordId &repository_id,
+ const data::Patch_Ptr & patch );
/**
* Implementation of the \ref ResolvableConsumer interface.
@@ -109,7 +113,8 @@
* \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 &repository_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
@@ -118,7 +123,8 @@
* \param repository_id ownership.
* \param message Message data
*/
- virtual void consumeMessage( const data::RecordId &repository_id, data::Message_Ptr);
+ virtual void consumeMessage( const data::RecordId & repository_id,
+ const data::Message_Ptr & message);
/**
* Implementation of the \ref ResolvableConsumer interface
@@ -127,7 +133,8 @@
* \param repository_id ownership.
* \param script Script data
*/
- virtual void consumeScript( const data::RecordId &repository_id, data::Script_Ptr);
+ virtual void consumeScript( const data::RecordId & repository_id,
+ const data::Script_Ptr & script);
/**
* Implementation of the \ref ResolvableConsumer interface
@@ -136,7 +143,8 @@
* \param repository_id ownership.
* \param pattern Pattern data
*/
- virtual void consumePattern( const data::RecordId &repository_id, data::Pattern_Ptr pattern );
+ virtual void consumePattern( const data::RecordId & repository_id,
+ const data::Pattern_Ptr & pattern );
/**
* Implementation of the \ref ResolvableConsumer interface
@@ -145,7 +153,8 @@
* \param repository_id ownership.
* \param pattern Pattern data
*/
- virtual void consumeProduct( const data::RecordId &repository_id, data::Product_Ptr product );
+ virtual void consumeProduct( const data::RecordId &repository_id,
+ const data::Product_Ptr & product );
/**
* Implementation of the \ref ResolvableConsumer interface
@@ -154,8 +163,11 @@
* \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 &repository_id, const data::Resolvable_Ptr & resolvable, const Changelog & changelog );
+ * \todo see implementation
+ */
+ virtual void consumeChangelog( const data::RecordId & repository_id,
+ const data::Resolvable_Ptr & resolvable,
+ const Changelog & changelog );
/**
* Implementation of the \ref ResolvableConsumer interface
@@ -164,8 +176,11 @@
* \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 &repository_id, const data::Resolvable_Ptr & resolvable, const data::Filenames & filenames );
+ * \todo see implementation
+ */
+ virtual void consumeFilelist( const data::RecordId &repository_id,
+ const data::Resolvable_Ptr & resolvable,
+ const data::Filenames & filenames );
/**
* Appends a resolvable to the store.
@@ -336,6 +351,24 @@
capability::CapabilityImpl::Ptr cap );
/**
+ * Insert patch RPM data into <tt>patch_packages</tt> table.
+ *
+ * \param prpm The patch RPM object to insert.
+ * \return Record ID of the newly inserted record.
+ */
+ data::RecordId appendPatchRpm( const data::PatchRpm_Ptr & prpm);
+
+
+ /**
+ * Insert delta RPM data into <tt>delta_packages</tt> table.
+ *
+ * \param drpm The delta RPM object to insert.
+ * \return Record ID of the newly inserted record.
+ */
+ data::RecordId appendDeltaRpm( const data::DeltaRpm_Ptr & drpm);
+
+
+ /**
* Returns the record id of a type
*
* Types are mostly used internally. To give concepts
@@ -562,10 +595,31 @@
const data::RecordId &type_id,
int value );
+ /**
+ * Append a bool attribute to a resolvable. Will be stored as
+ * numeric 1 or 0.
+ *
+ * \param resolvable_id Resovable Id, owner of the attribute
+ * \param type_id attribute id
+ * \param value bool value
+ */
+ void appendBooleanAttribute( const data::RecordId & resolvable_id,
+ const std::string & klass,
+ const std::string & name,
+ bool value);
+
+ /** \name Detail Attributes Inserters
+ * These functions are used by ResolvableConsumer interface functions
+ * to avoid some duplication across types.
+ */
+ //@{
+ void appendResObjectAttributes( const data::RecordId &rid,
+ const data::ResObject_Ptr & res );
+
+ void appendPackageBaseAttributes(const data::RecordId & pkgid,
+ const data::Packagebase_Ptr & package);
+ //@}
- // this functions are used by ResolvableConsumer interface functions
- // to avoid some duplication across types.
- void consumeResObject( const data::RecordId &rid, data::ResObject_Ptr res );
private:
/** Implementation. */
Modified: trunk/libzypp/zypp2/cache/ResolvableQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/ResolvableQu…
==============================================================================
--- trunk/libzypp/zypp2/cache/ResolvableQuery.cc (original)
+++ trunk/libzypp/zypp2/cache/ResolvableQuery.cc Mon Jun 4 01:11:45 2007
@@ -26,6 +26,7 @@
{
}
+
data::ResObject_Ptr fromRow( sqlite3_reader &reader )
{
data::ResObject_Ptr ptr (new data::ResObject);
@@ -39,6 +40,7 @@
return ptr;
}
+
void query( const data::RecordId &id,
ProcessResolvable fnc )
{
@@ -55,6 +57,7 @@
con.executenonquery("COMMIT;");
}
+
void query( const std::string &s,
ProcessResolvable fnc )
{
@@ -72,6 +75,7 @@
con.executenonquery("COMMIT;");
}
+
std::string queryStringAttribute( const data::RecordId &record_id,
const std::string &klass,
const std::string &name )
@@ -80,6 +84,7 @@
return queryStringAttributeTranslationInternal( con, record_id, Locale(), klass, name);
}
+
std::string queryStringAttributeTranslation( const data::RecordId &record_id,
const Locale &locale,
const std::string &klass,
@@ -89,6 +94,7 @@
return queryStringAttributeTranslationInternal( con, record_id, locale, klass, name );
}
+
TranslatedText queryTranslatedStringAttribute( const data::RecordId &record_id,
const std::string &klass,
const std::string &name )
@@ -97,6 +103,7 @@
return queryTranslatedStringAttributeInternal( con, record_id, klass, name );
}
+
int queryNumericAttribute( const data::RecordId &record_id,
const std::string &klass,
const std::string &name )
@@ -211,6 +218,14 @@
return _pimpl->queryNumericAttribute(record_id, klass, name);
}
+bool ResolvableQuery::queryBooleanAttribute( const data::RecordId &record_id,
+ const std::string &klass,
+ const std::string &name )
+{
+ return _pimpl->queryNumericAttribute(record_id, klass, name);
+}
+
+
std::string ResolvableQuery::queryStringAttribute( const data::RecordId &record_id,
const std::string &klass,
const std::string &name )
Modified: trunk/libzypp/zypp2/cache/ResolvableQuery.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/ResolvableQu…
==============================================================================
--- trunk/libzypp/zypp2/cache/ResolvableQuery.h (original)
+++ trunk/libzypp/zypp2/cache/ResolvableQuery.h Mon Jun 4 01:11:45 2007
@@ -65,7 +65,23 @@
int queryNumericAttribute( const data::RecordId &record_id,
const std::string &klass,
const std::string &name );
-
+
+
+ /**
+ * Queries a specifc attribute for a resolvable
+ *
+ * \param record_id Resolvable cache id
+ * \param klass Attribute Class
+ * \param name Attribute Name
+ *
+ * \return The bool value of the attribute or <tt>false</tt>
+ * if no record is found.
+ */
+ bool queryBooleanAttribute( const data::RecordId &record_id,
+ const std::string &klass,
+ const std::string &name );
+
+
/**
* Queries a specifc attribute for a resolvable
*
Modified: trunk/libzypp/zypp2/repo/cached/PackageImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/repo/cached/Packag…
==============================================================================
--- trunk/libzypp/zypp2/repo/cached/PackageImpl.cc (original)
+++ trunk/libzypp/zypp2/repo/cached/PackageImpl.cc Mon Jun 4 01:11:45 2007
@@ -82,7 +82,7 @@
bool PackageImpl::installOnly() const
{
- return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "installOnly" );
+ return _repository->resolvableQuery().queryBooleanAttribute( _id, "ResObject", "installOnly" );
}
unsigned PackageImpl::repositoryMediaNr() const
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] r5658 - in /trunk/updater-kde/updater: MainWindow.cpp MainWindow.h zypp/ZYppUpdater.cpp
by tgoettlicher@svn.opensuse.org 01 Jun '07
by tgoettlicher@svn.opensuse.org 01 Jun '07
01 Jun '07
Author: tgoettlicher
Date: Fri Jun 1 16:40:26 2007
New Revision: 5658
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5658&view=rev
Log:
Added patches and packages tabs to ui.
Modified:
trunk/updater-kde/updater/MainWindow.cpp
trunk/updater-kde/updater/MainWindow.h
trunk/updater-kde/updater/zypp/ZYppUpdater.cpp
Modified: trunk/updater-kde/updater/MainWindow.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/MainWindow.c…
==============================================================================
--- trunk/updater-kde/updater/MainWindow.cpp (original)
+++ trunk/updater-kde/updater/MainWindow.cpp Fri Jun 1 16:40:26 2007
@@ -20,6 +20,7 @@
#include <kglobal.h>
#include <kiconloader.h>
+#include <qtabwidget.h>
#include <kaction.h>
#include <kstdaction.h>
#include <klocale.h>
@@ -113,66 +114,99 @@
mainBox = new QVBoxLayout(centralWidget);
header = new HeaderWidget(centralWidget);
- updateList = new QListView(centralWidget);
- packageDescription = new KTextEdit(centralWidget);
+
+ tabwidget = new QTabWidget(centralWidget);
+
+ QWidget *patchWidget = new QWidget(tabwidget);
+ QWidget *packageWidget = new QWidget(tabwidget);
+
+ QVBoxLayout *patchBox = new QVBoxLayout(patchWidget);
+ QVBoxLayout *packageBox = new QVBoxLayout(packageWidget);
+
+ patchList = new QListView(patchWidget);
+ packageList = new QListView(packageWidget);
+ patchDescription = new KTextEdit(patchWidget);
+ packageDescription = new KTextEdit(packageWidget);
+
+ patchBox->addWidget(patchList,0,0);
+ patchBox->addWidget(patchDescription,0,0);
+
+ packageBox->addWidget(packageList,0,0);
+ packageBox->addWidget(packageDescription,0,0);
+
+ tabwidget->addTab(patchWidget, "Patches" );
+ tabwidget->addTab(packageWidget, "Packages (for experts only)" );
- configureButton = new KPushButton(i18n("Add/Remove Update Sources..."), centralWidget);
- cancelButton = new KPushButton(KStdGuiItem::cancel(), centralWidget);
- installButton = new KPushButton(KStdGuiItem::ok(), centralWidget);
- installButton->setText(i18n("Install"));
+// configureButton = new KPushButton(i18n("Add/Remove Update Sources..."), centralWidget);
+ cancelButton = new KPushButton(KStdGuiItem::cancel(), centralWidget);
+ installButton = new KPushButton(KStdGuiItem::ok(), centralWidget);
+ installButton->setText(i18n("Install"));
selectAllButton = new KPushButton(i18n("Select All"), centralWidget);
clearSelectionButton = new KPushButton(i18n("Clear Selection"), centralWidget);
mainBox->addWidget(header, 0, 0);
- mainBox->addWidget(updateList, 0, 0);
-
+ mainBox->addWidget(tabwidget, 0, 0);
+
selectionButtonsLayout = new QHBoxLayout(mainBox);
selectionButtonsLayout->addWidget(selectAllButton, false, Qt::AlignLeft);
selectionButtonsLayout->addWidget(clearSelectionButton, false, Qt::AlignRight);
+ patchDescription->setReadOnly(true);
packageDescription->setReadOnly(true);
- packageDescription->setMinimumHeight(125);
- mainBox->addWidget(packageDescription, 0, 0);
+
+// patchDescription->setMinimumHeight(125);
buttonsLayout = new QHBoxLayout(mainBox);
- buttonsLayout->addWidget(configureButton, false, Qt::AlignLeft);
- buttonsLayout->insertSpacing(1, 250);
+// buttonsLayout->addWidget(configureButton, false, Qt::AlignLeft);
+// buttonsLayout->insertSpacing(1, 250);
buttonsLayout->addWidget(installButton, false, Qt::AlignRight);
buttonsLayout->addSpacing(10);
buttonsLayout->addWidget(cancelButton, false, Qt::AlignRight);
- connect(configureButton, SIGNAL(clicked()), this, SLOT(serverButtonClicked()));
- connect(installButton, SIGNAL(clicked()), this, SLOT(installButtonClicked()));
- connect(cancelButton, SIGNAL(clicked()), this, SLOT(hide()));
+ connect(configureButton, SIGNAL(clicked()), this, SLOT(serverButtonClicked()));
+ connect(installButton, SIGNAL(clicked()), this, SLOT(installButtonClicked()));
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(selectAllButton, SIGNAL(clicked()), this, SLOT(selectButtonClicked()));
connect(clearSelectionButton, SIGNAL(clicked()), this, SLOT(clearButtonClicked()));
header->setDescription(i18n("<b>Available Updates:</b><br> The following are software upgrades and patches to add features and fix bugs.<br>"));
- updateList->addColumn(i18n("Name"));
- updateList->setColumnWidthMode(COLUMN_NAME, QListView::Maximum);
- updateList->addColumn(i18n("Type"));
- updateList->addColumn(i18n("New Version"));
- updateList->addColumn(i18n("Catalog"));
+ patchList->addColumn(i18n("Name"));
+ patchList->setColumnWidthMode(COLUMN_NAME, QListView::Maximum);
+ patchList->addColumn(i18n("Type"));
+ patchList->addColumn(i18n("New Version"));
+ patchList->addColumn(i18n("Catalog"));
+
+ packageList->addColumn(i18n("Name"));
+ packageList->setColumnWidthMode(COLUMN_NAME, QListView::Maximum);
+ packageList->addColumn(i18n("Type"));
+ packageList->addColumn(i18n("New Version"));
+ packageList->addColumn(i18n("Catalog"));
+
/*
Hidden Columns, we use these to store data about the packages/patches
*/
- updateList->addColumn("ID", 0); // This is a hidden column to hold the ID of the patch/package
+ patchList->addColumn("ID", 0); // This is a hidden column to hold the ID of the patch/package
- connect(updateList, SIGNAL(selectionChanged(QListViewItem*)),
+ connect(patchList, SIGNAL(selectionChanged(QListViewItem*)),
this, SLOT(slotPackageSelected(QListViewItem*)));
- connect(updateList, SIGNAL(clicked(QListViewItem*)),
+ connect(patchList, SIGNAL(clicked(QListViewItem*)),
this, SLOT(slotPackageClicked(QListViewItem*)));
- connect(updateList, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)),
+ connect(patchList, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)),
this, SLOT(slotPackageRightClicked(QListViewItem*, const QPoint&, int)));
- connect(updateList, SIGNAL(selectionChanged()),
+ connect(patchList, SIGNAL(selectionChanged()),
this, SLOT(slotPackageSelectionChanged()));
+ patchBox->setSpacing(10);
+ patchBox->setMargin(10);
+
+ packageBox->setSpacing(10);
+ packageBox->setMargin(10);
mainBox->setSpacing(10);
mainBox->setMargin(10);
@@ -186,7 +220,7 @@
{
// when are updates are selected for installation, enable "Install" button
if ( (_caps.canSelectIndividualUpdates==true && updatesSelected > 0) ||
- (_caps.canSelectIndividualUpdates==false && updateList->childCount() > 0 ) )
+ (_caps.canSelectIndividualUpdates==false && patchList->childCount() > 0 ) )
{
installButton->setDisabled(false);
}
@@ -204,13 +238,13 @@
{
selectAllButton->hide();
clearSelectionButton->hide();
- updateList->setSelectionMode ( QListView::NoSelection );
+ patchList->setSelectionMode ( QListView::NoSelection );
}
else
{
selectAllButton->show();
clearSelectionButton->show();
- updateList->setSelectionMode ( QListView::Multi );
+ patchList->setSelectionMode ( QListView::Multi );
}
updateButtons();
@@ -237,7 +271,7 @@
void MainWindow::slotAppletState(int state, int n)
{
- applet->setUpdates(updateList->childCount());
+ applet->setUpdates(patchList->childCount());
applet->setState(state);
applet->setUpdates(n);
@@ -263,9 +297,9 @@
}
void MainWindow::gotDescription(QString description) {
- packageDescription->setText("");
- packageDescription->setTextFormat(Qt::RichText);
- packageDescription->setText(description);
+ patchDescription->setText("");
+ patchDescription->setTextFormat(Qt::RichText);
+ patchDescription->setText(description);
}
/***************************************************************
@@ -330,7 +364,7 @@
void MainWindow::selectButtonClicked() {
- QCheckListItem *item = (QCheckListItem*)updateList->firstChild();
+ QCheckListItem *item = (QCheckListItem*)patchList->firstChild();
while (item != NULL) {
if (!item->isOn()) {
@@ -338,13 +372,13 @@
}
item = (QCheckListItem*)item->nextSibling();
}
- updatesSelected = updateList->childCount();
+ updatesSelected = patchList->childCount();
updateButtons();
}
void MainWindow::clearButtonClicked() {
- QCheckListItem *item = (QCheckListItem*)updateList->firstChild();
+ QCheckListItem *item = (QCheckListItem*)patchList->firstChild();
while (item != NULL) {
if (item->isOn()) {
@@ -382,12 +416,12 @@
//Clear the list and fire the update signal to the backend
- updateList->clear();
- packageDescription->setText("");
+ patchList->clear();
+ patchDescription->setText("");
updatesSelected = 0;
updateButtons();
- emit(populateUpdateList(updateList));
+ emit(populateUpdateList(patchList));
}
//Selection/Fetch Description slots
@@ -406,7 +440,7 @@
updatesSelected = 0;
- QCheckListItem *item = (QCheckListItem*)updateList->firstChild();
+ QCheckListItem *item = (QCheckListItem*)patchList->firstChild();
while (item != NULL) {
if (item->isOn()) {
Modified: trunk/updater-kde/updater/MainWindow.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/MainWindow.h…
==============================================================================
--- trunk/updater-kde/updater/MainWindow.h (original)
+++ trunk/updater-kde/updater/MainWindow.h Fri Jun 1 16:40:26 2007
@@ -90,9 +90,9 @@
/**
Signal we send to our current backend requesting updates for the list.
- @param updateList our QListView we want the backend to pack.
+ @param patchList our QListView we want the backend to pack.
*/
- void populateUpdateList(QListView* updateList);
+ void populateUpdateList(QListView* patchList);
/**
Signal we send to our current backend requesting the start of
@@ -246,7 +246,9 @@
void updateButtons();
TrayIcon *applet;
- QListView *updateList;
+ QListView *patchList;
+ QListView *packageList;
+ KTextEdit *patchDescription;
KTextEdit *packageDescription;
HeaderWidget *header;
@@ -271,6 +273,9 @@
QWidget *centralWidget;
+ QTabWidget *tabwidget;
+
+
KConfigDialog *configDialog;
int getNetworkStatus() const;
Modified: trunk/updater-kde/updater/zypp/ZYppUpdater.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp/ZYppUpd…
==============================================================================
--- trunk/updater-kde/updater/zypp/ZYppUpdater.cpp (original)
+++ trunk/updater-kde/updater/zypp/ZYppUpdater.cpp Fri Jun 1 16:40:26 2007
@@ -314,7 +314,9 @@
void ZYppUpdater::configureUpdater()
{
- KProcess *inst_source = new KProcess;
+ kdDebug() << "configure updater" << endl;
+
+ KProcess *inst_source = new KProcess;
*inst_source << "opensuseupdater-su" << "-c" << "/sbin/yast2 inst_source";
connect( inst_source, SIGNAL( processExited( KProcess * ) ),
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] r5657 - in /trunk/libzypp/zypp2: RepoManager.cc RepoManager.h repo/RepoException.h repo/RepositoryImpl.cc repo/RepositoryImpl.h repo/cached/RepoImpl.cc repo/cached/RepoImpl.h
by dmacvicar@svn.opensuse.org 01 Jun '07
by dmacvicar@svn.opensuse.org 01 Jun '07
01 Jun '07
Author: dmacvicar
Date: Fri Jun 1 16:12:55 2007
New Revision: 5657
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5657&view=rev
Log:
backup
Modified:
trunk/libzypp/zypp2/RepoManager.cc
trunk/libzypp/zypp2/RepoManager.h
trunk/libzypp/zypp2/repo/RepoException.h
trunk/libzypp/zypp2/repo/RepositoryImpl.cc
trunk/libzypp/zypp2/repo/RepositoryImpl.h
trunk/libzypp/zypp2/repo/cached/RepoImpl.cc
trunk/libzypp/zypp2/repo/cached/RepoImpl.h
Modified: trunk/libzypp/zypp2/RepoManager.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/RepoManager.cc?rev…
==============================================================================
--- trunk/libzypp/zypp2/RepoManager.cc (original)
+++ trunk/libzypp/zypp2/RepoManager.cc Fri Jun 1 16:12:55 2007
@@ -13,16 +13,17 @@
#include <iostream>
#include <list>
#include <algorithm>
-#include "zypp/base/Exception.h"
#include "zypp/base/InputStream.h"
#include "zypp/base/Logger.h"
#include "zypp/PathInfo.h"
#include "zypp/parser/IniDict.h"
+#include "zypp2/repo/RepoException.h"
#include "zypp2/RepoManager.h"
using namespace std;
using namespace zypp;
+using namespace zypp::repo;
using namespace zypp::filesystem;
using parser::IniDict;
@@ -170,6 +171,45 @@
RepoManager::~RepoManager()
{}
+ static void assert_alias( const RepoInfo &info )
+ {
+ if (info.alias().empty())
+ ZYPP_THROW(RepoNoAliasException());
+ }
+
+ static Pathname rawcache_path_for_alias( const RepoManagerOptions &opt, const string &alias )
+ {
+ //repoRawCachePath
+ return Pathname();
+ }
+
+ void RepoManager::refreshMetadata( const RepoInfo &info )
+ {
+ assert_alias(info);
+
+
+ }
+
+ void RepoManager::cleanMetadata( const RepoInfo &info )
+ {
+
+ }
+
+ void RepoManager::buildCache( const RepoInfo &info )
+ {
+
+ }
+
+ void RepoManager::cleanCache( const RepoInfo &info )
+ {
+
+ }
+
+ Repository RepoManager::createFromCache( const RepoInfo &info )
+ {
+ return Repository::noRepository;
+ }
+
/******************************************************************
**
** FUNCTION NAME : operator<<
Modified: trunk/libzypp/zypp2/RepoManager.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/RepoManager.h?rev=…
==============================================================================
--- trunk/libzypp/zypp2/RepoManager.h (original)
+++ trunk/libzypp/zypp2/RepoManager.h Fri Jun 1 16:12:55 2007
@@ -20,7 +20,7 @@
//#include "zypp/base/NonCopyable.h"
#include "zypp/Pathname.h"
#include "zypp/ZConfig.h"
-
+#include "zypp2/Repository.h"
#include "zypp2/RepoInfo.h"
#include "zypp2/repo/RepoException.h"
@@ -55,7 +55,9 @@
public:
RepoManager( const RepoManagerOptions &options = RepoManagerOptions() );
-
+ /** Dtor */
+ ~RepoManager();
+
/**
* \short List known repositories.
*
@@ -66,8 +68,60 @@
*/
std::list<RepoInfo> knownRepositories();
- /** Dtor */
- ~RepoManager();
+ /**
+ * \short Refresh local cache
+ *
+ * Will try to download the metadata
+ *
+ * \throws RepoNoUrl if no urls are available.
+ * \throws RepoNoAlias if can't figure an alias
+ * \throws Exception on unknown error.
+ */
+ void refreshMetadata( const RepoInfo &info );
+
+ /**
+ * \short Clean local metadata
+ *
+ * Empty local metadata.
+ *
+ * \throws RepoNoAlias if can't figure an alias
+ * \throws Exception on unknown error.
+ */
+ void cleanMetadata( const RepoInfo &info );
+
+ /**
+ * \short Refresh local cache
+ *
+ * Will try to build the cache from
+ * local metadata.
+ *
+ * If the cache exists it will be overwriten.
+ *
+ * \note the local metadata must be valid.
+ *
+ * \throws RepoNoAlias if can't figure an alias to look in cache
+ * \throws Exception on unknown error.
+ */
+ void buildCache( const RepoInfo &info );
+
+ /**
+ * \short clean local cache
+ *
+ * Clean the cached version of the metadata
+ *
+ * \note the local metadata must be valid.
+ *
+ * \throws RepoNoAlias if can't figure an alias to look in cache
+ * \throws Exception on unknown error.
+ */
+ void cleanCache( const RepoInfo &info );
+
+ /**
+ * \short Create a repository object from the cache data
+ *
+ * \throw RepoNotCachedException When the source is not cached.
+ */
+ Repository createFromCache( const RepoInfo &info );
public:
Modified: trunk/libzypp/zypp2/repo/RepoException.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/repo/RepoException…
==============================================================================
--- trunk/libzypp/zypp2/repo/RepoException.h (original)
+++ trunk/libzypp/zypp2/repo/RepoException.h Fri Jun 1 16:12:55 2007
@@ -56,7 +56,7 @@
* thrown when it was impossible to
* determine one url for this repo.
*/
- class RepoNoUrl : public RepoException
+ class RepoNoUrlException : public RepoException
{
};
@@ -65,7 +65,7 @@
* thrown when it was impossible to
* determine an alias for this repo.
*/
- class RepoNoAlias : public RepoException
+ class RepoNoAliasException : public RepoException
{
};
Modified: trunk/libzypp/zypp2/repo/RepositoryImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/repo/RepositoryImp…
==============================================================================
--- trunk/libzypp/zypp2/repo/RepositoryImpl.cc (original)
+++ trunk/libzypp/zypp2/repo/RepositoryImpl.cc Fri Jun 1 16:12:55 2007
@@ -5,11 +5,17 @@
IMPL_PTR_TYPE(RepositoryImpl)
-RepositoryImpl::RepositoryImpl()
+RepositoryImpl::RepositoryImpl( const RepoInfo &info )
+ : _info(info)
{
}
+const RepoInfo RepositoryImpl::info() const
+{
+ return _info;
+}
+
RepositoryImpl::~RepositoryImpl()
{
@@ -19,5 +25,11 @@
: base::ProvideNumericId<RepositoryImpl,Repository::NumericId>( NULL )
{}
+
+const ResStore & RepositoryImpl::resolvables() const
+{
+ return _store;
+}
+
} } // ns
Modified: trunk/libzypp/zypp2/repo/RepositoryImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/repo/RepositoryImp…
==============================================================================
--- trunk/libzypp/zypp2/repo/RepositoryImpl.h (original)
+++ trunk/libzypp/zypp2/repo/RepositoryImpl.h Fri Jun 1 16:12:55 2007
@@ -10,7 +10,10 @@
#include "zypp/base/NonCopyable.h"
#include "zypp/base/PtrTypes.h"
#include "zypp/base/ProvideNumericId.h"
+#include "zypp/ResStore.h"
#include "zypp2/Repository.h"
+#include "zypp2/RepoInfo.h"
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
@@ -21,15 +24,33 @@
DEFINE_PTR_TYPE(RepositoryImpl);
class RepositoryImpl : public base::ReferenceCounted,
- public base::ProvideNumericId<RepositoryImpl,Repository::NumericId>,
- private base::NonCopyable
+ public base::ProvideNumericId<RepositoryImpl,Repository::NumericId>,
+ private base::NonCopyable
{
friend std::ostream & operator<<( std::ostream & str, const RepositoryImpl & obj );
public:
- RepositoryImpl();
+ /**
+ * \short Ctor.
+ * \param info What is known about this source at construction time.
+ *
+ */
+ RepositoryImpl( const RepoInfo &info = RepoInfo() );
+
+ /**
+ * \short Information about this repository
+ * You can't change this information after creation.
+ * Use \ref RepoManager for that.
+ */
+ const RepoInfo info() const;
+
+ /**
+ * \short Dtor
+ */
~RepositoryImpl();
+ const ResStore & resolvables() const;
+
struct null {};
public:
/** Offer default Impl. */
@@ -43,8 +64,11 @@
Repository selfRepository()
{ return Repository( this ); }
+ protected:
+ RepoInfo _info;
+
+ ResStore _store;
};
-
}
}
Modified: trunk/libzypp/zypp2/repo/cached/RepoImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/repo/cached/RepoIm…
==============================================================================
--- trunk/libzypp/zypp2/repo/cached/RepoImpl.cc (original)
+++ trunk/libzypp/zypp2/repo/cached/RepoImpl.cc Fri Jun 1 16:12:55 2007
@@ -178,12 +178,6 @@
}
-
-
-
-
-
-
/////////////////////////////////////////////////////////////////
} // namespace plaindir
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp2/repo/cached/RepoImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/repo/cached/RepoIm…
==============================================================================
--- trunk/libzypp/zypp2/repo/cached/RepoImpl.h (original)
+++ trunk/libzypp/zypp2/repo/cached/RepoImpl.h Fri Jun 1 16:12:55 2007
@@ -48,45 +48,15 @@
RepoImpl( const zypp::Pathname &dbdir, const data::RecordId &repository_id );
/** Dtor */
~RepoImpl();
-
+ void factoryInit();
public:
cache::ResolvableQuery resolvableQuery();
+ void createResolvables();
- /** String identifying the type of the source. */
- static std::string typeString()
- { return "CachedSource"; }
-
- /** String identifying the type of the source. */
- virtual std::string type() const
- { return typeString(); }
-
- const ResStore & resolvables() const
- { return _store; }
-
- virtual void createResolvables();
- public:
-
-
-
- private:
- /** Ctor substitute.
- * Actually get the metadata.
- * \throw EXCEPTION on fail
- */
- virtual void factoryInit();
-
-
- zypp::Pathname _dbdir;
- ResStore _store;
-
- Rel relationFor( const data::RecordId &id );
- Resolvable::Kind kindFor( const data::RecordId &id );
- Dep deptypeFor( const data::RecordId &id );
- Arch archFor( const data::RecordId &id );
-
+ protected:
void read_capabilities( sqlite3x::sqlite3_connection &con, std::map<data::RecordId, NVRAD> &nvras );
-
+ Pathname _dbdir;
cache::CacheTypes _type_cache;
data::RecordId _repository_id;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] r5656 - in /trunk/libzypp: devel/devel.dmacvicar/ devel/devel.jkupec/ tests/cache/ tests/zypp/ tests/zypp/data/RepoManager/ tests/zypp/data/RepoManager/repos.d/ zypp/ zypp2/ zypp2/cache/ zypp2/cach...
by dmacvicar@svn.opensuse.org 01 Jun '07
by dmacvicar@svn.opensuse.org 01 Jun '07
01 Jun '07
Author: dmacvicar
Date: Fri Jun 1 14:48:35 2007
New Revision: 5656
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5656&view=rev
Log:
- RepoManager updates, like configurable paths
- Some API added to CacheStore to ask about repos
cached
- specific Cache and Repo exceptions
- test case for RepoManager.
- Change CacheStore repo api to use alias instead
of url and path
- compile all code with those changes
Added:
trunk/libzypp/tests/zypp/RepoManager_test.cc
trunk/libzypp/tests/zypp/data/RepoManager/
trunk/libzypp/tests/zypp/data/RepoManager/repos.d/
trunk/libzypp/tests/zypp/data/RepoManager/repos.d/filesharing.repo
trunk/libzypp/tests/zypp/data/RepoManager/repos.d/home:dmacvicar.repo
trunk/libzypp/tests/zypp/data/RepoManager/repos.d/ruby.repo
trunk/libzypp/zypp2/cache/CacheException.cc
trunk/libzypp/zypp2/cache/CacheException.h
trunk/libzypp/zypp2/repo/RepoException.cc
trunk/libzypp/zypp2/repo/RepoException.h
Modified:
trunk/libzypp/devel/devel.dmacvicar/YUMReader_tp.cc
trunk/libzypp/devel/devel.dmacvicar/testbed.cc
trunk/libzypp/devel/devel.jkupec/YUMParser_test.cc
trunk/libzypp/tests/cache/CMakeLists.txt
trunk/libzypp/tests/cache/CacheQuery_test.cc
trunk/libzypp/tests/cache/CacheStore_test.cc
trunk/libzypp/tests/zypp/CMakeLists.txt
trunk/libzypp/zypp/ZConfig.cc
trunk/libzypp/zypp/ZConfig.h
trunk/libzypp/zypp2/CMakeLists.txt
trunk/libzypp/zypp2/RepoManager.cc
trunk/libzypp/zypp2/RepoManager.h
trunk/libzypp/zypp2/RepoStatus.cc
trunk/libzypp/zypp2/RepoStatus.h
trunk/libzypp/zypp2/cache/CacheStore.cpp
trunk/libzypp/zypp2/cache/CacheStore.h
trunk/libzypp/zypp2/cache/schema/schema.sql
Modified: trunk/libzypp/devel/devel.dmacvicar/YUMReader_tp.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/YU…
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/YUMReader_tp.cc (original)
+++ trunk/libzypp/devel/devel.dmacvicar/YUMReader_tp.cc Fri Jun 1 14:48:35 2007
@@ -7,7 +7,7 @@
#include "zypp/base/Measure.h"
#include "zypp/detail/ResObjectFactory.h"
#include "zypp2/parser/yum/YUMParser.h"
-#include "zypp2/repository/memory/DPackageImpl.h"
+#include "zypp2/repo/memory/PackageImpl.h"
#undef ZYPP_BASE_LOGGER_LOGGROUP
@@ -17,7 +17,7 @@
using namespace zypp;
using namespace zypp::parser::yum;
using zypp::debug::Measure;
-using namespace zypp::repository::memory;
+using namespace zypp::repo::memory;
bool progress_function(ProgressData::value_type p)
{
@@ -30,8 +30,8 @@
{
public:
- typedef detail::ResImplTraits<DPackageImpl>::Ptr PkgImplPtr;
- typedef detail::ResImplTraits<DPackageImpl>::Ptr SrcPkgImplPtr;
+ typedef detail::ResImplTraits<PackageImpl>::Ptr PkgImplPtr;
+ typedef detail::ResImplTraits<PackageImpl>::Ptr SrcPkgImplPtr;
ResolvableConsumer()
{
@@ -59,7 +59,7 @@
virtual void consumePackage( const data::RecordId &repository_id, data::Package_Ptr ptr )
{
- PkgImplPtr impl = PkgImplPtr( new DPackageImpl(ptr) );
+ PkgImplPtr impl = PkgImplPtr( new PackageImpl(ptr) );
Dependencies deps;
collectDeps( deps, ptr->deps );
@@ -90,6 +90,16 @@
virtual void consumeFilelist( const data::RecordId & repository_id, const data::Resolvable_Ptr &, const data::Filenames & )
{}
+
+ virtual void consumeSourcePackage(const zypp::data::RecordId&, zypp::data::SrcPackage_Ptr)
+ {}
+
+ virtual void consumePackageAtom(const zypp::data::RecordId&, const zypp::data::PackageAtom_Ptr&)
+ {}
+
+ virtual void consumePattern(const zypp::data::RecordId&, zypp::data::Pattern_Ptr)
+ {}
+
//virtual void consumeSourcePackage( const data::SrcPackage_Ptr ) = 0;
ResStore _store;
};
@@ -113,7 +123,7 @@
Measure parse_primary_timer("primary.xml.gz parsing");
ResolvableConsumer store;
parser::yum::YUMParser parser( 0, store, &progress_function);
- parser.start(argv[1]);
+ parser.parse(argv[1]);
parse_primary_timer.stop();
cout << endl;
Modified: trunk/libzypp/devel/devel.dmacvicar/testbed.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/te…
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/testbed.cc (original)
+++ trunk/libzypp/devel/devel.dmacvicar/testbed.cc Fri Jun 1 14:48:35 2007
@@ -11,13 +11,13 @@
#include "zypp/detail/PackageImplIf.h"
#include "zypp/Package.h"
#include "zypp2/RepositoryFactory.h"
-#include "zypp2/repository/cached/CachedRepositoryImpl.h"
+#include "zypp2/repo/cached/RepoImpl.h"
#include "zypp/data/ResolvableData.h"
using namespace std;
using namespace zypp;
-using namespace zypp::repository;
-using namespace zypp::repository::cached;
+using namespace zypp::repo;
+using namespace zypp::repo::cached;
int main(int argc, char **argv)
Modified: trunk/libzypp/devel/devel.jkupec/YUMParser_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.jkupec/YUMPa…
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/YUMParser_test.cc (original)
+++ trunk/libzypp/devel/devel.jkupec/YUMParser_test.cc Fri Jun 1 14:48:35 2007
@@ -38,7 +38,7 @@
Measure open_repository_timer("CacheStore: lookupOrAppendRepository");
cache::CacheStore store(getenv("PWD"));
- data::RecordId repository_id = store.lookupOrAppendRepository( Url("http://some.url"), "/");
+ data::RecordId repository_id = store.lookupOrAppendRepository("somealias");
open_repository_timer.stop();
Modified: trunk/libzypp/tests/cache/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/cache/CMakeLists.t…
==============================================================================
--- trunk/libzypp/tests/cache/CMakeLists.txt (original)
+++ trunk/libzypp/tests/cache/CMakeLists.txt Fri Jun 1 14:48:35 2007
@@ -17,7 +17,7 @@
ADD_TEST(CacheStore ${CMAKE_CURRENT_BINARY_DIR}/CacheStore ${CMAKE_CURRENT_SOURCE_DIR}/data )
# run this test against a YUM repo
-ADD_TEST(CacheQuery ${CMAKE_CURRENT_BINARY_DIR}/CacheQuery ${CMAKE_SOURCE_DIR}/tests/repository/yum/data/10.2-updates-subset )
+ADD_TEST(CacheQuery ${CMAKE_CURRENT_BINARY_DIR}/CacheQuery ${CMAKE_SOURCE_DIR}/tests/repo/yum/data/10.2-updates-subset )
Modified: trunk/libzypp/tests/cache/CacheQuery_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/cache/CacheQuery_t…
==============================================================================
--- trunk/libzypp/tests/cache/CacheQuery_test.cc (original)
+++ trunk/libzypp/tests/cache/CacheQuery_test.cc Fri Jun 1 14:48:35 2007
@@ -40,7 +40,7 @@
{
cache::CacheStore store(tmpdir.path());
- data::RecordId repository_id = store.lookupOrAppendRepository( Url("http://novell.com"), "/");
+ data::RecordId repository_id = store.lookupOrAppendRepository("novell");
YUMParser parser( repository_id, store );
parser.parse(dir);
Modified: trunk/libzypp/tests/cache/CacheStore_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/cache/CacheStore_t…
==============================================================================
--- trunk/libzypp/tests/cache/CacheStore_test.cc (original)
+++ trunk/libzypp/tests/cache/CacheStore_test.cc Fri Jun 1 14:48:35 2007
@@ -40,7 +40,7 @@
cache::CacheStore store(tmpdir.path());
- repository_id = store.lookupOrAppendRepository( Url("http://novell.com"), "/");
+ repository_id = store.lookupOrAppendRepository("novell.com");
zypp::debug::Measure cap_parse_timer("store resolvables");
for ( list<MiniResolvable>::iterator it = res_list.begin(); it != res_list.end(); it++)
@@ -50,6 +50,7 @@
(*it).nvra,
(*it).deps );
}
+ store.commit();
}
{
MIL << "now read resolvables" << endl;
Modified: trunk/libzypp/tests/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/CMakeLists.tx…
==============================================================================
--- trunk/libzypp/tests/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/tests/zypp/CMakeLists.txt Fri Jun 1 14:48:35 2007
@@ -46,6 +46,9 @@
ADD_EXECUTABLE( FileChecker FileChecker_test.cc )
TARGET_LINK_LIBRARIES( FileChecker zypp boost_unit_test_framework )
+ADD_EXECUTABLE( RepoManager RepoManager_test.cc )
+TARGET_LINK_LIBRARIES( RepoManager zypp zypp2 boost_unit_test_framework )
+
ADD_TEST(ArchTest ${CMAKE_CURRENT_BINARY_DIR}/Arch)
ADD_TEST(UrlTest ${CMAKE_CURRENT_BINARY_DIR}/Url)
ADD_TEST(Edition ${CMAKE_CURRENT_BINARY_DIR}/Edition)
@@ -60,4 +63,5 @@
ADD_TEST(KeyRingTest ${CMAKE_CURRENT_BINARY_DIR}/KeyRing)
ADD_TEST(MediaSetAccessTest ${CMAKE_CURRENT_BINARY_DIR}/MediaSetAccess ${CMAKE_CURRENT_SOURCE_DIR}/data/mediasetaccess)
ADD_TEST(FileCheckerTest ${CMAKE_CURRENT_BINARY_DIR}/FileChecker ${CMAKE_CURRENT_SOURCE_DIR}/data/FileChecker)
+ADD_TEST(RepoManagerTest ${CMAKE_CURRENT_BINARY_DIR}/RepoManager ${CMAKE_CURRENT_SOURCE_DIR}/data/RepoManager)
ADD_TEST(FetcherTest ${CMAKE_CURRENT_BINARY_DIR}/Fetcher)
Added: trunk/libzypp/tests/zypp/RepoManager_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/RepoManager_t…
==============================================================================
--- trunk/libzypp/tests/zypp/RepoManager_test.cc (added)
+++ trunk/libzypp/tests/zypp/RepoManager_test.cc Fri Jun 1 14:48:35 2007
@@ -0,0 +1,71 @@
+
+#include <iostream>
+#include <fstream>
+#include <list>
+#include <string>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/KeyRing.h"
+#include "zypp/PublicKey.h"
+#include "zypp/TmpPath.h"
+
+#include "zypp2/RepoManager.h"
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/parameterized_test.hpp>
+#include <boost/test/unit_test_log.hpp>
+
+#include "KeyRingTestReceiver.h"
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using namespace boost::unit_test::log;
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::filesystem;
+
+void repomanager_test( const string &dir )
+{
+ RepoManagerOptions opts;
+
+ TmpDir tmpCachePath;
+ TmpDir tmpRawCachePath;
+
+ opts.repoCachePath = tmpCachePath.path();
+ opts.repoRawCachePath = tmpRawCachePath.path();
+ opts.knownReposPath = Pathname(dir) + "/repos.d";
+
+ RepoManager manager(opts);
+
+ list<RepoInfo> repos = manager.knownRepositories();
+
+ BOOST_CHECK_EQUAL(repos.size(), (unsigned) 3);
+}
+
+test_suite*
+init_unit_test_suite( int argc, char* argv[] )
+{
+ string datadir;
+ if (argc < 2)
+ {
+ datadir = TESTS_SRC_DIR;
+ datadir = (Pathname(datadir) + "/zypp/data/RepoManager").asString();
+ cout << "repomanager_test:"
+ " path to directory with test data required as parameter. Using " << datadir << endl;
+ //return (test_suite *)0;
+ }
+ else
+ {
+ datadir = argv[1];
+ }
+
+ std::string const params[] = { datadir };
+ //set_log_stream( std::cout );
+ test_suite* test= BOOST_TEST_SUITE( "RepoManagerTest" );
+ test->add(BOOST_PARAM_TEST_CASE( &repomanager_test,
+ (std::string const*)params, params+1));
+ return test;
+}
+
Added: trunk/libzypp/tests/zypp/data/RepoManager/repos.d/filesharing.repo
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/RepoMana…
==============================================================================
--- trunk/libzypp/tests/zypp/data/RepoManager/repos.d/filesharing.repo (added)
+++ trunk/libzypp/tests/zypp/data/RepoManager/repos.d/filesharing.repo Fri Jun 1 14:48:35 2007
@@ -0,0 +1,7 @@
+[filesharing]
+name=Filesharing applications (SUSE_Factory)
+type=rpm-md
+baseurl=http://software.opensuse.org/download/filesharing/SUSE_Factory/
+gpgcheck=1
+gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
+enabled=1
Added: trunk/libzypp/tests/zypp/data/RepoManager/repos.d/home:dmacvicar.repo
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/RepoMana…
==============================================================================
--- trunk/libzypp/tests/zypp/data/RepoManager/repos.d/home:dmacvicar.repo (added)
+++ trunk/libzypp/tests/zypp/data/RepoManager/repos.d/home:dmacvicar.repo Fri Jun 1 14:48:35 2007
@@ -0,0 +1,7 @@
+[home:dmacvicar]
+name=Duncan Mac-Vicar SUSE rpms (openSUSE_Factory)
+type=rpm-md
+baseurl=http://software.opensuse.org/download/home:/dmacvicar/openSUSE_Factory/
+gpgcheck=1
+gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
+enabled=1
Added: trunk/libzypp/tests/zypp/data/RepoManager/repos.d/ruby.repo
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/RepoMana…
==============================================================================
--- trunk/libzypp/tests/zypp/data/RepoManager/repos.d/ruby.repo (added)
+++ trunk/libzypp/tests/zypp/data/RepoManager/repos.d/ruby.repo Fri Jun 1 14:48:35 2007
@@ -0,0 +1,7 @@
+[ruby]
+name=Ruby is an Interpreted Object-Oriented Scripting Language (openSUSE_Factory)
+type=rpm-md
+baseurl=http://software.opensuse.org/download/ruby/openSUSE_Factory/
+gpgcheck=1
+gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
+enabled=1
Modified: trunk/libzypp/zypp/ZConfig.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.cc?rev=5656…
==============================================================================
--- trunk/libzypp/zypp/ZConfig.cc (original)
+++ trunk/libzypp/zypp/ZConfig.cc Fri Jun 1 14:48:35 2007
@@ -41,6 +41,21 @@
return getZYpp()->getTextLocale();
}
+ Pathname ZConfig::defaultRepoRawCachePath() const
+ {
+ return Pathname("/var/lib/zypp/cache/raw");
+ }
+
+ Pathname ZConfig::defaultRepoCachePath() const
+ {
+ return Pathname("/var/lib/zypp/cache");
+ }
+
+ Pathname ZConfig::defaultKnownReposPath() const
+ {
+ return Pathname("/etc/zypp/repos.d");
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/ZConfig.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.h?rev=5656&…
==============================================================================
--- trunk/libzypp/zypp/ZConfig.h (original)
+++ trunk/libzypp/zypp/ZConfig.h Fri Jun 1 14:48:35 2007
@@ -40,6 +40,23 @@
* descriptions, etc. passed to the UI.
*/
Locale defaultTextLocale() const;
+
+ /**
+ * Path where the repo metadata is downloaded and kept.
+ */
+ Pathname defaultRepoRawCachePath() const;
+
+ /**
+ * Path where the processed cache is kept
+ * (this is where zypp.db is located.
+ */
+ Pathname defaultRepoCachePath() const;
+
+ /**
+ * Path where the known repositories
+ * .repo files are kept
+ */
+ Pathname defaultKnownReposPath() const;
};
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp2/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/CMakeLists.txt?rev…
==============================================================================
--- trunk/libzypp/zypp2/CMakeLists.txt (original)
+++ trunk/libzypp/zypp2/CMakeLists.txt Fri Jun 1 14:48:35 2007
@@ -34,6 +34,7 @@
SET( zypp2_cache_SRCS
${CMAKE_BINARY_DIR}/zypp2/schema.h
cache/CacheInitializer.cpp
+ cache/CacheException.cc
cache/CacheTypes.cc
cache/ResolvableQuery.cc
cache/CacheStore.cpp
@@ -45,6 +46,7 @@
cache/CacheCommon.h
cache/CacheTypes.h
cache/CacheInitializer.h
+ cache/CacheException.h
cache/CacheStore.h
cache/CacheFSCK.h
cache/ResolvableQuery.h
@@ -76,11 +78,13 @@
SET( zypp2_repository_SRCS
repo/dummy.cc
repo/RepositoryImpl.cc
+ repo/RepoException.cc
)
SET( zypp2_repository_HEADERS
repo/dummy.h
repo/RepositoryImpl.h
+ repo/RepoException.h
)
SET( zypp2_repository_cached_SRCS
Modified: trunk/libzypp/zypp2/RepoManager.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/RepoManager.cc?rev…
==============================================================================
--- trunk/libzypp/zypp2/RepoManager.cc (original)
+++ trunk/libzypp/zypp2/RepoManager.cc Fri Jun 1 14:48:35 2007
@@ -1,4 +1,14 @@
-
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/RepoManager.cc
+ *
+*/
#include <iostream>
#include <list>
@@ -11,75 +21,165 @@
#include "zypp2/RepoManager.h"
-
using namespace std;
using namespace zypp;
using namespace zypp::filesystem;
using parser::IniDict;
-namespace zypp {
-
-RepoManager::RepoManager()
-{
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
-}
-
-static std::list<RepoInfo> repositories_in_file( const Pathname &file )
-{
- InputStream is(file);
- IniDict dict(is);
- std::list<RepoInfo> repos;
-
- for ( IniDict::section_const_iterator its = dict.sectionsBegin();
- its != dict.sectionsEnd();
- ++its )
- {
- MIL << (*its) << endl;
-
- RepoInfo info;
- info.setAlias(*its);
-
- for ( IniDict::entry_const_iterator it = dict.entriesBegin(*its);
- it != dict.entriesEnd(*its);
- ++it )
+ RepoManagerOptions::RepoManagerOptions()
+ {
+ ZConfig globalConfig;
+ repoCachePath = globalConfig.defaultRepoCachePath();
+ repoRawCachePath = globalConfig.defaultRepoRawCachePath();
+ knownReposPath = globalConfig.defaultKnownReposPath();
+ }
+
+ /**
+ * \short List of RepoInfo's from a file.
+ * \param file pathname of the file to read.
+ */
+ static std::list<RepoInfo> repositories_in_file( const Pathname &file )
+ {
+ InputStream is(file);
+ IniDict dict(is);
+ std::list<RepoInfo> repos;
+
+ for ( IniDict::section_const_iterator its = dict.sectionsBegin();
+ its != dict.sectionsEnd();
+ ++its )
{
+ MIL << (*its) << endl;
+
+ RepoInfo info;
+ info.setAlias(*its);
+
+ for ( IniDict::entry_const_iterator it = dict.entriesBegin(*its);
+ it != dict.entriesEnd(*its);
+ ++it )
+ {
+
+ //MIL << (*it).first << endl;
+ if (it->first == "name" )
+ info.setName(it-> second);
+ else if ( it->first == "enabled" )
+ info.setEnabled( it->second == "1" );
+ else if ( it->first == "baseurl" )
+ info.addBaseUrl( Url(it->second) );
+ else if ( it->first == "type" )
+ info.setType(it->second);
+ }
- //MIL << (*it).first << endl;
- if (it->first == "name" )
- info.setName(it-> second);
- else if ( it->first == "enabled" )
- info.setEnabled( it->second == "1" );
- else if ( it->first == "baseurl" )
- info.addBaseUrl( Url(it->second) );
+ // add it to the list.
+ repos.push_back(info);
}
- // add it to the list.
- repos.push_back(info);
+ return repos;
}
- return repos;
-}
-
-static std::list<RepoInfo> repositories_in_path( const Pathname &dir )
-{
- std::list<RepoInfo> repos;
- list<Pathname> entries;
- if ( filesystem::readdir( entries, Pathname(dir), false ) != 0 )
- ZYPP_THROW(Exception("failed to read directory"));
+ /**
+ * \short List of RepoInfo's from a directory
+ *
+ * Goes trough every file in a directory and adds all
+ * RepoInfo's contained in that file.
+ *
+ * \param file pathname of the file to read.
+ */
+ static std::list<RepoInfo> repositories_in_path( const Pathname &dir )
+ {
+ std::list<RepoInfo> repos;
+ list<Pathname> entries;
+ if ( filesystem::readdir( entries, Pathname(dir), false ) != 0 )
+ ZYPP_THROW(Exception("failed to read directory"));
+
+ for ( list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
+ {
+ Pathname file = *it;
+ std::list<RepoInfo> repos_here = repositories_in_file(file);
+ std::copy( repos_here.begin(), repos_here.end(), std::back_inserter(repos));
+ }
+ return repos;
+ }
- for ( list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
+ std::list<RepoInfo> RepoManager::knownRepositories()
{
- Pathname file = *it;
- std::list<RepoInfo> repos_here = repositories_in_file(file);
- std::copy( repos_here.begin(), repos_here.end(), std::back_inserter(repos));
+ return repositories_in_path("/etc/zypp/repos.d");
}
- return repos;
-}
-std::list<RepoInfo> RepoManager::knownRepositories()
-{
- return repositories_in_path("/etc/zypp/repos.d");
-}
+ /** RepoManager implementation. */
+ struct RepoManager::Impl
+ {
+ Impl( const RepoManagerOptions &opt )
+ : options(opt)
+ {
+
+ }
+
+ Impl()
+ {
+
+ }
+
+ RepoManagerOptions options;
+
+ public:
+ /** Offer default Impl. */
+ static shared_ptr<Impl> nullimpl()
+ {
+ static shared_ptr<Impl> _nullimpl( new Impl );
+ return _nullimpl;
+ }
+
+ private:
+ friend Impl * rwcowClone<Impl>( const Impl * rhs );
+ /** clone for RWCOW_pointer */
+ Impl * clone() const
+ { return new Impl( *this ); }
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates RepoManager::Impl Stream output */
+ inline std::ostream & operator<<( std::ostream & str, const RepoManager::Impl & obj )
+ {
+ return str << "RepoManager::Impl";
+ }
-} // ns zypp
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : RepoManager
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : RepoManager::RepoManager
+ // METHOD TYPE : Ctor
+ //
+ RepoManager::RepoManager( const RepoManagerOptions &opt )
+ : _pimpl( new Impl(opt) )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : RepoManager::~RepoManager
+ // METHOD TYPE : Dtor
+ //
+ RepoManager::~RepoManager()
+ {}
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const RepoManager & obj )
+ {
+ return str << *obj._pimpl;
+ }
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp2
+///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp2/RepoManager.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/RepoManager.h?rev=…
==============================================================================
--- trunk/libzypp/zypp2/RepoManager.h (original)
+++ trunk/libzypp/zypp2/RepoManager.h Fri Jun 1 14:48:35 2007
@@ -1,27 +1,86 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/RepoManager.h
+ *
+*/
+#ifndef ZYPP_REPOMANAGER_H
+#define ZYPP_REPOMANAGER_H
-#ifndef ZYPP_NEW_REPOMANAGER_H
-#define ZYPP_NEW_REPOMANAGER_H
-
+#include <iosfwd>
#include <list>
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
+
+#include "zypp/base/PtrTypes.h"
+//#include "zypp/base/ReferenceCounted.h"
+//#include "zypp/base/NonCopyable.h"
#include "zypp/Pathname.h"
+#include "zypp/ZConfig.h"
#include "zypp2/RepoInfo.h"
+#include "zypp2/repo/RepoException.h"
+///////////////////////////////////////////////////////////////////
namespace zypp
-{
-
- class RepoManager : public base::ReferenceCounted, private base::NonCopyable
+{ /////////////////////////////////////////////////////////////////
+
+ /**
+ * Repo manager settings.
+ * Settings default to ZYpp global settings.
+ */
+ struct RepoManagerOptions
+ {
+ RepoManagerOptions();
+
+ Pathname repoCachePath;
+ Pathname repoRawCachePath;
+ Pathname knownReposPath;
+ };
+
+ /**
+ * \short creates and provides information about known sources.
+ *
+ */
+ class RepoManager
{
friend std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
+
+ public:
+ /** Implementation */
+ class Impl;
+
public:
- RepoManager();
- std::list<RepoInfo> knownRepositories();
+ RepoManager( const RepoManagerOptions &options = RepoManagerOptions() );
+
+ /**
+ * \short List known repositories.
+ *
+ * The known repositories are read from
+ * \ref RepoManagerOptions::knownReposPath passed on the Ctor.
+ * Which defaults to ZYpp global settings.
+ *
+ */
+ std::list<RepoInfo> knownRepositories();
+
+ /** Dtor */
+ ~RepoManager();
+
+ public:
+
+ private:
+ /** Pointer to implementation */
+ RWCOW_pointer<Impl> _pimpl;
};
-
-
-}
+ ///////////////////////////////////////////////////////////////////
-#endif
+ /** \relates RepoManager Stream output */
+ std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp2
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP2_REPOMANAGER_H
Modified: trunk/libzypp/zypp2/RepoStatus.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/RepoStatus.cc?rev=…
==============================================================================
--- trunk/libzypp/zypp2/RepoStatus.cc (original)
+++ trunk/libzypp/zypp2/RepoStatus.cc Fri Jun 1 14:48:35 2007
@@ -14,7 +14,7 @@
#include "zypp2/RepoStatus.h"
-using std::endl;
+using namespace std;
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -30,7 +30,7 @@
public:
- CheckSum checksum;
+ string checksum;
Date timestamp;
/** Offer default Impl. */
@@ -77,7 +77,7 @@
RepoStatus::~RepoStatus()
{}
- RepoStatus & RepoStatus::setChecksum( const CheckSum &checksum )
+ RepoStatus & RepoStatus::setChecksum( const string &checksum )
{
_pimpl->checksum = checksum;
return *this;
@@ -89,7 +89,7 @@
return *this;
}
- CheckSum RepoStatus::checksum() const
+ string RepoStatus::checksum() const
{ return _pimpl->checksum; }
Date RepoStatus::timestamp() const
Modified: trunk/libzypp/zypp2/RepoStatus.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/RepoStatus.h?rev=5…
==============================================================================
--- trunk/libzypp/zypp2/RepoStatus.h (original)
+++ trunk/libzypp/zypp2/RepoStatus.h Fri Jun 1 14:48:35 2007
@@ -46,7 +46,7 @@
* checksum that changes when the repository changes
* in any way is sufficient.
*/
- CheckSum checksum() const;
+ std::string checksum() const;
/**
* timestamp of the repository. If the repository
@@ -59,7 +59,7 @@
* set the repository checksum \see checksum
* \param checksum
*/
- RepoStatus & setChecksum( const CheckSum &checksum );
+ RepoStatus & setChecksum( const std::string &checksum );
/**
* set the repository timestamp \see timestamp
Added: trunk/libzypp/zypp2/cache/CacheException.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheExcepti…
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheException.cc (added)
+++ trunk/libzypp/zypp2/cache/CacheException.cc Fri Jun 1 14:48:35 2007
@@ -0,0 +1,66 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/repo/CacheException.cc
+ *
+*/
+#include <iostream>
+//#include "zypp/base/Logger.h"
+#include "zypp2/cache/CacheException.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace cache
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : CacheException::CacheException
+ // METHOD TYPE : Ctor
+ //
+ CacheException::CacheException()
+ : Exception( "Cache exception" )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : CacheException::CacheException
+ // METHOD TYPE : Ctor
+ //
+ CacheException::CacheException( const std::string & msg_r )
+ : Exception( msg_r )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : CacheException::~CacheException
+ // METHOD TYPE : Dtor
+ //
+ CacheException::~CacheException() throw()
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : CacheException::dumpOn
+ // METHOD TYPE : std::ostream &
+ //
+ std::ostream & CacheException::dumpOn( std::ostream & str ) const
+ {
+ return Exception::dumpOn( str );
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace repo
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
Added: trunk/libzypp/zypp2/cache/CacheException.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheExcepti…
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheException.h (added)
+++ trunk/libzypp/zypp2/cache/CacheException.h Fri Jun 1 14:48:35 2007
@@ -0,0 +1,57 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef ZYPP_REPO_REPOEXCEPTION_H
+#define ZYPP_REPO_REPOEXCEPTION_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/base/Exception.h"
+#include "zypp/base/UserRequestException.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace cache
+ { /////////////////////////////////////////////////////////////////
+
+ /**
+ * \short Exception for cache errors
+ */
+ class CacheException : public Exception
+ {
+ public:
+ /** Default ctor */
+ CacheException();
+ /** Ctor */
+ CacheException( const std::string & msg_r );
+ /** Dtor */
+ virtual ~CacheException() throw();
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /**
+ * The record you supplied can't be found
+ */
+ class CacheRecordNotFoundException : public CacheException
+ {
+
+ };
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace cache
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H
Modified: trunk/libzypp/zypp2/cache/CacheStore.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.c…
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.cpp (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.cpp Fri Jun 1 14:48:35 2007
@@ -10,6 +10,7 @@
#include "zypp2/cache/CacheInitializer.h"
#include "zypp2/cache/CacheStore.h"
+#include "zypp2/cache/CacheException.h"
using namespace std;
using namespace zypp;
@@ -59,8 +60,8 @@
update_repository_cmd.reset( new sqlite3_command( con, "update repositories set checksum=:checksum, timestamp=:timestamp where id=:repository_id;" ));
- 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_repository_cmd.reset( new sqlite3_command( con, "select id from repositories where alias=:alias;" ));
+ insert_repository_cmd.reset( new sqlite3_command( con, "insert into repositories (alias,timestamp) values (:alias, :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);" ));
@@ -561,11 +562,10 @@
_pimpl->insert_repository_cmd->executenonquery();
}
-RecordId CacheStore::lookupOrAppendRepository( const Url &url, const Pathname &path )
+RecordId CacheStore::lookupOrAppendRepository( const string &alias )
{
- _pimpl->select_repository_cmd->bind(":url", url.asString());
- _pimpl->select_repository_cmd->bind(":path", path.asString());
-
+ _pimpl->select_repository_cmd->bind(":alias", alias);
+
long long id = 0;
try {
id = _pimpl->select_repository_cmd->executeint64();
@@ -573,8 +573,7 @@
catch ( const sqlite3x::database_error &e )
{
// does not exist
- _pimpl->insert_repository_cmd->bind(":url", url.asString());
- _pimpl->insert_repository_cmd->bind(":path", path.asString());
+ _pimpl->insert_repository_cmd->bind(":alias", alias);
_pimpl->insert_repository_cmd->bind(":timestamp", static_cast<int>((Date::ValueType) Date::now()) );
_pimpl->insert_repository_cmd->executenonquery();
id = _pimpl->con.insertid();
@@ -584,6 +583,62 @@
return static_cast<RecordId>(id);
}
+RepoStatus CacheStore::repositoryStatus( const data::RecordId &id )
+{
+ sqlite3_command cmd( _pimpl->con, "select id,alias,checksum,timestamp from repositories where id=:id");
+ cmd.bind(":id", id);
+
+ try
+ {
+ sqlite3_reader reader = cmd.executereader();
+ RepoStatus status;
+ while ( reader.read() )
+ {
+ status.setChecksum( reader.getstring(2) );
+ status.setTimestamp( reader.getstring(3) );
+ }
+ return status;
+ }
+ catch ( const sqlite3x::database_error &e )
+ {
+ ZYPP_THROW(CacheRecordNotFoundException());
+ }
+}
+
+RepoStatus CacheStore::repositoryStatus( const string &alias )
+{
+ return repositoryStatus(lookupRepository(alias));
+}
+
+bool CacheStore::isCached( const string &alias )
+{
+ try
+ {
+ lookupRepository(alias);
+ }
+ catch( const CacheRecordNotFoundException &e )
+ {
+ return false;
+ }
+ return true;
+}
+
+RecordId CacheStore::lookupRepository( const string &alias )
+{
+ sqlite3_command cmd(_pimpl->con, "select id from repositories where alias=:alias;");
+ cmd.bind(":alias", alias);
+
+ long long id = 0;
+ try {
+ id = cmd.executeint64();
+ }
+ catch ( const sqlite3x::database_error &e )
+ {
+ ZYPP_THROW(CacheRecordNotFoundException());
+ }
+ return id;
+}
+
RecordId CacheStore::lookupOrAppendType( const string &klass, const string &name )
{
pair<string, string> thetype = make_pair(klass,name);
Modified: trunk/libzypp/zypp2/cache/CacheStore.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.h…
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.h (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.h Fri Jun 1 14:48:35 2007
@@ -25,6 +25,7 @@
#include "zypp/data/RecordId.h"
#include "zypp/base/PtrTypes.h"
+#include "zypp2/RepoStatus.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -39,7 +40,7 @@
* \code
* CacheStore store("/path");
* RecordId repository_id =
- * store.lookupOrAppendRepository("http://updates.novell.com", "/");
+ * store.lookupOrAppendRepository("some-alias");
* store.consumePackage( repository_id, package_ptr );
* store.commit();
* \endcode
@@ -352,15 +353,13 @@
/**
* Returns the record id of a repository (Source)
*
- * \param url Url of the repository
- * \param path path of the repository (relative to url)
+ * \param alias Unique alias for this repo
*
* \note If the repository entry does not exist, it will
* be created and the new inserted entry's id will
* be returned.
*/
- data::RecordId lookupOrAppendRepository( const Url &url,
- const Pathname &path );
+ data::RecordId lookupOrAppendRepository( const std::string &alias );
/**
* Set the resolvable shared data flag pointing to
@@ -450,12 +449,60 @@
* It is responsability of the caller to operate with
* a valid record id. You can get one
* Using \ref lookupOrAppendRepository
+ *
+ * If the repository does not exists, nothing will happen
*/
void updateRepository( const data::RecordId &id,
- const std::string &checksum,
- const Date ×tamp = Date::now() );
+ const std::string &checksum,
+ const Date ×tamp = Date::now() );
+
+ /**
+ * get the status of a cached repository
+ *
+ * It is responsability of the caller to operate with
+ * a valid record id. You can get one
+ * Using \ref lookupOrAppendRepository
+ *
+ * You can check existence using \ref isCached
+ *
+ * \throws CacheRecordNotFoundException if the repository
+ * id is invalid.
+ */
+ RepoStatus repositoryStatus( const data::RecordId &id );
+
+ /**
+ * get the status of a cached repository
+ *
+ * It is responsability of the caller to operate with
+ * a valid alias. You can insert one
+ * Using \ref lookupOrAppendRepository
+ *
+ * You can check existence using \ref isCached
+ *
+ * \throws CacheRecordNotFoundException if the repository
+ * alias is unknown
+ */
+ RepoStatus repositoryStatus( const std::string &alias );
/**
+ * \short Does a repository exists in cache?
+ *
+ * True if the repository is cached
+ */
+ bool isCached( const std::string &alias );
+
+ /**
+ * \short looks the id for a repository in cache
+ *
+ * \param alias Repository unique alias
+ *
+ * \throws CacheRecordNotFoundException if the repository
+ * alias is unknown
+ */
+ data::RecordId lookupRepository( const std::string &alias );
+
+
+ /**
* Returns the record id of a file entry \a path
*
* \note If the file entry does not exist, it will
Modified: trunk/libzypp/zypp2/cache/schema/schema.sql
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/schema/schem…
==============================================================================
--- trunk/libzypp/zypp2/cache/schema/schema.sql (original)
+++ trunk/libzypp/zypp2/cache/schema/schema.sql Fri Jun 1 14:48:35 2007
@@ -58,11 +58,11 @@
CREATE TABLE repositories (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , url TEXT NOT NULL
- , path TEXT NOT NULL
+ , alias TEXT NOT NULL UNIQUE
, checksum TEXT DEFAULT NULL
, timestamp INTEGER NOT NULL
);
+CREATE INDEX repo_alias_index ON repositories(alias);
------------------------------------------------
-- Resolvable names
Added: trunk/libzypp/zypp2/repo/RepoException.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/repo/RepoException…
==============================================================================
--- trunk/libzypp/zypp2/repo/RepoException.cc (added)
+++ trunk/libzypp/zypp2/repo/RepoException.cc Fri Jun 1 14:48:35 2007
@@ -0,0 +1,66 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/repo/RepoException.cc
+ *
+*/
+#include <iostream>
+//#include "zypp/base/Logger.h"
+#include "zypp2/repo/RepoException.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace repo
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : RepoException::RepoException
+ // METHOD TYPE : Ctor
+ //
+ RepoException::RepoException()
+ : Exception( "Repo exception" )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : RepoException::RepoException
+ // METHOD TYPE : Ctor
+ //
+ RepoException::RepoException( const std::string & msg_r )
+ : Exception( msg_r )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : RepoException::~RepoException
+ // METHOD TYPE : Dtor
+ //
+ RepoException::~RepoException() throw()
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : RepoException::dumpOn
+ // METHOD TYPE : std::ostream &
+ //
+ std::ostream & RepoException::dumpOn( std::ostream & str ) const
+ {
+ return Exception::dumpOn( str );
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace repo
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
Added: trunk/libzypp/zypp2/repo/RepoException.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/repo/RepoException…
==============================================================================
--- trunk/libzypp/zypp2/repo/RepoException.h (added)
+++ trunk/libzypp/zypp2/repo/RepoException.h Fri Jun 1 14:48:35 2007
@@ -0,0 +1,79 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/tagfile/RepoException.h
+ *
+*/
+#ifndef ZYPP_REPO_REPOEXCEPTION_H
+#define ZYPP_REPO_REPOEXCEPTION_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/base/Exception.h"
+#include "zypp/base/UserRequestException.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace repo
+ { /////////////////////////////////////////////////////////////////
+
+ /**
+ * \short Exception for repository handling.
+ */
+ class RepoException : public Exception
+ {
+ public:
+ /** Default ctor */
+ RepoException();
+ /** Ctor */
+ RepoException( const std::string & msg_r );
+ /** Dtor */
+ virtual ~RepoException() throw();
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /**
+ * The repository cache is not built yet
+ * so you can't create the repostories from
+ * the cache.
+ */
+ class RepoNotCachedException : public RepoException
+ {
+
+ };
+
+ /**
+ * thrown when it was impossible to
+ * determine one url for this repo.
+ */
+ class RepoNoUrl : public RepoException
+ {
+
+ };
+
+ /**
+ * thrown when it was impossible to
+ * determine an alias for this repo.
+ */
+ class RepoNoAlias : public RepoException
+ {
+
+ };
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace parser
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0