Added Target::release(), returning the targets distribution release string.
authorMichael Andres <ma@suse.de>
Mon, 21 Apr 2008 13:39:45 +0000 (13:39 +0000)
committerMichael Andres <ma@suse.de>
Mon, 21 Apr 2008 13:39:45 +0000 (13:39 +0000)
devel/devel.ma/NewPool.cc
package/libzypp.changes
zypp/Target.cc
zypp/Target.h
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index a24e2aa..53e0643 100644 (file)
@@ -597,6 +597,7 @@ try {
     {
       getZYpp()->initializeTarget( sysRoot );
       getZYpp()->target()->load();
+      SEC << getZYpp()->target()->release() << endl;
     }
   }
 
@@ -613,29 +614,8 @@ try {
   ///////////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////////
 
-  if ( !pool.empty() )
-  {
-    PoolItem pi ( getPi<Package>( "aspell" ) );
-    MIL << pi << endl;
-    if ( pi )
-    {
-      pi.status().setTransact( true, ResStatus::USER );
-      solve();
-      vdumpPoolStats( USR << "Transacting:"<< endl,
-                      make_filter_begin<resfilter::ByTransact>(pool),
-                      make_filter_end<resfilter::ByTransact>(pool) ) << endl;
-      install();
-    }
-
-  }
-
-  ///////////////////////////////////////////////////////////////////
-  INT << "===[END]============================================" << endl << endl;
-  zypp::base::LogControl::instance().logNothing();
-  return 0;
-
   if ( 0 ) {
-    Measure x( "PROCXY" );
+    Measure x( "PROXY" );
     pool.proxy();
   }
 
index ba464c5..59b3ab1 100644 (file)
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Mon Apr 21 15:38:10 CEST 2008 - ma@suse.de
+
+- Added Target::release(), returning the targets distribution 
+  release string. 
+- revision 9761
+
+-------------------------------------------------------------------
 Sat Apr 19 01:08:04 CEST 2008 - ma@suse.de
 
 - per default abort if package installation fails. (bnc #381203)
index 9b8ae43..3d480dc 100644 (file)
@@ -94,6 +94,9 @@ namespace zypp
   Date Target::timestamp() const
   { return _pimpl->timestamp(); }
 
+  std::string Target::release() const
+  { return _pimpl->release(); }
+
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
index 53129f5..c6f2cad 100644 (file)
@@ -98,6 +98,13 @@ namespace zypp
     /** return the last modification date of the target */
     Date timestamp() const;
 
+    /** The targets distribution release string.
+     * \code
+     *   openSUSE 10.3 (i586)
+     * \endcode
+    */
+    std::string release() const;
+
   public:
     /** Ctor. If \c doRebuild_r is \c true, an already existing
      * database is rebuilt (rpm --rebuilddb ).
index ceba8fa..af0100c 100644 (file)
@@ -10,6 +10,7 @@
  *
 */
 #include <iostream>
+#include <fstream>
 #include <sstream>
 #include <string>
 #include <list>
@@ -22,6 +23,7 @@
 #include "zypp/base/Exception.h"
 #include "zypp/base/Iterator.h"
 #include "zypp/base/Gettext.h"
+#include "zypp/base/IOStream.h"
 #include "zypp/base/UserRequestException.h"
 
 #include "zypp/ZConfig.h"
@@ -793,6 +795,19 @@ namespace zypp
       return _rpm.timestamp();
     }
 
+    std::string TargetImpl::release() const
+    {
+      std::ifstream suseRelease( (_root / "/etc/SuSE-release").c_str() );
+      for( iostr::EachLine in( suseRelease ); in; in.next() )
+      {
+        std::string line( str::trim( *in ) );
+        if ( ! line.empty() )
+          return line;
+      }
+
+      return _("Unknown Distribution");
+    }
+
     void TargetImpl::installSrcPackage( const SrcPackage_constPtr & srcPackage_r )
     {
       // provide on local disk
index 826716c..2cfe587 100644 (file)
@@ -137,6 +137,13 @@ namespace zypp
       /** return the last modification date of the target */
       Date timestamp() const;
 
+      /** The targets distribution release string.
+       * \code
+       *   openSUSE 10.3 (i586)
+       * \endcode
+       */
+      std::string release() const;
+
     protected:
       /** Path to the target */
       Pathname _root;