PackagesParser.h\
SuseTagsImpl.h \
SuseTagsSelectionImpl.h \
+ SuseTagsPatternImpl.h \
SuseTagsPackageImpl.h \
- SelectionSelFileParser.h \
+ SelectionTagFileParser.h \
+ PatternTagFileParser.h \
ProductMetadataParser.h \
MediaMetadataParser.h \
MediaPatchesMetadataParser.h
PackagesParser.cc \
SuseTagsImpl.cc \
SuseTagsSelectionImpl.cc \
+ SuseTagsPatternImpl.cc \
SuseTagsPackageImpl.cc \
- SelectionSelFileParser.cc \
+ SelectionTagFileParser.cc \
+ PatternTagFileParser.cc \
ProductMetadataParser.cc \
MediaMetadataParser.cc \
MediaPatchesMetadataParser.cc
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/tagfile/PatternTagFileParser.cc
+ *
+*/
+#include <iostream>
+#include <fstream>
+#include <sstream>
+
+#include <boost/tokenizer.hpp>
+#include <boost/algorithm/string.hpp>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/PtrTypes.h"
+#include "zypp/base/String.h"
+#include "zypp/CapFactory.h"
+
+#include "zypp/source/susetags/PatternTagFileParser.h"
+#include <boost/regex.hpp>
+
+#undef ZYPP_BASE_LOGGER_LOGGROUP
+#define ZYPP_BASE_LOGGER_LOGGROUP "PatternsTagFileParser"
+
+using namespace std;
+using namespace boost;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace susetags
+ { /////////////////////////////////////////////////////////////////
+
+ Pattern::Ptr parsePattern( const Pathname & file_r )
+ {
+ PatternTagFileParser p;
+ p.parse( file_r );
+ return p.result;
+
+ }
+
+ PatternTagFileParser::PatternTagFileParser()
+ {
+ selImpl = shared_ptr<SuseTagsPatternImpl>(new SuseTagsPatternImpl);
+ }
+
+ void PatternTagFileParser::consume( const SingleTag &tag )
+ {
+ if ( tag.name == "Sum" )
+ {
+ selImpl->_summary.setText(tag.value, LanguageCode(tag.modifier));
+ }
+ else if ( tag.name == "Ver" )
+ {
+ selImpl->_parser_version = tag.value;
+ }
+ else if ( tag.name == "Pat" )
+ {
+ std::string line = tag.value;
+ std::vector<std::string> words;
+ str::split( line, std::back_inserter(words), " " );
+ XXX << "[" << words[0] << "]" << "[" << words[1] << "]" << "[" << words[2] << "]" << "[" << words[3] << "]" << std::endl;
+ selImpl->_name = words[0];
+ selImpl->_version = words[1];
+ selImpl->_release = words[2];
+ selImpl->_arch = words[3];
+ }
+ else if ( tag.name == "Vis" )
+ {
+ selImpl->_visible = (tag.value == "true") ? true : false;
+ }
+ else if ( tag.name == "Cat" )
+ {
+ selImpl->_category = tag.value;
+ }
+ else if ( tag.name == "Ord" )
+ {
+ selImpl->_order = tag.value;
+ }
+ }
+
+ void PatternTagFileParser::consume( const MultiTag &tag )
+ {
+ if ( tag.name == "Req" )
+ {
+ selImpl->_requires = tag.values;
+ }
+ else if ( tag.name == "Rec" )
+ {
+ selImpl->_recommends = tag.values;
+ }
+ else if ( tag.name == "Con" )
+ {
+ selImpl->_conflicts = tag.values;
+ }
+ else if ( tag.name == "Prq" ) // package requires
+ {
+ selImpl->_pkgrequires = tag.values;
+ }
+ else if ( tag.name == "Prc" ) // package recommends
+ {
+ selImpl->_pkgrecommends = tag.values;
+ }
+ }
+
+ void PatternTagFileParser::endParse()
+ {
+ #warning FIXME how to insert the specific language packages
+ CapFactory _f;
+ Dependencies _deps;
+
+ for (std::list<std::string>::const_iterator it = selImpl->_recommends.begin(); it != selImpl->_recommends.end(); it++)
+ {
+ Capability _cap = _f.parse( ResTraits<Pattern>::kind, *it );
+ _deps[Dep::RECOMMENDS].insert(_cap);
+ }
+
+ for (std::list<std::string>::const_iterator it = selImpl->_requires.begin(); it != selImpl->_requires.end(); it++)
+ {
+ Capability _cap = _f.parse( ResTraits<Pattern>::kind, *it );
+ _deps[Dep::REQUIRES].insert(_cap);
+ }
+
+ for (std::list<std::string>::const_iterator it = selImpl->_conflicts.begin(); it != selImpl->_conflicts.end(); it++)
+ {
+ Capability _cap = _f.parse( ResTraits<Pattern>::kind, *it );
+ _deps[Dep::CONFLICTS].insert(_cap);
+ }
+
+ for (std::list<std::string>::const_iterator it = selImpl->_recommends.begin(); it != selImpl->_pkgrecommends.end(); it++)
+ {
+ Capability _cap = _f.parse( ResTraits<Package>::kind, *it );
+ _deps[Dep::RECOMMENDS].insert(_cap);
+ }
+
+ for (std::list<std::string>::const_iterator it = selImpl->_requires.begin(); it != selImpl->_pkgrequires.end(); it++)
+ {
+ Capability _cap = _f.parse( ResTraits<Package>::kind, *it );
+ _deps[Dep::REQUIRES].insert(_cap);
+ }
+
+ NVRAD nvrad = NVRAD( selImpl->_name, Edition(selImpl->_version, selImpl->_release, std::string()), Arch(selImpl->_arch), _deps );
+ result = detail::makeResolvableFromImpl( nvrad, selImpl );
+ }
+ /////////////////////////////////////////////////////////////////
+ } // namespace tagfile
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+ } // namespace parser
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/source/susetags/PatternTagFileParser.h
+ *
+*/
+#ifndef ZYPP_PARSER_TAGFILE_PATTERNTAGFILEPARSER_H
+#define ZYPP_PARSER_TAGFILE_PATTERNTAGFILEPARSER_H
+
+#include <iosfwd>
+#include <set>
+#include <map>
+#include <list>
+
+#include "zypp/parser/tagfile/TagFileParser.h"
+#include "zypp/parser/tagfile/ParseException.h"
+#include "zypp/Pattern.h"
+#include "zypp/source/susetags/SuseTagsPatternImpl.h"
+
+#include "zypp/Pathname.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace susetags
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : PatternTagFileParser
+ //
+ /** Tagfile parser. */
+ struct PatternTagFileParser : public zypp::parser::tagfile::TagFileParser
+ {
+ Pattern::Ptr result;
+ shared_ptr<SuseTagsPatternImpl> selImpl;
+
+ PatternTagFileParser();
+ virtual ~PatternTagFileParser()
+ {}
+
+ void consume( const SingleTag &tag );
+ void consume( const MultiTag &tag );
+ void endParse();
+ };
+ ///////////////////////////////////////////////////////////////////
+ Pattern::Ptr parsePattern( const Pathname & file_r );
+ /////////////////////////////////////////////////////////////////
+ } // namespace source
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+ } // namespace susetags
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+//
+#endif // ZYPP_PARSER_TAGFILE_PATTERNTAGFILEPPARSER_H
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/parser/tagfile/SelectionSelFileParser.cc
+/** \file zypp/parser/tagfile/SelectionTagFileParser.cc
*
*/
#include <iostream>
#include "zypp/base/String.h"
#include "zypp/CapFactory.h"
-#include "zypp/source/susetags/SelectionSelFileParser.h"
+#include "zypp/source/susetags/SelectionTagFileParser.h"
#include <boost/regex.hpp>
+#undef ZYPP_BASE_LOGGER_LOGGROUP
#define ZYPP_BASE_LOGGER_LOGGROUP "SelectionsTagFileParser"
using namespace std;
Selection::Ptr parseSelection( const Pathname & file_r )
{
- SelectionSelFileParser p;
+ SelectionTagFileParser p;
p.parse( file_r );
return p.result;
}
- SelectionSelFileParser::SelectionSelFileParser()
+ SelectionTagFileParser::SelectionTagFileParser()
{
selImpl = shared_ptr<SuseTagsSelectionImpl>(new SuseTagsSelectionImpl);
}
- void SelectionSelFileParser::consume( const SingleTag &tag )
+ void SelectionTagFileParser::consume( const SingleTag &tag )
{
if ( tag.name == "Sum" )
{
}
}
- void SelectionSelFileParser::consume( const MultiTag &tag )
+ void SelectionTagFileParser::consume( const MultiTag &tag )
{
if ( tag.name == "Req" )
{
}
}
- void SelectionSelFileParser::endParse()
+ void SelectionTagFileParser::endParse()
{
#warning FIXME how to insert the specific language packages
CapFactory _f;
/** \file zypp/parser/tagfile/Parser.h
*
*/
-#ifndef ZYPP_PARSER_TAGFILE_SelectionSelFilePARSER_H
-#define ZYPP_PARSER_TAGFILE_SelectionSelFilePARSER_H
+#ifndef ZYPP_PARSER_TAGFILE_SELECTIONTAGFILEPARSER_H
+#define ZYPP_PARSER_TAGFILE_SELECTIONTAGFILEPARSER_H
#include <iosfwd>
#include <set>
///////////////////////////////////////////////////////////////////
//
- // CLASS NAME : SelectionSelFileParser
+ // CLASS NAME : SelectionTagFileParser
//
/** Tagfile parser. */
- struct SelectionSelFileParser : public zypp::parser::tagfile::TagFileParser
+ struct SelectionTagFileParser : public zypp::parser::tagfile::TagFileParser
{
Selection::Ptr result;
shared_ptr<SuseTagsSelectionImpl> selImpl;
- SelectionSelFileParser();
- virtual ~SelectionSelFileParser()
+ SelectionTagFileParser();
+ virtual ~SelectionTagFileParser()
{}
void consume( const SingleTag &tag );
} // namespace zypp
///////////////////////////////////////////////////////////////////
//
-#endif // ZYPP_PARSER_TAGFILE_SelectionSelFilePPARSER_H
+#endif // ZYPP_PARSER_TAGFILE_SELECTIONTAGFILEPPARSER_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/source/susetags/SelectionsParser.cc
- *
-*/
-#include <iostream>
-#include "zypp/base/Logger.h"
-
-#include "zypp/source/susetags/SelectionsParser.h"
-#include "zypp/parser/tagfile/Parser.h"
-#include "zypp/Selection.h"
-#include "zypp/detail/SelectionImpl.h"
-#include "zypp/CapFactory.h"
-#include "zypp/CapSet.h"
-
-
-using std::endl;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace source
- { /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace susetags
- { /////////////////////////////////////////////////////////////////
-
- using namespace parser::tagfile;
-
- struct SelectionsParser : public parser::tagfile::Parser
- {
- std::list<Selection::Ptr> result;
-
- shared_ptr<detail::SelectionImpl> pkgImpl;
- NVRAD nvrad;
-
- bool pkgPending() const
- { return pkgImpl; }
-
- void collectPkg( const shared_ptr<detail::SelectionImpl> & nextPkg_r
- = shared_ptr<detail::SelectionImpl>() )
- {
- if ( pkgPending() )
- {
- result.push_back( detail::makeResolvableFromImpl( nvrad, pkgImpl ) );
- }
- pkgImpl = nextPkg_r;
- }
-
- void newPkg()
- {
- collectPkg( shared_ptr<detail::SelectionImpl>(new detail::SelectionImpl) );
- }
-
- void collectDeps( const std::list<std::string> & depstr_r, CapSet & capset )
- {
- for ( std::list<std::string>::const_iterator it = depstr_r.begin();
- it != depstr_r.end(); ++it )
- {
- capset.insert( CapFactory().parse( ResTraits<Selection>::kind, *it ) );
- }
- }
-
- /* Consume SingleTag data. */
- virtual void consume( const STag & stag_r )
- {
- if ( stag_r.stag.isPlain( "Pkg" ) )
- {
- std::vector<std::string> words;
- str::split( stag_r.value, std::back_inserter(words) );
-
- if ( str::split( stag_r.value, std::back_inserter(words) ) != 4 )
- ZYPP_THROW( ParseException( "Pkg" ) );
-
- newPkg();
- nvrad = NVRAD( words[0], Edition(words[1],words[2]), Arch(words[3]) );
- }
- }
-
- /* Consume MulitTag data. */
- virtual void consume( const MTag & mtag_r )
- {
- if ( ! pkgPending() )
- return;
-
- if ( mtag_r.stag.isPlain( "Prv" ) )
- {
- collectDeps( mtag_r.value, nvrad[Dep::PROVIDES] );
- }
- else if ( mtag_r.stag.isPlain( "Prq" ) )
- {
- collectDeps( mtag_r.value, nvrad[Dep::PREREQUIRES] );
- }
- else if ( mtag_r.stag.isPlain( "Req" ) )
- {
- collectDeps( mtag_r.value, nvrad[Dep::REQUIRES] );
- }
- else if ( mtag_r.stag.isPlain( "Con" ) )
- {
- collectDeps( mtag_r.value, nvrad[Dep::CONFLICTS] );
- }
- else if ( mtag_r.stag.isPlain( "Obs" ) )
- {
- collectDeps( mtag_r.value, nvrad[Dep::OBSOLETES] );
- }
- }
-
- virtual void parseEnd()
- { collectPkg(); }
- };
-
- ////////////////////////////////////////////////////////////////////////////
-
- std::list<Selection::Ptr> parseSelections( const Pathname & file_r )
- {
- SelectionsParser p;
- p.parse( file_r );
- return p.result;
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace susetags
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
- } // namespace source
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
#include "zypp/source/susetags/SuseTagsImpl.h"
#include "zypp/source/susetags/PackagesParser.h"
-#include "zypp/source/susetags/SelectionSelFileParser.h"
+#include "zypp/source/susetags/SelectionTagFileParser.h"
+#include "zypp/source/susetags/PatternTagFileParser.h"
#include "zypp/SourceFactory.h"
std::ifstream sels (p.asString().c_str());
- while (!sels.eof())
+ while (sels && !sels.eof())
{
std::string selfile;
DBG << "Going to parse selection " << selfile << endl;
Pathname file = provideFile(_path + "suse/setup/descr/" + selfile);
- DBG << "Selection file to parse " << file << endl;
+ MIL << "Selection file to parse " << file << endl;
Selection::Ptr sel( parseSelection( file ) );
DBG << "Parsing of " << file << " done" << endl;
}
+
+ // parse patterns
+ p = provideFile(_path + "suse/setup/descr/patterns");
+
+ std::ifstream pats (p.asString().c_str());
+
+ while (pats && !pats.eof())
+ {
+ std::string patfile;
+
+ getline(pats,patfile);
+
+ if (patfile.empty() ) continue;
+
+ DBG << "Going to parse pattern " << patfile << endl;
+
+ Pathname file = provideFile(_path + "suse/setup/descr/" + patfile);
+ MIL << "Pattern file to parse " << file << endl;
+
+ Pattern::Ptr pat( parsePattern( file ) );
+
+ DBG << "Pattern:" << pat << endl;
+
+ if (pat)
+ _store.insert( pat );
+
+ DBG << "Parsing of " << file << " done" << endl;
+ }
}
///////////////////////////////////////////////////////////////////
//
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/detail/PatternImpl.cc
+ *
+*/
+#include "zypp/source/susetags/SuseTagsPatternImpl.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ namespace susetags
+ {
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : PatternImpl::PatternImpl
+ // METHOD TYPE : Ctor
+ //
+ SuseTagsPatternImpl::SuseTagsPatternImpl()
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : PatternImpl::~PatternImpl
+ // METHOD TYPE : Dtor
+ //
+ SuseTagsPatternImpl::~SuseTagsPatternImpl()
+ {}
+
+
+ TranslatedText SuseTagsPatternImpl::summary() const
+ { return _summary; }
+
+ TranslatedText SuseTagsPatternImpl::description() const
+ { return _summary; }
+
+ Label SuseTagsPatternImpl::category() const
+ { return _category; }
+
+ bool SuseTagsPatternImpl::visible() const
+ { return _visible; }
+
+ Label SuseTagsPatternImpl::order() const
+ { return _order; }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace detail
+ ///////////////////////////////////////////////////////////////////
+ }
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/detail/PatternImpl.h
+ *
+*/
+#ifndef ZYPP_DETAIL_SUSETAGS_PATTERNIMPL_H
+#define ZYPP_DETAIL_SUSETAGS_PATTERNIMPL_H
+
+#include "zypp/detail/PatternImplIf.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ namespace susetags
+ {
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : PatternImpl
+ //
+ /**
+ */
+ struct SuseTagsPatternImpl : public zypp::detail::PatternImplIf
+ {
+ public:
+ SuseTagsPatternImpl();
+ virtual ~SuseTagsPatternImpl();
+
+ /*
+ virtual std::list<std::string> suggests() const;
+ virtual std::list<std::string> recommends() const;
+ virtual std::list<std::string> insnotify( const LangCode & lang = LangCode("") ) const;
+ virtual std::list<std::string> delnotify( const LangCode & lang = LangCode("") ) const;
+ virtual ByteCount size() const;
+ virtual bool providesSources() const;
+ virtual std::string instSrcLabel() const;
+ virtual Vendor instSrcVendor() const;
+ virtual unsigned instSrcRank() const;
+ virtual std::list<PMPatternPtr> suggests_ptrs() const;
+ virtual std::list<PMPatternPtr> recommends_ptrs() const;
+ virtual std::list<std::string> inspacks( const LangCode & lang = LangCode("") ) const;
+ virtual std::list<std::string> delpacks( const LangCode & lang = LangCode("") ) const;
+ virtual PM::LocaleSet supportedLocales() const;
+ virtual std::set<PMSelectablePtr> pureInspacks_ptrs( const LangCode & lang ) const;
+ virtual std::set<PMSelectablePtr> inspacks_ptrs( const LangCode & lang ) const;
+ virtual std::set<PMSelectablePtr> delpacks_ptrs( const LangCode & lang ) const;
+ virtual bool isBase() const;
+ virtual PMError provideSelToInstall( Pathname & path_r ) const;
+ */
+
+ virtual TranslatedText summary() const;
+ virtual TranslatedText description() const;
+ virtual Label category() const;
+ virtual bool visible() const;
+ virtual Label order() const;
+
+ TranslatedText _summary;
+ std::string _parser_version;
+ std::string _name;
+ std::string _version;
+ std::string _release;
+ std::string _arch;
+ std::string _order;
+ std::string _category;
+ bool _visible;
+
+ std::list<std::string> _suggests;
+ std::list<std::string> _recommends;
+ std::list<std::string> _requires;
+ std::list<std::string> _conflicts;
+ std::list<std::string> _pkgsuggests;
+ std::list<std::string> _pkgrecommends;
+ std::list<std::string> _pkgrequires;
+ std::list<std::string> _supported_locales;
+ std::map< LanguageCode, std::list<std::string> > _insnotify;
+ std::map< LanguageCode, std::list<std::string> > _delnotify;
+
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace susetags
+ ///////////////////////////////////////////////////////////////////
+ } // namespace source
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_DETAIL_PATTERNIMPL_H