Author: schubi2
Date: Thu Oct 25 17:10:53 2007
New Revision: 7638
URL: http://svn.opensuse.org/viewcvs/zypp?rev=7638&view=rev
Log:
copying result back to zypp pool
Modified:
trunk/libzypp/zypp/sat/SATResolver.cc
Modified: trunk/libzypp/zypp/sat/SATResolver.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SATResolver.cc?rev=7638&r1=7637&r2=7638&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/SATResolver.cc (original)
+++ trunk/libzypp/zypp/sat/SATResolver.cc Thu Oct 25 17:10:53 2007
@@ -20,8 +20,9 @@
*/
#include "zypp/solver/detail/Helper.h"
-
+#include "zypp/base/String.h"
#include "zypp/CapSet.h"
+#include "zypp/ResStatus.h"
#include "zypp/base/Logger.h"
#include "zypp/base/String.h"
#include "zypp/base/Gettext.h"
@@ -181,7 +182,7 @@
// if data != NULL, set as APPL_LOW (from establishPool())
static void
-solution_to_pool (PoolItem_Ref item, const ResStatus & status, void *data)
+solution_to_pool (PoolItem_Ref item, const ResStatus & status, const ResStatus::TransactByValue causer)
{
if (triggeredSolution.find(item) != triggeredSolution.end()) {
_XDEBUG("solution_to_pool(" << item << ") is already in the pool --> skip");
@@ -191,20 +192,20 @@
triggeredSolution.insert(item);
// resetting transaction only
- item.status().resetTransact((data != NULL) ? ResStatus::APPL_LOW : ResStatus::SOLVER );
+ item.status().resetTransact (causer);
bool r;
if (status.isToBeInstalled()) {
- r = item.status().setToBeInstalled( (data != NULL) ? ResStatus::APPL_LOW : ResStatus::SOLVER );
+ r = item.status().setToBeInstalled (causer);
_XDEBUG("solution_to_pool(" << item << ", " << status << ") install !" << r);
}
else if (status.isToBeUninstalledDueToUpgrade()) {
- r = item.status().setToBeUninstalledDueToUpgrade( (data != NULL) ? ResStatus::APPL_LOW : ResStatus::SOLVER );
+ r = item.status().setToBeUninstalledDueToUpgrade (causer);
_XDEBUG("solution_to_pool(" << item << ", " << status << ") upgrade !" << r);
}
else if (status.isToBeUninstalled()) {
- r = item.status().setToBeUninstalled( (data != NULL) ? ResStatus::APPL_LOW : ResStatus::SOLVER );
+ r = item.status().setToBeUninstalled (causer);
_XDEBUG("solution_to_pool(" << item << ", " << status << ") remove !" << r);
}
else if (status.isIncomplete()
@@ -225,9 +226,138 @@
return;
}
-
+//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// resolvePool
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+// Helper functions for the ZYPP-Pool
+//----------------------------------------------------------------------------
+
+
+Resolvable::Kind
+string2kind (const std::string & str)
+{
+ Resolvable::Kind kind = ResTraitszypp::Package::kind;
+ if (!str.empty()) {
+ if (str == "package") {
+ // empty
+ }
+ else if (str == "patch") {
+ kind = ResTraitszypp::Patch::kind;
+ }
+ else if (str == "atom") {
+ kind = ResTraitszypp::Atom::kind;
+ }
+ else if (str == "pattern") {
+ kind = ResTraitszypp::Pattern::kind;
+ }
+ else if (str == "selection") {
+ kind = ResTraitszypp::Selection::kind;
+ }
+ else if (str == "script") {
+ kind = ResTraitszypp::Script::kind;
+ }
+ else if (str == "message") {
+ kind = ResTraitszypp::Message::kind;
+ }
+ else if (str == "product") {
+ kind = ResTraitszypp::Product::kind;
+ }
+ else if (str == "language") {
+ kind = ResTraitszypp::Language::kind;
+ }
+ else {
+ ERR << "get_poolItem unknown kind '" << str << "'" << endl;
+ }
+ }
+ return kind;
+}
+
+
+struct FindPackage : public resfilter::ResObjectFilterFunctor
+{
+ PoolItem_Ref poolItem;
+ Resolvable::Kind kind;
+ bool edition_set;
+ Edition edition;
+ bool arch_set;
+ Arch arch;
+
+ FindPackage (Resolvable::Kind k, const string & e, const string & a)
+ : kind (k)
+ , edition_set( !e.empty() )
+ , edition( e )
+ , arch_set( !a.empty() )
+ , arch( a )
+ {
+ }
+
+ bool operator()( PoolItem_Ref p)
+ {
+ if (arch_set && arch != p->arch()) { // if arch requested, force this arch
+ return true;
+ }
+
+ if (edition_set) {
+ if (p->edition().compare( edition ) == 0) { // if edition requested, force this edition
+ poolItem = p;
+ return false;
+ }
+ return true;
+ }
+
+ if (!poolItem // none yet
+ || (poolItem->arch().compare( p->arch() ) < 0) // new has better arch
+ || (poolItem->edition().compare( p->edition() ) < 0)) // new has better edition
+ {
+ poolItem = p;
+ }
+ return true;
+ }
+};
+
+
+static PoolItem_Ref
+get_poolItem (const ResPool & pool, const string & source_alias, const string & package_name, const string & kind_name = "", const string & edition = "", const string & arch = "")
+{
+ PoolItem_Ref poolItem;
+ Resolvable::Kind kind = string2kind (kind_name);
+
+ try {
+ FindPackage info (kind, edition, arch);
+
+ invokeOnEach( pool.byNameBegin( package_name ),
+ pool.byNameEnd( package_name ),
+ functor::chain( resfilter::ByRepository(source_alias), resfilter::ByKind (kind) ),
+ functor::functorRef