#include "zypp/PoolQuery.h"
#include "zypp/ServiceInfo.h"
-#include "zypp/parser/ProductConfReader.h"
-
#include <boost/mpl/int.hpp>
using namespace std;
#include "zypp/PoolQuery.h"
#include "zypp/ServiceInfo.h"
-#include "zypp/parser/ProductConfReader.h"
-
#include <boost/mpl/int.hpp>
using namespace std;
make install DESTDIR=$RPM_BUILD_ROOT
make -C doc/autodoc install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/etc/zypp/repos.d
-mkdir -p $RPM_BUILD_ROOT/etc/zypp/products.d
mkdir -p $RPM_BUILD_ROOT/etc/zypp/services.d
mkdir -p $RPM_BUILD_ROOT/%{_var}/lib/zypp
mkdir -p $RPM_BUILD_ROOT/%{_var}/log/zypp
%defattr(-,root,root)
%dir /etc/zypp
%dir /etc/zypp/repos.d
+%dir /etc/zypp/services.d
%config(noreplace) /etc/zypp/zypp.conf
%config(noreplace) /etc/zypp/systemCheck
%config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
parser/IniDict.cc
parser/RepoFileReader.cc
parser/RepoindexFileReader.cc
- parser/ProductConfReader.cc
parser/ServiceFileReader.cc
)
parser/IniDict.h
parser/ParserProgress.h
parser/RepoFileReader.h
- parser/ProductConfReader.h
parser/xml_escape_parser.hpp
parser/RepoindexFileReader.h
parser/ServiceFileReader.h
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/ProductConfReader.cc
- *
-*/
-#include <iostream>
-#include "zypp/base/Logger.h"
-
-#include "zypp/PathInfo.h"
-
-#include "zypp/parser/ProductConfReader.h"
-#include "zypp/parser/IniDict.h"
-
-using std::endl;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace parser
- { /////////////////////////////////////////////////////////////////
-
- std::ostream & operator<<( std::ostream & str, const ProductConfData & obj )
- {
- str << str::form( "|product|%s|%s|%s|%s|%s|",
- obj.name().c_str(),
- obj.edition().c_str(),
- obj.arch().c_str(),
- obj.distName().c_str(),
- obj.distEdition().c_str() );
- return str;
- }
-
- bool ProductConfReader::parse( const InputStream & input_r ) const
- {
- parser::IniDict dict( input_r );
-
- for_( sit, dict.sectionsBegin(), dict.sectionsEnd() )
- {
- std::string section( *sit );
- ProductConfData data;
-
- // last word is arch (%a substituted by system arch)
- std::string word( str::stripLastWord( section, /*rtrim_first*/true ) );
- if ( word.empty() )
- {
- ERR << "Malformed section without architecture ignored [" << *sit << "]" << endl;
- continue;
- }
- data._arch = Arch( word == "%arch" ? "" : word );
-
- // one but last word is edition
- word = str::stripLastWord( section, /*rtrim_first*/true );
- if ( word.empty() )
- {
- ERR << "Malformed section without edition ignored [" << *sit << "]" << endl;
- continue;
- }
- data._edition = Edition( word );
-
- // all the rest is name
- if ( section.empty() )
- {
- ERR << "Malformed section without name ignored [" << *sit << "]" << endl;
- continue;
- }
- data._name = IdString( section );
-
- // now the attributes:
- for_( it, dict.entriesBegin(*sit), dict.entriesEnd(*sit) )
- {
- std::string entry( it->first );
- std::string value( it->second );
- if ( entry == "distproduct" )
- {
- data._distName = IdString( value );
- }
- else if ( entry == "distversion" )
- {
- data._distEdition = Edition( value );
- }
- else
- {
- WAR << "Unknown Key: "<< entry << "=" << value << endl;
- }
- }
-
- if ( _consumer && ! _consumer( data ) )
- {
- MIL << "Stop consuming " << input_r << endl;
- return false;
- }
- }
- return true;
- }
-
- bool ProductConfReader::scanDir( const Consumer & consumer_r, const Pathname & dir_r )
- {
- DBG << "+++ scanDir " << dir_r << endl;
-
- std::list<Pathname> retlist;
- int res = filesystem::readdir( retlist, dir_r, /*dots*/false );
- if ( res != 0 )
- {
- WAR << "scanDir " << dir_r << " failed (" << res << ")" << endl;
- return true;
- }
-
- ProductConfReader reader( consumer_r );
- for_( it, retlist.begin(), retlist.end() )
- {
- if ( it->extension() == ".prod" && ! reader.parse( *it ) )
- {
- return false; // consumer_r request to stop parsing.
- }
- }
- DBG << "--- scanDir " << dir_r << endl;
- return true;
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace parser
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/ProductConfReader.h
- *
-*/
-#ifndef ZYPP_PARSER_PRODUCTCONFREADER_H
-#define ZYPP_PARSER_PRODUCTCONFREADER_H
-
-#include <iosfwd>
-
-#include "zypp/base/Function.h"
-#include "zypp/base/InputStream.h"
-
-#include "zypp/ZConfig.h"
-
-#include "zypp/Pathname.h"
-#include "zypp/IdString.h"
-#include "zypp/Edition.h"
-#include "zypp/Arch.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace parser
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ProductConfData
- //
- /** Data returned by \ref ProductConfReader
- * \see \ref ProductConfReader
- */
- class ProductConfData
- {
- public:
- /** Product name */
- IdString name() const
- { return _name; }
-
- /** Product edition */
- Edition edition() const
- { return _edition; }
-
- /** Product arch */
- Arch arch() const
- { return _arch.empty() ? ZConfig::instance().systemArchitecture() : _arch; }
-
- /** Product distName (defaults to \ref name)*/
- IdString distName() const
- { return _distName.empty() ? _name : _distName; }
-
- /** Product distEdition (defaults to \ref edition) */
- Edition distEdition() const
- { return _distEdition.empty() ? _edition : _distEdition; }
-
- public:
- IdString _name;
- Edition _edition;
- Arch _arch;
-
- IdString _distName;
- Edition _distEdition;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates ProductConfData Stream output */
- std::ostream & operator<<( std::ostream & str, const ProductConfData & obj );
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ProductConfReader
- //
- /** ProductConfReader (registration helper)
- * \code
- * - The file may contain zero or more product sections.
- * Required format for the section header is:
- *
- * [the products name version architecture]
- *
- * Last word is architecture,
- * one but last word is version,
- * the remaining words are the name.
- *
- * Less than 3 words is an error, section is ignored.
- *
- * If architecture is "%arch" it is substituted by the sytems architecture.
- *
- * - In each section you may define
- *
- * distproduct = some dist name
- * distversion = 1.2.3-4.5
- * \endcode
- */
- class ProductConfReader
- {
- public:
- /** Callback being invoked for each parsed section.
- * Return \c false to stop parsing.
- */
- typedef function<bool( const ProductConfData & )> Consumer;
-
- public:
- ProductConfReader()
- {}
-
- ProductConfReader( const Consumer & consumer_r )
- : _consumer( consumer_r )
- {}
-
- ProductConfReader( const Consumer & consumer_r, const InputStream & input_r )
- : _consumer( consumer_r )
- { parse( input_r ); }
-
- public:
- const Consumer & consumer() const
- { return _consumer; }
-
- void setConsumer( const Consumer & consumer_r )
- { _consumer = consumer_r; }
-
- public:
- /** Parse the input stream and call \c _consumer for each
- * parsed section.
- *
- * Returns \c false if the \c _consumer requested to stop parsing.
- */
- bool parse( const InputStream & input_r = InputStream() ) const;
-
- public:
- /** Parse all <tt>*.prod</tt> files in \c dir_r and call \c consumer_r
- * for each parsed section.
- *
- * Returns \c false if the \c _consumer requested to stop parsing.
- */
- static bool scanDir( const Consumer & consumer_r, const Pathname & dir_r );
-
- private:
- Consumer _consumer;
- };
- ///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
- } // namespace parser
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PARSER_PRODUCTCONFREADER_H