PatchContentsImpl.cc

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00016 #include <iostream>
00017 #include "zypp/base/Logger.h"
00018 #include "zypp/ui/PatchContentsImpl.h"
00019 #include <zypp/ZYppFactory.h>
00020 #include <zypp/ResPool.h>
00021 #include <zypp/Atom.h>
00022 
00023 using std::endl;
00024 
00025 namespace zypp
00026 {
00027     namespace ui
00028     {
00029         PatchContents::Impl::Impl( Patch::constPtr patch )
00030             : _patch( patch )
00031         {
00032             Patch::AtomList atomList = _patch->atoms();
00033             _contents.reserve( atomList.size() );
00034 
00035             ResPool pool = getZYpp()->pool();
00036 
00037             for( Patch::AtomList::iterator atom_it = atomList.begin();
00038                  atom_it != atomList.end();
00039                  ++atom_it )
00040             {
00041                 ResPool::byName_iterator foundNames    = pool.byNameBegin( (*atom_it)->name() );
00042                 ResPool::byName_iterator foundNamesEnd = pool.byNameEnd  ( (*atom_it)->name() );
00043 
00044                 bool found = false;
00045 
00046                 while ( ! found
00047                         && foundNames != foundNamesEnd )
00048                 {
00049                     // DBG << "Found " << (*atom_it)->name() << " " << (*foundNames)->edition().asString() << endl;
00050 
00051                     if ( ! isKind<Atom>( (*foundNames).resolvable() ) &&
00052                          (*atom_it)->edition() == (*foundNames)->edition() &&
00053                          (*atom_it)->arch()    == (*foundNames)->arch()      )
00054                     {
00055                         found = true;
00056                         _contents.push_back( *foundNames );
00057 
00058                         MIL << "Found resolvable for patch atom: "
00059                             << (*foundNames)->name() << "-" << (*foundNames)->edition()
00060                             << " arch: " << (*foundNames)->arch().asString()
00061                             << endl;
00062                     }
00063                     else
00064                         ++foundNames;
00065                 }
00066 
00067                 if ( ! found )
00068                 {
00069                     Arch system_arch = getZYpp()->architecture();
00070 
00071                     if (! (*atom_it)->arch().compatibleWith( system_arch) ) {
00072 
00073                         // It's perfectly legitimate for that corresponding resolvable not to be in the pool:
00074                         // The pool only contains resolvables in matching architectures, yet a
00075                         // multi-arch patch might as well contain atoms for different architectures.
00076 
00077                         continue;
00078                     }
00079 
00080                     ERR << "No resolvable for patch atom in pool: "
00081                         << (*atom_it)->name() << "-" << (*atom_it)->edition()
00082                         << " arch: " << (*atom_it)->arch().asString()
00083                         << endl;
00084                 }
00085             }
00086         }
00087 
00088 
00089         PatchContents::const_iterator PatchContents::Impl::begin() const
00090         {
00091             return _contents.begin();
00092         }
00093 
00094 
00095         PatchContents::const_iterator PatchContents::Impl::end() const
00096         {
00097             return _contents.end();
00098         }
00099 
00100 
00101         bool PatchContents::Impl::empty() const
00102         {
00103             return _contents.empty();
00104         }
00105 
00106 
00107         PatchContents::size_type PatchContents::Impl::size() const
00108         {
00109             return _contents.size();
00110         }
00111 
00112     } // namespace ui
00113 } // namespace zypp

Generated on Thu Jul 6 00:07:28 2006 for zypp by  doxygen 1.4.6