- Add Target::targetDistribution. Returns "distribution-arch" of
authorMichael Andres <ma@suse.de>
Fri, 15 Aug 2008 18:29:01 +0000 (18:29 +0000)
committerMichael Andres <ma@suse.de>
Fri, 15 Aug 2008 18:29:01 +0000 (18:29 +0000)
  the installed base product. Used for registration and i
  Service refresh. (for Fate #304915)

VERSION.cmake
devel/devel.ma/NewPool.cc
package/libzypp.changes
zypp/Target.cc
zypp/Target.h
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index ff9ed6b..6dd77d5 100644 (file)
@@ -63,6 +63,6 @@ SET(LIBZYPP_COMPATMINOR "5")
 SET(LIBZYPP_MINOR "6")
 SET(LIBZYPP_PATCH "0")
 #
-# LAST RELEASED: 5.5.1 (5)
+# LAST RELEASED: 5.6.0 (5)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index 0efd2db..c6ce7e6 100644 (file)
@@ -529,13 +529,13 @@ try {
   ///////////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////////
 
-  // Pool of Selectables
+  // access to the Pool of Selectables
   ResPoolProxy selectablePool( ResPool::instance().proxy() );
 
   // Iterate it's Products...
   for_( it, selectablePool.byKindBegin<Product>(), selectablePool.byKindEnd<Product>() )
   {
-    // current Product Selectable
+    // The current Product Selectable
     ui::Selectable::Ptr prodSel( *it );
     MIL << dump( prodSel ) << endl;
 
@@ -550,7 +550,7 @@ try {
       // Iterate the replaced Products...
       for_( it, prodReplaces.begin(), prodReplaces.end() )
       {
-        // current replaced Product
+        // The current replaced Product
         Product::constPtr replacedProduct( *it );
         DBG << replacedProduct << endl;
 
index 81d8fd6..545d244 100644 (file)
@@ -1,4 +1,13 @@
 -------------------------------------------------------------------
+Fri Aug 15 20:20:07 CEST 2008 - ma@suse.de
+
+- Add Target::targetDistribution. Returns "distribution-arch" of 
+  the installed base product. Used for registration and Service
+  refresh. (for Fate #304915)
+- revision 10877
+- version 5.6.0 (5)
+
+-------------------------------------------------------------------
 Fri Aug 15 17:42:58 CEST 2008 - ma@suse.de
 
 - Add method Product::replacedProducts to identify installed 
index 90748dd..91613ca 100644 (file)
@@ -100,9 +100,12 @@ namespace zypp
   std::string Target::release() const
   { return _pimpl->release(); }
 
+  std::string Target::targetDistribution() const
+  { return _pimpl->targetDistribution(); }
+
   std::string Target::anonymousUniqueId() const
   { return _pimpl->anonymousUniqueId(); }
-    
+
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
index 8c7f58b..08d75c7 100644 (file)
@@ -107,13 +107,18 @@ namespace zypp
     /** return the last modification date of the target */
     Date timestamp() const;
 
-    /** The targets distribution release string.
+    /** The targets distribution release string (/etc/SuSE-release)
      * \code
      *   openSUSE 10.3 (i586)
      * \endcode
     */
     std::string release() const;
 
+    /** This is "distribution-arch" of the installed base product.
+     * Used for registration and \ref Service refresh.
+     */
+    std::string targetDistribution() const;
+
     /**
      * anonymous unique id
      *
index ae850bf..398362e 100644 (file)
@@ -871,6 +871,30 @@ namespace zypp
       return _("Unknown Distribution");
     }
 
+    std::string TargetImpl::targetDistribution() const
+    {
+      std::ifstream baseProduct( (_root / "/etc/products.d/baseproduct").c_str() );
+      for( iostr::EachLine in( baseProduct ); in; in.next() )
+      {
+        std::string line( str::trim( *in ) );
+        if ( str::hasPrefix( line, "distribution" ) )
+        {
+          std::string::size_type pos( line.find( '=', 12 ) );
+          if ( pos == std::string::npos )
+            continue; // no '=' on line
+          pos = line.find_first_not_of( " \t", pos+1 );
+          if ( pos == std::string::npos )
+            continue; // empty value
+          line.erase( 0, pos );
+          line += "-";
+          line += ZConfig::instance().systemArchitecture().asString();
+          return line;
+        }
+      }
+      WAR << "No distribution in " << PathInfo(_root / "/etc/products.d/baseproduct") << endl;
+      return std::string();
+    }
+
     std::string TargetImpl::anonymousUniqueId() const
     {
         std::ifstream idfile( ( home() / "AnonymousUniqueId" ).c_str() );
index a19ae12..1259bec 100644 (file)
@@ -148,6 +148,11 @@ namespace zypp
        */
       std::string release() const;
 
+    /** This is "distribution-arch" of the installed base product.
+     * Used for registration and \ref Service refresh.
+     */
+    std::string targetDistribution() const;
+
     protected:
       /** Path to the target */
       Pathname _root;