- Fix evaluation of vendor support flags.
authorMichael Andres <ma@suse.de>
Thu, 11 Sep 2008 12:43:49 +0000 (12:43 +0000)
committerMichael Andres <ma@suse.de>
Thu, 11 Sep 2008 12:43:49 +0000 (12:43 +0000)
- Adapt retrieval of registration data (targetDistribution,
  targetDistributionRelease and targetDistributionFlavor).

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

index b9330e3..cc1cf7a 100644 (file)
@@ -60,7 +60,7 @@
 #
 SET(LIBZYPP_MAJOR "5")
 SET(LIBZYPP_COMPATMINOR "8")
-SET(LIBZYPP_MINOR "9")
+SET(LIBZYPP_MINOR "10")
 SET(LIBZYPP_PATCH "0")
 #
 # LAST RELEASED: 5.9.0 (8)
index e41f7d1..b20a8d5 100644 (file)
@@ -430,6 +430,17 @@ void testCMP( const L & lhs, const R & rhs )
 #undef OUTS
 }
 
+namespace zypp
+{
+  enum TestE {
+    TE1, TE2, TE3
+  };
+
+  inline void fromString( const std::string & str_r, TestE & cl_r )
+  { cl_r = TE1; }
+
+}
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -443,13 +454,11 @@ try {
   INT << "===[START]==========================================" << endl;
   ZConfig::instance();
 
-#if 0
-  ServiceInfo s( "STest", Url("dir:///somewhere") );
-  DBG << s << endl;
-  s.addCatalogToEnable( "foo" );
-  s.addCatalogToEnable( "ba a" );
-  s.addCatalogToEnable( "kaa" );
-  DBG << s << endl;
+
+#if 1
+  DBG << str::fromString<TestE>("te1") << endl;
+
+
 
   ///////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
@@ -470,6 +479,8 @@ try {
       }
       getZYpp()->target()->load();
       USR << getZYpp()->target()->targetDistribution() << endl;
+      USR << getZYpp()->target()->targetDistributionRelease() << endl;
+      USR << getZYpp()->target()->targetDistributionFlavor() << endl;
     }
   }
 
index 8e69998..118f74a 100644 (file)
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Thu Sep 11 14:41:28 CEST 2008 - ma@suse.de
+
+- Fix evaluation of vendor support flags.
+- Adapt retrieval of registration data (targetDistribution, 
+  targetDistributionRelease and targetDistributionFlavor).
+- revision 11013
+
+-------------------------------------------------------------------
 Wed Sep 10 18:23:52 CEST 2008 - ma@suse.de
 
 - Follow gpgcheck tag in .repo file and do no check if disabled.
index 4fb7415..c8ce76e 100644 (file)
@@ -45,14 +45,14 @@ namespace zypp
   VendorSupportOption Package::vendorSupport() const
   {
       Keywords kw(keywords());
-      
+
       for_( it, kw.begin(), kw.end() )
       {
           if ( *it == "support_unsupported")
               return VendorSupportUnsupported;
           if ( *it == "support_acc")
               return VendorSupportACC;
-          
+
           if ( *it == "support_l1")
               return VendorSupportLevel1;
           if ( *it == "support_l2")
@@ -61,27 +61,21 @@ namespace zypp
               return VendorSupportLevel3;
       }
       return VendorSupportUnknown;
-  }  
+  }
 
   bool Package::maybeUnsupported() const
   {
-      return ( vendorSupport() & ( VendorSupportACC | VendorSupportUnsupported | VendorSupportUnknown )  == ( VendorSupportACC | VendorSupportUnsupported | VendorSupportUnknown ) );
+      return ( vendorSupport() & ( VendorSupportACC | VendorSupportUnsupported | VendorSupportUnknown ) );
   }
 
-
   Changelog Package::changelog() const
   {
-      Target_Ptr target;
-      try
+      Target_Ptr target( getZYpp()->getTarget() );
+      if ( ! target )
       {
-          target = getZYpp()->target();
+        ERR << "Target not initialized. Changelog is not available." << std::endl;
+        return Changelog();
       }
-      catch ( const Exception &e )
-      {
-           ERR << "Target not initialized. Changelog is not available." << std::endl;
-           return Changelog();
-      }
-
 
       if ( repository().isSystemRepo() )
       {
index 91613ca..7feaa26 100644 (file)
@@ -103,6 +103,12 @@ namespace zypp
   std::string Target::targetDistribution() const
   { return _pimpl->targetDistribution(); }
 
+  std::string Target::targetDistributionRelease() const
+  { return _pimpl->targetDistributionRelease(); }
+
+  std::string Target::targetDistributionFlavor() const
+  { return _pimpl->targetDistributionFlavor(); }
+
   std::string Target::anonymousUniqueId() const
   { return _pimpl->anonymousUniqueId(); }
 
index 08d75c7..2fbf602 100644 (file)
@@ -107,18 +107,32 @@ namespace zypp
     /** return the last modification date of the target */
     Date timestamp() const;
 
+    /** \name Base product and registration. */
+    //@{
     /** The targets distribution release string (/etc/SuSE-release)
      * \code
      *   openSUSE 10.3 (i586)
      * \endcode
+     * \deprecated \ref targetDistribution might be a better choice as it does not depend on /etc/SuSE-release.
     */
-    std::string release() const;
+    std::string release() const ZYPP_DEPRECATED;
 
-    /** This is "distribution-arch" of the installed base product.
+    /** This is \c register.target attribute of the installed base product.
      * Used for registration and \ref Service refresh.
      */
     std::string targetDistribution() const;
 
+    /** This is \c register.release attribute of the installed base product.
+     * Used for registration.
+     */
+    std::string targetDistributionRelease() const;
+
+    /** This is \c register.flavor attribute of the installed base product.
+     * Used for registration.
+     */
+    std::string targetDistributionFlavor() const;
+    //@}
+
     /**
      * anonymous unique id
      *
index 3cd76eb..d75f1a4 100644 (file)
@@ -864,6 +864,8 @@ namespace zypp
       return _rpm.timestamp();
     }
 
+    ///////////////////////////////////////////////////////////////////
+
     std::string TargetImpl::release() const
     {
       std::ifstream suseRelease( (_root / "/etc/SuSE-release").c_str() );
@@ -877,29 +879,45 @@ namespace zypp
       return _("Unknown Distribution");
     }
 
-    std::string TargetImpl::targetDistribution() const
+    ///////////////////////////////////////////////////////////////////
+
+    namespace
     {
-      std::ostringstream cmd;
-      cmd << "rpmdb2solv";
-      cmd << " -n";
-      if ( ! _root.empty() )
-        cmd << " -r '" << _root << "'";
-      cmd << " -p '" << Pathname::assertprefix( _root, "/etc/products.d" ) << "'";
-      cmd << " -a distribution.target";
-
-      MIL << "Executing: " << cmd << endl;
-      ExternalProgram prog( cmd.str(), ExternalProgram::Discard_Stderr );
-      for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
+      std::string rpmdb2solvAttr( const std::string & attr_r, const Pathname & root_r )
       {
-        return str::trim(output);
-      }
+        std::ostringstream cmd;
+        cmd << "rpmdb2solv";
+        cmd << " -n";
+        if ( ! root_r.empty() )
+          cmd << " -r '" << root_r << "'";
+        cmd << " -p '" << Pathname::assertprefix( root_r, "/etc/products.d" ) << "'";
+        cmd << " -a distribution.target";
+
+        MIL << "Executing: " << cmd << endl;
+        ExternalProgram prog( cmd.str(), ExternalProgram::Discard_Stderr );
+        for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
+        {
+          return str::trim(output);
+        }
 
-      int ret = prog.close();
-      WAR << "Got no output from rpmdb2solv (returned " << ret << ")." << endl;
+        int ret = prog.close();
+        WAR << "Got no output from rpmdb2solv (returned " << ret << ")." << endl;
 
-      return std::string();
+        return std::string();
+      }
     }
 
+    std::string TargetImpl::targetDistribution() const
+    { return rpmdb2solvAttr( "register.target", _root ); }
+
+    std::string TargetImpl::targetDistributionRelease() const
+    { return rpmdb2solvAttr( "register.release", _root ); }
+
+    std::string TargetImpl::targetDistributionFlavor() const
+    { return rpmdb2solvAttr( "register.flavor", _root ); }
+
+    ///////////////////////////////////////////////////////////////////
+
     std::string TargetImpl::anonymousUniqueId() const
     {
         std::ifstream idfile( ( home() / "AnonymousUniqueId" ).c_str() );
@@ -912,6 +930,8 @@ namespace zypp
         return std::string();
     }
 
+    ///////////////////////////////////////////////////////////////////
+
     void TargetImpl::installSrcPackage( const SrcPackage_constPtr & srcPackage_r )
     {
       // provide on local disk
index 1259bec..5dd7843 100644 (file)
@@ -141,17 +141,17 @@ namespace zypp
       /** return the last modification date of the target */
       Date timestamp() const;
 
-      /** The targets distribution release string.
-       * \code
-       *   openSUSE 10.3 (i586)
-       * \endcode
-       */
+      /** \copydoc Target::release() */
       std::string release() const;
 
-    /** This is "distribution-arch" of the installed base product.
-     * Used for registration and \ref Service refresh.
-     */
-    std::string targetDistribution() const;
+      /** \copydoc Target::targetDistribution() */
+      std::string targetDistribution() const;
+
+      /** \copydoc Target::targetDistributionRelease()*/
+      std::string targetDistributionRelease() const;
+
+      /** \copydoc Target::targetDistributionFlavor() */
+      std::string targetDistributionFlavor() const;
 
     protected:
       /** Path to the target */