Add Target::requestedLocales retriever
authorMichael Andres <ma@suse.de>
Thu, 20 Oct 2011 13:58:46 +0000 (15:58 +0200)
committerMichael Andres <ma@suse.de>
Fri, 21 Oct 2011 09:51:17 +0000 (11:51 +0200)
zypp/Target.cc
zypp/Target.h
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index d4f965a..c4707a8 100644 (file)
@@ -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 )
index bc68445..e07f5b8 100644 (file)
@@ -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.
      *
index b286f20..e72bc75 100644 (file)
@@ -1615,21 +1615,6 @@ namespace zypp
     }
 
     ///////////////////////////////////////////////////////////////////
-
-    Product::constPtr TargetImpl::baseProduct() const
-    {
-      ResPool pool(ResPool::instance());
-      for_( it, pool.byKindBegin<Product>(), pool.byKindEnd<Product>() )
-      {
-        Product::constPtr p = (*it)->asKind<Product>();
-        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<Product>(), pool.byKindEnd<Product>() )
+      {
+        Product::constPtr p = (*it)->asKind<Product>();
+        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
index 189b9fc..f771607 100644 (file)
@@ -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;