Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / solver / detail / SolutionAction.cc
index 3788f27..77d3b39 100644 (file)
 
 #include "zypp/solver/detail/Resolver.h"
 #include "zypp/solver/detail/SolutionAction.h"
-#include "zypp/CapSet.h"
+#include "zypp/Capabilities.h"
 #include "zypp/base/Logger.h"
-#include "zypp/Dependencies.h"
-
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -63,15 +61,16 @@ TransactionSolutionAction::dumpOn( ostream& os) const
 {
     os << "TransactionSolutionAction: ";
     switch (_action) {
-       case KEEP:      os << "Keep"; break;
-       case INSTALL:   os << "Install"; break;
-       case UPDATE:    os << "Update"; break;
-       case REMOVE:    os << "Remove"; break;
-       case UNLOCK:    os << "Unlock"; break;      
+       case KEEP:                      os << "Keep " << _item; break;
+       case INSTALL:                   os << "Install " << _item; break;
+       case REMOVE:                    os << "Remove " << _item; break;
+       case UNLOCK:                    os << "Unlock " << _item; break;
+       case LOCK:                      os << "Lock " << _item; break;
+       case REMOVE_EXTRA_REQUIRE:      os << "Remove require " << _capability; break;
+       case REMOVE_EXTRA_CONFLICT:     os << "Remove conflict " << _capability; break;
+       case ADD_SOLVE_QUEUE_ITEM:      os << "Add SolveQueueItem " <<  _solverQueueItem; break;
+       case REMOVE_SOLVE_QUEUE_ITEM:   os << "Remove SolveQueueItem " <<  _solverQueueItem; break;
     }
-    os << " ";
-    os << _item;
-    os << endl;
     return os;
 }
 
@@ -103,17 +102,12 @@ ostream &
 InjectSolutionAction::dumpOn( ostream& os ) const
 {
     os << "InjectSolutionAction: ";
-    os << _capability;
-    os << ", ";
     switch (_kind) {
-       case REQUIRES:  os << "Requires"; break;
-       case CONFLICTS: os << "Conflicts"; break;
-       case ARCHITECTURE: os << "Architecture"; break;
+       case WEAK:      os << "Weak"; break;
        default: os << "Wrong kind"; break;
     }
     os << " ";
-    os << _item;           
-    os << endl;
+    os << _item;
     return os;
 }
 
@@ -130,24 +124,50 @@ SolutionAction::dumpOn( std::ostream & os ) const
 }
 
 
-bool 
+bool
 TransactionSolutionAction::execute(Resolver & resolver) const
 {
     bool ret = true;
     switch (action()) {
        case KEEP:
-           ret = _item.status().setNoTransact (ResStatus::USER);
+           _item.status().resetTransact (ResStatus::USER);
+           ret = _item.status().setTransact (false, ResStatus::APPL_HIGH); // APPL_HIGH: Locking should not be saved permanently
+           break;
        case INSTALL:
-       case UPDATE:
-           _item.status().setToBeInstalled (ResStatus::USER);
+           if (_item.status().isToBeUninstalled())
+               ret = _item.status().setTransact (false, ResStatus::USER);
+           else
+               _item.status().setToBeInstalled (ResStatus::USER);
            break;
        case REMOVE:
-           _item.status().setToBeUninstalled (ResStatus::USER);
+           if (_item.status().isToBeInstalled()) {
+               _item.status().setTransact (false,ResStatus::USER);
+               _item.status().setLock (true,ResStatus::USER); // no other dependency can set it again
+           } else if (_item.status().isInstalled())
+               _item.status().setToBeUninstalled (ResStatus::USER);
+           else
+               _item.status().setLock (true,ResStatus::USER); // no other dependency can set it again
            break;
        case UNLOCK:
-           ERR << "Not implemented yet" << endl;
-           ret = false;
-#warning Unlocking items not implemented
+           ret = _item.status().setLock (false, ResStatus::USER);
+           if (!ret) ERR << "Cannot unlock " << _item << endl;
+           break;
+       case LOCK:
+           _item.status().resetTransact (ResStatus::USER);
+           ret = _item.status().setLock (true, ResStatus::APPL_HIGH); // APPL_HIGH: Locking should not be saved permanently
+           if (!ret) ERR << "Cannot lock " << _item << endl;
+           break;
+       case REMOVE_EXTRA_REQUIRE:
+           resolver.removeExtraRequire (_capability);
+           break;
+       case REMOVE_EXTRA_CONFLICT:
+           resolver.removeExtraConflict (_capability);
+           break;
+       case ADD_SOLVE_QUEUE_ITEM:
+           resolver.addQueueItem(_solverQueueItem);
+           break;
+       case REMOVE_SOLVE_QUEUE_ITEM:
+           resolver.removeQueueItem(_solverQueueItem);
            break;
        default:
            ERR << "Wrong TransactionKind" << endl;
@@ -159,29 +179,14 @@ TransactionSolutionAction::execute(Resolver & resolver) const
 bool
 InjectSolutionAction::execute(Resolver & resolver) const
 {
-    if (_kind == CONFLICTS) {
-       // removing conflict in both resolvables
-       Dependencies dependencies = _item.resolvable()->deps();
-       CapSet depList = dependencies[Dep::CONFLICTS];
-       if (depList.find(_capability) != depList.end())
-       {
-           resolver.addIgnoreConflict (_item, _capability);
-       }
-       dependencies = _otherItem.resolvable()->deps();
-       depList = dependencies[Dep::CONFLICTS];
-       if (depList.find(_capability) != depList.end())
-       {
-           resolver.addIgnoreConflict (_otherItem, _capability);
-       }
-    } else if (_kind  == REQUIRES) {
-       // removing the requires dependency from the item
-       resolver.addIgnoreRequires (_item, _capability);
-    } else if (_kind  == ARCHITECTURE) {
-       // ignoring architecture
-       resolver.addIgnoreArchitecture (_item); 
-    } else {
-       ERR << "No valid InjectSolutionAction kind found" << endl;
-       return false;
+    switch (_kind) {
+        case WEAK:
+           // set item dependencies to weak
+           resolver.addWeak (_item);
+            break;
+        default:
+           ERR << "No valid InjectSolutionAction kind found" << endl;
+           return false;
     }
 
     return true;