From f4d1b9e00f0815f8b7c7cccf1f4ef5224f48d58b Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Thu, 20 Oct 2011 15:58:46 +0200 Subject: [PATCH] Add Target::requestedLocales retriever --- zypp/Target.cc | 5 +++++ zypp/Target.h | 9 +++++++++ zypp/target/TargetImpl.cc | 37 ++++++++++++++++++++++--------------- zypp/target/TargetImpl.h | 10 +++++++++- 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/zypp/Target.cc b/zypp/Target.cc index d4f965aad..c4707a8dc 100644 --- a/zypp/Target.cc +++ b/zypp/Target.cc @@ -103,6 +103,11 @@ namespace zypp Product::constPtr Target::baseProduct() const { return _pimpl->baseProduct(); } + LocaleSet Target::requestedLocales() const + { return _pimpl->requestedLocales(); } + LocaleSet Target::requestedLocales( const Pathname & root_r ) + { return target::TargetImpl::requestedLocales( root_r ); } + std::string Target::targetDistribution() const { return _pimpl->targetDistribution(); } std::string Target::targetDistribution( const Pathname & root_r ) diff --git a/zypp/Target.h b/zypp/Target.h index bc6844509..e07f5b81a 100644 --- a/zypp/Target.h +++ b/zypp/Target.h @@ -119,6 +119,15 @@ namespace zypp */ Product::constPtr baseProduct() const; + /** + * \brief Languages to be supported by the system. + * E.g. language specific packages to be installed. + */ + LocaleSet requestedLocales() const; + /** \overload Use a specific root_r, if empty the default targets root, or '/' + */ + static LocaleSet requestedLocales( const Pathname & root_r ); + public: /** \name Base product and registration. * diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index b286f2074..e72bc7506 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -1615,21 +1615,6 @@ namespace zypp } /////////////////////////////////////////////////////////////////// - - Product::constPtr TargetImpl::baseProduct() const - { - ResPool pool(ResPool::instance()); - for_( it, pool.byKindBegin(), pool.byKindEnd() ) - { - Product::constPtr p = (*it)->asKind(); - if ( p->isTargetDistribution() ) - return p; - } - return 0L; - } - - /////////////////////////////////////////////////////////////////// - namespace { parser::ProductFileData baseproductdata( const Pathname & root_r ) @@ -1673,6 +1658,28 @@ namespace zypp } return std::string(); } + } // namescpace + /////////////////////////////////////////////////////////////////// + + Product::constPtr TargetImpl::baseProduct() const + { + ResPool pool(ResPool::instance()); + for_( it, pool.byKindBegin(), pool.byKindEnd() ) + { + Product::constPtr p = (*it)->asKind(); + if ( p->isTargetDistribution() ) + return p; + } + return nullptr; + } + + LocaleSet TargetImpl::requestedLocales( const Pathname & root_r ) + { + const Pathname needroot( staticGuessRoot(root_r) ); + const Target_constPtr target( getZYpp()->getTarget() ); + if ( target && target->root() == needroot ) + return target->requestedLocales(); + return RequestedLocalesFile( home(needroot) / "RequestedLocales" ).locales(); } std::string TargetImpl::targetDistribution() const diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index 189b9fce2..f77160739 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -118,7 +118,10 @@ namespace zypp /** The directory to store things. */ Pathname home() const - { return _root / "/var/lib/zypp"; } + { return home( _root ); } + + static Pathname home( const Pathname & root_r ) + { return root_r / "/var/lib/zypp"; } /** Commit changes in the pool */ ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r ); @@ -150,6 +153,11 @@ namespace zypp /** \copydoc Target::baseProduct() */ Product::constPtr baseProduct() const; + /** \copydoc Target::requestedLocales() */ + LocaleSet requestedLocales() const + { return _requestedLocalesFile.locales(); } + /** \overload */ + static LocaleSet requestedLocales( const Pathname & root_r ); /** \copydoc Target::targetDistribution() */ std::string targetDistribution() const; -- 2.34.1