}
+ MIL << Arch_ppc.compatibleWith( Arch_x86_64 ) << endl;
+ MIL << Arch_i586.compatibleWith( Arch_x86_64 ) << endl;
+
+
#if 0
getZYpp()->resolver()->addRequire( Capability("amarok") );
solve();
return true;
}
+#include "zypp/base/Functional.h"
+
/******************************************************************
**
** FUNCTION NAME : main
{
Measure x( "PARSE" );
- USR << parser::ProductFileReader::scanDir( &Consumer, sysRoot / "etc/products.d" ) << endl;
+
+ parser::ProductFileData val;
+ std::vector<parser::ProductFileData> result;
+
+ parser::ProductFileReader::scanDir( functor::getFirst( val ),
+ //functor::getAll( std::back_inserter( result ) ),
+ sysRoot / "etc/products.d" );
+
+ USR << val << endl;
+ USR << result << endl;
}
#if 0
namespace zypp
{ /////////////////////////////////////////////////////////////////
- // builtin architecture STRING VALUES
+ ///////////////////////////////////////////////////////////////////
+ namespace
+ { /////////////////////////////////////////////////////////////////
+
+ // Builtin architecture STRING VALUES to be
+ // used in defCompatibleWith below!
+ //
+ // const IdString _foo( "foo" );
//
- // For arch 'foo' this macro defines:
- // const IdString _foo( "foo" ); // to be used in defCompatibleWith below!
- // const Arch Arch_foo( _foo );
+ // NOTE: Builtin CLASS Arch CONSTANTS are defined below.
+ // You have to change them accordingly.
//
-#define DEF_BUILTIN(A) namespace { const IdString _##A( #A ); } const Arch Arch_##A( _##A )
+#define DEF_BUILTIN(A) const IdString _##A( #A );
DEF_BUILTIN( noarch );
DEF_BUILTIN( i386 );
DEF_BUILTIN( sh4a );
#undef DEF_BUILTIN
- ///////////////////////////////////////////////////////////////////
- namespace
- { /////////////////////////////////////////////////////////////////
-
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : CompatSet
///////////////////////////////////////////////////////////////////
const Arch Arch_empty ( IdString::Empty );
-
- // all other Arch_* constants are defined via
- // the DEF_BUILTIN macro. See Above.
+ const Arch Arch_noarch( _noarch );
+
+ const Arch Arch_i386( _i386 );
+ const Arch Arch_i486( _i486 );
+ const Arch Arch_i586( _i586 );
+ const Arch Arch_i686( _i686 );
+ const Arch Arch_athlon( _athlon );
+ const Arch Arch_x86_64( _x86_64 );
+
+ const Arch Arch_pentium3( _pentium3 );
+ const Arch Arch_pentium4( _pentium4 );
+
+ const Arch Arch_s390( _s390 );
+ const Arch Arch_s390x( _s390x );
+
+ const Arch Arch_ppc( _ppc );
+ const Arch Arch_ppc64( _ppc64 );
+
+ const Arch Arch_ia64( _ia64 );
+
+ const Arch Arch_alphaev67( _alphaev67 );
+ const Arch Arch_alphaev6( _alphaev6 );
+ const Arch Arch_alphapca56( _alphapca56 );
+ const Arch Arch_alphaev56( _alphaev56 );
+ const Arch Arch_alphaev5( _alphaev5 );
+ const Arch Arch_alpha( _alpha );
+
+ const Arch Arch_sparc64( _sparc64 );
+ const Arch Arch_sparcv9( _sparcv9 );
+ const Arch Arch_sparcv8( _sparcv8 );
+ const Arch Arch_sparc( _sparc );
+
+ const Arch Arch_armv6l( _armv6l );
+ const Arch Arch_armv5tejl( _armv5tejl );
+ const Arch Arch_armv5tel( _armv5tel );
+ const Arch Arch_armv5l( _armv5l );
+ const Arch Arch_armv4tl( _armv4tl );
+ const Arch Arch_armv4l( _armv4l );
+ const Arch Arch_armv3l( _armv3l );
+
+ const Arch Arch_sh3( _sh3 );
+
+ const Arch Arch_sh4( _sh4 );
+ const Arch Arch_sh4a( _sh4a );
///////////////////////////////////////////////////////////////////
//
#include <iostream>
#include "zypp/base/Logger.h"
#include "zypp/base/Exception.h"
+#include "zypp/base/Functional.h"
#include "zypp/PathInfo.h"
#include "zypp/parser/ProductFileReader.h"
+#include "zypp/parser/xml/ParseDef.h"
#include "zypp/parser/xml/Reader.h"
using std::endl;
std::ostream & operator<<( std::ostream & str, const ProductFileData & obj )
{
- str << str::form( "|product|%s|%s|%s|%s|",
+ str << str::form( "|product|%s|%s|%s|%s|%p",
obj.name().c_str(),
obj.edition().c_str(),
obj.arch().c_str(),
- obj.vendor().c_str() );
+ obj.vendor().c_str(), (const void *)&obj );
return str;
}
// class ProductFileReader
//
/////////////////////////////////////////////////////////////////
+
bool consumeNode( xml::Reader & reader_r )
{
//DBG << *reader_r << endl;
return true;
}
+ struct ProductNode : public xml::ParseDef
+ {
+ ProductNode( Mode mode_r )
+ : ParseDef( "product", mode_r )
+ {
+ (*this)("ident", OPTIONAL)
+ ("onsys", OPTIONAL)
+ ;
+
+ (*this)["ident"]
+ ("name", OPTIONAL)
+ ("version", OPTIONAL)
+ ("description", OPTIONAL)
+ ("created", OPTIONAL)
+ ;
+
+ (*this)["onsys"]
+ ("entry", MULTIPLE_OPTIONAL)
+ ;
+ }
+ };
+
bool ProductFileReader::parse( const InputStream & input_r ) const
{
- INT << "+++" << input_r << endl;
+ MIL << "+++" << input_r << endl;
bool ret = true;
+ xml::ParseDef::_debug = true;
+
+ xml::Reader reader( input_r );
+
+ ProductNode rootNode( xml::ParseDef::MANDTAORY );
+ rootNode.take( reader );
+ ret = false;
+
+ MIL << "---" << ret << " - " << input_r << endl;
+ return ret;
+
try
{
xml::Reader reader( input_r );
// parse error
ERR << err << endl;
}
- INT << "---" << ret << " - " << input_r << endl;
+
+ if ( _consumer )
+ {
+ static unsigned idx = 0;
+
+ ProductFileData::Impl * i = new ProductFileData::Impl;
+ i->_name = IdString( str::numstring( ++idx, 4 ) );
+ ret = _consumer( i );
+ }
+
+ MIL << "---" << ret << " - " << input_r << endl;
return ret;
}
+ /////////////////////////////////////////////////////////////////
+
bool ProductFileReader::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 )
return false; // consumer_r request to stop parsing.
}
}
- DBG << "--- scanDir " << dir_r << endl;
return true;
}
- ProductFileData ProductFileReader::scanFile( const Pathname & dir_r )
+ ProductFileData ProductFileReader::scanFile( const Pathname & file_r )
{
- }
+ if ( ! PathInfo( file_r ).isFile() )
+ {
+ WAR << "scanFile " << PathInfo( file_r ) << " is no t a file." << endl;
+ return ProductFileData();
+ }
+
+ ProductFileData ret;
+ ProductFileReader reader( functor::getFirst( ret ), file_r );
+ return ret;
+ }
/////////////////////////////////////////////////////////////////
} // namespace parser
/** Ctor takes ownership of \c allocated_r. */
ProductFileData( Impl * allocated_r = 0 );
+ /** Whether this is an empty object without valid data. */
+ bool empty() const
+ { return name().empty(); }
+
public:
IdString vendor() const;
IdString name() const;
// CLASS NAME : ProductFileReader
//
/** Parser for /etc/products.d enries (just relevant entires).
+ *
+ * \code
+ * #include "zypp/base/Functional.h" // functor::getAll
+ *
+ * std::vector<ProductFileData> result;
+ * ProductFileReader::scanDir( functor::getAll( std::back_inserter( result ) ),
+ * "/etc/products.d" );
+ * \endcode
*/
class ProductFileReader
{
public:
/** Callback being invoked for each \ref ProductFileData parsed.
* Return \c false to stop parsing.
- */
+ */
typedef function<bool( const ProductFileData & )> Consumer;
public:
*/
static bool scanDir( const Consumer & consumer_r, const Pathname & dir_r );
- /** Parse one file (or symlink) and return the \ref ProductFileData parsed.
- */
- static ProductFileData scanFile( const Pathname & dir_r );
+ /** Parse one file (or symlink) and return the \ref ProductFileData parsed.
+ */
+ static ProductFileData scanFile( const Pathname & file_r );
private:
Consumer _consumer;
#include "zypp/TmpPath.h"
#include "zypp/KeyRing.h"
#include "zypp/ZYppFactory.h"
+#include "zypp/ZConfig.h"
using namespace std;
using namespace zypp::filesystem;
opts.push_back("-i");
else
opts.push_back("-U");
+
opts.push_back("--percent");
+ // ZConfig defines cross-arch installation
+ if ( ! ZConfig::instance.systemArchitecture().compatibleWith( ZConfig::instance.defaultSystemArchitecture() ) )
+ opts.push_back("--ignorearch");
+
if (flags & RPMINST_NODIGEST)
opts.push_back("--nodigest");
if (flags & RPMINST_NOSIGNATURE)