ref: refs/heads/ma-misc
commit f70550c6a0b03bc3c98a4ca98e6b1310e95dd4ab
Author: Michael Andres
Date: Thu Oct 15 17:04:13 2009 +0200
Distupgrade: Evaluate new products droplist and schedule packages for deletion. (bnc #539543)
---
libzypp.spec.cmake | 2 +-
tests/data/TCdup/solver-system.xml | 55 +++++++++++++++++++++++++++++++
tests/data/TCdup/solver-test.xml | 13 +++++++
tests/data/TCdup/update.xml | 36 ++++++++++++++++++++
tests/zypp/CMakeLists.txt | 1 +
tests/zypp/Dup_test.cc | 63 ++++++++++++++++++++++++++++++++++++
zypp/solver/detail/SATResolver.cc | 31 +++++++++++++++++-
7 files changed, 199 insertions(+), 2 deletions(-)
diff --git a/libzypp.spec.cmake b/libzypp.spec.cmake
index 6bdc2a6..a49bda5 100644
--- a/libzypp.spec.cmake
+++ b/libzypp.spec.cmake
@@ -25,7 +25,7 @@ Provides: yast2-packagemanager
Obsoletes: yast2-packagemanager
Recommends: logrotate
BuildRequires: cmake
-BuildRequires: libsatsolver-devel >= 0.14.5
+BuildRequires: libsatsolver-devel >= 0.14.9
BuildRequires: openssl-devel
BuildRequires: boost-devel curl-devel dejagnu doxygen gcc-c++ gettext-devel graphviz hal-devel libxml2-devel
diff --git a/tests/data/TCdup/solver-system.xml b/tests/data/TCdup/solver-system.xml
new file mode 100644
index 0000000..2e60954
--- /dev/null
+++ b/tests/data/TCdup/solver-system.xml
@@ -0,0 +1,55 @@
+<channel><subchannel>
+<product>
+ <name>Product</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>1</version>
+ <release>1</release>
+ </update></history>
+</product>
+<package>
+ <name>release-package</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>1</version>
+ <release>1</release>
+ </update></history>
+ <provides>
+ <dep name='product()'/>
+ <dep name='product(Product)' op='==' version='1' release='1' />
+ </provides>
+</package>
+
+<package>
+ <name>glibc</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>1</version>
+ <release>1</release>
+ </update></history>
+ <requires>
+ <dep name='dropped_required'/>
+ </requires>
+</package>
+<package>
+ <name>dropped_required</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>1</version>
+ <release>1</release>
+ </update></history>
+</package>
+<package>
+ <name>dropped</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>1</version>
+ <release>1</release>
+ </update></history>
+</package>
+</subchannel></channel>
diff --git a/tests/data/TCdup/solver-test.xml b/tests/data/TCdup/solver-test.xml
new file mode 100644
index 0000000..08c701d
--- /dev/null
+++ b/tests/data/TCdup/solver-test.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<test>
+<setup arch="x86_64">
+ <system file="solver-system.xml"/>
+ <!--
+ - alias : update
+ - url : http://foo.org/distribution/update
+ -->
+ <channel file="update.xml" name="update" priority="10" />
+ <locale name="en_US" />
+ <locale name="de" />
+</setup>
+</test>
diff --git a/tests/data/TCdup/update.xml b/tests/data/TCdup/update.xml
new file mode 100644
index 0000000..e8e0e0c
--- /dev/null
+++ b/tests/data/TCdup/update.xml
@@ -0,0 +1,36 @@
+<channel><subchannel>
+<product>
+ <name>Product</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>2</version>
+ <release>1</release>
+ </update></history>
+</product>
+<package>
+ <name>release-package</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>2</version>
+ <release>1</release>
+ </update></history>
+ <provides>
+ <dep name='product()'/>
+ <dep name='product(Product)' op='==' version='2' release='1' />
+ <dep name='weakremover(dropped_required)'/>
+ <dep name='weakremover(dropped)'/>
+ </provides>
+</package>
+
+<package>
+ <name>package</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>2</version>
+ <release>1</release>
+ </update></history>
+</package>
+</subchannel></channel>
diff --git a/tests/zypp/CMakeLists.txt b/tests/zypp/CMakeLists.txt
index a4a2495..3ca5491 100644
--- a/tests/zypp/CMakeLists.txt
+++ b/tests/zypp/CMakeLists.txt
@@ -10,6 +10,7 @@ ADD_TESTS(
Capabilities
CheckSum
Date
+ Dup
Digest
Deltarpm
Edition
diff --git a/tests/zypp/Dup_test.cc b/tests/zypp/Dup_test.cc
new file mode 100644
index 0000000..248a03d
--- /dev/null
+++ b/tests/zypp/Dup_test.cc
@@ -0,0 +1,63 @@
+#include "TestSetup.h"
+#include "zypp/ResPool.h"
+#include "zypp/ResPoolProxy.h"
+#include "zypp/pool/PoolStats.h"
+#include "zypp/ui/Selectable.h"
+
+#define BOOST_TEST_MODULE Dup
+
+/////////////////////////////////////////////////////////////////////////////
+
+static TestSetup test;
+
+template <class _Iterator>
+std::ostream & vdumpPoolStats( std::ostream & str, _Iterator begin_r, _Iterator end_r )
+{
+ pool::PoolStats stats;
+ for_( it, begin_r, end_r )
+ {
+ str << *it << endl;
+ stats( *it );
+ }
+ return str << stats;
+}
+
+bool upgrade()
+{
+ bool rres = false;
+ {
+ rres = getZYpp()->resolver()->doUpgrade();
+ }
+ if ( ! rres )
+ {
+ ERR << "upgrade " << rres << endl;
+ getZYpp()->resolver()->problems();
+ return false;
+ }
+ MIL << "upgrade " << rres << endl;
+ vdumpPoolStats( USR << "Transacting:"<< endl,
+ make_filter_beginresfilter::ByTransact(test.pool()),
+ make_filter_endresfilter::ByTransact(test.pool()) ) << endl;
+ return true;
+}
+
+
+BOOST_AUTO_TEST_CASE(testcase_init)
+{
+ //zypp::base::LogControl::instance().logToStdErr();
+ test.loadTestcaseRepos( TESTS_SRC_DIR"/data/TCdup" );
+ dumpRange( USR, test.pool().knownRepositoriesBegin(),
+ test.pool().knownRepositoriesEnd() ) << endl;
+ USR << "pool: " << test.pool() << endl;
+ BOOST_REQUIRE( upgrade() );
+}
+/////////////////////////////////////////////////////////////////////////////
+
+BOOST_AUTO_TEST_CASE(orphaned)
+{
+ ResPoolProxy proxy( test.poolProxy() );
+ BOOST_CHECK_EQUAL( proxy.lookup( ResKind::package, "glibc" )->status(), ui::S_KeepInstalled );
+ BOOST_CHECK_EQUAL( proxy.lookup( ResKind::package, "release-package" )->status(), ui::S_AutoUpdate );
+ BOOST_CHECK_EQUAL( proxy.lookup( ResKind::package, "dropped_required" )->status(), ui::S_KeepInstalled );
+ BOOST_CHECK_EQUAL( proxy.lookup( ResKind::package, "dropped" )->status(), ui::S_AutoDel );
+}
diff --git a/zypp/solver/detail/SATResolver.cc b/zypp/solver/detail/SATResolver.cc
index 433e65c..9e4598f 100644
--- a/zypp/solver/detail/SATResolver.cc
+++ b/zypp/solver/detail/SATResolver.cc
@@ -31,10 +31,11 @@ extern "C"
#include "zypp/solver/detail/Helper.h"
#include "zypp/base/String.h"
+#include "zypp/Product.h"
#include "zypp/Capability.h"
#include "zypp/ResStatus.h"
#include "zypp/VendorAttr.h"
-#include "zypp/base/Logger.h"
+#include "zypp/base/LogTools.h"
#include "zypp/base/String.h"
#include "zypp/base/Gettext.h"
#include "zypp/base/Algorithm.h"
@@ -640,6 +641,34 @@ SATResolver::solverInit(const PoolItemList & weakItems)
queue_push( &(_jobQueue), SOLVER_NOOBSOLETES_SOLVABLE_NAME );
queue_push( &(_jobQueue), it->id() );
}
+
+ if ( _distupgrade )
+ {
+ if ( ZConfig::instance().solverUpgradeRemoveDropedPackages() )
+ {
+ MIL << "Checking droplists ..." << endl;
+ // Dropped packages: look for 'weakremover()' provides
+ // in dup candidates of installed products.
+ ResPoolProxy proxy( ResPool::instance().proxy() );
+ for_( it, proxy.byKindBegin<Product>(), proxy.byKindEnd<Product>() )
+ {
+ if ( (*it)->onSystem() ) // (to install) or (not to delete)
+ {
+ CapabilitySet droplist( (*it)->candidateAsKind<Product>()->droplist() );
+ dumpRangeLine( MIL << "Droplist for " << (*it)->candidateObj() << ": " << droplist.size() << " ", droplist.begin(), droplist.end() ) << endl;
+ for_( cap, droplist.begin(), droplist.end() )
+ {
+ queue_push( &_jobQueue, SOLVER_DROP_ORPHANED|SOLVER_SOLVABLE_NAME );
+ queue_push( &_jobQueue, cap->id() );
+ }
+ }
+ }
+ }
+ else
+ {
+ MIL << "Droplist processing is disabled." << endl;
+ }
+ }
}
void
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org