1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/sat/detail/PoolImpl.cc
13 #include <boost/mpl/int.hpp>
15 #include "zypp/base/Logger.h"
16 #include "zypp/base/Gettext.h"
17 #include "zypp/base/Exception.h"
19 #include "zypp/ZConfig.h"
21 #include "zypp/sat/detail/PoolImpl.h"
22 #include "zypp/Capability.h"
26 #undef ZYPP_BASE_LOGGER_LOGGROUP
27 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::satpool"
29 // ///////////////////////////////////////////////////////////////////
31 { /////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////
34 { /////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////
37 { /////////////////////////////////////////////////////////////////
39 // MPL checks for satlib constants we redefine to avoid
40 // includes and defines.
41 BOOST_MPL_ASSERT_RELATION( noId, ==, STRID_NULL );
42 BOOST_MPL_ASSERT_RELATION( emptyId, ==, STRID_EMPTY );
44 BOOST_MPL_ASSERT_RELATION( solvablePrereqMarker, ==, SOLVABLE_PREREQMARKER );
45 BOOST_MPL_ASSERT_RELATION( solvableFileMarker, ==, SOLVABLE_FILEMARKER );
47 BOOST_MPL_ASSERT_RELATION( CapDetail::CAP_AND, ==, REL_AND );
48 BOOST_MPL_ASSERT_RELATION( CapDetail::CAP_OR, ==, REL_OR );
49 BOOST_MPL_ASSERT_RELATION( CapDetail::CAP_WITH, ==, REL_WITH );
50 BOOST_MPL_ASSERT_RELATION( CapDetail::CAP_NAMESPACE, ==, REL_NAMESPACE );
52 /////////////////////////////////////////////////////////////////
54 static void logSat( struct _Pool *, void *data, int type, const char *logString )
56 if ((type & (SAT_FATAL|SAT_ERROR))) {
57 _ERR("satsolver") << logString;
59 _MIL("satsolver") << logString;
63 static detail::IdType nsCallback( struct _Pool *, void *data, detail::IdType lhs, detail::IdType rhs )
65 //T << Cability( lhs ) << (const char *)data << Capability( rhs ) << endl;
69 ///////////////////////////////////////////////////////////////////
71 // METHOD NAME : PoolMember::myPool
72 // METHOD TYPE : PoolImpl
74 PoolImpl & PoolMember::myPool()
76 static PoolImpl _global;
80 ///////////////////////////////////////////////////////////////////
82 // METHOD NAME : PoolImpl::PoolImpl
86 : _pool( ::pool_create() )
90 ZYPP_THROW( Exception( _("Can not create sat-pool.") ) );
92 // initialialize logging
93 bool verbose = ( getenv("ZYPP_FULLLOG") || getenv("ZYPP_LIBSAT_FULLLOG") );
94 ::pool_setdebuglevel( _pool, verbose ? 5 : 2 );
95 ::pool_setdebugcallback( _pool, logSat, NULL );
97 // set pool architecture
98 ::pool_setarch( _pool, ZConfig::instance().systemArchitecture().asString().c_str() );
100 // set namespace callback
101 _pool->nscallback = &nsCallback;
102 _pool->nscallbackdata = (void*)" NAMESPACE ";
103 SEC << _pool->nscallback << endl;
106 ///////////////////////////////////////////////////////////////////
108 // METHOD NAME : PoolImpl::~PoolImpl
109 // METHOD TYPE : Dtor
111 PoolImpl::~PoolImpl()
113 ::pool_free( _pool );
116 ///////////////////////////////////////////////////////////////////
118 void PoolImpl::setDirty( const char * a1, const char * a2, const char * a3 )
122 if ( a3 ) DBG << a1 << " " << a2 << " " << a3 << endl;
123 else if ( a2 ) DBG << a1 << " " << a2 << endl;
124 else DBG << a1 << endl;
127 ::pool_freewhatprovides( _pool );
130 void PoolImpl::prepare()
132 if ( _watcher.remember( _serial ) )
134 // sat solver claims to handle this on it's own:
135 ::pool_createwhatprovides( _pool );
139 /////////////////////////////////////////////////////////////////
140 } // namespace detail
141 ///////////////////////////////////////////////////////////////////
142 /////////////////////////////////////////////////////////////////
144 ///////////////////////////////////////////////////////////////////
145 /////////////////////////////////////////////////////////////////
147 ///////////////////////////////////////////////////////////////////