added lock request; bugfix in wead dependency
authorStefan Schubert <schubi@suse.de>
Tue, 15 Apr 2008 15:54:06 +0000 (15:54 +0000)
committerStefan Schubert <schubi@suse.de>
Tue, 15 Apr 2008 15:54:06 +0000 (15:54 +0000)
zypp/CMakeLists.txt
zypp/solver/detail/SolverQueueItem.cc
zypp/solver/detail/SolverQueueItem.h
zypp/solver/detail/SolverQueueItemDelete.cc
zypp/solver/detail/SolverQueueItemInstall.cc
zypp/solver/detail/SolverQueueItemLock.cc [new file with mode: 0644]
zypp/solver/detail/SolverQueueItemLock.h [new file with mode: 0644]
zypp/solver/detail/Types.h

index a5b6967..bc845f7 100644 (file)
@@ -494,6 +494,7 @@ SET( zypp_solver_detail_SRCS
   solver/detail/SolverQueueItemDelete.cc
   solver/detail/SolverQueueItemUpdate.cc
   solver/detail/SolverQueueItemInstallOneOf.cc
+  solver/detail/SolverQueueItemLock.cc
   solver/detail/SATResolver.cc
 )
 
@@ -515,6 +516,7 @@ SET( zypp_solver_detail_HEADERS
   solver/detail/SolverQueueItemDelete.h
   solver/detail/SolverQueueItemUpdate.h
   solver/detail/SolverQueueItemInstallOneOf.h
+  solver/detail/SolverQueueItemLock.h
   solver/detail/SATResolver.h
 )
 
index 68396c8..f3e5334 100644 (file)
@@ -43,9 +43,10 @@ SolverQueueItem::dumpOn( std::ostream & os ) const
 {
     switch (_type) {
       case QUEUE_ITEM_TYPE_UNKNOWN       :     os << "unknown"; break;
-      case QUEUE_ITEM_TYPE_UPDATE        :     os << "update"; break;    
+      case QUEUE_ITEM_TYPE_UPDATE        :     os << "update"; break;
+      case QUEUE_ITEM_TYPE_LOCK          :     os << "lock"; break;      
       case QUEUE_ITEM_TYPE_INSTALL       :     os << "install"; break;
-      case QUEUE_ITEM_TYPE_DELETE      :       os << "delete"; break;
+      case QUEUE_ITEM_TYPE_DELETE        :     os << "delete"; break;
       case QUEUE_ITEM_TYPE_INSTALL_ONE_OF:     os << "install one of"; break;    
       default: os << "?solverqueueitem?"; break;
     }
index dcebddb..bf43583 100644 (file)
@@ -52,7 +52,8 @@ typedef enum {
     QUEUE_ITEM_TYPE_UPDATE,    
     QUEUE_ITEM_TYPE_INSTALL,
     QUEUE_ITEM_TYPE_DELETE,
-    QUEUE_ITEM_TYPE_INSTALL_ONE_OF,    
+    QUEUE_ITEM_TYPE_INSTALL_ONE_OF,
+    QUEUE_ITEM_TYPE_LOCK    
 } SolverQueueItemType;
 
        
@@ -98,6 +99,7 @@ class SolverQueueItem : public base::ReferenceCounted, private base::NonCopyable
     bool isDelete (void) const { return _type == QUEUE_ITEM_TYPE_DELETE; }
     bool isInstall (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL; }
     bool isUpdate (void) const { return _type == QUEUE_ITEM_TYPE_UPDATE; }
+    bool isLock (void) const { return _type == QUEUE_ITEM_TYPE_LOCK; }    
     bool isInstallOneOf (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL_ONE_OF; }    
 
 
index 6defd1b..9ea6f7c 100644 (file)
@@ -65,12 +65,13 @@ SolverQueueItemDelete::~SolverQueueItemDelete()
 bool SolverQueueItemDelete::addRule (Queue & q, Pool *SATPool)
 {
     Id id = str2id( SATPool, _name.c_str(), 0 );
-    queue_push( &(q), SOLVER_ERASE_SOLVABLE_NAME );
+    if (_soft) {    
+       queue_push( &(q), SOLVER_ERASE_SOLVABLE_NAME | SOLVER_WEAK);
+    } else {
+       queue_push( &(q), SOLVER_ERASE_SOLVABLE_NAME ); 
+    }
     queue_push( &(q), id);
-    if (_soft) {
-       queue_push( &(q), SOLVER_WEAK );
-       queue_push( &(q), id);
-    }    
+
     MIL << "Delete " << _name << (_soft ? "(soft)" : "")
        << " with SAT-Pool: " << id << endl;    
     return true;
index 79dc989..f902327 100644 (file)
@@ -66,12 +66,13 @@ SolverQueueItemInstall::~SolverQueueItemInstall()
 bool SolverQueueItemInstall::addRule (Queue & q, Pool *SATPool)
 {
     Id id = str2id( SATPool, _name.c_str(), 0 );
-    queue_push( &(q), SOLVER_INSTALL_SOLVABLE_NAME );
-    queue_push( &(q), id);
-    if (_soft) {
-       queue_push( &(q), SOLVER_WEAK );
-       queue_push( &(q), id);
+    if (_soft) {    
+       queue_push( &(q), SOLVER_INSTALL_SOLVABLE_NAME | SOLVER_WEAK  );
+    } else {
+       queue_push( &(q), SOLVER_INSTALL_SOLVABLE_NAME );
     }
+    queue_push( &(q), id);
+
     MIL << "Install " << _name << (_soft ? "(soft)" : "")
        << " with SAT-Pooly: " << id << endl;        
     return true;
diff --git a/zypp/solver/detail/SolverQueueItemLock.cc b/zypp/solver/detail/SolverQueueItemLock.cc
new file mode 100644 (file)
index 0000000..506e20f
--- /dev/null
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* SolverQueueItem.cc
+ *
+ * Copyright (C) 2008 SUSE Linux Products GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "zypp/base/Logger.h"
+#include "zypp/solver/detail/SolverQueueItemLock.h"
+
+/////////////////////////////////////////////////////////////////////////
+namespace zypp 
+{ ///////////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////////
+  namespace solver
+  { /////////////////////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////////////////////
+    namespace detail
+    { ///////////////////////////////////////////////////////////////////
+
+using namespace std;
+
+IMPL_PTR_TYPE(SolverQueueItemLock);
+
+//---------------------------------------------------------------------------
+
+std::ostream &
+SolverQueueItemLock::dumpOn( std::ostream & os ) const
+{
+    os << "[" << (_soft?"Soft":"") << "Lock: " <<
+       _item << "]";
+
+    return os;
+}
+
+//---------------------------------------------------------------------------
+
+SolverQueueItemLock::SolverQueueItemLock (const ResPool & pool,
+                                             const PoolItem & item, bool soft)
+    : SolverQueueItem (QUEUE_ITEM_TYPE_LOCK, pool)
+    , _item (item)
+    , _soft (soft)
+{
+}
+
+
+SolverQueueItemLock::~SolverQueueItemLock()
+{
+}
+
+//---------------------------------------------------------------------------
+
+bool SolverQueueItemLock::addRule (Queue & q, Pool *SATPool)
+{
+    Id id = _item.satSolvable().id();
+    if (id == ID_NULL) {
+       ERR << "Lock : " << _item << " not found" << endl;
+       return false;
+    }
+    MIL << "Lock " << _item << " with the SAT-Pool ID: " << id << endl;
+    if (_item.status().isInstalled()) {    
+       if (_soft) {    
+           queue_push( &(q), SOLVER_INSTALL_SOLVABLE | SOLVER_WEAK );
+       } else {
+           queue_push( &(q), SOLVER_INSTALL_SOLVABLE );        
+       }
+    } else {
+       if (_soft) {    
+           queue_push( &(q), SOLVER_ERASE_SOLVABLE | SOLVER_WEAK );
+       } else {
+           queue_push( &(q), SOLVER_ERASE_SOLVABLE );  
+       }       
+    }
+    queue_push( &(q), id );    
+    return true;
+}
+
+SolverQueueItem_Ptr
+SolverQueueItemLock::copy (void) const
+{
+    SolverQueueItemLock_Ptr new_lock = new SolverQueueItemLock (pool(), _item);
+    new_lock->SolverQueueItem::copy(this);
+
+    new_lock->_soft = _soft;
+    return new_lock;
+}
+
+int
+SolverQueueItemLock::cmp (SolverQueueItem_constPtr item) const
+{
+    int cmp = this->compare (item);
+    if (cmp != 0)
+        return cmp;
+    SolverQueueItemLock_constPtr lock = dynamic_pointer_cast<const SolverQueueItemLock>(item);
+    return compareByNVRA (_item.resolvable(), lock->_item.resolvable());
+}
+
+
+//---------------------------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////////////
+    };// namespace detail
+    /////////////////////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////////////////////
+  };// namespace solver
+  ///////////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////////
+};// namespace zypp
+/////////////////////////////////////////////////////////////////////////
diff --git a/zypp/solver/detail/SolverQueueItemLock.h b/zypp/solver/detail/SolverQueueItemLock.h
new file mode 100644 (file)
index 0000000..eb5fe97
--- /dev/null
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* QueueItem.h
+ *
+ * Copyright (C) 2008 SUSE Linux Products GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef ZYPP_SOLVER_DETAIL_QUEUEITEMLOCK_H
+#define ZYPP_SOLVER_DETAIL_QUEUEITEMLOCK_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/solver/detail/SolverQueueItem.h"
+#include "zypp/PoolItem.h"
+
+/////////////////////////////////////////////////////////////////////////
+namespace zypp
+{ ///////////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////////
+  namespace solver
+  { /////////////////////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////////////////////
+    namespace detail
+    { ///////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+//     CLASS NAME : SolverQueueItemLock
+
+class SolverQueueItemLock : public SolverQueueItem {
+    
+  private:
+
+    PoolItem _item;    // the item to-be-locked
+    bool _soft;         // if triggered by a soft requirement (a recommends)
+
+  public:
+
+    SolverQueueItemLock (const ResPool & pool, const PoolItem & item, bool soft = false);
+    virtual ~SolverQueueItemLock();
+    
+    // ---------------------------------- I/O
+
+    virtual std::ostream & dumpOn( std::ostream & str ) const;
+
+    friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemLock & obj)
+    { return obj.dumpOn (str); }
+
+    // ---------------------------------- accessors
+
+    bool isSoft (void) const { return _soft; }    
+
+    // ---------------------------------- methods
+    
+    virtual bool addRule (Queue & q, Pool *SATPool);
+    virtual SolverQueueItem_Ptr copy (void) const;
+    virtual int cmp (SolverQueueItem_constPtr item) const;
+};
+
+///////////////////////////////////////////////////////////////////
+    };// namespace detail
+    /////////////////////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////////////////////
+  };// namespace solver
+  ///////////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////////
+};// namespace zypp
+/////////////////////////////////////////////////////////////////////////
+
+#endif // ZYPP_SOLVER_DETAIL_QUEUEITEMLOCK_H
index 8bb9b4b..e50f351 100644 (file)
@@ -62,7 +62,8 @@ DEFINE_PTR_TYPE(SolverQueueItem);
 DEFINE_PTR_TYPE(SolverQueueItemUpdate);
 DEFINE_PTR_TYPE(SolverQueueItemDelete);
 DEFINE_PTR_TYPE(SolverQueueItemInstall);       
-DEFINE_PTR_TYPE(SolverQueueItemInstallOneOf);  
+DEFINE_PTR_TYPE(SolverQueueItemInstallOneOf);
+DEFINE_PTR_TYPE(SolverQueueItemLock);          
       
       ///////////////////////////////////////////////////////////////////
     };// namespace detail