From 6a483d7b3ae57c730248d5f3c0044630c93f2abc Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Fri, 15 Jul 2011 15:14:34 +0200 Subject: [PATCH] Check for /etc/sysconfig/storage changes before solving (bnc#702365) --- zypp/sat/Pool.cc | 3 +++ zypp/sat/Pool.h | 3 +++ zypp/sat/detail/PoolImpl.cc | 45 ++++++++++++++++++++++++++++++--------- zypp/sat/detail/PoolImpl.h | 9 ++++++++ zypp/solver/detail/SATResolver.cc | 4 ++-- 5 files changed, 52 insertions(+), 12 deletions(-) diff --git a/zypp/sat/Pool.cc b/zypp/sat/Pool.cc index cc0b336..c93422c 100644 --- a/zypp/sat/Pool.cc +++ b/zypp/sat/Pool.cc @@ -45,6 +45,9 @@ namespace zypp void Pool::prepare() const { return myPool().prepare(); } + void Pool::prepareForSolving() const + { return myPool().prepareForSolving(); } + bool Pool::reposEmpty() const { return ! myPool()->nrepos; } diff --git a/zypp/sat/Pool.h b/zypp/sat/Pool.h index d88e5c4..df86592 100644 --- a/zypp/sat/Pool.h +++ b/zypp/sat/Pool.h @@ -65,6 +65,9 @@ namespace zypp /** Update housekeeping data if necessary (e.g. whatprovides). */ void prepare() const; + /** \ref prepare plus some expensive checks done before solving only. */ + void prepareForSolving() const; + public: /** Whether \ref Pool contains repos. */ bool reposEmpty() const; diff --git a/zypp/sat/detail/PoolImpl.cc b/zypp/sat/detail/PoolImpl.cc index 79b2106..8786e78 100644 --- a/zypp/sat/detail/PoolImpl.cc +++ b/zypp/sat/detail/PoolImpl.cc @@ -82,6 +82,13 @@ namespace zypp return _val; } + const Pathname & sysconfigStoragePath() + { + static const Pathname _val( "/etc/sysconfig/storage" ); + return _val; + } + + ///////////////////////////////////////////////////////////////// static void logSat( struct _Pool *, void *data, int type, const char *logString ) @@ -131,15 +138,7 @@ namespace zypp case NAMESPACE_FILESYSTEM: { - static const Pathname sysconfigStoragePath( "/etc/sysconfig/storage" ); - static WatchFile sysconfigFile( sysconfigStoragePath, WatchFile::NO_INIT ); - static std::set requiredFilesystems; - if ( sysconfigFile.hasChanged() ) - { - requiredFilesystems.clear(); - str::split( base::sysconfig::read( sysconfigStoragePath )["USED_FS_LIST"], - std::inserter( requiredFilesystems, requiredFilesystems.end() ) ); - } + const std::set & requiredFilesystems( reinterpret_cast(data)->requiredFilesystems() ); return requiredFilesystems.find( IdString(rhs).asString() ) != requiredFilesystems.end() ? RET_systemProperty : RET_unsupported; } break; @@ -237,7 +236,7 @@ namespace zypp void PoolImpl::prepare() const { - if ( _watcher.remember( _serial ) ) + if ( _watcher.remember( _serial ) ) { // After repo/solvable add/remove: // set pool architecture @@ -246,6 +245,7 @@ namespace zypp if ( ! _pool->whatprovides ) { MIL << "pool_createwhatprovides..." << endl; + ::pool_addfileprovides( _pool ); ::pool_createwhatprovides( _pool ); } @@ -256,6 +256,19 @@ namespace zypp } } + void PoolImpl::prepareForSolving() const + { + // additional /etc/sysconfig/storage check: + static WatchFile sysconfigFile( sysconfigStoragePath(), WatchFile::NO_INIT ); + if ( sysconfigFile.hasChanged() ) + { + _requiredFilesystemsPtr.reset(); // recreated on demand + const_cast(this)->depSetDirty( "/etc/sysconfig/storage change" ); + } + // finally prepare as usual: + prepare(); + } + /////////////////////////////////////////////////////////////////// ::_Repo * PoolImpl::_createRepo( const std::string & name_r ) @@ -599,6 +612,18 @@ namespace zypp MIL << "onSystemByUserList found: " << onSystemByUserList.size() << endl; } + const std::set & PoolImpl::requiredFilesystems() const + { + if ( ! _requiredFilesystemsPtr ) + { + _requiredFilesystemsPtr.reset( new std::set ); + std::set & requiredFilesystems( *_requiredFilesystemsPtr ); + str::split( base::sysconfig::read( sysconfigStoragePath() )["USED_FS_LIST"], + std::inserter( requiredFilesystems, requiredFilesystems.end() ) ); + } + return *_requiredFilesystemsPtr; + } + ///////////////////////////////////////////////////////////////// } // namespace detail /////////////////////////////////////////////////////////////////// diff --git a/zypp/sat/detail/PoolImpl.h b/zypp/sat/detail/PoolImpl.h index 09ea430..00edf97 100644 --- a/zypp/sat/detail/PoolImpl.h +++ b/zypp/sat/detail/PoolImpl.h @@ -67,6 +67,8 @@ namespace zypp * \todo actually requires a watcher. */ void prepare() const; + /** \ref prepare plus some expensive checks done before solving only. */ + void prepareForSolving() const; private: /** Invalidate housekeeping data (e.g. whatprovides) if the @@ -261,6 +263,10 @@ namespace zypp } //@} + public: + /** accessor for etc/sysconfig/storage reading file on demand */ + const std::set & requiredFilesystems() const; + private: /** sat-pool. */ ::_Pool * _pool; @@ -283,6 +289,9 @@ namespace zypp /** */ void onSystemByUserListInit() const; mutable scoped_ptr _onSystemByUserListPtr; + + /** filesystems mentioned in /etc/sysconfig/storage */ + mutable scoped_ptr > _requiredFilesystemsPtr; }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/solver/detail/SATResolver.cc b/zypp/solver/detail/SATResolver.cc index a2629bb..390c88f 100644 --- a/zypp/solver/detail/SATResolver.cc +++ b/zypp/solver/detail/SATResolver.cc @@ -442,7 +442,7 @@ SATResolver::solving(const CapabilitySet & requires_caps, _solv->distupgrade = _distupgrade; _solv->distupgrade_removeunsupported = _distupgrade_removeunsupported; - sat::Pool::instance().prepare(); + sat::Pool::instance().prepareForSolving(); // Solve ! MIL << "Starting solving...." << endl; @@ -826,7 +826,7 @@ void SATResolver::doUpdate() _solv->distupgrade = _distupgrade; _solv->distupgrade_removeunsupported = _distupgrade_removeunsupported; - sat::Pool::instance().prepare(); + sat::Pool::instance().prepareForSolving(); // Solve ! MIL << "Starting solving for update...." << endl; -- 2.7.4