From 64a94b68e37d79199b649566a6a99c52e6bf040f Mon Sep 17 00:00:00 2001 From: Jiri Srain Date: Wed, 23 Nov 2005 14:41:18 +0000 Subject: [PATCH] parse multiple versions of a package inside the patch file --- zypp/parser/yum/YUMParserData.cc | 58 ++++++++++++++++++++++------------- zypp/parser/yum/YUMParserData.h | 63 +++++++++++++++++++++++---------------- zypp/parser/yum/YUMPatchParser.cc | 56 ++++++++++++++++++---------------- 3 files changed, 107 insertions(+), 70 deletions(-) diff --git a/zypp/parser/yum/YUMParserData.cc b/zypp/parser/yum/YUMParserData.cc index d816692..dac6db4 100644 --- a/zypp/parser/yum/YUMParserData.cc +++ b/zypp/parser/yum/YUMParserData.cc @@ -475,26 +475,9 @@ std::ostream& operator<<(std::ostream& out, const YUMPatchPackage& data) << data.files << endl << " Changelog:" << endl << data.changelog << endl - << " Plain RPM:" << endl - << " arch: " << data.plainRpm.arch << endl - << " filename: " << data.plainRpm.filename << endl - << " download size: " << data.plainRpm.downloadsize << endl - << " MD5: " << data.plainRpm.md5sum << endl - << " build time: " << data.plainRpm.buildtime << endl - << " Patch RPM:" << endl - << " arch: " << data.patchRpm.arch << endl - << " filename: " << data.patchRpm.filename << endl - << " download size: " << data.patchRpm.downloadsize << endl - << " MD5: " << data.patchRpm.md5sum << endl - << " build time: " << data.patchRpm.buildtime << endl - << data.patchRpm.baseVersions - << " Delta RPM:" << endl - << " arch: " << data.deltaRpm.arch << endl - << " filename: " << data.deltaRpm.filename << endl - << " download size: " << data.deltaRpm.downloadsize << endl - << " MD5: " << data.deltaRpm.md5sum << endl - << " build time: " << data.deltaRpm.buildtime << endl - << data.deltaRpm.baseVersion; + << data.plainRpms + << data.patchRpms + << data.deltaRpms; return out; } @@ -509,3 +492,38 @@ std::ostream& operator<<(std::ostream& out, const YUMBaseVersion& data) << " source info: " << data.source_info << endl; return out; } + +std::ostream& operator<<(std::ostream& out, const PlainRpm& data) +{ + out << " Plain RPM:" << endl + << " arch: " << data.arch << endl + << " filename: " << data.filename << endl + << " download size: " << data.downloadsize << endl + << " MD5: " << data.md5sum << endl + << " build time: " << data.buildtime << endl; + return out; +} + +std::ostream& operator<<(std::ostream& out, const PatchRpm& data) +{ + out << " Patch RPM:" << endl + << " arch: " << data.arch << endl + << " filename: " << data.filename << endl + << " download size: " << data.downloadsize << endl + << " MD5: " << data.md5sum << endl + << " build time: " << data.buildtime << endl + << data.baseVersions; + return out; +} + +std::ostream& operator<<(std::ostream& out, const DeltaRpm& data) +{ + out << " Delta RPM:" << endl + << " arch: " << data.arch << endl + << " filename: " << data.filename << endl + << " download size: " << data.downloadsize << endl + << " MD5: " << data.md5sum << endl + << " build time: " << data.buildtime << endl + << data.baseVersion << endl; + return out; +} diff --git a/zypp/parser/yum/YUMParserData.h b/zypp/parser/yum/YUMParserData.h index e477838..0b6936f 100644 --- a/zypp/parser/yum/YUMParserData.h +++ b/zypp/parser/yum/YUMParserData.h @@ -182,6 +182,36 @@ namespace zypp { virtual AtomType atomType() = 0; }; + class PlainRpm { + public: + std::string arch; + std::string filename; + std::string downloadsize; + std::string md5sum; + std::string buildtime; + }; + + class PatchRpm { + public: + std::string arch; + std::string filename; + std::string downloadsize; + std::string md5sum; + std::string buildtime; + std::list baseVersions; + }; + + class DeltaRpm { + public: + std::string arch; + std::string filename; + std::string downloadsize; + std::string md5sum; + std::string buildtime; + YUMBaseVersion baseVersion; + }; + + class YUMPatchPackage : public YUMPatchAtom { public: YUMPatchPackage() {}; @@ -219,29 +249,9 @@ namespace zypp { // Change Log std::list changelog; // Package Files - struct { - std::string arch; - std::string filename; - std::string downloadsize; - std::string md5sum; - std::string buildtime; - } plainRpm; - struct { - std::string arch; - std::string filename; - std::string downloadsize; - std::string md5sum; - std::string buildtime; - std::list baseVersions; - } patchRpm; - struct { - std::string arch; - std::string filename; - std::string downloadsize; - std::string md5sum; - std::string buildtime; - YUMBaseVersion baseVersion; - } deltaRpm; + std::list plainRpms; + std::list patchRpms; + std::list deltaRpms; }; class YUMPatchScript : public YUMPatchAtom { @@ -375,8 +385,8 @@ namespace zypp { std::string patchId; std::string timestamp; std::string engine; - MultiLang summary; - MultiLang description; + std::list summary; + std::list description; std::string category; bool rebootNeeded; bool packageManager; @@ -411,6 +421,9 @@ std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchMes std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchScript& data); std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchPackage& data); std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMBaseVersion& data); +std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::PlainRpm& data); +std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::PatchRpm& data); +std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::DeltaRpm& data); diff --git a/zypp/parser/yum/YUMPatchParser.cc b/zypp/parser/yum/YUMPatchParser.cc index fcb1930..ae1cc8a 100644 --- a/zypp/parser/yum/YUMPatchParser.cc +++ b/zypp/parser/yum/YUMPatchParser.cc @@ -78,14 +78,14 @@ namespace zypp { patchPtr->name = _helper.content(child); } else if (name == "summary") { - patchPtr->summary = MultiLang( - _helper.attribute(child,"lang"), - _helper.content(child)); + patchPtr->summary.push_back(MultiLang( + _helper.attribute(child,"lang"), + _helper.content(child))); } else if (name == "description") { - patchPtr->description = MultiLang( - _helper.attribute(child,"lang"), - _helper.content(child)); + patchPtr->description.push_back(MultiLang( + _helper.attribute(child,"lang"), + _helper.content(child))); } else if (name == "version") { patchPtr->epoch = _helper.attribute(child,"epoch"); @@ -245,11 +245,12 @@ namespace zypp { YUMPatchParser::parsePkgPlainRpmNode(YUMPatchPackage *dataPtr, xmlNodePtr formatNode) { - dataPtr->plainRpm.arch = _helper.attribute( formatNode, "arch" ); - dataPtr->plainRpm.filename = _helper.attribute( formatNode, "filename" ); - dataPtr->plainRpm.downloadsize = _helper.attribute( formatNode, "downloadsize" ); - dataPtr->plainRpm.md5sum = _helper.attribute( formatNode, "md5sum" ); - dataPtr->plainRpm.buildtime = _helper.attribute( formatNode, "buildtime" ); + PlainRpm plainRpm; + plainRpm.arch = _helper.attribute( formatNode, "arch" ); + plainRpm.filename = _helper.attribute( formatNode, "filename" ); + plainRpm.downloadsize = _helper.attribute( formatNode, "downloadsize" ); + plainRpm.md5sum = _helper.attribute( formatNode, "md5sum" ); + plainRpm.buildtime = _helper.attribute( formatNode, "buildtime" ); for (xmlNodePtr child = formatNode->children; child != 0; child = child ->next) { @@ -260,26 +261,28 @@ namespace zypp { << _helper.positionInfo(child) << ", skipping" << endl; } } + dataPtr->plainRpms.push_back(plainRpm); } void YUMPatchParser::parsePkgPatchRpmNode(YUMPatchPackage *dataPtr, xmlNodePtr formatNode) { - dataPtr->patchRpm.arch = _helper.attribute( formatNode, "arch" ); - dataPtr->patchRpm.filename = _helper.attribute( formatNode, "filename" ); - dataPtr->patchRpm.downloadsize = _helper.attribute( formatNode, "downloadsize" ); - dataPtr->patchRpm.md5sum = _helper.attribute( formatNode, "md5sum" ); - dataPtr->patchRpm.buildtime = _helper.attribute( formatNode, "buildtime" ); + PatchRpm patchRpm; + patchRpm.arch = _helper.attribute( formatNode, "arch" ); + patchRpm.filename = _helper.attribute( formatNode, "filename" ); + patchRpm.downloadsize = _helper.attribute( formatNode, "downloadsize" ); + patchRpm.md5sum = _helper.attribute( formatNode, "md5sum" ); + patchRpm.buildtime = _helper.attribute( formatNode, "buildtime" ); for (xmlNodePtr child = formatNode->children; child != 0; child = child ->next) { if (_helper.isElement(child)) { string name = _helper.name(child); if (name == "base_version") { - YUMBaseVersion base_version; - parsePkgBaseVersionNode( &base_version, child); - dataPtr->patchRpm.baseVersions.push_back( base_version ); + YUMBaseVersion base_version; + parsePkgBaseVersionNode( &base_version, child); + patchRpm.baseVersions.push_back( base_version ); } else { WAR << "YUM contains the unknown element <" @@ -288,24 +291,26 @@ namespace zypp { } } } + dataPtr->patchRpms.push_back(patchRpm); } void YUMPatchParser::parsePkgDeltaRpmNode(YUMPatchPackage *dataPtr, xmlNodePtr formatNode) { - dataPtr->deltaRpm.arch = _helper.attribute( formatNode, "arch" ); - dataPtr->deltaRpm.filename = _helper.attribute( formatNode, "filename" ); - dataPtr->deltaRpm.downloadsize = _helper.attribute( formatNode, "downloadsize" ); - dataPtr->deltaRpm.md5sum = _helper.attribute( formatNode, "md5sum" ); - dataPtr->deltaRpm.buildtime = _helper.attribute( formatNode, "buildtime" ); + DeltaRpm deltaRpm; + deltaRpm.arch = _helper.attribute( formatNode, "arch" ); + deltaRpm.filename = _helper.attribute( formatNode, "filename" ); + deltaRpm.downloadsize = _helper.attribute( formatNode, "downloadsize" ); + deltaRpm.md5sum = _helper.attribute( formatNode, "md5sum" ); + deltaRpm.buildtime = _helper.attribute( formatNode, "buildtime" ); for (xmlNodePtr child = formatNode->children; child != 0; child = child ->next) { if (_helper.isElement(child)) { string name = _helper.name(child); if (name == "base_version") { - parsePkgBaseVersionNode( &(dataPtr->deltaRpm.baseVersion), child); + parsePkgBaseVersionNode( &(deltaRpm.baseVersion), child); } else { WAR << "YUM contains the unknown element <" @@ -314,6 +319,7 @@ namespace zypp { } } } + dataPtr->deltaRpms.push_back(deltaRpm); } -- 2.7.4