Author: jkupec
Date: Mon Apr 30 18:35:53 2007
New Revision: 5463
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5463&view=rev
Log:
backup
- PrimaryFileReader almost complete
- YUMParser will handle all metadata file readers
- YUMResourceType added
- unified namespaces of some readers to zypp::parser::yum
- OtherFileReader and PatchFileReader started
Added:
trunk/libzypp/zypp/parser/yum/OtherFileReader.cc
trunk/libzypp/zypp/parser/yum/OtherFileReader.h
trunk/libzypp/zypp/parser/yum/PatchFileReader.cc
trunk/libzypp/zypp/parser/yum/PatchFileReader.h
trunk/libzypp/zypp/source/yum/YUMResourceType.cc
trunk/libzypp/zypp/source/yum/YUMResourceType.h
Modified:
trunk/libzypp/devel/devel.jkupec/YUMParser.cc
trunk/libzypp/devel/devel.jkupec/YUMParser.h
trunk/libzypp/devel/devel.jkupec/YUMParser_test.cc
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/ResObject.h
trunk/libzypp/zypp/data/ResolvableData.h
trunk/libzypp/zypp/parser/yum/PrimaryFileReader.cc
trunk/libzypp/zypp/parser/yum/PrimaryFileReader.h
trunk/libzypp/zypp/parser/yum/RepomdFileReader.cc
trunk/libzypp/zypp/parser/yum/RepomdFileReader.h
trunk/libzypp/zypp/source/yum/YUMDownloader.cc
trunk/libzypp/zypp/source/yum/YUMDownloader.h
Modified: trunk/libzypp/devel/devel.jkupec/YUMParser.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.jkupec/YUMParser.cc?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/YUMParser.cc (original)
+++ trunk/libzypp/devel/devel.jkupec/YUMParser.cc Mon Apr 30 18:35:53 2007
@@ -1,7 +1,21 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
#include "zypp/ZYpp.h"
#include "zypp/ZYppFactory.h"
#include "zypp/base/Logger.h"
+#include "zypp/parser/yum/RepomdFileReader.h"
+#include "zypp/parser/yum/PrimaryFileReader.h"
+#include "zypp/parser/yum/PatchesFileReader.h"
+#include "zypp/parser/yum/PatchFileReader.h"
+
#include "YUMParser.h"
using std::endl;
@@ -24,12 +38,22 @@
}
- bool YUMParser::primary_CB(const zypp::data::Package &package, const zypp::data::Dependencies &deps)
+ bool YUMParser::repomd_CB( const OnMediaLocation &loc, const YUMResourceType &dtype )
+ {
+ DBG << "Adding " << dtype
+ << " (" << loc.filename() << ") to YUMParser jobs " << endl;
+
+ _jobs.push_back(YUMParserJob(loc.filename(), dtype));
+
+ return true;
+ }
+
+ bool YUMParser::primary_CB(const zypp::data::Package & package)
{
NVRA nvra(package.name, package.edition, package.arch);
data::RecordId pkgid =
_consumer.appendResolvable(
- _catalog_id, ResTraits<Package>::kind, nvra, deps);
+ _catalog_id, ResTraits<Package>::kind, nvra, package.deps);
/* MIL << "got package "
<< package.name << package.edition << " "
@@ -39,15 +63,87 @@
MIL << "summary: " << package.summary << endl;*/
}
+
+ bool YUMParser::patches_CB(const OnMediaLocation &loc, const string & patch_id)
+ {
+ DBG << "Adding patch " << loc.filename() << " to YUMParser jobs " << endl;
+
+ _jobs.push_back(YUMParserJob(loc.filename(), YUMResourceType::PATCH));
+
+ return true;
+ }
+
+
+ bool YUMParser::patch_CB(const zypp::data::Patch & patch)
+ {
+ NVRA nvra(patch.name, patch.edition, patch.arch);
+ data::RecordId pkgid =
+ _consumer.appendResolvable(
+ _catalog_id, ResTraits<Patch>::kind, nvra, patch.deps);
+
+ MIL << "got patch "
+ << patch.name << patch.edition << " "
+ << patch.arch
+ << endl;
+ }
+
+
void YUMParser::start(const Pathname &cache_dir, ParserProgress::Ptr progress)
{
- zypp::parser::yum::PrimaryFileReader(
- cache_dir + "/repodata/primary.xml.gz",
- bind(&YUMParser::primary_CB, this, _1, _2),
- progress);
+ zypp::parser::yum::RepomdFileReader(
+ cache_dir + "/repodata/repomd.xml",
+ bind(&YUMParser::repomd_CB, this, _1, _2));
+
+ doJobs(cache_dir, progress);
+ }
+
+
+ void YUMParser::doJobs(const Pathname &cache_dir, ParserProgress::Ptr progress)
+ {
+ for(list<YUMParserJob>::const_iterator it = _jobs.begin(); it != _jobs.end(); ++it)
+ {
+ YUMParserJob job = *it;
+
+ MIL << "going to parse " << job.type() << " file " << job.filename() << endl;
+
+ switch(job.type().toEnum())
+ {
+ // parse primary.xml.gz
+ case YUMResourceType::PRIMARY_e:
+ {
+ zypp::parser::yum::PrimaryFileReader(
+ cache_dir + job.filename(),
+ bind(&YUMParser::primary_CB, this, _1),
+ progress);
+ break;
+ }
+ case YUMResourceType::PATCHES_e:
+ {
+ zypp::source::yum::PatchesFileReader(
+ cache_dir + job.filename(),
+ bind(&YUMParser::patches_CB, this, _1, _2));
+ break;
+ }
+ case YUMResourceType::PATCH_e:
+ {
+ zypp::parser::yum::PatchFileReader(
+ cache_dir + job.filename(),
+ bind(&YUMParser::patch_CB, this, _1));
+ break;
+ }
+ default:
+ {
+ DBG << "oh yeah, time will come, when we will parse "
+ << job.type() << " file "
+ << job.filename() << endl;
+ }
+ }
+ }
}
} // ns yum
} // ns parser
} // 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=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/YUMParser.h (original)
+++ trunk/libzypp/devel/devel.jkupec/YUMParser.h Mon Apr 30 18:35:53 2007
@@ -1,15 +1,26 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
#ifndef YUMPARSER_H_
#define YUMPARSER_H_
#include "zypp/base/Logger.h"
#include "zypp2/cache/CacheStore.h"
#include "zypp/data/ResolvableData.h"
-#include "zypp/parser/yum/PrimaryFileReader.h"
#include "zypp/parser/ParserProgress.h"
+#include "zypp/source/yum/YUMResourceType.h"
+
#undef ZYPP_BASE_LOGGER_LOGGROUP
#define ZYPP_BASE_LOGGER_LOGGROUP "parser"
+using zypp::source::yum::YUMResourceType;
namespace zypp
{
@@ -18,22 +29,45 @@
namespace yum
{
+ /**
+ *
+ */
+ struct YUMParserJob
+ {
+ YUMParserJob(const Pathname & filename, const YUMResourceType & type)
+ : _filename(filename), _type(type) {}
+ const Pathname & filename() const { return _filename; }
+ const YUMResourceType & type() const { return _type; }
+
+ private:
+ Pathname _filename;
+ YUMResourceType _type;
+ };
+
+
+ /**
+ *
+ */
class YUMParser
{
public:
typedef function Progress;
- YUMParser(const zypp::data::RecordId &catalog_id, zypp::cache::CacheStore &consumer);
+ YUMParser(const zypp::data::RecordId & catalog_id, zypp::cache::CacheStore & consumer);
- void start(const zypp::Pathname &path, ParserProgress::Ptr progress);
+ void start(const zypp::Pathname & path, ParserProgress::Ptr progress);
+ void doJobs(const zypp::Pathname & path, ParserProgress::Ptr progress);
- bool primary_CB(const zypp::data::Package &package, const zypp::data::Dependencies &deps);
- bool test() { return true; }
+ bool repomd_CB(const OnMediaLocation & loc, const YUMResourceType & dtype);
+ bool primary_CB(const zypp::data::Package & package);
+ bool patches_CB(const OnMediaLocation &loc, const std::string & patch_id);
+ bool patch_CB(const zypp::data::Patch & patch);
private:
- zypp::cache::CacheStore &_consumer;
+ zypp::cache::CacheStore & _consumer;
zypp::data::RecordId _catalog_id;
+ std::list<YUMParserJob> _jobs;
};
@@ -42,3 +76,5 @@
} // ns zypp
#endif /*YUMPARSER_H_*/
+
+// vim: set ts=2 sts=2 sw=2 et ai:
Modified: trunk/libzypp/devel/devel.jkupec/YUMParser_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.jkupec/YUMParser_test.cc?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/YUMParser_test.cc (original)
+++ trunk/libzypp/devel/devel.jkupec/YUMParser_test.cc Mon Apr 30 18:35:53 2007
@@ -64,3 +64,5 @@
return 0;
}
+
+// vim: set ts=2 sts=2 sw=2 et ai:
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Mon Apr 30 18:35:53 2007
@@ -541,6 +541,7 @@
parser/yum/RepomdFileReader.cc
parser/yum/PatchesFileReader.cc
parser/yum/PrimaryFileReader.cc
+ parser/yum/PatchFileReader.cc
)
SET( zypp_parser_yum_HEADERS
@@ -558,6 +559,7 @@
parser/yum/RepomdFileReader.h
parser/yum/PatchesFileReader.h
parser/yum/PrimaryFileReader.h
+ parser/yum/PatchFileReader.h
parser/yum/schemanames.h
)
@@ -566,14 +568,6 @@
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/parser/yum
)
-SET( zypp_parser_yum2_SRCS
- parser/yum2/YUMPrimaryParser.cc
-)
-
-SET( zypp_parser_yum2_HEADERS
- parser/yum2/YUMPrimaryParser.h
-)
-
INSTALL( FILES
${zypp_parser_yum2_HEADERS}
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/parser/yum2
@@ -768,6 +762,7 @@
source/yum/YUMProductImpl.cc
source/yum/YUMScriptImpl.cc
source/yum/YUMSourceImpl.cc
+ source/yum/YUMResourceType.cc
)
SET( zypp_source_yum_HEADERS
@@ -781,6 +776,7 @@
source/yum/YUMProductImpl.h
source/yum/YUMScriptImpl.h
source/yum/YUMSourceImpl.h
+ source/yum/YUMResourceType.h
)
INSTALL( FILES
Modified: trunk/libzypp/zypp/ResObject.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResObject.h?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/zypp/ResObject.h (original)
+++ trunk/libzypp/zypp/ResObject.h Mon Apr 30 18:35:53 2007
@@ -63,10 +63,10 @@
/** */
Vendor vendor() const;
- /** */
+ /** Installed size. */
ByteCount size() const;
- /** */
+ /** Size of the rpm package. */
ByteCount archivesize() const;
/** Backlink to the source providing this. */
Modified: trunk/libzypp/zypp/data/ResolvableData.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/data/ResolvableData.h?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/zypp/data/ResolvableData.h (original)
+++ trunk/libzypp/zypp/data/ResolvableData.h Mon Apr 30 18:35:53 2007
@@ -71,9 +71,11 @@
std::string license_to_confirm;
std::string vendor;
+ /** Installed size. \see zypp::ResObject::size() */
ByteCount size;
+ /** RPM package size. \see zypp::ResObject::archive_size() */
ByteCount archive_size;
-
+
std::string source;
int source_media_nr;
@@ -83,7 +85,7 @@
Date build_time;
Date install_time;
};
-
+
class AtomBase : public ResObject
{
public:
@@ -134,6 +136,21 @@
{
public:
Patch() {};
+
+ /** Patch ID */
+ std::string id;
+ /** Patch time stamp */
+ Date timestamp;
+ /** Patch category (recommended, security,...) */
+ std::string category;
+ /** Does the system need to reboot to finish the update process? */
+ bool reboot_needed;
+ /** Does the patch affect the package manager itself? */
+ bool affects_pkg_manager;
+ /** The list of all atoms building the patch */
+ //AtomList atoms;
+ /** Is the patch installation interactive? (does it need user input?) */
+ bool interactive;
};
/*
@@ -229,7 +246,7 @@
std::string group;
std::string url;
std::string os;
-
+
std::string prein;
std::string postin;
std::string preun;
Added: trunk/libzypp/zypp/parser/yum/OtherFileReader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/OtherFileReader.cc?rev=5463&view=auto
==============================================================================
--- trunk/libzypp/zypp/parser/yum/OtherFileReader.cc (added)
+++ trunk/libzypp/zypp/parser/yum/OtherFileReader.cc Mon Apr 30 18:35:53 2007
@@ -0,0 +1,75 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#include <fstream>
+
+#include "zypp/parser/yum/OtherFileReader.h"
+
+using namespace std;
+using namespace zypp::xml;
+
+namespace zypp
+{
+ namespace parser
+ {
+ namespace yum
+ {
+
+
+ OtherFileReader::OtherFileReader(const Pathname & other_file, ProcessOther callback)
+ : _callback(callback), _resolvable(NULL)
+ {
+ 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)
+ {
+ if (reader_r->name() == "package")
+ {
+ if (_resolvable) delete _resolvable;
+ _resolvable = new zypp::data::Resolvable();
+
+ _resolvable->name = reader_r->getAttribute("name").asString();
+ _resolvable->arch = Arch(reader_r->getAttribute("arch").asString());
+ return true;
+ }
+ if (reader_r->name() == "version")
+ {
+ _package->edition = Edition(reader_r->getAttribute("ver").asString(),
+ reader_r->getAttribute("rel").asString(),
+ reader_r->getAttribute("epoch").asString());
+ }
+ }
+ else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
+ {
+ if (reader_r->name() == "package")
+ {
+ // _callback(*_resolvable, changelog, checksum - package id);
+ if (_resolvable)
+ {
+ delete _resolvable;
+ _resolvable = NULL;
+ }
+ return true;
+ }
+ }
+ return true;
+ }
+
+
+ } // ns yum
+ } // ns parser
+} // ns zypp
+
+// vim: set ts=2 sts=2 sw=2 et ai:
Added: trunk/libzypp/zypp/parser/yum/OtherFileReader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/OtherFileReader.h?rev=5463&view=auto
==============================================================================
--- trunk/libzypp/zypp/parser/yum/OtherFileReader.h (added)
+++ trunk/libzypp/zypp/parser/yum/OtherFileReader.h Mon Apr 30 18:35:53 2007
@@ -0,0 +1,108 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef OTHERFILEREADER_H_
+#define OTHERFILEREADER_H_
+
+#include "zypp/base/Function.h"
+#include "zypp/base/Logger.h"
+#include "zypp/parser/xml/Reader.h"
+#include "zypp/data/ResolvableData.h"
+#include "zypp/parser/ParserProgress.h"
+
+#undef ZYPP_BASE_LOGGER_LOGGROUP
+#define ZYPP_BASE_LOGGER_LOGGROUP "parser"
+
+namespace zypp
+{
+ namespace parser
+ {
+ namespace yum
+ {
+
+ /**
+ * Reads through a other.xml file and collects additional package data
+ * like 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.
+ *
+ * The \ref _callback is provided on construction.
+ *
+ * \code
+ * PrimaryFileReader reader(repomd_file,
+ * bind(&SomeClass::callbackfunc, &object, _1));
+ * \endcode
+ */
+ class OtherFileReader
+ {
+ public:
+ /**
+ * Callback definition.
+ */
+ typedef function ProcessPackage;
+
+
+ /**
+ * Constructor
+ * \param other_file the other.xml.gz file you want to read
+ * \param function to process \ref _resolvable data.
+ * \param progress progress reporting function TODO better progress reporting
+ *
+ * \see OtherFileReader::ProcessPackage
+ */
+ PrimaryFileReader(const Pathname & other_file,
+ ProcessPackage callback, ParserProgress::Ptr progress);
+
+ /**
+ * Callback provided to the XML parser.
+ */
+ bool consumeNode(zypp::xml::Reader & reader_r);
+
+ private:
+
+ /**
+ * Number of packages read so far.
+ */
+ unsigned _count;
+
+ /**
+ * Total number of packages to be read. This information is acquired from
+ * the <code>packages</code> attribute of <code>otherdata<code> tag.
+ */
+ unsigned _total_packages;
+
+ /**
+ * Pointer to the \ref zypp::data::Resolvable object for storing the NVRA
+ * data.
+ */
+ zypp::data::Resolvable *_resolvable;
+
+ /**
+ * Callback for processing package metadata passed in through constructor.
+ */
+ ProcessPackage _callback;
+
+ /**
+ * Progress reporting object.
+ */
+ ParserProgress::Ptr _progress;
+
+ long int _old_progress;
+ };
+
+
+ } // ns zypp
+ } // ns parser
+} // ns yum
+
+#endif /*OTHERFILEREADER_H_*/
+
+// vim: set ts=2 sts=2 sw=2 et ai:
Added: trunk/libzypp/zypp/parser/yum/PatchFileReader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/PatchFileReader.cc?rev=5463&view=auto
==============================================================================
--- trunk/libzypp/zypp/parser/yum/PatchFileReader.cc (added)
+++ trunk/libzypp/zypp/parser/yum/PatchFileReader.cc Mon Apr 30 18:35:53 2007
@@ -0,0 +1,74 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#include <fstream>
+
+#include "zypp/parser/yum/PatchFileReader.h"
+
+using namespace std;
+using namespace zypp::xml;
+
+namespace zypp
+{
+ namespace parser
+ {
+ namespace yum
+ {
+
+
+ PatchFileReader::PatchFileReader(const Pathname & patch_file, ProcessPatch callback)
+ : _callback(callback), _patch(NULL)
+ {
+ Reader reader(patch_file);
+ MIL << "Reading " << patch_file << endl;
+ reader.foreachNode(bind(&PatchFileReader::consumeNode, this, _1));
+ }
+
+
+ bool PatchFileReader::consumeNode(Reader & reader_r)
+ {
+ if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
+ {
+ if (reader_r->name() == "patch")
+ {
+ if (_patch) delete _patch;
+ _patch = new zypp::data::Patch();
+
+ _patch->id = reader_r->getAttribute("patchid").asString();
+ _patch->timestamp = Date(reader_r->getAttribute("timestamp").asString());
+ return true;
+ }
+ if (reader_r->name() == "yum:name")
+ {
+ _patch->name = reader_r.nodeText().asString();
+ return true;
+ }
+ }
+ else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
+ {
+ if (reader_r->name() == "patch")
+ {
+ _callback(*_patch);
+ if (_patch)
+ {
+ delete _patch;
+ _patch = NULL;
+ }
+ return true;
+ }
+ }
+ return true;
+ }
+
+
+ } // ns yum
+ } // ns parser
+} // ns zypp
+
+// vim: set ts=2 sts=2 sw=2 et ai:
Added: trunk/libzypp/zypp/parser/yum/PatchFileReader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/PatchFileReader.h?rev=5463&view=auto
==============================================================================
--- trunk/libzypp/zypp/parser/yum/PatchFileReader.h (added)
+++ trunk/libzypp/zypp/parser/yum/PatchFileReader.h Mon Apr 30 18:35:53 2007
@@ -0,0 +1,76 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef PATCHFILEREADER_H_
+#define PATCHFILEREADER_H_
+
+#include "zypp/base/Function.h"
+#include "zypp/base/Logger.h"
+#include "zypp/parser/xml/Reader.h"
+#include "zypp/data/ResolvableData.h"
+
+#undef ZYPP_BASE_LOGGER_LOGGROUP
+#define ZYPP_BASE_LOGGER_LOGGROUP "parser"
+
+namespace zypp
+{
+ namespace parser
+ {
+ namespace yum
+ {
+
+
+ /**
+ *
+ */
+ class PatchFileReader
+ {
+ public:
+
+ /**
+ * Callback definition.
+ */
+ typedef function ProcessPatch;
+
+ /**
+ *
+ */
+ PatchFileReader(const Pathname & patch_file, ProcessPatch callback);
+
+ /**
+ * Callback provided to the XML parser.
+ */
+ bool consumeNode(zypp::xml::Reader & reader_r);
+
+ private:
+ /**
+ * Callback for processing patch metadata passed in through constructor.
+ */
+ ProcessPatch _callback;
+
+ /**
+ * Pointer to the \ref zypp::data::Patch object for storing the patch
+ * metada (except of depencencies).
+ */
+ zypp::data::Patch *_patch;
+
+ /**
+ * A map of lists of strings for storing dependencies.
+ *
+ * \see zypp::data::Dependencies
+ */
+ zypp::data::Dependencies _deps;
+ };
+
+
+ }
+ }
+}
+
+#endif /*PATCHFILEREADER_H_*/
Modified: trunk/libzypp/zypp/parser/yum/PrimaryFileReader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/PrimaryFileReader.cc?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/yum/PrimaryFileReader.cc (original)
+++ trunk/libzypp/zypp/parser/yum/PrimaryFileReader.cc Mon Apr 30 18:35:53 2007
@@ -1,9 +1,18 @@
-//#include "zypp/base/String.h"
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
#include "zypp/base/Logger.h"
#include "zypp/parser/yum/PrimaryFileReader.h"
#include "zypp/Arch.h"
#include "zypp/Edition.h"
#include "zypp/TranslatedText.h"
+#include "zypp/ByteCount.h"
using namespace std;
using namespace zypp::xml;
@@ -16,8 +25,13 @@
{
- PrimaryFileReader::PrimaryFileReader(const Pathname &primary_file, ProcessPackage callback, ParserProgress::Ptr progress)
- : _callback(callback), _package(NULL), _count(0), _total_packages(0),
+ PrimaryFileReader::PrimaryFileReader(
+ const Pathname &primary_file,
+ ProcessPackage callback,
+ ParserProgress::Ptr progress)
+ :
+ _callback(callback), _package(NULL),
+ _count(0), _total_packages(0),
_tag(tag_NONE), _expect_rpm_entry(false), _dtype(zypp::Dep::REQUIRES),
_progress(progress), _old_progress(0)
{
@@ -95,13 +109,40 @@
if (reader_r->name() == "packager")
{
- _package->packager = reader_r.nodeText().asString();
+ _package->packager = reader_r.nodeText().asString();
+// DBG << "packager: " << _package->packager << endl;
+ return true;
+ }
+
+ if (reader_r->name() == "url")
+ {
+// DBG << "url: " << reader_r.nodeText().asString() << endl;
+ _package->url = reader_r.nodeText().asString();
return true;
}
- // TODO url
- // TODO time
- // TODO size
+ if (reader_r->name() == "time")
+ {
+ _package->build_time = reader_r->getAttribute("build").asString();
+ // ignoring reader_r->getAttribute("file").asString(); (rpm file timestamp)
+ return true;
+ }
+
+ if (reader_r->name() == "size")
+ {
+ // ???
+ // reader_r->getAttribute("archive").asString();
+
+ // installed size
+ ByteCount size(str::strtonum<long long>(reader_r->getAttribute("installed").asString()), Unit());
+ _package->size = size;
+
+ // rpm package size
+ ByteCount size_rpm(str::strtonum<long long>(reader_r->getAttribute("package").asString()), Unit());
+ _package->archive_size = size_rpm;
+
+ return true;
+ }
if (reader_r->name() == "location")
{
@@ -112,7 +153,6 @@
if (reader_r->name() == "format")
{
_tag = tag_format;
- _deps.clear();
return true;
}
}
@@ -120,7 +160,7 @@
{
if (reader_r->name() == "package")
{
- _callback(*_package, _deps);
+ _callback(*_package);
if (_package)
{
delete _package;
@@ -169,7 +209,7 @@
<< reader_r->getAttribute("name").asString()
<< " " << edition << endl;
*/
- _deps[_dtype].push_back(
+ _package->deps[_dtype].push_back(
zypp::capability::parse(
ResTraits<Package>::kind,
reader_r->getAttribute("name").asString(),
@@ -179,12 +219,42 @@
);
}
- // TODO license
- // TODO vendor
- // TODO group
- // TODO buildhost
- // TODO sourcerpm
- // TODO header-range
+ if (reader_r->name() == "rpm:license")
+ {
+ _package->license = reader_r.nodeText().asString();
+ return true;
+ }
+
+ if (reader_r->name() == "rpm:vendor")
+ {
+ _package->vendor = reader_r.nodeText().asString();
+ return true;
+ }
+
+ if (reader_r->name() == "rpm:group")
+ {
+ _package->group = reader_r.nodeText().asString();
+ return true;
+ }
+
+ if (reader_r->name() == "rpm:buildhost")
+ {
+ _package->buildhost = reader_r.nodeText().asString();
+ return true;
+ }
+
+ if (reader_r->name() == "rpm:sourcerpm")
+ {
+ //package->source = reader_r.nodeText().asString();
+ return true;
+ }
+
+ if (reader_r->name() == "rpm:header-range")
+ {
+ //reader_r->getAttribute("start").asString(),
+ //reader_r->getAttribute("end").asString(),
+ return true;
+ }
if (reader_r->name() == "rpm:provides")
{
@@ -240,7 +310,14 @@
_expect_rpm_entry = true;
return true;
}
- // TODO file
+
+ if (reader_r->name() == "file")
+ {
+ // TODO figure out how to read files
+ // file = reader_r.nodeText().asString();
+ // type = reader_r->getAttribute("type").asString();
+ return true;
+ }
}
else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
{
Modified: trunk/libzypp/zypp/parser/yum/PrimaryFileReader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/PrimaryFileReader.h?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/yum/PrimaryFileReader.h (original)
+++ trunk/libzypp/zypp/parser/yum/PrimaryFileReader.h Mon Apr 30 18:35:53 2007
@@ -1,3 +1,12 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
#ifndef ZYPP_PARSER_YUM_PRIMARYFILEPARSER_H
#define ZYPP_PARSER_YUM_PRIMARYFILEPARSER_H
@@ -21,9 +30,8 @@
* Reads through a primary.xml file and collects package data including
* dependencies.
*
- * After a package is read, a \ref zypp::data::Package
- * and \ref zypp::data::Dependencies object is prepared and \ref _callback
- * is called with these two objects passed in.
+ * After a package is read, a \ref zypp::data::Package object is prepared
+ * and \ref _callback is called with this object passed in.
*
* The \ref _callback is provided on construction.
*
@@ -38,7 +46,7 @@
/**
* Callback definition.
*/
- typedef function ProcessPackage;
+ typedef function ProcessPackage;
/**
* Enumeration of some primary.xml tags.
@@ -49,20 +57,7 @@
tag_package,
tag_format
};
-/*
- enum RPMTag
- {
- rpmtag_NONE,
- rpmtag_provides,
- rpmtag_conflicts,
- rpmtag_obsoletes,
- rpmtag_requires,
- rpmtag_recommends,
- rpmtag_enhances,
- rpmtag_supplements,
- rpmtag_suggests
- };
-*/
+
/**
* Constructor
* \param primary_file the primary.xml.gz file you want to read
@@ -87,8 +82,6 @@
/** Used to remember primary.xml tag beeing currently processed. */
Tag _tag;
-// RPMTag _rpmtag;
-
/**
* Used to remember whether we are expecting an rpm:entry tag
* e.g. for rpm:requires
@@ -113,18 +106,11 @@
/**
* Pointer to the \ref zypp::data::Package object for storing the package
- * metada (except of depencencies are stored).
+ * metada
*/
zypp::data::Package *_package;
/**
- * A map of lists of strings for storing package dependencies.
- *
- * \see zypp::data::Dependencies
- */
- zypp::data::Dependencies _deps;
-
- /**
* Callback for processing package metadata passed in through constructor.
*/
ProcessPackage _callback;
Modified: trunk/libzypp/zypp/parser/yum/RepomdFileReader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/RepomdFileReader.cc?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/yum/RepomdFileReader.cc (original)
+++ trunk/libzypp/zypp/parser/yum/RepomdFileReader.cc Mon Apr 30 18:35:53 2007
@@ -15,11 +15,12 @@
using namespace std;
using namespace zypp::xml;
+using zypp::source::yum::YUMResourceType;
-namespace zypp { namespace source { namespace yum {
+namespace zypp { namespace parser { namespace yum {
RepomdFileReader::RepomdFileReader( const Pathname &repomd_file, ProcessResource callback )
- : _tag(tag_NONE), _callback(callback)
+ : _tag(tag_NONE), _callback(callback), _type(YUMResourceType::NONE_e)
{
Reader reader( repomd_file );
MIL << "Reading " << repomd_file << endl;
@@ -40,7 +41,7 @@
if ( reader_r->name() == "data" )
{
_tag = tag_Data;
- _type = reader_r->getAttribute("type").asString();
+ _type = YUMResourceType(reader_r->getAttribute("type").asString());
return true;
}
if ( reader_r->name() == "location" )
Modified: trunk/libzypp/zypp/parser/yum/RepomdFileReader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/RepomdFileReader.h?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/yum/RepomdFileReader.h (original)
+++ trunk/libzypp/zypp/parser/yum/RepomdFileReader.h Mon Apr 30 18:35:53 2007
@@ -15,13 +15,14 @@
#include "zypp/OnMediaLocation.h"
#include "zypp/base/Function.h"
#include "zypp/parser/xml/Reader.h"
+#include "zypp/source/yum/YUMResourceType.h"
using namespace std;
using namespace zypp::xml;
namespace zypp
{
- namespace source
+ namespace parser
{
namespace yum
{
@@ -46,8 +47,11 @@
* first parameter is a \ref OnMediaLocation object with the resource
* second parameter is the resource type
*/
- typedef function ProcessResource;
-
+ typedef function< bool(
+ const OnMediaLocation &,
+ const source::yum::YUMResourceType & )>
+ ProcessResource;
+
enum Tag
{
tag_NONE,
@@ -74,7 +78,7 @@
private:
OnMediaLocation _location;
Tag _tag;
- std::string _type;
+ source::yum::YUMResourceType _type;
ProcessResource _callback;
CheckSum _checksum;
std::string _checksum_type;
Modified: trunk/libzypp/zypp/source/yum/YUMDownloader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/source/yum/YUMDownloader.cc?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/zypp/source/yum/YUMDownloader.cc (original)
+++ trunk/libzypp/zypp/source/yum/YUMDownloader.cc Mon Apr 30 18:35:53 2007
@@ -20,6 +20,7 @@
using namespace std;
using namespace zypp::xml;
+using namespace zypp::parser::yum;
namespace zypp
{
@@ -41,7 +42,7 @@
}
-bool YUMDownloader::repomd_Callback( const OnMediaLocation &loc, const string &dtype )
+bool YUMDownloader::repomd_Callback( const OnMediaLocation &loc, const YUMResourceType &dtype )
{
MIL << dtype << " : " << loc << endl;
_fetcher.enqueue(loc);
@@ -49,7 +50,7 @@
// We got a patches file we need to read, to add patches listed
// there, so we transfer what we have in the queue, and
// queue the patches in the patches callback
- if ( dtype == "patches" )
+ if ( dtype == YUMResourceType::PATCHES )
{
_fetcher.start( _dest_dir, _media);
// now the patches.xml file must exists
Modified: trunk/libzypp/zypp/source/yum/YUMDownloader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/source/yum/YUMDownloader.h?rev=5463&r1=5462&r2=5463&view=diff
==============================================================================
--- trunk/libzypp/zypp/source/yum/YUMDownloader.h (original)
+++ trunk/libzypp/zypp/source/yum/YUMDownloader.h Mon Apr 30 18:35:53 2007
@@ -16,6 +16,7 @@
#include "zypp/OnMediaLocation.h"
#include "zypp/MediaSetAccess.h"
#include "zypp/parser/xml/Reader.h"
+#include "zypp/source/yum/YUMResourceType.h"
namespace zypp
{
@@ -46,7 +47,7 @@
void download( const Pathname &dest_dir );
protected:
- bool repomd_Callback( const OnMediaLocation &loc, const std::string &dtype );
+ bool repomd_Callback( const OnMediaLocation &loc, const YUMResourceType &dtype );
bool patches_Callback( const OnMediaLocation &loc, const std::string &id );
private:
Url _url;
Added: trunk/libzypp/zypp/source/yum/YUMResourceType.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/source/yum/YUMResourceType.cc?rev=5463&view=auto
==============================================================================
--- trunk/libzypp/zypp/source/yum/YUMResourceType.cc (added)
+++ trunk/libzypp/zypp/source/yum/YUMResourceType.cc Mon Apr 30 18:35:53 2007
@@ -0,0 +1,90 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#include <map>
+
+#include "zypp/base/Exception.h"
+
+#include "YUMResourceType.h"
+//#include <iostream>
+
+namespace zypp
+{
+ namespace source
+ {
+ namespace yum
+ {
+
+
+ static std::mapstd::string,YUMResourceType::Type _table;
+
+ const YUMResourceType YUMResourceType::REPOMD(YUMResourceType::REPOMD_e);
+ const YUMResourceType YUMResourceType::PRIMARY(YUMResourceType::PRIMARY_e);
+ const YUMResourceType YUMResourceType::OTHER(YUMResourceType::OTHER_e);
+ const YUMResourceType YUMResourceType::FILELISTS(YUMResourceType::FILELISTS_e);
+ const YUMResourceType YUMResourceType::GROUP(YUMResourceType::GROUP_e);
+ const YUMResourceType YUMResourceType::PATCHES(YUMResourceType::PATCHES_e);
+ const YUMResourceType YUMResourceType::PATCH(YUMResourceType::PATCH_e);
+ const YUMResourceType YUMResourceType::PRODUCT(YUMResourceType::PRODUCT_e);
+
+
+ YUMResourceType::YUMResourceType(const std::string & strval_r)
+ : _type(parse(strval_r))
+ {}
+
+ YUMResourceType::Type YUMResourceType::parse(const std::string & strval_r)
+ {
+ if (_table.empty())
+ {
+ // initialize it
+ _table["repomd"] = YUMResourceType::REPOMD_e;
+ _table["primary"] = YUMResourceType::PRIMARY_e;
+ _table["other"] = YUMResourceType::OTHER_e;
+ _table["filelists"] = YUMResourceType::FILELISTS_e;
+ _table["group"] = YUMResourceType::GROUP_e;
+ _table["patches"] = YUMResourceType::PATCHES_e;
+ _table["patch"] = YUMResourceType::PATCH_e;
+ _table["product"] = YUMResourceType::PRODUCT_e;
+ _table["NONE"] = _table["none"] = YUMResourceType::NONE_e;
+ }
+
+ std::mapstd::string,YUMResourceType::Type::const_iterator it
+ = _table.find(strval_r);
+ if (it == _table.end())
+ {
+ ZYPP_THROW(Exception(
+ "YUMResourceType parse: illegal string value '" + strval_r + "'"));
+ }
+ return it->second;
+ }
+
+
+ const std::string & YUMResourceType::asString() const
+ {
+ static std::map _table;
+ if ( _table.empty() )
+ {
+ // initialize it
+ _table[REPOMD_e] = "repomd";
+ _table[PRIMARY_e] = "primary";
+ _table[OTHER_e] = "other";
+ _table[FILELISTS_e] = "filelists";
+ _table[GROUP_e] = "group";
+ _table[PATCHES_e] = "patches";
+ _table[PATCH_e] = "patch";
+ _table[PRODUCT_e] = "product";
+ _table[NONE_e] = "NONE";
+ }
+ return _table[_type];
+ }
+
+
+ }
+ }
+}
Added: trunk/libzypp/zypp/source/yum/YUMResourceType.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/source/yum/YUMResourceType.h?rev=5463&view=auto
==============================================================================
--- trunk/libzypp/zypp/source/yum/YUMResourceType.h (added)
+++ trunk/libzypp/zypp/source/yum/YUMResourceType.h Mon Apr 30 18:35:53 2007
@@ -0,0 +1,76 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef YUMRESOURCETYPE_H_
+#define YUMRESOURCETYPE_H_
+
+#include<string>
+
+
+namespace zypp
+{
+ namespace source
+ {
+ namespace yum
+ {
+
+
+ /**
+ *
+ */
+ struct YUMResourceType
+ {
+ static const YUMResourceType REPOMD;
+ static const YUMResourceType PRIMARY;
+ static const YUMResourceType OTHER;
+ static const YUMResourceType FILELISTS;
+ static const YUMResourceType GROUP;
+ static const YUMResourceType PATCHES; // suse extension
+ static const YUMResourceType PATCH; // suse extension
+ static const YUMResourceType PRODUCT; // suse extension
+
+ enum Type
+ {
+ NONE_e,
+ REPOMD_e,
+ PRIMARY_e,
+ OTHER_e,
+ FILELISTS_e,
+ GROUP_e,
+ PATCHES_e,
+ PATCH_e,
+ PRODUCT_e
+ };
+
+ YUMResourceType(Type type) : _type(type) {}
+
+ explicit YUMResourceType(const std::string & strval_r);
+
+ const Type toEnum() const { return _type; }
+
+ YUMResourceType::Type parse(const std::string & strval_r);
+
+ const std::string & asString() const;
+
+ Type _type;
+ };
+
+
+ inline std::ostream & operator<<( std::ostream & str, const YUMResourceType & obj )
+ { return str << obj.asString(); }
+
+ inline bool operator==(const YUMResourceType & obj1, const YUMResourceType & obj2)
+ { return obj1._type == obj2._type; }
+
+ }
+ }
+}
+#endif /*YUMRESOURCETYPE_H_*/
+
+// vim: set ts=2 sts=2 sw=2 et ai:
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org