Don't write a solver testcase when solving for dist upgrade, but when actually commit...
authorMichael Andres <ma@suse.de>
Wed, 15 Jul 2009 15:59:56 +0000 (17:59 +0200)
committerMichael Andres <ma@suse.de>
Wed, 15 Jul 2009 15:59:56 +0000 (17:59 +0200)
VERSION.cmake
package/libzypp.changes
zypp/Resolver.cc
zypp/Resolver.h
zypp/solver/detail/ResolverUpgrade.cc
zypp/solver/detail/Testcase.cc
zypp/solver/detail/Testcase.h
zypp/target/TargetImpl.cc

index 8da4290..24d156e 100644 (file)
@@ -63,6 +63,6 @@ SET(LIBZYPP_COMPATMINOR "10")
 SET(LIBZYPP_MINOR "10")
 SET(LIBZYPP_PATCH "3")
 #
-# LAST RELEASED: 6.10.2 (10)
+# LAST RELEASED: 6.10.3 (10)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index 5c1eebe..a61d1f2 100644 (file)
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Wed Jul 15 17:53:43 CEST 2009 - ma@suse.de
+
+- Don't write a solver testcase when solving for dist upgrade, 
+  but when actually committing.
+- version 6.10.3 (10)
+
+-------------------------------------------------------------------
 Wed Jul 15 16:45:39 CEST 2009 - ma@suse.de
 
 - Add new string Match::Mode STRINGSTART and STRINGEND.
index 2cdb175..d974694 100644 (file)
@@ -84,6 +84,8 @@ namespace zypp
   void Resolver::resetOnlyRequires()                   { _pimpl->setOnlyRequires( indeterminate ); }
   bool Resolver::onlyRequires()                                { return _pimpl->onlyRequires(); }
 
+  bool Resolver::upgradeMode() const                   { return _pimpl->isUpgradeMode(); }
+
   void Resolver::setAllowVendorChange( bool yesno_r )  { _pimpl->setAllowVendorChange( yesno_r ); }
   void Resolver::setDefaultAllowVendorChange()         { _pimpl->setAllowVendorChange( indeterminate ); }
   bool Resolver::allowVendorChange() const             { return _pimpl->allowVendorChange(); }
@@ -108,10 +110,10 @@ namespace zypp
   std::list<PoolItem> Resolver::problematicUpdateItems() const
   { return _pimpl->problematicUpdateItems(); }
 
-  bool Resolver::createSolverTestcase( const std::string & dumpPath )
+  bool Resolver::createSolverTestcase( const std::string & dumpPath, bool runSolver )
   {
     solver::detail::Testcase testcase (dumpPath);
-    return testcase.createTestcase(*_pimpl);
+    return testcase.createTestcase(*_pimpl, true, runSolver);
   }
 
   solver::detail::ItemCapKindList Resolver::isInstalledBy( const PoolItem & item )
index 4ebbdd4..d00e5a9 100644 (file)
@@ -179,6 +179,11 @@ namespace zypp
     bool onlyRequires();
 
     /**
+     * Whether the \ref Resolver is in upgrade mode.
+     */
+    bool upgradeMode() const;
+
+    /**
      * Setting whether the solver should allow or disallow vendor changes.
      *
      * If OFF (the default) the solver will replace packages with packages
@@ -254,7 +259,7 @@ namespace zypp
      * \parame dumpPath destination directory of the created directory
      * \return true if it was successful
      */
-    bool createSolverTestcase( const std::string & dumpPath = "/var/log/YaST2/solverTestcase" );
+    bool createSolverTestcase( const std::string & dumpPath = "/var/log/YaST2/solverTestcase", bool runSolver = true );
 
     /**
      * Gives information about WHO has pused an installation of an given item.
index db0f251..ae079b8 100644 (file)
@@ -69,13 +69,7 @@ Resolver::doUpgrade()
   {
     ERR << "Huh, no target ?" << endl;
     return false; // can't continue without target
- }
-
-  // create a testcase for the updating system
-  std::string now( Date::now().form( "-%Y-%m-%d-%H-%M-%S" ) );
-  Pathname path ( target->assertRootPrefix("/var/log/updateTestcase"+now) );
-  Testcase testcase( path.asString() );
-  testcase.createTestcase (*this, true, false); // create pool, do not solve
+  }
 
   // Setting Resolver to upgrade mode. SAT solver will do the update
   _upgradeMode = true;
index ab2607a..41299dc 100644 (file)
@@ -273,7 +273,7 @@ bool Testcase::createTestcase(Resolver & resolver, bool dumpPool, bool runSolver
     PathInfo path (dumpPath);
 
     if ( !path.isExist() ) {
-       if (zypp::filesystem::mkdir (dumpPath)!=0) {
+       if (zypp::filesystem::assert_dir (dumpPath)!=0) {
            ERR << "Cannot create directory " << dumpPath << endl;
            return false;
        }
index eca8dae..dc012c0 100644 (file)
@@ -39,22 +39,22 @@ namespace zypp
 template<class T>
 std::string helixXML( const T &obj ); //undefined
 
-template<> 
+template<>
 std::string helixXML( const Edition &edition );
 
-template<> 
+template<>
 std::string helixXML( const Arch &arch );
 
-template<> 
+template<>
 std::string helixXML( const Capability &cap );
 
-template<> 
+template<>
 std::string helixXML( const Capabilities &caps );
 
-template<> 
+template<>
 std::string helixXML( const CapabilitySet &caps );
 
-template<> 
+template<>
 std::string helixXML( const PoolItem &item );
 
 
@@ -69,7 +69,7 @@ class  HelixResolvable : public base::ReferenceCounted, private base::NonCopyabl
 
   private:
     std::string dumpFile; // Path of the generated testcase
-    ofgzstream *file;    
+    ofgzstream *file;
 
   public:
     HelixResolvable (const std::string & path);
@@ -99,12 +99,12 @@ class  HelixControl {
     HelixControl (const std::string & controlPath,
                  const RepositoryTable & sourceTable,
                  const Arch & systemArchitecture,
-                 const LocaleSet &languages,             
+                 const LocaleSet &languages,
                  const std::string & systemPath = "solver-system.xml.gz",
                  const bool forceResolve = false,
                  const bool onlyRequires = false,
                  const bool ignorealreadyrecommended = false);
-    HelixControl ();    
+    HelixControl ();
     ~HelixControl ();
 
     void installResolvable (const ResObject::constPtr &resObject,
@@ -112,21 +112,21 @@ class  HelixControl {
     void lockResolvable (const ResObject::constPtr &resObject,
                         const ResStatus &status);
     void keepResolvable (const ResObject::constPtr &resObject,
-                        const ResStatus &status);        
+                        const ResStatus &status);
     void deleteResolvable (const ResObject::constPtr &resObject,
                           const ResStatus &status);
     void addDependencies (const CapabilitySet &capRequire, const CapabilitySet &capConflict);
-    
+
     void distupgrade ();
     void verifySystem ();
     void update ();
-    
+
     std::string filename () { return dumpFile; }
 };
-       
 
 
-       
+
+
 ///////////////////////////////////////////////////////////////////
 //
 //     CLASS NAME : Testcase
@@ -140,11 +140,11 @@ class Testcase {
 
   public:
     Testcase (const std::string & path);
-    Testcase ();    
+    Testcase ();
     ~Testcase ();
 
     bool createTestcase (Resolver & resolver, bool dumpPool = true, bool runSolver = true);
-    bool createTestcasePool(const ResPool &pool);    
+    bool createTestcasePool(const ResPool &pool);
 };
 
 
index 2837564..6b0ddbb 100644 (file)
@@ -49,6 +49,7 @@
 
 #include "zypp/pool/GetResolvablesToInsDel.h"
 #include "zypp/solver/detail/Helper.h"
+#include "zypp/solver/detail/Testcase.h"
 
 #include "zypp/repo/DeltaCandidates.h"
 #include "zypp/repo/PackageProvider.h"
@@ -58,6 +59,7 @@
 
 using namespace std;
 
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -65,6 +67,24 @@ namespace zypp
   namespace target
   { /////////////////////////////////////////////////////////////////
 
+    /** \internal Manage writing a new testcase when doing an upgrade. */
+    void writeOutUpgradeTestcase()
+    {
+      Target_Ptr target( getZYpp()->getTarget() );
+      if ( ! target )
+      {
+        WAR << "No Target no Testcase!" << endl;
+        return;
+      }
+
+      std::string stem( "updateTestcase" );
+      Pathname dir( target->assertRootPrefix("/var/log/") );
+      Pathname next( dir / Date::now().form( stem+"-%Y-%m-%d-%H-%M-%S" ) );
+
+      MIL << "Write new testcase " << next << endl;
+      getZYpp()->resolver()->createSolverTestcase( next.asString(), false/*no solving*/ );
+    }
+
     ///////////////////////////////////////////////////////////////////
     namespace
     { /////////////////////////////////////////////////////////////////
@@ -673,6 +693,14 @@ namespace zypp
       MIL << "TargetImpl::commit(<pool>, " << policy_r << ")" << endl;
 
       ///////////////////////////////////////////////////////////////////
+      // Write out a testcase if we're in dist upgrade mode.
+      ///////////////////////////////////////////////////////////////////
+      if ( getZYpp()->resolver()->upgradeMode() )
+      {
+        writeOutUpgradeTestcase();
+      }
+
+      ///////////////////////////////////////////////////////////////////
       // Store non-package data:
       ///////////////////////////////////////////////////////////////////
       filesystem::assert_dir( home() );