ref: refs/heads/ma-misc
commit bce7f7b32ada56852a354652fb931888eed2c979
Author: Michael Andres
Date: Thu Jul 16 16:32:07 2009 +0200
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.cmake | 4 ++--
package/libzypp.changes | 8 ++++++++
zypp.conf | 13 +++++++++++++
zypp/ZConfig.cc | 13 +++++++++++--
zypp/ZConfig.h | 9 +++++++++
zypp/target/TargetImpl.cc | 29 +++++++++++++++++++++++++++--
6 files changed, 70 insertions(+), 6 deletions(-)
diff --git a/VERSION.cmake b/VERSION.cmake
index 24d156e..9113d51 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -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)
#=======
diff --git a/package/libzypp.changes b/package/libzypp.changes
index a61d1f2..948f569 100644
--- a/package/libzypp.changes
+++ b/package/libzypp.changes
@@ -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,
diff --git a/zypp.conf b/zypp.conf
index e1c8920..7121341 100644
--- a/zypp.conf
+++ b/zypp.conf
@@ -257,6 +257,19 @@
# 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
##
diff --git a/zypp/ZConfig.cc b/zypp/ZConfig.cc
index 738cc71..b05c5ea 100644
--- a/zypp/ZConfig.cc
+++ b/zypp/ZConfig.cc
@@ -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 solver_onlyRequires;
- Option solver_allowVendorChange;
+ Option solver_onlyRequires;
+ Option solver_allowVendorChange;
+ Option 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; }
diff --git a/zypp/ZConfig.h b/zypp/ZConfig.h
index 6de0e12..c5bb921 100644
--- a/zypp/ZConfig.h
+++ b/zypp/ZConfig.h
@@ -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)
*/
diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc
index 6b0ddbb..f691981 100644
--- a/zypp/target/TargetImpl.cc
+++ b/zypp/target/TargetImpl.cc
@@ -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::liststd::string content;
+ filesystem::readdir( content, dir, /*dots*/false );
+ std::setstd::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();
}
///////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org