From: Stefan Schubert Date: Wed, 27 Feb 2008 12:24:47 +0000 (+0000) Subject: Moving sat-repo to official libzypp-repo; PART 1 X-Git-Tag: 6.6.0~1329 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b8a2033e2af18473634ab2fe61303f5ff117bdc;p=platform%2Fupstream%2Flibzypp.git Moving sat-repo to official libzypp-repo; PART 1 --- diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc index cd4ff4b3a..659be20f8 100644 --- a/zypp/RepoManager.cc +++ b/zypp/RepoManager.cc @@ -913,7 +913,7 @@ namespace zypp if ( ! PathInfo(solvfile).isExist() ) ZYPP_THROW(RepoNotCachedException()); - sat::Repo repo = satpool.addRepoSolv(solvfile, info); + Repo repo = satpool.addRepoSolv(solvfile, info); } //////////////////////////////////////////////////////////////////////////// diff --git a/zypp/ResObject.cc b/zypp/ResObject.cc index f7e3b82bf..af22b61ee 100644 --- a/zypp/ResObject.cc +++ b/zypp/ResObject.cc @@ -17,61 +17,9 @@ #include "zypp/sat/Solvable.h" #include "zypp/sat/Repo.h" -extern "C" -{ -#include "satsolver/repo.h" -} - using namespace zypp; using namespace std; -class SearchQuery -{ - public: - - SearchQuery( const sat::Solvable &solvable_r ) - : _solvable(solvable_r) - { - - } - - void lookup( const sat::SolvAttr &attr ) - { - //search( _solvable.repo().get(), _solvable.id(), attr.idStr().id(), 0, 0 ); - //return repo_lookup_str(_solvable.get(), attr.idStr().id()); - } - - void search(Repo *repo, Id p, Id key, const char *match, int flags) - { - repo_search( repo, p, key, match, flags, SearchQuery::repo_search_cb, (void*) this); - } - - static int repo_search_cb(void *cbdata, ::Solvable *s, ::Repodata *data, ::Repokey *key, ::KeyValue *kv) - { - cout << "found attribute" << endl; - SearchQuery *q = (SearchQuery *) cbdata; - const char *keyname; - keyname = id2str(data->repo->pool, key->name); - switch(key->type) - { - case TYPE_ID: - //if (data->localpool) - // kv->str = stringpool_id2str(&data->spool, kv->id); - //else - // kv->str = id2str(data->repo->pool, kv->id); - // printf("%s: %s\n", keyname, kv->str); - break; - case TYPE_STR: - q->_result = kv->str; - break; - } - return 1; - } - - sat::Solvable _solvable; - std::string _result; -}; - /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// diff --git a/zypp/sat/Pool.h b/zypp/sat/Pool.h index e791bd5a3..f6c0ad987 100644 --- a/zypp/sat/Pool.h +++ b/zypp/sat/Pool.h @@ -43,7 +43,7 @@ namespace zypp { public: typedef detail::SolvableIterator SolvableIterator; - typedef detail::RepoIterator RepoIterator; + typedef zypp::detail::RepoIterator RepoIterator; typedef detail::size_type size_type; public: diff --git a/zypp/sat/Repo.cc b/zypp/sat/Repo.cc index 22c21a99e..92fcc507c 100644 --- a/zypp/sat/Repo.cc +++ b/zypp/sat/Repo.cc @@ -28,8 +28,6 @@ using std::endl; namespace zypp { ///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// - namespace sat - { ///////////////////////////////////////////////////////////////// const Repo Repo::norepo; @@ -48,126 +46,124 @@ namespace zypp bool Repo::isSystemRepo() const { - NO_REPO_RETURN( false ); - return( Pool::systemRepoName() == _repo->name ); + NO_REPO_RETURN( false ); + return( sat::Pool::systemRepoName() == _repo->name ); } std::string Repo::name() const { - NO_REPO_RETURN( std::string() ); - if ( ! _repo->name ) - return std::string(); - return _repo->name; + NO_REPO_RETURN( std::string() ); + if ( ! _repo->name ) + return std::string(); + return _repo->name; } bool Repo::solvablesEmpty() const { - NO_REPO_RETURN( true ); - return _repo->nsolvables; + NO_REPO_RETURN( true ); + return _repo->nsolvables; } Repo::size_type Repo::solvablesSize() const { - NO_REPO_RETURN( 0 ); - return _repo->nsolvables; + NO_REPO_RETURN( 0 ); + return _repo->nsolvables; } Repo::SolvableIterator Repo::solvablesBegin() const { - NO_REPO_RETURN( make_filter_iterator( detail::ByRepo( *this ), - detail::SolvableIterator(), - detail::SolvableIterator() ) ); - return make_filter_iterator( detail::ByRepo( *this ), - detail::SolvableIterator(_repo->start), - detail::SolvableIterator(_repo->end) ); + NO_REPO_RETURN( make_filter_iterator( detail::ByRepo( *this ), + sat::detail::SolvableIterator(), + sat::detail::SolvableIterator() ) ); + return make_filter_iterator( detail::ByRepo( *this ), + sat::detail::SolvableIterator(_repo->start), + sat::detail::SolvableIterator(_repo->end) ); } Repo::SolvableIterator Repo::solvablesEnd() const { - NO_REPO_RETURN( make_filter_iterator( detail::ByRepo( *this ), - detail::SolvableIterator(), - detail::SolvableIterator() ) ); - return make_filter_iterator(detail::ByRepo( *this ), - detail::SolvableIterator(_repo->end), - detail::SolvableIterator(_repo->end) ); + NO_REPO_RETURN( make_filter_iterator( detail::ByRepo( *this ), + sat::detail::SolvableIterator(), + sat::detail::SolvableIterator() ) ); + return make_filter_iterator(detail::ByRepo( *this ), + sat::detail::SolvableIterator(_repo->end), + sat::detail::SolvableIterator(_repo->end) ); } RepoInfo Repo::info() const { - NO_REPO_RETURN( RepoInfo() ); - return myPool().repoInfo( _repo ); + NO_REPO_RETURN( RepoInfo() ); + return myPool().repoInfo( _repo ); } void Repo::setInfo( const RepoInfo & info_r ) { - NO_REPO_THROW( Exception( _("Can't set RepoInfo for norepo.") ) ); - if ( info_r.alias() != name() ) - { - ZYPP_THROW( Exception( str::form( _("RepoInfo alias (%s) does not match repository name (%s)"), - info_r.alias().c_str(), name().c_str() ) ) ); - } - myPool().setRepoInfo( _repo, info_r ); + NO_REPO_THROW( Exception( _("Can't set RepoInfo for norepo.") ) ); + if ( info_r.alias() != name() ) + { + ZYPP_THROW( Exception( str::form( _("RepoInfo alias (%s) does not match repository name (%s)"), + info_r.alias().c_str(), name().c_str() ) ) ); + } + myPool().setRepoInfo( _repo, info_r ); } void Repo::clearInfo() { - NO_REPO_RETURN(); - myPool().setRepoInfo( _repo, RepoInfo() ); + NO_REPO_RETURN(); + myPool().setRepoInfo( _repo, RepoInfo() ); } void Repo::eraseFromPool() { - NO_REPO_RETURN(); - myPool()._deleteRepo( _repo ); - _id = detail::noRepoId; + NO_REPO_RETURN(); + myPool()._deleteRepo( _repo ); + _id = sat::detail::noRepoId; } #warning NEED POOL MANIP EXEPTIONS void Repo::addSolv( const Pathname & file_r ) { - NO_REPO_THROW( Exception( _("Can't add solvables to norepo.") ) ); - - AutoDispose 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 ) != 0 ) - { - ZYPP_THROW( Exception( _("Error reading solv-file: ")+file_r.asString() ) ); - } + NO_REPO_THROW( Exception( _("Can't add solvables to norepo.") ) ); + + AutoDispose 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 ) != 0 ) + { + ZYPP_THROW( Exception( _("Error reading solv-file: ")+file_r.asString() ) ); + } } - detail::SolvableIdType Repo::addSolvables( unsigned count_r ) + sat::detail::SolvableIdType Repo::addSolvables( unsigned count_r ) { - NO_REPO_THROW( Exception( _("Can't add solvables to norepo.") ) ); - return myPool()._addSolvables( _repo, count_r ); + NO_REPO_THROW( Exception( _("Can't add solvables to norepo.") ) ); + return myPool()._addSolvables( _repo, count_r ); } /****************************************************************** - ** - ** FUNCTION NAME : operator<< - ** FUNCTION TYPE : std::ostream & - */ + ** + ** FUNCTION NAME : operator<< + ** FUNCTION TYPE : std::ostream & + */ std::ostream & operator<<( std::ostream & str, const Repo & obj ) { - if ( ! obj ) - return str << "sat::repo()"; - - return str << "sat::repo(" << obj.name() << ")" - << "{" - << obj.solvablesSize() - << ' ' << obj.get()->start << ' ' << obj.get()->end << ' ' - << (obj.get()->start < 0 ? "_START_":"") - << (obj.get()->nsolvables < 0 ?"_NUMSOLV_":"") - <<"}"; + if ( ! obj ) + return str << "sat::repo()"; + + return str << "sat::repo(" << obj.name() << ")" + << "{" + << obj.solvablesSize() + << ' ' << obj.get()->start << ' ' << obj.get()->end << ' ' + << (obj.get()->start < 0 ? "_START_":"") + << (obj.get()->nsolvables < 0 ?"_NUMSOLV_":"") + <<"}"; } + ///////////////////////////////////////////////////////////////// - } // namespace sat - /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// diff --git a/zypp/sat/Repo.h b/zypp/sat/Repo.h index 6c99e3c3f..0517915b1 100644 --- a/zypp/sat/Repo.h +++ b/zypp/sat/Repo.h @@ -23,35 +23,32 @@ namespace zypp { ///////////////////////////////////////////////////////////////// - class Pathname; - class RepoInfo; + class Pathname; + class RepoInfo; - /////////////////////////////////////////////////////////////////// - namespace sat - { ///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// // // CLASS NAME : Repo // /** */ - class Repo : protected detail::PoolMember, + class Repo : protected sat::detail::PoolMember, private base::SafeBool { - public: - typedef filter_iterator SolvableIterator; - typedef detail::size_type size_type; + public: + typedef filter_iterator SolvableIterator; + typedef sat::detail::size_type size_type; - public: + public: /** Default ctor creates \ref norepo.*/ Repo() - : _id( detail::noRepoId ) {} + : _id( sat::detail::noRepoId ) {} /** \ref PoolImpl ctor. */ - explicit Repo( detail::RepoIdType id_r ) - : _id( id_r ) {} + explicit Repo( sat::detail::RepoIdType id_r ) + : _id( id_r ) {} - public: + public: /** Represents no \ref Repo. */ static const Repo norepo; @@ -61,7 +58,7 @@ namespace zypp /** Return whether this is the system repo. */ bool isSystemRepo() const; - public: + public: /** The repos name (alias). */ std::string name() const; @@ -77,7 +74,7 @@ namespace zypp /** Iterator behind the last \ref Solvable. */ SolvableIterator solvablesEnd() const; - public: + public: /** Return any associated \ref RepoInfo. */ RepoInfo info() const; @@ -85,20 +82,20 @@ namespace zypp * \throws Exception if this is \ref norepo * \throws Exception if the \ref RepoInfo::alias * does not match the \ref Repo::name. - */ + */ void setInfo( const RepoInfo & info_r ); - /** Remove any \ref RepoInfo set for this repository. */ + /** Remove any \ref RepoInfo set for this repository. */ void clearInfo(); - public: + public: /** Remove this \ref Repo from it's \ref Pool. */ void eraseFromPool(); /** Functor calling \ref eraseFromPool. */ struct EraseFromPool; - public: + public: /** \name Repo content manipulating methods. * \todo maybe a separate Repo/Solvable content manip interface * provided by the pool. @@ -113,22 +110,22 @@ namespace zypp void addSolv( const Pathname & file_r ); /** Add \c count_r new empty \ref Solvable to this \ref Repo. */ - detail::SolvableIdType addSolvables( unsigned count_r ); + sat::detail::SolvableIdType addSolvables( unsigned count_r ); /** \overload Add only one new \ref Solvable. */ - detail::SolvableIdType addSolvable() - { return addSolvables( 1 ); } + sat::detail::SolvableIdType addSolvable() + { return addSolvables( 1 ); } //@} - public: + public: /** Expert backdoor. */ ::_Repo * get() const; /** Expert backdoor. */ - detail::RepoIdType id() const { return _id; } - private: + sat::detail::RepoIdType id() const { return _id; } + private: friend base::SafeBool::operator bool_type() const; bool boolTest() const { return get(); } - private: - detail::RepoIdType _id; + private: + sat::detail::RepoIdType _id; }; /////////////////////////////////////////////////////////////////// @@ -179,8 +176,8 @@ namespace zypp */ struct Repo::EraseFromPool { - void operator()( Repo repo_r ) const - { repo_r.eraseFromPool(); } + void operator()( Repo repo_r ) const + { repo_r.eraseFromPool(); } }; /////////////////////////////////////////////////////////////////// @@ -192,57 +189,54 @@ namespace zypp // CLASS NAME : RepoIterator // /** */ - class RepoIterator : public boost::iterator_adaptor< - RepoIterator // Derived - , ::_Repo ** // Base - , Repo // Value - , boost::forward_traversal_tag // CategoryOrTraversal - , Repo // Reference - > - { + class RepoIterator : public boost::iterator_adaptor< + RepoIterator // Derived + , ::_Repo ** // Base + , Repo // Value + , boost::forward_traversal_tag // CategoryOrTraversal + , Repo // Reference + > + { public: - RepoIterator() - : RepoIterator::iterator_adaptor_( 0 ) - {} + RepoIterator() + : RepoIterator::iterator_adaptor_( 0 ) + {} - explicit RepoIterator( ::_Repo ** p ) - : RepoIterator::iterator_adaptor_( p ) - {} + explicit RepoIterator( ::_Repo ** p ) + : RepoIterator::iterator_adaptor_( p ) + {} private: - friend class boost::iterator_core_access; - - Repo dereference() const - { return Repo( *base() ); } - }; - /////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : ByRepo - // - /** Functor filtering \ref Solvable by \ref Repo.*/ - struct ByRepo - { + friend class boost::iterator_core_access; + + Repo dereference() const + { return Repo( *base() ); } + }; + /////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : ByRepo + // + /** Functor filtering \ref Solvable by \ref Repo.*/ + struct ByRepo + { public: - ByRepo( const Repo & repo_r ) : _repo( repo_r ) {} - ByRepo( RepoIdType id_r ) : _repo( id_r ) {} - ByRepo() {} + ByRepo( const Repo & repo_r ) : _repo( repo_r ) {} + ByRepo( sat::detail::RepoIdType id_r ) : _repo( id_r ) {} + ByRepo() {} - bool operator()( const Solvable & slv_r ) const - { return slv_r.repo() == _repo; } + bool operator()( const sat::Solvable & slv_r ) const + { return slv_r.repo() == _repo; } private: - Repo _repo; - }; - /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// + Repo _repo; + }; + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// } // namespace detail /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// - } // namespace sat - /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// #endif // ZYPP_SAT_REPO_H diff --git a/zypp/sat/SATResolver.cc b/zypp/sat/SATResolver.cc index 467a7d07e..dbf0070cb 100644 --- a/zypp/sat/SATResolver.cc +++ b/zypp/sat/SATResolver.cc @@ -233,7 +233,7 @@ SATSolutionToPool (PoolItem item, const ResStatus & status, const ResStatus::Tra bool SATResolver::doesObsoleteItem (PoolItem candidate, PoolItem installed) { Solvable *sCandidate = _SATPool->solvables + candidate.satSolvable().id(); - Repo *installedRepo = sat::Pool::instance().systemRepo().get(); + ::_Repo *installedRepo = sat::Pool::instance().systemRepo().get(); Id p, *pp, obsolete, *obsoleteIt; diff --git a/zypp/sat/detail/PoolMember.h b/zypp/sat/detail/PoolMember.h index 82f4337fe..0d8829733 100644 --- a/zypp/sat/detail/PoolMember.h +++ b/zypp/sat/detail/PoolMember.h @@ -40,13 +40,19 @@ namespace zypp class IdString; class Capability; class Capabilities; + class Repo; + /////////////////////////////////////////////////////////////////// + namespace detail + { + class RepoIterator; + class ByRepo; + } /////////////////////////////////////////////////////////////////// namespace sat { ///////////////////////////////////////////////////////////////// class Solvable; - class Repo; class Pool; /////////////////////////////////////////////////////////////////// @@ -116,8 +122,6 @@ namespace zypp { ///////////////////////////////////////////////////////////////// class SolvableIterator; - class RepoIterator; - class ByRepo; ///////////////////////////////////////////////////////////////// } // namespace detail diff --git a/zypp/solver/detail/Testcase.cc b/zypp/solver/detail/Testcase.cc index 84c78b153..e44bebe18 100644 --- a/zypp/solver/detail/Testcase.cc +++ b/zypp/solver/detail/Testcase.cc @@ -284,7 +284,7 @@ bool Testcase::createTestcasePool(const ResPool &pool) system.addResolvable (*it); } else { // repo channels - sat::Repo repo = it->resolvable()->satSolvable().repo(); + Repo repo = it->resolvable()->satSolvable().repo(); if (repoTable.find (repo) == repoTable.end()) { repoTable[repo] = new HelixResolvable(dumpPath + "/" + str::numstring((long)repo.id()) @@ -357,7 +357,7 @@ bool Testcase::createTestcase(Resolver & resolver, bool dumpPool, bool runSolver system->addResolvable (*it); } else { // repo channels - sat::Repo repo = it->resolvable()->satSolvable().repo(); + Repo repo = it->resolvable()->satSolvable().repo(); if (dumpPool) { if (repoTable.find (repo) == repoTable.end()) { repoTable[repo] = new HelixResolvable(dumpPath + "/" diff --git a/zypp/solver/detail/Testcase.h b/zypp/solver/detail/Testcase.h index df63a1c02..b9a982a11 100644 --- a/zypp/solver/detail/Testcase.h +++ b/zypp/solver/detail/Testcase.h @@ -82,7 +82,7 @@ class HelixResolvable : public base::ReferenceCounted, private base::NonCopyabl }; DEFINE_PTR_TYPE(HelixResolvable); -typedef std::map RepositoryTable; +typedef std::map RepositoryTable; /////////////////////////////////////////////////////////////////// // diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index 08e601ae5..4f0136a7e 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -380,7 +380,7 @@ namespace zypp //now add the repos to the pool MIL << "adding " << rpmsolv << " to pool(" << sat::Pool::instance().systemRepoName() << ")"; - sat::Repo system = sat::Pool::instance().systemRepo(); + Repo system = sat::Pool::instance().systemRepo(); system.addSolv(rpmsolv); MIL << "Target loaded: " << system.solvablesSize() << " resolvables" << endl;