From eb04e2a85b732f28c5fecc91f6ea397dcf50eebb Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Wed, 6 Feb 2008 16:10:46 +0000 Subject: [PATCH] - remove ResStores in target and repositories - allow storing RepoInfo along with a sat::Repo - Provide RepoInfo (and Repository) in ResObject --- zypp/CMakeLists.txt | 11 --- zypp/Pattern.cc | 13 ++- zypp/RepoInfo.h | 6 +- zypp/RepoManager.cc | 4 +- zypp/RepoManager.h | 2 - zypp/Repository.cc | 14 +-- zypp/Repository.h | 13 +-- zypp/ResFilters.h | 4 +- zypp/ResObject.cc | 16 ++-- zypp/ResObject.h | 13 ++- zypp/ResStore.cc | 103 -------------------- zypp/ResStore.h | 190 ------------------------------------- zypp/Resolvable.h | 2 + zypp/Target.cc | 12 +-- zypp/Target.h | 20 ++-- zypp/ZYpp.h | 1 - zypp/parser/plaindir/RepoParser.cc | 1 - zypp/pool/PoolImpl.h | 2 + zypp/repo/RepositoryImpl.cc | 21 +--- zypp/repo/RepositoryImpl.h | 9 +- zypp/repo/cached/RepoImpl.cc | 85 ----------------- zypp/repo/cached/RepoImpl.h | 94 ------------------ zypp/sat/Pool.cc | 21 +++- zypp/sat/Pool.h | 7 ++ zypp/sat/Repo.cc | 23 +++++ zypp/sat/Repo.h | 17 +++- zypp/sat/detail/PoolImpl.h | 16 +++- zypp/target/TargetImpl.cc | 32 ------- zypp/target/TargetImpl.h | 18 +--- 29 files changed, 144 insertions(+), 626 deletions(-) delete mode 100644 zypp/ResStore.cc delete mode 100644 zypp/ResStore.h delete mode 100644 zypp/repo/cached/RepoImpl.cc delete mode 100644 zypp/repo/cached/RepoImpl.h diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt index 063784f..1f09082 100644 --- a/zypp/CMakeLists.txt +++ b/zypp/CMakeLists.txt @@ -69,7 +69,6 @@ SET( zypp_SRCS ResPool.cc ResPoolProxy.cc ResStatus.cc - ResStore.cc Script.cc Signature.cc SrcPackage.cc @@ -160,7 +159,6 @@ SET( zypp_HEADERS ResPool.h ResPoolProxy.h ResStatus.h - ResStore.h ResTraits.h Script.h Signature.h @@ -787,14 +785,6 @@ INSTALL( FILES DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/repo ) -SET( zypp_repo_cached_SRCS - repo/cached/RepoImpl.cc -) - -SET( zypp_repo_cached_HEADERS - repo/cached/RepoImpl.h -) - SET( zypp_repo_yum_SRCS repo/yum/Downloader.cc repo/yum/ResourceType.cc @@ -827,7 +817,6 @@ ${zypp_media_proxyinfo_SRCS} ${zypp_media_SRCS} ${zypp_url_SRCS} ${zypp_repo_SRCS} -${zypp_repo_cached_SRCS} ${zypp_repo_yum_SRCS} ${zypp_repo_susetags_SRCS} ${zypp_repo_data_SRCS} diff --git a/zypp/Pattern.cc b/zypp/Pattern.cc index 110553a..a9f46c5 100644 --- a/zypp/Pattern.cc +++ b/zypp/Pattern.cc @@ -91,11 +91,18 @@ namespace zypp return std::set(); } - const Capabilities & Pattern::includes() const - { return Capabilities(); } +#warning implement PATTERN::INSTALL_PACKAGES + const Capabilities & Pattern::includes() const + { + static Capabilities _val; + return _val; + } const Capabilities & Pattern::extends() const - { return Capabilities(); } + { + static Capabilities _val; + return _val; + } ///////////////////////////////////////////////////////////////// diff --git a/zypp/RepoInfo.h b/zypp/RepoInfo.h index 4de790a..428a65b 100644 --- a/zypp/RepoInfo.h +++ b/zypp/RepoInfo.h @@ -69,8 +69,6 @@ namespace zypp RepoInfo(); ~RepoInfo(); - typedef unsigned long NumericId; - /** * unique identifier for this source. If not specified * It should be generated from the base url. @@ -116,12 +114,12 @@ namespace zypp * If empty, the base url will be used. */ Url mirrorListUrl() const; - + typedef std::set url_set; //typedef url_set::const_iterator urls_const_iterator; typedef url_set::size_type urls_size_type; typedef transform_iterator urls_const_iterator; - + /** * iterator that points at begin of repository urls */ diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc index bf3f262..b425e04 100644 --- a/zypp/RepoManager.cc +++ b/zypp/RepoManager.cc @@ -29,7 +29,6 @@ #include "zypp/RepoManager.h" #include "zypp/cache/SolvStore.h" -#include "zypp/repo/cached/RepoImpl.h" #include "zypp/media/MediaManager.h" #include "zypp/MediaSetAccess.h" #include "zypp/ExternalProgram.h" @@ -38,7 +37,6 @@ #include "zypp/parser/RepoFileReader.h" #include "zypp/repo/yum/Downloader.h" #include "zypp/parser/yum/RepoParser.h" -//#include "zypp/parser/plaindir/RepoParser.h" #include "zypp/repo/susetags/Downloader.h" #include "zypp/parser/susetags/RepoParser.h" @@ -907,7 +905,7 @@ namespace zypp if ( ! PathInfo(solvfile).isExist() ) ZYPP_THROW(RepoNotCachedException()); - sat::Repo repo = satpool.addRepoSolv(solvfile, alias ); + sat::Repo repo = satpool.addRepoSolv(solvfile, info); } //////////////////////////////////////////////////////////////////////////// diff --git a/zypp/RepoManager.h b/zypp/RepoManager.h index 44f77e6..a958700 100644 --- a/zypp/RepoManager.h +++ b/zypp/RepoManager.h @@ -16,8 +16,6 @@ #include #include "zypp/base/PtrTypes.h" -//#include "zypp/base/ReferenceCounted.h" -//#include "zypp/base/NonCopyable.h" #include "zypp/Pathname.h" #include "zypp/ZConfig.h" #include "zypp/Repository.h" diff --git a/zypp/Repository.cc b/zypp/Repository.cc index 26e2c21..110ee1e 100644 --- a/zypp/Repository.cc +++ b/zypp/Repository.cc @@ -21,17 +21,16 @@ namespace zypp : _pimpl( Impl::nullimpl() ) {} - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : Repository::Repository - // METHOD TYPE : Ctor - // Repository::Repository( const Impl_Ptr & impl_r ) : _pimpl( impl_r ) { assert( impl_r ); } + Repository::Repository( const RepoInfo & info_r ) + : _pimpl( new repo::RepositoryImpl( info_r ) ) + {} + /////////////////////////////////////////////////////////////////// // // Forward to RepositoryImpl: @@ -41,11 +40,6 @@ namespace zypp Repository::NumericId Repository::numericId() const { return _pimpl->numericId(); } - const ResStore & Repository::resolvables() const - { - return _pimpl->resolvables(); - } - const RepoInfo & Repository::info() const { return _pimpl->info(); diff --git a/zypp/Repository.h b/zypp/Repository.h index 37903e5..b004793 100644 --- a/zypp/Repository.h +++ b/zypp/Repository.h @@ -7,14 +7,11 @@ #include "zypp/base/PtrTypes.h" #include "zypp/base/SafeBool.h" -//#include "zypp/ResStore.h" #include "zypp/RepoInfo.h" #include "zypp/repo/PackageDelta.h" namespace zypp { - class ResStore; - namespace repo { DEFINE_PTR_TYPE(RepositoryImpl); @@ -43,6 +40,11 @@ namespace zypp explicit Repository( const Impl_Ptr & impl_r ); + /** \short Factory ctor taking a RepositoryImpl. + */ + explicit + Repository( const RepoInfo & info_r ); + /** * A dummy Repository (Id \c 0) providing nothing, doing nothing. */ @@ -60,11 +62,6 @@ namespace zypp NumericId numericId() const; /** - * \short Get the resolvables for repo - */ - const ResStore & resolvables() const; - - /** * \short Repository info used to create this repository */ const RepoInfo & info() const; diff --git a/zypp/ResFilters.h b/zypp/ResFilters.h index 8ee8952..6268135 100644 --- a/zypp/ResFilters.h +++ b/zypp/ResFilters.h @@ -21,8 +21,6 @@ #include "zypp/PoolItem.h" #include "zypp/CapAndItem.h" -//#include "zypp/Repository.h" - /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// @@ -346,7 +344,7 @@ namespace zypp return p.status().isKept(); } }; - + /////////////////////////////////////////////////////////////////// diff --git a/zypp/ResObject.cc b/zypp/ResObject.cc index 4e2d8e8..3a84b23 100644 --- a/zypp/ResObject.cc +++ b/zypp/ResObject.cc @@ -45,7 +45,7 @@ class SearchQuery { 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; @@ -67,7 +67,7 @@ class SearchQuery } return 1; } - + sat::Solvable _solvable; std::string _result; }; @@ -132,13 +132,13 @@ namespace zypp { return lookupStrAttribute( sat::SolvAttr::vendor ); } ByteCount ResObject::size() const - { return lookupNumAttribute( sat::SolvAttr::size ); } - - Repository ResObject::repository() const - { return Repository(); } + { return lookupNumAttribute( sat::SolvAttr::size ); } ByteCount ResObject::downloadSize() const - { return lookupNumAttribute( sat::SolvAttr::downloadsize ); } + { return lookupNumAttribute( sat::SolvAttr::downloadsize ); } + + RepoInfo ResObject::repoInfo() const + { return repo().info(); } unsigned ResObject::mediaNr() const { return 1; } @@ -163,7 +163,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// #include "zypp/ResObjects.h" - + /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// diff --git a/zypp/ResObject.h b/zypp/ResObject.h index c3b9e0d..5930da8 100644 --- a/zypp/ResObject.h +++ b/zypp/ResObject.h @@ -95,10 +95,15 @@ namespace zypp /** Size of the rpm package. */ ByteCount downloadSize() const; - /** - * Source providing this resolvable + /** \ref RepoInfo associated with the repository + * providing this resolvable. + */ + RepoInfo repoInfo() const; + + /** \deprecated \ref repoInfo is provided directly. */ - Repository repository() const; + ZYPP_DEPRECATED Repository repository() const + { return Repository( repoInfo() ); } /** * Media number where the resolvable is located @@ -108,6 +113,8 @@ namespace zypp /** * \TODO FIXME what is this? + * Flag in the metadata indicating this should be + * installed unsing '-i' (not -U). */ bool installOnly() const; diff --git a/zypp/ResStore.cc b/zypp/ResStore.cc deleted file mode 100644 index fd13fb6..0000000 --- a/zypp/ResStore.cc +++ /dev/null @@ -1,103 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ -/** \file zypp/ResStore.cc - * -*/ -#include -//#include "zypp/base/Logger.h" - -#include "zypp/ResStore.h" - -using std::endl; - -/////////////////////////////////////////////////////////////////// -namespace zypp -{ ///////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : ResStore::Impl - // - /** ResStore implementation. */ - struct ResStore::Impl - { - Impl() - {} -#if 0 - iterator begin() - { return _store.begin(); } - - iterator end(); - { return _store.end(); } - - const_iterator begin() const; - { return _store.begin(); } - - const_iterator end() const; - { return _store.end(); } - - StorageT _store; -#endif - }; - /////////////////////////////////////////////////////////////////// - - /** \relates ResStore::Impl Stream output */ - inline std::ostream & operator<<( std::ostream & str, const ResStore::Impl & obj ) - { - return str << "ResStore::Impl"; - } - - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : ResStore - // - /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : ResStore::ResStore - // METHOD TYPE : Ctor - // - ResStore::ResStore() - //: _pimpl( new Impl ) - {} - - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : ResStore::~ResStore - // METHOD TYPE : Dtor - // - ResStore::~ResStore() - {} -#if 0 - ResStore::iterator ResStore::begin() - { return _pimpl->begin(); } - - ResStore::iterator ResStore::end(); - { return _pimpl->end(); } - - ResStore::const_iterator ResStore::begin() const; - { return _pimpl->begin(); } - - ResStore::const_iterator ResStore::end() const; - { return _pimpl->end(); } -#endif - /****************************************************************** - ** - ** FUNCTION NAME : operator<< - ** FUNCTION TYPE : std::ostream & - */ - std::ostream & operator<<( std::ostream & str, const ResStore & obj ) - { - return str << "ResStore: " << obj.size(); - } - - ///////////////////////////////////////////////////////////////// -} // namespace zypp -/////////////////////////////////////////////////////////////////// diff --git a/zypp/ResStore.h b/zypp/ResStore.h deleted file mode 100644 index 9a8d0fa..0000000 --- a/zypp/ResStore.h +++ /dev/null @@ -1,190 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ -/** \file zypp/ResStore.h - * -*/ -#ifndef ZYPP_RESSTORE_H -#define ZYPP_RESSTORE_H - -#include -#include - -#include "zypp/base/PtrTypes.h" -#include "zypp/ResObject.h" -#include "zypp/ResFilters.h" - -/////////////////////////////////////////////////////////////////// -namespace zypp -{ ///////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : ResStore - // - /** \todo obsolete and remove this class. - */ - class ZYPP_DEPRECATED ResStore - { - friend std::ostream & operator<<( std::ostream & str, const ResStore & obj ); - - public: - /** Implementation */ - class Impl; - - /** Type of Resolvable provided by ResStore. */ - typedef ResObject ResT; - - private: - typedef std::set StorageT; - - public: - typedef StorageT::value_type value_type; - typedef StorageT::const_reference const_reference; - typedef StorageT::size_type size_type; - typedef StorageT::iterator iterator; - typedef StorageT::const_iterator const_iterator; - typedef boost::filter_iterator resfilter_const_iterator; - - public: - /** Default ctor */ - ResStore(); - /** Dtor */ - ~ResStore(); - - public: - /** */ - iterator begin() - { return store().begin(); } - /** */ - iterator end() - { return store().end(); } - /** */ - const_iterator begin() const - { return store().begin(); } - /** */ - const_iterator end() const - { return store().end(); } - - /** */ - bool empty() const - { return store().empty(); } - /** */ - size_type size() const - { return store().size(); } - - // insert/erase - /** */ - iterator insert( const ResT::Ptr & ptr_r ) - { return store().insert( ptr_r ).first; } - - /** */ - iterator insert( iterator position, const value_type &v ) - { return store().insert( position, v ); } - - /** */ - template - void insert( _InputIterator first_r, _InputIterator last_r ) - { store().insert( first_r, last_r ); } - /** */ - size_type erase( const ResT::Ptr & ptr_r ) - { return store().erase( ptr_r ); } - /** */ - void erase( iterator pos_r ) - { store().erase( pos_r ); } - /** */ - void erase( iterator first_r, iterator last_r ) - { store().erase( first_r, last_r ); } - /** Erase by Kind */ - void erase( const Resolvable::Kind & kind_r ) - { - for ( iterator it = begin(); it != end(); ) - { - if ( (*it)->kind() == kind_r ) - { - store().erase( it++ ); // postfix! Incrementing before erase - } - else - ++it; - } - } - /** Erase by Kind. */ - template - void erase() - { erase( ResTraits<_Res>::kind ); } - /** */ - void clear() - { store().clear(); } - - /** Query inerface. - * Both, \a filter_r and \a fnc_r are expected to be - * functions or functors taking a ResT::Ptr - * as argument and return a \c bool. - * - * forEach iterates over all ResTs and invokes \a fnc_r, - * iff \a filter_r returned \c true. If \a fnc_r returnes - * \c false the loop is aborted. - * - * forEach returns the number of \a fnc_r invocations. Positive - * if the loop succeeded. Negative if some call to \a fnc_r - * returned \c false. - + - * \see \ref RESFILTERS for a collection of predefined filters. - */ - template - int forEach( _Filter filter_r, _Function fnc_r ) const - { - int cnt = 0; - for ( ResStore::const_iterator it = _store.begin(); it != _store.end(); ++it ) - { - if ( filter_r( *it ) ) - { - ++cnt; - if ( ! fnc_r( *it ) ) - return -cnt; - } - } - return cnt; - } - - template - int forEach( _Function fnc_r ) const - { - int cnt = 0; - for ( ResStore::const_iterator it = _store.begin(); it != _store.end(); ++it ) - { - ++cnt; - if ( ! fnc_r( *it ) ) - return -cnt; - } - return cnt; - } - - private: - /** */ - StorageT _store; - /** */ - StorageT & store() - { return _store; } - /** */ - const StorageT & store() const - { return _store; } - - private: - /** Pointer to implementation */ - RW_pointer _pimpl; // currently unsused - }; - /////////////////////////////////////////////////////////////////// - - /** \relates ResStore Stream output */ - std::ostream & operator<<( std::ostream & str, const ResStore & obj ); - - ///////////////////////////////////////////////////////////////// -} // namespace zypp -/////////////////////////////////////////////////////////////////// -#endif // ZYPP_RESSTORE_H diff --git a/zypp/Resolvable.h b/zypp/Resolvable.h index 4c21f3d..8363f17 100644 --- a/zypp/Resolvable.h +++ b/zypp/Resolvable.h @@ -53,6 +53,8 @@ namespace zypp public: /** Whether this represents a valid- or no-solvable. */ using sat::Solvable::operator bool_type; + /** Whether this represents an installed solvable. */ + using sat::Solvable::isSystem; using sat::Solvable::ident; diff --git a/zypp/Target.cc b/zypp/Target.cc index 3d61bec..f4ff4c0 100644 --- a/zypp/Target.cc +++ b/zypp/Target.cc @@ -67,12 +67,6 @@ namespace zypp void Target::load() { _pimpl->load(); } - ResStore::resfilter_const_iterator Target::byKindBegin( const ResObject::Kind & kind_r ) const - { return _pimpl->byKindBegin( kind_r ); } - - ResStore::resfilter_const_iterator Target::byKindEnd( const ResObject::Kind & kind_r ) const - { return _pimpl->byKindEnd( kind_r ); } - target::rpm::RpmDb & Target::rpmDb() { return _pimpl->rpm(); } @@ -82,7 +76,7 @@ namespace zypp bool Target::providesFile (const std::string & name_str, const std::string & path_str) const { return _pimpl->providesFile (name_str, path_str); } - ResObject::constPtr Target::whoOwnsFile (const std::string & path_str) const + std::string Target::whoOwnsFile (const std::string & path_str) const { return _pimpl->whoOwnsFile (path_str); } std::ostream & Target::dumpOn( std::ostream & str ) const @@ -93,10 +87,10 @@ namespace zypp Date Target::timestamp() const { return _pimpl->timestamp(); } - + void Target::reset() { return _pimpl->reset(); } - + ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// diff --git a/zypp/Target.h b/zypp/Target.h index baa23e8..b52227a 100644 --- a/zypp/Target.h +++ b/zypp/Target.h @@ -19,7 +19,6 @@ #include "zypp/base/PtrTypes.h" #include "zypp/base/Deprecated.h" -#include "zypp/ResStore.h" #include "zypp/Pathname.h" #include "zypp/ResPool.h" @@ -39,7 +38,7 @@ namespace zypp } DEFINE_PTR_TYPE(Target); - + /////////////////////////////////////////////////////////////////// // // CLASS NAME : Target @@ -60,22 +59,14 @@ namespace zypp */ void load(); - /** + /** * reload the target in future calls if * needed. * note the loading can actually be delayed, but - * the next call to resolvables must reflect the + * the next call to resolvables must reflect the * status of the system. */ void reset(); - - /** - * load resolvables of certain kind in the internal store - * and return a iterator - * successive calls will be faster as resolvables are cached- - */ - ResStore::resfilter_const_iterator byKindBegin( const ResObject::Kind & kind_r ) const; - ResStore::resfilter_const_iterator byKindEnd( const ResObject::Kind & kind_r ) const; /** Null implementation */ static Target_Ptr nullimpl(); @@ -87,7 +78,10 @@ namespace zypp Needed to evaluate split provides during Resolver::Upgrade() */ bool providesFile (const std::string & name_str, const std::string & path_str) const; - ResObject::constPtr whoOwnsFile (const std::string & path_str) const; + /** Return name of package owning \a path_str + * or empty string if no installed package owns \a path_str. + **/ + std::string whoOwnsFile (const std::string & path_str) const; /** Set the log file for target */ bool setInstallationLogfile(const Pathname & path_r); diff --git a/zypp/ZYpp.h b/zypp/ZYpp.h index 7d8ae27..8a5ee36 100644 --- a/zypp/ZYpp.h +++ b/zypp/ZYpp.h @@ -41,7 +41,6 @@ namespace zypp class ZYppFactory; class ResPool; class ResPoolProxy; - class ResStore; class Locale; class KeyRing; diff --git a/zypp/parser/plaindir/RepoParser.cc b/zypp/parser/plaindir/RepoParser.cc index eaa7b48..3f71708 100644 --- a/zypp/parser/plaindir/RepoParser.cc +++ b/zypp/parser/plaindir/RepoParser.cc @@ -20,7 +20,6 @@ #include "zypp/parser/plaindir/RepoParser.h" #include "zypp/parser/ParseException.h" #include "zypp/PathInfo.h" -#include "zypp/ResStore.h" #include "zypp/ZConfig.h" using namespace std; diff --git a/zypp/pool/PoolImpl.h b/zypp/pool/PoolImpl.h index f974dfe..c9b2f75 100644 --- a/zypp/pool/PoolImpl.h +++ b/zypp/pool/PoolImpl.h @@ -223,6 +223,8 @@ namespace zypp } } } + + _storeDirty = false; } return _store; } diff --git a/zypp/repo/RepositoryImpl.cc b/zypp/repo/RepositoryImpl.cc index 82ec979..eceb831 100644 --- a/zypp/repo/RepositoryImpl.cc +++ b/zypp/repo/RepositoryImpl.cc @@ -10,9 +10,8 @@ namespace zypp { namespace repo { IMPL_PTR_TYPE(RepositoryImpl) RepositoryImpl::RepositoryImpl( const RepoInfo &info ) - : _restore_lazy_initialized(false), - _deltas_lazy_initialized(false), - _info(info) + : _deltas_lazy_initialized(false) + , _info(info) { } @@ -31,22 +30,6 @@ RepositoryImpl::RepositoryImpl( const null & ) : base::ProvideNumericId( NULL ) {} - -const ResStore & RepositoryImpl::resolvables() const -{ - if ( ! _restore_lazy_initialized ) - { - const_cast(this)->createResolvables(); - const_cast(this)->_restore_lazy_initialized = true; - } - return _store; -} - -void RepositoryImpl::createResolvables() -{ - WAR << "createResolvables() not implemented" << endl; -} - void RepositoryImpl::createPatchAndDeltas() { WAR << "createPatchAndDeltas() not implemented" << endl; diff --git a/zypp/repo/RepositoryImpl.h b/zypp/repo/RepositoryImpl.h index 37f227a..94c6534 100644 --- a/zypp/repo/RepositoryImpl.h +++ b/zypp/repo/RepositoryImpl.h @@ -10,7 +10,6 @@ #include "zypp/base/NonCopyable.h" #include "zypp/base/PtrTypes.h" #include "zypp/base/ProvideNumericId.h" -#include "zypp/ResStore.h" #include "zypp/Repository.h" #include "zypp/RepoInfo.h" @@ -49,13 +48,11 @@ namespace zypp */ const RepoInfo & info() const; - const ResStore & resolvables() const; - const std::list & patchRpms() const; const std::list & deltaRpms() const; - virtual void createResolvables(); virtual void createPatchAndDeltas(); + public: struct null {}; @@ -72,13 +69,11 @@ namespace zypp { return Repository( this ); } protected: - ResStore _store; std::list _patchRpms; std::list _deltaRpms; private: - bool _restore_lazy_initialized; bool _deltas_lazy_initialized; - + RepoInfo _info; }; } diff --git a/zypp/repo/cached/RepoImpl.cc b/zypp/repo/cached/RepoImpl.cc deleted file mode 100644 index e008e38..0000000 --- a/zypp/repo/cached/RepoImpl.cc +++ /dev/null @@ -1,85 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ - -#include -#include - -#include "zypp/base/Gettext.h" -#include "zypp/base/Logger.h" -#include "zypp/base/Measure.h" -#include "zypp/repo/cached/RepoImpl.h" -#include "zypp/cache/ResolvableQuery.h" - -#include "zypp/sat/Pool.h" -#include "zypp/sat/Repo.h" -#include "zypp/sat/Solvable.h" - -using namespace zypp::cache; -using namespace std; - -/////////////////////////////////////////////////////////////////// -namespace zypp -{ ///////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////// -namespace repo -{ ///////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// -namespace cached -{ ///////////////////////////////////////////////////////////////// - -RepoImpl::RepoImpl( const RepoOptions &opts ) - : RepositoryImpl(opts.repoinfo) - , _rquery(opts.solvdir) - , _options(opts) -{ -} - -RepoImpl::~RepoImpl() -{ - MIL << "Destroying repo '" << info().alias() << "'" << endl; -} - -void RepoImpl::createResolvables() -{ - sat::Pool satpool( sat::Pool::instance() ); - - Pathname solvfile = (_options.solvdir + _options.repoinfo.alias()).extend(".solv"); - sat::Repo repo = satpool.addRepoSolv(solvfile, _options.repoinfo.alias() ); - - if ( repo != sat::Repo::norepo ) - { - sat::Repo::SolvableIterator it; - for ( it = repo.solvablesBegin(); it != repo.solvablesEnd(); ++it ) - { - _store.insert( makeResObject(*it) ); - } - } -} - -void RepoImpl::createPatchAndDeltas() -{ - -} - -ResolvableQuery RepoImpl::resolvableQuery() -{ - return _rquery; -} - - -///////////////////////////////////////////////////////////////// -} // namespace cached -/////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////// -} // namespace repo -/////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////// -} // namespace zypp -/////////////////////////////////////////////////////////////////// - diff --git a/zypp/repo/cached/RepoImpl.h b/zypp/repo/cached/RepoImpl.h deleted file mode 100644 index b264eb7..0000000 --- a/zypp/repo/cached/RepoImpl.h +++ /dev/null @@ -1,94 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ - -#ifndef ZYPP_RepoImpl_H -#define ZYPP_RepoImpl_H - -#include -#include -#include -#include "zypp/Arch.h" -#include "zypp/Rel.h" -#include "zypp/Pathname.h" -#include "zypp/ProgressData.h" -#include "zypp/data/RecordId.h" -#include "zypp/repo/RepositoryImpl.h" -#include "zypp/ResStore.h" -#include "zypp/RepoInfo.h" -#include "zypp/cache/CacheTypes.h" -#include "zypp/cache/ResolvableQuery.h" - -/////////////////////////////////////////////////////////////////// -namespace zypp -{ ///////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - namespace repo - { ///////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - namespace cached - { ///////////////////////////////////////////////////////////////// - - struct RepoOptions - { - RepoOptions( const RepoInfo &repoinfo_, - const Pathname &solvdir_ ) - - : repoinfo(repoinfo_) - , solvdir(solvdir_) - {} - - - ProgressData::ReceiverFnc readingResolvablesProgress; - ProgressData::ReceiverFnc readingPatchDeltasProgress; - RepoInfo repoinfo; - Pathname solvdir; - }; - - /** - * \short Cached repository implementation - * - * Reads attributes on demand from cache - */ - class RepoImpl : public repo::RepositoryImpl - { - public: - typedef intrusive_ptr Ptr; - typedef intrusive_ptr constPtr; - - public: - /** Default ctor */ - RepoImpl( const RepoOptions &opts ); - /** Dtor */ - ~RepoImpl(); - - public: - virtual void createResolvables(); - virtual void createPatchAndDeltas(); - - cache::ResolvableQuery resolvableQuery(); - private: - cache::ResolvableQuery _rquery; - RepoOptions _options; - }; - /////////////////////////////////////////////////////////////////// - - ///////////////////////////////////////////////////////////////// - } // namespace cached - /////////////////////////////////////////////////////////////////// - - using cached::RepoImpl; - - ///////////////////////////////////////////////////////////////// - } // namespace source - /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// -} // namespace zypp -/////////////////////////////////////////////////////////////////// -#endif // ZYPP_SOURCE_PLAINDIR_PLAINDIRIMPL_H - diff --git a/zypp/sat/Pool.cc b/zypp/sat/Pool.cc index 70f8c40..f2903ed 100644 --- a/zypp/sat/Pool.cc +++ b/zypp/sat/Pool.cc @@ -101,7 +101,18 @@ namespace zypp Repo ret( reposFind( name_r ) ); if ( ret ) return ret; - return Repo( myPool()._createRepo( name_r ) ); + + ret = Repo( myPool()._createRepo( name_r ) ); + if ( name_r == systemRepoName() ) + { + // autoprovide (dummy) RepoInfo + ret.setInfo( RepoInfo() + .setAlias( name_r ) + .setName( name_r ) + .setAutorefresh( true ) + .setEnabled( true ) ); + } + return ret; } Repo Pool::reposFind( const std::string & name_r ) const @@ -129,6 +140,14 @@ namespace zypp Repo Pool::addRepoSolv( const Pathname & file_r ) { return addRepoSolv( file_r, file_r.basename() ); } + Repo Pool::addRepoSolv( const Pathname & file_r, const RepoInfo & info_r ) + { + Repo ret( addRepoSolv( file_r, info_r.alias() ) ); + ret.setInfo( info_r ); + return ret; + } + + /****************************************************************** ** ** FUNCTION NAME : operator<< diff --git a/zypp/sat/Pool.h b/zypp/sat/Pool.h index 21c38e0..e68eaaa 100644 --- a/zypp/sat/Pool.h +++ b/zypp/sat/Pool.h @@ -24,6 +24,7 @@ namespace zypp { ///////////////////////////////////////////////////////////////// class SerialNumber; + class RepoInfo; /////////////////////////////////////////////////////////////////// namespace sat @@ -102,6 +103,8 @@ namespace zypp { return reposInsert( systemRepoName() ); } public: + + public: /** Load \ref Solvables from a solv-file into a \ref Repo named \c name_r. * In case of an exception the \ref Repo is removed from the \ref Pool. * \throws Exception if loading the solv-file fails. @@ -110,6 +113,10 @@ namespace zypp Repo addRepoSolv( const Pathname & file_r, const std::string & name_r ); /** \overload Using the files basename as \ref Repo name. */ Repo addRepoSolv( const Pathname & file_r ); + /** \overload Using the \ref RepoInfo::alias \ref Repo name. + * Additionally stores the \ref RepoInfo. \See \ref Prool::setInfo. + */ + Repo addRepoSolv( const Pathname & file_r, const RepoInfo & info_r ); public: /** Whether \ref Pool contains solvables. */ diff --git a/zypp/sat/Repo.cc b/zypp/sat/Repo.cc index 909d562..22c21a9 100644 --- a/zypp/sat/Repo.cc +++ b/zypp/sat/Repo.cc @@ -92,6 +92,29 @@ namespace zypp detail::SolvableIterator(_repo->end) ); } + RepoInfo Repo::info() const + { + 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 ); + } + + void Repo::clearInfo() + { + NO_REPO_RETURN(); + myPool().setRepoInfo( _repo, RepoInfo() ); + } + void Repo::eraseFromPool() { NO_REPO_RETURN(); diff --git a/zypp/sat/Repo.h b/zypp/sat/Repo.h index 2823040..4980e00 100644 --- a/zypp/sat/Repo.h +++ b/zypp/sat/Repo.h @@ -61,7 +61,7 @@ namespace zypp bool isSystemRepo() const; public: - /** The repos name (alias?). */ + /** The repos name (alias). */ std::string name() const; /** Whether \ref Repo contains solvables. */ @@ -77,6 +77,20 @@ namespace zypp SolvableIterator solvablesEnd() const; public: + /** Return any associated \ref RepoInfo. */ + RepoInfo info() const; + + /** Set \ref RepoInfo for this repository. + * \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. */ + void clearInfo(); + + public: /** Remove this \ref Repo from it's \ref Pool. */ void eraseFromPool(); @@ -91,6 +105,7 @@ namespace zypp //@{ /** Load \ref Solvables from a solv-file. * In case of an exception the repo remains in the \ref Pool. + * \throws Exception if this is \ref norepo * \throws Exception if loading the solv-file fails. * \see \ref Pool::addRepoSolv and \ref Repo::EraseFromPool */ diff --git a/zypp/sat/detail/PoolImpl.h b/zypp/sat/detail/PoolImpl.h index 087fc76..6e12824 100644 --- a/zypp/sat/detail/PoolImpl.h +++ b/zypp/sat/detail/PoolImpl.h @@ -24,6 +24,7 @@ extern "C" #include "zypp/base/NonCopyable.h" #include "zypp/base/SerialNumber.h" #include "zypp/sat/detail/PoolMember.h" +#include "zypp/RepoInfo.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -87,6 +88,7 @@ namespace zypp { setDirty(__FUNCTION__, repo_r->name ); ::repo_free( repo_r, /*reuseids*/false ); + eraseRepoInfo( repo_r ); } /** Adding solv file to a repo. */ @@ -154,12 +156,24 @@ namespace zypp return noSolvableId; } + public: + /** */ + const RepoInfo & repoInfo( RepoIdType id_r ) + { return _repoinfos[id_r]; } + /** */ + void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r ) + { _repoinfos[id_r] = info_r; } + /** */ + void eraseRepoInfo( RepoIdType id_r ) + { _repoinfos.erase( id_r ); } + private: /** sat-pool. */ ::_Pool * _pool; /** Serial number. */ SerialNumber _serial; - + /** Additional \ref RepoInfo. */ + std::map _repoinfos; }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index 46b0713..5fba083 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -352,20 +352,6 @@ namespace zypp return _root; } - ResStore::resfilter_const_iterator TargetImpl::byKindBegin( const ResObject::Kind & kind_r ) const - { - TargetImpl *ptr = const_cast(this); - resfilter::ResFilter filter = ByKind(kind_r); - return make_filter_iterator( filter, _store.begin(), _store.end() ); - } - - ResStore::resfilter_const_iterator TargetImpl::byKindEnd( const ResObject::Kind & kind_r ) const - { - TargetImpl *ptr = const_cast(this); - resfilter::ResFilter filter = ByKind(kind_r); - return make_filter_iterator( filter, _store.end(), _store.end() ); - } - void TargetImpl::reset() { // FIXME remove @@ -697,24 +683,6 @@ namespace zypp return _rpm.hasFile(path_str, name_str); } - /** Return the resolvable which provides path_str (rpm -qf) - return NULL if no resolvable provides this file */ - ResObject::constPtr TargetImpl::whoOwnsFile (const std::string & path_str) const - { - string name = _rpm.whoOwnsFile (path_str); - if (name.empty()) - return NULL; - - for (ResStore::const_iterator it = _store.begin(); it != _store.end(); ++it) - { - if ((*it)->name() == name) - { - return *it; - } - } - return NULL; - } - /** Set the log file for target */ bool TargetImpl::setInstallationLogfile(const Pathname & path_r) { diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index 81fa696..10dc21d 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -20,7 +20,6 @@ #include "zypp/base/NonCopyable.h" #include "zypp/base/DefaultFalseBool.h" #include "zypp/base/PtrTypes.h" -#include "zypp/ResStore.h" #include "zypp/PoolItem.h" #include "zypp/ZYppCommit.h" @@ -72,14 +71,6 @@ namespace zypp public: - /** - * load resolvables of certain kind in the internal store - * and return a iterator - * successive calls will be faster as resolvables are cached- - */ - ResStore::resfilter_const_iterator byKindBegin( const ResObject::Kind & kind_r ) const; - ResStore::resfilter_const_iterator byKindEnd( const ResObject::Kind & kind_r ) const; - /** The root set for this target */ Pathname root() const; @@ -123,9 +114,10 @@ namespace zypp Needed to evaluate split provides during Resolver::Upgrade() */ bool providesFile (const std::string & path_str, const std::string & name_str) const; - /** Return the resolvable which provides path_str (rpm -qf) - return NULL if no resolvable provides this file */ - ResObject::constPtr whoOwnsFile (const std::string & path_str) const; + /** Return name of package owning \a path_str + * or empty string if no installed package owns \a path_str. */ + std::string whoOwnsFile (const std::string & path_str) const + { return _rpm.whoOwnsFile (path_str); } /** Set the log file for target */ bool setInstallationLogfile(const Pathname & path_r); @@ -143,8 +135,6 @@ namespace zypp void reset(); protected: - /** All resolvables provided by the target. */ - ResStore _store; /** Path to the target */ Pathname _root; /** RPM database */ -- 2.7.4