adapt to satpool now recording the system repo
authorMichael Andres <ma@suse.de>
Thu, 23 Oct 2008 14:07:01 +0000 (14:07 +0000)
committerMichael Andres <ma@suse.de>
Thu, 23 Oct 2008 14:07:01 +0000 (14:07 +0000)
devel/devel.ma/NewPool.cc
zypp/Repository.cc
zypp/Repository.h
zypp/sat/Pool.cc
zypp/sat/Pool.h
zypp/sat/Solvable.cc
zypp/sat/detail/PoolImpl.cc
zypp/sat/detail/PoolImpl.h

index dc033bc..af5d9d8 100644 (file)
@@ -523,7 +523,6 @@ try {
         continue;
 
       repoManager.refreshService( nservice );
-
     }
   }
 
@@ -611,22 +610,6 @@ try {
     }
   }
 
-  SEC << endl;
-  for_( it, pool.knownRepositoriesBegin(), pool.knownRepositoriesEnd() )
-  {
-    USR << *it << endl;
-    it->info().hasLicense();
-  }
-
-  SEC << endl;
-  RepoManager repoManager( makeRepoManager( sysRoot ) );
-  RepoInfoList repos = repoManager.knownRepositories();
-  for_( it, repos.begin(), repos.end() )
-  {
-    USR << *it << endl;
-    it->hasLicense();
-    WAR << it->getLicense( Locale("de_De") ) << endl;
-  }
 
 #if 0
   getZYpp()->resolver()->addRequire( Capability("amarok") );
index 708b246..4fafd59 100644 (file)
@@ -27,10 +27,12 @@ using std::endl;
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////
 
     const Repository Repository::noRepository;
 
+    const std::string & Repository::systemRepoAlias()
+    { return sat::detail::PoolImpl::systemRepoAlias(); }
+
     /////////////////////////////////////////////////////////////////
 
     ::_Repo * Repository::get() const
@@ -47,7 +49,7 @@ namespace zypp
     bool Repository::isSystemRepo() const
     {
        NO_REPOSITORY_RETURN( false );
-       return( sat::Pool::systemRepoAlias() == _repo->name );
+       return myPool().isSystemRepo( _repo );
     }
 
     std::string Repository::alias() const
@@ -217,6 +219,7 @@ namespace zypp
     void Repository::eraseFromPool()
     {
        NO_REPOSITORY_RETURN();
+        MIL << *this << " removed from pool" << endl;
        myPool()._deleteRepo( _repo );
        _id = sat::detail::noRepoId;
     }
@@ -236,22 +239,23 @@ namespace zypp
       return noRepository;
     }
 
-#warning NEED POOL MANIP EXEPTIONS
     void Repository::addSolv( const Pathname & file_r )
     {
-       NO_REPOSITORY_THROW( Exception( "Can't add solvables to norepo." ) );
+      NO_REPOSITORY_THROW( Exception( "Can't add solvables to norepo." ) );
 
-       AutoDispose<FILE*> file( ::fopen( file_r.c_str(), "r" ), ::fclose );
-       if ( file == NULL )
-       {
-           file.resetDispose();
-           ZYPP_THROW( Exception( "Can't open solv-file: "+file_r.asString() ));
-       }
+      AutoDispose<FILE*> file( ::fopen( file_r.c_str(), "r" ), ::fclose );
+      if ( file == NULL )
+      {
+        file.resetDispose();
+        ZYPP_THROW( Exception( "Can't open solv-file: "+file_r.asString() ) );
+      }
 
-       if ( myPool()._addSolv( _repo, file, isSystemRepo() ) != 0 )
-       {
-           ZYPP_THROW( Exception( "Error reading solv-file: "+file_r.asString() ));
-       }
+      if ( myPool()._addSolv( _repo, file ) != 0 )
+      {
+        ZYPP_THROW( Exception( "Error reading solv-file: "+file_r.asString() ) );
+      }
+
+      MIL << *this << " after adding " << file_r << endl;
     }
 
     sat::detail::SolvableIdType Repository::addSolvables( unsigned count_r )
index ed7f586..0bbaec0 100644 (file)
@@ -68,6 +68,9 @@ namespace zypp
         /** Evaluate \ref Repository in a boolean context (\c != \c noRepository). */
         using base::SafeBool<Repository>::operator bool_type;
 #endif
+        /** Reserved system repository alias \c @System. */
+        static const std::string & systemRepoAlias();
+
         /** Return whether this is the system repository. */
         bool isSystemRepo() const;
 
@@ -83,22 +86,6 @@ namespace zypp
           */
         std::string alias() const;
 
-         /**
-          * Short unique, convenience string to refer to a repo.
-          * ie: openSUSE-10.3
-          *
-          * The sat solver uses name for what we know as alias
-          * In rpm repositories, name is a label string
-          * ie: "openSUSE 10.3 Main repository"
-          *
-          * We know follow rpm conventions and ignore satsolver
-          * wording for name.
-          *
-          * Use \ref alias() instead
-          */
-        ZYPP_DEPRECATED std::string name() const
-        { return alias(); }
-
         /**
          * Timestamp when this repository was generated
          *
index 187f20d..f0b7fac 100644 (file)
@@ -36,10 +36,7 @@ namespace zypp
   { /////////////////////////////////////////////////////////////////
 
     const std::string & Pool::systemRepoAlias()
-    {
-      static const std::string _val( "@System" );
-      return _val;
-    }
+    { return detail::PoolImpl::systemRepoAlias(); }
 
     ::_Pool * Pool::get() const
     { return myPool().getPool(); }
@@ -104,7 +101,7 @@ namespace zypp
         return ret;
 
       ret = Repository( myPool()._createRepo( alias_r ) );
-      if ( alias_r == systemRepoAlias() )
+      if ( ret.isSystemRepo() )
       {
         // autoprovide (dummy) RepoInfo
         RepoInfo info;
@@ -113,8 +110,6 @@ namespace zypp
         info.setAutorefresh( true );
         info.setEnabled( true );
         ret.setInfo( info );
-        // indicate
-        ::pool_set_installed( get(), ret.get() );
       }
       return ret;
     }
index 7e3f761..ceb14d0 100644 (file)
@@ -99,11 +99,6 @@ namespace zypp
         /** Reserved system repository alias \c @System. */
         static const std::string & systemRepoAlias();
 
-        /** Deprecated, use \ref systemRepoAlias() */
-        ZYPP_DEPRECATED static const std::string & systemRepoName()
-        { return systemRepoAlias(); } 
-
-
         /** Return the system repository if it is on the pool. */
         Repository findSystemRepo() const
         { return reposFind( systemRepoAlias() ); }
index 1dc4f48..886979c 100644 (file)
@@ -133,7 +133,7 @@ namespace zypp
     bool Solvable::isSystem() const
     {
       NO_SOLVABLE_RETURN( _id == detail::systemSolvableId );
-      return Repository( _solvable->repo ).isSystemRepo();
+      return myPool().isSystemRepo( _solvable->repo );
     }
 
     IdString Solvable::ident() const
index 4124ca5..967a096 100644 (file)
@@ -64,6 +64,14 @@ namespace zypp
 
      /////////////////////////////////////////////////////////////////
 
+      const std::string & PoolImpl::systemRepoAlias()
+      {
+        static const std::string _val( "@System" );
+        return _val;
+      }
+
+      /////////////////////////////////////////////////////////////////
+
       static void logSat( struct _Pool *, void *data, int type, const char *logString )
       {
          if ((type & (SAT_FATAL|SAT_ERROR))) {
@@ -233,11 +241,27 @@ namespace zypp
 
       ///////////////////////////////////////////////////////////////////
 
-      int PoolImpl::_addSolv( ::_Repo * repo_r, FILE * file_r, bool isSystemRepo_r )
+      ::_Repo * PoolImpl::_createRepo( const std::string & name_r )
+      {
+        setDirty(__FUNCTION__, name_r.c_str() );
+        ::_Repo * ret = ::repo_create( _pool, name_r.c_str() );
+        if ( ret && name_r == systemRepoAlias() )
+          ::pool_set_installed( _pool, ret );
+        return ret;
+      }
+
+      void PoolImpl::_deleteRepo( ::_Repo * repo_r )
+      {
+        setDirty(__FUNCTION__, repo_r->name );
+        ::repo_free( repo_r, /*reuseids*/false );
+        eraseRepoInfo( repo_r );
+      }
+
+      int PoolImpl::_addSolv( ::_Repo * repo_r, FILE * file_r )
       {
         setDirty(__FUNCTION__, repo_r->name );
         int ret = ::repo_add_solv( repo_r , file_r  );
-        if ( ret == 0 && ! isSystemRepo_r )
+        if ( ret == 0 && ! isSystemRepo( repo_r ) )
         {
           // Filter out unwanted archs
           std::set<detail::IdType> sysids;
@@ -280,6 +304,12 @@ namespace zypp
         return ret;
       }
 
+      detail::SolvableIdType PoolImpl::_addSolvables( ::_Repo * repo_r, unsigned count_r )
+      {
+        setDirty(__FUNCTION__, repo_r->name );
+        return ::repo_add_solvable_block( repo_r, count_r );
+      }
+
       ///////////////////////////////////////////////////////////////////
 
       // need on demand and id based Locale
index e6c8f11..db774c7 100644 (file)
@@ -82,38 +82,32 @@ namespace zypp
           static detail::IdType nsCallback( ::_Pool *, void * data, detail::IdType lhs, detail::IdType rhs );
 
         public:
+          /** Reserved system repository alias \c @System. */
+          static const std::string & systemRepoAlias();
+
+          bool isSystemRepo( ::_Repo * repo_r ) const
+          { return repo_r && _pool->installed == repo_r; }
+
+        public:
           /** \name Actions invalidating housekeeping data.
            *
            * All methods expect valid arguments being passed.
            */
           //@{
           /** Creating a new repo named \a name_r. */
-          RepoIdType _createRepo( const std::string & name_r )
-          {
-            setDirty(__FUNCTION__, name_r.c_str() );
-            return ::repo_create( _pool, name_r.c_str() );
-          }
+          ::_Repo * _createRepo( const std::string & name_r );
 
           /** Creating a new repo named \a name_r. */
-          void _deleteRepo( ::_Repo * repo_r )
-          {
-            setDirty(__FUNCTION__, repo_r->name );
-            ::repo_free( repo_r, /*reuseids*/false );
-            eraseRepoInfo( repo_r );
-          }
+          void _deleteRepo( ::_Repo * repo_r );
 
           /** Adding solv file to a repo.
            * Except for \c isSystemRepo_r, solvables of incompatible architecture
            * are filtered out.
           */
-          int _addSolv( ::_Repo * repo_r, FILE * file_r, bool isSystemRepo_r = false );
+          int _addSolv( ::_Repo * repo_r, FILE * file_r );
 
           /** Adding Solvables to a repo. */
-          detail::SolvableIdType _addSolvables( ::_Repo * repo_r, unsigned count_r )
-          {
-            setDirty(__FUNCTION__, repo_r->name );
-            return ::repo_add_solvable_block( repo_r, count_r );
-          }
+          detail::SolvableIdType _addSolvables( ::_Repo * repo_r, unsigned count_r );
           //@}
 
         public: