Mailinglist Archive: zypp-commit (301 mails)

< Previous Next >
[zypp-commit] r7507 - in /branches/use-solv/libzypp: ./ zypp/ zypp/capability/ zypp/repo/cached/ zypp/target/rpm/
  • From: matz@xxxxxxxxxxxxxxxx
  • Date: Fri, 12 Oct 2007 15:49:57 -0000
  • Message-id: <20071012154957.D840745523@xxxxxxxxxxxxxxxx>
Author: matz
Date: Fri Oct 12 17:49:57 2007
New Revision: 7507

URL: http://svn.opensuse.org/viewcvs/zypp?rev=7507&view=rev
Log:
Initial hacks for using the SOLV datastructure.

Modified:
    branches/use-solv/libzypp/CMakeLists.txt
    branches/use-solv/libzypp/zypp/CMakeLists.txt
    branches/use-solv/libzypp/zypp/RepoManager.cc
    branches/use-solv/libzypp/zypp/capability/VersionedCap.cc
    branches/use-solv/libzypp/zypp/capability/VersionedCap.h
    branches/use-solv/libzypp/zypp/repo/cached/RepoImpl.cc
    branches/use-solv/libzypp/zypp/repo/cached/RepoImpl.h
    branches/use-solv/libzypp/zypp/target/rpm/RpmDb.cc
    branches/use-solv/libzypp/zypp/target/rpm/RpmDb.h
    branches/use-solv/libzypp/zypp/target/rpm/RpmPackageImpl.cc
    branches/use-solv/libzypp/zypp/target/rpm/RpmPackageImpl.h

Modified: branches/use-solv/libzypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/CMakeLists.txt?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/CMakeLists.txt (original)
+++ branches/use-solv/libzypp/CMakeLists.txt Fri Oct 12 17:49:57 2007
@@ -196,6 +196,8 @@
   MESSAGE( STATUS "doxygen found: ${DOXYGEN}" )
 ENDIF ( NOT DOXYGEN )
 
+INCLUDE_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/include/satsolver)
+
 MESSAGE(STATUS "soname: ${LIBZYPP_VERSION_INFO}")
 MESSAGE(STATUS "version: ${VERSION}")
 

Modified: branches/use-solv/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/zypp/CMakeLists.txt?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/zypp/CMakeLists.txt (original)
+++ branches/use-solv/libzypp/zypp/CMakeLists.txt Fri Oct 12 17:49:57 2007
@@ -1158,6 +1158,7 @@
 TARGET_LINK_LIBRARIES(zypp ${LIBXML_LIBRARY} )
 TARGET_LINK_LIBRARIES(zypp ${SQLITE_LIBRARY} )
 TARGET_LINK_LIBRARIES(zypp ${ZLIB_LIBRARY} )
+TARGET_LINK_LIBRARIES(zypp ${CMAKE_INSTALL_PREFIX}/lib/libsatsolver.a)
 
 INSTALL(TARGETS zypp LIBRARY DESTINATION ${LIB_INSTALL_DIR} )
 

Modified: branches/use-solv/libzypp/zypp/RepoManager.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/zypp/RepoManager.cc?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/zypp/RepoManager.cc (original)
+++ branches/use-solv/libzypp/zypp/RepoManager.cc Fri Oct 12 17:49:57 2007
@@ -12,6 +12,7 @@
 
 #include <iostream>
 #include <fstream>
+#include <sstream>
 #include <list>
 #include <algorithm>
 #include "zypp/base/InputStream.h"
@@ -39,6 +40,9 @@
 
 #include "zypp/ZYppCallbacks.h"
 
+#include "pool.h"
+#include "source_solv.h"
+
 using namespace std;
 using namespace zypp;
 using namespace zypp::repo;
@@ -249,13 +253,14 @@
       static shared_ptr<Impl> _nullimpl( new Impl );
       return _nullimpl;
     }
-    
+
   private:
     friend Impl * rwcowClone<Impl>( const Impl * rhs );
     /** clone for RWCOW_pointer */
     Impl * clone() const
     { return new Impl( *this ); }
   };
+
   ///////////////////////////////////////////////////////////////////
 
   /** \relates RepoManager::Impl Stream output */
@@ -825,6 +830,9 @@
     return cache_status;
   }
 
+  Pool *the_pool;
+  map<data::RecordId, Source *> repo2source;
+
   Repository RepoManager::createFromCache( const RepoInfo &info,
                                            const ProgressData::ReceiverFnc & progressrcv )
   {
@@ -841,12 +849,41 @@
 
     MIL << "Repository " << info.alias() << " is cached" << endl;
 
+    if (!the_pool)
+    {
+      the_pool = pool_create ();
+      the_pool->verbose = 1;
+    }
+
     data::RecordId id = store.lookupRepository(info.alias());
+    map<data::RecordId,Source*>::const_iterator it = repo2source.find(id);
+    Source *source;
+    if (it == repo2source.end())
+    {
+      Pathname name = _pimpl->options.repoCachePath;
+      ostringstream os;
+      os << id.get();
+      name += os.str() + ".solv";
+      source = 0;
+      //cerr << "BLA: " << name.asString() << endl;
+      if (PathInfo(name.asString()).isExist())
+      {
+        FILE *fp = fopen (name.c_str(), "r");
+       if (fp)
+       {
+         source = pool_addsource_solv(the_pool, fp, name.c_str());
+         fclose (fp);
+       }
+      }
+      repo2source[id] = source;
+    } else
+      source = it->second;
     
     CombinedProgressData subprogrcv(progress);
     
     repo::cached::RepoOptions opts( info, _pimpl->options.repoCachePath, id );
     opts.readingResolvablesProgress = subprogrcv;
+    opts.source = source;
     repo::cached::RepoImpl::Ptr repoimpl =
         new repo::cached::RepoImpl( opts );
 

Modified: branches/use-solv/libzypp/zypp/capability/VersionedCap.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/zypp/capability/VersionedCap.cc?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/zypp/capability/VersionedCap.cc (original)
+++ branches/use-solv/libzypp/zypp/capability/VersionedCap.cc Fri Oct 12 17:49:57 2007
@@ -37,6 +37,31 @@
       return ret;
     }
 
+    bool VersionedCap::same (const CapabilityImpl_constPtr &_rhs) const
+    {
+      intrusive_ptr<const Self> rhs( asKind<Self>(_rhs) );
+      if (!rhs) {
+        /* Gnah!  VersionCap::kind() is "NamedCap", hence we might come
+          here with a NamedCap rhs, which then is not the same as us.  */
+       intrusive_ptr<const NamedCap> rhs2( asKind<NamedCap>(_rhs) );
+       if (!rhs2) {
+         std::cerr << "Argh! : " << this->kind() << " <-> " << _rhs->kind() << std::endl;
+         return false;
+       }
+       return name() == rhs2->name();
+      }
+      if (name() != rhs->name())
+        return false;
+      const Edition::MatchRange & other = rhs->_range;
+      if (_range.op != other.op)
+        return false;
+      const Edition &ed1 = _range.value;
+      const Edition &ed2 = other.value;
+      return (ed1.epoch() == ed2.epoch()
+             && ed1.version() == ed2.version()
+             && ed1.release() == ed2.release());
+    }
+
     size_t VersionedCap::hash() const
     {
       size_t ret = __gnu_cxx::hash<const char*>()( name().c_str() );

Modified: branches/use-solv/libzypp/zypp/capability/VersionedCap.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/zypp/capability/VersionedCap.h?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/zypp/capability/VersionedCap.h (original)
+++ branches/use-solv/libzypp/zypp/capability/VersionedCap.h Fri Oct 12 17:49:57 2007
@@ -57,6 +57,7 @@
       virtual Edition edition () const;
 
       virtual size_t hash() const;
+      virtual bool same (const CapabilityImpl_constPtr &rhs) const;
 
     protected:
       /** Implementation dependent value. */

Modified: branches/use-solv/libzypp/zypp/repo/cached/RepoImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/zypp/repo/cached/RepoImpl.cc?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/zypp/repo/cached/RepoImpl.cc (original)
+++ branches/use-solv/libzypp/zypp/repo/cached/RepoImpl.cc Fri Oct 12 17:49:57 2007
@@ -38,6 +38,9 @@
 #include "zypp/repo/cached/AtomImpl.h"
 #include "zypp/cache/CacheAttributes.h"
 
+#include "pool.h"
+#include "source_solv.h"
+
 using namespace zypp::detail;
 using namespace zypp::cache;
 using namespace std;
@@ -66,6 +69,232 @@
   MIL << "Destroying repo '" << info().alias() << "'" << endl;
 }
 
+void RepoImpl::insertNVRAD (data::RecordId id, Resolvable::Kind kind, const NVRAD &nvrad)
+{
+  if ( kind == ResTraits<Package>::kind )
+  {
+    ResImplTraits<cached::PackageImpl>::Ptr impl = new cached::PackageImpl(id, this);
+    Package::Ptr package = detail::makeResolvableFromImpl( nvrad, impl );
+    _store.insert( package );
+  }
+  else if ( kind == ResTraits<SrcPackage>::kind )
+  {
+    ResImplTraits<cached::SrcPackageImpl>::Ptr impl = new cached::SrcPackageImpl(id, this);
+    SrcPackage::Ptr srcpackage = detail::makeResolvableFromImpl( nvrad, impl );
+    _store.insert( srcpackage );
+  }
+  else if ( kind == ResTraits<Product>::kind )
+  {
+    ResImplTraits<cached::ProductImpl>::Ptr impl = new cached::ProductImpl(id, this);
+    Product::Ptr product = detail::makeResolvableFromImpl( nvrad, impl );
+    _store.insert( product );
+  }
+  else if ( kind == ResTraits<Pattern>::kind )
+  {
+    ResImplTraits<cached::PatternImpl>::Ptr impl = new cached::PatternImpl(id, this);
+    Pattern::Ptr pattern = detail::makeResolvableFromImpl( nvrad, impl );
+    _store.insert( pattern );
+  }
+  else if ( kind == ResTraits<Patch>::kind )
+  {
+    ResImplTraits<cached::PatchImpl>::Ptr impl = new cached::PatchImpl(id, this);
+    Patch::Ptr patch = detail::makeResolvableFromImpl( nvrad, impl );
+    _store.insert( patch );
+  }
+  else if ( kind == ResTraits<Message>::kind )
+  {
+    ResImplTraits<cached::MessageImpl>::Ptr impl = new cached::MessageImpl(id, this);
+    Message::Ptr message = detail::makeResolvableFromImpl( nvrad, impl );
+    _store.insert( message );
+  }
+  else if ( kind == ResTraits<Script>::kind )
+  {
+    ResImplTraits<cached::ScriptImpl>::Ptr impl = new cached::ScriptImpl(id, this);
+    Script::Ptr script = detail::makeResolvableFromImpl( nvrad, impl );
+    _store.insert( script );
+  }
+  else if ( kind == ResTraits<Atom>::kind )
+  {
+    ResImplTraits<cached::AtomImpl>::Ptr impl = new cached::AtomImpl(id, this);
+    Atom::Ptr atom = detail::makeResolvableFromImpl( nvrad, impl );
+    _store.insert( atom );
+  }
+}
+
+static inline Resolvable::Kind
+kind_for_name (const char *name, Id arch)
+{
+  switch (name[0])
+    {
+      case 'a':
+        if (!strncmp (name, "atom:", 5))
+         return ResTraits<Atom>::kind;
+       break;
+      case 'l':
+        if (!strncmp (name, "language:", 9))
+         return ResTraits<Language>::kind;
+       break;
+      case 'm':
+        if (!strncmp (name, "message:", 8))
+         return ResTraits<Message>::kind;
+       break;
+      case 'p':
+        if (!strncmp (name, "patch:", 6))
+         return ResTraits<Patch>::kind;
+        if (!strncmp (name, "pattern:", 8))
+         return ResTraits<Pattern>::kind;
+        if (!strncmp (name, "product:", 8))
+         return ResTraits<Product>::kind;
+       break;
+      case 's':
+        if (!strncmp (name, "selection:", 10))
+         return ResTraits<Selection>::kind;
+        if (!strncmp (name, "script:", 7))
+         return ResTraits<Script>::kind;
+       break;
+    }
+  if (arch == ARCH_SRC)
+    return ResTraits<SrcPackage>::kind;
+  return ResTraits<Package>::kind;
+}
+
+map<Id, Capability> id2cap;
+map<Id, Edition> id2ed;
+static const Rel flag2rel[8] = {
+  Rel::NONE,
+  Rel::GT,
+  Rel::EQ,
+  Rel::GE,
+  Rel::LT,
+  Rel::NE,
+  Rel::LE,
+  Rel::ANY
+};
+static inline void
+add_deps (CapFactory &factory, Pool *pool, CapSet &caps, Id *ids)
+{
+  Id id;
+  char buf[1024];
+  if (!ids)
+    return;
+  while((id = *ids++) != 0)
+    {
+      if (id2cap.find(id) != id2cap.end())
+        {
+         caps.insert (id2cap[id]);
+       }
+      else
+        {
+         const char *name = id2str (pool, id);
+         capability::CapabilityImpl::Ptr capi;
+         if (name[0] == '/')
+           {
+             capi = new capability::FileCap (ResTraits<Package>::kind, name);
+           }
+         else if (!strncmp (name, "hal(", 4))
+           {
+             char * modname = strdup (name + 4);
+             if (strlen (modname))
+               modname[strlen (modname) - 1] = 0;
+             capi = new capability::HalCap (ResTraits<SystemResObject>::kind, modname);
+             free (modname);
+           }
+         else if (!strncmp (name, "modalias(", 9))
+           {
+             char * modname = strdup (name + 9);
+             if (strlen (modname))
+               modname[strlen (modname) - 1] = 0;
+             capi = new capability::ModaliasCap (ResTraits<SystemResObject>::kind, modname);
+             free (modname);
+           }
+         else if (!strncmp (name, "filesystem(", 11))
+           {
+             char * modname = strdup (name + 11);
+             if (strlen (modname))
+               modname[strlen (modname) - 1] = 0;
+             capi = new capability::FilesystemCap (ResTraits<SystemResObject>::kind, modname);
+             free (modname);
+           }
+         else if (!ISRELDEP (id))
+           {
+             Resolvable::Kind refer = kind_for_name (name, 1);
+             capi = new capability::NamedCap (refer, name);
+           }
+         else
+           {
+             Reldep *rd = GETRELDEP (pool, id);
+             Resolvable::Kind refer = kind_for_name (name, 1);
+             Rel rel = flag2rel[rd->flags & 7];
+             Edition ed;
+             if (id2ed.find (rd->evr) != id2ed.end())
+               ed = id2ed[rd->evr];
+             else
+               {
+                 /* ??? catch exception here? */
+                 ed = Edition (id2str (pool, rd->evr));
+                 id2ed[rd->evr] = ed;
+               }
+              capi = new capability::VersionedCap( refer, name, rel, ed );
+           }
+
+         //snprintf(buf, sizeof(buf), "%s%s%s", name, id2rel(pool, id), id2evr(pool, id));
+         /* XXX Bah, we need the kind of the thing referred _to_ :-(
+            Do something about the kind stuff, s->name contains it,
+            but zypp wants to have it as extra field.  */
+         //cerr << "doing cap " << id << ": " << buf << endl;
+         //capability::CapabilityImpl::Ptr capi = capability::parse (refer, buf);
+         Capability cap = factory.fromImpl(capi);
+         id2cap[id] = cap;
+          caps.insert (cap);
+        }
+    }
+}
+
+void RepoImpl::createResFromSource()
+{
+  Source *source = _options.source;
+  Pool *pool = source->pool;
+  int i;
+  cerr << "SOLV: have " << source->nsolvables << " solvables" << endl;
+  CapFactory capfactory;
+  for (i = source->start; i < source->start + source->nsolvables; i++)
+    {
+      Solvable *s = pool->solvables + i;
+      data::RecordId id(i);
+      Resolvable::Kind kind;
+      Edition ed;
+      const char *name = id2str (pool, s->name);
+      if (id2ed.find (s->evr) != id2ed.end())
+       ed = id2ed[s->evr];
+      else
+        {
+         /* ??? catch exception here? */
+         /* XXX Edition ctor does a regexp if given a string :( */
+         ed = Edition (id2str (pool, s->evr));
+         id2ed[s->evr] = ed;
+        }
+      NVRAD nvrad ( name,
+                    ed,
+                   /* XXX Arch needs to become Id based.  */
+                    Arch(id2str (pool, s->arch)));
+      add_deps (capfactory, pool, nvrad[Dep::PROVIDES], s->provides);
+      add_deps (capfactory, pool, nvrad[Dep::REQUIRES], s->requires);
+      add_deps (capfactory, pool, nvrad[Dep::CONFLICTS], s->conflicts);
+      add_deps (capfactory, pool, nvrad[Dep::OBSOLETES], s->obsoletes);
+      add_deps (capfactory, pool, nvrad[Dep::RECOMMENDS], s->recommends);
+      add_deps (capfactory, pool, nvrad[Dep::SUGGESTS], s->suggests);
+      add_deps (capfactory, pool, nvrad[Dep::FRESHENS], s->freshens);
+      add_deps (capfactory, pool, nvrad[Dep::ENHANCES], s->enhances);
+      add_deps (capfactory, pool, nvrad[Dep::SUPPLEMENTS], s->supplements);
+      //add_deps (capfactory, nvrad[Dep::PREREQUIRES], s->prerequires);
+      /* XXX do something about the kind stuff, s->name contains it,
+         but zypp wants to have it as extra field.  */
+      kind = kind_for_name (name, s->arch);
+      insertNVRAD (id, kind, nvrad);
+    }
+  //id2cap.clear();
+}
+
 void RepoImpl::createResolvables()
 {
   ProgressData ticks;
@@ -74,6 +303,12 @@
   CombinedProgressData subprogrcv(ticks);
 
   debug::Measure m("create resolvables");
+  if (_options.source)
+  {
+    createResFromSource();
+    return;
+  }
+
   CapFactory capfactory;
   try
   {

Modified: branches/use-solv/libzypp/zypp/repo/cached/RepoImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/zypp/repo/cached/RepoImpl.h?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/zypp/repo/cached/RepoImpl.h (original)
+++ branches/use-solv/libzypp/zypp/repo/cached/RepoImpl.h Fri Oct 12 17:49:57 2007
@@ -25,6 +25,8 @@
 #include "zypp/cache/ResolvableQuery.h"
 #include "zypp/RepoInfo.h"
 
+#include "source_solv.h"
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -44,6 +46,7 @@
           : repoinfo(repoinfo_)
           , dbdir(dbdir_)
           , repository_id(repository_id_)
+         , source(0)
         {}
 
 
@@ -52,6 +55,7 @@
         RepoInfo repoinfo;
         Pathname dbdir;
         data::RecordId repository_id;
+       Source *source;
       };
 
       /**
@@ -81,6 +85,8 @@
                                 data::RecordId repo_id,
                                 std::map<data::RecordId, std::pair<Resolvable::Kind, NVRAD> > &nvras,
                                 ProgressData &ticks );
+       void insertNVRAD (data::RecordId id, Resolvable::Kind kind, const NVRAD &nvrad);
+       void createResFromSource();
         cache::CacheTypes _type_cache;
         cache::ResolvableQuery _rquery;
         RepoOptions _options;

Modified: branches/use-solv/libzypp/zypp/target/rpm/RpmDb.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/zypp/target/rpm/RpmDb.cc?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/zypp/target/rpm/RpmDb.cc (original)
+++ branches/use-solv/libzypp/zypp/target/rpm/RpmDb.cc Fri Oct 12 17:49:57 2007
@@ -28,11 +28,15 @@
 #include "zypp/base/String.h"
 #include "zypp/base/Regex.h"
 
+#include "zypp/data/RecordId.h"
+
 #include "zypp/Date.h"
 #include "zypp/Pathname.h"
 #include "zypp/PathInfo.h"
 #include "zypp/PublicKey.h"
 
+#include "zypp/capability/Capabilities.h"
+
 #include "zypp/target/rpm/RpmDb.h"
 #include "zypp/target/rpm/RpmCallbacks.h"
 
@@ -55,6 +59,7 @@
 
 namespace zypp
 {
+extern Pool * the_pool;
 namespace target
 {
 namespace rpm
@@ -277,6 +282,7 @@
 RpmDb::RpmDb()
     : _dbStateInfo( DbSI_NO_INIT )
     , _packages( * new Packages ) // delete in destructor
+    , source(0)
 #warning Check for obsolete memebers
     , _backuppath ("/var/adm/backup")
     , _packagebackups(false)
@@ -1254,6 +1260,117 @@
   return pptr;
 }
 
+static bool
+update_solv (string dbpath)
+{
+  cerr << "trying " << dbpath << endl;
+  if (dbpath != "//var/lib/rpm" && dbpath != "/var/lib/rpm")
+    return false;
+  cerr << "Building system.solv" << endl;
+  system ("if test -f /tmp/system.solv; then /matz/projects/solver/klaus/dev/tools/rpmdb2solv /tmp/system.solv > /tmp/system.solv.new; else /matz/projects/solver/klaus/dev/tools/rpmdb2solv > /tmp/system.solv.new; fi; mv /tmp/system.solv.new /tmp/system.solv");
+  return true;
+}
+
+static inline Resolvable::Kind
+kind_for_name (const char *name, Id arch)
+{
+  switch (name[0])
+    {
+      case 'a':
+        if (!strncmp (name, "atom:", 5))
+         return ResTraits<Atom>::kind;
+       break;
+      case 'l':
+        if (!strncmp (name, "language:", 9))
+         return ResTraits<Language>::kind;
+       break;
+      case 'm':
+        if (!strncmp (name, "message:", 8))
+         return ResTraits<Message>::kind;
+       break;
+      case 'p':
+        if (!strncmp (name, "patch:", 6))
+         return ResTraits<Patch>::kind;
+        if (!strncmp (name, "pattern:", 8))
+         return ResTraits<Pattern>::kind;
+        if (!strncmp (name, "product:", 8))
+         return ResTraits<Product>::kind;
+       break;
+      case 's':
+        if (!strncmp (name, "selection:", 10))
+         return ResTraits<Selection>::kind;
+        if (!strncmp (name, "script:", 7))
+         return ResTraits<Script>::kind;
+       break;
+    }
+  if (arch == ARCH_SRC)
+    return ResTraits<SrcPackage>::kind;
+  return ResTraits<Package>::kind;
+}
+
+map<Id, Capability> id2cap;
+map<Id, Edition> id2ed;
+static const Rel flag2rel[8] = {
+  Rel::NONE,
+  Rel::GT,
+  Rel::EQ,
+  Rel::GE,
+  Rel::LT,
+  Rel::NE,
+  Rel::LE,
+  Rel::ANY
+};
+static inline void
+add_deps (CapFactory &factory, Pool *pool, CapSet &caps, Id *ids)
+{
+  Id id;
+  if (!ids)
+    return;
+  while((id = *ids++) != 0)
+    {
+      if (id2cap.find(id) != id2cap.end())
+        {
+         caps.insert (id2cap[id]);
+       }
+      else
+        {
+         const char *name = id2str (pool, id);
+         capability::CapabilityImpl::Ptr capi;
+         if (name[0] == '/')
+           {
+             capi = new capability::FileCap (ResTraits<Package>::kind, name);
+           }
+         /* ??? The normal target::rpm code doesn't look at the specific
+            kind of the dependencies (hal/modalias/filesystem).  */
+         else if (!ISRELDEP (id))
+           {
+             Resolvable::Kind refer = kind_for_name (name, 1);
+             capi = new capability::NamedCap (refer, name);
+           }
+         else
+           {
+             Reldep *rd = GETRELDEP (pool, id);
+             Resolvable::Kind refer = kind_for_name (name, 1);
+             Rel rel = flag2rel[rd->flags & 7];
+             Edition ed;
+             if (id2ed.find (rd->evr) != id2ed.end())
+               ed = id2ed[rd->evr];
+             else
+               {
+                 /* ??? catch exception here? */
+                 ed = Edition (id2str (pool, rd->evr));
+                 id2ed[rd->evr] = ed;
+               }
+              capi = new capability::VersionedCap( refer, name, rel, ed );
+           }
+
+         Capability cap = factory.fromImpl(capi);
+         id2cap[id] = cap;
+          caps.insert (cap);
+        }
+    }
+}
+
 const list<Package::Ptr> & RpmDb::doGetPackages(callback::SendReport<ScanDBReport> & report)
 {
   if ( packagesValid() )
@@ -1262,19 +1379,88 @@
   }
 
   _packages.clear();
+  if (source)
+    {
+      pool_freesource (the_pool, source);
+      source = 0;
+    }
+  if (update_solv ((root() + dbPath()).asString()))
+    {
+      FILE *fp = fopen ("/tmp/system.solv", "r");
+      if (fp)
+        {
+          source = pool_addsource_solv(the_pool, fp, "system");
+         fclose (fp);
+       }
+      if (source)
+        {
+         int i;
+         cerr << "SOLV: have " << source->nsolvables << " solvables" << endl;
+         CapFactory capfactory;
+         for (i = source->start; i < source->start + source->nsolvables; i++)
+           {
+             Solvable *s = the_pool->solvables + i;
+             data::RecordId id(i);
+             Resolvable::Kind kind;
+             Edition ed;
+             const char *name = id2str (the_pool, s->name);
+             if (id2ed.find (s->evr) != id2ed.end())
+               ed = id2ed[s->evr];
+             else
+               {
+                 /* ??? catch exception here? */
+                 /* XXX Edition ctor does a regexp if given a string :( */
+                 ed = Edition (id2str (the_pool, s->evr));
+                 id2ed[s->evr] = ed;
+               }
+             NVRAD nvrad ( name,
+                           ed,
+                           /* XXX Arch needs to become Id based.  */
+                           Arch(id2str (the_pool, s->arch)));
+             add_deps (capfactory, the_pool, nvrad[Dep::PROVIDES], s->provides);
+             add_deps (capfactory, the_pool, nvrad[Dep::REQUIRES], s->requires);
+             add_deps (capfactory, the_pool, nvrad[Dep::CONFLICTS], s->conflicts);
+             add_deps (capfactory, the_pool, nvrad[Dep::OBSOLETES], s->obsoletes);
+             add_deps (capfactory, the_pool, nvrad[Dep::RECOMMENDS], s->recommends);
+             add_deps (capfactory, the_pool, nvrad[Dep::SUGGESTS], s->suggests);
+             add_deps (capfactory, the_pool, nvrad[Dep::FRESHENS], s->freshens);
+             add_deps (capfactory, the_pool, nvrad[Dep::ENHANCES], s->enhances);
+             add_deps (capfactory, the_pool, nvrad[Dep::SUPPLEMENTS], s->supplements);
+             //add_deps (capfactory, nvrad[Dep::PREREQUIRES], s->prerequires);
+             detail::ResImplTraits<RPMPackageImpl>::Ptr impl( new RPMPackageImpl() );
+
+             Package::Ptr pptr;
+             try
+             {
+               // create package from dataprovider
+               pptr = detail::makeResolvableFromImpl( nvrad, impl );
+             }
+             catch (Exception & excpt_r)
+             {
+               ZYPP_CAUGHT( excpt_r );
+               ERR << "Can't create Package::Ptr" << endl;
+             }
+             if (pptr)
+               _packages._list.push_back (pptr);
+             /* ??? deal with filerequires somehow?  Should be done in the solver.  */
+           }
+       }
+    }
 
   ///////////////////////////////////////////////////////////////////
   // Collect package data.
   ///////////////////////////////////////////////////////////////////
+  librpmDb::db_const_iterator iter;
+  CapFactory _f;
+
+  if (!source) {
   unsigned expect = 0;
   librpmDb::constPtr dbptr;
   librpmDb::dbAccess( dbptr );
   expect = dbptr->size();
   DBG << "Expecting " << expect << " packages" << endl;
 
-  librpmDb::db_const_iterator iter;
   unsigned current = 0;
-  CapFactory _f;
   Pathname location;
 
   for ( iter.findAll(); *iter; ++iter, ++current, report->progress( (100*current)/expect))
@@ -1298,6 +1484,7 @@
 
     _packages._list.push_back( pptr );
   }
+  }
   _packages.buildIndex();
   DBG << "Found installed packages: " << _packages._list.size() << endl;
 

Modified: branches/use-solv/libzypp/zypp/target/rpm/RpmDb.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/zypp/target/rpm/RpmDb.h?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/zypp/target/rpm/RpmDb.h (original)
+++ branches/use-solv/libzypp/zypp/target/rpm/RpmDb.h Fri Oct 12 17:49:57 2007
@@ -30,6 +30,9 @@
 #include "zypp/target/rpm/RpmCallbacks.h"
 #include "zypp/ZYppCallbacks.h"
 
+#include "pool.h"
+#include "source_solv.h"
+
 namespace zypp
 {
 namespace target
@@ -239,6 +242,7 @@
   class Packages;
 
   Packages & _packages;
+  Source *source;
 
   std::set<std::string> _filerequires;
 

Modified: branches/use-solv/libzypp/zypp/target/rpm/RpmPackageImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/zypp/target/rpm/RpmPackageImpl.cc?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/zypp/target/rpm/RpmPackageImpl.cc (original)
+++ branches/use-solv/libzypp/zypp/target/rpm/RpmPackageImpl.cc Fri Oct 12 17:49:57 2007
@@ -48,17 +48,45 @@
     _license(data->tag_license()),
     _packager(data->tag_packager()),
     _group(data->tag_group()),
-    _changelog(data->tag_changelog()),
+    //_changelog(data->tag_changelog()),
+    _changelog(Changelog()),
     _type("rpm"), // FIXME in the future
-    _filenames(data->tag_filenames()),
+    //_filenames(data->tag_filenames()),
+    _filenames(std::list<std::string>()),
     _size(data->tag_size())
 {
   // we know we are reading english.
-  _description.setText(data->tag_description(), Locale("en"));
+  //_description.setText(data->tag_description(), Locale("en"));
+  _description.setText(std::string(), Locale("en"));
   data->tag_du(_disk_usage);
   _location.setDownloadSize(data->tag_archivesize());
 }
 
+RPMPackageImpl::RPMPackageImpl()
+    : _summary("XXXXXXXXXXX", Locale("en")),
+    _description("XXX"),
+    _buildtime(Date()),
+    _installtime(Date()),
+    _buildhost(""),
+    _url(""),
+    _vendor(""),
+    _license(""),
+    _packager(""),
+    _group(PackageGroup()),
+    //_changelog(data->tag_changelog()),
+    _changelog(Changelog()),
+    _type("rpm"), // FIXME in the future
+    //_filenames(data->tag_filenames()),
+    _filenames(std::list<std::string>()),
+    _size(0)
+{
+  // we know we are reading english.
+  //_description.setText(data->tag_description(), Locale("en"));
+  _description.setText(std::string(), Locale("en"));
+  //data->tag_du(_disk_usage);
+  //_location.setDownloadSize(data->tag_archivesize());
+}
+
 /** Package summary */
 TranslatedText RPMPackageImpl::summary() const
 {
@@ -128,6 +156,7 @@
 /** */
 Changelog RPMPackageImpl::changelog() const
 {
+std::cerr << "Argh" << std::endl;
   return _changelog;
 }
 
@@ -189,6 +218,7 @@
 /** */
 std::list<std::string> RPMPackageImpl::filenames() const
 {
+//std::cerr << "Argh2" << std::endl;
   return _filenames;
 }
 

Modified: branches/use-solv/libzypp/zypp/target/rpm/RpmPackageImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/use-solv/libzypp/zypp/target/rpm/RpmPackageImpl.h?rev=7507&r1=7506&r2=7507&view=diff
==============================================================================
--- branches/use-solv/libzypp/zypp/target/rpm/RpmPackageImpl.h (original)
+++ branches/use-solv/libzypp/zypp/target/rpm/RpmPackageImpl.h Fri Oct 12 17:49:57 2007
@@ -40,6 +40,8 @@
     const RpmHeader::constPtr data
   );
 
+  RPMPackageImpl();
+
   /** Package summary */
   virtual TranslatedText summary() const;
   /** Package description */

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages