adapt to libsolv api
authorMichael Andres <ma@suse.de>
Mon, 10 Oct 2011 12:17:38 +0000 (14:17 +0200)
committerMichael Andres <ma@suse.de>
Mon, 10 Oct 2011 12:19:21 +0000 (14:19 +0200)
doc/autoinclude/EnvironmentVariables.doc
zypp/Capability.cc
zypp/Edition.cc
zypp/IdString.cc
zypp/ZConfig.cc
zypp/sat/Transaction.cc
zypp/sat/detail/PoolImpl.cc
zypp/solver/detail/SATResolver.cc
zypp/solver/detail/SolverQueueItemLock.cc

index 739ff84..5ca194a 100644 (file)
@@ -16,7 +16,9 @@ Note that for Boolean variables we usually test whether the variable exists and
 
 \li \c ZYPP_LOGFILE=<PATH> Location of the logfile to write or \c - for stderr.
 \li \c ZYPP_FULLLOG=1 Even more verbose logging (usually not needed).
-\li \c ZYPP_LIBSAT_FULLLOG=1 Verbose logging when resolving dependencies.
+\li \c ZYPP_LIBSOLV_FULLLOG=1 Verbose logging when resolving dependencies.
+\li \c (ZYPP_LIBSAT_FULLLOG=1) deprecated since \c libzypp-10.x, prefer \c ZYPP_LIBSOLV_FULLLOG
+
 \li \c ZYPP_MEDIA_CURL_DEBUG=<0|1> Log http headers, if \c 1 also log server responses.
 
 \subsection zypp-envars-mediabackend Selecting the mediabackend to use.
index 40408dd..271bd7f 100644 (file)
@@ -149,19 +149,19 @@ namespace zypp
       {
         // map 'kind srcpackage' to 'arch src', the pseudo architecture
         // libsolv uses.
-        nid = ::rel2id( pool_r, nid, IdString(ARCH_SRC).id(), REL_ARCH, /*create*/true );
+        nid = ::pool_rel2id( pool_r, nid, IdString(ARCH_SRC).id(), REL_ARCH, /*create*/true );
       }
 
       // Extend name by architecture, if provided and not a srcpackage
       if ( ! arch_r.empty() && kind_r != ResKind::srcpackage )
       {
-        nid = ::rel2id( pool_r, nid, arch_r.id(), REL_ARCH, /*create*/true );
+        nid = ::pool_rel2id( pool_r, nid, arch_r.id(), REL_ARCH, /*create*/true );
       }
 
       // Extend 'op edition', if provided
       if ( op_r != Rel::ANY && ed_r != Edition::noedition )
       {
-        nid = ::rel2id( pool_r, nid, ed_r.id(), op_r.bits(), /*create*/true );
+        nid = ::pool_rel2id( pool_r, nid, ed_r.id(), op_r.bits(), /*create*/true );
       }
 
       return nid;
@@ -300,7 +300,7 @@ namespace zypp
   {}
 
   const char * Capability::c_str() const
-  { return( _id ? ::dep2str( myPool().getPool(), _id ) : "" ); }
+  { return( _id ? ::pool_dep2str( myPool().getPool(), _id ) : "" ); }
 
   CapMatch Capability::_doMatch( sat::detail::IdType lhs,  sat::detail::IdType rhs )
   {
index 429fb00..24f3e9c 100644 (file)
@@ -120,14 +120,14 @@ namespace zypp
   int Edition::_doCompare( const char * lhs,  const char * rhs )
   {
     if ( lhs == rhs ) return 0;
-    if ( lhs && rhs ) return ::evrcmp_str( myPool().getPool(), lhs, rhs, EVRCMP_COMPARE );
+    if ( lhs && rhs ) return ::pool_evrcmp_str( myPool().getPool(), lhs, rhs, EVRCMP_COMPARE );
     return( lhs ? 1 : -1 );
   }
 
   int Edition::_doMatch( const char * lhs,  const char * rhs )
   {
     if ( lhs == rhs ) return 0;
-    if ( lhs && rhs ) return ::evrcmp_str( myPool().getPool(), lhs, rhs, EVRCMP_MATCH );
+    if ( lhs && rhs ) return ::pool_evrcmp_str( myPool().getPool(), lhs, rhs, EVRCMP_MATCH );
     return( lhs ? 1 : -1 );
   }
 
index 31f48ef..33e05f2 100644 (file)
@@ -29,18 +29,18 @@ namespace zypp
   /////////////////////////////////////////////////////////////////
 
   IdString::IdString( const char * str_r )
-  : _id( ::str2id( myPool().getPool(), str_r, /*create*/true ) )
+  : _id( ::pool_str2id( myPool().getPool(), str_r, /*create*/true ) )
   {}
 
   IdString::IdString( const std::string & str_r )
-  : _id( ::str2id( myPool().getPool(), str_r.c_str(), /*create*/true ) )
+  : _id( ::pool_str2id( myPool().getPool(), str_r.c_str(), /*create*/true ) )
   {}
 
   unsigned IdString::size() const
   { return ::strlen( c_str() ); }
 
   const char * IdString::c_str() const
-  { return _id ? ::id2str( myPool().getPool(), _id ) : ""; }
+  { return _id ? ::pool_id2str( myPool().getPool(), _id ) : ""; }
 
   int IdString::compare( const IdString & rhs ) const
   {
index b68039d..c38669d 100644 (file)
@@ -13,7 +13,7 @@ extern "C"
 {
 #include <sys/utsname.h>
 #include <unistd.h>
-#include <solv/satversion.h>
+#include <solv/solvversion.h>
 }
 #include <iostream>
 #include <fstream>
@@ -834,8 +834,8 @@ namespace zypp
   {
     str << "libzypp: " << VERSION << " built " << __DATE__ << " " <<  __TIME__ << endl;
 
-    str << "libsolv: " << sat_version;
-    if ( ::strcmp( sat_version, LIBSOLV_VERSION_STRING ) )
+    str << "libsolv: " << solv_version;
+    if ( ::strcmp( solv_version, LIBSOLV_VERSION_STRING ) )
       str << " (built against " << LIBSOLV_VERSION_STRING << ")";
     str << endl;
 
index fe53beb..ca8e5ad 100644 (file)
@@ -44,6 +44,7 @@ namespace zypp
      *
      */
     struct Transaction::Impl : protected detail::PoolMember
+                            , private base::NonCopyable
     {
       friend std::ostream & operator<<( std::ostream & str, const Impl & obj );
 
@@ -69,14 +70,13 @@ namespace zypp
 
       public:
        Impl()
-       { memset( &_trans, 0, sizeof(_trans) ); }
+         : _trans( ::transaction_create( nullptr ) )
+       { memset( _trans, 0, sizeof(_trans) ); }
 
        Impl( ::_Transaction & trans_r )
          : _watcher( myPool().serial() )
+         , _trans( nullptr )
        {
-         memset( &_trans, 0, sizeof(_trans) );
-         ::transaction_init( &_trans, myPool().getPool() );
-
          Queue decisionq;
          for_( it, ResPool::instance().begin(), ResPool::instance().end() )
          {
@@ -87,13 +87,13 @@ namespace zypp
          }
          if ( trans_r.noobsmap.size )
            ::map_grow( &trans_r.noobsmap, myPool()->nsolvables );
-         ::transaction_calculate( &_trans, decisionq, &trans_r.noobsmap );
+         _trans = ::transaction_create_decisionq( myPool().getPool(), decisionq, &trans_r.noobsmap );
 
          // NOTE: package/product buddies share the same ResStatus
          // so we also link the buddies stepStages. This assumes
          // only one buddy is acting during commit (package is installed,
          // but no extra operation for the product).
-         for_( it, _trans.steps.elements, _trans.steps.elements + _trans.steps.count )
+         for_( it, _trans->steps.elements, _trans->steps.elements + _trans->steps.count )
          {
            sat::Solvable solv( *it );
            // buddy list:
@@ -119,7 +119,7 @@ namespace zypp
        }
 
        ~Impl()
-       { ::transaction_free( &_trans ); }
+       { ::transaction_free( _trans ); }
 
       public:
        bool valid() const
@@ -135,13 +135,13 @@ namespace zypp
          // This is hwo we could implement out own order method.
          // As ::transaction already groups by MediaNr, we don't
          // need it for ORDER_BY_MEDIANR.
-         ::transaction_order( &_trans, SOLVER_TRANSACTION_KEEP_ORDERDATA );
+         ::transaction_order( _trans, SOLVER_TRANSACTION_KEEP_ORDERDATA );
          detail::IdType chosen = 0;
          Queue choices;
 
          while ( true )
          {
-           int ret = transaction_order_add_choices( &_trans, chosen, choices );
+           int ret = transaction_order_add_choices( _trans, chosen, choices );
            MIL << ret << ": " << chosen << ": " << choices << endl;
            chosen = choices.pop_front(); // pick one out of choices
            if ( ! chosen )
@@ -151,27 +151,27 @@ namespace zypp
 #endif
          if ( !_ordered )
          {
-           ::transaction_order( &_trans, 0 );
+           ::transaction_order( _trans, 0 );
            _ordered = true;
          }
          return true;
        }
 
        bool empty() const
-       { return( _trans.steps.count == 0 ); }
+       { return( _trans->steps.count == 0 ); }
 
        size_t size() const
-       { return _trans.steps.count; }
+       { return _trans->steps.count; }
 
        const_iterator begin( const RW_pointer<Transaction::Impl> & self_r ) const
-       { return const_iterator( self_r, _trans.steps.elements ); }
+       { return const_iterator( self_r, _trans->steps.elements ); }
        iterator begin( const RW_pointer<Transaction::Impl> & self_r )
-       { return iterator( self_r, _trans.steps.elements ); }
+       { return iterator( self_r, _trans->steps.elements ); }
 
        const_iterator end( const RW_pointer<Transaction::Impl> & self_r ) const
-       { return const_iterator( self_r, _trans.steps.elements + _trans.steps.count ); }
+       { return const_iterator( self_r, _trans->steps.elements + _trans->steps.count ); }
        iterator end( const RW_pointer<Transaction::Impl> & self_r )
-       { return iterator( self_r, _trans.steps.elements + _trans.steps.count ); }
+       { return iterator( self_r, _trans->steps.elements + _trans->steps.count ); }
 
        const_iterator find(const RW_pointer<Transaction::Impl> & self_r, const sat::Solvable & solv_r ) const
        { detail::IdType * it( _find( solv_r ) ); return it ? const_iterator( self_r, it ) : end( self_r ); }
@@ -187,7 +187,7 @@ namespace zypp
            return isIn( _systemErase, solv_r.id() ) ? TRANSACTION_ERASE : TRANSACTION_IGNORE;
          }
 
-         switch( ::transaction_type( &_trans, solv_r.id(), SOLVER_TRANSACTION_RPM_ONLY ) )
+         switch( ::transaction_type( _trans, solv_r.id(), SOLVER_TRANSACTION_RPM_ONLY ) )
          {
            case SOLVER_TRANSACTION_ERASE: return TRANSACTION_ERASE; break;
            case SOLVER_TRANSACTION_INSTALL: return TRANSACTION_INSTALL; break;
@@ -248,9 +248,9 @@ namespace zypp
       private:
        detail::IdType * _find( const sat::Solvable & solv_r ) const
        {
-         if ( solv_r && _trans.steps.elements )
+         if ( solv_r && _trans->steps.elements )
          {
-           for_( it, _trans.steps.elements, _trans.steps.elements + _trans.steps.count )
+           for_( it, _trans->steps.elements, _trans->steps.elements + _trans->steps.count )
            {
              if ( *it == detail::IdType(solv_r.id()) )
                return it;
@@ -261,7 +261,7 @@ namespace zypp
 
      private:
        SerialNumberWatcher _watcher;
-       mutable ::Transaction _trans;
+       mutable ::Transaction _trans;
        DefaultIntegral<bool,false> _ordered;
        //
        set_type        _doneSet;
index 9a2e7d9..13c0ef7 100644 (file)
@@ -93,9 +93,9 @@ namespace zypp
 
       static void logSat( struct _Pool *, void *data, int type, const char *logString )
       {
-         if ( type & (SAT_FATAL|SAT_ERROR) ) {
+         if ( type & (SOLV_FATAL|SOLV_ERROR) ) {
            _ERR("libsolv") << logString;
-         } else if ( type & SAT_DEBUG_STATS ) {
+         } else if ( type & SOLV_DEBUG_STATS ) {
            _DBG("libsolv") << logString;
          } else {
            _MIL("libsolv") << logString;
@@ -181,12 +181,12 @@ namespace zypp
           ZYPP_THROW( Exception( _("Can not create sat-pool.") ) );
         }
         // initialialize logging
-       if ( getenv("ZYPP_LIBSAT_FULLLOG") )
+       if ( getenv("ZYPP_LIBSOLV_FULLLOG") || getenv("ZYPP_LIBSAT_FULLLOG") )
          ::pool_setdebuglevel( _pool, 4 );
        else if ( getenv("ZYPP_FULLLOG") )
          ::pool_setdebuglevel( _pool, 2 );
        else
-         ::pool_setdebugmask(_pool, SAT_DEBUG_JOB|SAT_DEBUG_STATS);
+         ::pool_setdebugmask(_pool, SOLV_DEBUG_JOB|SOLV_DEBUG_STATS);
 
         ::pool_setdebugcallback( _pool, logSat, NULL );
 
index 0420dc5..0b74990 100644 (file)
@@ -166,7 +166,11 @@ sat::Transaction SATResolver::getTransaction()
 {
   if ( !_solv )
     return sat::Transaction();
-  return sat::Transaction( _solv->trans );
+
+  ::Transaction * sattrans = ::solver_create_transaction( _solv );
+  sat::Transaction ret ( *sattrans );
+  ::transaction_free( sattrans );
+  return ret;
 }
 
 ResPool
@@ -703,7 +707,7 @@ SATResolver::resolvePool(const CapabilitySet & requires_caps,
            ERR << "Install: " << *iter << " not found" << endl;
        } else {
            MIL << "Install " << *iter << endl;
-           queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE );
+           queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
            queue_push( &(_jobQueue), id );
        }
     }
@@ -714,7 +718,7 @@ SATResolver::resolvePool(const CapabilitySet & requires_caps,
            ERR << "Delete: " << *iter << " not found" << endl;
        } else {
            MIL << "Delete " << *iter << endl;
-           queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE | MAYBE_CLEANDEPS );
+           queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
            queue_push( &(_jobQueue), id);
        }
     }
@@ -773,7 +777,7 @@ SATResolver::resolveQueue(const SolverQueueItemList &requestQueue,
            ERR << "Install: " << *iter << " not found" << endl;
        } else {
            MIL << "Install " << *iter << endl;
-           queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE );
+           queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
            queue_push( &(_jobQueue), id );
        }
     }
@@ -971,7 +975,7 @@ string SATResolver::SATprobleminfoString(Id problem, string &detail, Id &ignoreI
          ret = _("some dependency problem");
          break;
       case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
-         ret = str::form (_("nothing provides requested %s"), dep2str(pool, dep));
+         ret = str::form (_("nothing provides requested %s"), pool_dep2str(pool, dep));
          detail += _("Have you enabled all requested repositories?");
          break;
       case SOLVER_RULE_RPM_NOT_INSTALLABLE:
@@ -981,7 +985,7 @@ string SATResolver::SATprobleminfoString(Id problem, string &detail, Id &ignoreI
       case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
          ignoreId = source; // for setting weak dependencies
          s = mapSolvable (source);
-         ret = str::form (_("nothing provides %s needed by %s"), dep2str(pool, dep), s.asString().c_str());
+         ret = str::form (_("nothing provides %s needed by %s"), pool_dep2str(pool, dep), s.asString().c_str());
          break;
       case SOLVER_RULE_RPM_SAME_NAME:
          s = mapSolvable (source);
@@ -991,21 +995,21 @@ string SATResolver::SATprobleminfoString(Id problem, string &detail, Id &ignoreI
       case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
          s = mapSolvable (source);
          s2 = mapSolvable (target);
-         ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), dep2str(pool, dep), s2.asString().c_str());
+         ret = str::form (_("%s conflicts with %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
          break;
       case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
          s = mapSolvable (source);
          s2 = mapSolvable (target);
-         ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), dep2str(pool, dep), s2.asString().c_str());
+         ret = str::form (_("%s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
          break;
       case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
          s = mapSolvable (source);
          s2 = mapSolvable (target);
-         ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), dep2str(pool, dep), s2.asString().c_str());
+         ret = str::form (_("installed %s obsoletes %s provided by %s"), s.asString().c_str(), pool_dep2str(pool, dep), s2.asString().c_str());
          break;
       case SOLVER_RULE_RPM_SELF_CONFLICT:
          s = mapSolvable (source);
-         ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), dep2str(pool, dep));
+         ret = str::form (_("solvable %s conflicts with %s provided by itself"), s.asString().c_str(), pool_dep2str(pool, dep));
           break;
       case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
          ignoreId = source; // for setting weak dependencies
@@ -1037,7 +1041,7 @@ string SATResolver::SATprobleminfoString(Id problem, string &detail, Id &ignoreI
              }
          }
 
-         ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), dep2str(pool, dep));
+         ret = str::form (_("%s requires %s, but this requirement cannot be provided"), s.asString().c_str(), pool_dep2str(pool, dep));
          if (providerlistInstalled.size() > 0) {
              detail += _("deleted providers: ");
              for (ProviderList::const_iterator iter = providerlistInstalled.begin(); iter != providerlistInstalled.end(); iter++) {
@@ -1186,11 +1190,11 @@ SATResolver::problems ()
                                    resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
                                    resolverProblem->setDescription(_("This request will break your system!"));
                                    description = _("ignore the warning of a broken system");
-                                    description += string(" (requires:")+dep2str(pool, what)+")";
+                                    description += string(" (requires:")+pool_dep2str(pool, what)+")";
                                     MIL << description << endl;
                                     problemSolution->addFrontDescription (description);
                                } else {
-                                   description = str::form (_("do not ask to install a solvable providing %s"), dep2str(pool, what));
+                                   description = str::form (_("do not ask to install a solvable providing %s"), pool_dep2str(pool, what));
                                     MIL << description << endl;
                                     problemSolution->addDescription (description);
                                }
@@ -1207,12 +1211,12 @@ SATResolver::problems ()
                                    resolverProblem->setDetails( resolverProblem->description() + "\n" + resolverProblem->details() );
                                    resolverProblem->setDescription(_("This request will break your system!"));
                                    description = _("ignore the warning of a broken system");
-                                    description += string(" (conflicts:")+dep2str(pool, what)+")";
+                                    description += string(" (conflicts:")+pool_dep2str(pool, what)+")";
                                     MIL << description << endl;
                                     problemSolution->addFrontDescription (description);
 
                                } else {
-                                   description = str::form (_("do not ask to delete all solvables providing %s"), dep2str(pool, what));
+                                   description = str::form (_("do not ask to delete all solvables providing %s"), pool_dep2str(pool, what));
                                     MIL << description << endl;
                                     problemSolution->addDescription (description);
                                }
@@ -1296,7 +1300,7 @@ SATResolver::problems ()
                            if (itemFrom && itemTo) {
                                problemSolution->addSingleAction (itemTo, INSTALL);
 
-                               if (evrcmp(pool, s.get()->evr, sd.get()->evr, EVRCMP_COMPARE ) > 0)
+                               if (pool_evrcmp(pool, s.get()->evr, sd.get()->evr, EVRCMP_COMPARE ) > 0)
                                {
                                    string description = str::form (_("downgrade of %s to %s"), s.asString().c_str(), sd.asString().c_str());
                                    MIL << description << endl;
@@ -1384,11 +1388,11 @@ void SATResolver::setLocks()
         sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
        if (iter->status().isInstalled()) {
            MIL << "Lock installed item " << *iter << endl;
-           queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE );
+           queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE );
            queue_push( &(_jobQueue), ident );
        } else {
            MIL << "Lock NOT installed item " << *iter << endl;
-           queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE | MAYBE_CLEANDEPS );
+           queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | MAYBE_CLEANDEPS );
            queue_push( &(_jobQueue), ident );
        }
     }
@@ -1397,11 +1401,11 @@ void SATResolver::setLocks()
         sat::detail::SolvableIdType ident( (*iter)->satSolvable().id() );
        if (iter->status().isInstalled()) {
            MIL << "Keep installed item " << *iter << endl;
-           queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE | SOLVER_WEAK);
+           queue_push( &(_jobQueue), SOLVER_INSTALL | SOLVER_SOLVABLE | SOLVER_WEAK);
            queue_push( &(_jobQueue), ident );
        } else {
            MIL << "Keep NOT installed item " << *iter << ident << endl;
-           queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE | SOLVER_WEAK | MAYBE_CLEANDEPS );
+           queue_push( &(_jobQueue), SOLVER_ERASE | SOLVER_SOLVABLE | SOLVER_WEAK | MAYBE_CLEANDEPS );
            queue_push( &(_jobQueue), ident );
        }
     }
index 3b06ae6..e1c9473 100644 (file)
@@ -77,15 +77,15 @@ bool SolverQueueItemLock::addRule (_Queue & q)
     MIL << "Lock " << _item << " with the SAT-Pool ID: " << id << endl;
     if (_item.status().isInstalled()) {
        if (_soft) {
-           queue_push( &(q), SOLVER_INSTALL_SOLVABLE | SOLVER_WEAK );
+           queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE | SOLVER_WEAK );
        } else {
-           queue_push( &(q), SOLVER_INSTALL_SOLVABLE );
+           queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE );
        }
     } else {
        if (_soft) {
-           queue_push( &(q), SOLVER_ERASE_SOLVABLE | SOLVER_WEAK );
+           queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE | SOLVER_WEAK );
        } else {
-           queue_push( &(q), SOLVER_ERASE_SOLVABLE );
+           queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE );
        }
     }
     queue_push( &(q), id );