YUMGroupParser.h \
YUMParserData.h \
YUMPatchParser.h \
+ YUMPatchesParser.h \
YUMProductParser.h \
YUMRepomdParser.h \
schemanames.h
YUMRepomdParser.cc \
YUMGroupParser.cc \
YUMPatchParser.cc \
+ YUMPatchesParser.cc \
YUMOtherParser.cc \
YUMPrimaryParser.cc \
YUMProductParser.cc
#include "zypp/parser/yum/YUMFileListParser.h"
#include "zypp/parser/yum/YUMOtherParser.h"
#include "zypp/parser/yum/YUMPatchParser.h"
+#include "zypp/parser/yum/YUMPatchesParser.h"
#include "zypp/parser/yum/YUMProductParser.h"
#endif
IMPL_PTR_TYPE(YUMFileListData);
IMPL_PTR_TYPE(YUMOtherData);
IMPL_PTR_TYPE(YUMPatchData);
+ IMPL_PTR_TYPE(YUMPatchesData);
IMPL_PTR_TYPE(YUMProductData);
IMPL_PTR_TYPE(YUMPatchPackage);
IMPL_PTR_TYPE(YUMPatchScript);
return out;
}
+ostream& operator<<(ostream &out, const YUMPatchesData& data)
+{
+ out << "-------------------------------------------------" << endl
+ << "Patches Entry Data: " << endl
+ << " patch ID: " << data.id << endl
+ << " location: " << data.location << endl
+ << " checksumType: '" << data.checksumType << "'" << endl
+ << " checksum: '" << data.checksum << "'" << endl;
+ return out;
+}
+
ostream& operator<<(ostream &out, const YUMProductData& data)
{
out << "-------------------------------------------------" << endl
DEFINE_PTR_TYPE( YUMFileListData );
DEFINE_PTR_TYPE( YUMOtherData );
DEFINE_PTR_TYPE( YUMPatchData );
+ DEFINE_PTR_TYPE( YUMPatchesData );
DEFINE_PTR_TYPE( YUMProductData );
DEFINE_PTR_TYPE( YUMPatchPackage );
DEFINE_PTR_TYPE( YUMPatchScript );
std::list<shared_ptr<YUMPatchAtom> > atoms;
};
+ class YUMPatchesData : public base::ReferenceCounted, private base::NonCopyable {
+ public:
+ YUMPatchesData() {};
+ ~YUMPatchesData() {};
+
+ std::string location;
+ std::string id;
+ std::string checksumType;
+ std::string checksum;
+ };
+
class YUMProductData : public YUMObjectData {
public:
YUMProductData() {};
std::ostream& operator<<(std::ostream &out, const zypp::parser::yum::YUMFileListData& data);
std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMOtherData& data);
std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchData& data);
+std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchesData& data);
std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMProductData& data);
std::ostream& operator<<(std::ostream& out, const shared_ptr<zypp::parser::yum::YUMPatchAtom> data);
std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchMessage& data);
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/yum/YUMPatchesParser.cc
+ *
+*/
+
+#include <zypp/parser/yum/YUMPatchesParser.h>
+#include <zypp/parser/yum/YUMPrimaryParser.h>
+#include <istream>
+#include <string>
+#include <cassert>
+#include <libxml/xmlreader.h>
+#include <libxml/tree.h>
+#include <zypp/parser/LibXMLHelper.h>
+#include <zypp/base/Logger.h>
+#include <zypp/parser/yum/schemanames.h>
+
+using namespace std;
+namespace zypp {
+ namespace parser {
+ namespace yum {
+
+ YUMPatchesParser::~YUMPatchesParser()
+ { }
+
+ YUMPatchesParser::YUMPatchesParser(istream &is, const string& baseUrl)
+ : XMLNodeIterator<YUMPatchesData_Ptr>(is, baseUrl,PATCHESSCHEMA)
+ {
+ fetchNext();
+ }
+
+ YUMPatchesParser::YUMPatchesParser()
+ { }
+
+ YUMPatchesParser::YUMPatchesParser(YUMPatchesData_Ptr& entry)
+ : XMLNodeIterator<YUMPatchesData_Ptr>(entry)
+ { }
+
+
+ // select for which elements process() will be called
+ bool
+ YUMPatchesParser::isInterested(const xmlNodePtr nodePtr)
+ {
+ return _helper.isElement(nodePtr) && _helper.name(nodePtr) == "patch";
+ }
+
+ // do the actual processing
+ YUMPatchesData_Ptr
+ YUMPatchesParser::process(const xmlTextReaderPtr reader)
+ {
+ assert(reader);
+ YUMPatchesData_Ptr patchPtr = new YUMPatchesData;
+ xmlNodePtr dataNode = xmlTextReaderExpand(reader);
+ assert(dataNode);
+
+ patchPtr->id = _helper.attribute(dataNode,"id");
+
+ for (xmlNodePtr child = dataNode->children;
+ child && child != dataNode;
+ child = child->next) {
+ if (_helper.isElement(child)) {
+ string name = _helper.name(child);
+ if (name == "location") {
+ patchPtr->location = _helper.attribute(child,"href");
+ }
+ else if (name == "checksum") {
+ patchPtr->checksumType = _helper.attribute(child,"type");
+ patchPtr->checksum = _helper.content(child);
+ }
+ else {
+ WAR << "YUM <data> contains the unknown element <" << name << "> "
+ << _helper.positionInfo(child) << ", skipping" << endl;
+ }
+ }
+ }
+ return patchPtr;
+ } /* end process */
+
+
+ } // namespace yum
+ } // namespace parser
+} // namespace zypp
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/yum/YUMPatchesParser.h
+ *
+*/
+
+
+
+#ifndef YUMPatchesParser_h
+#define YUMPatchesParser_h
+
+#include <zypp/parser/yum/YUMParserData.h>
+#include <zypp/parser/XMLNodeIterator.h>
+#include <zypp/parser/LibXMLHelper.h>
+#include <list>
+
+namespace zypp {
+ namespace parser {
+ namespace yum {
+
+ /**
+ * @short Parser for YUM primary.xml files (containing package metadata)
+ * Use this class as an iterator that produces, one after one,
+ * YUMPatchesData_Ptr(s) for the XML package elements in the input.
+ * Here's an example:
+ *
+ * for (YUMPatchesParser iter(anIstream, baseUrl),
+ * iter != YUMOtherParser.end(), // or: iter() != 0, or ! iter.atEnd()
+ * ++iter) {
+ * doSomething(*iter)
+ * }
+ *
+ * The iterator owns the pointer (i.e., caller must not delete it)
+ * until the next ++ operator is called. At this time, it will be
+ * destroyed (and a new ENTRYTYPE is created.)
+ *
+ * If the input is fundamentally flawed so that it makes no sense to
+ * continue parsing, XMLNodeIterator will log it and consider the input as finished.
+ * You can query the exit status with errorStatus().
+ */
+ class YUMPatchesParser : public XMLNodeIterator<YUMPatchesData_Ptr>
+ {
+ public:
+ YUMPatchesParser(std::istream &is, const std::string &baseUrl);
+ YUMPatchesParser();
+ YUMPatchesParser(YUMPatchesData_Ptr& entry);
+ virtual ~YUMPatchesParser();
+
+ private:
+ virtual bool isInterested(const xmlNodePtr nodePtr);
+ virtual YUMPatchesData_Ptr process(const xmlTextReaderPtr reader);
+ LibXMLHelper _helper;
+ };
+ } // namespace yum
+ } // namespace parser
+} // namespace zypp
+
+#endif
--- /dev/null
+default namespace = "http://novell.com/package/metadata/suse/patches"
+
+element patches
+ {
+ element patch {
+ attribute id { text }&
+ element location {
+ attribute xml:base { xsd:anyURI }?,
+ attribute href { xsd:anyURI }
+ }&
+ element checksum {
+ attribute type { "md5" | "sha" },
+ text
+ }
+ }*
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<element name="patches" ns="http://novell.com/package/metadata/suse/patches" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+ <zeroOrMore>
+ <element name="patch">
+ <interleave>
+ <attribute name="id"/>
+ <element name="location">
+ <optional>
+ <attribute name="xml:base">
+ <data type="anyURI"/>
+ </attribute>
+ </optional>
+ <attribute name="href">
+ <data type="anyURI"/>
+ </attribute>
+ </element>
+ <element name="checksum">
+ <attribute name="type">
+ <choice>
+ <value>md5</value>
+ <value>sha</value>
+ </choice>
+ </attribute>
+ <text/>
+ </element>
+ </interleave>
+ </element>
+ </zeroOrMore>
+</element>
<element name="entry">
<attribute name="name"/>
<optional>
+ <attribute name="kind">
+ <choice>
+ <value>package</value>
+ <value>patch</value>
+ <value>script</value>
+ <value>message</value>
+ <value>product</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
<attribute name="flags">
<choice>
<value>EQ</value>
<element name="entry">
<attribute name="name"/>
<optional>
+ <attribute name="kind">
+ <choice>
+ <value>package</value>
+ <value>patch</value>
+ <value>script</value>
+ <value>message</value>
+ <value>product</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
<attribute name="flags">
<choice>
<value>EQ</value>
<element name="entry">
<attribute name="name"/>
<optional>
+ <attribute name="kind">
+ <choice>
+ <value>package</value>
+ <value>patch</value>
+ <value>script</value>
+ <value>message</value>
+ <value>product</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
<attribute name="flags">
<choice>
<value>EQ</value>
element repomd {
element data {
- attribute type { "other" | "filelists" | "primary" }&
+ attribute type { "other" | "filelists" | "primary" | "group" | "product" | "patches" }&
element location {
attribute xml:base { xsd:anyURI }?,
attribute href { xsd:anyURI },
<value>other</value>
<value>filelists</value>
<value>primary</value>
+ <value>group</value>
+ <value>product</value>
+ <value>patches</value>
</choice>
</attribute>
<element name="location">
#define FILELISTSCHEMA (SCHEMABASE "filelists.rng")
#define OTHERSCHEMA (SCHEMABASE "other.rng")
#define PATCHSCHEMA (SCHEMABASE "patch.rng")
+ #define PATCHESSCHEMA (SCHEMABASE "patches.rng")
#define PRODUCTSCHEMA (SCHEMABASE "product.rng")
} // namespace yum
} // namespace parser