zypper port starts. zypp2 to zypp
[platform/upstream/libzypp.git] / devel / devel.ma / Parse.cc
index 6548d54..2556a71 100644 (file)
@@ -29,6 +29,9 @@
 #include "zypp/parser/susetags/ContentFileReader.h"
 #include "zypp/parser/susetags/RepoIndex.h"
 
+#include "zypp/parser/susetags/RepoParser.h"
+#include "zypp/cache/CacheStore.h"
+
 using namespace std;
 using namespace zypp;
 using namespace zypp::functor;
@@ -123,97 +126,15 @@ std::ostream & operator<<( std::ostream & str, const iostr::EachLine & obj )
 
 }
 
-#include "zypp/ProgressData.h"
-#include "zypp2/cache/CacheStore.h"
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  namespace parser
-  { /////////////////////////////////////////////////////////////////
-   ///////////////////////////////////////////////////////////////////
-    namespace susetags
-    { /////////////////////////////////////////////////////////////////
-#if 0
-      class RepoParser
-      {
-       public:
-         RepoParser( const Pathname & reporoot_r, data::RecordId catalogId_r, const Pathname & dbdir_r )
-         : _reporoot( reporoot_r )
-         , _catalogId( catalogId_r )
-         , _store( store_r );
-         {
-           if ( 1 )
-           {
-             std::string file( "content" );
-             Measure x( file );
-
-             ContentFileReader tp;
-
-
-           }
-
-
-           if ( 1 )
-           {
-             std::string file("packages");
-             Measure x( file );
-
-             PackagesFileReader tp;
-             tp.setPkgConsumer   ( bind( &RepoParser::consumePkg, this, _1 ) );
-             tp.setSrcPkgConsumer( bind( &RepoParser::consumeSrcPkg , this, _1 ) );
-             tp.parse(repodescr()/file );
-           }
-         }
-
-
-       public:
-         const Pathname & reporoot() const
-         { return _reporoot; }
-
-         Pathname repodescr() const
-         { return _reporoot/"suse/setup/descr"; }
-
-         Pathname repodata() const
-         { return _reporoot/"suse"; }
-
-       private:
-         void consumePkg( const data::Package_Ptr & pkg_r )
-         {
-            MIL << "[Pkg]" << pkg_r << endl;
-         }
-
-         void consumeSrcPkg( const data::SrcPackage_Ptr & pkg_r )
-         {
-            //DBG << "[Src]" << pkg_r << endl;
-         }
-
-         void consumePat( const data::Pattern_Ptr & pat_r )
-         {
-           MIL << "[Pat]" << pat_r << endl;
-         }
-       public:
-         Pathname          _reporoot;
-         data::RecordId    _catalogId;
-         cache::CacheStore _store;
-
-      };
-
-#endif
-
-      /////////////////////////////////////////////////////////////////
-    } // namespace susetags
-    ///////////////////////////////////////////////////////////////////
-    /////////////////////////////////////////////////////////////////
-  } // namespace parser
-  ///////////////////////////////////////////////////////////////////
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
 
 using namespace zypp::parser::susetags;
-#include "zypp2/cache/CacheStore.h"
+#include "zypp/cache/CacheStore.h"
 
 void consumeIndex( const parser::susetags::RepoIndex_Ptr & index_r )
 {
@@ -266,6 +187,7 @@ void pPattern( const Pathname & p )
   tp.setConsumer( consumePat );
   tp.parse( p );
 }
+
  /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -276,9 +198,22 @@ int main( int argc, char * argv[] )
   //zypp::base::LogControl::instance().logfile( "log.restrict" );
   INT << "===[START]==========================================" << endl;
 
-  Pathname p( "lmd/content" );
+  Pathname dbdir( "store" );
+  Pathname reporoot( "lmd" );
 
-  Measure x( p.basename() );
+  cache::CacheStore store( dbdir );
+  data::RecordId repositoryId = store.lookupOrAppendRepository( Url("dir:///"), "/" );
+  {
+    Measure x( "XXXXXXXXXXXXX" );
+
+    parser::susetags::RepoParser repo( repositoryId, store );
+    repo.parse( reporoot );
+
+    store.commit();
+  }
+
+
+#if 0
   ContentFileReader tp;
   tp.setProductConsumer( consumeProd );
   tp.setRepoIndexConsumer( consumeIndex );
@@ -286,7 +221,6 @@ int main( int argc, char * argv[] )
   tp.parse( p );
 
 
-#if 0
   //try
   {
     //Pathname dbdir( "/Local/ma/zypp-TRUNK/BUILD/libzypp/devel/devel.ma/store" );
@@ -296,9 +230,9 @@ int main( int argc, char * argv[] )
     Pathname metadir( "lmd" );
 
     cache::CacheStore store( dbdir );
-    data::RecordId catalogId = store.lookupOrAppendCatalog( Url("http://www.google.com"), "/" );
+    data::RecordId repositoryId = store.lookupOrAppendRepository( Url("http://www.google.com"), "/" );
 
-    RepoParser( metadir, catalogId, store );
+    RepoParser( metadir, repositoryId, store );
 
   }
 
@@ -309,9 +243,9 @@ int main( int argc, char * argv[] )
       Pathname dbfile( "data.db" );
       cache::CacheStore store(getenv("PWD"));
 
-      data::RecordId catalog_id = store.lookupOrAppendCatalog( Url("http://www.google.com"), "/");
+      data::RecordId repository_id = store.lookupOrAppendRepository( Url("http://www.google.com"), "/");
 
-      PackagesParser parser( catalog_id, store);
+      PackagesParser parser( repository_id, store);
       Measure m;
       parser.start(argv[1], &progress_function);
       m.elapsed();