Author: schubi2
Date: Fri May 16 16:45:32 2008
New Revision: 10125
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10125&view=rev
Log:
- Added new calls : isInstalledBy (const PoolItem item);
installs (const PoolItem item);
Modified:
trunk/libzypp/VERSION.cmake
trunk/libzypp/zypp/Resolver.cc
trunk/libzypp/zypp/Resolver.h
trunk/libzypp/zypp/solver/detail/Resolver.cc
trunk/libzypp/zypp/solver/detail/Resolver.h
trunk/libzypp/zypp/solver/detail/SATResolver.cc
trunk/libzypp/zypp/solver/detail/SATResolver.h
Modified: trunk/libzypp/VERSION.cmake
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=10125&r1=10124&r2=10125&view=diff
==============================================================================
--- trunk/libzypp/VERSION.cmake (original)
+++ trunk/libzypp/VERSION.cmake Fri May 16 16:45:32 2008
@@ -45,6 +45,6 @@
#
SET(LIBZYPP_MAJOR "4")
-SET(LIBZYPP_MINOR "22")
+SET(LIBZYPP_MINOR "23")
SET(LIBZYPP_COMPATMINOR "21")
SET(LIBZYPP_PATCH "0")
Modified: trunk/libzypp/zypp/Resolver.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Resolver.cc?rev=10125&r1=10124&r2=10125&view=diff
==============================================================================
--- trunk/libzypp/zypp/Resolver.cc (original)
+++ trunk/libzypp/zypp/Resolver.cc Fri May 16 16:45:32 2008
@@ -109,6 +109,10 @@
bool Resolver::createSolverTestcase (const std::string & dumpPath)
{ solver::detail::Testcase testcase (dumpPath);
return testcase.createTestcase(*_pimpl);}
+ const solver::detail::ItemCapKindList Resolver::isInstalledBy (const PoolItem item)
+ { return _pimpl->isInstalledBy (item); }
+ const solver::detail::ItemCapKindList Resolver::installs (const PoolItem item)
+ { return _pimpl->installs (item); }
/////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/Resolver.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Resolver.h?rev=10125&r1=10124&r2=10125&view=diff
==============================================================================
--- trunk/libzypp/zypp/Resolver.h (original)
+++ trunk/libzypp/zypp/Resolver.h Fri May 16 16:45:32 2008
@@ -216,8 +216,33 @@
*/
bool createSolverTestcase (const std::string & dumpPath = "/var/log/YaST2/solverTestcase");
+ /**
+ * Gives information about WHO has pused an installation of an given item.
+ *
+ * \param item Evaluate additional information for this resolvable.
+ * \return A list of structures which contains:
+ * item Item which has triggered the installation of the given param item.
+ * cap Capability which has triggerd this installation
+ * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
+ *
+ * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
+ *
+ */
+ const solver::detail::ItemCapKindList isInstalledBy (const PoolItem item);
- protected:
+ /**
+ * Gives information about WHICH additional items will be installed due the installation of an item.
+ *
+ * \param item Evaluate additional information for this resolvable.
+ * \return A list of structures which contains:
+ * item Item which will be installed due to the installation of the given param item too.
+ * cap Capability which causes the installation
+ * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
+ *
+ * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
+ *
+ */
+ const solver::detail::ItemCapKindList installs (const PoolItem item);
private:
solver::detail::Resolver_Ptr _pimpl;
Modified: trunk/libzypp/zypp/solver/detail/Resolver.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Resolver.cc?rev=10125&r1=10124&r2=10125&view=diff
==============================================================================
--- trunk/libzypp/zypp/solver/detail/Resolver.cc (original)
+++ trunk/libzypp/zypp/solver/detail/Resolver.cc Fri May 16 16:45:32 2008
@@ -102,6 +102,9 @@
_extra_requires.clear();
_extra_conflicts.clear();
}
+
+ _isInstalledBy.clear();
+ _installs.clear();
}
void
@@ -288,6 +291,11 @@
if (_verifying)
_satResolver->setFixsystem(true);
+
+ // Resetting additional solver information
+ _isInstalledBy.clear();
+ _installs.clear();
+
}
bool
@@ -420,6 +428,165 @@
}
+//----------------------------------------------------------------------------
+// Getting more information about the solve results
+
+
+void
+Resolver::collectResolverInfo(void)
+{
+ if ( _satResolver
+ && _isInstalledBy.empty()
+ && _installs.empty()) {
+
+ // generating new
+ PoolItemList itemsToInstall = _satResolver->resultItemsToInstall();
+
+ for (PoolItemList::const_iterator instIter = itemsToInstall.begin();
+ instIter != itemsToInstall.end(); instIter++) {
+
+ // Requires
+ for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::REQUIRES).begin(); capIt != (*instIter)->dep (Dep::REQUIRES).end(); ++capIt)
+ {
+ sat::WhatProvides possibleProviders(*capIt);
+ for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
+ PoolItem provider = ResPool::instance().find( *iter );
+
+ // searching if this provider will already be installed
+ bool found = false;
+ bool alreadySetForInstallation = false;
+ ItemCapKindMap::const_iterator pos = _isInstalledBy.find(provider);
+ while (pos != _isInstalledBy.end()
+ && pos->first == provider
+ && !found) {
+ alreadySetForInstallation = true;
+ ItemCapKind capKind = pos->second;
+ if (capKind.item == *instIter) found = true;
+ pos++;
+ }
+
+ if (!found
+ && provider.status().isToBeInstalled()) {
+ if (provider.status().isBySolver()) {
+ ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::REQUIRES, !alreadySetForInstallation );
+ _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
+ } else {
+ // no initial installation cause it has been set be e.g. user
+ ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::REQUIRES, false );
+ _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
+ }
+ ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::REQUIRES, !alreadySetForInstallation );
+ _installs.insert (make_pair( *instIter, capKindisInstalledBy));
+ }
+ }
+ }
+
+ //Recommends
+ for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::RECOMMENDS).begin(); capIt != (*instIter)->dep (Dep::RECOMMENDS).end(); ++capIt)
+ {
+ sat::WhatProvides possibleProviders(*capIt);
+ for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
+ PoolItem provider = ResPool::instance().find( *iter );
+
+ // searching if this provider will already be installed
+ bool found = false;
+ bool alreadySetForInstallation = false;
+ ItemCapKindMap::const_iterator pos = _isInstalledBy.find(provider);
+ while (pos != _isInstalledBy.end()
+ && pos->first == provider
+ && !found) {
+ alreadySetForInstallation = true;
+ ItemCapKind capKind = pos->second;
+ if (capKind.item == *instIter) found = true;
+ pos++;
+ }
+
+ if (!found
+ && provider.status().isToBeInstalled()) {
+ if (provider.status().isBySolver()) {
+ ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::RECOMMENDS, !alreadySetForInstallation );
+ _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
+ } else {
+ // no initial installation cause it has been set be e.g. user
+ ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::RECOMMENDS, false );
+ _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
+ }
+ ItemCapKind capKindisInstalledBy( provider, *capIt, Dep::RECOMMENDS, !alreadySetForInstallation );
+ _installs.insert (make_pair( *instIter, capKindisInstalledBy));
+ }
+ }
+ }
+
+ //Suggests
+ for (Capabilities::const_iterator capIt = (*instIter)->dep (Dep::SUGGESTS).begin(); capIt != (*instIter)->dep (Dep::SUGGESTS).end(); ++capIt)
+ {
+ sat::WhatProvides possibleProviders(*capIt);
+ for_( iter, possibleProviders.begin(), possibleProviders.end() ) {
+ PoolItem provider = ResPool::instance().find( *iter );
+
+ // searching if this provider will already be installed
+ bool found = false;
+ bool alreadySetForInstallation = false;
+ ItemCapKindMap::const_iterator pos = _isInstalledBy.find(provider);
+ while (pos != _isInstalledBy.end()
+ && pos->first == provider
+ && !found) {
+ alreadySetForInstallation = true;
+ ItemCapKind capKind = pos->second;
+ if (capKind.item == *instIter) found = true;
+ pos++;
+ }
+
+ if (!found) {
+ ItemCapKind capKindisInstalledBy( *instIter, *capIt, Dep::SUGGESTS, !alreadySetForInstallation );
+ _isInstalledBy.insert (make_pair( provider, capKindisInstalledBy));
+ }
+ }
+ }
+ }
+ }
+}
+
+
+const ItemCapKindList Resolver::isInstalledBy (const PoolItem item) {
+ ItemCapKindList ret;
+ collectResolverInfo();
+
+ for (ItemCapKindMap::const_iterator iter = _isInstalledBy.find(item); iter != _isInstalledBy.end();) {
+ ItemCapKind info = iter->second;
+ PoolItem iterItem = iter->first;
+ if (iterItem == item) {
+ ret.push_back(info);
+ iter++;
+ } else {
+ // exit
+ iter = _isInstalledBy.end();
+ }
+ }
+ return ret;
+}
+
+const ItemCapKindList Resolver::installs (const PoolItem item) {
+ ItemCapKindList ret;
+ collectResolverInfo();
+
+ for (ItemCapKindMap::const_iterator iter = _installs.find(item); iter != _installs.end();) {
+ ItemCapKind info = iter->second;
+ PoolItem iterItem = iter->first;
+ if (iterItem == item) {
+ ret.push_back(info);
+ iter++;
+ } else {
+ // exit
+ iter = _installs.end();
+ }
+ }
+ return ret;
+}
+
+
+
+
///////////////////////////////////////////////////////////////////
};// namespace detail
/////////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/solver/detail/Resolver.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Resolver.h?rev=10125&r1=10124&r2=10125&view=diff
==============================================================================
--- trunk/libzypp/zypp/solver/detail/Resolver.h (original)
+++ trunk/libzypp/zypp/solver/detail/Resolver.h Fri May 16 16:45:32 2008
@@ -58,6 +58,32 @@
class SATResolver;
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ItemCapKind
+ //
+ /** */
+ struct ItemCapKind
+ {
+ public:
+ Capability cap; //Capability which has triggerd this selection
+ Dep capKind; //Kind of that capability
+ PoolItem item; //Item which has triggered this selection
+ bool initialInstallation; //This item has triggered the installation
+ //Not already fullfilled requierement only.
+
+ ItemCapKind() : capKind("FRESHENS") {}
+ ItemCapKind( PoolItem i, Capability c, Dep k, bool initial)
+ : cap( c )
+ , capKind( k )
+ , item( i )
+ , initialInstallation( initial )
+ { }
+ };
+ typedef std::multimap