Imported Upstream version 17.21.0
[platform/upstream/libzypp.git] / zypp / ui / SelectableImpl.h
index 29b3e91..01de374 100644 (file)
@@ -109,9 +109,9 @@ namespace zypp
       PoolItem candidateObj() const
       {
         PoolItem ret( transactingCandidate() );
-        if ( ret )
-          return ret;
-        return _candidate ? _candidate : defaultCandidate();
+        if ( ret )
+         ret = _candidate ? _candidate : defaultCandidate();
+       return ret;
       }
 
       /** Set a userCandidate (out of available objects).
@@ -129,6 +129,8 @@ namespace zypp
       {
         for ( const PoolItem & pi : available() )
         {
+         if ( pi.isRetracted() )
+           continue;
           if ( pi.repository() == repo_r )
             return pi;
         }
@@ -148,7 +150,10 @@ namespace zypp
        // multiversionInstall: This returns the candidate for the last
        // instance installed. Actually we'd need a list here.
 
-        if ( installedEmpty() || ! defaultCand )
+       if ( ! defaultCand || defaultCand.isRetracted() )
+         return PoolItem();
+
+        if ( installedEmpty() )
           return defaultCand;
         // Here: installed and defaultCand are non NULL and it's not a
         //       multiversion install.
@@ -175,8 +180,15 @@ namespace zypp
       PoolItem highestAvailableVersionObj() const
       {
         PoolItem ret;
+       bool retractedOk = false;
         for ( const PoolItem & pi : available() )
         {
+         if ( !retractedOk && pi.isRetracted() )
+         {
+           if ( ret )
+             break;    // prefer a not retracted candidate
+           retractedOk = true;
+         }
           if ( !ret || pi.edition() > ret.edition() )
             ret = pi;
         }
@@ -298,6 +310,32 @@ namespace zypp
 
       ////////////////////////////////////////////////////////////////////////
 
+      bool hasRetracted() const
+      { return !_availableItems.empty() && _availableItems.rbegin()->isRetracted(); }
+
+      bool hasRetractedInstalled() const
+      {
+       bool ret = false;
+       if ( hasRetracted() )
+       {
+         for ( const PoolItem & ipi : installed() )
+         {
+           PoolItem pi { identicalAvailableObj( ipi ) };
+           if ( pi && pi.isRetracted() )
+           {
+             ret = true;
+             break;
+           }
+         }
+       }
+       return ret;
+// later if pool index is available:
+//     for ( const PoolItem & pi : installed() )
+//       if ( pi.isRetracted() )
+//         return true;
+//     return false;
+      }
+
       bool isUnmaintained() const
       { return availableEmpty(); }