Author: jkupec
Date: Mon May 21 02:02:32 2007
New Revision: 5572
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5572&view=rev
Log:
other.xml.gz file reader complete
Modified:
trunk/libzypp/devel/devel.jkupec/YUMParser.cc
trunk/libzypp/devel/devel.jkupec/YUMParser.h
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/data/ResolvableDataConsumer.h
trunk/libzypp/zypp/parser/yum/OtherFileReader.cc
trunk/libzypp/zypp/parser/yum/OtherFileReader.h
trunk/libzypp/zypp2/cache/CacheStore.cpp
trunk/libzypp/zypp2/cache/CacheStore.h
Modified: trunk/libzypp/devel/devel.jkupec/YUMParser.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.jkupec/YUMParser.cc?rev=5572&r1=5571&r2=5572&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/YUMParser.cc (original)
+++ trunk/libzypp/devel/devel.jkupec/YUMParser.cc Mon May 21 02:02:32 2007
@@ -15,6 +15,7 @@
#include "zypp/parser/yum/PrimaryFileReader.h"
#include "zypp/parser/yum/PatchesFileReader.h"
#include "zypp/parser/yum/PatchFileReader.h"
+#include "zypp/parser/yum/OtherFileReader.h"
#include "YUMParser.h"
@@ -98,6 +99,21 @@
}
+ bool YUMParser::other_CB(const data::Resolvable_Ptr & res_ptr, const Changelog & changelog)
+ {
+ _consumer.consumeChangelog(_catalog_id, res_ptr, changelog);
+/*
+ DBG << "got changelog for "
+ << res_ptr->name << res_ptr->edition << " "
+ << res_ptr->arch
+ << endl;
+
+ DBG << "last entry: " << changelog.front() << endl;
+*/
+ return true;
+ }
+
+
void YUMParser::start(const Pathname &cache_dir)
{
zypp::parser::yum::RepomdFileReader(
@@ -133,6 +149,7 @@
&progress_function);
break;
}
+
case YUMResourceType::PATCHES_e:
{
zypp::source::yum::PatchesFileReader(
@@ -143,6 +160,7 @@
_ticks.range(_jobs.size());
break;
}
+
case YUMResourceType::PATCH_e:
{
zypp::parser::yum::PatchFileReader(
@@ -150,6 +168,16 @@
bind(&YUMParser::patch_CB, this, _1));
break;
}
+
+ case YUMResourceType::OTHER_e:
+ {
+ zypp::parser::yum::OtherFileReader(
+ cache_dir + job.filename(),
+ bind(&YUMParser::other_CB, this, _1, _2),
+ &progress_function);
+ break;
+ }
+
default:
{
WAR << "Don't know how to read "
@@ -168,3 +196,4 @@
} // ns zypp
// vim: set ts=2 sts=2 sw=2 et ai:
+
Modified: trunk/libzypp/devel/devel.jkupec/YUMParser.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.jkupec/YUMParser.h?rev=5572&r1=5571&r2=5572&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/YUMParser.h (original)
+++ trunk/libzypp/devel/devel.jkupec/YUMParser.h Mon May 21 02:02:32 2007
@@ -15,6 +15,7 @@
#include "zypp/data/ResolvableData.h"
#include "zypp/source/yum/YUMResourceType.h"
#include "zypp/ProgressData.h"
+#include "zypp/Changelog.h"
using zypp::source::yum::YUMResourceType;
@@ -64,6 +65,7 @@
bool primary_CB(const data::Package_Ptr & package_r);
bool patches_CB(const OnMediaLocation &loc, const std::string & patch_id);
bool patch_CB(const data::Patch_Ptr & patch);
+ bool other_CB(const data::Resolvable_Ptr & res_ptr, const Changelog & changelog);
private:
zypp::cache::CacheStore & _consumer;
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=5572&r1=5571&r2=5572&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Mon May 21 02:02:32 2007
@@ -554,6 +554,7 @@
parser/yum/RepomdFileReader.cc
parser/yum/PatchesFileReader.cc
parser/yum/PrimaryFileReader.cc
+ parser/yum/OtherFileReader.cc
parser/yum/PatchFileReader.cc
)
@@ -573,6 +574,7 @@
parser/yum/RepomdFileReader.h
parser/yum/PatchesFileReader.h
parser/yum/PrimaryFileReader.h
+ parser/yum/OtherFileReader.h
parser/yum/PatchFileReader.h
parser/yum/schemanames.h
)
Modified: trunk/libzypp/zypp/data/ResolvableDataConsumer.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/data/ResolvableDataConsumer.h?rev=5572&r1=5571&r2=5572&view=diff
==============================================================================
--- trunk/libzypp/zypp/data/ResolvableDataConsumer.h (original)
+++ trunk/libzypp/zypp/data/ResolvableDataConsumer.h Mon May 21 02:02:32 2007
@@ -33,7 +33,9 @@
virtual void consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr ) = 0;
virtual void consumeMessage( const data::RecordId &catalog_id, data::Message_Ptr ) = 0;
virtual void consumeScript( const data::RecordId &catalog_id, data::Script_Ptr ) = 0;
-
+
+ virtual void consumeChangelog( const data::RecordId &catalog_id, data::Resolvable_Ptr, Changelog ) = 0;
+
//virtual void consumeSourcePackage( const data::SrcPackage_Ptr ) = 0;
};
Modified: trunk/libzypp/zypp/parser/yum/OtherFileReader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/OtherFileReader.cc?rev=5572&r1=5571&r2=5572&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/yum/OtherFileReader.cc (original)
+++ trunk/libzypp/zypp/parser/yum/OtherFileReader.cc Mon May 21 02:02:32 2007
@@ -22,51 +22,116 @@
{
- OtherFileReader::OtherFileReader(const Pathname & other_file, ProcessOther callback)
- : _callback(callback), _resolvable(NULL)
+ // --------------------------------------------------------------------------
+
+ /*
+ * xpath and multiplicity of processed nodes are included in the code
+ * for convenience:
+ *
+ * // xpath: <xpath> (?|*|+)
+ *
+ * if multiplicity is ommited, then the node has multiplicity 'one'.
+ */
+
+ // --------------------------------------------------------------------------
+
+ OtherFileReader::OtherFileReader(
+ const Pathname & other_file,
+ const ProcessPackage & callback,
+ const ProgressData::ReceiverFnc & progress)
+ :
+ _callback(callback)
{
+ _ticks.sendTo(progress);
+ _ticks.name("other.xml.gz");
+
Reader reader(other_file);
MIL << "Reading " << other_file << endl;
reader.foreachNode(bind(&OtherFileReader::consumeNode, this, _1));
}
+ // --------------------------------------------------------------------------
bool OtherFileReader::consumeNode(Reader & reader_r)
{
if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
{
+ // xpath: /otherdata
+ if (reader_r->name() == "otherdata")
+ {
+ unsigned total_packages;
+ zypp::str::strtonum(reader_r->getAttribute("packages").asString(), total_packages);
+ _ticks.range(total_packages);
+ _ticks.toMin();
+ return true;
+ }
+
+ // xpath: /otherdata/package (+)
if (reader_r->name() == "package")
{
- if (_resolvable) delete _resolvable;
- _resolvable = new zypp::data::Resolvable();
+ _resolvable = new data::Resolvable;
+ _changelog.clear();
_resolvable->name = reader_r->getAttribute("name").asString();
_resolvable->arch = Arch(reader_r->getAttribute("arch").asString());
+
return true;
}
+
+ // xpath: /otherdata/package/version
if (reader_r->name() == "version")
{
- _package->edition = Edition(reader_r->getAttribute("ver").asString(),
+ _resolvable->edition = Edition(reader_r->getAttribute("ver").asString(),
reader_r->getAttribute("rel").asString(),
reader_r->getAttribute("epoch").asString());
+ return true;
+ }
+
+ // xpath: /otherdata/package/changelog (*)
+ if (reader_r->name() == "changelog")
+ {
+ ChangelogEntry entry(
+ Date(reader_r->getAttribute("date").asString()),
+ reader_r->getAttribute("author").asString(),
+ reader_r.nodeText().asString());
+ _changelog.push_back(entry);
+ return true;
}
}
+
else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
{
+ // xpath: /otherdata/package
if (reader_r->name() == "package")
{
- // _callback(*_resolvable, changelog, checksum - package id);
- if (_resolvable)
- {
- delete _resolvable;
- _resolvable = NULL;
- }
+ if (_callback && !_changelog.empty())
+ _callback(handoutResolvable(), _changelog);
+
+ _ticks.incr();
+
+ return true;
+ }
+
+ // xpath: /otherdata
+ if (reader_r->name() == "otherdata")
+ {
+ _ticks.toMax();
return true;
}
}
+
return true;
}
+ // --------------------------------------------------------------------------
+
+ data::Resolvable_Ptr OtherFileReader::handoutResolvable()
+ {
+ data::Resolvable_Ptr ret;
+ ret.swap(_resolvable);
+ return ret;
+ }
+
} // ns yum
} // ns parser
Modified: trunk/libzypp/zypp/parser/yum/OtherFileReader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/OtherFileReader.h?rev=5572&r1=5571&r2=5572&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/yum/OtherFileReader.h (original)
+++ trunk/libzypp/zypp/parser/yum/OtherFileReader.h Mon May 21 02:02:32 2007
@@ -14,7 +14,8 @@
#include "zypp/base/Logger.h"
#include "zypp/parser/xml/Reader.h"
#include "zypp/data/ResolvableData.h"
-#include "zypp/parser/ParserProgress.h"
+#include "zypp/ProgressData.h"
+#include "zypp/Changelog.h"
#undef ZYPP_BASE_LOGGER_LOGGROUP
#define ZYPP_BASE_LOGGER_LOGGROUP "parser"
@@ -26,19 +27,20 @@
namespace yum
{
+
/**
* Reads through a other.xml file and collects additional package data
- * like changelogs.
+ * (currently only changelogs).
*
- * After a package is read, a \ref zypp::data::Resolvable
- * and \ref changelog TODO is prepared and \ref _callback
- * is called with these two objects passed in.
+ * After a package is read, a \ref data::Resolvable
+ * and \ref Changelog is prepared and \ref _callback
+ * is called with these two objects passed in.
*
* The \ref _callback is provided on construction.
*
* \code
- * PrimaryFileReader reader(repomd_file,
- * bind(&SomeClass::callbackfunc, &object, _1));
+ * OtherFileReader reader(other_file,
+ * bind(&SomeClass::callbackfunc, &object, _1));
* \endcode
*/
class OtherFileReader
@@ -47,43 +49,47 @@
/**
* Callback definition.
*/
- typedef function