- remove Arch::system, move it to Resolver
authorKlaus Kaempf <kkaempf@suse.de>
Tue, 7 Feb 2006 20:38:28 +0000 (20:38 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Tue, 7 Feb 2006 20:38:28 +0000 (20:38 +0000)
- make Arch::isCompatibleWith compatible with itself
- filter out 'src' when iterating the pool
- fix the install/uninstall/upgrade counting

23 files changed:
zypp/Arch.cc
zypp/Arch.h
zypp/Makefile.am
zypp/Resolver.cc
zypp/Resolver.h
zypp/solver/detail/Helper.cc
zypp/solver/detail/InstallOrder.cc
zypp/solver/detail/QueueItemConflict.cc
zypp/solver/detail/QueueItemInstall.cc
zypp/solver/detail/QueueItemRequire.cc
zypp/solver/detail/QueueItemUninstall.cc
zypp/solver/detail/Resolver.cc
zypp/solver/detail/Resolver.h
zypp/solver/detail/ResolverContext.cc
zypp/solver/detail/ResolverContext.h
zypp/solver/detail/ResolverInfoChildOf.cc
zypp/solver/detail/ResolverInfoConflictsWith.cc
zypp/solver/detail/ResolverInfoDependsOn.cc
zypp/solver/detail/ResolverInfoNeededBy.cc
zypp/solver/detail/ResolverInfoObsoletes.cc
zypp/solver/detail/ResolverQueue.cc
zypp/solver/detail/ResolverQueue.h
zypp/solver/detail/ResolverUpgrade.cc

index 786c11c..c1fd2a6 100644 (file)
@@ -11,7 +11,6 @@
 */
 #include <iostream>
 #include <set>
-#include <sys/utsname.h>
 
 #include "zypp/Arch.h"
 
@@ -110,12 +109,8 @@ namespace zypp
 
 #undef DEF_BUILTIN
 
- static const string system_arch (void);
  static const string canonical_arch (const string & arch);
 
-    
-  const Arch Arch::System = Arch(system_arch ());
-      
  //---------------------------------------------------------------------------
  // architecture stuff
       
@@ -127,7 +122,7 @@ namespace zypp
      static canonical canonical_archs[] = {
         { "noarch",  "noarch" },
         { "unknown", "unknown" },
-        { "any",        "any" },
+        { "any",     "any" },
         { "all",     "any" },
         { "i386",    "i386" },
         { "ix86",    "i386" }, /* OpenPKG uses this */
@@ -161,27 +156,7 @@ namespace zypp
      return "canonical";
  }
       
-      
- static const string
- system_arch (void)
- {
-     static struct utsname buf;
-     static bool checked = false;
-      
-     if (!checked) {
-        if (uname (&buf) < 0) {
-            return NULL;
-        }
-        checked = true;
-     }
-      
-     return string (buf.machine);
- }
-      
-      
- //---------------------------------------------------------------------------
-
-
+//---------------------------------------------------------------------------
     
   ///////////////////////////////////////////////////////////////////
 
@@ -201,7 +176,9 @@ namespace zypp
   //
   bool Arch::compatibleWith( const Arch & rhs ) const
   {
-    return CompatTable::compatible( *this, rhs );
+    return _value.empty()
+       || *this == rhs
+       || CompatTable::compatible( *this, rhs );
   }
 
   /////////////////////////////////////////////////////////////////
index 0e2223e..d4cc421 100644 (file)
@@ -55,13 +55,6 @@ namespace zypp
     int compare( const Arch & rhs ) const
     { return _value.compare( rhs._value ); }
 
-    /** Architecture of the current working system
-     * \return \c Arch.
-     * \todo Eliminate this, it's not task of a data type to
-     * detect and define what the system architecture is.
-    */
-    static const Arch System;
-
   private:
     /** String representation of Arch. */
     std::string _value;
index b02fc60..53114c4 100644 (file)
@@ -140,6 +140,7 @@ lib@PACKAGE@_la_SOURCES = \
        TranslatedText.cc \
        ZYppFactory.cc
 
+
 lib@PACKAGE@_la_LDFLAGS =      @LIBZYPP_VERSION_INFO@
 
 lib@PACKAGE@_la_LIBADD =        base/lib@PACKAGE@_base.la      \
index 162aedb..8b19370 100644 (file)
@@ -70,6 +70,10 @@ namespace zypp
   { return _pimpl->applySolutions (solutions); }      
   void Resolver::doUpgrade( UpgradeStatistics & opt_stats_r )
   { return _pimpl->doUpgrade(opt_stats_r); }
+  Arch Resolver::architecture() const
+  { return _pimpl->architecture(); }
+  void Resolver::setArchitecture( const Arch & arch )
+  { _pimpl->setArchitecture( arch ); }
 
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
index 9c66e3c..d86d44b 100644 (file)
@@ -112,6 +112,9 @@ namespace zypp
      **/
     bool applySolutions( const ProblemSolutionList & solutions );
 
+    Arch architecture() const;
+    void setArchitecture( const Arch & arch);
+
   protected:
 
   private:
index 50548c3..183a43e 100644 (file)
@@ -86,7 +86,7 @@ Helper::findInstalledByNameAndKind (const ResPool & pool, const string & name, c
        ResPool::const_nameiterator pend = pool.nameend(name);
        for (ResPool::const_nameiterator it = pool.namebegin(name); it != pend; ++it) {
            PoolItem item = it->second;
-           if (item.status().staysInstalled()
+           if (item.status().isInstalled()
                && item->kind() == kind) {
                if (!info( it->second ))
                    break;
index 87579b7..7b0fbb4 100644 (file)
@@ -269,6 +269,8 @@ InstallOrder::rdfsvisit (const PoolItem_Ref  item)
 #endif
        ResPool::const_indexiterator pend = _pool.providesend(requirement.index());
        for (ResPool::const_indexiterator it = _pool.providesbegin(requirement.index()); it != pend; ++it) {
+           if (it->second.second->arch() == Arch_src)
+               continue;
            if (requirement.matches (it->second.first) == CapMatch::yes) {
                if (!info( it->second.second, it->second.first))
                    break;
index 81305c5..d4e1fc2 100644 (file)
@@ -220,6 +220,8 @@ struct ConflictProcess : public resfilter::OnCapMatchCallbackFunctor
 #endif
        ResPool::const_indexiterator pend = pool.providesend(maybe_upgrade_cap.index());
        for (ResPool::const_indexiterator it = pool.providesbegin(maybe_upgrade_cap.index()); it != pend; ++it) {
+           if (it->second.second->arch() == Arch_src)
+               continue;
            if (maybe_upgrade_cap.matches (it->second.first) == CapMatch::yes) {
                if (!upgrade_info( it->second.second, it->second.first))
                    break;
index 48b2711..e5d13f6 100644 (file)
@@ -368,6 +368,9 @@ QueueItemInstall::process (ResolverContext_Ptr context, QueueItemList & qil)
 
            ResPool::const_indexiterator cend = pool().conflictsend(cap.index());
            for (ResPool::const_indexiterator it = pool().conflictsbegin(cap.index()); it != cend; ++it) {
+               if (it->second.second->arch() == Arch_src)
+                   continue;
+
                if (cap.matches (it->second.first) == CapMatch::yes) {
                    // conflicting item found
                    PoolItem_Ref conflicting_item = it->second.second;
index 1c655b9..12fdde4 100644 (file)
@@ -175,6 +175,11 @@ struct RequireProcess : public resfilter::OnCapMatchCallbackFunctor
            return true;
        }
 
+       if (!provider->arch().compatibleWith( context->architecture() )) {
+           MIL << "provider " << provider << " has incompatible arch '" << provider->arch() << "'" << endl;
+           return true;
+       }
+
        if (! (status.isToBeUninstalled() || status.isImpossible())
            && ! context->isParallelInstall (provider)
            && ! uniq.has(provider)
@@ -312,6 +317,8 @@ QueueItemRequire::process (ResolverContext_Ptr context, QueueItemList & new_item
        // world->foreachProvidingResItem (_capability, require_process_cb, &info);
        ResPool::const_indexiterator pend = pool().providesend(_capability.index());
        for (ResPool::const_indexiterator it = pool().providesbegin(_capability.index()); it != pend; ++it) {
+           if (it->second.second->arch() == Arch_src)
+               continue;
            if (_capability.matches (it->second.first) == CapMatch::yes) {
                if (!info( it->second.second, it->second.first))
                    break;
@@ -375,12 +382,23 @@ QueueItemRequire::process (ResolverContext_Ptr context, QueueItemList & new_item
            // Maybe we can add some extra info on why none of the providers are suitable.
 
            // pool()->foreachProvidingResItem (_capability, no_installable_providers_info_cb, (void *)&info);
-
+#if 0
            Dep dep( Dep::PROVIDES );
 
            invokeOnEach( pool().byCapabilityIndexBegin( _capability.index(), dep ), // begin()
                          pool().byCapabilityIndexEnd( _capability.index(), dep ),   // end()
                          resfilter::callOnCapMatchIn( dep, _capability, functor::functorRef<bool,PoolItem,Capability>(info)) );
+#endif
+               // world->foreachProvidingResItem (_capability, require_process_cb, &info);
+               ResPool::const_indexiterator pend = pool().providesend(_capability.index());
+               for (ResPool::const_indexiterator it = pool().providesbegin(_capability.index()); it != pend; ++it) {
+                   if (it->second.second->arch() == Arch_src)
+                       continue;
+                   if (_capability.matches (it->second.first) == CapMatch::yes) {
+                       if (!info( it->second.second, it->second.first))
+                           break;
+                   }
+               }
 
        }
 
@@ -398,8 +416,7 @@ QueueItemRequire::process (ResolverContext_Ptr context, QueueItemList & new_item
 #if 0  // **!!!** re-enable editon check in LookForUpgrades()
 
            invokeOnEach( pool().byNameBegin( _requiring_item->name() ), pool().byNameEnd( _requiring_item->name() ),
-                         functor::chain( resfilter::ByUninstalled(),
-                                         resfilter::ByKind( _requiring_item->kind() ) ),
+                         resfilter::ByKind( _requiring_item->kind() ),
 #if 0
        // CompareByGT is broken                  resfilter::byEdition<CompareByGT<Edition> >( _requiring_item->edition() )),
 #endif
@@ -408,8 +425,7 @@ QueueItemRequire::process (ResolverContext_Ptr context, QueueItemList & new_item
        ResPool::const_nameiterator pend = pool().nameend(_requiring_item->name());
        for (ResPool::const_nameiterator it = pool().namebegin(_requiring_item->name()); it != pend; ++it) {
            PoolItem pos = it->second;
-           if (pos.status().staysUninstalled()
-               && pos->kind() == _requiring_item->kind()
+           if (pos->kind() == _requiring_item->kind()
                && _requiring_item->edition().compare(pos->edition()) < 0)
            {
                if (!info( pos ))
index c832ca4..2a70586 100644 (file)
@@ -188,7 +188,7 @@ struct UninstallProcess: public resfilter::OnCapMatchCallbackFunctor
        if (context->requirementIsMet (match, false))                   // its provided by another installed resolvable -> dont care
            return true;
 
-       if (requirer.status().isSatisfied()) {                  // it is just satisfied, check freshens
+       if (context->getStatus(requirer).isSatisfied()) {               // it is just satisfied, check freshens
 #warning If an uninstall incompletes a satisfied, the uninstall should be cancelled
            QueueItemEstablish_Ptr establish_item = new QueueItemEstablish (pool, requirer, soft);      // re-check if its still needed
            qil.push_back (establish_item);
@@ -264,6 +264,8 @@ QueueItemUninstall::process (ResolverContext_Ptr context, QueueItemList & qil)
        Capability c = *iter;
        ResPool::const_indexiterator rend = pool().requiresend(c.index());
        for (ResPool::const_indexiterator it = pool().requiresbegin(c.index()); it != rend; ++it) {
+           if (it->second.second->arch() == Arch_src)
+               continue;
            if (c.matches (it->second.first) == CapMatch::yes) {
                if (!info( it->second.second, it->second.first))
                    break;
@@ -330,6 +332,8 @@ QueueItemUninstall::process (ResolverContext_Ptr context, QueueItemList & qil)
        Capability c = *iter;
        ResPool::const_indexiterator rend = pool().requiresend(c.index());
        for (ResPool::const_indexiterator it = pool().requiresbegin(c.index()); it != rend; ++it) {
+           if (it->second.second->arch() == Arch_src)
+               continue;
            if (c.matches (it->second.first) == CapMatch::yes) {
                if (!info( it->second.second, it->second.first))
                    break;
index 30c7548..cbb209b 100644 (file)
@@ -19,6 +19,8 @@
  * 02111-1307, USA.
  */
 
+#include <sys/utsname.h>
+
 #include "zypp/solver/detail/Resolver.h"
 #include "zypp/solver/detail/Helper.h"
 
@@ -64,6 +66,14 @@ Resolver::Resolver (const ResPool & pool)
     , _best_context (NULL)
     , _timed_out (false)
 {
+    struct utsname buf;
+    if (uname (&buf) < 0) {
+       ERR << "Can't determine system architecture" << endl;
+    }
+    else {
+       MIL << "System architecture is '" << buf.machine << "'" << endl;
+       _architecture = Arch(buf.machine);
+    }
 }
 
 
@@ -350,7 +360,7 @@ Resolver::establishState (ResolverContext_Ptr context)
     }
 
     if (context == NULL)
-       context = new ResolverContext(_pool);
+       context = new ResolverContext(_pool, _architecture);
 
     context->setEstablishing (true);
 
@@ -443,7 +453,7 @@ Resolver::resolveDependencies (const ResolverContext_Ptr context)
 
     // create initial_queue
 
-    ResolverQueue_Ptr initial_queue = new ResolverQueue(_pool, context);
+    ResolverQueue_Ptr initial_queue = new ResolverQueue(_pool, _architecture, context);
 
     /* If this is a verify, we do a "soft resolution" */
 
@@ -650,7 +660,7 @@ Resolver::resolvePool ()
 {
 
     CollectTransact info (*this);
-#if 0
+#if 1
     MIL << "Resolver::resolvePool()" << endl;
     MIL << "Pool before resolve" << endl;
     MIL << "---------------------------------------" << endl;
@@ -669,7 +679,7 @@ Resolver::resolvePool ()
        MIL << "Have solution, copying back to pool" << endl;
        ResolverContext_Ptr solution = bestContext();
        solution->foreachMarked (solution_to_pool, NULL);
-#if 0
+#if 1
        MIL << "Pool after resolve" << endl;
        MIL << "---------------------------------------" << endl;
        for (ResPool::const_iterator it = _pool.begin(); it != _pool.end(); ++it) {
index 29988b0..8f1725b 100644 (file)
@@ -99,6 +99,8 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable {
 
     std::set<Source_Ref> _subscribed;
 
+    Arch _architecture;
+
     // helpers
     bool doesObsoleteCapability (PoolItem_Ref candidate, const Capability & cap);
     bool doesObsoleteItem (PoolItem_Ref candidate, PoolItem_Ref installed);
@@ -172,6 +174,9 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable {
     bool applySolutions (const ProblemSolutionList &solutions);
 
     void reset (void);
+
+    Arch architecture() const { return _architecture; }
+    void setArchitecture( const Arch & arch) { _architecture = arch; }
 };
 
 ///////////////////////////////////////////////////////////////////
index 6082200..7af6295 100644 (file)
@@ -72,7 +72,7 @@ operator<<( ostream& os, const ResolverContext & context)
 
 //---------------------------------------------------------------------------
 
-ResolverContext::ResolverContext (const ResPool & pool, ResolverContext_Ptr parent)
+ResolverContext::ResolverContext (const ResPool & pool, const Arch & arch, ResolverContext_Ptr parent)
     : _parent (parent)
     , _pool (pool)
     , _download_size (0)
@@ -84,6 +84,7 @@ ResolverContext::ResolverContext (const ResPool & pool, ResolverContext_Ptr pare
     , _verifying (false)
     , _establishing (false)
     , _invalid (false)
+    , _architecture(arch)
 {
 _DEBUG( "ResolverContext[" << this << "]::ResolverContext(" << parent << ")" );
     if (parent != NULL) {
@@ -131,9 +132,15 @@ _XDEBUG( "[" << context << "]:" << it->second );
        }
        context = context->_parent;                     // N: go up the chain
     }
-    _last_checked_status = item.status();
-_XDEBUG( "[NULL]:" << item.status() );
-    return item.status();                              // Not part of context, return Pool status
+    ResStatus status;
+    if (item.status().isInstalled())
+       status = ResStatus::installed;
+    else
+       status = ResStatus::uninstalled;
+
+    _last_checked_status = status;
+_XDEBUG( "[NULL]:" << status );
+    return status;                             // Not part of context, return Pool status
 }
 
 
@@ -273,14 +280,14 @@ ResolverContext::upgrade (PoolItem_Ref item, PoolItem_Ref old_item, bool is_soft
        setStatus (item, ResStatus::toBeInstalled);
     }
 
-    if (old_item.status().wasUninstalled()) {
-       Resolvable::constPtr res = old_item.resolvable();
-       Package::constPtr pkg = asKind<Package>(res);                   // try to access it as a package
-       if (pkg) {                                                      // if its !=NULL, get size information
+    Resolvable::constPtr res = old_item.resolvable();
+    Package::constPtr pkg = asKind<Package>(res);                      // try to access it as a package
+    if (pkg) {                                                 // if its !=NULL, get size information
 
-           _install_size -= pkg->size();
-       }
+       _install_size -= pkg->size();
+    }
 
+    if (status == ResStatus::uninstalled) {
        res = item.resolvable();
        pkg = asKind<Package>(res);                                     // try to access it as a package
        if (pkg) {                                                      // if its !=NULL, get size information
@@ -304,7 +311,6 @@ ResolverContext::upgrade (PoolItem_Ref item, PoolItem_Ref old_item, bool is_soft
 
        _other_penalties += other_penalty;
     }
-
     return true;
 }
 
@@ -540,12 +546,15 @@ typedef struct {
 } InstallInfo;
 
 static void
-install_pkg_cb (PoolItem_Ref item, const ResStatus & status, void *data)
+install_item_cb (PoolItem_Ref item, const ResStatus & status, void *data)
 {
     InstallInfo *info = (InstallInfo *)data;
+MIL << "install_item_cb " << item << ": " << status << endl;
     if (status.isToBeInstalled()
+       && !item.status().isInstalled()
        && !Helper::findInstalledItem( info->pool, item))
     {
+MIL << "install !" << endl;
        if (info->fn) info->fn (item, status, info->rl);
        ++info->count;
     }
@@ -558,7 +567,7 @@ ResolverContext::foreachInstall (MarkedPoolItemFn fn, void *data) const
     PoolItemList *rl = (PoolItemList *)data;
     InstallInfo info = { _pool, fn, rl, 0 };
 
-    foreachMarked (install_pkg_cb, (void *)&info);
+    foreachMarked (install_item_cb, (void *)&info);
 
     return info.count;
 }
@@ -598,7 +607,7 @@ typedef struct {
 } SatisfyInfo;
 
 static void
-satisfy_pkg_cb (PoolItem_Ref item, const ResStatus & status, void *data)
+satisfy_item_cb (PoolItem_Ref item, const ResStatus & status, void *data)
 {
     SatisfyInfo *info = (SatisfyInfo *)data;
     if (status.isSatisfied()
@@ -617,7 +626,7 @@ ResolverContext::foreachSatisfy (MarkedPoolItemFn fn, void *data) const
     PoolItemList *rl = (PoolItemList *)data;
     SatisfyInfo info = { _pool, fn, rl, 0 };
 
-    foreachMarked (satisfy_pkg_cb, (void *)&info);
+    foreachMarked (satisfy_item_cb, (void *)&info);
 
     return info.count;
 }
@@ -656,7 +665,7 @@ typedef struct {
 } IncompleteInfo;
 
 static void
-incomplete_pkg_cb (PoolItem_Ref item, const ResStatus & status, void *data)
+incomplete_item_cb (PoolItem_Ref item, const ResStatus & status, void *data)
 {
     IncompleteInfo *info = (IncompleteInfo *)data;
 
@@ -673,7 +682,7 @@ ResolverContext::foreachIncomplete (MarkedPoolItemFn fn, void *data) const
     PoolItemList *rl = (PoolItemList *)data;
     IncompleteInfo info = { _pool, fn, rl, 0 };
 
-    foreachMarked (incomplete_pkg_cb, (void *)&info);
+    foreachMarked (incomplete_item_cb, (void *)&info);
 
     return info.count;
 }
@@ -713,18 +722,21 @@ typedef struct {
 } UpgradeInfo;
 
 static void
-upgrade_pkg_cb (PoolItem_Ref item, const ResStatus & status, void *data)
+upgrade_item_cb (PoolItem_Ref item, const ResStatus & status, void *data)
 {
     UpgradeInfo *info = (UpgradeInfo *)data;
 
     PoolItem_Ref to_be_upgraded;
 
+MIL << "upgrade_item_cb " << item << ": " << status << endl;
     if (status.isToBeInstalled()
-       && ! status.staysInstalled ())
+       && ! item.status().isInstalled ())
     {
+MIL << "upgrade_item_cb which ?" << endl;
 
        to_be_upgraded = Helper::findInstalledItem(info->pool, item);
        if (to_be_upgraded) {
+MIL << "upgrade_item_cb ! " << to_be_upgraded << endl;
            if (info->fn) {
                info->fn (item, status, to_be_upgraded, info->context->getStatus(to_be_upgraded), info->data);
            }
@@ -739,7 +751,7 @@ ResolverContext::foreachUpgrade (MarkedPoolItemPairFn fn, void *data)
 {
     UpgradeInfo info = { _pool, fn, data, this, 0 };
 
-    foreachMarked (upgrade_pkg_cb, (void *)&info);
+    foreachMarked (upgrade_item_cb, (void *)&info);
 
     return info.count;
 }
@@ -777,15 +789,17 @@ typedef struct {
 } UninstallInfo;
 
 static void
-uninstall_pkg_cb (PoolItem_Ref item, const ResStatus & status, void *data)
+uninstall_item_cb (PoolItem_Ref item, const ResStatus & status, void *data)
 {
     UninstallInfo *info = (UninstallInfo *)data;
 
+MIL << "uninstall_item_cb " << item << ": " << status << endl;
     UpgradeTable::const_iterator pos = info->upgrade_hash.find(item->name());
 
     if (status.isToBeUninstalled ()
        && pos == info->upgrade_hash.end())             // dont count upgrades
     {
+MIL << "uninstall_item_cb! " << endl;
        if (info->fn)
            info->fn (item, status, info->rl);
        ++info->count;
@@ -811,7 +825,7 @@ ResolverContext::foreachUninstall (MarkedPoolItemFn fn, void *data)
     info.count = 0;
 
     foreachUpgrade (build_upgrade_hash_cb, (void *)&(info.upgrade_hash));
-    foreachMarked (uninstall_pkg_cb, (void *)&info);
+    foreachMarked (uninstall_item_cb, (void *)&info);
 
     return info.count;
 }
@@ -839,7 +853,7 @@ typedef struct {
 } ImpossibleInfo;
 
 static void
-impossible_pkg_cb (PoolItem_Ref item, const ResStatus & status, void *data)
+impossible_item_cb (PoolItem_Ref item, const ResStatus & status, void *data)
 {
     ImpossibleInfo *info = (ImpossibleInfo *)data;
 
@@ -855,7 +869,7 @@ ResolverContext::foreachImpossible (MarkedPoolItemFn fn, void *data)
 {
     ImpossibleInfo info = { _pool, fn, 0, data };
 
-    foreachMarked (impossible_pkg_cb, (void *)&info);
+    foreachMarked (impossible_item_cb, (void *)&info);
 
     return info.count;
 }
@@ -867,7 +881,7 @@ static void
 install_count_cb (PoolItem_Ref item, const ResStatus & status, void *data)
 {
     int *count = (int *)data;
-    if (item.status().wasUninstalled ()) {
+    if (!item.status().isInstalled ()) {
        ++*count;
     }
 }
@@ -887,7 +901,7 @@ static void
 uninstall_count_cb (PoolItem_Ref item, const ResStatus & status, void *data)
 {
     int *count = (int *)data;
-    if (item.status().wasInstalled ()) {
+    if (item.status().isInstalled ()) {
        ++*count;
     }
 }
@@ -915,7 +929,7 @@ static void
 satisfy_count_cb (PoolItem_Ref item, const ResStatus & status, void *data)
 {
     int *count = (int *)data;
-    if (item.status().wasUninstalled ()) {
+    if (!item.status().isInstalled ()) {
        ++*count;
     }
 }
index c3d9d92..3007849 100644 (file)
@@ -79,8 +79,10 @@ class ResolverContext : public base::ReferenceCounted, private base::NonCopyable
     PoolItem_Ref _last_checked_item;           // cache for {get,set}Status
     ResStatus _last_checked_status;
 
+    Arch _architecture;
+
   public:
-    ResolverContext (const ResPool & pool, ResolverContext_Ptr parent = NULL);
+    ResolverContext (const ResPool & pool, const Arch & arch, ResolverContext_Ptr parent = NULL);
     virtual ~ResolverContext();
 
     // ---------------------------------- I/O
@@ -107,6 +109,8 @@ class ResolverContext : public base::ReferenceCounted, private base::NonCopyable
 
     inline ResPool pool() const { return _pool; }
 
+    inline Arch architecture() const { return _architecture; }
+
     // ---------------------------------- methods
 
     /**
index 39ec44d..d3afbbb 100644 (file)
@@ -64,7 +64,7 @@ string
 ResolverInfoChildOf::message( ) const
 {
     string affected_str = ResolverInfo::toString(affected());
-    string container_str = itemsToString( false );
+    string container_str = itemsToString( true );
 
     // TranslatorExplanation: 1.%s name of package, 2.%s list of names
     // TranslatorExplanation: 1.%s is part of 'bundles', the bundles are listed in 2.%s
index 5e57d39..9ae3aaf 100644 (file)
@@ -63,7 +63,7 @@ string
 ResolverInfoConflictsWith::message( ) const
 {
     string affected_str = ResolverInfo::toString(affected());
-    string container_str = itemsToString( false );
+    string container_str = itemsToString( true );
 
     // TranslatorExplanation: 1.%s name of package, 2.%s list of names
     // TranslatorExplanation: 1.%s is conflicting with multiple others
index 75398f9..9c9fc49 100644 (file)
@@ -62,7 +62,7 @@ string
 ResolverInfoDependsOn::message( ) const
 {
     string affected_str = ResolverInfo::toString(affected());
-    string container_str = itemsToString( false );
+    string container_str = itemsToString( true );
 
     // TranslatorExplanation: 1.%s name of package, 2.%s list of names
     // TranslatorExplanation: 1.%s is dependent on list of names
index 99ecd5d..30f6e33 100644 (file)
@@ -55,7 +55,7 @@ ResolverInfoNeededBy::dumpOn( std::ostream & os ) const
          // Translator: all.%s = name of package,patch,...
     os << str::form (_("%s is needed by %s"),
                            affected_str.str().c_str(),
-                           itemsToString(false).c_str());
+                           itemsToString(true).c_str());
     return os;
 }
 
index 802c22e..2b60e00 100644 (file)
@@ -54,7 +54,7 @@ ResolverInfoObsoletes::dumpOn( std::ostream & os ) const
     // Translator: all.%s = name of package,patch,....
     os << str::form (_("%s is replaced by %s"),
                           affected_str.str().c_str(),
-                          itemsToString(false).c_str());
+                          itemsToString(true).c_str());
     return os;
 }
 
index 54a46f4..8d0bdfd 100644 (file)
@@ -64,12 +64,12 @@ operator<<( ostream& os, const ResolverQueue & resolverqueue)
 
 //---------------------------------------------------------------------------
 
-ResolverQueue::ResolverQueue (const ResPool & pool, ResolverContext_Ptr context)
+ResolverQueue::ResolverQueue (const ResPool & pool, const Arch & arch, ResolverContext_Ptr context)
     : _context (context)
 {
     _DEBUG("ResolverQueue::ResolverQueue(pool, " << context << ")");
     if (context == NULL)
-       _context = new ResolverContext(pool);
+       _context = new ResolverContext(pool, arch);
 }
 
 
@@ -293,16 +293,16 @@ ResolverQueue::process ()
 
 //---------------------------------------------------------------------------
 
-static ResolverQueue_Ptr
-copy_queue_except_for_branch (ResolverQueue_Ptr queue, QueueItem_Ptr branch_qitem, QueueItem_Ptr subqitem)
+ResolverQueue_Ptr
+ResolverQueue::copy_queue_except_for_branch (QueueItem_Ptr branch_qitem, QueueItem_Ptr subqitem) const
 {
     ResolverContext_Ptr new_context;
     ResolverQueue_Ptr new_queue;
     _DEBUG("copy_queue_except_for_branch");
-    new_context = new ResolverContext (queue->context()->pool(), queue->context());
-    new_queue = new ResolverQueue (new_context->pool(), new_context);
+    new_context = new ResolverContext (_context->pool(), _context->architecture(), _context);
+    new_queue = new ResolverQueue (new_context->pool(), new_context->architecture(), new_context);
 
-    QueueItemList qil = queue->qitems();
+    QueueItemList qil = _qitems;
     for (QueueItemList::const_iterator iter = qil.begin(); iter != qil.end(); ++iter) {
        QueueItem_Ptr qitem = *iter;
        QueueItem_Ptr new_qitem;
@@ -312,14 +312,13 @@ copy_queue_except_for_branch (ResolverQueue_Ptr queue, QueueItem_Ptr branch_qite
 
            if (new_qitem->isInstall()) {
                QueueItemInstall_Ptr install_qitem = dynamic_pointer_cast<QueueItemInstall>(new_qitem);
-#warning needs Source backref
-#if 0
+
                /* Penalties are negative priorities */
                int penalty;
-               penalty = - queue->context()->getChannelPriority (install_qitem->poolItem()->channel());
+               Source_Ref src = install_qitem->item()->source();
+               penalty = - src.priority();
 
                install_qitem->setOtherPenalty (penalty);
-#endif
            }
 
        } else {
@@ -397,7 +396,7 @@ ResolverQueue::splitFirstBranch (ResolverQueueList & new_queues, ResolverQueueLi
        ResolverQueue_Ptr new_queue;
        QueueItem_Ptr new_qitem = *iter;
 
-       new_queue = copy_queue_except_for_branch (this, (QueueItem_Ptr) first_branch, new_qitem);
+       new_queue = copy_queue_except_for_branch ((QueueItem_Ptr) first_branch, new_qitem);
 
        DeferTable::const_iterator pos = to_defer.find (new_qitem);
        if (pos != to_defer.end()) {
index e676ec5..6d0a5df 100644 (file)
@@ -63,8 +63,10 @@ class ResolverQueue : public base::ReferenceCounted, private base::NonCopyable {
     IgnoreMap _ignoreConflicts;
     IgnoreMap _ignoreRequires;
 
+    ResolverQueue_Ptr copy_queue_except_for_branch (QueueItem_Ptr branch_qitem, QueueItem_Ptr subqitem) const;
+
   public:
-    ResolverQueue (const ResPool & pool, ResolverContext_Ptr context = NULL);
+    ResolverQueue (const ResPool & pool, const Arch & arch, ResolverContext_Ptr context = NULL);
     virtual ~ResolverQueue();
 
     // ---------------------------------- I/O
@@ -78,7 +80,6 @@ class ResolverQueue : public base::ReferenceCounted, private base::NonCopyable {
 
     // ---------------------------------- methods
 
-
     void addPoolItemToInstall (PoolItem_Ref poolItem);
     void addPoolItemToEstablish (PoolItem_Ref poolItem);
     void addPoolItemToRemove (PoolItem_Ref poolItem, bool remove_only_mode);
index 1a9641f..860f8d6 100644 (file)
@@ -112,7 +112,10 @@ struct FindObsoletes : public resfilter::OnCapMatchCallbackFunctor
 
     bool operator()( PoolItem_Ref provider, const Capability & match )
     {
-       obsoletes = true;                                       // we have a match
+       if (provider->arch() == Arch_src)
+           return true;
+
+       obsoletes = true;                               // we have a match
        return false;                                   // stop looping here
     }
 };