PatchFileReader.cc

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #include "zypp/base/Logger.h"
00013 #include "zypp/parser/xml/Reader.h"
00014 #include "zypp/data/ResolvableData.h"
00015 
00016 #include "zypp/parser/yum/PatchFileReader.h"
00017 #include "zypp/parser/yum/FileReaderBaseImpl.h"
00018 
00019 #include "zypp/ZConfig.h"
00020 
00021 #undef ZYPP_BASE_LOGGER_LOGGROUP
00022 #define ZYPP_BASE_LOGGER_LOGGROUP "parser::yum"
00023 
00024 using namespace std;
00025 using namespace zypp::xml;
00026 
00027 namespace zypp
00028 {
00029   namespace parser
00030   {
00031     namespace yum
00032     {
00033 
00034 
00036   //
00037   //  CLASS NAME : PatchFileReader::Impl
00038   //
00039   class PatchFileReader::Impl : public BaseImpl
00040   {
00041   public:
00043     Impl(const Pathname & patch_file,
00044          const ProcessPatch & callback);
00045 
00054     bool consumeNode(xml::Reader & reader_r);
00055 
00063     bool consumeAtomsNode(xml::Reader & reader_r);
00064 
00074     bool consumePackageNode(xml::Reader & reader_r);
00075 
00083     bool consumePatchrpmNode(xml::Reader & reader_r);
00084 
00092     bool consumeDeltarpmNode(xml::Reader & reader_r);
00093 
00101     bool consumeMessageNode(xml::Reader & reader_r);
00102 
00110     bool consumeScriptNode(xml::Reader & reader_r);
00111 
00117     data::Patch_Ptr handoutPatch();
00118 
00124     void saveAtomInPatch();
00125 
00129     void copyPackageAtomFromTmpObj(data::Atom_Ptr & atom_ptr) const;
00130 
00131   private:
00135     ProcessPatch _callback;
00136 
00141     data::Patch_Ptr _patch;
00142 
00149     data::ResObject_Ptr _tmpResObj;
00150 
00152     data::PatchRpm_Ptr _patchrpm;
00153 
00155     data::DeltaRpm_Ptr _deltarpm;
00156   };
00158 
00159   PatchFileReader::Impl::Impl(
00160       const Pathname & patch_file,
00161       const ProcessPatch & callback)
00162     :
00163       _callback(callback)
00164   {
00165     Reader reader(patch_file);
00166     MIL << "Reading " << patch_file << endl;
00167     reader.foreachNode(bind(&PatchFileReader::Impl::consumeNode, this, _1));
00168   }
00169 
00170   // --------------------------------------------------------------------------
00171 
00172   /*
00173    * xpath and multiplicity of processed nodes are included in the code
00174    * for convenience:
00175    *
00176    * // xpath: <xpath> (?|*|+)
00177    *
00178    * if multiplicity is ommited, then the node has multiplicity 'one'.
00179    */
00180 
00181   // --------------------------------------------------------------------------
00182 
00183   bool PatchFileReader::Impl::consumeNode(Reader & reader_r)
00184   {
00185     if (isBeingProcessed(tag_atoms) && consumeAtomsNode(reader_r))
00186       return true;
00187 
00188     if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
00189     {
00190       // xpath: /patch
00191       if (reader_r->name() == "patch")
00192       {
00193         tag(tag_patch);
00194 
00195         _patch = new data::Patch;
00196 
00197         _patch->id = reader_r->getAttribute("patchid").asString();
00198         _patch->timestamp = Date(reader_r->getAttribute("timestamp").asString());
00199         // reader_r->getAttribute("timestamp").asString() ?
00200         return true;
00201       }
00202 
00203       // xpath: /patch/yum:name
00204       if (reader_r->name() == "yum:name")
00205       {
00206         _patch->name = reader_r.nodeText().asString();
00207         return true;
00208       }
00209 
00210       // xpath: /patch/summary
00211       if (reader_r->name() == "summary")
00212       {
00213         Locale locale(reader_r->getAttribute("lang").asString());
00214         _patch->summary.setText(reader_r.nodeText().asString(), locale);
00215         return true;
00216       }
00217 
00218       // xpath: /patch/description
00219       if (reader_r->name() == "description")
00220       {
00221         Locale locale(reader_r->getAttribute("lang").asString());
00222         _patch->description.setText(reader_r.nodeText().asString(), locale);
00223         return true;
00224       }
00225 
00226       // xpath: /patch/licence-to-confirm (*)
00227       if (reader_r->name() == "license-to-confirm")
00228       {
00229         // TODO support several licenses in several languages?
00230         Locale locale(reader_r->getAttribute("lang").asString());
00231         _patch->licenseToConfirm.setText(reader_r.nodeText().asString(), locale);
00232         return true;
00233       }
00234 
00235       // xpath: /patch/yum:version
00236       if (reader_r->name() == "yum:version")
00237       {
00238         _patch->edition = Edition(reader_r->getAttribute("ver").asString(),
00239                                   reader_r->getAttribute("rel").asString(),
00240                                   reader_r->getAttribute("epoch").asString());
00241         return true;
00242       }
00243 
00244       // dependency block nodes
00245       if (consumeDependency(reader_r, _patch->deps))
00246         return true;
00247 
00248       // xpath: /patch/category
00249       if (reader_r->name() == "category")
00250       {
00251         _patch->category = reader_r.nodeText().asString();
00252         return true;
00253       }
00254 
00255       // xpath: /patch/reboot-needed (?)
00256       if (reader_r->name() == "reboot-needed")
00257       {
00258         _patch->rebootNeeded = true;
00259         return true;
00260       }
00261 
00262       // xpath: /patch/package-manager (?)
00263       if (reader_r->name() == "package-manager")
00264       {
00265         _patch->affectsPkgManager = true;
00266         return true;
00267       }
00268 
00269       // xpath: /patch/update-script (?)
00270       if (reader_r->name() == "update-script")
00271       {
00272         _patch->updateScript = reader_r.nodeText().asString();
00273       }
00274 
00275       // xpath: /patch/atoms (+)
00276       if (reader_r->name() == "atoms")
00277       {
00278         // remember that we are processing atoms from now on
00279         // xpath: /patch/atoms/*
00280         tag(tag_atoms);
00281         // no need to further process this node so not calling
00282         // consumeAtomsNode() here
00283         return true;
00284       }
00285     }
00286     else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
00287     {
00288       // xpath: /patch
00289       if (reader_r->name() == "patch")
00290       {
00291         if (!_patch->atoms.size())
00292           WAR << "No atoms found for patch " << _patch->name << " " << _patch->edition << endl;
00293 
00294         if (_callback)
00295           _callback(handoutPatch());
00296 
00297         toParentTag(); // just for the case of reuse somewhere/sometimes
00298 
00299         return true;
00300       }
00301     }
00302 
00303     return true;
00304   }
00305 
00306   // --------------------------------------------------------------------------
00307 
00308   bool PatchFileReader::Impl::consumeAtomsNode(Reader & reader_r)
00309   {
00310     /*
00311        Implementation note:
00312 
00313        !!! do _NOT_ filter out incompatible architectures of atoms !!!
00314 
00315        See https://bugzilla.novell.com/show_bug.cgi?id=300569#c11
00316      */
00317 
00318     // consumePackageNode
00319     if (isBeingProcessed(tag_package) && consumePackageNode(reader_r))
00320       return true;
00321     // consumeMessageNode
00322     else if (isBeingProcessed(tag_message) && consumeMessageNode(reader_r))
00323       return true;
00324     // consumeScriptNode
00325     else if (isBeingProcessed(tag_script) && consumeScriptNode(reader_r))
00326       return true;
00327 
00328 
00329     if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
00330     {
00331       // xpath: /patch/atoms/package
00332       if (reader_r->name() == "package")
00333       {
00334         // remember that we are processing package from now on
00335         // xpath: /patch/atoms/package/*
00336         tag(tag_package);
00337         // DBG << "Atom node, tagpath: " << tagPath() << endl;
00338         _tmpResObj = new data::PackageAtom;
00339         // process also the package node attributes
00340         consumePackageNode(reader_r);
00341         return true;
00342       }
00343 
00344       // xpath: /patch/atoms/message
00345       if (reader_r->name() == "message")
00346       {
00347         // remember that we are processing message from now on
00348         // xpath: /patch/atoms/message/*
00349         tag(tag_message);
00350         // DBG << "Message node, tagpath: " << tagPath() << endl;
00351         _tmpResObj = new data::Message;
00352         return true;
00353       }
00354 
00355       // xpath: /patch/atoms/script
00356       if (reader_r->name() == "script")
00357       {
00358         // remember that we are processing script from now on
00359         // xpath: /patch/atoms/script/*
00360         tag(tag_script);
00361         // DBG << "Script node, tagpath: " << tagPath() << endl;
00362         _tmpResObj = new data::Script;
00363         return true;
00364       }
00365     }
00366     else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
00367     {
00368       // xpath: /patch/atoms/package
00369       if (reader_r->name() == "package")
00370       {
00371         // DBG << "Atom " << _tmpResObj->name << " " << _tmpResObj->edition << " successfully read." << endl;
00372 
00373         saveAtomInPatch();
00374         toParentTag(); // back to processing of previous tag (atoms)
00375         return true;
00376       }
00377 
00378       // xpath: /patch/atoms/message
00379       if (reader_r->name() == "message")
00380       {
00381         // DBG << "Message " << _tmpResObj->name << " " << _tmpResObj->edition << " successfully read." << endl;
00382 
00383         saveAtomInPatch();
00384         toParentTag(); // back to processing of previous tag (atoms)
00385         return true;
00386       }
00387 
00388       // xpath: /patch/atoms/script
00389       if (reader_r->name() == "script")
00390       {
00391         // DBG << "Script " << _tmpResObj->name << " " << _tmpResObj->edition << " successfully read." << endl;
00392 
00393         saveAtomInPatch();
00394         toParentTag(); // back to processing of previous tag (atoms)
00395         return true;
00396       }
00397 
00398       // xpath: /patch/atoms
00399       if (reader_r->name() == "atoms")
00400       {
00401         toParentTag(); // back to processing of previous tag (patch)
00402         return true;
00403       }
00404     }
00405 
00406     return true;
00407   }
00408 
00409   // --------------------------------------------------------------------------
00410 
00411   bool PatchFileReader::Impl::consumePackageNode(Reader & reader_r)
00412   {
00413     /*
00414        Implementation note:
00415 
00416        !!! do _NOT_ filter out incompatible architectures of atoms !!!
00417 
00418        See https://bugzilla.novell.com/show_bug.cgi?id=300569#c11
00419      */
00420 
00421     if (isBeingProcessed(tag_patchrpm) && consumePatchrpmNode(reader_r))
00422       return true;
00423     else if (isBeingProcessed(tag_deltarpm) && consumeDeltarpmNode(reader_r))
00424       return true;
00425 
00426     if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
00427     {
00428       // xpath: /patch/atoms/package/pkgfiles
00429       if (reader_r->name() == "pkgfiles")
00430       {
00431         tag(tag_pkgfiles);
00432         return true;
00433       }
00434 
00435       // xpath: /patch/atoms/package/pkgfiles/patchrpm (*)
00436       if (reader_r->name() == "patchrpm")
00437       {
00438         tag(tag_patchrpm);
00439         _patchrpm = new data::PatchRpm;
00440         return true;
00441       }
00442 
00443       // xpath: /patch/atoms/package/pkgfiles/deltarpm (*)
00444       if (reader_r->name() == "deltarpm")
00445       {
00446         tag(tag_deltarpm);
00447         _deltarpm = new data::DeltaRpm;
00448         return true;
00449       }
00450 
00451       // xpath: /patch/atoms/package/license-to-confirm (*)
00452       if (reader_r->name() == "license-to-confirm")
00453       {
00454         DBG << "got license-to-confirm, lang: " << reader_r->getAttribute("lang").asString();
00455 
00456         // no way to determine which translation is associated
00457         // with another, all previous will be overwritten with
00458         // the last one
00459         // TODO introduce an identifier in YUM data
00460         // TODO make this rely on tag order as a temporary solution?
00461 
00462         _tmpResObj->licenseToConfirm.setText(
00463             reader_r.nodeText().asString(),
00464             Locale(reader_r->getAttribute("lang").asString()));
00465 
00466         return true;
00467       }
00468     }
00469 
00470     else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
00471     {
00472       // xpath: /patch/atoms/package/pkgfiles
00473       if (reader_r->name() == "pkgfiles")
00474       {
00475         toParentTag();
00476         return true;
00477       }
00478 
00479       // xpath: /patch/atoms/package/pkgfiles/patchrpm (*)
00480       if (reader_r->name() == "patchrpm")
00481       {
00482         data::PatchRpm_Ptr tmp;
00483         tmp.swap(_patchrpm);
00484         data::PackageAtom_Ptr patom_ptr = zypp::dynamic_pointer_cast<data::PackageAtom>(_tmpResObj);
00485         if (patom_ptr && patom_ptr->arch.compatibleWith( ZConfig::instance().systemArchitecture() ))
00486         {
00487           // Patch and delta rpms are standalone objects.
00488           // We must store the target packages NVRA.
00489           // We don't store incompatible archs.
00490           tmp->name    = patom_ptr->name;
00491           tmp->edition = patom_ptr->edition;
00492           tmp->arch    = patom_ptr->arch;
00493           patom_ptr->patchRpms.insert(tmp);
00494         }
00495         toParentTag();
00496         return true;
00497       }
00498 
00499       // xpath: /patch/atoms/package/pkgfiles/deltarpm (*)
00500       if (reader_r->name() == "deltarpm")
00501       {
00502         data::DeltaRpm_Ptr tmp;
00503         tmp.swap(_deltarpm);
00504         data::PackageAtom_Ptr patom_ptr = zypp::dynamic_pointer_cast<data::PackageAtom>(_tmpResObj);
00505         if (patom_ptr && patom_ptr->arch.compatibleWith( ZConfig::instance().systemArchitecture() ))
00506         {
00507           // Patch and delta rpms are standalone objects.
00508           // We must store the target packages NVRA.
00509           // We don't store incompatible archs.
00510           tmp->name    = patom_ptr->name;
00511           tmp->edition = patom_ptr->edition;
00512           tmp->arch    = patom_ptr->arch;
00513           patom_ptr->deltaRpms.insert(tmp);
00514         }
00515         toParentTag();
00516         return true;
00517       }
00518     }
00519 
00520     // FileReaderBase::consumePackageNode() call here, otherwise the pkgfiles
00521     // would not be read.
00522     data::Packagebase_Ptr package_ptr = zypp::dynamic_pointer_cast<data::Packagebase>(_tmpResObj);
00523     if (package_ptr)
00524     {
00525       // xpath: /patch/atoms/package/* (except pkgfiles/* and license-to-confirm) (*)
00526       if (isBeingProcessed(tag_package))
00527         return FileReaderBase::BaseImpl::consumePackageNode(reader_r, package_ptr);
00528     }
00529     else
00530     {
00531       ZYPP_THROW(Exception("Error in parser code. Package atom object not found."));
00532     }
00533 
00534     return true;
00535   }
00536 
00537   // --------------------------------------------------------------------------
00538 
00539   bool PatchFileReader::Impl::consumePatchrpmNode(Reader & reader_r)
00540   {
00541     if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
00542     {
00543       // xpath: /patch/atoms/package/patchrpm/location
00544       if (reader_r->name() == "location")
00545       {
00546         _patchrpm->location.setLocation(reader_r->getAttribute("href").asString(), 1);
00547         // ignoring attribute 'base'
00548         return true;
00549       }
00550 
00551       // xpath: /patch/atoms/package/patchrpm/checksum
00552       if (reader_r->name() == "checksum")
00553       {
00554         _patchrpm->location.setChecksum(CheckSum(
00555                   reader_r->getAttribute("type").asString(),
00556                   reader_r.nodeText().asString()));
00557         return true;
00558       }
00559 
00560       // xpath: /patch/atoms/package/patchrpm/time
00561       if (reader_r->name() == "time")
00562       {
00563         _patchrpm->buildTime =
00564             Date(reader_r->getAttribute("build").asString());
00565 
00566         _patchrpm->fileTime =
00567             Date(reader_r->getAttribute("file").asString());
00568 
00569         return true;
00570       }
00571 
00572       // xpath: /patch/atoms/package/patchrpm/size
00573       if (reader_r->name() == "size")
00574       {
00575         // size of the rpm file
00576         _patchrpm->location.setDownloadSize(str::strtonum<ByteCount::SizeType>(
00577             reader_r->getAttribute("package").asString()));
00578 
00579         // size of ??
00580         _patchrpm->archiveSize = str::strtonum<ByteCount::SizeType>(
00581             reader_r->getAttribute("archive").asString());
00582 
00583         return true;
00584       }
00585 
00586       // xpath: /patch/atoms/package/patchrpm/base-version (+)
00587       if (reader_r->name() == "base-version")
00588       {
00589         data::BaseVersion_Ptr base_ptr = new data::BaseVersion;
00590 
00591         // size of the rpm file
00592         base_ptr->edition = Edition(reader_r->getAttribute("ver").asString(),
00593                                     reader_r->getAttribute("rel").asString(),
00594                                     reader_r->getAttribute("epoch").asString());
00595 
00596         _patchrpm->baseVersions.insert(base_ptr);
00597         return true;
00598       }
00599     }
00600 
00601     else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
00602     {
00603       // xpath: /patch/atoms/package/pkgfiles/patchrpm
00604       if (reader_r->name() == "patchrpm")
00605       {
00606         return false;
00607       }
00608     }
00609 
00610     return true;
00611   }
00612 
00613   // --------------------------------------------------------------------------
00614 
00615   bool PatchFileReader::Impl::consumeDeltarpmNode(Reader & reader_r)
00616   {
00617     if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
00618     {
00619       // xpath: /patch/atoms/package/deltarpm/location
00620       if (reader_r->name() == "location")
00621       {
00622         _deltarpm->location.setLocation(reader_r->getAttribute("href").asString(), 1);
00623         // ignoring attribute 'base'
00624         return true;
00625       }
00626 
00627       // xpath: /patch/atoms/package/deltarpm/checksum
00628       if (reader_r->name() == "checksum")
00629       {
00630         _deltarpm->location.setChecksum(CheckSum(
00631                   reader_r->getAttribute("type").asString(),
00632                   reader_r.nodeText().asString()));
00633         return true;
00634       }
00635 
00636       // xpath: /patch/atoms/package/deltarpm/time
00637       if (reader_r->name() == "time")
00638       {
00639         _deltarpm->buildTime =
00640             Date(reader_r->getAttribute("build").asString());
00641 
00642         _deltarpm->fileTime =
00643             Date(reader_r->getAttribute("file").asString());
00644 
00645         return true;
00646       }
00647 
00648       // xpath: /patch/atoms/package/deltarpm/size
00649       if (reader_r->name() == "size")
00650       {
00651         // size of the rpm file
00652         _deltarpm->location.setDownloadSize(str::strtonum<ByteCount::SizeType>(
00653             reader_r->getAttribute("package").asString()));
00654 
00655         // size of ??
00656         _deltarpm->archiveSize = str::strtonum<ByteCount::SizeType>(
00657             reader_r->getAttribute("archive").asString());
00658 
00659         return true;
00660       }
00661 
00662       // xpath: /patch/atoms/package/deltarpm/base-version
00663       if (reader_r->name() == "base-version")
00664       {
00665         // size of the rpm file
00666         _deltarpm->baseVersion.edition = Edition(reader_r->getAttribute("ver").asString(),
00667                                     reader_r->getAttribute("rel").asString(),
00668                                     reader_r->getAttribute("epoch").asString());
00669         // checksum
00670         _deltarpm->baseVersion.checkSum =
00671             CheckSum("md5", reader_r->getAttribute("md5sum").asString());
00672 
00673         // build time
00674         _deltarpm->baseVersion.buildTime =
00675             Date(reader_r->getAttribute("buildtime").asString());
00676 
00677         // sequence info
00678         _deltarpm->baseVersion.sequenceInfo =
00679             reader_r->getAttribute("sequence_info").asString();
00680 
00681         return true;
00682       }
00683     }
00684 
00685     else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
00686     {
00687       // xpath: /patch/atoms/package/pkgfiles/deltarpm
00688       if (reader_r->name() == "deltarpm")
00689       {
00690         return false;
00691       }
00692     }
00693 
00694     return true;
00695   }
00696 
00697   // --------------------------------------------------------------------------
00698 
00699   bool PatchFileReader::Impl::consumeMessageNode(Reader & reader_r)
00700   {
00701     if (consumeDependency(reader_r, _tmpResObj->deps))
00702       return true;
00703 
00704     if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
00705     {
00706       // xpath: /patch/atoms/message/yum:name
00707       if (reader_r->name() == "yum:name")
00708       {
00709         _tmpResObj->name = reader_r.nodeText().asString();
00710         return true;
00711       }
00712 
00713       // xpath: /patch/atoms/message/yum:name
00714       if (reader_r->name() == "yum:version")
00715       {
00716         _tmpResObj->edition = Edition(reader_r->getAttribute("ver").asString(),
00717                                     reader_r->getAttribute("rel").asString(),
00718                                     reader_r->getAttribute("epoch").asString());
00719         return true;
00720       }
00721 
00722       // xpath: /patch/atoms/message//text
00723       if (reader_r->name() == "text")
00724       {
00725         data::Message_Ptr message = dynamic_pointer_cast<data::Message>(_tmpResObj);
00726         if (message)
00727           message->text.setText(
00728               reader_r.nodeText().asString(),
00729               Locale(reader_r->getAttribute("lang").asString()));
00730         return true;
00731       }
00732     }
00733 
00734     else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
00735     {
00736       // xpath: /patch/atoms/message
00737       if (reader_r->name() == "message")
00738       {
00739         return false;
00740       }
00741     }
00742 
00743     return true;
00744   }
00745 
00746   // --------------------------------------------------------------------------
00747 
00748   bool PatchFileReader::Impl::consumeScriptNode(Reader & reader_r)
00749   {
00750     if (consumeDependency(reader_r, _tmpResObj->deps))
00751       return true;
00752 
00753     if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
00754     {
00755       data::Script_Ptr script = dynamic_pointer_cast<data::Script>(_tmpResObj);
00756       if (!script)
00757       {
00758         WAR << "data::Script object expected, but not found" << endl;
00759         return true;
00760       }
00761 
00762       // xpath: /patch/atoms/script/yum:name
00763       if (reader_r->name() == "yum:name")
00764       {
00765         _tmpResObj->name = reader_r.nodeText().asString();
00766         return true;
00767       }
00768 
00769       // xpath: /patch/atoms/script/yum:version
00770       if (reader_r->name() == "yum:version")
00771       {
00772         _tmpResObj->edition = Edition(reader_r->getAttribute("ver").asString(),
00773                                     reader_r->getAttribute("rel").asString(),
00774                                     reader_r->getAttribute("epoch").asString());
00775         return true;
00776       }
00777 
00778       // xpath: /patch/atoms/script/do
00779       if (reader_r->name() == "do")
00780       {
00781         script->doScript = reader_r.nodeText().asString();
00782         return true;
00783       }
00784 
00785       // xpath: /patch/atoms/script/undo
00786       if (reader_r->name() == "undo")
00787       {
00788         script->undoScript = reader_r.nodeText().asString();
00789         return true;
00790       }
00791 
00792       // xpath: /patch/atoms/script/do-location
00793       if (reader_r->name() == "do-location")
00794       {
00795         // xsd:anyURI do script file path base (not used)
00796         // ignoring reader_r->getAttribute("xml:base").asString();
00797 
00798         // xsd:anyURI do script file path
00799         script->doScriptLocation.setLocation(reader_r->getAttribute("href").asString(), 1);
00800         return true;
00801       }
00802 
00803       // xpath: /patch/atoms/script/do-checksum
00804       if (reader_r->name() == "do-checksum")
00805       {
00806         script->doScriptLocation.setChecksum(CheckSum(
00807                             reader_r->getAttribute("type").asString(),
00808                             reader_r.nodeText().asString()));
00809         return true;
00810       }
00811 
00812       // xpath: /patch/atoms/script/undo-location
00813       if (reader_r->name() == "undo-location")
00814       {
00815         // xsd:anyURI undo script file path base (not used)
00816         // ignoring reader_r->getAttribute("xml:base").asString();
00817 
00818         // xsd:anyURI undo script file path
00819         script->undoScriptLocation.setLocation(reader_r->getAttribute("href").asString(), 1);
00820         return true;
00821       }
00822 
00823       // xpath: /patch/atoms/script/undo-checksum
00824       if (reader_r->name() == "undo-checksum")
00825       {
00826         script->undoScriptLocation.setChecksum(CheckSum(
00827                             reader_r->getAttribute("type").asString(),
00828                             reader_r.nodeText().asString()));
00829         return true;
00830       }
00831     }
00832 
00833     else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
00834     {
00835       // xpath: /patch/atoms/script
00836       if (reader_r->name() == "script")
00837       {
00838         return false;
00839       }
00840     }
00841 
00842     return true;
00843   }
00844 
00845   // --------------------------------------------------------------------------
00846 
00847   data::Patch_Ptr PatchFileReader::Impl::handoutPatch()
00848   {
00849     data::Patch_Ptr ret;
00850     ret.swap(_patch);
00851     return ret;
00852   }
00853 
00854   // --------------------------------------------------------------------------
00855 
00856   void PatchFileReader::Impl::saveAtomInPatch()
00857   {
00858     data::ResObject_Ptr tmp;
00859     tmp.swap(_tmpResObj);
00860     _patch->atoms.insert(tmp);
00861   }
00862 
00863 
00865   //
00866   //  CLASS NAME : PatchFileReader::Impl
00867   //
00869 
00870   PatchFileReader::PatchFileReader(const Pathname & patch_file, ProcessPatch callback)
00871       : _pimpl(new PatchFileReader::Impl(patch_file, callback))
00872   {}
00873 
00874   PatchFileReader::~PatchFileReader()
00875   {}
00876 
00877 
00878     } // ns yum
00879   } // ns parser
00880 } // ns zypp
00881 
00882 // vim: set ts=2 sts=2 sw=2 et ai:

Generated on Tue Sep 25 19:23:04 2007 for libzypp by  doxygen 1.5.3