From: Klaus Kaempf Date: Sun, 2 Apr 2006 20:14:05 +0000 (+0000) Subject: skip incompatible archs X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~1234 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85cb7a60799a57275159778f702dfae063e129b4;p=platform%2Fupstream%2Flibzypp.git skip incompatible archs --- diff --git a/zypp/parser/yum/YUMPrimaryParser.cc b/zypp/parser/yum/YUMPrimaryParser.cc index 2c0313e..8bdf518 100644 --- a/zypp/parser/yum/YUMPrimaryParser.cc +++ b/zypp/parser/yum/YUMPrimaryParser.cc @@ -20,7 +20,7 @@ #include #include #include - +#include using namespace std; namespace zypp { @@ -30,6 +30,7 @@ namespace zypp { YUMPrimaryParser::YUMPrimaryParser(istream &is, const string& baseUrl) : XMLNodeIterator(is, baseUrl,PRIMARYSCHEMA) + , _zypp_architecture( getZYpp()->architecture() ) { if (is.fail()) { ERR << "Bad stream" << endl; @@ -38,10 +39,12 @@ namespace zypp { } YUMPrimaryParser::YUMPrimaryParser() + : _zypp_architecture( getZYpp()->architecture() ) { } YUMPrimaryParser::YUMPrimaryParser(YUMPrimaryData_Ptr& entry) : XMLNodeIterator(entry) + , _zypp_architecture( getZYpp()->architecture() ) { } @@ -76,7 +79,8 @@ namespace zypp { for (xmlNodePtr child = dataNode->children; child != 0; - child = child->next) { + child = child->next) + { if (_helper.isElement(child)) { string name = _helper.name(child); if (name == "name") { @@ -84,6 +88,18 @@ namespace zypp { } else if (name == "arch") { dataPtr->arch = _helper.content(child); + try { + if (!Arch(dataPtr->arch).compatibleWith( _zypp_architecture )) { + dataPtr = NULL; // skip , incompatible architecture + break; + } + } + catch( const Exception & excpt_r ) { + ZYPP_CAUGHT( excpt_r ); + DBG << "Skipping malformed " << dataPtr->arch << endl; + dataPtr = NULL; + break; + } } else if (name == "version") { dataPtr->epoch = _helper.attribute(child,"epoch"); @@ -137,6 +153,7 @@ namespace zypp { YUMPrimaryParser::parseFormatNode(YUMPrimaryData_Ptr dataPtr, xmlNodePtr formatNode) { + if (dataPtr == NULL) return; // skipping xml_assert(formatNode); dataPtr->installOnly = false; for (xmlNodePtr child = formatNode->children; diff --git a/zypp/parser/yum/YUMPrimaryParser.h b/zypp/parser/yum/YUMPrimaryParser.h index e994118..c39814a 100644 --- a/zypp/parser/yum/YUMPrimaryParser.h +++ b/zypp/parser/yum/YUMPrimaryParser.h @@ -18,6 +18,7 @@ #include #include #include +#include #include namespace zypp { @@ -71,6 +72,7 @@ namespace zypp { xmlNodePtr node); LibXMLHelper _helper; + Arch _zypp_architecture; }; } // namespace yum } // namespace parser diff --git a/zypp/source/yum/YUMSourceImpl.cc b/zypp/source/yum/YUMSourceImpl.cc index fbba3f9..64b9fca 100644 --- a/zypp/source/yum/YUMSourceImpl.cc +++ b/zypp/source/yum/YUMSourceImpl.cc @@ -416,7 +416,9 @@ namespace zypp !prim.atEnd(); ++prim) { - MIL << "found package "<< (*prim)->name << std::endl; + if (*prim == NULL) continue; // incompatible arch detected during parsing + +// MIL << "found package "<< (*prim)->name << std::endl; Arch arch; if (!(*prim)->arch.empty()) @@ -446,7 +448,7 @@ namespace zypp ); ImplAndPackage iap = { impl, p }; _package_impl[nvra] = iap; - MIL << "inserting package "<< p->name() << std::endl; +// MIL << "inserting package "<< p->name() << std::endl; _store.insert (p); } if (prim.errorStatus())