backup
authorMichael Andres <ma@suse.de>
Tue, 30 Mar 2010 13:29:39 +0000 (15:29 +0200)
committerMichael Andres <ma@suse.de>
Tue, 30 Mar 2010 13:31:15 +0000 (15:31 +0200)
devel/devel.ma/Main.cc
devel/devel.ma/Xml.cc
zypp/RepoInfo.h

index 57b989d..329e6ce 100644 (file)
@@ -9,6 +9,7 @@
 ///////////////////////////////////////////////////////////////////
 
 //static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" );
+//static const Pathname sysRoot( "/tmp/ToolScanRepos" );
 static const Pathname sysRoot( "/" );
 
 ///////////////////////////////////////////////////////////////////
@@ -58,6 +59,12 @@ namespace zypp
   }
 }
 
+std::ostream & operator<<( std::ostream & str, const sat::Solvable::SplitIdent & obj )
+{
+  str << "{" << obj.ident() << "}{" << obj.kind() << "}{" << obj.name () << "}" << endl;
+  return str;
+}
+
 int main( int argc, char * argv[] )
 try {
   --argc;
@@ -65,79 +72,24 @@ try {
   zypp::base::LogControl::instance().logToStdErr();
   INT << "===[START]==========================================" << endl;
   ///////////////////////////////////////////////////////////////////
-
-
-  DBG << Pathname("a\\b") << endl;
-  DBG << Pathname(".\\a/") << endl;
-  DBG << Pathname("/a\\b/c") << endl;
-
-  INT << "===[END]============================================" << endl << endl;
-  zypp::base::LogControl::instance().logNothing();
-  return 0;
-
-  ::unsetenv( "ZYPP_CONF" );
-  ZConfig::instance();
+  if ( sysRoot == "/" )
+    ::unsetenv( "ZYPP_CONF" );
+  ZConfig::instance().setTextLocale( Locale("de_DE") );
   ResPool   pool( ResPool::instance() );
   sat::Pool satpool( sat::Pool::instance() );
   ///////////////////////////////////////////////////////////////////
-  dumpRange( WAR, satpool.multiversionBegin(), satpool.multiversionEnd() ) << endl;
+  dumpRange( WAR << "satpool.multiversion " , satpool.multiversionBegin(), satpool.multiversionEnd() ) << endl;
   TestSetup::LoadSystemAt( sysRoot, Arch_i586 );
   ///////////////////////////////////////////////////////////////////
 
-  dumpRange( USR, satpool.reposBegin(), satpool.reposEnd() ) << endl;
-  USR << "pool: " << pool << endl;
-
-  dumpRange( WAR, satpool.multiversionBegin(), satpool.multiversionEnd() ) << endl;
-
-  ui::Selectable::Ptr sel( getSel<Package>( "test" ) );
-  WAR << dump( sel ) << endl;
-
-  DBG << sel->setStatus( ui::S_Update, ResStatus::USER ) << endl;
-  WAR << dump( sel ) << endl;
-
-  DBG << sel->setStatus( ui::S_Del, ResStatus::USER ) << endl;
-  WAR << dump( sel ) << endl;
+  ui::Selectable::Ptr s( getSel<Package>( "libzypp" ) );
+  MIL << s << endl;
+  DBG << s->setStatus( ui::S_Taboo ) << endl;
+  DBG << s->setStatus( ui::S_Protected ) << endl;
+  MIL << s << endl;
+  DBG << s->setStatus( ui::S_Update ) << endl;
+  MIL << s << endl;
 
-  DBG << sel->setStatus( ui::S_KeepInstalled, ResStatus::USER ) << endl;
-  WAR << dump( sel ) << endl;
-
-  DBG << sel->pickInstall( *(++++sel->availableBegin()) ) << endl;
-  WAR << dump( sel ) << endl;
-
-  DBG << sel->pickDelete( *(++sel->installedBegin()) ) << endl;
-  WAR << dump( sel ) << endl;
-
-  DBG << sel->pickInstall( *(sel->installedBegin()) ) << endl;
-  WAR << dump( sel ) << endl;
-
-  solve();
-  WAR << dump( sel ) << endl;
-  pool::GetResolvablesToInsDel collect( pool, pool::GetResolvablesToInsDel::ORDER_BY_MEDIANR );
-
-  ///////////////////////////////////////////////////////////////////
-  INT << "===[END]============================================" << endl << endl;
-  zypp::base::LogControl::instance().logNothing();
-       return 0;
-   {
-    PoolQuery q;
-    q.addAttribute( sat::SolvAttr::name, "open" );
-    q.addKind( ResKind::patch );
-    MIL << dump(q) << endl;
-  }
-  {
-    PoolQuery q;
-    q.addAttribute( sat::SolvAttr::name, "patch:yast2-samba-server" );
-    MIL << dump(q) << endl;
-  }
-
-  if ( 0 )
-  {
-    getZYpp()->resolver()->addRequire( Capability("emacs") );
-    solve();
-    vdumpPoolStats( USR << "Transacting:"<< endl,
-                    make_filter_begin<resfilter::ByTransact>(pool),
-                    make_filter_end<resfilter::ByTransact>(pool) ) << endl;
-  }
 
   ///////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
index 717e2cb..170c035 100644 (file)
@@ -1,55 +1,39 @@
-#include "Tools.h"
-
-extern "C"
-{
-#include <libxml/xmlreader.h>
-#include <libxml/xmlerror.h>
-}
 #include <iostream>
-#include <fstream>
 #include <list>
 #include <map>
 #include <set>
 
-#include <boost/call_traits.hpp>
-
-#include <zypp/base/LogControl.h>
 #include <zypp/base/LogTools.h>
+#include <zypp/base/LogControl.h>
+#include <zypp/base/Exception.h>
 
-#include "zypp/base/Exception.h"
-#include "zypp/base/InputStream.h"
-#include "zypp/base/DefaultIntegral.h"
-#include <zypp/base/Function.h>
-#include <zypp/base/Iterator.h>
-#include <zypp/Pathname.h>
-#include <zypp/Edition.h>
-#include <zypp/CheckSum.h>
-#include <zypp/Date.h>
-#include <zypp/Rel.h>
-
-#include "zypp/parser/xml/Reader.h"
+#include <zypp/parser/xml/Reader.h>
+//#include <zypp/parser/xml/ParseDef.h>
+//#include <zypp/parser/xml/ParseDefConsume.h>
 
 using namespace std;
 using namespace zypp;
 
-///////////////////////////////////////////////////////////////////
-
-static const Pathname sysRoot( "/Local/ROOT" );
+#include <zypp/base/Measure.h>
+using zypp::debug::Measure;
 
 ///////////////////////////////////////////////////////////////////
 
-template<class _Cl>
-    void ti( const _Cl & c )
+/** Helper to detect an objects type. */
+template<class _Cl> void ti( const _Cl & c )
 {
   SEC << __PRETTY_FUNCTION__ << endl;
 }
 
-///////////////////////////////////////////////////////////////////
-
-bool dump( xml::Reader & reader_r )
+bool noop( xml::Reader & reader_r )
 {
-  MIL << *reader_r << endl;
+  return true;
 }
+struct Noop
+{
+  bool operator()( xml::Reader & reader_r ) const
+  { return true; }
+};
 
 ///////////////////////////////////////////////////////////////////
 
@@ -83,65 +67,33 @@ bool dumpNode( xml::Reader & reader_r )
 
 ///////////////////////////////////////////////////////////////////
 
-bool dumpEd( xml::Reader & reader_r )
+bool consume( xml::Reader & reader_r )
 {
-  static int num = 5;
-  if ( reader_r->nodeType() == XML_READER_TYPE_ELEMENT
-       && reader_r->name() == "version" )
-    {
-      MIL << *reader_r << endl;
-#define _show(x) DBG << #x << " = " << reader_r->getAttribute( #x ) << endl
-      _show( rel );
-      _show( ver );
-      _show( epoch );
-      WAR << Edition( reader_r->getAttribute( "ver" ).asString(),
-                      reader_r->getAttribute( "rel" ).asString(),
-                      reader_r->getAttribute( "epoch" ).asString() ) << endl;
-      --num;
-    }
-  return num;
-}
-
-///////////////////////////////////////////////////////////////////
-
-template<class _OutputIterator>
-  struct DumpDeps
+  switch ( reader_r->nodeType() )
   {
-    DumpDeps( _OutputIterator result_r )
-    : _result( result_r )
-    {}
-
-    bool operator()( xml::Reader & reader_r )
-    {
-      if ( reader_r->nodeType()     == XML_READER_TYPE_ELEMENT
-           && reader_r->prefix()    == "rpm"
-           && reader_r->localName() == "entry" )
-        {
-          string n( reader_r->getAttribute( "name" ).asString() );
-          Rel op( reader_r->getAttribute( "flags" ).asString() );
-          if ( op != Rel::ANY )
-            {
-              n += " ";
-              n += op.asString();
-              n += " ";
-              n += reader_r->getAttribute( "ver" ).asString();
-              n += "-";
-              n += reader_r->getAttribute( "rel" ).asString();
-            }
-          *_result = n;
-          ++_result;
-        }
-      return true;
-    }
+    case XML_READER_TYPE_ELEMENT:
+      //MIL << *reader_r << endl;
+      for ( int i = 0; i < reader_r->attributeCount(); ++i )
+      {
+       //MIL << " attr no " << i << " '" << reader_r->getAttributeNo( i ) << "'" << endl;
+      }
+      break;
 
-    _OutputIterator _result;
-  };
+    case XML_READER_TYPE_ATTRIBUTE:
+      //WAR << *reader_r << endl;
+      break;
 
-template<class _OutputIterator>
-  DumpDeps<_OutputIterator> dumpDeps( _OutputIterator result_r )
-  { return DumpDeps<_OutputIterator>( result_r ); }
+    case XML_READER_TYPE_TEXT:
+    case XML_READER_TYPE_CDATA:
+      //DBG << *reader_r << endl;
+      break;
 
-///////////////////////////////////////////////////////////////////
+    default:
+      //ERR << *reader_r << endl;
+      break;
+  }
+  return true;
+}
 
 /******************************************************************
 **
@@ -150,45 +102,40 @@ template<class _OutputIterator>
 */
 int main( int argc, char * argv[] )
 {
+  --argc, ++argv;
   INT << "===[START]==========================================" << endl;
 
-  --argc;
-  ++argv;
+  bool verbose( true );
+  Pathname input( "test.xml" );
+  xml::Reader::ProcessNode consumer( consume );
 
-  Pathname repodata;
-  if ( argc )
-    {
-      repodata = *argv;
-    }
-  else
-    {
-      repodata = "/Local/FACTORY/repodata";
-      repodata /= "primary.xml";
-    }
+  if ( argc && !strcmp( *argv, "-q" ) )
+  {
+    --argc, ++argv;
+    verbose = false;
+  }
 
-  if ( 1 )
+  {
+    Measure m( "Parse all" );
+    for ( ; argc; --argc, ++argv )
     {
-      Measure m( "Parse" );
-      xml::Reader reader( repodata );
-
-      switch ( 3 )
+      input = *argv;
+      if( 0 )
+      try {
+       Measure m( input.basename() );
+//     zypp::base::LogControl::TmpLineWriter shutUp;
+       xml::Reader reader( input );
+       if ( verbose )
+         reader.foreachNodeOrAttribute( consumer );
+       else
+         reader.foreachNode( consumer );
+      }
+      catch ( const Exception & exp )
       {
-       case 1:
-         reader.foreachNode( dumpNode );
-         break;
-       case 2:
-         reader.foreachNodeOrAttribute( dumpNode );
-         break;
-       case 3:
-         reader.foreachNode( dumpEd );
-         break;
-
-       default:
-         WAR << "NOP" << endl;
-         break;
+       INT << exp << endl << exp.historyAsString();
       }
     }
-
+  }
   INT << "===[END]============================================" << endl << endl;
   return 0;
 }
index 37c4526..e832d4c 100644 (file)
@@ -150,7 +150,7 @@ namespace zypp
        * located at the root of the media it is important to know the path
        * to the product directory relative to the media root. So a media
        * verifier can be set for that media. You may also read it as
-       * <tt>baseUrl = url to mount</tt> and <tt>path = path on the 
+       * <tt>baseUrl = url to mount</tt> and <tt>path = path on the
        * mounted media</tt>.
        *
        * It is not mandatory, and the default is \c /.
@@ -313,9 +313,17 @@ namespace zypp
       /** Return the locales the license is available for.
        * \ref Locale::noCode is included in case of \c license.txt which does
        * not specify a specific locale.
-      */
+       */
       LocaleSet getLicenseLocales() const;
       //@}
+
+      /** \name Repository global unique id
+       *
+       *
+       */
+      //@{
+      //@}
+
     public:
       /**
        * Write a human-readable representation of this RepoInfo object