New solver.upgradeTestcasesToKeep option in zypp.conf.
authorMichael Andres <ma@suse.de>
Thu, 16 Jul 2009 14:32:07 +0000 (16:32 +0200)
committerMichael Andres <ma@suse.de>
Thu, 16 Jul 2009 14:32:07 +0000 (16:32 +0200)
It tells how many dist upgrade solver testcases should be kept
on the system. Per default just the last two are kept.

VERSION.cmake
package/libzypp.changes
zypp.conf
zypp/ZConfig.cc
zypp/ZConfig.h
zypp/target/TargetImpl.cc

index 24d156e..9113d51 100644 (file)
@@ -61,8 +61,8 @@
 SET(LIBZYPP_MAJOR "6")
 SET(LIBZYPP_COMPATMINOR "10")
 SET(LIBZYPP_MINOR "10")
-SET(LIBZYPP_PATCH "3")
+SET(LIBZYPP_PATCH "4")
 #
-# LAST RELEASED: 6.10.3 (10)
+# LAST RELEASED: 6.10.4 (10)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index a61d1f2..948f569 100644 (file)
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Thu Jul 16 16:25:24 CEST 2009 - ma@suse.de
+
+- New solver.upgradeTestcasesToKeep option in zypp.conf. It tells 
+  how many dist upgrade solver testcases should be kept on the system.
+  Per default just the last two are kept. 
+- version 6.10.4 (10)
+
+-------------------------------------------------------------------
 Wed Jul 15 17:53:43 CEST 2009 - ma@suse.de
 
 - Don't write a solver testcase when solving for dist upgrade, 
index e1c8920..7121341 100644 (file)
--- a/zypp.conf
+++ b/zypp.conf
 # solver.checkSystemFile = /etc/zypp/systemCheck
 
 ##
+## When committing a dist upgrade (e.g. 'zypper dup') a solver testcase
+## is written to /var/log/updateTestcase-<date>. It is needed in bugreports.
+## This optin returns the number of testcases to keep on the system. Old
+## cases will be deleted, as new ones are created.
+##
+## Use 0 to write no testcase at all, or -1 to keep all testcases.
+##
+## Valid values:       Integer
+## Default value:      2
+##
+# solver.upgradeTestcasesToKeep = 2
+
+##
 ## Packages which are parallel installable with
 ## diffent versions
 ##
index 738cc71..b05c5ea 100644 (file)
@@ -329,6 +329,10 @@ namespace zypp
                 {
                   solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange.get() ) );
                 }
+                else if ( entry == "solver.upgradeTestcasesToKeep" )
+                {
+                  solver_upgradeTestcasesToKeep.set( str::strtonum<unsigned>( value ) );
+                }
                 else if ( entry == "solver.checkSystemFile" )
                 {
                   solver_checkSystemFile = Pathname(value);
@@ -439,8 +443,9 @@ namespace zypp
     int download_max_download_speed;
     int download_max_silent_tries;
 
-    Option<bool,false> solver_onlyRequires;
-    Option<bool,false> solver_allowVendorChange;
+    Option<bool,false>  solver_onlyRequires;
+    Option<bool,false>  solver_allowVendorChange;
+    Option<unsigned,2U> solver_upgradeTestcasesToKeep;
     Pathname solver_checkSystemFile;
 
     std::set<IdString> multiversion;
@@ -638,6 +643,7 @@ namespace zypp
   long ZConfig::download_max_silent_tries() const
   { return _pimpl->download_max_silent_tries; }
 
+
   bool ZConfig::solver_onlyRequires() const
   { return _pimpl->solver_onlyRequires.get(); }
 
@@ -648,6 +654,9 @@ namespace zypp
   { return ( _pimpl->solver_checkSystemFile.empty()
       ? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); }
 
+  unsigned ZConfig::solver_upgradeTestcasesToKeep() const
+  { return _pimpl->solver_upgradeTestcasesToKeep.get(); }
+
   std::set<IdString> ZConfig::multiversion() const
   { return _pimpl->multiversion; }
 
index 6de0e12..c5bb921 100644 (file)
@@ -227,6 +227,15 @@ namespace zypp
       bool solver_allowVendorChange() const;
 
       /**
+       * When committing a dist upgrade (e.g. <tt>zypper dup</tt>)
+       * a solver testcase is written. It is needed in bugreports,
+       * in case something went wrong. This returns the number of
+       * testcases to keep on the system. Old cases will be deleted,
+       * as new ones are created. Use \c 0 to write no testcase at all.
+       */
+      unsigned solver_upgradeTestcasesToKeep() const;
+
+      /**
        * Packages which can be installed parallel with different versions
        * Returning a set of package names (IdString)
        */
index 6b0ddbb..f691981 100644 (file)
@@ -68,8 +68,12 @@ namespace zypp
   { /////////////////////////////////////////////////////////////////
 
     /** \internal Manage writing a new testcase when doing an upgrade. */
-    void writeOutUpgradeTestcase()
+    void writeUpgradeTestcase()
     {
+      unsigned toKeep( ZConfig::instance().solver_upgradeTestcasesToKeep() );
+      MIL << "Testcases to keep: " << toKeep << endl;
+      if ( !toKeep )
+        return;
       Target_Ptr target( getZYpp()->getTarget() );
       if ( ! target )
       {
@@ -81,6 +85,27 @@ namespace zypp
       Pathname dir( target->assertRootPrefix("/var/log/") );
       Pathname next( dir / Date::now().form( stem+"-%Y-%m-%d-%H-%M-%S" ) );
 
+      {
+        std::list<std::string> content;
+        filesystem::readdir( content, dir, /*dots*/false );
+        std::set<std::string> cases;
+        for_( c, content.begin(), content.end() )
+        {
+          if ( str::startsWith( *c, stem ) )
+            cases.insert( *c );
+        }
+        if ( cases.size() >= toKeep )
+        {
+          unsigned toDel = cases.size() - toKeep + 1; // +1 for the new one
+          for_( c, cases.begin(), cases.end() )
+          {
+            filesystem::recursive_rmdir( dir/(*c) );
+            if ( ! --toDel )
+              break;
+          }
+        }
+      }
+
       MIL << "Write new testcase " << next << endl;
       getZYpp()->resolver()->createSolverTestcase( next.asString(), false/*no solving*/ );
     }
@@ -697,7 +722,7 @@ namespace zypp
       ///////////////////////////////////////////////////////////////////
       if ( getZYpp()->resolver()->upgradeMode() )
       {
-        writeOutUpgradeTestcase();
+        writeUpgradeTestcase();
       }
 
       ///////////////////////////////////////////////////////////////////