generating a testcase BEFORE updating the system; compress testcase
authorStefan Schubert <schubi@suse.de>
Thu, 24 Jan 2008 11:01:02 +0000 (11:01 +0000)
committerStefan Schubert <schubi@suse.de>
Thu, 24 Jan 2008 11:01:02 +0000 (11:01 +0000)
zypp/sat/SATResolver.cc
zypp/solver/detail/Resolver.cc
zypp/solver/detail/ResolverUpgrade.cc
zypp/solver/detail/Testcase.cc
zypp/solver/detail/Testcase.h

index 9ecc5e1..e211097 100644 (file)
@@ -33,7 +33,6 @@
 #include "zypp/sat/SATResolver.h"
 #include "zypp/sat/Pool.h"
 #include "zypp/solver/detail/ProblemSolutionCombi.h"
-#include "zypp/solver/detail/Testcase.h"
 
 extern "C" {
 #include "satsolver/repo_solv.h"
@@ -95,8 +94,6 @@ SATResolver::SATResolver (const ResPool & pool, Pool *SATPool)
     , _architecture( zypp_detail::defaultArchitecture() )
 
 {
-    Testcase testcase("/var/log/YaST2/autotestcase");
-    testcase.createTestcasePool (pool); // dump pool to testcase
 }
 
 
index 5ecb39a..106c8d1 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "zypp/solver/detail/Resolver.h"
 #include "zypp/solver/detail/Helper.h"
+#include "zypp/solver/detail/Testcase.h"
 
 #include "zypp/Capabilities.h"
 #include "zypp/base/Logger.h"
@@ -292,6 +293,8 @@ Resolver::resolvePool()
        if ( !_satResolver ) {
            sat::Pool satPool( sat::Pool::instance() );
            _satResolver = new SATResolver(_pool, satPool.get());
+           Testcase testcase("/var/log/YaST/autoTestcase");
+           testcase.createTestcase (*this, true, false); // create pool, do not solver
        }
 #if 0
        MIL << "------SAT-Pool------" << endl;
index d3739ed..63ed449 100644 (file)
@@ -53,6 +53,7 @@
 #include "zypp/solver/detail/Types.h"
 #include "zypp/solver/detail/Helper.h"
 #include "zypp/solver/detail/Resolver.h"
+#include "zypp/solver/detail/Testcase.h"
 #include "zypp/Target.h"
 
 /////////////////////////////////////////////////////////////////////////
@@ -330,6 +331,10 @@ Resolver::doUpgrade( UpgradeStatistics & opt_stats_r )
     << "(keep_installed_patches:" << (opt_stats_r.keep_installed_patches?"yes":"no") << ")"
     << endl;
 
+  // create a testcase for the updating system
+  Testcase testcase("/var/log/updateTestcase");
+  testcase.createTestcase (*this, true, false); // create pool, do not solver  
+
   _update_items.clear();
   {
     UpgradeOptions opts( opt_stats_r );
index 555b65a..a6a6d97 100644 (file)
@@ -203,49 +203,6 @@ Testcase::~Testcase()
 {
 }
 
-bool Testcase::createTestcasePool(const ResPool &pool)
-{
-    PathInfo path (dumpPath);
-
-    if ( !path.isExist() ) {
-       if (zypp::filesystem::mkdir (dumpPath)!=0) {
-           ERR << "Cannot create directory " << dumpPath << endl;
-           return false;
-       }
-    } else {
-       if (!path.isDir()) {
-           ERR << dumpPath << " is not a directory." << endl;
-           return false;
-       }
-       // remove old stuff
-       zypp::filesystem::clean_dir (dumpPath);
-    }
-    
-    RepositoryTable            repoTable;
-    HelixResolvable    system (dumpPath + "/solver-system.xml");    
-
-    for ( ResPool::const_iterator it = pool.begin(); it != pool.end(); ++it )
-    {
-       Resolvable::constPtr res = it->resolvable();
-
-       if ( it->status().isInstalled() ) {
-           // system channel
-           system.addResolvable (*it);
-       } else {
-           // repo channels
-           ResObject::constPtr repoItem = it->resolvable();
-           Repository repo  = repoItem->repository();
-           if (repoTable.find (repo) == repoTable.end()) {
-               repoTable[repo] = new HelixResolvable(dumpPath + "/"
-                                                     + numstring(repo.numericId())
-                                                     + "-package.xml");
-           }
-           repoTable[repo]->addResolvable (*it);
-       }
-    }  
-    return true;
-}
-
 
 bool Testcase::createTestcase(Resolver & resolver, bool dumpPool, bool runSolver)
 {
@@ -367,7 +324,7 @@ bool Testcase::createTestcase(Resolver & resolver, bool dumpPool, bool runSolver
 HelixResolvable::HelixResolvable(const std::string & path)
     :dumpFile (path)    
 {
-    file = new ofstream(path.c_str());
+    file = new ofgzstream(path.c_str());
     if (!file) {
        ZYPP_THROW (Exception( "Can't open " + path ) );
     }
index 818cd30..e21e8b8 100644 (file)
@@ -21,6 +21,7 @@
 #include "zypp/solver/detail/Resolver.h"
 #include "zypp/Capabilities.h"
 #include "zypp/ResPool.h"
+#include "zypp/base/GzStream.h"
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -69,7 +70,7 @@ class  HelixResolvable : public base::ReferenceCounted, private base::NonCopyabl
 
   private:
     std::string dumpFile; // Path of the generated testcase
-    std::ofstream *file;    
+    ofgzstream *file;    
 
   public:
     HelixResolvable (const std::string & path);
@@ -132,8 +133,6 @@ class Testcase {
     ~Testcase ();
 
     bool createTestcase (Resolver & resolver, bool dumpPool = true, bool runSolver = true);
-    bool createTestcasePool(const ResPool &pool);    
-
 };