provide sane indentation
authorKlaus Kaempf <kkaempf@suse.de>
Fri, 24 Feb 2006 13:01:28 +0000 (13:01 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Fri, 24 Feb 2006 13:01:28 +0000 (13:01 +0000)
zypp/source/yum/YUMSourceImpl.cc

index 2b91f59..fb151b2 100644 (file)
@@ -28,7 +28,7 @@
 #include "zypp/SourceFactory.h"
 #include "zypp/ZYppCallbacks.h"
 
-#include "zypp/gzstream/gzstream.h"
+#include "zypp/base/GzStream.h"
 
 #include <fstream>
 
@@ -55,568 +55,407 @@ namespace zypp
 
       void YUMSourceImpl::factoryInit()
       {
-        try {
-          media::MediaManager media_mgr;
-          MIL << "Adding no media verifier" << endl;
-          media::MediaAccessId _media = _media_set->getMediaAccessId(1);
-          media_mgr.delVerifier(_media);
-          media_mgr.addVerifier(_media, media::MediaVerifierRef(new media::NoVerifier()));
-        }
-        catch (const Exception & excpt_r)
-        {
+       try {
+         media::MediaManager media_mgr;
+         MIL << "Adding no media verifier" << endl;
+         media::MediaAccessId _media = _media_set->getMediaAccessId(1);
+         media_mgr.delVerifier(_media);
+         media_mgr.addVerifier(_media, media::MediaVerifierRef(new media::NoVerifier()));
+       }
+       catch (const Exception & excpt_r)
+       {
 #warning FIXME: If media data is not set, verifier is not set. Should the media be refused instead?
-          ZYPP_CAUGHT(excpt_r);
-          WAR << "Verifier not found" << endl;
-        }
-
-        try {
-          // first read list of all files in the repository
-          Pathname filename;
-          if (_cache_dir.empty())
-          {
-            // now, the file exists, try to read it
-            filename = provideFile(_path + "/repodata/repomd.xml");
-          }
-          else
-          {
-            filename = _cache_dir + "/repodata/repomd.xml";
-          }
-        
-          if ( ! PathInfo(filename).isExist() )
-            ZYPP_THROW(Exception("repodata/repomd.xml not found"));
-
-          DBG << "Reading file " << filename << endl;
-          ifstream repo_st(filename.asString().c_str());
-          YUMRepomdParser repomd(repo_st, "");
-        
-          for(;
-              ! repomd.atEnd();
-              ++repomd)
-          {
-          }
-        }
-        catch (...)
-        {
-          ERR << "Cannot read repomd file, cannot initialize source" << endl;
-          ZYPP_THROW( Exception("Cannot read repomd file, cannot initialize source") );
-        }
+         ZYPP_CAUGHT(excpt_r);
+         WAR << "Verifier not found" << endl;
+       }
+
+       try {
+         // first read list of all files in the repository
+         Pathname filename;
+         if (_cache_dir.empty())
+         {
+           // now, the file exists, try to read it
+           filename = provideFile(_path + "/repodata/repomd.xml");
+         }
+         else
+         {
+           filename = _cache_dir + "/repodata/repomd.xml";
+         }
+       
+         if ( ! PathInfo(filename).isExist() )
+           ZYPP_THROW(Exception("repodata/repomd.xml not found"));
+
+         DBG << "Reading file " << filename << endl;
+         ifstream repo_st(filename.asString().c_str());
+         YUMRepomdParser repomd(repo_st, "");
+       
+         for(;
+             ! repomd.atEnd();
+             ++repomd)
+         {
+         }
+       }
+       catch (...)
+       {
+         ERR << "Cannot read repomd file, cannot initialize source" << endl;
+         ZYPP_THROW( Exception("Cannot read repomd file, cannot initialize source") );
+       }
       }
 
       void YUMSourceImpl::storeMetadata(const Pathname & cache_dir_r)
       {
-        INT << "Storing data to cache" << endl;
-        resolvables(SourceFactory().createFrom(this));
-        for (std::list<Pathname>::const_iterator it = _metadata_files.begin();
-            it != _metadata_files.end(); it++)
-        {
-          Pathname src = provideFile(_path + *it);
-          Pathname dst = cache_dir_r + *it;
-          if (0 != assert_dir(dst.dirname(), 0700))
-            ZYPP_THROW(Exception("Cannot create cache directory"));
-          filesystem::copy(src, dst);
-        }
+       INT << "Storing data to cache" << endl;
+       resolvables(SourceFactory().createFrom(this));
+       for (std::list<Pathname>::const_iterator it = _metadata_files.begin();
+           it != _metadata_files.end(); it++)
+       {
+         Pathname src = provideFile(_path + *it);
+         Pathname dst = cache_dir_r + *it;
+         if (0 != assert_dir(dst.dirname(), 0700))
+           ZYPP_THROW(Exception("Cannot create cache directory"));
+         filesystem::copy(src, dst);
+       }
       }
 
       void YUMSourceImpl::createResolvables(Source_Ref source_r)
       {
-        std::list<YUMRepomdData_Ptr> repo_primary;
-        std::list<YUMRepomdData_Ptr> repo_files;
-        std::list<YUMRepomdData_Ptr> repo_other;
-        std::list<YUMRepomdData_Ptr> repo_group;
-        std::list<YUMRepomdData_Ptr> repo_pattern;
-        std::list<YUMRepomdData_Ptr> repo_product;
-        std::list<YUMRepomdData_Ptr> repo_patches;
-
-        callback::SendReport<CreateSourceReport> report;
+       std::list<YUMRepomdData_Ptr> repo_primary;
+       std::list<YUMRepomdData_Ptr> repo_files;
+       std::list<YUMRepomdData_Ptr> repo_other;
+       std::list<YUMRepomdData_Ptr> repo_group;
+       std::list<YUMRepomdData_Ptr> repo_pattern;
+       std::list<YUMRepomdData_Ptr> repo_product;
+       std::list<YUMRepomdData_Ptr> repo_patches;
+
+       callback::SendReport<CreateSourceReport> report;
   
-        report->startData( url() );
+       report->startData( url() );
 
-      try {
-  // first read list of all files in the reposotory
-        Pathname filename = _cache_dir.empty()
-    ? provideFile(_path + "/repodata/repomd.xml")
-    : _cache_dir + "/repodata/repomd.xml";
-  _metadata_files.push_back("/repodata/repomd.xml");
-  DBG << "Reading file " << filename << endl;
-  ifstream repo_st(filename.asString().c_str());
-  YUMRepomdParser repomd(repo_st, "");
-
-  for(;
-      ! repomd.atEnd();
-      ++repomd)
-  {
-    if ((*repomd)->type == "primary")
-      repo_primary.push_back(*repomd);
-    else if ((*repomd)->type == "filelists")
-      repo_files.push_back(*repomd);
-    else if ((*repomd)->type == "other")
-      repo_other.push_back(*repomd);
-    else if ((*repomd)->type == "group")
-      repo_group.push_back(*repomd);
-    else if ((*repomd)->type == "pattern")
-      repo_pattern.push_back(*repomd);
-    else if ((*repomd)->type == "product")
-      repo_product.push_back(*repomd);
-    else if ((*repomd)->type == "patches")
-      repo_patches.push_back(*repomd);
-    else
-      ERR << "Unknown type of repo file: " << (*repomd)->type << endl;
-  }
-      }
-      catch (...)
-      {
-  ERR << "Cannot read repomd file, cannot initialize source" << endl;
-  ZYPP_THROW( Exception("Cannot read repomd file, cannot initialize source") );
-      }
-      try {
-  // now put other and filelist data to structures for easier find
-  map<PackageID, YUMFileListData_Ptr> files_data;
-  map<PackageID, YUMOtherData_Ptr> other_data;
-  for (std::list<YUMRepomdData_Ptr>::const_iterator it
-          = repo_files.begin();
-      it != repo_files.end();
-      it++)
-  {
-    // TODO check checksum
-    Pathname filename = _cache_dir.empty()
-      ? provideFile(_path + (*it)->location)
-      : _cache_dir + (*it)->location;
-    _metadata_files.push_back((*it)->location);
-    DBG << "Reading file " << filename << endl;
-
-    if (filename.asString().find( ".gz", filename.asString().size()-3) != string::npos) {
-      igzstream st ( filename.asString().c_str() );
-
-      YUMFileListParser filelist ( st, "" );
-      for (;
-          ! filelist.atEnd();
-          ++filelist)
-      {
-        PackageID id((*filelist)->name,
-                    (*filelist)->ver,
-                    (*filelist)->rel,
-                    (*filelist)->arch);
-        files_data[id] = *filelist;
-      }
-      if (filelist.errorStatus())
-        throw *filelist.errorStatus();
-    }
-    else {
-      ifstream st( filename.asString().c_str() );
-      YUMFileListParser filelist ( st, "" );
-      for (;
-          ! filelist.atEnd();
-          ++filelist)
-      {
-        PackageID id((*filelist)->name,
-                    (*filelist)->ver,
-                    (*filelist)->rel,
-                    (*filelist)->arch);
-        files_data[id] = *filelist;
-      }
-      if (filelist.errorStatus())
-        throw *filelist.errorStatus();
-  
-      }
-  }
-
-  for (std::list<YUMRepomdData_Ptr>::const_iterator it
-          = repo_other.begin();
-      it != repo_other.end();
-      it++)
-  {
-    // TODO check checksum
-    Pathname filename = _cache_dir.empty()
-      ? provideFile(_path + (*it)->location)
-      : _cache_dir + (*it)->location;
-    _metadata_files.push_back((*it)->location);
-    DBG << "Reading file " << filename << endl;
-
-    if (filename.asString().find( ".gz", filename.asString().size()-3) != string::npos) {
-      igzstream st ( filename.asString().c_str() );
-      YUMOtherParser other(st, "");
-      for (;
-          ! other.atEnd();
-          ++other)
-      {
-        PackageID id((*other)->name,
-                    (*other)->ver,
-                    (*other)->rel,
-                    (*other)->arch);
-        other_data[id] = *other;
-      }
-      if (other.errorStatus())
-        throw *other.errorStatus();
-    }
-    else {
-      ifstream st(filename.asString().c_str());
-      YUMOtherParser other(st, "");
-      for (;
-          ! other.atEnd();
-          ++other)
-      {
-        PackageID id((*other)->name,
-                    (*other)->ver,
-                    (*other)->rel,
-                    (*other)->arch);
-        other_data[id] = *other;
-      }
-      if (other.errorStatus())
-        throw *other.errorStatus();
-      }
-  }
-
-  // now read primary data, merge them with filelist and changelog
-  for (std::list<YUMRepomdData_Ptr>::const_iterator it
-          = repo_primary.begin();
-      it != repo_primary.end();
-      it++)
-  {
-    // TODO check checksum
-    Pathname filename = _cache_dir.empty()
-      ? provideFile(_path + (*it)->location)
-      : _cache_dir + (*it)->location;
-    _metadata_files.push_back((*it)->location);
-    DBG << "Reading file " << filename << endl;
-    if (filename.asString().find( ".gz", filename.asString().size()-3) != string::npos) {
-      igzstream st ( filename.asString().c_str() );
-      YUMPrimaryParser prim(st, "");
-      for (;
-          !prim.atEnd();
-          ++prim)
-      {
-        PackageID id((*prim)->name,
-                    (*prim)->ver,
-                    (*prim)->rel,
-                    (*prim)->arch);
-        map<PackageID, YUMOtherData_Ptr>::iterator found_other
-            = other_data.find(id);
-        map<PackageID, YUMFileListData_Ptr>::iterator found_files
-            = files_data.find(id);
-  
-        YUMFileListData filelist_empty;
-        YUMOtherData other_empty;
-        Package::Ptr p = createPackage(
-          source_r,
-          **prim,
-          found_files != files_data.end()
-            ? *found_files->second
-            : filelist_empty,
-          found_other != other_data.end()
-            ? *found_other->second
-            : other_empty
-        );
-        _store.insert (p);
-      }
-      if (prim.errorStatus())
-        throw *prim.errorStatus();
-    }
-    else {
-      ifstream st(filename.asString().c_str());
-      YUMPrimaryParser prim(st, "");
-      for (;
-          !prim.atEnd();
-          ++prim)
-      {
-        PackageID id((*prim)->name,
-                    (*prim)->ver,
-                    (*prim)->rel,
-                    (*prim)->arch);
-        map<PackageID, YUMOtherData_Ptr>::iterator found_other
-            = other_data.find(id);
-        map<PackageID, YUMFileListData_Ptr>::iterator found_files
-            = files_data.find(id);
-  
-        YUMFileListData filelist_empty;
-        YUMOtherData other_empty;
-        Package::Ptr p = createPackage(
-          source_r,
-          **prim,
-          found_files != files_data.end()
-            ? *found_files->second
-            : filelist_empty,
-          found_other != other_data.end()
-            ? *found_other->second
-            : other_empty
-        );
-        _store.insert (p);
-      }
-      if (prim.errorStatus())
-        throw *prim.errorStatus();
-    }
-  }
-      }
-      catch (...) {
-  ERR << "Cannot read package information" << endl;
-      }
-
-      try {
-  // groups
-  for (std::list<YUMRepomdData_Ptr>::const_iterator it = repo_group.begin();
-      it != repo_group.end();
-      it++)
-  {
-    // TODO check checksum
-    Pathname filename = _cache_dir.empty()
-      ? provideFile(_path + (*it)->location)
-      : _cache_dir + (*it)->location;
-    _metadata_files.push_back((*it)->location);
-    DBG << "Reading file " << filename << endl;
-    if (filename.asString().find( ".gz", filename.asString().size()-3) != string::npos)
-    {
-      igzstream st ( filename.asString().c_str() );
-      YUMGroupParser group(st, "");
-      for (;
-          !group.atEnd();
-          ++group)
-      {
-        Selection::Ptr p = createGroup(
-          source_r,
-          **group
-        );
-        _store.insert (p);
-      }
-      if (group.errorStatus())
-        throw *group.errorStatus();
-    }
-    else
-    {
-      ifstream st(filename.asString().c_str());
-      YUMGroupParser group(st, "");
-      for (;
-          !group.atEnd();
-          ++group)
-      {
-        Selection::Ptr p = createGroup(
-          source_r,
-          **group
-        );
-        _store.insert (p);
-      }
-      if (group.errorStatus())
-        throw *group.errorStatus();
-    }
-  }
-      }
-      catch (...) {
-  ERR << "Cannot read package groups information" << endl;
-      }
+    //---------------------------------
+    // repomd
 
       try {
-  // patterns
-  for (std::list<YUMRepomdData_Ptr>::const_iterator it = repo_pattern.begin();
-      it != repo_pattern.end();
-      it++)
-  {
-    // TODO check checksum
-    Pathname filename = _cache_dir.empty()
-      ? provideFile(_path + (*it)->location)
-      : _cache_dir + (*it)->location;
-    _metadata_files.push_back((*it)->location);
-    DBG << "Reading file " << filename << endl;
-    if (filename.asString().find( ".gz", filename.asString().size()-3) != string::npos)
-    {
-      igzstream st ( filename.asString().c_str() );
-      YUMPatternParser pattern(st, "");
-      for (;
-          !pattern.atEnd();
-          ++pattern)
-      {
-        Pattern::Ptr p = createPattern(
-          source_r,
-          **pattern
-        );
-        _store.insert (p);
+         // first read list of all files in the repository
+       Pathname filename = _cache_dir.empty()
+           ? provideFile(_path + "/repodata/repomd.xml")
+           : _cache_dir + "/repodata/repomd.xml";
+         _metadata_files.push_back("/repodata/repomd.xml");
+         DBG << "Reading ifgz file " << filename << endl;
+         ifgzstream repo_st(filename.asString().c_str());
+         YUMRepomdParser repomd(repo_st, "");
+
+         for(;
+             ! repomd.atEnd();
+             ++repomd)
+         {
+           if ((*repomd)->type == "primary")
+             repo_primary.push_back(*repomd);
+           else if ((*repomd)->type == "filelists")
+             repo_files.push_back(*repomd);
+           else if ((*repomd)->type == "other")
+             repo_other.push_back(*repomd);
+           else if ((*repomd)->type == "group")
+             repo_group.push_back(*repomd);
+           else if ((*repomd)->type == "pattern")
+             repo_pattern.push_back(*repomd);
+           else if ((*repomd)->type == "product")
+             repo_product.push_back(*repomd);
+           else if ((*repomd)->type == "patches")
+             repo_patches.push_back(*repomd);
+           else
+             ERR << "Unknown type of repo file: " << (*repomd)->type << endl;
+       }
       }
-      if (pattern.errorStatus())
-        throw *pattern.errorStatus();
-    }
-    else
-    {
-      ifstream st(filename.asString().c_str());
-      YUMPatternParser pattern(st, "");
-      for (;
-          !pattern.atEnd();
-          ++pattern)
+      catch (...)
       {
-        Pattern::Ptr p = createPattern(
-          source_r,
-          **pattern
-        );
-        _store.insert (p);
-      }
-      if (pattern.errorStatus())
-        throw *pattern.errorStatus();
-    }
-  }
-      }
-      catch (...) {
-  ERR << "Cannot read installation patterns information" << endl;
+         ERR << "Cannot read repomd file, cannot initialize source" << endl;
+         ZYPP_THROW( Exception("Cannot read repomd file, cannot initialize source") );
       }
 
-      try {
-  // products
-  for (std::list<YUMRepomdData_Ptr>::const_iterator it = repo_product.begin();
-      it != repo_product.end();
-      it++)
-  {
-    // TODO check checksum
-    Pathname filename = _cache_dir.empty()
-      ? provideFile(_path + (*it)->location)
-      : _cache_dir + (*it)->location;
-    _metadata_files.push_back((*it)->location);
-    DBG << "Reading file " << filename << endl;
-    if (filename.asString().find( ".gz", filename.asString().size()-3) != string::npos)
-    {
-      igzstream st ( filename.asString().c_str() );
-      YUMProductParser product(st, "");
-      for (;
-          !product.atEnd();
-          ++product)
-      {
-        Product::Ptr p = createProduct(
-          source_r,
-          **product
-        );
-        _store.insert (p);
-      }
-      if (product.errorStatus())
-        throw *product.errorStatus();
-    }
-    else
-    {
-      ifstream st(filename.asString().c_str());
-      YUMProductParser product(st, "");
-      for (;
-          !product.atEnd();
-          ++product)
-      {
-        Product::Ptr p = createProduct(
-          source_r,
-          **product
-        );
-        _store.insert (p);
-      }
-      if (product.errorStatus())
-        throw *product.errorStatus();
-    }
-  }
-      }
-      catch (...) {
-  ERR << "Cannot read products information" << endl;
-      }
+    //---------------------------------
+    // files mentioned within repomd
 
       try {
-  // patches
-  std::list<std::string> patch_files;
-  for (std::list<YUMRepomdData_Ptr>::const_iterator it = repo_patches.begin();
-      it != repo_patches.end();
-      it++)
-  {
-    // TODO check checksum
-    Pathname filename = _cache_dir.empty()
-      ? provideFile(_path + (*it)->location)
-      : _cache_dir + (*it)->location;
-    _metadata_files.push_back((*it)->location);
-    DBG << "Reading file " << filename << endl;
-    if (filename.asString().find( ".gz", filename.asString().size()-3) != string::npos)
-    {
-      igzstream st ( filename.asString().c_str() );
-      YUMPatchesParser patch(st, "");
-      for (;
-          !patch.atEnd();
-          ++patch)
-      {
-        // TODO check checksum
-        string filename = (*patch)->location;
-        patch_files.push_back(filename);
-      }
-      if (patch.errorStatus())
-        throw *patch.errorStatus();
-    }
-    else
-    {
-      ifstream st(filename.asString().c_str());
-      YUMPatchesParser patch(st, "");
-      for (;
-          !patch.atEnd();
-          ++patch)
-      {
-        // TODO check checksum
-        string filename = (*patch)->location;
-        patch_files.push_back(filename);
-      }
-      if (patch.errorStatus())
-        throw *patch.errorStatus();
-    }
-  }
-
-  for (std::list<std::string>::const_iterator it = patch_files.begin();
-      it != patch_files.end();
-      it++)
-  {
-      Pathname filename = _cache_dir.empty()
-        ? provideFile(_path + *it)
-        : _cache_dir + *it;
-      _metadata_files.push_back(*it);
-      DBG << "Reading file " << filename << endl;
-      if (filename.asString().find( ".gz", filename.asString().size()-3) != string::npos)
-      {
-        igzstream st ( filename.asString().c_str() );
-        YUMPatchParser ptch(st, "");
-        for(;
-            !ptch.atEnd();
-            ++ptch)
-        {
-          Patch::Ptr p = createPatch(
-            source_r,
-           **ptch
-          );
-          _store.insert (p);
-          Patch::AtomList atoms = p->atoms();
-          for (Patch::AtomList::iterator at = atoms.begin();
-             at != atoms.end();
-             at++)
-          {
-            _store.insert (*at);
-          }
-        }
-        if (ptch.errorStatus())
-          throw *ptch.errorStatus();
-      }
-      else
-      {
-        ifstream st(filename.asString().c_str());
-        YUMPatchParser ptch(st, "");
-        for(;
-            !ptch.atEnd();
-            ++ptch)
-        {
-          Patch::Ptr p = createPatch(
-            source_r,
-           **ptch
-          );
-          _store.insert (p);
-          Patch::AtomList atoms = p->atoms();
-          for (Patch::AtomList::iterator at = atoms.begin();
-             at != atoms.end();
-             at++)
-          {
-            _store.insert (*at);
-          }
-        }
-        if (ptch.errorStatus())
-          throw *ptch.errorStatus();
-      }
+         // now put other and filelist data to structures for easier find
+         map<PackageID, YUMFileListData_Ptr> files_data;
+         map<PackageID, YUMOtherData_Ptr> other_data;
+         for (std::list<YUMRepomdData_Ptr>::const_iterator it
+                 = repo_files.begin();
+             it != repo_files.end();
+             it++)
+         {
+           // TODO check checksum
+           Pathname filename = _cache_dir.empty()
+             ? provideFile(_path + (*it)->location)
+             : _cache_dir + (*it)->location;
+           _metadata_files.push_back((*it)->location);
+           DBG << "Reading ifgz file " << filename << endl;
+
+           ifgzstream st( filename.asString().c_str() );
+
+           YUMFileListParser filelist ( st, "" );
+           for (;
+                 ! filelist.atEnd();
+                 ++filelist)
+           {
+               PackageID id((*filelist)->name,
+                           (*filelist)->ver,
+                           (*filelist)->rel,
+                           (*filelist)->arch);
+               files_data[id] = *filelist;
+           }
+           if (filelist.errorStatus())
+             throw *filelist.errorStatus();
+         }
+
+         for (std::list<YUMRepomdData_Ptr>::const_iterator it
+                 = repo_other.begin();
+             it != repo_other.end();
+             it++)
+         {
+           // TODO check checksum
+           Pathname filename = _cache_dir.empty()
+             ? provideFile(_path + (*it)->location)
+             : _cache_dir + (*it)->location;
+           _metadata_files.push_back((*it)->location);
+           DBG << "Reading file " << filename << endl;
+
+           ifgzstream st ( filename.asString().c_str() );
+           YUMOtherParser other(st, "");
+           for (;
+                 ! other.atEnd();
+                 ++other)
+           {
+               PackageID id((*other)->name,
+                           (*other)->ver,
+                           (*other)->rel,
+                           (*other)->arch);
+               other_data[id] = *other;
+           }
+           if (other.errorStatus())
+             throw *other.errorStatus();
+       }
+
+       // now read primary data, merge them with filelist and changelog
+         for (std::list<YUMRepomdData_Ptr>::const_iterator it
+                 = repo_primary.begin();
+             it != repo_primary.end();
+             it++)
+       {
+           // TODO check checksum
+           Pathname filename = _cache_dir.empty()
+                             ? provideFile(_path + (*it)->location)
+                             : _cache_dir + (*it)->location;
+           _metadata_files.push_back((*it)->location);
+           DBG << "Reading file " << filename << endl;
+           ifgzstream st ( filename.asString().c_str() );
+           YUMPrimaryParser prim(st, "");
+           for (;
+                 !prim.atEnd();
+                 ++prim)
+           {
+               PackageID id((*prim)->name,
+                        (*prim)->ver,
+                        (*prim)->rel,
+                        (*prim)->arch);
+               map<PackageID, YUMOtherData_Ptr>::iterator found_other
+                   = other_data.find(id);
+               map<PackageID, YUMFileListData_Ptr>::iterator found_files
+                   = files_data.find(id);
+  
+               YUMFileListData filelist_empty;
+               YUMOtherData other_empty;
+               Package::Ptr p = createPackage(
+                 source_r,
+                 **prim,
+                 found_files != files_data.end()
+                   ? *found_files->second
+                   : filelist_empty,
+                 found_other != other_data.end()
+                   ? *found_other->second
+                    : other_empty
+               );
+               _store.insert (p);
+           }
+           if (prim.errorStatus())
+               throw *prim.errorStatus();
+       }
+    }
+    catch (...) {
+       ERR << "Cannot read package information" << endl;
+    }
+
+    //---------------------------------
+    // groups
+    try {
+       for (std::list<YUMRepomdData_Ptr>::const_iterator it = repo_group.begin();
+             it != repo_group.end();
+             it++)
+       {
+           // TODO check checksum
+           Pathname filename = _cache_dir.empty()
+             ? provideFile(_path + (*it)->location)
+             : _cache_dir + (*it)->location;
+           _metadata_files.push_back((*it)->location);
+           DBG << "Reading file " << filename << endl;
+           ifgzstream st ( filename.asString().c_str() );
+           YUMGroupParser group(st, "");
+           for (;
+                 !group.atEnd();
+                 ++group)
+           {
+               Selection::Ptr p = createGroup(
+                 source_r,
+                 **group
+               );
+               _store.insert (p);
+           }
+           if (group.errorStatus())
+               throw *group.errorStatus();
+       }
+    }
+    catch (...) {
+       ERR << "Cannot read package groups information" << endl;
+    }
+
+    //---------------------------------
+    // patterns
+
+    try {
+       for (std::list<YUMRepomdData_Ptr>::const_iterator it = repo_pattern.begin();
+             it != repo_pattern.end();
+             it++)
+       {
+           // TODO check checksum
+           Pathname filename = _cache_dir.empty()
+             ? provideFile(_path + (*it)->location)
+             : _cache_dir + (*it)->location;
+           _metadata_files.push_back((*it)->location);
+           DBG << "Reading file " << filename << endl;
+           ifgzstream st ( filename.asString().c_str() );
+           YUMPatternParser pattern(st, "");
+           for (;
+                 !pattern.atEnd();
+                 ++pattern)
+           {
+               Pattern::Ptr p = createPattern(
+                 source_r,
+                 **pattern
+               );
+               _store.insert (p);
+           }
+           if (pattern.errorStatus())
+               throw *pattern.errorStatus();
+       }
+    }
+    catch (...) {
+         ERR << "Cannot read installation patterns information" << endl;
+    }
+
+
+    //---------------------------------
+    // products
+    try {
+       for (std::list<YUMRepomdData_Ptr>::const_iterator it = repo_product.begin();
+             it != repo_product.end();
+             it++)
+       {
+           // TODO check checksum
+           Pathname filename = _cache_dir.empty()
+             ? provideFile(_path + (*it)->location)
+             : _cache_dir + (*it)->location;
+           _metadata_files.push_back((*it)->location);
+           DBG << "Reading file " << filename << endl;
+           ifgzstream st ( filename.asString().c_str() );
+           YUMProductParser product(st, "");
+           for (;
+                 !product.atEnd();
+                 ++product)
+           {
+               Product::Ptr p = createProduct(
+                 source_r,
+                 **product
+               );
+               _store.insert (p);
+           }
+           if (product.errorStatus())
+               throw *product.errorStatus();
+         }
+    }
+    catch (...) {
+         ERR << "Cannot read products information" << endl;
+    }
+
+    //---------------------------------
+    // patches, first the patches.xml index
+    try {
+         std::list<std::string> patch_files;
+         for (std::list<YUMRepomdData_Ptr>::const_iterator it = repo_patches.begin();
+             it != repo_patches.end();
+             it++)
+         {
+           // TODO check checksum
+           Pathname filename = _cache_dir.empty()
+             ? provideFile(_path + (*it)->location)
+             : _cache_dir + (*it)->location;
+           _metadata_files.push_back((*it)->location);
+           DBG << "Reading file " << filename << endl;
+           ifgzstream st ( filename.asString().c_str() );
+           YUMPatchesParser patch(st, "");
+           for (;
+                 !patch.atEnd();
+                 ++patch)
+           {
+               // TODO check checksum
+               string filename = (*patch)->location;
+               patch_files.push_back(filename);
+           }
+           if (patch.errorStatus())
+               throw *patch.errorStatus();
+       }
+
+       //---------------------------------
+       // now the individual patch files
+
+       for (std::list<std::string>::const_iterator it = patch_files.begin();
+         it != patch_files.end();
+         it++)
+       {
+           Pathname filename = _cache_dir.empty()
+               ? provideFile(_path + *it)
+               : _cache_dir + *it;
+           _metadata_files.push_back(*it);
+           DBG << "Reading file " << filename << endl;
+           ifgzstream st ( filename.asString().c_str() );
+           YUMPatchParser ptch(st, "");
+           for(;
+                   !ptch.atEnd();
+                   ++ptch)
+           {
+                 Patch::Ptr p = createPatch(
+                   source_r,
+                   **ptch
+                 );
+                 _store.insert (p);
+                 Patch::AtomList atoms = p->atoms();
+                 for (Patch::AtomList::iterator at = atoms.begin();
+                     at != atoms.end();
+                     at++)
+                 {
+                   _store.insert (*at);
+                 }
+           }
+           if (ptch.errorStatus())
+               throw *ptch.errorStatus();
+       }
+    }
+    catch (...)
+    {
+       ERR << "Cannot read patch metadata" << endl;
+    }
+
+    report->finishData( url(), CreateSourceReport::NO_ERROR, "" );
   }
-      }
-      catch (...)
-      {
-  ERR << "Cannot read patch metadata" << endl;
-      }
-
-  report->finishData( url(), CreateSourceReport::NO_ERROR, "" );
-      }
 
   Package::Ptr YUMSourceImpl::createPackage(
     Source_Ref source_r,
@@ -628,17 +467,17 @@ namespace zypp
     try
     {
       ResImplTraits<YUMPackageImpl>::Ptr impl(
-        new YUMPackageImpl(source_r, parsed, filelist, other));
-
-            // Collect basic Resolvable data
-            NVRAD dataCollect( parsed.name,
-                              Edition( parsed.ver, parsed.rel, parsed.epoch ),
-                              Arch( parsed.arch ),
-                              createDependencies(parsed,
-                                                  ResTraits<Package>::kind)
-                            );
+       new YUMPackageImpl(source_r, parsed, filelist, other));
+
+           // Collect basic Resolvable data
+           NVRAD dataCollect( parsed.name,
+                             Edition( parsed.ver, parsed.rel, parsed.epoch ),
+                             Arch( parsed.arch ),
+                             createDependencies(parsed,
+                                                 ResTraits<Package>::kind)
+                           );
       Package::Ptr package = detail::makeResolvableFromImpl(
-        dataCollect, impl
+       dataCollect, impl
       );
       return package;
     }
@@ -658,15 +497,15 @@ namespace zypp
     {
       ResImplTraits<YUMPackageImpl>::Ptr impl(new YUMPackageImpl(source_r, parsed));
 
-            // Collect basic Resolvable data
-            NVRAD dataCollect( parsed.name,
-                              Edition( parsed.ver, parsed.rel, parsed.epoch ),
-                              Arch( parsed.arch ),
-                              createDependencies(parsed,
-                                                  ResTraits<Package>::kind)
-                            );
+           // Collect basic Resolvable data
+           NVRAD dataCollect( parsed.name,
+                             Edition( parsed.ver, parsed.rel, parsed.epoch ),
+                             Arch( parsed.arch ),
+                             createDependencies(parsed,
+                                                 ResTraits<Package>::kind)
+                           );
       Package::Ptr package = detail::makeResolvableFromImpl(
-        dataCollect, impl
+       dataCollect, impl
       );
       return package;
     }
@@ -685,13 +524,13 @@ namespace zypp
     try
     {
       ResImplTraits<YUMGroupImpl>::Ptr impl(new YUMGroupImpl(source_r, parsed));
-            // Collect basic Resolvable data
-            NVRAD dataCollect( parsed.groupId,
-                              Edition::noedition,
-                              Arch_noarch,
-                              createGroupDependencies(parsed));
+           // Collect basic Resolvable data
+           NVRAD dataCollect( parsed.groupId,
+                             Edition::noedition,
+                             Arch_noarch,
+                             createGroupDependencies(parsed));
       Selection::Ptr group = detail::makeResolvableFromImpl(
-        dataCollect, impl
+       dataCollect, impl
       );
       return group;
     }
@@ -710,13 +549,13 @@ namespace zypp
     try
     {
       ResImplTraits<YUMPatternImpl>::Ptr impl(new YUMPatternImpl(source_r, parsed));
-            // Collect basic Resolvable data
-            NVRAD dataCollect( parsed.name,
-                              Edition::noedition,
-                              Arch_noarch,
-                              createDependencies(parsed, ResTraits<Pattern>::kind));
+           // Collect basic Resolvable data
+           NVRAD dataCollect( parsed.name,
+                             Edition::noedition,
+                             Arch_noarch,
+                             createDependencies(parsed, ResTraits<Pattern>::kind));
       Pattern::Ptr pattern = detail::makeResolvableFromImpl(
-        dataCollect, impl
+       dataCollect, impl
       );
       return pattern;
     }
@@ -736,15 +575,15 @@ namespace zypp
     {
       ResImplTraits<YUMMessageImpl>::Ptr impl(new YUMMessageImpl(source_r, parsed));
 
-            // Collect basic Resolvable data
-            NVRAD dataCollect( parsed.name,
-                              Edition( parsed.ver, parsed.rel, parsed.epoch ),
-                              Arch_noarch,
-                              createDependencies(parsed,
-                                                  ResTraits<Message>::kind)
-                            );
+           // Collect basic Resolvable data
+           NVRAD dataCollect( parsed.name,
+                             Edition( parsed.ver, parsed.rel, parsed.epoch ),
+                             Arch_noarch,
+                             createDependencies(parsed,
+                                                 ResTraits<Message>::kind)
+                           );
       Message::Ptr message = detail::makeResolvableFromImpl(
-        dataCollect, impl
+       dataCollect, impl
       );
       return message;
     }
@@ -764,15 +603,15 @@ namespace zypp
     {
       ResImplTraits<YUMScriptImpl>::Ptr impl(new YUMScriptImpl(source_r, parsed));
 
-            // Collect basic Resolvable data
-            NVRAD dataCollect( parsed.name,
-                              Edition( parsed.ver, parsed.rel, parsed.epoch ),
-                              Arch_noarch,
-                              createDependencies(parsed,
-                                                  ResTraits<Script>::kind)
-                            );
+           // Collect basic Resolvable data
+           NVRAD dataCollect( parsed.name,
+                             Edition( parsed.ver, parsed.rel, parsed.epoch ),
+                             Arch_noarch,
+                             createDependencies(parsed,
+                                                 ResTraits<Script>::kind)
+                           );
       Script::Ptr script = detail::makeResolvableFromImpl(
-        dataCollect, impl
+       dataCollect, impl
       );
       return script;
     }
@@ -792,15 +631,15 @@ namespace zypp
     {
       ResImplTraits<YUMProductImpl>::Ptr impl(new YUMProductImpl(source_r, parsed));
 
-            // Collect basic Resolvable data
-            NVRAD dataCollect( parsed.name,
-                              Edition( parsed.ver, parsed.rel, parsed.epoch ),
-                              Arch_noarch,
-                              createDependencies(parsed,
-                                                  ResTraits<Product>::kind)
-                            );
+           // Collect basic Resolvable data
+           NVRAD dataCollect( parsed.name,
+                             Edition( parsed.ver, parsed.rel, parsed.epoch ),
+                             Arch_noarch,
+                             createDependencies(parsed,
+                                                 ResTraits<Product>::kind)
+                           );
       Product::Ptr product = detail::makeResolvableFromImpl(
-        dataCollect, impl
+       dataCollect, impl
       );
       return product;
     }
@@ -820,15 +659,15 @@ namespace zypp
     {
       ResImplTraits<YUMPatchImpl>::Ptr impl(new YUMPatchImpl(source_r, parsed, *this));
 
-            // Collect basic Resolvable data
-            NVRAD dataCollect( parsed.name,
-                              Edition( parsed.ver, parsed.rel, parsed.epoch ),
-                              Arch_noarch,
-                              createDependencies(parsed,
-                                                  ResTraits<Patch>::kind)
-                            );
+           // Collect basic Resolvable data
+           NVRAD dataCollect( parsed.name,
+                             Edition( parsed.ver, parsed.rel, parsed.epoch ),
+                             Arch_noarch,
+                             createDependencies(parsed,
+                                                 ResTraits<Patch>::kind)
+                           );
       Patch::Ptr patch = detail::makeResolvableFromImpl(
-        dataCollect, impl
+       dataCollect, impl
       );
       return patch;
     }
@@ -846,69 +685,69 @@ namespace zypp
   {
     Dependencies _deps;
     for (std::list<YUMDependency>::const_iterator it = parsed.provides.begin();
-        it != parsed.provides.end();
-        it++)
+       it != parsed.provides.end();
+       it++)
     {
       _deps[Dep::PROVIDES].insert(createCapability(*it, my_kind));
     }
 
     for (std::list<YUMDependency>::const_iterator it = parsed.conflicts.begin();
-        it != parsed.conflicts.end();
-        it++)
+       it != parsed.conflicts.end();
+       it++)
     {
       _deps[Dep::CONFLICTS].insert(createCapability(*it, my_kind));
     }
 
     for (std::list<YUMDependency>::const_iterator it = parsed.obsoletes.begin();
-        it != parsed.obsoletes.end();
-        it++)
+       it != parsed.obsoletes.end();
+       it++)
     {
       _deps[Dep::OBSOLETES].insert(createCapability(*it, my_kind));
     }
 
     for (std::list<YUMDependency>::const_iterator it = parsed.freshen.begin();
-        it != parsed.freshen.end();
-        it++)
+       it != parsed.freshen.end();
+       it++)
     {
       _deps[Dep::FRESHENS].insert(createCapability(*it, my_kind));
     }
 
     for (std::list<YUMDependency>::const_iterator it = parsed.recommends.begin();
-        it != parsed.recommends.end();
-        it++)
+       it != parsed.recommends.end();
+       it++)
     {
       _deps[Dep::RECOMMENDS].insert(createCapability(*it, my_kind));
     }
 
     for (std::list<YUMDependency>::const_iterator it = parsed.suggests.begin();
-        it != parsed.suggests.end();
-        it++)
+       it != parsed.suggests.end();
+       it++)
     {
       _deps[Dep::SUGGESTS].insert(createCapability(*it, my_kind));
     }
 
     for (std::list<YUMDependency>::const_iterator it = parsed.supplements.begin();
-        it != parsed.supplements.end();
-        it++)
+       it != parsed.supplements.end();
+       it++)
     {
       _deps[Dep::SUPPLEMENTS].insert(createCapability(*it, my_kind));
     }
 
     for (std::list<YUMDependency>::const_iterator it = parsed.enhances.begin();
-        it != parsed.enhances.end();
-        it++)
+       it != parsed.enhances.end();
+       it++)
     {
       _deps[Dep::ENHANCES].insert(createCapability(*it, my_kind));
     }
 
     for (std::list<YUMDependency>::const_iterator it = parsed.requires.begin();
-        it != parsed.requires.end();
-        it++)
+       it != parsed.requires.end();
+       it++)
     {
       if (it->pre == "1")
-        _deps[Dep::PREREQUIRES].insert(createCapability(*it, my_kind));
+       _deps[Dep::PREREQUIRES].insert(createCapability(*it, my_kind));
       else
-        _deps[Dep::REQUIRES].insert(createCapability(*it, my_kind));
+       _deps[Dep::REQUIRES].insert(createCapability(*it, my_kind));
     }
 
     return _deps;
@@ -927,15 +766,15 @@ namespace zypp
       Dep _dep_kind = Dep::REQUIRES;
       if (it->type == "mandatory" || it->type == "")
       {
-        _dep_kind = Dep::REQUIRES;
+       _dep_kind = Dep::REQUIRES;
       }
       else if (it->type == "default")
       {
-        _dep_kind = Dep::RECOMMENDS;
+       _dep_kind = Dep::RECOMMENDS;
       }
       else if (it->type == "optional")
       {
-        _dep_kind = Dep::SUGGESTS;
+       _dep_kind = Dep::SUGGESTS;
       }
       _deps[_dep_kind].insert(createCapability(YUMDependency(
       "",
@@ -945,8 +784,8 @@ namespace zypp
       it->ver,
       it->rel,
       ""
-        ),
-        ResTraits<Package>::kind));
+       ),
+       ResTraits<Package>::kind));
     }
     for (std::list<MetaPkg>::const_iterator it = parsed.grouplist.begin();
       it != parsed.grouplist.end();
@@ -955,15 +794,15 @@ namespace zypp
       Dep _dep_kind = Dep::REQUIRES;
       if (it->type == "mandatory" || it->type == "")
       {
-        _dep_kind = Dep::REQUIRES;
+       _dep_kind = Dep::REQUIRES;
       }
       else if (it->type == "default")
       {
-        _dep_kind = Dep::RECOMMENDS;
+       _dep_kind = Dep::RECOMMENDS;
       }
       else if (it->type == "optional")
       {
-        _dep_kind = Dep::SUGGESTS;
+       _dep_kind = Dep::SUGGESTS;
       }
       _deps[_dep_kind].insert(createCapability(YUMDependency(
       "",
@@ -973,14 +812,14 @@ namespace zypp
       "",
       "",
       ""
-        ),
-        ResTraits<Selection>::kind));
+       ),
+       ResTraits<Selection>::kind));
     }
     return _deps;
   }
 
   Capability YUMSourceImpl::createCapability(const YUMDependency & dep,
-                const Resolvable::Kind & my_kind)
+               const Resolvable::Kind & my_kind)
   {
     CapFactory _f;
     Resolvable::Kind _kind = dep.kind == "" ? my_kind : Resolvable::Kind(dep.kind);