lets try to append a resolvable
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 15 Jan 2008 22:53:02 +0000 (22:53 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 15 Jan 2008 22:53:02 +0000 (22:53 +0000)
zypp/cache/SolvStore.cc
zypp/cache/SolvStore.h

index fcfe4a6..b1b4678 100644 (file)
@@ -349,6 +349,32 @@ void SolvStore::updatePackageLang( const data::RecordId & resolvable_id,
   appendTranslatedStringAttribute( resolvable_id, attrResObjectDelnotify(),        data_r->delnotify );
 }
 
+::_Solvable* SolvStore::appendResolvable( const data::RecordId &repository_id,
+                                          const data::Resolvable_Ptr &res )
+{
+  Repo *repo;
+  map<RecordId, Repo*>::const_iterator it = _pimpl->_id2repo.find(repository_id);
+  if ( it == _pimpl->_id2repo.end() )
+  {
+    // throw
+  }
+  repo = it->second;
+
+  Solvable *s = pool_id2solvable(_pimpl->_pool, repo_add_solvable(repo));
+  s->evr = str2id(_pimpl->_pool, res->edition.c_str(), 1);
+//   s->provides = adddep(pool, pd, s->provides, atts, 0);
+// 
+//   s->name = str2id(pool, nvra.name.c_str(), 1);
+//   s->arch = str2id(pool, nvra.arch.c_str(), 1);
+//   s->vendor = str2id(pool, nvra.vendor.c_str(), 1);
+// 
+//   if (!s->arch)
+//     s->arch = ARCH_NOARCH;
+
+  return s;
+}
+
+
 RecordId SolvStore::appendResolvable( const RecordId &repository_id,
                                        const Resolvable::Kind &kind,
                                        const _NVRA &nvra,
@@ -544,6 +570,7 @@ RecordId SolvStore::lookupOrAppendRepository( const string &alias )
   if (it == _pimpl->_name2repoid.end())
   {
     _pimpl->_name2repoid[alias] = ++_pimpl->_last_repoid;
+    _pimpl->_id2repo[_pimpl->_last_repoid] = repo_create(_pimpl->_pool, alias.c_str());
   }
   return _pimpl->_name2repoid[alias];
 }
index 4057c50..9168e68 100644 (file)
@@ -29,6 +29,8 @@
 #include "zypp/ProgressData.h"
 #include "zypp/cache/Attribute.h"
 
+#include "satsolver/solvable.h"
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -225,6 +227,7 @@ namespace zypp
                                      const data::Packagebase_Ptr & data_r );
       //@}
       public:
+
       /**
        * Appends a resolvable to the store.
        *
@@ -758,6 +761,35 @@ namespace zypp
       data::RecordId lookupOrAppendFileName( const std::string &name );
 
     protected:
+
+       /**
+       * Appends a solvable to the store.
+       *
+       * You have to specify with \a kind of resolvable are you inserting
+       * and its \c _NVRA (name version release and architecture ).
+       * Optionaly you can pass a list of \c CapabilityImpl::Ptr
+       * as dependencies for the resolvable.
+       *
+       * You have to specify the RecordId for the repository owning
+       * this resolvable. Yuu can obtain it with
+       * \ref lookupOrAppendRepository
+       *
+       * You can create those \a deps using \ref capability::parse
+       * functions, or the build methods to create specific types
+       * of capabilities:
+       * \ref capability::buildVersioned for \c VersionedCap
+       * \ref capability::buildNamed for \c NamedCap
+       * etc.
+       *
+       * Once the resolvable is inserted, you will get back the id
+       * if it in the store. Which you can use for later adding
+       * other properties.
+       *
+       */
+      ::_Solvable* appendResolvable( const data::RecordId &repository_id,
+                                     const data::Resolvable_Ptr &res );
+
+    protected:
       /**
        * Internally used function that appends a entry in
        * the capabilities table for a specific capability