backup
authorMichael Andres <ma@suse.de>
Thu, 3 May 2007 22:31:57 +0000 (22:31 +0000)
committerMichael Andres <ma@suse.de>
Thu, 3 May 2007 22:31:57 +0000 (22:31 +0000)
devel/devel.ma/CMakeLists.txt
devel/devel.ma/Parse.cc
zypp/base/Exception.h
zypp2/cache/CacheInitializer.cpp
zypp2/cache/CacheStore.h

index 7e3706b..737c951 100644 (file)
@@ -29,7 +29,7 @@ ADD_CUSTOM_TARGET( ma_test
 
 ## ############################################################
 
-FOREACH( loop_var ScanSource Iorder Parse Xml Main)
+FOREACH( loop_var ScanSource Iorder Xml Main)
    ADD_EXECUTABLE( ${loop_var}
       ${loop_var}.cc
    )
@@ -39,13 +39,12 @@ FOREACH( loop_var ScanSource Iorder Parse Xml Main)
 ENDFOREACH( loop_var )
 
 
-FOREACH( loop_var AOUT )
+FOREACH( loop_var AOUT Parse)
    ADD_EXECUTABLE( ${loop_var}
       ${loop_var}.cc
    )
    TARGET_LINK_LIBRARIES( ${loop_var}
-      boost_filesystem boost_regex
-      zypp
+      zypp zypp2
    )
 ENDFOREACH( loop_var )
 
index 8757d6b..a885382 100644 (file)
@@ -152,6 +152,8 @@ namespace zypp
 
 using namespace zypp::parser::susetags;
 
+#include "zypp2/cache/CacheStore.h"
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -162,6 +164,45 @@ int main( int argc, char * argv[] )
   //zypp::base::LogControl::instance().logfile( "log.restrict" );
   INT << "===[START]==========================================" << endl;
 
+  //try
+  {
+    //cache::CacheStore( "./store" );
+    cache::CacheStore( "/home/ma/zypp-trunk/BUILD/libzypp/devel/devel.ma/store" );
+  }
+
+#if 0
+    try
+    {
+      ZYpp::Ptr z = getZYpp();
+
+      Pathname dbfile( "data.db" );
+      cache::CacheStore store(getenv("PWD"));
+
+      data::RecordId catalog_id = store.lookupOrAppendCatalog( Url("http://www.google.com"), "/");
+
+      PackagesParser parser( catalog_id, store);
+      Measure m;
+      parser.start(argv[1], &progress_function);
+      m.elapsed();
+    }
+    catch ( const Exception &e )
+    {
+      cout << "ups! " << e.msg() << std::endl;
+    }
+#endif
+
+  INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
+  return 0;
+
+
+
+
+
+
+
+
+
   //Pathname p( "lmd/suse/setup/descr/packages" );
   Pathname p( "packages" );
 
index e99f079..f546604 100644 (file)
@@ -53,7 +53,8 @@ namespace zypp
     ///////////////////////////////////////////////////////////////////
 
     /** Create CodeLocation object storing the current location. */
-    #define ZYPP_EX_CODELOCATION ::zypp::exception_detail::CodeLocation(__FILE__,__FUNCTION__,__LINE__)
+    //#define ZYPP_EX_CODELOCATION ::zypp::exception_detail::CodeLocation(__FILE__,__FUNCTION__,__LINE__)
+#define ZYPP_EX_CODELOCATION ::zypp::exception_detail::CodeLocation(( *__FILE__ == '/' ? strrchr( __FILE__, '/' ) + 1 : __FILE__ ),__FUNCTION__,__LINE__)
 
     /** \relates CodeLocation Stream output */
     std::ostream & operator<<( std::ostream & str, const CodeLocation & obj );
index 30c1580..889909d 100644 (file)
@@ -32,7 +32,7 @@ namespace zypp
 ///////////////////////////////////////////////////////////////////
 namespace cache
 { /////////////////////////////////////////////////////////////////
-  
+
 struct CacheInitializer::Impl
 {
   Impl( const Pathname &root_r )
@@ -44,7 +44,7 @@ struct CacheInitializer::Impl
   Pathname root;
   bool just_initialized;
 };
-  
+
 CacheInitializer::CacheInitializer( const Pathname &root_r, const Pathname &db_file )
   : _pimpl( new Impl( root_r ) )
 {
@@ -56,7 +56,7 @@ CacheInitializer::CacheInitializer( const Pathname &root_r, const Pathname &db_f
   {
     ZYPP_RETHROW(Exception(ex.what()));
     //ERR << "Exception Occured: " << ex.what() << endl;
-  } 
+  }
 
   try
   {
@@ -77,7 +77,7 @@ CacheInitializer::CacheInitializer( const Pathname &root_r, const Pathname &db_f
     ZYPP_RETHROW(Exception(ex.what()));
     //ERR << "Exception Occured: " << ex.what() << endl;
   }
-  
+
 }
 
 bool CacheInitializer::justInitialized() const
@@ -87,7 +87,7 @@ bool CacheInitializer::justInitialized() const
 
 CacheInitializer::~CacheInitializer()
 {
+
 }
 
 bool CacheInitializer::tablesCreated() const
@@ -119,9 +119,9 @@ void CacheInitializer::createTables()
     }
     else
     {
-      ZYPP_THROW(Exception("Can't open db schema"));
+      ZYPP_THROW(Exception(str::form("Can't open db schema %s", filename)));
     }
-    
+
     //ERR << "Executing " << statements[i] << endl;
     MIL << "Schema size: " << sql.size() << endl;
     _pimpl->con->execute(sql.c_str());
index 12b3a8a..38ffca4 100644 (file)
@@ -32,35 +32,35 @@ namespace zypp
   ///////////////////////////////////////////////////////////////////
   namespace cache
   { /////////////////////////////////////////////////////////////////
-        
+
     /**
      * The cache store caches resolvable data into some backend.
     */
     class CacheStore
     {
     public:
-      
+
       CacheStore();
       ~CacheStore();
-      
+
       /**
        * Constructor for the CacheStore
        *
        * \note a transaction will be started from the moment the
        * CacheStore is instanciated.
-       * 
+       *
        * The data will be saved in the directory specified in
        * \a dbdir
        */
       CacheStore( const Pathname &dbdir );
-      
+
       /**
        * Implements the ResolvableConsumer consumePackage interface
        * Consumer a package and inserts it into the database.
        * Don't use this method yet
       */
       virtual void consumePackage( const data::Package &package);
-      
+
       /**
        * Appends a resolvable to the store.
        *
@@ -68,11 +68,11 @@ namespace zypp
        * and its \c NVRA (name version release and architecture ).
        * Optionaly you can pass a list of \c CapabilityImpl::Ptr
        * as dependencies for the resolvable.
-       * 
+       *
        * You have to specify the RecordId for the catalog owning
        * this resolvable. Yuu can obtain it with
        * \ref lookupOrAppendCatalog
-       * 
+       *
        * You can create those \a deps using \ref capability::parse
        * functions, or the build methods to create specific types
        * of capabilities:
@@ -89,7 +89,7 @@ namespace zypp
                                        const Resolvable::Kind &kind,
                                        const NVRA &nvra,
                                        const data::Dependencies &deps );
-      
+
       /**
        * Adds dependencies to the store
        *
@@ -103,30 +103,30 @@ namespace zypp
        */
       void appendDependencies( const data::RecordId &resolvable_id,
                                const data::Dependencies &dependencies );
-      
+
       /**
        * Adds dependencies to the store
        *
        * A lists of dependencies \a dlist to be specified. Among
        * which type of dependencies \ref zypp::Dep it is as
        * the \a deptype argument.
-       * 
+       *
        * \a resolvable_id is the resolvable Id in the CacheStore
        * that will own those capabilities.
        *
        * FIXME should it \throw if the resolvable does not exist?
        */
-      void appendDependencyList( const data::RecordId &resolvable_id, 
+      void appendDependencyList( const data::RecordId &resolvable_id,
                                  zypp::Dep deptype,
                                  const data::DependencyList &dlist );
-      
+
       /**
        * Adds a dependency to the store.
        *
-       * A \ref CapabilityImpl::Ptr argument \a cap has to be specified. 
+       * A \ref CapabilityImpl::Ptr argument \a cap has to be specified.
        * Among which type of dependency \ref zypp::Dep it is as
        * the \a deptype argument.
-       * 
+       *
        * \a resolvable_id is the resolvable Id in the CacheStore
        * that will own the capability
        *
@@ -135,14 +135,14 @@ namespace zypp
       void appendDependency( const data::RecordId &resolvable_id,
                              zypp::Dep deptype,
                              capability::CapabilityImpl::Ptr cap );
-      
+
       /**
        * Adds a Named dependency to the store.
        *
        * A \ref NamedCap::Ptr \a dlist to be specified. Among
        * which type of dependency \ref zypp::Dep it is as
        * the \a deptype argument.
-       * 
+       *
        * \a resolvable_id is the resolvable Id in the CacheStore
        * that will own the capability
        *
@@ -153,14 +153,14 @@ namespace zypp
        */
       void appendNamedDependency( const data::RecordId &, zypp::Dep,
                                   capability::NamedCap::Ptr);
-      
+
       /**
        * Adds a file dependency to the store.
        *
        * A \ref FileCap::Ptr \a dlist to be specified. Among
        * which type of dependency \ref zypp::Dep it is as
        * the \a deptype argument.
-       * 
+       *
        * \a resolvable_id is the resolvable Id in the CacheStore
        * that will own the capability
        *
@@ -169,16 +169,16 @@ namespace zypp
        *
        * FIXME should it \throw if the resolvable does not exist?
        */
-      void appendFileDependency( const data::RecordId &, zypp::Dep, 
+      void appendFileDependency( const data::RecordId &, zypp::Dep,
                                  capability::FileCap::Ptr);
-      
+
       /**
        * Adds a Modalias dependency to the store.
        *
        * A \ref ModaliasCap::Ptr \a cap to be specified. Among
        * which type of dependency \ref zypp::Dep it is as
        * the \a deptype argument.
-       * 
+       *
        * \a resolvable_id is the resolvable Id in the CacheStore
        * that will own the capability
        *
@@ -190,14 +190,14 @@ namespace zypp
       void appendModaliasDependency( const data::RecordId &resolvable_id,
                                      zypp::Dep deptype,
                                      capability::ModaliasCap::Ptr cap);
-      
+
       /**
        * Adds a Hal dependency to the store.
        *
        * A \ref HalCap::Ptr \a cap to be specified. Among
        * which type of dependency \ref zypp::Dep it is as
        * the \a deptype argument.
-       * 
+       *
        * \a resolvable_id is the resolvable Id in the CacheStore
        * that will own the capability
        *
@@ -209,14 +209,14 @@ namespace zypp
       void appendHalDependency( const data::RecordId &resolvable_id,
                                       zypp::Dep deptype,
                                       capability::HalCap::Ptr cap );
-      
+
       /**
        * Adds a unknown dependency to the store.
        *
        * A \ref Capability::Ptr \a cap to be specified. Among
        * which type of dependency \ref zypp::Dep it is as
        * the \a deptype argument.
-       * 
+       *
        * \a resolvable_id is the resolvable Id in the CacheStore
        * that will own the capability
        *
@@ -228,7 +228,7 @@ namespace zypp
       void appendUnknownDependency( const data::RecordId &resolvable_id,
                                           zypp::Dep deptype,
                                           capability::CapabilityImpl::Ptr cap );
-      
+
       /**
        * Returns the record id of a catalog (Source) \a path
        *
@@ -236,9 +236,9 @@ namespace zypp
        * be created and the new inserted entry's id will
        * be returned.
        */
-      data::RecordId lookupOrAppendCatalog( const Url &url, 
+      data::RecordId lookupOrAppendCatalog( const Url &url,
                                             const Pathname &path );
-      
+
        /**
        * Update a known catalog checksum and timestamp
        *
@@ -249,10 +249,10 @@ namespace zypp
        * a valid record id. You can get one
        * Using \ref lookupOrAppendCatalog
        */
-      void updateCatalog( const data::RecordId &id, 
-                                    const std::string &checksum, 
+      void updateCatalog( const data::RecordId &id,
+                                    const std::string &checksum,
                                     const Date &timestamp = Date::now() );
-      
+
       /**
        * Returns the record id of a file entry \a path
        *
@@ -261,7 +261,7 @@ namespace zypp
        * be returned.
        */
       data::RecordId lookupOrAppendFile( const Pathname &path );
-      
+
       /**
        * Returns the record id of a name entry \a name
        *
@@ -270,7 +270,7 @@ namespace zypp
        * be returned.
        */
       data::RecordId lookupOrAppendName( const std::string &name );
-      
+
       /**
        * Returns the record id of a directory name  entry \a name
        *
@@ -279,7 +279,7 @@ namespace zypp
        * be returned.
        */
       data::RecordId lookupOrAppendDirName( const std::string &name );
-      
+
       /**
        * Returns the record id of a file name entry \a name
        *
@@ -288,16 +288,16 @@ namespace zypp
        * be returned.
        */
       data::RecordId lookupOrAppendFileName( const std::string &name );
-      
+
     protected:
       /**
        * Internally used function that appends a entry in
        * the capabilities table for a specific capability
        * entry.
        */
-//       data::RecordId appendDependencyEntry( const data::RecordId &, 
+//       data::RecordId appendDependencyEntry( const data::RecordId &,
 //                                             zypp::Dep, const Resolvable::Kind & );
-      
+
     private:
       /** Implementation. */
       class Impl;