///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- {
+ if ( 0 ) {
Measure x( "PROCXY" );
pool.proxy();
}
- {
+ if ( 0 ) {
Measure x( "ALL PATTERNS" );
for_( it, pool.byKindBegin<Pattern>(), pool.byKindEnd<Pattern>() )
}
}
- if ( 0 )
+ if ( 1 )
{
PoolItem pi ( getPi<Package>("amarok") );
MIL << pi << endl;
pi.status().setTransact( true, ResStatus::USER );
solve();
vdumpPoolStats( USR << "Transacting:"<< endl,
- make_filter_begin<resfilter::ByTransact>(pool),
- make_filter_end<resfilter::ByTransact>(pool) ) << endl;
+ make_filter_begin<resfilter::ByTransact>(pool),
+ make_filter_end<resfilter::ByTransact>(pool) ) << endl;
}
}
+-------------------------------------------------------------------
+Mon Apr 14 12:01:13 CEST 2008 - ma@suse.de
+
+- Enable evaluation of hardware dependencies.
+- revision 9603
+
-------------------------------------------------------------------
Sun Apr 13 02:17:25 CEST 2008 - jkupec@suse.cz
#include "zypp/Capability.h"
#include "zypp/Locale.h"
+#include "zypp/target/modalias/Modalias.h"
+
using std::endl;
#undef ZYPP_BASE_LOGGER_LOGGROUP
}
}
- detail::IdType PoolImpl::nsCallback( struct _Pool *, void *data, detail::IdType lhs, detail::IdType rhs )
+ detail::IdType PoolImpl::nsCallback( struct _Pool *, void * data, detail::IdType lhs, detail::IdType rhs )
{
- if ( lhs == NAMESPACE_LANGUAGE )
+ // lhs: the namespace identifier, e.g. NAMESPACE:MODALIAS
+ // rhs: the value, e.g. pci:v0000104Cd0000840[01]sv*sd*bc*sc*i*
+ // return: 0 if not supportded
+ // 1 if supported by the system
+ // -1 AFAIK it's also possible to return a list of solvables that support it, but don't know how.
+
+ static const detail::IdType RET_unsupported = 0;
+ static const detail::IdType RET_systemProperty = 1;
+ switch ( lhs )
{
- const std::tr1::unordered_set<IdString> & locale2Solver( reinterpret_cast<PoolImpl*>(data)->_locale2Solver );
- return locale2Solver.find( IdString(rhs) ) == locale2Solver.end() ? 0 : 1;
+ case NAMESPACE_LANGUAGE:
+ {
+ const std::tr1::unordered_set<IdString> & locale2Solver( reinterpret_cast<PoolImpl*>(data)->_locale2Solver );
+ return locale2Solver.find( IdString(rhs) ) == locale2Solver.end() ? RET_unsupported : RET_systemProperty;
+ }
+ break;
+
+ case NAMESPACE_MODALIAS:
+ {
+ return target::Modalias::instance().query( IdString(rhs) ) ? RET_systemProperty : RET_unsupported;
+ }
+ break;
+
+ case NAMESPACE_FILESYSTEM:
+ {
+
+ }
+ break;
}
- DBG << Capability( lhs ) << " vs. " << Capability( rhs ) << endl;
- return 0;
+
+ INT << "Unhandled " << Capability( lhs ) << " vs. " << Capability( rhs ) << endl;
+ return RET_unsupported;
}
///////////////////////////////////////////////////////////////////
*/
void depSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
+ /** Callback to resolve namespace dependencies (language, modalias, filesystem, etc.). */
static detail::IdType nsCallback( ::_Pool *, void * data, detail::IdType lhs, detail::IdType rhs );
public:
/** \file zypp/target/modalias/Modalias.cc
*
*/
-#include <iostream>
-
-#undef ZYPP_BASE_LOGGER_LOGGROUP
-#define ZYPP_BASE_LOGGER_LOGGROUP "MODALIAS"
-#include "zypp/base/Logger.h"
-
-#include "zypp/target/modalias/Modalias.h"
-
-#include <cstdlib>
-#include <stdio.h>
+extern "C"
+{
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <fnmatch.h>
+}
+#include <cstdlib>
+#include <cstdio>
#include <cstring>
#include <cerrno>
+#include <iostream>
+
+#undef ZYPP_BASE_LOGGER_LOGGROUP
+#define ZYPP_BASE_LOGGER_LOGGROUP "MODALIAS"
+#include "zypp/base/Logger.h"
+
+#include "zypp/target/modalias/Modalias.h"
+
+
using std::endl;
using std::string;
namespace target
{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- namespace modalias
+ namespace
{ /////////////////////////////////////////////////////////////////
/*
* If FUNC returns a non-zero return value, stop reading the directory
* and return that value. Returns -1 if an error occurs.
*/
-static int
+int
foreach_file(const char *path, int (*func)(const char *, const char *, void *),
void *arg)
{
* If DIR/FILE/modalias exists, remember this modalias on the linked modalias list
* passed in in ARG. Never returns an error.
*/
-static int
+int
read_modalias(const char *dir, const char *file, void *arg)
{
char path[PATH_MAX];
* and remembers all module aliases for those devices on
* the linked modalias list passed in in ARG.
*/
-static int
+int
iterate_bus(const char *dir, const char *file, void *arg)
{
char path[PATH_MAX];
* and remembers all module aliases for those devices on
* the linked modalias list passed in in ARG.
*/
-static int
+int
iterate_class(const char *dir, const char *file, void *arg)
{
char path[PATH_MAX];
return 0;
}
+ /////////////////////////////////////////////////////////////////
+ } // namespace
+ ///////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : Modalias::Impl
}
}
- /**
- * query for modalias capability present
- */
-
- bool query( const std::string & cap_r ) const
- { return query( cap_r, Rel::ANY, std::string() ); }
-
- /**
- * query for modalias capability having a specific value
+ /*
+ * Check if a device on the system matches a modalias PATTERN.
+ *
+ * Returns NULL if no matching device is found, and the modalias
+ * of the first matching device otherwise. (More than one device
+ * may match a given pattern.)
+ *
+ * On a system that has the following device,
+ *
+ * pci:v00008086d0000265Asv00008086sd00004556bc0Csc03i00
+ *
+ * modalias_matches("pci:v00008086d0000265Asv*sd*bc*sc*i*") will
+ * return a non-NULL value.
*/
- bool query( const std::string & cap_r,
- Rel op_r,
- const std::string & val_r ) const
+ bool query( const char * cap_r ) const
{
-
- /*
- * Check if a device on the system matches a modalias PATTERN.
- *
- * Returns NULL if no matching device is found, and the modalias
- * of the first matching device otherwise. (More than one device
- * may match a given pattern.)
- *
- * On a system that has the following device,
- *
- * pci:v00008086d0000265Asv00008086sd00004556bc0Csc03i00
- *
- * modalias_matches("pci:v00008086d0000265Asv*sd*bc*sc*i*") will
- * return a non-NULL value.
- */
-
- struct modalias_list *l;
- for (l = _modaliases; l; l = l->next) {
- if ( fnmatch( cap_r.c_str(), l->modalias, 0 ) == 0 )
- return true;
- }
- return false;
-
-#if 0 // once we get a capabilities values, we can compare it ...
- if (value) {
- string lhs (value);
- int cmp = (lhs != rhs) ? ((lhs < rhs) ? -1 : 1) : 0;
-
- switch ( relation.inSwitch() )
- {
- case Rel::EQ_e:
- res = (cmp == 0);
- break;
- case Rel::NE_e:
- res = (cmp != 0);
- break;
- case Rel::LT_e:
- res = (cmp == -1);
- break;
- case Rel::LE_e:
- res = (cmp != 1);
- break;
- case Rel::GT_e:
- res = (cmp == 1);
- break;
- case Rel::GE_e:
- res = (cmp != -1);
- break;
- case Rel::ANY_e:
- res = true;
- break;
- case Rel::NONE_e:
- res = false;
- break;
- default:
- // We shouldn't get here.
- INT << "Unknown relational opertor '" << relation << "' treated as 'NONE'" << endl;
- break;
- }
- }
-#endif
-
+ if ( cap_r )
+ {
+ struct modalias_list *l;
+ for (l = _modaliases; l; l = l->next) {
+ if ( fnmatch( cap_r, l->modalias, 0 ) == 0 )
+ return true;
+ }
+ }
+ return false;
}
public:
// Foreward to implenemtation
///////////////////////////////////////////////////////////////////
-bool Modalias::query( const std::string & cap_r ) const
+bool Modalias::query( const char * cap_r ) const
{ return _pimpl->query( cap_r ); }
-bool Modalias::query( const std::string & cap_r,
- Rel op_r,
- const std::string & val_r ) const
-{ return _pimpl->query( cap_r, op_r, val_r ); }
-
/******************************************************************
**
** FUNCTION NAME : operator<<
return str << *obj._pimpl;
}
-/////////////////////////////////////////////////////////////////
- } // namespace modalias
- ///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
} // namespace target
///////////////////////////////////////////////////////////////////
#include <string>
#include "zypp/base/PtrTypes.h"
-#include "zypp/Rel.h"
+#include "zypp/IdString.h"
///////////////////////////////////////////////////////////////////
namespace zypp
///////////////////////////////////////////////////////////////////
namespace target
{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace modalias
- { /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : Modalias
- //
- /** Hardware abstaction layer.
- * Singleton.
- */
- class Modalias
- {
- friend std::ostream & operator<<( std::ostream & str, const Modalias & obj );
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : Modalias
+ //
+ /** Hardware abstaction layer singleton.
+ */
+ class Modalias
+ {
+ friend std::ostream & operator<<( std::ostream & str, const Modalias & obj );
public:
/** Implementation */
public:
- /** */
- bool query( const std::string & cap_r ) const;
-
- /** */
- bool query( const std::string & cap_r,
- Rel op_r,
- const std::string & val_r ) const;
+ /** Checks if a device on the system matches a modalias pattern.
+ *
+ * Returns \c false if no matching device is found, and the modalias
+ * of the first matching device otherwise. (More than one device
+ * may match a given pattern.)
+ *
+ * On a system that has the following device,
+ * \code
+ * pci:v00008086d0000265Asv00008086sd00004556bc0Csc03i00
+ * \endcode
+ * the following query will return \c true:
+ * \code
+ * modalias_matches("pci:v00008086d0000265Asv*sd*bc*sc*i*")
+ * \endcode
+ */
+ bool query( IdString cap_r ) const
+ { return query( cap_r.c_str() ); }
+ /** \overload */
+ bool query( const char * cap_r ) const;
+ /** \overload */
+ bool query( const std::string & cap_r ) const
+ { return query( cap_r.c_str() ); }
private:
/** Singleton ctor. */
/** Pointer to implementation */
RW_pointer<Impl> _pimpl;
- };
- ///////////////////////////////////////////////////////////////////
+ };
+ ///////////////////////////////////////////////////////////////////
- /** \relates Modalias Stream output */
- std::ostream & operator<<( std::ostream & str, const Modalias & obj );
+ /** \relates Modalias Stream output */
+ std::ostream & operator<<( std::ostream & str, const Modalias & obj );
- /////////////////////////////////////////////////////////////////
- } // namespace modalias
- ///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
} // namespace target
///////////////////////////////////////////////////////////////////