snif, this is emotional for me, it was the first piece of c++ code I wrote when joining SUSE.
But the replacement is... nothing! what can be better than removing code by simplifying the concept.
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/parser/xml
)
-SET( zypp_parser_xmlstore_SRCS
- parser/xmlstore/XMLLanguageParser.cc
- parser/xmlstore/XMLParserData.cc
- parser/xmlstore/XMLPatchParser.cc
- parser/xmlstore/XMLPatternParser.cc
- parser/xmlstore/XMLProductParser.cc
- parser/xmlstore/XMLResObjectParser.cc
- parser/xmlstore/XMLSourceCacheParser.cc
-)
-
-SET( zypp_parser_xmlstore_HEADERS
- parser/xmlstore/XMLLanguageParser.h
- parser/xmlstore/XMLParserData.h
- parser/xmlstore/XMLPatchParser.h
- parser/xmlstore/XMLPatternParser.h
- parser/xmlstore/XMLProductParser.h
- parser/xmlstore/XMLResObjectParser.h
- parser/xmlstore/XMLSourceCacheParser.h
- parser/xmlstore/schemanames.h
-)
-
-INSTALL( FILES
- ${zypp_parser_xmlstore_HEADERS}
- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/parser/xmlstore
-)
-
SET( zypp_parser_yum_SRCS
parser/yum/RepoParser.cc
parser/yum/FileReaderBaseImpl.cc
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/target/rpm
)
-SET( zypp_target_store_SRCS
- target/store/Backend.cc
- target/store/PersistentStorage.cc
- target/store/XMLFilesBackend.cc
- target/store/serialize.cc
- target/store/xml_escape_parser.cpp
-)
-
-SET( zypp_target_store_HEADERS
- target/store/Backend.h
- target/store/PersistentStorage.h
- target/store/XMLFilesBackend.h
- target/store/parser_utils.hpp
- target/store/serialize.h
- target/store/xml_escape_parser.hpp
-)
-
-INSTALL( FILES
- ${zypp_target_store_HEADERS}
- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/target/store
-)
-
SET( zypp_thread_SRCS
thread/Mutex.cc
)
${zypp_cache_sqlite3x_SRCS}
${zypp_pool_SRCS}
${zypp_parser_susetags_SRCS}
-${zypp_parser_xmlstore_SRCS}
${zypp_parser_xml_SRCS}
${zypp_parser_yum_SRCS}
${zypp_parser_plaindir_SRCS}
${zypp_repo_yum_SRCS}
${zypp_repo_susetags_SRCS}
${zypp_repo_data_SRCS}
-${zypp_target_store_SRCS}
${zypp_target_rpm_SRCS}
${zypp_target_hal_SRCS}
${zypp_target_modalias_SRCS}
${zypp_cache_HEADERS}
${zypp_cache_sqlite3x_HEADERS}
${zypp_ui_HEADERS}
-${zypp_parser_xmlstore_HEADERS}
${zypp_media_HEADERS}
${zypp_target_hal_HEADERS}
${zypp_media_proxyinfo_HEADERS}
${zypp_solver_detail_HEADERS}
${zypp_sat_HEADERS}
${zypp_sat_detail_HEADERS}
-${zypp_target_store_HEADERS}
${zypp_url_HEADERS}
${zypp_HEADERS}
${zypp_zypp_detail_HEADERS}
#SET_LOGGROUP( "group" ${zypp_parser_yum2_SRCS} )
#SET_LOGGROUP( "group" ${zypp_capability_SRCS} )
#SET_LOGGROUP( "group" ${zypp_ui_SRCS} )
-#SET_LOGGROUP( "group" ${zypp_parser_xmlstore_SRCS} )
#SET_LOGGROUP( "group" ${zypp_data_SRCS} )
#SET_LOGGROUP( "group" ${zypp_media_SRCS} )
#SET_LOGGROUP( "group" ${zypp_target_hal_SRCS} )
#SET_LOGGROUP( "group" ${zypp_base_SRCS} )
#SET_LOGGROUP( "group" ${zypp_solver_detail_SRCS} )
#SET_LOGGROUP( "group" ${zypp_sat_SRCS} )
-#SET_LOGGROUP( "group" ${zypp_target_store_SRCS} )
#SET_LOGGROUP( "group" ${zypp_url_SRCS} )
#SET_LOGGROUP( "group" ${zypp_source_SRCS} )
#SET_LOGGROUP( "group" ${zypp_parser_SRCS} )
# install XML schemas
FILE( GLOB YUM_SCHEMA_FILES ${CMAKE_SOURCE_DIR}/zypp/parser/yum/schema/*.rng )
INSTALL(FILES ${YUM_SCHEMA_FILES} DESTINATION "${CMAKE_INSTALL_PREFIX}/share/zypp/schema/yum" )
-
-FILE( GLOB XMLSTORE_SCHEMA_FILES ${CMAKE_SOURCE_DIR}/zypp/parser/xmlstore/schema/*.rng )
-INSTALL(FILES ${XMLSTORE_SCHEMA_FILES} DESTINATION "${CMAKE_INSTALL_PREFIX}/share/zypp/schema/xmlstore" )
#include "zypp/base/String.h"
#include "zypp/base/Measure.h"
#include "zypp/cache/CacheInitializer.h"
-#include "zypp/target/store/PersistentStorage.h"
#include "zypp/cache/Utils.h"
#include "zypp/PathInfo.h"
#include "sqlite-schema.h"
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLLanguageParser.cc
- *
-*/
-
-#include <zypp/parser/xmlstore/XMLLanguageParser.h>
-#include <zypp/parser/xmlstore/XMLResObjectParser.h>
-
-#include <zypp/parser/LibXMLHelper.h>
-#include <istream>
-#include <string>
-#include "zypp/parser/xml_parser_assert.h"
-#include <libxml/xmlreader.h>
-#include <libxml/tree.h>
-#include <zypp/base/Logger.h>
-#include <zypp/parser/xmlstore/schemanames.h>
-
-using namespace std;
-namespace zypp {
- namespace parser {
- namespace xmlstore {
-
- XMLLanguageParser::XMLLanguageParser()
- { }
-
- XMLLanguageParser::XMLLanguageParser(XMLLanguageData_Ptr& entry)
- : XMLNodeIterator<XMLLanguageData_Ptr>(entry)
- { }
-
-
- XMLLanguageParser::~XMLLanguageParser()
- { }
-
-
- // select for which elements process() will be called
- bool
- XMLLanguageParser::isInterested(const xmlNodePtr nodePtr)
- {
- return _helper.isElement(nodePtr) && _helper.name(nodePtr) == "language";
- }
-
- // do the actual processing
- XMLLanguageData_Ptr
- XMLLanguageParser::process(const xmlTextReaderPtr reader)
- {
- xml_assert(reader);
- XMLLanguageData_Ptr dataPtr = new XMLLanguageData;
- xmlNodePtr dataNode = xmlTextReaderExpand(reader);
- xml_assert(dataNode);
-
- parseResObjectCommonData( dataPtr, dataNode);
- parseDependencies( dataPtr, dataNode);
-
-// for (xmlNodePtr child = dataNode->children; child && child != dataNode; child = child->next)
-// {
-// if (_helper.isElement(child))
-// {
-// string name = _helper.name(child);
-//
-//
-// }
-// }
- return dataPtr;
- } /* end process */
-
-
- XMLLanguageParser::XMLLanguageParser(std::istream &is, const std::string &baseUrl)
- : XMLNodeIterator<XMLLanguageData_Ptr>(is, baseUrl,LANGUAGESCHEMA)
- {
- fetchNext();
- }
-
- } // namespace yum
- } // namespace parser
-} // namespace zypp
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLLanguageParser.h
- *
-*/
-
-
-
-#ifndef XMLLanguageParser_h
-#define XMLLanguageParser_h
-
-#include <zypp/parser/xmlstore/XMLResObjectParser.h>
-#include <zypp/parser/xmlstore/XMLParserData.h>
-#include <zypp/parser/XMLNodeIterator.h>
-#include <zypp/parser/LibXMLHelper.h>
-#include <list>
-
-namespace zypp {
- namespace parser {
- namespace xmlstore {
-
- class XMLLanguageParser : public XMLNodeIterator<XMLLanguageData_Ptr>, public XMLResObjectParser
- {
- public:
- XMLLanguageParser(std::istream &is, const std::string &baseUrl);
- XMLLanguageParser();
- XMLLanguageParser(XMLLanguageData_Ptr& entry);
- virtual ~XMLLanguageParser();
-
- private:
- virtual bool isInterested(const xmlNodePtr nodePtr);
- virtual XMLLanguageData_Ptr process(const xmlTextReaderPtr reader);
-
- LibXMLHelper _helper;
- };
- } // namespace xmlstore
- } // namespace parser
-} // namespace zypp
-
-#endif
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLParserData.cc
- *
-*/
-
-#include <iostream>
-#include <zypp/parser/xmlstore/XMLParserData.h>
-
-using namespace std;
-
-namespace zypp {
- namespace parser {
- namespace xmlstore {
-
- XMLDependency::XMLDependency(const std::string& kind,
- const std::string& encoded)
- : kind(kind),
- encoded(encoded)
- { };
-
-
- XMLResObjectData::XMLResObjectData() : install_only(false)
- { }
-
- XMLPatternData::XMLPatternData() : userVisible(true)
- { }
-
- /*
- XMLPatchData::XMLPatchData()
- { }
- */
-
- /* output operators */
-
- namespace {
- /**
- * @short Generic stream output for lists of Ptrs
- * @param out the ostream where the output goes to
- * @param aList the list to output
- * @return is out
- */
- template<class T>
- ostream& operator<<(ostream &out, const list<T>& aList)
- {
- typedef typename list<T>::const_iterator IterType;
- for (IterType iter = aList.begin();
- iter != aList.end();
- ++iter) {
- if (iter != aList.begin())
- out << endl;
- operator<<(out,*iter);
- }
- return out;
- }
- }
-
- /**
- * Join a list of strings into a single string
- * @param aList the list of strings
- * @param joiner what to put between the list elements
- * @return the joined string
- */
- string join(const list<string>& aList,
- const string& joiner)
- {
- string res;
- for (list<string>::const_iterator iter = aList.begin();
- iter != aList.end();
- ++ iter) {
- if (iter != aList.begin())
- res += joiner;
- res += *iter;
- }
- return res;
- }
-
- ostream& operator<<(ostream &out, const XMLDependency& data)
- {
- if (! data.kind.empty())
- out << "[" << data.kind << "] ";
- out << data.encoded;
- return out;
- }
-
- ostream& operator<<(ostream &out, const XMLPatternData& data)
- {
- out << "-------------------------------------------------" << endl
- << "Pattern Data: " << endl
- << "name:" << data.name << endl
- << "summary: '" << data.summary << "'" << endl
- << "default: '" << data.default_ << "'" << endl
- << "user-visible: '" << data.userVisible << "'" << endl
- << "description:" << endl << data.description << endl
- << "category: " << data.category << endl
- << "icon: " << data.icon << endl
- << "script: " << data.script << endl
- << "provides:" << endl << data.provides << endl
- << "conflicts:" << endl << data.conflicts << endl
- << "obsoletes:" << endl << data.obsoletes << endl
- << "requires:" << endl << data.requires << endl
- << "recommends:" << endl << data.recommends << endl
- << "suggests:" << endl << data.suggests << endl
- << "supplements:" << endl << data.supplements << endl
- << "enhances:" << endl << data.enhances << endl
- << "freshens: " << endl << data.freshens << endl;
- return out;
- }
-
- ostream& operator<<(ostream &out, const XMLProductData& data)
- {
- out << "-------------------------------------------------" << endl
- << "Product Data: " << endl
- << " type: " << data.type << endl
- << " vendor: " << data.vendor << endl
- << " name: " << data.name << endl
- << " summary: " << data.summary << endl
- << " description: " << data.description << endl
- << " short name: " << data.short_name << endl
- << " epoch: " << data.epoch << endl
- << " version: " << data.ver << endl
- << " release: " << data.rel << endl
- << " dist_name: " << data.dist_name << endl
- << " dist_version: " << data.dist_version << endl
- << " provides: " << data.provides << endl
- << " conflicts: " << data.conflicts << endl
- << " obsoletes: " << data.obsoletes << endl
- << " freshens: " << data.freshens << endl
- << " requires: " << data.requires << endl
- << " recommends:" << endl << data.recommends << endl
- << " suggests:" << endl << data.suggests << endl
- << " supplements:" << endl << data.supplements << endl
- << " enhances:" << endl << data.enhances << endl;
- return out;
- }
-
- IMPL_PTR_TYPE(XMLResObjectData);
- IMPL_PTR_TYPE(XMLPatternData);
- IMPL_PTR_TYPE(XMLProductData);
- IMPL_PTR_TYPE(XMLLanguageData);
- IMPL_PTR_TYPE(XMLPatchData);
- IMPL_PTR_TYPE(XMLPatchAtomData);
- IMPL_PTR_TYPE(XMLPatchMessageData);
- IMPL_PTR_TYPE(XMLPatchScriptData);
-
- } // namespace xml
- } // namespace parser
-} // namespace zypp
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef XMLParserData_h
-#define XMLParserData_h
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/Pathname.h"
-#include "zypp/ByteCount.h"
-#include "zypp/Date.h"
-#include "zypp/TranslatedText.h"
-#include <string>
-#include <list>
-#include <iosfwd>
-#include <zypp/base/PtrTypes.h>
-
-using namespace zypp::base;
-
-
-namespace zypp {
- namespace parser {
- namespace xmlstore {
-
- DEFINE_PTR_TYPE(XMLResObjectData);
- DEFINE_PTR_TYPE(XMLProductData);
- DEFINE_PTR_TYPE(XMLPatternData);
- DEFINE_PTR_TYPE(XMLLanguageData);
- DEFINE_PTR_TYPE(XMLPatchData);
- DEFINE_PTR_TYPE(XMLPatchAtomData);
- DEFINE_PTR_TYPE(XMLPatchMessageData);
- DEFINE_PTR_TYPE(XMLPatchScriptData);
-
- /**
- * @short Holds dependency data
- */
- class XMLDependency {
- public:
- XMLDependency();
- XMLDependency(const std::string& kind, const std::string& encoded);
- std::string kind;
- std::string encoded;
- };
-
-
- class XMLResObjectData : public base::ReferenceCounted, private base::NonCopyable {
- public:
- XMLResObjectData();
- std::string name;
- std::string epoch;
- std::string ver;
- std::string rel;
- std::string arch;
- std::list<XMLDependency> provides;
- std::list<XMLDependency> conflicts;
- std::list<XMLDependency> obsoletes;
- std::list<XMLDependency> freshens;
- std::list<XMLDependency> requires;
- std::list<XMLDependency> prerequires;
- std::list<XMLDependency> recommends;
- std::list<XMLDependency> suggests;
- std::list<XMLDependency> supplements;
- std::list<XMLDependency> enhances;
-
- // in the future move above to XMLResolvableData
- TranslatedText summary;
- TranslatedText description;
-
- TranslatedText install_notify;
- TranslatedText delete_notify;
- TranslatedText license_to_confirm;
- std::string vendor;
- ByteCount size;
- ByteCount downloadSize;
- bool install_only;
- Date build_time;
- Date install_time;
-
- };
-
- /**
- * @short Describes the patterns in a target store
- **/
- class XMLPatternData : public XMLResObjectData
- {
- public:
- XMLPatternData();
-
- std::string default_;
- bool userVisible;
- TranslatedText category;
- std::string icon;
- std::string script;
- };
-
- class XMLLanguageData : public XMLResObjectData
- {
- public:
- XMLLanguageData() {};
- ~XMLLanguageData() {};
- };
-
- class XMLProductData : public XMLResObjectData
- {
- public:
- XMLProductData() {};
- ~XMLProductData() {};
-
- std::string parser_version;
- std::string type;
- TranslatedText short_name;
- // those are suse specific tags
- std::string releasenotesurl;
- std::list<std::string> update_urls;
- std::list<std::string> extra_urls;
- std::list<std::string> optional_urls;
- std::list<std::string> flags;
- std::string dist_name;
- std::string dist_version;
- };
-
- class XMLPatchAtomData : public XMLResObjectData
- {
- public:
- enum AtomType { Atom, Script, Message };
- virtual AtomType atomType() { return Atom; };
- };
-
- class XMLPatchScriptData : public XMLPatchAtomData
- {
- public:
- XMLPatchScriptData() {};
- virtual AtomType atomType() { return Script; };
- std::string doScript;
- std::string undoScript;
- };
-
- class XMLPatchMessageData : public XMLPatchAtomData
- {
- public:
- XMLPatchMessageData() {};
- virtual AtomType atomType() { return Message; };
- TranslatedText text;
- };
-
- class XMLPatchData : public XMLResObjectData
- {
- public:
- XMLPatchData() {};
- ~XMLPatchData()
- {
- }
-
- std::string patchId;
- std::string timestamp;
- std::string engine;
- std::string category;
- bool rebootNeeded;
- bool packageManager;
- std::string updateScript;
- std::list<XMLPatchAtomData_Ptr > atoms;
- };
-
-
- /* Easy output */
- std::ostream& operator<<(std::ostream &out, const XMLDependency& data);
- std::ostream& operator<<(std::ostream &out, const XMLPatternData& data);
- std::ostream& operator<<(std::ostream& out, const XMLProductData& data);
-
-
- } // namespace xmlstore
- } // namespace parser
-} // namespace zypp
-
-
-
-
-
-
-#endif
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLPatchParser.cc
-*
-*/
-
-#include <zypp/parser/xmlstore/XMLPatchParser.h>
-
-#include <istream>
-#include <string>
-#include "zypp/parser/xml_parser_assert.h"
-#include <libxml/xmlreader.h>
-#include <libxml/tree.h>
-#include <zypp/parser/LibXMLHelper.h>
-#include <zypp/base/Logger.h>
-#include <zypp/parser/xmlstore/schemanames.h>
-
-using namespace std;
-
-namespace zypp {
- namespace parser {
- namespace xmlstore {
-
- XMLPatchParser::~XMLPatchParser()
- { }
-
- XMLPatchParser::XMLPatchParser(std::istream &is, const std::string& baseUrl)
- : XMLNodeIterator<XMLPatchData_Ptr>(is, baseUrl ,PATCHSCHEMA)
- {
- fetchNext();
- }
-
- XMLPatchParser::XMLPatchParser()
- { }
-
- XMLPatchParser::XMLPatchParser(XMLPatchData_Ptr& entry)
- : XMLNodeIterator<XMLPatchData_Ptr>(entry)
- { }
-
-
- // select for which elements process() will be called
- bool
- XMLPatchParser::isInterested(const xmlNodePtr nodePtr)
- {
- return _helper.isElement(nodePtr) && _helper.name(nodePtr) == "patch";
- }
-
- // do the actual processing
- XMLPatchData_Ptr
- XMLPatchParser::process(const xmlTextReaderPtr reader)
- {
- xml_assert(reader);
- XMLPatchData_Ptr patchPtr = new XMLPatchData();
- xmlNodePtr dataNode = xmlTextReaderExpand(reader);
- xml_assert(dataNode);
-
- // default values for optional entries
- patchPtr->rebootNeeded = false;
- patchPtr->packageManager = false;
-
- parseResObjectCommonData( patchPtr, dataNode);
- parseDependencies( patchPtr, dataNode);
-
- for (xmlNodePtr child = dataNode->children; child && child != dataNode; child = child->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
-
- if (name == "id") {
- patchPtr->patchId = _helper.content(child);
- }
- else if (name == "timestamp") {
- patchPtr->timestamp = _helper.content(child);
- }
- else if (name == "category") {
- patchPtr->category = _helper.content(child);
- }
- else if (name == "reboot-needed") {
- patchPtr->rebootNeeded = (_helper.content(child) == "true") ? true : false;
- }
- else if (name == "affects-package-manager") {
- patchPtr->packageManager = (_helper.content(child) == "true") ? true : false;
- }
- else if (name == "atoms") {
- parseAtomsNode(patchPtr, child);
- }
- }
- }
- return patchPtr;
- } /* end process */
-
-
- void
- XMLPatchParser::parseAtomsNode(XMLPatchData_Ptr dataPtr, xmlNodePtr formatNode)
- {
- xml_assert(formatNode);
- for (xmlNodePtr child = formatNode->children; child != 0; child = child ->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
- XXX << "parseAtomsNode(" << name << ")" << endl;
- if (name == "atom")
- {
- parseAtomNode (dataPtr, child);
- }
- else if (name == "script")
- {
- parseScriptNode (dataPtr, child);
- }
- else if (name == "message")
- {
- parseMessageNode (dataPtr, child);
- }
- }
- }
- }
-
- void
- XMLPatchParser::parseAtomNode(XMLPatchData_Ptr dataPtr, xmlNodePtr formatNode)
- {
- XMLPatchAtomData_Ptr atom(new XMLPatchAtomData);
- // inject dependencies and other stuff
- parseResObjectCommonData( atom, formatNode);
- parseDependencies( atom, formatNode);
-
- dataPtr->atoms.push_back(atom);
- }
-
- void
- XMLPatchParser::parseScriptNode(XMLPatchData_Ptr dataPtr, xmlNodePtr formatNode)
- {
- XMLPatchScriptData_Ptr script(new XMLPatchScriptData);
-
- parseResObjectCommonData( script, formatNode);
- parseDependencies( script, formatNode);
-
- for (xmlNodePtr child = formatNode->children; child != 0; child = child ->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
- if (name == "do") {
- script->doScript = _helper.content(child);
- }
- else if (name == "undo")
- {
- script->undoScript = _helper.content(child);
- }
- }
- }
- dataPtr->atoms.push_back(script);
- }
-
- void
- XMLPatchParser::parseMessageNode(XMLPatchData_Ptr dataPtr, xmlNodePtr formatNode)
- {
- XMLPatchMessageData_Ptr message(new XMLPatchMessageData);
-
- parseResObjectCommonData( message, formatNode);
- parseDependencies( message, formatNode);
-
- for (xmlNodePtr child = formatNode->children; child != 0; child = child ->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
- if (name == "text") {
- message->text.setText(_helper.content(child), Locale(_helper.attribute(child,"lang")));
- }
- }
- }
- dataPtr->atoms.push_back(message);
- }
-
- } // namespace yum
- } // namespace parser
-} // namespace zypp
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLPatchParser.h
- *
-*/
-
-#ifndef XMLPatchParser_h
-#define XMLPatchParser_h
-
-#include <zypp/parser/xmlstore/XMLResObjectParser.h>
-#include <zypp/parser/xmlstore/XMLParserData.h>
-#include <zypp/parser/XMLNodeIterator.h>
-#include <zypp/parser/LibXMLHelper.h>
-#include <list>
-
-namespace zypp
-{
- namespace parser
- {
- namespace xmlstore
- {
-
- class XMLPatchParser : public XMLNodeIterator<XMLPatchData_Ptr>, public XMLResObjectParser
- {
- public:
- XMLPatchParser(std::istream &is, const std::string &baseUrl);
- XMLPatchParser();
- XMLPatchParser(XMLPatchData_Ptr& entry);
- virtual ~XMLPatchParser();
-
- private:
- virtual bool isInterested(const xmlNodePtr nodePtr);
- virtual XMLPatchData_Ptr process(const xmlTextReaderPtr reader);
- void parseAtomsNode(XMLPatchData_Ptr dataPtr, xmlNodePtr formatNode);
- //void parsePackageNode(XMLPatchData_Ptr dataPtr, xmlNodePtr formatNode);
- void parseMessageNode(XMLPatchData_Ptr dataPtr, xmlNodePtr formatNode);
- void parseScriptNode(XMLPatchData_Ptr dataPtr, xmlNodePtr formatNode);
- void parseAtomNode(XMLPatchData_Ptr dataPtr, xmlNodePtr formatNode);
- // base method to parse capabilities and other stuff
- void parseResolvableNode(XMLResObjectData_Ptr dataPtr, xmlNodePtr formatNode);
- };
- } // namespace xml
- } // namespace parser
-} // namespace zypp
-
-#endif
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLPatternParser.cc
- *
-*/
-
-#include <zypp/parser/xmlstore/XMLPatternParser.h>
-#include <zypp/parser/xmlstore/XMLResObjectParser.h>
-
-#include <zypp/parser/LibXMLHelper.h>
-#include <istream>
-#include <string>
-#include "zypp/parser/xml_parser_assert.h"
-#include <libxml/xmlreader.h>
-#include <libxml/tree.h>
-#include <zypp/base/Logger.h>
-#include <zypp/parser/xmlstore/schemanames.h>
-
-using namespace std;
-namespace zypp {
- namespace parser {
- namespace xmlstore {
-
- XMLPatternParser::XMLPatternParser()
- { }
-
- XMLPatternParser::XMLPatternParser(XMLPatternData_Ptr& entry)
- : XMLNodeIterator<XMLPatternData_Ptr>(entry)
- { }
-
-
- XMLPatternParser::~XMLPatternParser()
- { }
-
-
- // select for which elements process() will be called
- bool
- XMLPatternParser::isInterested(const xmlNodePtr nodePtr)
- {
- return _helper.isElement(nodePtr) && _helper.name(nodePtr) == "pattern";
- }
-
- // do the actual processing
- XMLPatternData_Ptr
- XMLPatternParser::process(const xmlTextReaderPtr reader)
- {
- xml_assert(reader);
- XMLPatternData_Ptr dataPtr = new XMLPatternData;
- xmlNodePtr dataNode = xmlTextReaderExpand(reader);
- xml_assert(dataNode);
-
- parseResObjectCommonData( dataPtr, dataNode);
- parseDependencies( dataPtr, dataNode);
-
- for (xmlNodePtr child = dataNode->children; child && child != dataNode; child = child->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
-
- if (name == "default") {
- dataPtr->default_ = _helper.content(child);
- }
- else if (name == "uservisible") {
- dataPtr->userVisible = (_helper.content(child) == "false") ? false : true;
- }
- else if (name == "category") {
- dataPtr->category.setText(_helper.content(child));
- }
- else if (name == "icon") {
- dataPtr->icon = _helper.content(child);
- }
- else if (name == "script") {
- dataPtr->script = _helper.content(child);
- }
- }
- }
- return dataPtr;
- } /* end process */
-
-
- XMLPatternParser::XMLPatternParser(std::istream &is, const std::string &baseUrl)
- : XMLNodeIterator<XMLPatternData_Ptr>(is, baseUrl,PATTERNSCHEMA)
- {
- fetchNext();
- }
-
- } // namespace yum
- } // namespace parser
-} // namespace zypp
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLPatternParser.h
- *
-*/
-
-
-
-#ifndef XMLPatternParser_h
-#define XMLPatternParser_h
-
-#include <zypp/parser/xmlstore/XMLResObjectParser.h>
-#include <zypp/parser/xmlstore/XMLParserData.h>
-#include <zypp/parser/XMLNodeIterator.h>
-#include <zypp/parser/LibXMLHelper.h>
-#include <list>
-
-namespace zypp {
- namespace parser {
- namespace xmlstore {
-
- class XMLPatternParser : public XMLNodeIterator<XMLPatternData_Ptr>, public XMLResObjectParser
- {
- public:
- XMLPatternParser(std::istream &is, const std::string &baseUrl);
- XMLPatternParser();
- XMLPatternParser(XMLPatternData_Ptr& entry);
- virtual ~XMLPatternParser();
-
- private:
- virtual bool isInterested(const xmlNodePtr nodePtr);
- virtual XMLPatternData_Ptr process(const xmlTextReaderPtr reader);
-
- LibXMLHelper _helper;
- };
- } // namespace xmlstore
- } // namespace parser
-} // namespace zypp
-
-#endif
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLProductParser.cc
- *
-*/
-
-#include <istream>
-#include <string>
-#include "zypp/parser/xml_parser_assert.h"
-#include <libxml/xmlreader.h>
-#include <libxml/tree.h>
-#include "zypp/parser/xmlstore/XMLProductParser.h"
-#include "zypp/parser/xmlstore/XMLResObjectParser.h"
-#include "zypp/parser/LibXMLHelper.h"
-#include "zypp/base/Logger.h"
-#include "zypp/parser/xmlstore/schemanames.h"
-
-using namespace std;
-namespace zypp {
- namespace parser {
- namespace xmlstore {
-
- XMLProductParser::~XMLProductParser()
- { }
-
- XMLProductParser::XMLProductParser(std::istream &is, const std::string& baseUrl)
- : XMLNodeIterator<XMLProductData_Ptr>(is, baseUrl ,PRODUCTSCHEMA)
- {
- fetchNext();
- }
-
- XMLProductParser::XMLProductParser()
- { }
-
- XMLProductParser::XMLProductParser(XMLProductData_Ptr& entry)
- : XMLNodeIterator<XMLProductData_Ptr>(entry)
- { }
-
-
- // select for which elements process() will be called
- bool
- XMLProductParser::isInterested(const xmlNodePtr nodePtr)
- {
- return _helper.isElement(nodePtr) && _helper.name(nodePtr) == "product";
- }
-
- // do the actual processing
- XMLProductData_Ptr
- XMLProductParser::process(const xmlTextReaderPtr reader)
- {
- xml_assert(reader);
- XMLProductData_Ptr productPtr = new XMLProductData;
- xmlNodePtr dataNode = xmlTextReaderExpand(reader);
- xml_assert(dataNode);
- productPtr->type = _helper.attribute(dataNode,"type");
- productPtr->parser_version = _helper.attribute(dataNode, "version");
-
- parseResObjectCommonData( productPtr, dataNode);
- parseDependencies( productPtr, dataNode);
-
- for (xmlNodePtr child = dataNode->children; child && child != dataNode; child = child->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
- if (name == "vendor")
- {
- productPtr->vendor = _helper.content(child);
- }
- else if (name == "release-notes-url") {
- productPtr->releasenotesurl = _helper.content(child);
- }
- else if (name == "distribution-name") {
- productPtr->dist_name = _helper.content(child);
- }
- else if (name == "distribution-edition") {
- productPtr->dist_version = _helper.content(child);
- }
- else if (name == "shortname") {
- productPtr->short_name.setText(_helper.content(child), Locale(_helper.attribute(child,"lang")));
- }
- else if (name == "product-flags") {
- parseProductFlags( productPtr, child);
- }
- else if (name == "update-urls")
- {
- parseList<string>( "update-url", productPtr->update_urls, child);
- }
- else if (name == "extra-urls")
- {
- parseList<string>( "extra-url", productPtr->extra_urls, child);
- }
- else if (name == "optional-urls")
- {
- parseList<string>( "optional-url", productPtr->optional_urls, child);
- }
-
- }
- }
- return productPtr;
- } /* end process */
-
- void
- XMLProductParser::parseProductFlags( XMLProductData_Ptr productPtr, xmlNodePtr node)
- {
- for (xmlNodePtr child = node->children; child && child != node; child = child->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
- if (name == "product-flag")
- {
- productPtr->flags.push_back(_helper.content(child));
- }
- }
- }
- }
-
- template <class T>
- void XMLProductParser::parseList( const std::string &tagname, std::list<T> &list, xmlNodePtr node)
- {
- for (xmlNodePtr child = node->children; child && child != node; child = child->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
- if (name == tagname)
- {
- list.push_back(_helper.content(child));
- }
- }
- }
- }
-
- } // namespace yum
- } // namespace parser
-} // namespace zypp
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLProductParser.h
- *
-*/
-
-#ifndef XMLProductParser_h
-#define XMLProductParser_h
-
-#include "zypp/Url.h"
-#include "zypp/parser/xmlstore/XMLParserData.h"
-#include "zypp/parser/xmlstore/XMLResObjectParser.h"
-#include "zypp/parser/XMLNodeIterator.h"
-#include "zypp/parser/LibXMLHelper.h"
-#include <list>
-
-namespace zypp {
- namespace parser {
- namespace xmlstore {
-
- class XMLProductParser : public XMLNodeIterator<XMLProductData_Ptr>, public XMLResObjectParser
- {
- public:
- XMLProductParser(std::istream &is, const std::string &baseUrl);
- XMLProductParser();
- XMLProductParser(XMLProductData_Ptr &entry);
- virtual ~XMLProductParser();
-
- private:
- void parseProductFlags( XMLProductData_Ptr productPtr, xmlNodePtr node);
-
- template<class T>
- void parseList( const std::string &tagname, std::list<T> &list, xmlNodePtr node);
-
- virtual bool isInterested(const xmlNodePtr nodePtr);
- virtual XMLProductData_Ptr process(const xmlTextReaderPtr reader);
- };
- } // namespace yum
- } // namespace parser
-} // namespace zypp
-
-#endif
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLResObjectParser.cc
- *
-*/
-
-#include <zypp/parser/xmlstore/XMLResObjectParser.h>
-#include <istream>
-#include <string>
-#include "zypp/parser/xml_parser_assert.h"
-#include <libxml/xmlstring.h>
-#include <libxml/xmlreader.h>
-#include <libxml/tree.h>
-#include <zypp/parser/LibXMLHelper.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/parser/yum/schemanames.h>
-
-using namespace std;
-namespace zypp
-{
-namespace parser
-{
-namespace xmlstore
-{
-
-
-XMLResObjectParser::XMLResObjectParser()
-{ }
-
-XMLResObjectParser::~XMLResObjectParser()
-{
-}
-
-
-void
-XMLResObjectParser::parseResObjectCommonData( XMLResObjectData_Ptr dataPtr, xmlNodePtr node)
-{
- xml_assert(node);
-
- for (xmlNodePtr child = node->children; child != 0; child = child ->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
-
- if (name == "name") {
- dataPtr->name = _helper.content(child);
- }
- else if (name == "arch") {
- dataPtr->arch = _helper.content(child);
- }
- else if (name == "version") {
- dataPtr->epoch = _helper.attribute(child,"epoch");
- dataPtr->ver = _helper.attribute(child,"ver");
- dataPtr->rel = _helper.attribute(child,"rel");
- } // FIXME move the following to a ResolvableParser?
- else if (name == "summary") {
- dataPtr->summary.setText(_helper.content(child), Locale(_helper.attribute(child,"lang")));
- }
- else if (name == "description") {
- dataPtr->description.setText(_helper.content(child), Locale(_helper.attribute(child,"lang")));
- }
- else if (name == "install-notify") {
- dataPtr->install_notify.setText(_helper.content(child), Locale(_helper.attribute(child,"lang")));
- }
- else if (name == "delete-notify") {
- dataPtr->delete_notify.setText(_helper.content(child), Locale(_helper.attribute(child,"lang")));
- }
- else if (name == "license-to-confirm") {
- dataPtr->license_to_confirm.setText(_helper.content(child), Locale(_helper.attribute(child,"lang")));
- }
- else if (name == "vendor") {
- dataPtr->vendor = _helper.content(child);
- }
- else if (name == "size") {
- dataPtr->size = str::strtonum<ByteCount::SizeType>(_helper.content(child));
- }
- else if (name == "archive-size") {
- dataPtr->downloadSize = str::strtonum<ByteCount::SizeType>(_helper.content(child));
- }
- else if (name == "install-only") {
- dataPtr->install_only = (_helper.content(child) == "true") ? true : false;
- }
- else if (name == "build-time") {
- dataPtr->build_time = str::strtonum<Date::ValueType>(_helper.content(child));
- }
- else if (name == "install-time") {
- dataPtr->install_time = str::strtonum<Date::ValueType>(_helper.content(child));
- }
- }
- }
-}
-
-void
- XMLResObjectParser::parseDependencies( XMLResObjectData_Ptr dataPtr, xmlNodePtr node)
-{
- xml_assert(node);
-
- for (xmlNodePtr child = node->children; child != 0; child = child ->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
- if (name == "provides") {
- parseDependencyEntries(& dataPtr->provides, child);
- }
- else if (name == "conflicts") {
- parseDependencyEntries(& dataPtr->conflicts, child);
- }
- else if (name == "obsoletes") {
- parseDependencyEntries(& dataPtr->obsoletes, child);
- }
- else if (name == "prerequires") {
- parseDependencyEntries(& dataPtr->prerequires, child);
- }
- else if (name == "requires") {
- parseDependencyEntries(& dataPtr->requires, child);
- }
- else if (name == "recommends") {
- parseDependencyEntries(& dataPtr->recommends, child);
- }
- else if (name == "suggests") {
- parseDependencyEntries(& dataPtr->suggests, child);
- }
- else if (name == "supplements") {
- parseDependencyEntries(& dataPtr->supplements, child);
- }
- else if (name == "enhances") {
- parseDependencyEntries(& dataPtr->enhances, child);
- }
- else if (name == "freshens") {
- parseDependencyEntries(& dataPtr->freshens, child);
- }
- }
- }
-
-}
-
-void
-XMLResObjectParser::parseDependencyEntries( std::list<XMLDependency> *depList,
- xmlNodePtr depNode)
-{
- xml_assert(depNode);
-
- for (xmlNodePtr child = depNode->children; child != 0; child = child ->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
-
- if ( name == "capability" )
- {
- depList->push_back
- (XMLDependency(_helper.attribute(child,"kind"),
- _helper.content(child)));
- }
- else
- {
- WAR << "XML dependency contains the unknown element <" << name << "> "
- << _helper.positionInfo(child) << ", skipping" << endl;
- }
- }
- }
-}
-
-} // namespace xmlstore
-} // namespace parser
-} // namespace zypp
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLResObjectParser.h
- *
-*/
-
-
-
-#ifndef XMLResObjectParser_h
-#define XMLResObjectParser_h
-
-#include <zypp/parser/xmlstore/XMLParserData.h>
-#include <zypp/parser/XMLNodeIterator.h>
-#include <zypp/parser/LibXMLHelper.h>
-#include <list>
-
-namespace zypp {
- namespace parser {
- namespace xmlstore {
-
- class XMLResObjectParser
- {
- public:
- XMLResObjectParser();
- virtual ~XMLResObjectParser();
-
- protected:
- void parseResObjectCommonData( XMLResObjectData_Ptr dataPtr, xmlNodePtr node);
- void parseDependencies( XMLResObjectData_Ptr dataPtr, xmlNodePtr depNode);
- void parseDependencyEntries(std::list<XMLDependency> *depList, xmlNodePtr depNode);
- LibXMLHelper _helper;
- };
- } // namespace yum
- } // namespace parser
-} // namespace zypp
-
-#endif
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLSourceCacheParser.cc
- *
-*/
-
-#include <zypp/parser/LibXMLHelper.h>
-#include <istream>
-#include <string>
-#include <cassert>
-#include <libxml/xmlreader.h>
-#include <libxml/tree.h>
-#include <zypp/base/Logger.h>
-#include <zypp/parser/xmlstore/schemanames.h>
-#include "zypp/repo/RepoType.h"
-#include "XMLSourceCacheParser.h"
-
-using namespace std;
-
-namespace zypp {
-namespace parser {
-namespace xmlstore {
-
- XMLSourceCacheParser::XMLSourceCacheParser()
- { }
-
- XMLSourceCacheParser::XMLSourceCacheParser(RepoInfo_Ptr &entry)
- : zypp::parser::XMLNodeIterator<RepoInfo_Ptr>(entry)
- { }
-
-
- XMLSourceCacheParser::~XMLSourceCacheParser()
- { }
-
-
- // select for which elements process() will be called
- bool
- XMLSourceCacheParser::isInterested(const xmlNodePtr nodePtr)
- {
- return _helper.isElement(nodePtr) && _helper.name(nodePtr) == "source";
- }
-
- // do the actual processing
- RepoInfo_Ptr
- XMLSourceCacheParser::process(const xmlTextReaderPtr reader)
- {
- assert(reader);
- RepoInfo_Ptr dataPtr( new RepoInfo );
- xmlNodePtr dataNode = xmlTextReaderExpand(reader);
- assert(dataNode);
-
- for (xmlNodePtr child = dataNode->children; child && child != dataNode; child = child->next)
- {
- if (_helper.isElement(child))
- {
- string name = _helper.name(child);
- if (name == "enabled")
- {
- if ( (_helper.content(child) == "true") || (_helper.content(child) == "1") )
- dataPtr->setEnabled(true);
- else if ( (_helper.content(child) == "false") || (_helper.content(child) == "0") )
- dataPtr->setEnabled(false);
- }
- else if (name == "auto-refresh")
- {
- if ( (_helper.content(child) == "true") || (_helper.content(child) == "1") )
- dataPtr->setAutorefresh(true);
- else if ( (_helper.content(child) == "false") || (_helper.content(child) == "0") )
- dataPtr->setAutorefresh(false);
- }
- else if (name == "type")
- {
- dataPtr->setType(repo::RepoType(_helper.content(child)));
- }
- else if (name == "alias")
- {
- dataPtr->setAlias(_helper.content(child));
- }
- else if (name == "url")
- {
- dataPtr->addBaseUrl(_helper.content(child));
- }
- else
- {
- WAR << "SourceCache entry contains the unknown element <" << name << "> "
- << _helper.positionInfo(child) << ", skipping" << endl;
- }
- }
- }
- return dataPtr;
- } /* end process */
-
-
- XMLSourceCacheParser::XMLSourceCacheParser(std::istream &is, const std::string &baseUrl)
- : zypp::parser::XMLNodeIterator<RepoInfo_Ptr>(is, baseUrl, SOURCESCHEMA)
- {
- fetchNext();
- }
-}
-} // namespace parser
-} // namespace zypp
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/XMLSourceCacheParser.h
- *
-*/
-
-#ifndef XMLSourceCacheParser_h
-#define XMLSourceCacheParser_h
-
-#include <zypp/RepoInfo.h>
-#include <zypp/parser/XMLNodeIterator.h>
-#include <zypp/parser/LibXMLHelper.h>
-#include <list>
-
-namespace zypp
-{
-namespace parser
-{
-namespace xmlstore
-{
- typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
-
- /*
- * Use this class as an iterator that produces, one after one,
- * XMLSourceCacheData_Ptr(s) for the XML group elements.
- * Here's an example:
- *
- * for (XMLSourceCacheParser iter(anIstream, baseUrl),
- * iter != XMLSourceCacheParser.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 XMLSourceCacheParser : public zypp::parser::XMLNodeIterator<RepoInfo_Ptr>
- {
- public:
- XMLSourceCacheParser(std::istream &is, const std::string &baseUrl);
- XMLSourceCacheParser();
- XMLSourceCacheParser(RepoInfo_Ptr & entry);
- virtual ~XMLSourceCacheParser();
-
- private:
- virtual bool isInterested(const xmlNodePtr nodePtr);
- virtual RepoInfo_Ptr process(const xmlTextReaderPtr reader);
- void parseSourceList(RepoInfo_Ptr dataPtr, xmlNodePtr node);
- zypp::parser::LibXMLHelper _helper;
- };
- } // namespace parser
-} // namespace xmlstore
-} // namespace zypp
-
-#endif
+++ /dev/null
-default namespace = "http://www.novell.com/metadata/zypp/xml-store"
-
-boolean = "true" | "false"
-source-type = text
-url = xsd:anyURI
-start = element-source
-
-element-source =
- element source { source }
-
-source =
- element enabled { boolean },
- element auto-refresh { boolean },
- element product-dir { text },
- element cache-dir { text },
- element type { source-type },
- element url { url },
- element alias { text }
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<grammar ns="http://www.novell.com/metadata/zypp/xml-store" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <define name="boolean">
- <choice>
- <value>true</value>
- <value>false</value>
- </choice>
- </define>
- <define name="source-type">
- <text/>
- </define>
- <define name="url">
- <data type="anyURI"/>
- </define>
- <start>
- <ref name="element-source"/>
- </start>
- <define name="element-source">
- <element name="source">
- <ref name="source"/>
- </element>
- </define>
- <define name="source">
- <element name="enabled">
- <ref name="boolean"/>
- </element>
- <element name="auto-refresh">
- <ref name="boolean"/>
- </element>
- <element name="product-dir">
- <text/>
- </element>
- <element name="cache-dir">
- <text/>
- </element>
- <element name="type">
- <ref name="source-type"/>
- </element>
- <element name="url">
- <ref name="url"/>
- </element>
- <element name="alias">
- <text/>
- </element>
- </define>
-</grammar>
+++ /dev/null
-default namespace = "http://www.novell.com/metadata/zypp/xml-store"
-
-include "resolvable.rnc"
-
-start = element-language
-
-element-language =
- element language { language }
-
-language =
- resolvable-data
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<grammar ns="http://www.novell.com/metadata/zypp/xml-store" xmlns="http://relaxng.org/ns/structure/1.0">
- <include href="resolvable.rng"/>
- <start>
- <ref name="element-language"/>
- </start>
- <define name="element-language">
- <element name="language">
- <ref name="language"/>
- </element>
- </define>
- <define name="language">
- <ref name="resolvable-data"/>
- </define>
-</grammar>
+++ /dev/null
-default namespace = "http://www.novell.com/metadata/zypp/xml-store"
-
-include "resolvable.rnc"
-
-start = element-patch
-
-element-patch =
- element patch { patch }
-
-element-message =
- element message { message }
-
-message =
- resolvable-data,
- element text { text }
-
-element-script =
- element script { script }
-
-script =
- resolvable-data,
- element do { text },
- element undo { text }
-
-element-atom =
- element atom { atom }
-
-atom =
- resolvable-data
-
-atoms =
- element-script* & element-message* & element-atom*
-
-patch =
- resolvable-data,
- element id { text },
- element timestamp { text },
- element category { text },
- element affects-package-manager { boolean },
- element reboot-needed { boolean },
- element interactive { boolean },
- element atoms { atoms }
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<grammar ns="http://www.novell.com/metadata/zypp/xml-store" xmlns="http://relaxng.org/ns/structure/1.0">
- <include href="resolvable.rng"/>
- <start>
- <ref name="element-patch"/>
- </start>
- <define name="element-patch">
- <element name="patch">
- <ref name="patch"/>
- </element>
- </define>
- <define name="element-message">
- <element name="message">
- <ref name="message"/>
- </element>
- </define>
- <define name="message">
- <ref name="resolvable-data"/>
- <element name="text">
- <text/>
- </element>
- </define>
- <define name="element-script">
- <element name="script">
- <ref name="script"/>
- </element>
- </define>
- <define name="script">
- <ref name="resolvable-data"/>
- <element name="do">
- <text/>
- </element>
- <element name="undo">
- <text/>
- </element>
- </define>
- <define name="element-atom">
- <element name="atom">
- <ref name="atom"/>
- </element>
- </define>
- <define name="atom">
- <ref name="resolvable-data"/>
- </define>
- <define name="atoms">
- <interleave>
- <zeroOrMore>
- <ref name="element-script"/>
- </zeroOrMore>
- <zeroOrMore>
- <ref name="element-message"/>
- </zeroOrMore>
- <zeroOrMore>
- <ref name="element-atom"/>
- </zeroOrMore>
- </interleave>
- </define>
- <define name="patch">
- <ref name="resolvable-data"/>
- <element name="id">
- <text/>
- </element>
- <element name="timestamp">
- <text/>
- </element>
- <element name="category">
- <text/>
- </element>
- <element name="affects-package-manager">
- <ref name="boolean"/>
- </element>
- <element name="reboot-needed">
- <ref name="boolean"/>
- </element>
- <element name="interactive">
- <ref name="boolean"/>
- </element>
- <element name="atoms">
- <ref name="atoms"/>
- </element>
- </define>
-</grammar>
+++ /dev/null
-default namespace = "http://www.novell.com/metadata/zypp/xml-store"
-
-include "resolvable.rnc"
-
-start = element-pattern
-
-element-pattern =
- element pattern { pattern }
-
-pattern =
- resolvable-data,
- element default { boolean }?,
- element uservisible { boolean },
- element category { text },
- element icon { text }?,
- element script { text }
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<grammar ns="http://www.novell.com/metadata/zypp/xml-store" xmlns="http://relaxng.org/ns/structure/1.0">
- <include href="resolvable.rng"/>
- <start>
- <ref name="element-pattern"/>
- </start>
- <define name="element-pattern">
- <element name="pattern">
- <ref name="pattern"/>
- </element>
- </define>
- <define name="pattern">
- <ref name="resolvable-data"/>
- <optional>
- <element name="default">
- <ref name="boolean"/>
- </element>
- </optional>
- <element name="uservisible">
- <ref name="boolean"/>
- </element>
- <element name="category">
- <text/>
- </element>
- <optional>
- <element name="icon">
- <text/>
- </element>
- </optional>
- <element name="script">
- <text/>
- </element>
- </define>
-</grammar>
+++ /dev/null
-default namespace = "http://www.novell.com/metadata/zypp/xml-store"
-
-include "resolvable.rnc"
-
-start = element-product
-
-element-product =
- element product { attribute type { text }, product }
-
-product =
- resolvable-data,
- element shortname { translated-text }*,
- element vendor { text }?,
-# (vendor moved to resolvable)
- element source { text },
- element release-notes-url { text },
- element update-urls { element update-url { text }* },
- element product-flags { element product-flag {text }* }
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<grammar ns="http://www.novell.com/metadata/zypp/xml-store" xmlns="http://relaxng.org/ns/structure/1.0">
- <include href="resolvable.rng"/>
- <start>
- <ref name="element-product"/>
- </start>
- <define name="element-product">
- <element name="product">
- <attribute name="type"/>
- <ref name="product"/>
- </element>
- </define>
- <define name="product">
- <ref name="resolvable-data"/>
- <zeroOrMore>
- <element name="shortname">
- <ref name="translated-text"/>
- </element>
- </zeroOrMore>
- <optional>
- <element name="vendor">
- <text/>
- </element>
- </optional>
- <!-- (vendor moved to resolvable) -->
- <element name="source">
- <text/>
- </element>
- <element name="release-notes-url">
- <text/>
- </element>
- <element name="update-urls">
- <zeroOrMore>
- <element name="update-url">
- <text/>
- </element>
- </zeroOrMore>
- </element>
- <element name="product-flags">
- <zeroOrMore>
- <element name="product-flag">
- <text/>
- </element>
- </zeroOrMore>
- </element>
- </define>
-</grammar>
+++ /dev/null
-default namespace = "http://www.novell.com/metadata/zypp/xml-store"
-
-boolean = "true" | "false"
-
-attribute-kind =
- attribute kind { "pattern" | "package" | "patch" | "script" | "message" | "product" | "atom" }
-
-arch =
- "noarch"
- | "athlon"
- | "i386"
- | "i486"
- | "i586"
- | "i686"
- | "ia64"
- | "ppc"
- | "ppc64"
- | "s390"
- | "s390x"
- | "x86_64"
- | "src"
-
-element-version =
- element version { version }
-
-translated-text =
- attribute lang { text }?,
- text
-
-version =
- attribute ver { text },
- attribute rel { text },
- attribute epoch { xsd:nonNegativeInteger }?,
- empty
-
-element-summary =
- element summary { translated-text }
-
-element-description =
- element description { translated-text }
-
-capability =
- element capability { attribute-kind,
- text }
-
-capability-set =
- capability*
-
-provides =
- element provides { capability-set }
-requires =
- element requires { capability-set }
-prerequires =
- element prerequires { capability-set }
-conflicts =
- element conflicts { capability-set }
-suggests =
- element suggests { capability-set }
-freshens =
- element freshens { capability-set }
-supplements =
- element supplements { capability-set }
-enhances =
- element enhances { capability-set }
-recommends =
- element recommends { capability-set }
-obsoletes =
- element obsoletes { capability-set }
-
-dependencies =
- provides?,
- prerequires?,
- conflicts?,
- obsoletes?,
- freshens?,
- requires?,
- recommends?,
- enhances?,
- supplements?,
- suggests?
-
-element-install-notify =
- element install-notify { translated-text }
-
-element-delete-notify =
- element delete-notify { translated-text }
-
-element-license-to-confirm =
- element license-to-confirm { translated-text }
-
-element-vendor =
- element vendor { text }
-
-element-size =
- element size { xsd:nonNegativeInteger }
-
-element-archive-size =
- element archive-size { xsd:nonNegativeInteger }
-
-element-install-only =
- element install-only { boolean }
-
-element-build-time =
- element build-time { xsd:nonNegativeInteger }
-
-element-install-time =
- element install-time { xsd:nonNegativeInteger }
-
-resolvable-data =
- element name { text },
- element-version,
- element arch { arch },
- dependencies,
- element-summary+,
- element-description+,
- element-install-notify*,
- element-delete-notify*,
- element-license-to-confirm*,
- element-vendor?,
- element-size?,
- element-archive-size?,
- element-install-only?,
- element-build-time?,
- element-install-time?
-
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<grammar ns="http://www.novell.com/metadata/zypp/xml-store" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <define name="boolean">
- <choice>
- <value>true</value>
- <value>false</value>
- </choice>
- </define>
- <define name="attribute-kind">
- <attribute name="kind">
- <choice>
- <value>pattern</value>
- <value>package</value>
- <value>patch</value>
- <value>script</value>
- <value>message</value>
- <value>product</value>
- <value>atom</value>
- </choice>
- </attribute>
- </define>
- <define name="arch">
- <choice>
- <value>noarch</value>
- <value>athlon</value>
- <value>i386</value>
- <value>i486</value>
- <value>i586</value>
- <value>i686</value>
- <value>ia64</value>
- <value>ppc</value>
- <value>ppc64</value>
- <value>s390</value>
- <value>s390x</value>
- <value>x86_64</value>
- <value>src</value>
- </choice>
- </define>
- <define name="element-version">
- <element name="version">
- <ref name="version"/>
- </element>
- </define>
- <define name="translated-text">
- <optional>
- <attribute name="lang"/>
- </optional>
- <text/>
- </define>
- <define name="version">
- <attribute name="ver"/>
- <attribute name="rel"/>
- <optional>
- <attribute name="epoch">
- <data type="nonNegativeInteger"/>
- </attribute>
- </optional>
- <empty/>
- </define>
- <define name="element-summary">
- <element name="summary">
- <ref name="translated-text"/>
- </element>
- </define>
- <define name="element-description">
- <element name="description">
- <ref name="translated-text"/>
- </element>
- </define>
- <define name="capability">
- <element name="capability">
- <ref name="attribute-kind"/>
- <text/>
- </element>
- </define>
- <define name="capability-set">
- <zeroOrMore>
- <ref name="capability"/>
- </zeroOrMore>
- </define>
- <define name="provides">
- <element name="provides">
- <ref name="capability-set"/>
- </element>
- </define>
- <define name="requires">
- <element name="requires">
- <ref name="capability-set"/>
- </element>
- </define>
- <define name="prerequires">
- <element name="prerequires">
- <ref name="capability-set"/>
- </element>
- </define>
- <define name="conflicts">
- <element name="conflicts">
- <ref name="capability-set"/>
- </element>
- </define>
- <define name="suggests">
- <element name="suggests">
- <ref name="capability-set"/>
- </element>
- </define>
- <define name="freshens">
- <element name="freshens">
- <ref name="capability-set"/>
- </element>
- </define>
- <define name="supplements">
- <element name="supplements">
- <ref name="capability-set"/>
- </element>
- </define>
- <define name="enhances">
- <element name="enhances">
- <ref name="capability-set"/>
- </element>
- </define>
- <define name="recommends">
- <element name="recommends">
- <ref name="capability-set"/>
- </element>
- </define>
- <define name="obsoletes">
- <element name="obsoletes">
- <ref name="capability-set"/>
- </element>
- </define>
- <define name="dependencies">
- <optional>
- <ref name="provides"/>
- </optional>
- <optional>
- <ref name="prerequires"/>
- </optional>
- <optional>
- <ref name="conflicts"/>
- </optional>
- <optional>
- <ref name="obsoletes"/>
- </optional>
- <optional>
- <ref name="freshens"/>
- </optional>
- <optional>
- <ref name="requires"/>
- </optional>
- <optional>
- <ref name="recommends"/>
- </optional>
- <optional>
- <ref name="enhances"/>
- </optional>
- <optional>
- <ref name="supplements"/>
- </optional>
- <optional>
- <ref name="suggests"/>
- </optional>
- </define>
- <define name="element-install-notify">
- <element name="install-notify">
- <ref name="translated-text"/>
- </element>
- </define>
- <define name="element-delete-notify">
- <element name="delete-notify">
- <ref name="translated-text"/>
- </element>
- </define>
- <define name="element-license-to-confirm">
- <element name="license-to-confirm">
- <ref name="translated-text"/>
- </element>
- </define>
- <define name="element-vendor">
- <element name="vendor">
- <text/>
- </element>
- </define>
- <define name="element-size">
- <element name="size">
- <data type="nonNegativeInteger"/>
- </element>
- </define>
- <define name="element-archive-size">
- <element name="archive-size">
- <data type="nonNegativeInteger"/>
- </element>
- </define>
- <define name="element-install-only">
- <element name="install-only">
- <ref name="boolean"/>
- </element>
- </define>
- <define name="element-build-time">
- <element name="build-time">
- <data type="nonNegativeInteger"/>
- </element>
- </define>
- <define name="element-install-time">
- <element name="install-time">
- <data type="nonNegativeInteger"/>
- </element>
- </define>
- <define name="resolvable-data">
- <element name="name">
- <text/>
- </element>
- <ref name="element-version"/>
- <element name="arch">
- <ref name="arch"/>
- </element>
- <ref name="dependencies"/>
- <oneOrMore>
- <ref name="element-summary"/>
- </oneOrMore>
- <oneOrMore>
- <ref name="element-description"/>
- </oneOrMore>
- <zeroOrMore>
- <ref name="element-install-notify"/>
- </zeroOrMore>
- <zeroOrMore>
- <ref name="element-delete-notify"/>
- </zeroOrMore>
- <zeroOrMore>
- <ref name="element-license-to-confirm"/>
- </zeroOrMore>
- <optional>
- <ref name="element-vendor"/>
- </optional>
- <optional>
- <ref name="element-size"/>
- </optional>
- <optional>
- <ref name="element-archive-size"/>
- </optional>
- <optional>
- <ref name="element-install-only"/>
- </optional>
- <optional>
- <ref name="element-build-time"/>
- </optional>
- <optional>
- <ref name="element-install-time"/>
- </optional>
- </define>
-</grammar>
+++ /dev/null
-#!/bin/bash
-for i in *.rnc; do trang -I rnc -O rng $i ${i%.rnc}.rng; done
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/xmlstore/schemanames.h
- *
-*/
-
-
-#ifndef xmlstore_schemanames_h
-#define xmlstore_schemanames_h
-
-namespace zypp {
- namespace parser {
- namespace xmlstore {
- /* FIXME: How do I do this properly? */
-#define SCHEMABASE "/usr/share/zypp/schema/xmlstore/"
- //#define REPOMDSCHEMA (SCHEMABASE "repomd.rng")
- //#define PRIMARYSCHEMA (SCHEMABASE "suse-primary.rng")
- //#define GROUPSCHEMA (SCHEMABASE "groups.rng")
- #define PATTERNSCHEMA (SCHEMABASE "pattern.rng")
- //#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")
-#define LANGUAGESCHEMA (SCHEMABASE "language.rng")
-#define SOURCESCHEMA (SCHEMABASE "known-source.rng")
- } // namespace xmlstore
- } // namespace parser
-} // namespace zypp
-
-#endif
#include "zypp/Product.h"
#include "zypp/Package.h"
#include "zypp/Edition.h"
-#include "zypp/target/store/xml_escape_parser.hpp"
+#include "zypp/parser/xml_escape_parser.hpp"
#include "zypp/base/String.h"
#include "zypp/base/PtrTypes.h"
#include "zypp/Capabilities.h"
#include "zypp/media/MediaAccess.h"
#include "zypp/Target.h"
#include "zypp/target/rpm/RpmDb.h"
-#include "zypp/target/store/PersistentStorage.h"
#include "zypp/target/TargetException.h"
///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/target/store/Backend.cc
-*
-*/
-#include <iostream>
-//#include "zypp/base/Logger.h"
-
-#include "Backend.h"
-
-using std::endl;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace storage
- {
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : Backend
- //
- ///////////////////////////////////////////////////////////////////
- class Backend::Private
- {
- };
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : Backend
- //
- ///////////////////////////////////////////////////////////////////
-
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : Backend::Backend
- // METHOD TYPE : Ctor
- //
- Backend::Backend(const Pathname &root)
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : Backend::~Backend
- // METHOD TYPE : Dtor
- //
- Backend::~Backend()
- {}
-
- /******************************************************************
- **
- ** FUNCTION NAME : operator<<
- ** FUNCTION TYPE : std::ostream &
- */
- std::ostream & operator<<( std::ostream & str, const Backend & obj )
- {
- return str;
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace devel.dmacvicar
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace devel
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/target/store/Backend.h
-*
-*/
-#ifndef ZYPP_STORAGE_BACKEND_H
-#define ZYPP_STORAGE_BACKEND_H
-
-#include <iosfwd>
-
-#include "zypp/base/PtrTypes.h"
-#include <zypp/Pathname.h>
-#include <zypp/Patch.h>
-
-#include <zypp/target/store/PersistentStorage.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace storage
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : Backend
-//
-/**
-* This class represents a storage backend implementation
-*/
-class Backend
-{
- friend std::ostream & operator<<( std::ostream & str, const Backend & obj );
-public:
- /** root is the system root path */
- Backend(const Pathname &root);
- /** Dtor */
- virtual ~Backend();
- virtual void doTest() = 0;
-
- /**
- * is the storage backend initialized
- */
- virtual bool isBackendInitialized() const = 0;
- /**
- * initialize the storage backend
- */
- virtual void initBackend() = 0;
-
- /**
- * timestamp of last modification
- */
- virtual Date timestamp() const = 0;
-
- /**
- * Stores a Resolvable in the active backend.
- */
- virtual void storeObject( ResObject::constPtr resolvable ) = 0;
- /**
- * Deletes a Resolvable from the active backend.
- */
- virtual void deleteObject( ResObject::constPtr resolvable ) = 0;
-
- /**
- * Query for installed Resolvables.
- */
- virtual std::list<ResObject::Ptr> storedObjects() const = 0;
- /**
- * Query for installed Resolvables of a certain kind
- */
- virtual std::list<ResObject::Ptr> storedObjects(const Resolvable::Kind) const = 0;
- /**
- * Query for installed Resolvables of a certain kind by name
- * \a partial_match allows for text search.
- */
- virtual std::list<ResObject::Ptr> storedObjects(const Resolvable::Kind, const std::string & name, bool partial_match = false) const = 0;
-
- /////////////////////////////////////////////////////////
- // Resolvables Flags API
- ////////////////////////////////////////////////////////
- public:
- virtual void setObjectFlag( ResObject::constPtr resolvable, const std::string &flag ) = 0;
- virtual void removeObjectFlag( ResObject::constPtr resolvable, const std::string &flag ) = 0;
- virtual std::set<std::string> objectFlags( ResObject::constPtr resolvable ) const = 0;
- virtual bool doesObjectHasFlag( ResObject::constPtr resolvable, const std::string &flag ) const = 0;
-
- /////////////////////////////////////////////////////////
- // Named Flags API
- ////////////////////////////////////////////////////////
- public:
- virtual void setFlag( const std::string &key, const std::string &flag ) = 0;
- virtual void removeFlag( const std::string &key, const std::string &flag ) = 0;
- virtual std::set<std::string> flags( const std::string &key ) const = 0;
- virtual bool hasFlag( const std::string &key, const std::string &flag ) const = 0;
-
-private:
- /** Pointer to implementation */
- class Private;
- Private *d;
-};
-///////////////////////////////////////////////////////////////////
-
-/** \relates Backend Stream output */
-std::ostream & operator<<( std::ostream & str, const Backend & obj );
-
-/////////////////////////////////////////////////////////////////
-} // namespace storage
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // DEVEL_DEVEL_DMACVICAR_BACKEND_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/target/store/PersistentStorage.cc
-*
-*/
-#include <iostream>
-#include "zypp/base/Logger.h"
-
-#include "PersistentStorage.h"
-#include "Backend.h"
-//#include "XMLFilesBackend.h"
-
-using std::endl;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace storage
-{
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : PersistentStoragePrivate
-//
-///////////////////////////////////////////////////////////////////
-struct PersistentStorage::Private
-{
- shared_ptr<Backend> backend;
-};
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : PersistentStorage
-//
-///////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : PersistentStorage::PersistentStorage
-// METHOD TYPE : Ctor
-//
-PersistentStorage::PersistentStorage()
-: d( new Private )
-{
- DBG << " Creating XML Files backend" << endl;
-}
-
-void PersistentStorage::init(const Pathname &root)
-{
- //d->backend.reset( new XMLFilesBackend(root) );
-}
-
-bool PersistentStorage::isInitialized() const
-{
- return d->backend;
-}
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : PersistentStorage::~PersistentStorage
-// METHOD TYPE : Dtor
-//
-PersistentStorage::~PersistentStorage()
-{}
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : PersistentStorage::~PersistentStorage
-// METHOD TYPE : Dtor
-//
-void PersistentStorage::doTest()
-{
-// d->backend->doTest();
-}
-
-Date
-PersistentStorage::timestamp() const
-{
-// return d->backend->timestamp();
- return Date();
-}
-
-void
-PersistentStorage::storeObject( ResObject::constPtr resolvable )
-{
-// d->backend->storeObject(resolvable);
-}
-
-void
-PersistentStorage::deleteObject( ResObject::constPtr resolvable )
-{
-// d->backend->deleteObject(resolvable);
-}
-
-std::list<ResObject::Ptr>
-PersistentStorage::storedObjects() const
-{
-// return d->backend->storedObjects();
- return std::list<ResObject::Ptr>();
-}
-
-std::list<ResObject::Ptr>
-PersistentStorage::storedObjects(const Resolvable::Kind kind) const
-{
- //list<ResObject::Ptr>::iterator it;
- //it = find(nums.begin(), nums.end(), 3); // Search the list.
-// return d->backend->storedObjects(kind);
- return std::list<ResObject::Ptr>();
-}
-
-std::list<ResObject::Ptr>
-PersistentStorage::storedObjects(const Resolvable::Kind kind, const std::string & name, bool partial_match) const
-{
-// return d->backend->storedObjects(kind, name, partial_match);
- return std::list<ResObject::Ptr>();
-}
-
-/////////////////////////////////////////////////////////
-// FLAGS API
-////////////////////////////////////////////////////////
-
-void
-PersistentStorage::setObjectFlag( ResObject::constPtr resolvable, const std::string &flag )
-{
-// d->backend->setObjectFlag(resolvable, flag);
-}
-
-void
-PersistentStorage::removeObjectFlag( ResObject::constPtr resolvable, const std::string &flag )
-{
-// d->backend->removeObjectFlag(resolvable, flag);
-}
-
-std::set<std::string>
-PersistentStorage::objectFlags( ResObject::constPtr resolvable ) const
-{
-// return d->backend->objectFlags(resolvable);
- return std::set<std::string>();
-}
-
-bool
-PersistentStorage::doesObjectHasFlag( ResObject::constPtr resolvable, const std::string &flag ) const
-{
-// return d->backend->doesObjectHasFlag(resolvable, flag);
- return false;
-}
-
-/////////////////////////////////////////////////////////
-// Named Flags API
-////////////////////////////////////////////////////////
-
-void
-PersistentStorage::setFlag( const std::string &key, const std::string &flag )
-{
-// d->backend->setFlag(key, flag);
-}
-
-void
-PersistentStorage::removeFlag( const std::string &key, const std::string &flag )
-{
-// d->backend->removeFlag(key, flag);
-}
-
-std::set<std::string>
-PersistentStorage::flags( const std::string &key ) const
-{
-// return d->backend->flags(key);
- return std::set<std::string>();
-}
-
-bool
-PersistentStorage::hasFlag( const std::string &key, const std::string &flag ) const
-{
-// return d->backend->hasFlag(key, flag);
- return false;
-}
-
-/******************************************************************
-**
-** FUNCTION NAME : operator<<
-** FUNCTION TYPE : std::ostream &
-*/
-std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj )
-{
- //return str << *obj._pimpl;
- return str;
-}
- /////////////////////////////////////////////////////////////////
-} // namespace storage
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/target/store/PersistentStorage.h
-*
-*/
-#ifndef ZYPP_TARGET_PERSISTENTSTORAGE_H
-#define ZYPP_TARGET_PERSISTENTSTORAGE_H
-
-#include <iosfwd>
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/base/PtrTypes.h"
-#include <zypp/Pathname.h>
-#include <zypp/Url.h>
-#include <zypp/Date.h>
-#include <zypp/Patch.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace storage
- { /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : PersistentStorage
- //
- /** */
- class PersistentStorage : public base::ReferenceCounted, private base::NonCopyable
- {
- friend std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj );
- typedef intrusive_ptr<PersistentStorage> Ptr;
- typedef intrusive_ptr<const PersistentStorage> constPtr;
- public:
- /** Default ctor */
- PersistentStorage();
- /** Dtor */
- ~PersistentStorage();
- void doTest();
-
- public:
- /**
- * Initializes the Storage when the system is located in some
- * root path. THIS MUST BE CALLED BEFORE DOING ANY OPERATION
- */
- void init(const Pathname &root);
-
- /**
- * true is backend was already initialized
- */
- bool isInitialized() const;
-
- /**
- * last modification
- */
- Date timestamp() const;
-
- /**
- * Stores a Resolvable in the active backend.
- */
- void storeObject( ResObject::constPtr resolvable );
- /**
- * Deletes a Resolvable from the active backend.
- */
- void deleteObject( ResObject::constPtr resolvable );
- /**
- * Query for installed Resolvables.
- */
- std::list<ResObject::Ptr> storedObjects() const;
- /**
- * Query for installed Resolvables of a certain kind.
- */
- std::list<ResObject::Ptr> storedObjects(const Resolvable::Kind kind) const;
- /**
- * Query for installed Resolvables of a certain kind by name
- * \a partial_match allows for text search.
- */
- std::list<ResObject::Ptr> storedObjects(const Resolvable::Kind kind, const std::string & name, bool partial_match = false) const;
- /////////////////////////////////////////////////////////
- // Resolvables Flags API
- ////////////////////////////////////////////////////////
- public:
- /**
- * Set a flag for a resolvable
- */
- void setObjectFlag( ResObject::constPtr resolvable, const std::string &flag );
- /**
- * Removes a flag for a resolvable
- */
- void removeObjectFlag( ResObject::constPtr resolvable, const std::string &flag );
- /**
- * Returns a set of flags a resolvable has stored
- */
- std::set<std::string> objectFlags( ResObject::constPtr resolvable ) const;
- /**
- * True if the resolvable has that flag
- */
- bool doesObjectHasFlag( ResObject::constPtr resolvable, const std::string &flag ) const;
-
- /////////////////////////////////////////////////////////
- // Named Flags API
- ////////////////////////////////////////////////////////
- public:
- void setFlag( const std::string &key, const std::string &flag );
- void removeFlag( const std::string &key, const std::string &flag );
- std::set<std::string> flags( const std::string &key ) const;
- bool hasFlag( const std::string &key, const std::string &flag ) const;
-
- private:
- class Private;
- shared_ptr<Private> d;
- };
- ///////////////////////////////////////////////////////////////////
- /** \relates PersistentStorage Stream output */
- std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj );
-
- /////////////////////////////////////////////////////////////////
- } // namespace storage
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_TARGET_PERSISTENTSTORAGE_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/target/store/XMLFilesBackend.cc
-*
-*/
-#warning NEED XMLFilesBackend TO SolvFile fix
-#if 0
-#include <iostream>
-#include <ctime>
-#include <cstdlib>
-#include <cstdio>
-
-#include "zypp/base/Logger.h"
-#include "zypp/base/Exception.h"
-#include "zypp/base/Random.h"
-#include "zypp/base/Gettext.h"
-#include "zypp/CapFactory.h"
-#include "zypp/Digest.h"
-#include "zypp/ExternalProgram.h"
-
-#include "zypp/parser/xmlstore/XMLProductParser.h"
-#include "zypp/parser/xmlstore/XMLPatternParser.h"
-#include "zypp/parser/xmlstore/XMLPatchParser.h"
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <streambuf>
-
-#include <list>
-
-#include <zypp/TmpPath.h>
-#include <zypp/ZYppFactory.h>
-#include <zypp/ZYpp.h>
-#include <zypp/PathInfo.h>
-
-#include "XMLFilesBackend.h"
-#include "serialize.h"
-
-//#define ZYPP_DB_DIR "/var/lib/zypp_db/"
-#define ZYPP_DB_DIR ( getZYpp()->homePath().asString()+"/db/" )
-
-using std::endl;
-using std::string;
-using std::list;
-using namespace zypp;
-using namespace zypp::filesystem;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-namespace storage
-{ /////////////////////////////////////////////////////////////////
-
-/**
- * the following hardcoded table fixes a bug where Product was
- * serialized to the store using distproduct and distversion
- * in the name/version fields.
- * Those products have missing distversion.
- * The trick is to see the version of the xml format, if it is
- * minor than 2.0, we check if the name matches a dist
- * product and fix the product on construction
- *
- * see: https://bugzilla.novell.com/show_bug.cgi?id=205392
- */
-
-struct PRODUCT_TABLE_ENTRY
-{
- const char * dist_name;
- const char * dist_version;
- const char * product_name;
- const char * product_version;
-};
-
-/**
- * create the map on demand so we
- * create it once and only when
- * needed
- */
-PRODUCT_TABLE_ENTRY* products_table()
-{
- static PRODUCT_TABLE_ENTRY products[] = {
- { "SUSE-Linux-Enterprise-Desktop-i386", "10-0", "SUSE SLED" , "10" },
- { "SUSE-Linux-Enterprise-Desktop-x86_64", "10-0", "SUSE SLED", "10" },
- { "SUSE-Linux-Enterprise-Server-i386", "10-0", "SUSE SLES", "10" },
- { "SUSE-Linux-Enterprise-Server-x86_64", "10-0", "SUSE SLES", "10" },
- { "SUSE-Linux-Enterprise-Server-ppc", "10-0", "SUSE SLES", "10" },
- { "SUSE-Linux-Enterprise-Server-ia64", "10-0", "SUSE SLES", "10" },
- { "SUSE-Linux-Enterprise-Server-s390x", "10-0", "SUSE SLES", "10" },
- { "SUSE-Linux-10.1-CD-download-x86", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-CD-download-ppc", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-CD-download-x86_64", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-CD-x86", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-CD-ppc", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-CD-x86_64", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-DVD9-x86-x86_64", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-OSS-DVD-x86", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-DVD-OSS-i386", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-DVD-OSS-ppc", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-DVD-OSS-x86_64", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-FTP", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-DVD-i386", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-DVD-x86_64", "10.1-0", "SUSE LINUX", "10.1" },
- { "SuSE-Linux-10.1-PromoDVD-i386", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-10.1-DVD9-CTMAGAZIN-x86-x86_64", "10.1-0", "SUSE LINUX", "10.1" },
- { "SUSE-Linux-Enterprise-SDK-i386", "10-0", "SLE SDK", "10" },
- { "SUSE-Linux-Enterprise-SDK-x86_64", "10-0", "SLE SDK", "10" },
- { "SUSE-Linux-Enterprise-SDK-ia64", "10-0", "SLE SDK", "10" },
- { "SUSE-Linux-Enterprise-SDK-s390x", "10-0", "SLE SDK", "10" },
- { "SUSE-Linux-Enterprise-SDK-ppc", "10-0", "SLE SDK", "10" },
- { "SUSE-Linux-Enterprise-RT", "10-0", "SLE RT", "10" },
- { 0L, 0L, 0L, 0L }
- };
-
- return products;
-}
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : XMLFilesBackend::Private
-//
-///////////////////////////////////////////////////////////////////
-class XMLFilesBackend::Private
-{
- public:
- Private()
- { }
- bool randomFileName;
- std::set<Resolvable::Kind> kinds;
- std::set<Resolvable::Kind> kinds_flags;
- Pathname root;
-};
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : XMLFilesBackend
-//
-///////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : XMLFilesBackend::XMLFilesBackend
-// METHOD TYPE : Ctor
-//
-XMLFilesBackend::XMLFilesBackend(const Pathname &root) : Backend(root)
-{
- d = new Private;
- d->randomFileName = false;
- d->root = root;
-
- // types of resolvables stored (supported)
- d->kinds.insert(ResTraits<zypp::Patch>::kind);
- //d->kinds.insert(ResTraits<zypp::Message>::kind);
- //d->kinds.insert(ResTraits<zypp::Script>::kind);
- d->kinds.insert(ResTraits<zypp::Product>::kind);
- d->kinds.insert(ResTraits<zypp::Pattern>::kind);
-
- // types of resolvables stored (supported)
- d->kinds_flags.insert(ResTraits<zypp::Package>::kind);
- d->kinds_flags.insert(ResTraits<zypp::Patch>::kind);
- //d->kinds.insert(ResTraits<zypp::Message>::kind);
- d->kinds_flags.insert(ResTraits<zypp::Script>::kind);
- d->kinds_flags.insert(ResTraits<zypp::Product>::kind);
- d->kinds_flags.insert(ResTraits<zypp::Pattern>::kind);
-
-
- // check if the db exists
- if (!isBackendInitialized())
- {
- DBG << "Database not initialized" << std::endl;
- initBackend();
- // should be initialized now...
- if (!isBackendInitialized())
- DBG << "Error, cant init database" << std::endl;
- else
- DBG << "Database initialized" << std::endl;
- }
- else
- {
- DBG << "Database already initialized" << std::endl;
- }
-}
-
-Date XMLFilesBackend::timestamp() const
-{
- PathInfo ts_info = PathInfo( d->root + Pathname(ZYPP_DB_DIR) + "timestamp" );
- if ( ts_info.isExist() )
- {
- return Date(ts_info.mtime());
- }
- else
- {
- updateTimestamp();
- return Date::now();
- }
-}
-
-bool
-XMLFilesBackend::isBackendInitialized() const
-{
- bool ok = true;
- Pathname dbdir = d->root + ZYPP_DB_DIR;
- ok = ok && PathInfo(dbdir).isExist();
-
- bool fixperms = false;
-
- // The db dir was created with 700 permissions
- // see bug #169094
- if ( ok && PathInfo(dbdir).perm() == 0700 )
- {
- if ( geteuid() == 0 )
- {
- fixperms = true;
- WAR << "Wrong permissions for /var/lib/zypp, will fix" << std::endl;
-
- const char* argv[] =
- {
- "chmod",
- "-R",
- "0755",
- "/var/lib/zypp",
- NULL
- };
-
- ExternalProgram prog(argv,ExternalProgram::Discard_Stderr, false, -1, true);
- prog.close();
- }
- else
- {
- WAR << "Wrong permissions for /var/lib/zypp, but can't fix unless you run as root." << std::endl;
- }
-
- }
-
- // folders for resolvables
- std::set<Resolvable::Kind>::const_iterator it_kinds;
- for ( it_kinds = d->kinds.begin() ; it_kinds != d->kinds.end(); ++it_kinds )
- {
- Resolvable::Kind kind = (*it_kinds);
- bool isthere = PathInfo( dirForResolvableKind(kind) ).isExist();
- ok = ok && isthere;
- }
-
- // resolvable flags folder flags
- for ( it_kinds = d->kinds_flags.begin() ; it_kinds != d->kinds_flags.end(); ++it_kinds )
- {
- Resolvable::Kind kind = (*it_kinds);
- bool isthere = PathInfo( dirForResolvableKindFlags(kind) ).isExist();
- ok = ok && isthere;
- }
-
- // named flags
- bool nmthere = PathInfo( dirForNamedFlags() ).isExist();
- ok = ok && nmthere;
-
- return ok;
-}
-
-void
-XMLFilesBackend::initBackend()
-{
- // all directories are 755 except the sources directory which can contain passwords
- // in urls.
-
- Pathname topdir = d->root + Pathname(ZYPP_DB_DIR);
- DBG << "Creating directory structure " << topdir << std::endl;
-
- if (0 != assert_dir(topdir, 0755))
- ZYPP_THROW(Exception("Cannot create XMLBackend db directory " + topdir.asString()));
-
- // create dir for resolvables
- std::set<Resolvable::Kind>::const_iterator it_kinds;
- for ( it_kinds = d->kinds.begin() ; it_kinds != d->kinds.end(); ++it_kinds )
- {
- Resolvable::Kind kind = (*it_kinds);
- Pathname p(dirForResolvableKind(kind));
- if (0 != assert_dir(p, 0755))
- ZYPP_THROW(Exception("Cannot create directory " + p.asString()));
- else
- MIL << "Created " << p.asString() << std::endl;
- }
-
- // create dir for resolvables flags
- for ( it_kinds = d->kinds_flags.begin() ; it_kinds != d->kinds_flags.end(); ++it_kinds )
- {
- Resolvable::Kind kind = (*it_kinds);
- Pathname p(dirForResolvableKindFlags(kind));
- if (0 != assert_dir(p, 0755))
- ZYPP_THROW(Exception("Cannot create directory " + p.asString()));
- else
- MIL << "Created " << p.asString() << std::endl;
- }
-
- // dir for named flags
- Pathname namedflags(dirForNamedFlags());
- if (0 != assert_dir(namedflags, 0755))
- ZYPP_THROW(Exception("Cannot create directory " + namedflags.asString()));
- else
- MIL << "Created " << namedflags.asString() << std::endl;
-}
-
-void XMLFilesBackend::setRandomFileNameEnabled( bool enabled )
-{
- d->randomFileName = enabled;
-}
-
-std::string
-XMLFilesBackend::dirForResolvableKind( Resolvable::Kind kind ) const
-{
- return Pathname( d->root + Pathname(ZYPP_DB_DIR) + Pathname(resolvableKindToString(kind, true)) ).asString();
-}
-
-std::string
-XMLFilesBackend::dirForResolvableKindFlags( Resolvable::Kind kind ) const
-{
- return Pathname( d->root + Pathname(ZYPP_DB_DIR) + Pathname("flags") + Pathname(resolvableKindToString(kind, true)) ).asString();
-}
-
-std::string
-XMLFilesBackend::dirForNamedFlags() const
-{
- return Pathname( d->root + Pathname(ZYPP_DB_DIR) + Pathname("named-flags")).asString();
-}
-
-std::string
-XMLFilesBackend::dirForResolvable( ResObject::constPtr resolvable ) const
-{
- return dirForResolvableKind(resolvable->kind());
-}
-
-std::string
-XMLFilesBackend::dirForResolvableFlags( ResObject::constPtr resolvable ) const
-{
- return dirForResolvableKindFlags(resolvable->kind());
-}
-
-std::string
-XMLFilesBackend::fileNameForNVR( const NVR &nvr ) const
-{
- std::string filename;
- filename = nvr.name;
- if ( nvr.edition != Edition::noedition )
- {
- filename += "-" + nvr.edition.asString();
- }
- // get rid of spaces and other characters
- std::stringstream filename_stream(filename);
- std::string filename_encoded = Digest::digest("MD5", filename_stream);
- return filename_encoded;
-}
-
-std::string
-XMLFilesBackend::fileNameForResolvable( ResObject::constPtr resolvable ) const
-{
- return fileNameForNVR( NVR( resolvable->name(), resolvable->edition() ) );
-}
-
-std::string
-XMLFilesBackend::fullPathForResolvable( ResObject::constPtr resolvable ) const
-{
- return( Pathname( dirForResolvable(resolvable) ) / fileNameForResolvable(resolvable) ).asString();
-}
-
-std::string
-XMLFilesBackend::fullPathForNamedFlags( const std::string &key ) const
-{
- std::stringstream key_stream(key);
- std::string key_encoded = Digest::digest("MD5", key_stream);
- return( Pathname( dirForNamedFlags() ) / key_encoded ).asString();
-}
-
-std::string
-XMLFilesBackend::fullPathForResolvableFlags( ResObject::constPtr resolvable ) const
-{
- // flags are in a hidden file with the same name
- return( Pathname( dirForResolvableFlags(resolvable) ) / fileNameForResolvable(resolvable) ).asString();
-}
-
-void
-XMLFilesBackend::setObjectFlag( ResObject::constPtr resolvable, const std::string &flag )
-{
- std::set<std::string> flags = objectFlags(resolvable);
- flags.insert(flag);
- writeObjectFlags(resolvable, flags);
-}
-
-void
-XMLFilesBackend::removeObjectFlag( ResObject::constPtr resolvable, const std::string &flag )
-{
- std::set<std::string> flags = objectFlags(resolvable);
- flags.erase(flag);
- writeObjectFlags(resolvable, flags);
-}
-
-void
-XMLFilesBackend::writeObjectFlags( ResObject::constPtr resolvable, const std::set<std::string> &flags )
-{
- std::string filename = fullPathForResolvableFlags(resolvable);
- writeFlagsInFile( filename, flags );
- MIL << "Wrote " << flags.size() << " flags for " << resolvable->name() << " " << resolvable->edition() << std::endl;
-}
-
-std::set<std::string>
-XMLFilesBackend::objectFlags( ResObject::constPtr resolvable ) const
-{
- std::string filename = fullPathForResolvableFlags(resolvable);
- return flagsFromFile(filename);
-}
-
-bool
-XMLFilesBackend::doesObjectHasFlag( ResObject::constPtr resolvable, const std::string &flag ) const
-{
- std::set<std::string> flags = objectFlags(resolvable);
- return (find(flags.begin(), flags.end(), flag) != flags.end());
-}
-
-/////////////////////////////////////////////////////////
-// Named Flags API
-////////////////////////////////////////////////////////
-
-void
-XMLFilesBackend::setFlag( const std::string &key, const std::string &flag )
-{
- std::set<std::string> _flags = flags(key);
- _flags.insert(flag);
- writeFlags(key, _flags);
-}
-
-void
-XMLFilesBackend::removeFlag( const std::string &key, const std::string &flag )
-{
- std::set<std::string> _flags = flags(key);
- _flags.erase(flag);
- writeFlags(key, _flags);
-}
-
-std::set<std::string>
-XMLFilesBackend::flags( const std::string &key ) const
-{
- std::string filename = fullPathForNamedFlags(key);
- return flagsFromFile(filename);
-}
-
-bool
-XMLFilesBackend::hasFlag( const std::string &key, const std::string &flag ) const
-{
- std::set<std::string> _flags = flags(key);
- return (find(_flags.begin(), _flags.end(), flag) != _flags.end());
-}
-
-void
-XMLFilesBackend::writeFlags( const std::string &key, const std::set<std::string> &pflags )
-{
- std::string filename = fullPathForNamedFlags(key);
- writeFlagsInFile( filename, pflags );
- MIL << "Wrote " << pflags.size() << " flags for " << key << std::endl;
-}
-
-/////////////////////////////////////////////////////////
-// Common functions for both named and resolvable flags
-////////////////////////////////////////////////////////
-
-void
-XMLFilesBackend::writeFlagsInFile( const std::string &filename, const std::set<std::string> &pflags )
-{
- std::ofstream file(filename.c_str());
- if (!file) {
- ZYPP_THROW (Exception( "Can't open " + filename ) );
- }
-
- try
- {
- for ( std::set<std::string>::const_iterator it = pflags.begin(); it != pflags.end(); it++)
- {
- // dont save empty strings
- if ( *it == std::string() )
- continue;
- else
- file << *it << std::endl;
- }
- file << std::endl;
- MIL << "Wrote " << pflags.size() << " flags in " << filename << std::endl;
- }
- catch( std::exception &e )
- {
- ZYPP_THROW(Exception("Can't write flags to store"));
- }
- updateTimestamp();
-}
-
-std::set<std::string>
-XMLFilesBackend::flagsFromFile( const std::string &filename ) const
-{
- std::set<std::string> _flags;
- // do we have previous saved flags?
- if ( ! PathInfo( filename ).isExist() )
- return _flags;
-
- std::ifstream file(filename.c_str());
- if (!file) {
- ZYPP_THROW (Exception( "Can't open " + filename ) );
- }
-
- std::string buffer;
- while(file && !file.eof())
- {
- getline(file, buffer);
- if (buffer == std::string())
- continue;
-
- _flags.insert(buffer);
- }
- //MIL << "Read " << flags.size() << " flags for " << resolvable->name() << " " << resolvable->edition() << std::endl;
- return _flags;
-}
-
-void
-XMLFilesBackend::updateTimestamp() const
-{
- Pathname filename = d->root + Pathname(ZYPP_DB_DIR) + "timestamp";
- std::ofstream file(filename.asString().c_str(), std::ios::out);
- if (!file)
- {
- ZYPP_THROW (Exception( "Can't open timestamp file " + filename.asString() ) );
- }
- file.close();
-}
-
-/////////////////////////////////////////////////////////
-// Resolvables storage
-////////////////////////////////////////////////////////
-
-void
-XMLFilesBackend::storeObject( ResObject::constPtr resolvable )
-{
- // only ignore if it is not a supported resolvable kind
- std::set<Resolvable::Kind>::const_iterator it;
- it = find(d->kinds.begin(), d->kinds.end(), resolvable->kind() );
- if (it == d->kinds.end())
- {
- ERR << "This backend was not designed to store resolvable of kind " << resolvableKindToString(resolvable->kind()) << ", ignoring..." << std::endl;
- return;
- }
-
- std::string xml = castedToXML(resolvable);
- std::string filename = fullPathForResolvable(resolvable);
- //DBG << std::endl << xml << std::endl;
- std::ofstream file;
- //DBG << filename << std::endl;
- try
- {
- file.open(filename.c_str());
- file << xml;
- file.close();
- }
- catch(std::exception &e)
- {
- ERR << "Error saving resolvable " << resolvable << std::endl;
- ZYPP_THROW(Exception(e.what()));
- }
- updateTimestamp();
-}
-
-void
-XMLFilesBackend::deleteFileObject( const Pathname &filename ) const
-{
- try
- {
- int ret = filesystem::unlink( filename );
- if ( ret != 0 && ret != ENOENT )
- {
- ERR << "Error removing resolvable file " << filename << std::endl;
- ZYPP_THROW(Exception("Error deleting " + filename.asString()));
- }
- updateTimestamp();
- }
- catch(std::exception &e)
- {
- ERR << "Error removing resolvable file " << filename << std::endl;
- ZYPP_THROW(Exception(e.what()));
- }
-}
-
-void
-XMLFilesBackend::deleteObject( ResObject::constPtr resolvable )
-{
- // only ignore if it is not a supported resolvable kind
- std::set<Resolvable::Kind>::const_iterator it;
- it = find(d->kinds.begin(), d->kinds.end(), resolvable->kind() );
- if (it == d->kinds.end())
- {
- ERR << "This backend was not designed to store resolvable of kind " << resolvableKindToString(resolvable->kind()) << ", ignoring..." << std::endl;
- return;
- }
-
- // only remove the file
- try
- {
- deleteFileObject( fullPathForResolvable(resolvable) );
- }
- catch ( const Exception &e )
- {
- ERR << "Error removing resolvable " << resolvable << std::endl;
- ZYPP_RETHROW(e);
- }
-}
-
-std::list<ResObject::Ptr> XMLFilesBackend::resolvablesFromFile( std::string file_path, Resolvable::Kind kind ) const
-{
- MIL << "[" << resolvableKindToString( kind, false ) << "] - " << file_path << std::endl;
- std::list<ResObject::Ptr> resolvables;
- std::ifstream res_file(file_path.c_str());
- if ( kind == ResTraits<zypp::Patch>::kind )
- {
- // a patch file can contain more than one patch, but we store only
- // one patch, so we break at the first
- // FIXME how can we avoid creating this for every object?
- try {
- XMLPatchParser iter(res_file,"");
- for (; !iter.atEnd(); ++iter)
- {
- Patch::Ptr patch = createPatch(**iter);
- resolvables.push_back(patch);
- Patch::AtomList atoms = patch->atoms();
- for (Patch::AtomList::iterator at = atoms.begin(); at != atoms.end(); at++)
- resolvables.push_back(*at);
-
- break;
- }
- }
- catch (const Exception & excpt_r)
- {
- ZYPP_CAUGHT( excpt_r );
- WAR << "Skipping invalid patch file " << file_path << endl;
- }
- }
- else if ( kind == ResTraits<zypp::Product>::kind )
- {
- XMLProductParser iter(res_file,"");
- for (; !iter.atEnd(); ++iter)
- {
- resolvables.push_back(createProduct(**iter));
- break;
- }
- }
- else if ( kind == ResTraits<zypp::Pattern>::kind )
- {
- XMLPatternParser iter(res_file,"");
- for (; !iter.atEnd(); ++iter)
- {
- resolvables.push_back(createPattern(**iter));
- break;
- }
- }
- else
- {
- /* nothing for now */
- }
- return resolvables;
-}
-
-std::list<ResObject::Ptr>
-XMLFilesBackend::storedObjects() const
-{
- DBG << std::endl;
- std::list<ResObject::Ptr> objects;
-
- std::set<Resolvable::Kind>::const_iterator it_kinds;
- for ( it_kinds = d->kinds.begin() ; it_kinds != d->kinds.end(); ++it_kinds )
- {
- Resolvable::Kind kind = (*it_kinds);
- std::list<ResObject::Ptr> objects_for_kind = storedObjects(kind);
- std::list<ResObject::Ptr>::iterator it;
- for( it = objects_for_kind.begin(); it != objects_for_kind.end(); ++it)
- {
- //DBG << "adding objects back" << std::endl;
- objects.push_back(*it);
- }
- }
- return objects;
-}
-
-std::list<ResObject::Ptr>
-XMLFilesBackend::storedObjects(const Resolvable::Kind kind) const
-{
- std::list<ResObject::Ptr> objects;
- Pathname dir_path(dirForResolvableKind(kind));
- DBG << "Reading objects of kind " << resolvableKindToString(kind) << " in " << dir_path << std::endl;
- // return empty list if the dir does not exist
- if ( ! PathInfo( dir_path ).isExist() )
- {
- ERR << "path " << dir_path << " does not exists. Required to read objects of kind " << resolvableKindToString(kind) << std::endl;
- return std::list<ResObject::Ptr>();
- }
-
- list<string> files;
- filesystem::readdir( files, dir_path, false /* ignore hidden .name files */ );
-
- for ( list<string>::const_iterator it = files.begin(); it != files.end(); ++it )
- {
- Pathname curr_file = dir_path + (*it);
- DBG << "[" << resolvableKindToString( kind, false ) << "] - " << curr_file << std::endl;
- std::list<ResObject::Ptr> objects_for_file;
- objects_for_file = resolvablesFromFile( curr_file.asString(), kind);
- for ( std::list<ResObject::Ptr>::iterator it = objects_for_file.begin(); it != objects_for_file.end(); ++it)
- objects.push_back(*it);
- }
-
- MIL << "done reading " << objects.size() << " stored objects for file of kind " << resolvableKindToString(kind) << std::endl;
- return objects;
-}
-
-std::list<ResObject::Ptr>
-XMLFilesBackend::storedObjects(const Resolvable::Kind kind, const std::string & name, bool partial_match) const
-{
- std::list<ResObject::Ptr> result;
- std::list<ResObject::Ptr> all;
- all = storedObjects(kind);
- std::list<ResObject::Ptr>::const_iterator it;
- for( it = all.begin(); it != all.end(); ++it)
- {
- ResObject::Ptr item = *it;
- if (item->name() == name )
- result.push_back(item);
- }
- MIL << "done reading stored objects of kind " << resolvableKindToString(kind) << " and keyword [" << name <<"]" << std::endl;
- return result;
-}
-
-Patch::Ptr
-XMLFilesBackend::createPatch( const zypp::parser::xmlstore::XMLPatchData & parsed ) const
-{
- try
- {
- detail::ResImplTraits<XMLPatchImpl>::Ptr impl(new XMLPatchImpl());
- impl->_patch_id = parsed.patchId;
- impl->_timestamp = str::strtonum<time_t>(parsed.timestamp);
- impl->_category = parsed.category;
- impl->_reboot_needed = parsed.rebootNeeded;
- impl->_affects_pkg_manager = parsed.packageManager;
- // impl._atoms -> std::list<shared_ptr<YUMPatchAtom> > parsed.atoms */
-
- impl->_summary = parsed.summary;
- impl->_description = parsed.summary;
-
- impl->_install_notify = parsed.install_notify;
- impl->_delete_notify = parsed.delete_notify;
- impl->_license_to_confirm = parsed.license_to_confirm;
- impl->_vendor = parsed.vendor;
- impl->_size = parsed.size;
- impl->_downloadSize = parsed.downloadSize;
- impl->_install_only = parsed.install_only;
- impl->_build_time = parsed.build_time;
- impl->_install_time = parsed.install_time;
-
- Arch arch;
- if (!parsed.arch.empty())
- arch = Arch(parsed.arch);
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name,
- Edition( parsed.ver, parsed.rel, parsed.epoch ), arch,
- createDependencies(parsed, ResTraits<Patch>::kind) );
- Patch::Ptr patch = detail::makeResolvableFromImpl( dataCollect, impl );
- CapFactory _f;
-
- //MIL << parsed.atoms.size() << " to process" << std::endl;
-
- // now process the atoms
- ResObject::Ptr atom;
- for (std::list<XMLPatchAtomData_Ptr >::const_iterator it = parsed.atoms.begin(); it != parsed.atoms.end(); it++)
- {
- switch ((*it)->atomType())
- {
- case XMLPatchAtomData::Atom:
- {
- // atoms are mostly used for packages
- // we dont create a package resolvable and then add it to the atoms list, because we
- // dont know if the package is in the pool or not. It is different to Scripts and Messages
- // that are actually contributed to the Patch itself, instead we create and atom, make
- // the patch require the atom, the atom require and freshens the package.
-
- // get the parsed patch atom data
- XMLPatchAtomData_Ptr atom_data = dynamic_pointer_cast<XMLPatchAtomData>(*it);
- atom = createAtom(*atom_data);
- impl->_atoms.push_back(atom);
- break;
- }
- case XMLPatchAtomData::Message:
- {
- XMLPatchMessageData_Ptr message_data = dynamic_pointer_cast<XMLPatchMessageData>(*it);
- atom = createMessage(*message_data);
- impl->_atoms.push_back(atom);
- break;
- }
- case XMLPatchAtomData::Script:
- {
- XMLPatchScriptData_Ptr script_data = dynamic_pointer_cast<XMLPatchScriptData>(*it);
- atom = createScript(*script_data);
- if ( doesObjectHasFlag( atom, "SCRIPT_EXEC_FAILED" ) )
- {
- WAR << "Patch script not yet successfully executed: " << atom << endl;
- } else {
- impl->_atoms.push_back(atom);
- }
- break;
- }
- default:
- ERR << "Unknown type of atom" << endl;
- }
- // the patch should depends on its atoms, so we inject a requires on the just created atom resolvable
- Capability cap( _f.parse(atom->kind(), atom->name(), Rel::EQ, atom->edition() ));
-#warning CANT INJECTD DEPENDENCIES HERE ANYMORE
-#if 0
- patch->injectRequires(cap);
-#endif
- }
- return patch;
- }
- catch (const Exception & excpt_r)
- {
- ZYPP_CAUGHT(excpt_r);
- Exception nexcpt("Cannot create patch object");
- nexcpt.remember(excpt_r);
- ZYPP_THROW(nexcpt);
- }
- return 0L;
-}
-
-Atom::Ptr
-XMLFilesBackend::createAtom( const zypp::parser::xmlstore::XMLPatchAtomData & parsed ) const
-{
- try
- {
- detail::ResImplTraits<XMLAtomImpl>::Ptr impl(new XMLAtomImpl());
-
- Arch arch;
- if (!parsed.arch.empty())
- arch = Arch(parsed.arch);
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name, Edition( parsed.ver, parsed.rel, parsed.epoch ), arch, createDependencies(parsed, ResTraits<Atom>::kind) );
-
- impl->_summary = parsed.summary;
- impl->_description = parsed.summary;
-
- impl->_install_notify = parsed.install_notify;
- impl->_delete_notify = parsed.delete_notify;
- impl->_license_to_confirm = parsed.license_to_confirm;
- impl->_vendor = parsed.vendor;
- impl->_size = parsed.size;
- impl->_downloadSize = parsed.downloadSize;
- impl->_install_only = parsed.install_only;
- impl->_build_time = parsed.build_time;
- impl->_install_time = parsed.install_time;
-
- Atom::Ptr atom = detail::makeResolvableFromImpl( dataCollect, impl);
- return atom;
- }
- catch (const Exception & excpt_r)
- {
- ZYPP_CAUGHT(excpt_r);
- Exception nexcpt("Cannot create atom object");
- nexcpt.remember(excpt_r);
- ZYPP_THROW(nexcpt);
- }
- return 0L;
-}
-
-Message::Ptr
-XMLFilesBackend::createMessage( const zypp::parser::xmlstore::XMLPatchMessageData & parsed ) const
-{
- try
- {
- detail::ResImplTraits<XMLMessageImpl>::Ptr impl(new XMLMessageImpl());
- impl->_text = parsed.text;
-
- Arch arch;
- if (!parsed.arch.empty())
- arch = Arch(parsed.arch);
-
- impl->_summary = parsed.summary;
- impl->_description = parsed.summary;
-
- impl->_install_notify = parsed.install_notify;
- impl->_delete_notify = parsed.delete_notify;
- impl->_license_to_confirm = parsed.license_to_confirm;
- impl->_vendor = parsed.vendor;
- impl->_size = parsed.size;
- impl->_downloadSize = parsed.downloadSize;
- impl->_install_only = parsed.install_only;
- impl->_build_time = parsed.build_time;
- impl->_install_time = parsed.install_time;
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name, Edition( parsed.ver, parsed.rel, parsed.epoch ), arch, createDependencies(parsed, ResTraits<Message>::kind) );
- Message::Ptr message = detail::makeResolvableFromImpl( dataCollect, impl);
- return message;
- }
- catch (const Exception & excpt_r)
- {
- ZYPP_CAUGHT(excpt_r);
- Exception nexcpt("Cannot create message object");
- nexcpt.remember(excpt_r);
- ZYPP_THROW(nexcpt);
- }
- return 0L;
-}
-
-Script::Ptr
-XMLFilesBackend::createScript(const zypp::parser::xmlstore::XMLPatchScriptData & parsed ) const
-{
- try
- {
- detail::ResImplTraits<XMLScriptImpl>::Ptr impl(new XMLScriptImpl());
-
- impl->_doScript = parsed.doScript;
- impl->_undoScript = parsed.undoScript;
-
- Arch arch;
- if (!parsed.arch.empty())
- arch = Arch(parsed.arch);
-
- impl->_summary = parsed.summary;
- impl->_description = parsed.summary;
-
- impl->_install_notify = parsed.install_notify;
- impl->_delete_notify = parsed.delete_notify;
- impl->_license_to_confirm = parsed.license_to_confirm;
- impl->_vendor = parsed.vendor;
- impl->_size = parsed.size;
- impl->_downloadSize = parsed.downloadSize;
- impl->_install_only = parsed.install_only;
- impl->_build_time = parsed.build_time;
- impl->_install_time = parsed.install_time;
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name, Edition( parsed.ver, parsed.rel, parsed.epoch ), arch, createDependencies(parsed, ResTraits<Script>::kind));
- Script::Ptr script = detail::makeResolvableFromImpl( dataCollect, impl );
- return script;
- }
- catch (const Exception & excpt_r)
- {
- ZYPP_CAUGHT(excpt_r);
- Exception nexcpt("Cannot create script object");
- nexcpt.remember(excpt_r);
- ZYPP_THROW(nexcpt);
- }
- catch (const std::exception & excpt_r)
- {
- ERR << excpt_r.what() << endl;
- ZYPP_THROW(Exception("Cannot create script object"));
- }
- return 0L;
-}
-
-Product::Ptr
-XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & parsed ) const
-{
- try
- {
- detail::ResImplTraits<XMLProductImpl>::Ptr impl(new XMLProductImpl());
-
- Edition parser_edition = ( parsed.parser_version.empty() ? Edition::noedition : Edition(parsed.parser_version) );
-
- impl->_summary = parsed.summary;
- impl->_description = parsed.summary;
-
- impl->_install_notify = parsed.install_notify;
- impl->_delete_notify = parsed.delete_notify;
- impl->_license_to_confirm = parsed.license_to_confirm;
- impl->_vendor = parsed.vendor;
- impl->_size = parsed.size;
- impl->_downloadSize = parsed.downloadSize;
- impl->_install_only = parsed.install_only;
- impl->_build_time = parsed.build_time;
- impl->_install_time = parsed.install_time;
-
- impl->_type = parsed.type;
- impl->_short_name = parsed.short_name;
- impl->_dist_name = parsed.dist_name;
- impl->_dist_version = Edition( parsed.dist_version );
-
- if ( parsed.releasenotesurl.size() > 0 )
- impl->_release_notes_url = parsed.releasenotesurl;
- else
- impl->_release_notes_url = Url();
-
- // update_urls
- list<string> update_urls = parsed.update_urls;
- for ( list<string>::const_iterator it = update_urls.begin(); it != update_urls.end(); ++it )
- {
- try
- {
- Url u(*it);
- impl->_update_urls.push_back (u);
- }
- catch ( const Exception &e )
- {
- ZYPP_CAUGHT(e);
- Exception ne("Error parsing update url: " + e.msg());
- ne.remember(e);
- ZYPP_THROW(ne);
- }
- }
-
- // extra_urls
- list<string> extra_urls = parsed.extra_urls;
- for ( list<string>::const_iterator it = extra_urls.begin(); it != extra_urls.end(); ++it )
- {
- try
- {
- Url u(*it);
- impl->_extra_urls.push_back (u);
- }
- catch ( const Exception &e )
- {
- ZYPP_CAUGHT(e);
- Exception ne("Error parsing extra url: " + e.msg());
- ne.remember(e);
- ZYPP_THROW(ne);
- }
- }
-
- // extra_urls
- list<string> optional_urls = parsed.optional_urls;
- for ( list<string>::const_iterator it = optional_urls.begin(); it != optional_urls.end(); ++it )
- {
- try
- {
- Url u(*it);
- impl->_optional_urls.push_back (u);
- }
- catch ( const Exception &e )
- {
- ZYPP_CAUGHT(e);
- Exception ne("Error parsing optional url: " + e.msg());
- ne.remember(e);
- ZYPP_THROW(ne);
- }
- }
-
- impl->_flags = parsed.flags;
-
- Arch arch;
- if (!parsed.arch.empty())
- arch = Arch(parsed.arch);
-
- Edition prod_edition( parsed.ver, parsed.rel, parsed.epoch );
- string prod_name(parsed.name);
- // check for product name to see if it was written with distname
- // as name as part of https://bugzilla.novell.com/show_bug.cgi?id=205392
- bool save_new_product_again_workaround = false;
- if ( parser_edition == Edition::noedition )
- {
- MIL << "Product " << parsed.name << " " << prod_edition << " possibly suffers from bug #205392. checking..." << endl;
- PRODUCT_TABLE_ENTRY *all_products = products_table();
- while ( all_products->dist_name != 0L )
- {
- //MIL << "Checking " << parsed.name << " " << prod_edition << " with " << all_products->dist_name << " " << all_products->dist_version << endl;
- if ( ( parsed.name == all_products->dist_name ) && ( prod_edition.asString() == all_products->dist_version ) )
- {
- MIL << "[ATTENTION] Detected bug #205392. Product " << parsed.name << " " << prod_edition << " will be changed to " << all_products->product_name << " " << all_products->product_version << std::endl;
-
- // save pathname of the old wrong product
- Pathname wrong_product = Pathname(dirForResolvableKind(ResTraits<zypp::Product>::kind)) + fileNameForNVR( NVR( parsed.name, prod_edition) );
-
- // ok, potentially this is a wrong product, well, IT IS!
- // overwrte those here as they are used in dataCollect
- prod_name = string(all_products->product_name);
- prod_edition = Edition(all_products->product_version);
-
- // those were already set, so reset them.
- impl->_dist_name = all_products->dist_name;
- impl->_dist_version = Edition(all_products->dist_version);
-
- // ok, now mark for save this product and delete the old one
- deleteFileObject( wrong_product );
- MIL << "Fix for bug #205392 Old product deleted." << std::endl;
- save_new_product_again_workaround = true;
- break;
- }
- ++all_products;
- }
-
- }
-
- // replace spaces to underscores
- std::replace(prod_name.begin(), prod_name.end(), ' ', '_');
-
- // Collect basic Resolvable data
- NVRAD dataCollect( prod_name, prod_edition, arch, createDependencies(parsed, ResTraits<Product>::kind) );
- Product::Ptr product = detail::makeResolvableFromImpl( dataCollect, impl );
-
- if ( save_new_product_again_workaround )
- {
- const_cast<XMLFilesBackend *>(this)->storeObject(product);
- MIL << "Fixed Product saved. Fix for bug #205392. complete" << std::endl;
- }
-
- return product;
- }
- catch (const Exception & excpt_r)
- {
- ZYPP_CAUGHT(excpt_r);
- Exception nexcpt("Cannot create product object");
- nexcpt.remember(excpt_r);
- ZYPP_THROW(nexcpt);
- }
- return 0L;
-}
-
-Pattern::Ptr
-XMLFilesBackend::createPattern( const zypp::parser::xmlstore::XMLPatternData & parsed ) const
-{
- try
- {
- detail::ResImplTraits<XMLPatternImpl>::Ptr impl(new XMLPatternImpl());
-
- impl->_summary = parsed.summary;
- impl->_description = parsed.summary;
-
- impl->_install_notify = parsed.install_notify;
- impl->_delete_notify = parsed.delete_notify;
- impl->_license_to_confirm = parsed.license_to_confirm;
- impl->_vendor = parsed.vendor;
- impl->_size = parsed.size;
- impl->_downloadSize = parsed.downloadSize;
- impl->_install_only = parsed.install_only;
- impl->_build_time = parsed.build_time;
- impl->_install_time = parsed.install_time;
-
- impl->_user_visible = parsed.userVisible;
- impl->_default = ((parsed.default_ == "false" ) ? false : true );
- impl->_category = parsed.category;
- impl->_icon = parsed.icon;
- impl->_script = parsed.script;
-
- Arch arch;
- if (!parsed.arch.empty())
- arch = Arch(parsed.arch);
-
- // Workaround for bug #307743:
- // Hijack installed patterns with empty vendor.
- if ( impl->_vendor.empty() )
- {
- impl->_vendor = "SUSE (assumed)";
- }
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name, Edition( parsed.ver, parsed.rel, parsed.epoch ), arch, createDependencies( parsed, ResTraits<Pattern>::kind));
- Pattern::Ptr pattern = detail::makeResolvableFromImpl( dataCollect, impl );
- return pattern;
- }
- catch (const Exception & excpt_r)
- {
- ZYPP_CAUGHT(excpt_r);
- Exception nexcpt("Cannot create installation pattern object");
- nexcpt.remember(excpt_r);
- ZYPP_THROW(nexcpt);
- }
- return 0L;
-}
-
-
-Dependencies
-XMLFilesBackend::createDependencies( const zypp::parser::xmlstore::XMLResObjectData & parsed, const Resolvable::Kind my_kind ) const
-{
- Dependencies _deps;
- for (std::list<XMLDependency>::const_iterator it = parsed.provides.begin(); it != parsed.provides.end(); it++)
- {
- _deps[Dep::PROVIDES].insert(createCapability(*it, my_kind));
- }
- for (std::list<XMLDependency>::const_iterator it = parsed.conflicts.begin(); it != parsed.conflicts.end(); it++)
- {
- _deps[Dep::CONFLICTS].insert(createCapability(*it, my_kind));
- }
-
- for (std::list<XMLDependency>::const_iterator it = parsed.obsoletes.begin(); it != parsed.obsoletes.end(); it++)
- {
- _deps[Dep::OBSOLETES].insert(createCapability(*it, my_kind));
- }
-
- for (std::list<XMLDependency>::const_iterator it = parsed.freshens.begin(); it != parsed.freshens.end(); it++)
- {
- _deps[Dep::FRESHENS].insert(createCapability(*it, my_kind));
- }
-
- for (std::list<XMLDependency>::const_iterator it = parsed.recommends.begin(); it != parsed.recommends.end(); it++)
- {
- _deps[Dep::RECOMMENDS].insert(createCapability(*it, my_kind));
- }
-
- for (std::list<XMLDependency>::const_iterator it = parsed.suggests.begin(); it != parsed.suggests.end(); it++)
- {
- _deps[Dep::SUGGESTS].insert(createCapability(*it, my_kind));
- }
-
- for (std::list<XMLDependency>::const_iterator it = parsed.enhances.begin(); it != parsed.enhances.end(); it++)
- {
- _deps[Dep::ENHANCES].insert(createCapability(*it, my_kind));
- }
-
- for (std::list<XMLDependency>::const_iterator it = parsed.requires.begin(); it != parsed.requires.end(); it++)
- {
- _deps[Dep::REQUIRES].insert(createCapability(*it, my_kind));
- }
-
- for (std::list<XMLDependency>::const_iterator it = parsed.prerequires.begin(); it != parsed.prerequires.end(); it++)
- {
- _deps[Dep::PREREQUIRES].insert(createCapability(*it, my_kind));
- }
- return _deps;
-}
-
-Capability
-XMLFilesBackend::createCapability(const XMLDependency & dep, const Resolvable::Kind & my_kind) const
-{
- CapFactory _f;
- Resolvable::Kind _kind = dep.kind == "" ? my_kind : Resolvable::Kind(dep.kind);
- Capability cap;
- cap = _f.parse( _kind, dep.encoded );
- return cap;
-}
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : XMLFilesBackend::~XMLFilesBackend
-// METHOD TYPE : Dtor
-//
-XMLFilesBackend::~XMLFilesBackend()
-{
- delete d;
-}
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : XMLFilesBackend::doTest()
-// METHOD TYPE : Dtor
-//
-void XMLFilesBackend::doTest()
-{}
-
-/******************************************************************
-**
-** FUNCTION NAME : operator<<
-** FUNCTION TYPE : std::ostream &
-*/
-std::ostream & operator<<( std::ostream & str, const XMLFilesBackend & obj )
-{
- return str;
-}
-
-/////////////////////////////////////////////////////////////////
-} // namespace storage
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/target/store/XMLFilesBackend.h
-*
-*/
-#ifndef DEVEL_DEVEL_DMACVICAR_XMLFILESBACKEND_H
-#define DEVEL_DEVEL_DMACVICAR_XMLFILESBACKEND_H
-#if 0
-#include <iosfwd>
-
-#include "zypp/NVR.h"
-#include "zypp/ResObjects.h"
-
-#include "zypp/parser/xmlstore/XMLParserData.h"
-
-#include "zypp/base/PtrTypes.h"
-#include "Backend.h"
-
-using namespace zypp;
-using namespace zypp::parser::xmlstore;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace storage
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : XMLFilesBackend
-//
-/** */
-class XMLFilesBackend : public Backend
-{
- friend std::ostream & operator<<( std::ostream & str, const XMLFilesBackend & obj );
-public:
- typedef intrusive_ptr<XMLFilesBackend> Ptr;
- typedef intrusive_ptr<const XMLFilesBackend> constPtr;
-
- public:
- /** Default ctor */
- XMLFilesBackend(const Pathname &root);
- /** Dtor */
- ~XMLFilesBackend();
- void setRandomFileNameEnabled( bool enabled );
- virtual void doTest();
-
- /**
- * is the storage backend initialized
- */
- virtual bool isBackendInitialized() const;
- /**
- * initialize the storage backend
- */
- virtual void initBackend();
-
- virtual Date timestamp() const;
-
- /**
- * Stores a Resolvable in the active backend.
- */
- virtual void storeObject( ResObject::constPtr resolvable ) ;
- /**
- * Deletes a Resolvable from the active backend.
- */
- virtual void deleteObject( ResObject::constPtr resolvable );
- /**
- * Deletes a Resolvable from the active backend.
- */
- virtual std::list<ResObject::Ptr> storedObjects() const;
- /**
- * Query for installed Resolvables of a certain kind
- */
- virtual std::list<ResObject::Ptr> storedObjects(const Resolvable::Kind) const;
- /**
- * Query for installed Resolvables of a certain kind by name
- * \a partial_match allows for text search.
- */
- virtual std::list<ResObject::Ptr> storedObjects(const Resolvable::Kind, const std::string & name, bool partial_match = false) const;
-
- /////////////////////////////////////////////////////////
- // Resolvables Flags API
- ////////////////////////////////////////////////////////
- public:
- void setObjectFlag( ResObject::constPtr resolvable, const std::string &flag );
- void removeObjectFlag( ResObject::constPtr resolvable, const std::string &flag );
- std::set<std::string> objectFlags( ResObject::constPtr resolvable ) const;
- bool doesObjectHasFlag( ResObject::constPtr resolvable, const std::string &flag ) const;
-
- /////////////////////////////////////////////////////////
- // Named Flags API
- ////////////////////////////////////////////////////////
- public:
- void setFlag( const std::string &key, const std::string &flag );
- void removeFlag( const std::string &key, const std::string &flag );
- std::set<std::string> flags( const std::string &key ) const;
- bool hasFlag( const std::string &key, const std::string &flag ) const;
-
- protected:
- void writeObjectFlags( ResObject::constPtr resolvable, const std::set<std::string> &pflags );
- void writeFlags( const std::string &key, const std::set<std::string> &pflags );
-
- void writeFlagsInFile( const std::string &filename, const std::set<std::string> &pflags );
- std::set<std::string> flagsFromFile( const std::string &filename ) const;
-
- void updateTimestamp() const;
-
- protected:
-
- /**
- * delete a path in the database, only used by deleteObject
- * and workarounds
- */
- void deleteFileObject( const Pathname &filename ) const;
-
- /**
- * Directory where the xml file is stored (for the given resolvable)
- */
- std::string dirForResolvable( ResObject::constPtr resolvable ) const;
- /**
- * Directory where the flags are stored (for the given resolvable)
- */
- std::string dirForResolvableFlags( ResObject::constPtr resolvable ) const;
-
- /**
- * Encoded filename for a resolvable NVR. Does not take kind into account.
- */
- std::string fileNameForNVR( const zypp::NVR &nvr ) const;
-
- /**
- * Encoded filename for a resolvable. Does not take kind into account.
- */
- std::string fileNameForResolvable( ResObject::constPtr resolvable ) const;
- /**
- * Encoded filename for resolvable flags. Does not take kind into account.
- */
- std::string fullPathForResolvableFlags( ResObject::constPtr resolvable ) const;
- /**
- * dir for named flags
- */
- std::string dirForNamedFlags() const;
- /**
- * full path for named flags
- */
- std::string fullPathForNamedFlags( const std::string &key ) const;
-
-
- /**
- * Directory where the xml file is stored (for the given resolvable kind)
- */
- std::string dirForResolvableKind( Resolvable::Kind kind ) const;
- /**
- * Directory where the flags are stored (for the given resolvable kind)
- */
- std::string dirForResolvableKindFlags( Resolvable::Kind kind ) const;
- /**
- * Full path to the xml file for a given resolvable
- * Does not care if the resolvable is yet stored or not
- */
- std::string fullPathForResolvable( ResObject::constPtr resolvable ) const;
- /**
- * Full path to the xml file for a given resolvable
- * Does not care if the resolvable is yet stored or not
- */
- std::list<ResObject::Ptr> resolvablesFromFile( std::string file_path, Resolvable::Kind kind ) const;
-
- Patch::Ptr createPatch( const zypp::parser::xmlstore::XMLPatchData & parsed ) const;
- Message::Ptr createMessage( const zypp::parser::xmlstore::XMLPatchMessageData & parsed ) const;
- Script::Ptr createScript(const zypp::parser::xmlstore::XMLPatchScriptData & parsed ) const;
- Product::Ptr createProduct( const zypp::parser::xmlstore::XMLProductData & parsed ) const;
- Pattern::Ptr createPattern( const zypp::parser::xmlstore::XMLPatternData & parsed ) const;
- Atom::Ptr createAtom( const zypp::parser::xmlstore::XMLPatchAtomData & parsed ) const;
-
- Dependencies createDependencies( const zypp::parser::xmlstore::XMLResObjectData & parsed, const Resolvable::Kind my_kind ) const;
-
- Capability createCapability(const XMLDependency & dep, const Resolvable::Kind & my_kind) const;
-
- private:
- class Private;
- Private *d;
-};
-
-///////////////////////////////////////////////////////////////////
-/** \relates XMLFilesBackend Stream output */
-std::ostream & operator<<( std::ostream & str, const XMLFilesBackend & obj );
-/////////////////////////////////////////////////////////////////
-} // namespace devel.dmacvicar
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace devel
-///////////////////////////////////////////////////////////////////
-#endif
-#endif // DEVEL_DEVEL_DMACVICAR_SQLITEBACKEND_H
+++ /dev/null
-/*\r
-IoBind Library License:\r
---------------------------\r
-\r
-The zlib/libpng License Copyright (c) 2003 Jonathan de Halleux\r
-\r
-This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\r
-\r
-Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:\r
-\r
-1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\r
-\r
-2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\r
-\r
-3. This notice may not be removed or altered from any source distribution\r
-*/\r
-\r
-\r
-#ifndef IOBIND_PARSER_UTILS_HPP\r
-#define IOBIND_PARSER_UTILS_HPP\r
-\r
-#include <boost/spirit.hpp>\r
-#include <boost/call_traits.hpp>\r
-#include <string>\r
-\r
-namespace iobind{\r
-namespace parser{\r
-namespace detail{\r
-\r
-template<\r
- typename Container,\r
- typename Policy\r
-> \r
-class append_with_policy\r
-{\r
-public:\r
- append_with_policy( Container& container_, Policy const& policy_)\r
- : m_container(container_), m_policy(policy_)\r
- {};\r
-\r
- // the method called by the parser \r
- template <typename IteratorT>\r
- void operator()(IteratorT const& first, IteratorT const& last) const\r
- {\r
- m_container.insert(m_container.end(), m_policy.encode( std::string(first, last) ) );\r
- }\r
-\r
-private:\r
- Container& m_container;\r
- Policy const& m_policy;\r
-};\r
-\r
-template<\r
- typename Container,\r
- typename Policy\r
-> \r
-class insert_with_policy\r
-{\r
-public:\r
- insert_with_policy( size_t& index_, Container& container_, Policy const& policy_)\r
- : m_index(index_), m_container(container_), m_policy(policy_)\r
- {};\r
-\r
- // the method called by the parser \r
- template <typename IteratorT>\r
- void operator()(IteratorT const& first, IteratorT const& last) const\r
- {\r
- if (m_index < m_container.size())\r
- m_container[m_index++]=m_policy.encode( std::string(first, last) );\r
-#ifdef _DEBUG\r
- else\r
- std::cerr<<"insert_with_policy: could not add data"<<std::endl;\r
-#endif\r
- }\r
-\r
-private:\r
- size_t& m_index;\r
- Container& m_container;\r
- Policy const& m_policy;\r
-};\r
-\r
-template<\r
- typename Pair,\r
- typename FirstPolicy,\r
- typename SecondPolicy\r
-> \r
-class assign_pair_with_policy\r
-{\r
-public:\r
- \r
- explicit assign_pair_with_policy( \r
- Pair& pair_, \r
- FirstPolicy const& first_policy_,\r
- SecondPolicy const& second_policy_,\r
- std::string const& first_,\r
- std::string const& second_\r
- )\r
- : \r
- m_pair(pair_), \r
- m_first_policy(first_policy_),\r
- m_second_policy(second_policy_),\r
- m_first(first_),\r
- m_second(second_)\r
- {};\r
-\r
- // the method called by the parser \r
- template <typename IteratorT>\r
- void operator()(IteratorT first, IteratorT last) const\r
- {\r
- m_pair=Pair(\r
- m_first_policy.encode(m_first.c_str()),\r
- m_second_policy.encode(m_second.c_str())\r
- );\r
- }\r
-\r
-private:\r
- Pair& m_pair;\r
- FirstPolicy const& m_first_policy;\r
- SecondPolicy const& m_second_policy;\r
- std::string const& m_first;\r
- std::string const& m_second;\r
-};\r
-\r
-class concat_string\r
-{\r
-public:\r
- // key_ and val_ should point to the string modified in keyvalue_grammar\r
- // kvc_ is the map of key - values\r
- concat_string( std::ostream& out_)\r
- : out(out_)\r
- { };\r
-\r
- // the method called by the parser \r
- template <typename IteratorT>\r
- void operator()(IteratorT first, IteratorT last) const\r
- {\r
- out<<std::string(first,last);\r
- }\r
-\r
- template <typename IteratorT>\r
- void operator()(IteratorT single) const\r
- {\r
- out<<single;\r
- }\r
-private:\r
- std::ostream& out;\r
-};\r
-\r
-class concat_symbol\r
-{\r
-public:\r
- // key_ and val_ should point to the string modified in keyvalue_grammar\r
- // kvc_ is the map of key - values\r
- concat_symbol( std::ostream& out_)\r
- : out(out_)\r
- { };\r
-\r
- // the method called by the parser \r
- void operator()(std::string const& str) const\r
- {\r
- out<<str;\r
- }\r
-private:\r
- std::ostream& out;\r
-};\r
-\r
-class concat_pre_post_symbol\r
-{\r
-public:\r
- // key_ and val_ should point to the string modified in keyvalue_grammar\r
- // kvc_ is the map of key - values\r
- concat_pre_post_symbol( std::ostream& out_, std::string const& pre_, std::string const& post_)\r
- : m_out(out_),m_pre(pre_), m_post(post_)\r
- { };\r
-\r
- // the method called by the parser \r
- void operator()(std::string const& str_) const\r
- {\r
- m_out<<m_pre<<str_<<m_post;\r
- }\r
-private:\r
- std::ostream& m_out;\r
- std::string m_pre;\r
- std::string m_post;\r
-};\r
-\r
-};//details\r
-};//parser\r
-};//iobind\r
-\r
-#endif\r
-\r
-\r
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/target/store/serialize.cc
-*
-*/
-#include <iostream>
-#include <ctime>
-#include <fstream>
-#include <sstream>
-#include <streambuf>
-
-#include <boost/logic/tribool.hpp>
-
-#include "zypp/base/Logger.h"
-#include "zypp/Url.h"
-
-#include "zypp/ResObject.h"
-#include "zypp/repo/ScriptProvider.h"
-
-#include "serialize.h"
-
-#include "xml_escape_parser.hpp"
-
-using namespace std;
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-namespace storage
-{ /////////////////////////////////////////////////////////////////
-
-static void copyFileToStream( const Pathname & file_r, std::ostream & out_r )
-{
- std::ifstream infile( file_r.c_str() );
- while (infile.good())
- {
- char c = (char)infile.get();
- if (! infile.eof())
- out_r << c;
- }
- infile.close();
-}
-
-static string xml_escape( const string &text )
-{
- iobind::parser::xml_escape_parser parser;
- return parser.escape(text);
-}
-
-static string xml_tag_enclose( const string &text, const string &tag, bool escape = false )
-{
- string result;
- result += "<" + tag + ">";
-
- if ( escape)
- result += xml_escape(text);
- else
- result += text;
-
- result += "</" + tag + ">";
- return result;
-}
-
-static ostream & operator<<( ostream & str, const boost::tribool obj )
-{
- if (obj)
- return str << "true";
- else if (!obj)
- return str << "false";
- else
- return str << "indeterminate";
-}
-
-/**
- * helper function that builds
- * <tagname lang="code">text</tagname>
- *
- *
- */
-static string translatedTextToXML(const TranslatedText &text, const string &tagname)
-{
- set<Locale> locales = text.locales();
- //ERR << "locale contains " << locales.size() << " translations" << endl;
- stringstream out;
- for ( set<Locale>::const_iterator it = locales.begin(); it != locales.end(); ++it)
- {
- //ERR << "serializing " << (*it).code() << endl;
- if ( *it == Locale() )
- out << "<" << tagname << ">" << xml_escape(text.text(*it)) << "</" << tagname << ">" << endl;
- else
- out << "<" << tagname << " lang=\"" << (*it).code() << "\">" << xml_escape(text.text(*it)) << "</" << tagname << ">" << endl;
- }
- return out.str();
-}
-
-template<class T>
-string toXML( const T &obj ); //undefined
-
-template<>
-string toXML( const Edition &edition )
-{
- stringstream out;
- // sad the yum guys did not acll it edition
- out << "<version ver=\"" << xml_escape(edition.version()) << "\" rel=\"" << xml_escape(edition.release()) << "\" epoch=\"" << edition.epoch() << "\" />";
- return out.str();
-}
-
-template<>
-string toXML( const Arch &arch )
-{
- stringstream out;
- out << xml_tag_enclose(xml_escape(arch.asString()), "arch");
- return out.str();
-}
-
-template<>
-string toXML( const Capability &cap )
-{
-#warning FIX WRITING AND READING CAPABILITY (incl old format)
- stringstream out;
- //CapFactory factory;
- //out << "<capability kind=\"" << cap.refers() << "\" >" << xml_escape(factory.encode(cap)) << "</capability>" << endl;
- out << "<capability>" << cap << "</capability>" << endl; // wrong !
-
- return out.str();
-}
-
-template<>
-string toXML( const Capabilities &caps )
-{
- stringstream out;
- Capabilities::const_iterator it = caps.begin();
- for ( ; it != caps.end(); ++it)
- {
- out << toXML((*it));
- }
- return out.str();
-}
-
-template<>
-string toXML( const CapabilitySet &caps )
-{
- stringstream out;
- CapabilitySet::const_iterator it = caps.begin();
- for ( ; it != caps.end(); ++it)
- {
- out << toXML((*it));
- }
- return out.str();
-}
-
-template<>
-string toXML( const Dependencies &dep )
-{
- stringstream out;
- if ( ! dep[Dep::PROVIDES].empty() )
- out << " " << xml_tag_enclose(toXML(dep[Dep::PROVIDES]), "provides") << endl;
- if ( ! dep[Dep::PREREQUIRES].empty() )
- out << " " << xml_tag_enclose(toXML(dep[Dep::PREREQUIRES]), "prerequires") << endl;
- if ( ! dep[Dep::CONFLICTS].empty() )
- out << " " << xml_tag_enclose(toXML(dep[Dep::CONFLICTS]), "conflicts") << endl;
- if ( ! dep[Dep::OBSOLETES].empty() )
- out << " " << xml_tag_enclose(toXML(dep[Dep::OBSOLETES]), "obsoletes") << endl;
- if ( ! dep[Dep::FRESHENS].empty() )
- out << " " << xml_tag_enclose(toXML(dep[Dep::FRESHENS]), "freshens") << endl;
- if ( ! dep[Dep::REQUIRES].empty() )
- out << " " << xml_tag_enclose(toXML(dep[Dep::REQUIRES]), "requires") << endl;
- if ( ! dep[Dep::RECOMMENDS].empty() )
- out << " " << xml_tag_enclose(toXML(dep[Dep::RECOMMENDS]), "recommends") << endl;
- if ( ! dep[Dep::ENHANCES].empty() )
- out << " " << xml_tag_enclose(toXML(dep[Dep::ENHANCES]), "enhances") << endl;
- if ( ! dep[Dep::SUPPLEMENTS].empty() )
- out << " " << xml_tag_enclose(toXML(dep[Dep::SUPPLEMENTS]), "supplements") << endl;
- if ( ! dep[Dep::SUGGESTS].empty() )
- out << " " << xml_tag_enclose(toXML(dep[Dep::SUGGESTS]), "suggests") << endl;
- return out.str();
-
-}
-
-inline string toXML( const Resolvable::constPtr &obj, Dep deptag_r )
-{
- stringstream out;
- Capabilities caps( obj->dep(deptag_r) );
- if ( ! caps.empty() )
- out << " " << xml_tag_enclose(toXML(caps), deptag_r.asString()) << endl;
- return out.str();
-}
-
-template<>
-string toXML( const Resolvable::constPtr &obj )
-{
- stringstream out;
-
- out << " <name>" << xml_escape(obj->name()) << "</name>" << endl;
- // is this shared? uh
- out << " " << toXML(obj->edition()) << endl;
- out << " " << toXML(obj->arch()) << endl;
- out << " " << toXML( obj, Dep::PROVIDES);
- out << " " << toXML( obj, Dep::PREREQUIRES);
- out << " " << toXML( obj, Dep::CONFLICTS);
- out << " " << toXML( obj, Dep::OBSOLETES);
- out << " " << toXML( obj, Dep::FRESHENS);
- out << " " << toXML( obj, Dep::REQUIRES);
- out << " " << toXML( obj, Dep::RECOMMENDS);
- out << " " << toXML( obj, Dep::ENHANCES);
- out << " " << toXML( obj, Dep::SUPPLEMENTS);
- out << " " << toXML( obj, Dep::SUGGESTS);
- return out.str();
-}
-
-template<>
-string toXML( const ResObject::constPtr &obj )
-{
- stringstream out;
-#warning FIX WRITING AND READING TRANSLATED TEXTS
- // access implementation
- //detail::ResImplTraits<ResObject::Impl>::constPtr pipp( detail::ImplConnect::resimpl( obj ) );
- //out << translatedTextToXML(pipp->summary(), "summary");
- //out << translatedTextToXML(pipp->description(), "description");
-
- //out << translatedTextToXML(pipp->insnotify(), "install-notify");
- //out << translatedTextToXML(pipp->delnotify(), "delete-notify");
- //out << translatedTextToXML(pipp->licenseToConfirm(), "license-to-confirm");
- out << " <vendor>" << xml_escape(obj->vendor()) << "</vendor>" << endl;
- out << " <size>" << static_cast<ByteCount::SizeType>(obj->size()) << "</size>" << endl;
- out << " <archive-size>" << static_cast<ByteCount::SizeType>(obj->downloadSize()) << "</archive-size>" << endl;
- out << " <install-only>" << ( obj->installOnly() ? "true" : "false" ) << "</install-only>" << endl;
- out << " <build-time>" << obj->buildtime().asSeconds() << "</build-time>" << endl;
- // we assume we serialize on storeObject, set install time to NOW
- out << " <install-time>" << Date::now().asSeconds() << "</install-time>" << endl;
-
- return out.str();
-}
-
-template<>
-string toXML( const Package::constPtr &obj )
-{
- stringstream out;
- out << "<package>" << endl;
- // reuse Resolvable information serialize function
- out << toXML(static_cast<Resolvable::constPtr>(obj));
- out << toXML(static_cast<ResObject::constPtr>(obj));
- out << "</package>" << endl;
- return out.str();
-}
-
-template<>
-string toXML( const Script::constPtr &obj )
-{
- stringstream out;
- out << "<script>" << endl;
- // reuse Resolvable information serialize function
- out << toXML(static_cast<Resolvable::constPtr>(obj));
- out << toXML(static_cast<ResObject::constPtr>(obj));
-
- repo::RepoMediaAccess access;
- repo::ScriptProvider prov( access );
-
- out << " <do>" << endl;
- out << " <![CDATA[" << endl;
- copyFileToStream( prov.provideDoScript( obj ), out );
- out << " ]]>" << endl;
- out << " </do>" << endl;
-
- if ( obj->undoAvailable() )
- {
- out << " <undo>" << endl;
- out << " <![CDATA[" << endl;
- copyFileToStream( prov.provideUndoScript( obj ), out );
- out << " ]]>" << endl;
- out << " </undo>" << endl;
-
- }
- out << "</script>" << endl;
- return out.str();
-}
-
-template<>
-string toXML( const Message::constPtr &obj )
-{
- stringstream out;
- out << "<message>" << endl;
- // reuse Resolvable information serialize function
- out << toXML(static_cast<Resolvable::constPtr>(obj));
- out << toXML(static_cast<ResObject::constPtr>(obj));
- out << " <text>" << xml_escape(obj->text().text()) << "</text>" << endl;
- out << "</message>" << endl;
- return out.str();
-}
-
-template<>
-string toXML( const Atom::constPtr &obj )
-{
- stringstream out;
- out << "<atom>" << endl;
- out << toXML(static_cast<Resolvable::constPtr>(obj)) << endl;
- out << toXML(static_cast<ResObject::constPtr>(obj));
- out << "</atom>" << endl;
- return out.str();
-}
-
-template<>
-string toXML( const Pattern::constPtr &obj )
-{
- stringstream out;
- out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
- out << "<pattern version=\"" << SERIALIZER_VERSION << "\" xmlns=\"http://www.novell.com/metadata/zypp/xml-store\">" << endl;
-
- out << toXML(static_cast<Resolvable::constPtr>(obj)) << endl;
- out << toXML(static_cast<ResObject::constPtr>(obj));
-
- out << " <default>" << (obj->isDefault() ? "true" : "false" ) << "</default>" << endl;
- out << " <uservisible>" << (obj->userVisible() ? "true" : "false" ) << "</uservisible>" << endl;
- out << " <category>" << xml_escape(obj->category()) << "</category>" << endl;
- out << " <icon>" << xml_escape(obj->icon().asString()) << "</icon>" << endl;
- out << " <script>" << xml_escape(obj->script().asString()) << "</script>" << endl;
- out << "</pattern>" << endl;
- return out.str();
-}
-
-template<>
-string toXML( const Product::constPtr &obj )
-{
- stringstream out;
- out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
- out << "<product version=\"" << SERIALIZER_VERSION << "\" xmlns=\"http://www.novell.com/metadata/zypp/xml-store\" type=\"" << xml_escape(obj->type()) << "\">" << endl;
- out << toXML(static_cast<Resolvable::constPtr>(obj)) << endl;
-#warning "FIXME description and displayname of products"
-
- out << toXML(static_cast<ResObject::constPtr>(obj));
-
-#warning FIX WRITING AND READING TRANSLATED TEXTS
- // access implementation
-// detail::ResImplTraits<Product::Impl>::constPtr pipp( detail::ImplConnect::resimpl( obj ) );
-// out << translatedTextToXML(pipp->shortName(), "shortname");
-
- out << " <distribution-name>" << xml_escape(obj->distributionName()) << "</distribution-name>" << endl;
- out << " <distribution-edition>" << xml_escape(obj->distributionEdition().asString()) << "</distribution-edition>" << endl;
- out << " <source>" << xml_escape(obj->repository().info().alias()) << "</source>" << endl;
- out << " <release-notes-url>" << xml_escape(obj->releaseNotesUrl().asString()) << "</release-notes-url>" << endl;
-
- out << " <update-urls>" << endl;
- list<Url> updateUrls = obj->updateUrls();
- for ( list<Url>::const_iterator it = updateUrls.begin(); it != updateUrls.end(); ++it)
- {
- out << " <update-url>" << xml_escape(it->asString()) << "</update-url>" << endl;
- }
- out << " </update-urls>" << endl;
-
- out << " <extra-urls>" << endl;
- list<Url> extraUrls = obj->extraUrls();
- for ( list<Url>::const_iterator it = extraUrls.begin(); it != extraUrls.end(); ++it)
- {
- out << " <extra-url>" << xml_escape(it->asString()) << "</extra-url>" << endl;
- }
- out << " </extra-urls>" << endl;
-
- out << " <optional-urls>" << endl;
- list<Url> optionalUrls = obj->optionalUrls();
- for ( list<Url>::const_iterator it = optionalUrls.begin(); it != optionalUrls.end(); ++it)
- {
- out << " <optional-url>" << xml_escape(it->asString()) << "</optional-url>" << endl;
- }
- out << " </optional-urls>" << endl;
-
- out << " <product-flags>" << endl;
- list<string> flags = obj->flags();
- for ( list<string>::const_iterator it = flags.begin(); it != flags.end(); ++it)
- {
- out << " <product-flag>" << xml_escape(*it) << "</product-flag>" << endl;
- }
- out << " </product-flags>" << endl;
-
- out << "</product>" << endl;
-
- return out.str();
-}
-
-
-string castedToXML( const Resolvable::constPtr &resolvable )
-{
- stringstream out;
- if ( isKind<Package>(resolvable) )
- out << toXML(asKind<const Package>(resolvable)) << endl;
- if ( isKind<Patch>(resolvable) )
- out << toXML(asKind<const Patch>(resolvable)) << endl;
- if ( isKind<Message>(resolvable) )
- out << toXML(asKind<const Message>(resolvable)) << endl;
- if ( isKind<Script>(resolvable) )
- out << toXML(asKind<const Script>(resolvable)) << endl;
- if ( isKind<Atom>(resolvable) )
- out << toXML(asKind<const Atom>(resolvable)) << endl;
- if ( isKind<Product>(resolvable) )
- out << toXML(asKind<const Product>(resolvable)) << endl;
- if ( isKind<Pattern>(resolvable) )
- out << toXML(asKind<const Pattern>(resolvable)) << endl;
- return out.str();
-}
-
-string resolvableTypeToString( const Resolvable::constPtr &resolvable, bool plural )
-{
- return resolvableKindToString(resolvable->kind(), plural);
-}
-
-string resolvableKindToString( const Resolvable::Kind &kind, bool plural)
-{
- string k = kind.asString();
- if (k.substr(k.size() - 2, 2) == "ch")
- return k + (plural?"es":"");
- else
- return k + (plural?"s":"");
-}
-
-template<>
-string toXML( const Patch::constPtr &obj )
-{
- stringstream out;
- out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
- out << "<patch version=\"" << SERIALIZER_VERSION << "\" xmlns=\"http://www.novell.com/metadata/zypp/xml-store\">" << endl;
-
- // reuse Resolvable information serialize function
- out << toXML(static_cast<Resolvable::constPtr>(obj));
- out << toXML(static_cast<ResObject::constPtr>(obj));
-
- out << "<id>" << xml_escape(obj->id()) << "</id>" << endl;
- out << "<timestamp>" << obj->timestamp().asSeconds() << "</timestamp>" << endl;
-
- out << "<category>" << obj->category() << "</category>" << endl;
- out << "<affects-package-manager>" << ( obj->affects_pkg_manager() ? "true" : "false" ) << "</affects-package-manager>" << endl;
- out << "<reboot-needed>" << ( obj->reboot_needed() ? "true" : "false" ) << "</reboot-needed>" << endl;
-
- Patch::AtomList at = obj->atoms();
- out << " <atoms>" << endl;
- for (Patch::AtomList::iterator it = at.begin(); it != at.end(); it++)
- {
- Resolvable::Ptr one_atom = *it;
- out << castedToXML(one_atom) << endl;
- }
- out << " </atoms>" << endl;
- out << "</patch>" << endl;
- return out.str();
-}
-
-/////////////////////////////////////////////////////////////////
-} // namespace storage
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/target/store/serialize.h
-*
-*/
-#ifndef DEVEL_DEVEL_DMACVICAR_SERIALIZE_H
-#define DEVEL_DEVEL_DMACVICAR_SERIALIZE_H
-
-#include <iosfwd>
-
-#include "zypp/base/PtrTypes.h"
-#include "Backend.h"
-
-#include <zypp/ResObjects.h>
-
-#define SERIALIZER_VERSION "2.0"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace storage
-{ /////////////////////////////////////////////////////////////////
-
-template<class T>
-std::string toXML( const T &obj ); //undefined
-
-template<>
-std::string toXML( const Edition &edition );
-
-template<>
-std::string toXML( const Arch &arch );
-
-template<>
-std::string toXML( const Capability &cap );
-
-template<>
-std::string toXML( const Capabilities &caps );
-
-template<>
-std::string toXML( const CapabilitySet &caps );
-
-template<>
-std::string toXML( const Dependencies &dep );
-
-/**
- * Serialize Resolvable properties
- * NOTE: This wont serialize child classes properties
- * Use castedToXML for that.
- */
-template<>
-std::string toXML( const Resolvable::constPtr &obj );
-
-/**
- * Serialize ResObject properties
- */
-template<>
-std::string toXML( const ResObject::constPtr &obj );
-
-/**
- * Serialize properties based in the specific kind of the Resolvable
- */
-std::string castedToXML( const Resolvable::constPtr &ret );
-
-/**
- * lack of instrospection sucks
- */
-std::string resolvableTypeToString( const Resolvable::constPtr &resolvable, bool plural = false );
-
-/**
- * lack of instrospection sucks
- */
-std::string resolvableKindToString( const Resolvable::Kind &kind, bool plural = false );
-
-template<>
-std::string toXML( const Package::constPtr &obj );
-
-template<>
-std::string toXML( const Script::constPtr &obj );
-
-template<>
-std::string toXML( const Message::constPtr &obj );
-
-template<>
-std::string toXML( const Patch::constPtr &obj );
-
-template<>
-std::string toXML( const Atom::constPtr &obj );
-
-template<>
-std::string toXML( const Pattern::constPtr &obj );
-
-template<>
-std::string toXML( const Product::constPtr &obj );
-
-/////////////////////////////////////////////////////////////////
-} // namespace storage
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // DEVEL_DEVEL_DMACVICAR_SQLITEBACKEND_H
-