- Fix computation of Product::flavor.
authorMichael Andres <ma@suse.de>
Fri, 26 Sep 2008 13:39:39 +0000 (13:39 +0000)
committerMichael Andres <ma@suse.de>
Fri, 26 Sep 2008 13:39:39 +0000 (13:39 +0000)
- Add Product::productLine. A vendor specific string denoting the
  product line.

VERSION.cmake
devel/devel.ma/NewPool.cc
package/libzypp.changes
zypp/Product.cc
zypp/Product.h
zypp/sat/SolvAttr.cc
zypp/sat/SolvAttr.h

index 43e5419..fafe047 100644 (file)
@@ -63,6 +63,6 @@ SET(LIBZYPP_COMPATMINOR "13")
 SET(LIBZYPP_MINOR "13")
 SET(LIBZYPP_PATCH "0")
 #
-# LAST RELEASED: 5.12.0 (12)
+# LAST RELEASED: 5.13.0 (13)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index 239d133..e0812b9 100644 (file)
@@ -443,6 +443,23 @@ try {
   INT << "===[START]==========================================" << endl;
   ZConfig::instance();
 
+  {
+  Capability cap("flavor(dvd9)");
+  DBG << cap.detail().isSimple() << endl;
+  DBG << cap.detail().isNamed() << endl;
+  DBG << cap.detail().name() << endl;
+  std::string capstr = str::stripPrefix( cap.asString(), "flavor(" );
+  DBG << capstr << endl;
+  capstr.erase(capstr.size()-1);
+  DBG << capstr << endl;
+  }
+
+
+  ///////////////////////////////////////////////////////////////////
+  INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
+  return 0;
+
 #if 0
 
   RepoManager repoManager( makeRepoManager( sysRoot ) );
@@ -504,7 +521,6 @@ try {
       getZYpp()->target()->load();
       USR << getZYpp()->target()->targetDistribution() << endl;
       USR << getZYpp()->target()->targetDistributionRelease() << endl;
-      USR << getZYpp()->target()->targetDistributionFlavor() << endl;
     }
   }
 
@@ -616,10 +632,10 @@ try {
 
   PoolItem pi ( getPi<Package>("amarok") );
   MIL << pi << endl;
-  MIL << pi->as<Package>() << endl;
-  MIL << pi->as<Product>() << endl;
+  MIL << pi->asKind<Package>() << endl;
+  MIL << pi->asKind<Product>() << endl;
   if ( pi->isKind<Package>() )
-    SEC << pi->as<Package>() << endl;
+    SEC << pi->asKind<Package>() << endl;
 
  //////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
index 5283cbc..bc366e5 100644 (file)
@@ -1,4 +1,13 @@
 -------------------------------------------------------------------
+Fri Sep 26 15:37:50 CEST 2008 - ma@suse.de
+
+- Fix computation of Product::flavor.
+- Add Product::productLine. A vendor specific string denoting the 
+  product line.
+- revision 11182
+- version 5.13.0 (13)
+
+-------------------------------------------------------------------
 Thu Sep 25 23:19:55 CEST 2008 - jkupec@suse.cz
 
 - ZConfig::credentialsGlobal{File,Dir}() added
index d9a3168..642cc6d 100644 (file)
@@ -114,17 +114,48 @@ namespace zypp
       if ( (*it).buddy().isKind( ResKind::product ) )
         ret.push_back( make<Product>( (*it).buddy() ) );
     }
-
     return ret;
   }
 
+  std::string Product::productLine() const
+  {
+#warning productLine needs to be implemented.
+    return std::string();
+  }
+
   ///////////////////////////////////////////////////////////////////
 
   std::string Product::shortName() const
   { return lookupStrAttribute( sat::SolvAttr::productShortlabel ); }
 
   std::string Product::flavor() const
-  { return lookupStrAttribute( sat::SolvAttr::productFlavor ); }
+  {
+    // Look for a  provider of 'product_flavor(name) = version'
+    // within the same repo. Unlike the reference package, we
+    // can be relaxed and ignore the architecture.
+    Capability identCap( str::form( "product_flavor(%s) = %s", name().c_str(), edition().c_str() ) );
+
+    sat::WhatProvides providers( identCap );
+    for_( it, providers.begin(), providers.end() )
+    {
+      if ( it->repository() == repository() )
+      {
+        // Got the package now try to get the provided 'flavor(...)'
+        Capabilities provides( it->provides() );
+        for_( cap, provides.begin(), provides.end() )
+        {
+          std::string capstr( cap.asString() );
+          if ( str::hasPrefix( capstr, "flavor(" ) )
+          {
+            capstr = str::stripPrefix( capstr, "flavor(" );
+            capstr.erase( capstr.size()-1 ); // trailing ')'
+            return capstr;
+          }
+        }
+      }
+    }
+    return std::string();
+  }
 
   std::string Product::type() const
   { return lookupStrAttribute( sat::SolvAttr::productType ); }
@@ -162,7 +193,6 @@ namespace zypp
         /* safety checks, shouldn't happen (tm) */
         if (url_type_it == url_type.end())
         {
-            /* FIXME: Raise exception ?! */
             ERR << *this << " : The thing that should not happen, happened." << endl;
             break;
         }
index 3bb0610..093ed0a 100644 (file)
@@ -52,6 +52,9 @@ namespace zypp
      */
     ReplacedProducts replacedProducts() const;
 
+    /** Vendor specific string denoting the product line. */
+    std::string productLine() const;
+
   public:
     /** Untranslated short name like <tt>SLES 10</tt>*/
     std::string shortName() const;
index 394ea44..09641a0 100644 (file)
@@ -103,19 +103,18 @@ namespace sat
   const SolvAttr SolvAttr::productDistversion    ( PRODUCT_DISTVERSION );
   const SolvAttr SolvAttr::productType           ( PRODUCT_TYPE );
   const SolvAttr SolvAttr::productFlags          ( PRODUCT_FLAGS );
-  const SolvAttr SolvAttr::productFlavor         ( PRODUCT_FLAVOR );
   const SolvAttr SolvAttr::productUpdaterepoKey  ( PRODUCT_UPDATEREPOKEY );
   const SolvAttr SolvAttr::productRegisterTarget ( PRODUCT_REGISTER_TARGET );
   const SolvAttr SolvAttr::productRegisterRelease( PRODUCT_REGISTER_RELEASE );
-  const SolvAttr SolvAttr::productUrl( PRODUCT_URL );
-  const SolvAttr SolvAttr::productUrlType( PRODUCT_URL_TYPE );
+  const SolvAttr SolvAttr::productUrl            ( PRODUCT_URL );
+  const SolvAttr SolvAttr::productUrlType        ( PRODUCT_URL_TYPE );
 
   // repository
   const SolvAttr SolvAttr::repositoryTimestamp ( REPOSITORY_TIMESTAMP );
-  const SolvAttr SolvAttr::repositoryExpire ( REPOSITORY_EXPIRE );
-  const SolvAttr SolvAttr::repositoryUpdates ( REPOSITORY_UPDATES );
-  const SolvAttr SolvAttr::repositoryProducts ( REPOSITORY_PRODUCTS );
-  const SolvAttr SolvAttr::repositoryKeywords ( REPOSITORY_KEYWORDS );
+  const SolvAttr SolvAttr::repositoryExpire    ( REPOSITORY_EXPIRE );
+  const SolvAttr SolvAttr::repositoryUpdates   ( REPOSITORY_UPDATES );
+  const SolvAttr SolvAttr::repositoryProducts  ( REPOSITORY_PRODUCTS );
+  const SolvAttr SolvAttr::repositoryKeywords  ( REPOSITORY_KEYWORDS );
 
 } // namespace sat
   /////////////////////////////////////////////////////////////////
index 616f117..8a8405f 100644 (file)
@@ -128,7 +128,6 @@ namespace sat
       static const SolvAttr productDistversion;
       static const SolvAttr productType;
       static const SolvAttr productFlags;
-      static const SolvAttr productFlavor;
       static const SolvAttr productUpdaterepoKey;
       static const SolvAttr productRegisterTarget;
       static const SolvAttr productRegisterRelease;