Fixed some missing package and source package attributes.
authorMichael Andres <ma@suse.de>
Thu, 3 Apr 2008 10:56:33 +0000 (10:56 +0000)
committerMichael Andres <ma@suse.de>
Thu, 3 Apr 2008 10:56:33 +0000 (10:56 +0000)
17 files changed:
devel/devel.ma/NewPool.cc
package/libzypp.changes
zypp/Arch.h
zypp/Capability.cc
zypp/CheckSum.h
zypp/Edition.h
zypp/IdString.cc
zypp/IdString.h
zypp/IdStringType.h
zypp/Package.cc
zypp/Package.h
zypp/SrcPackage.cc
zypp/sat/SolvAttr.cc
zypp/sat/SolvAttr.h
zypp/sat/Solvable.cc
zypp/sat/Solvable.h
zypp/sat/detail/PoolImpl.cc

index 6397c17..8125a43 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "zypp/sat/Pool.h"
 #include "zypp/sat/LocaleSupport.h"
+#include "zypp/sat/detail/PoolImpl.h"
 
 #include <zypp/base/GzStream.h>
 
@@ -141,6 +142,12 @@ std::ostream & testDump( std::ostream & str, const PoolItem & pi )
   if ( p )
   {
 #define OUTS(V) str << str::form("%-25s: ",#V) << p->V() << endl
+    Locale l( "de" );
+    str << str::form("%-25s: ",l.code().c_str()) << p->summary(l) << endl;
+    l = Locale( "fr" );
+    str << str::form("%-25s: ",l.code().c_str()) << p->summary(l) << endl;
+    l = Locale( "dsdf" );
+    str << str::form("%-25s: ",l.code().c_str()) << p->summary(l) << endl;
     OUTS( summary );
     OUTS( size );
     OUTS( downloadSize );
@@ -149,6 +156,8 @@ std::ostream & testDump( std::ostream & str, const PoolItem & pi )
     OUTS( checksum );
     OUTS( location );
 #undef OUTS
+
+
   }
   return str;
 }
@@ -442,6 +451,32 @@ void testCMP( const L & lhs, const R & rhs )
 namespace zypp
 {
 //   poolItemIterator
+  template <class _Filter>
+  class PoolFilter
+  {
+    typedef filter_iterator<_Filter,ResPool::const_iterator> iterator;
+
+    public:
+      PoolFilter()
+      {}
+
+      PoolFilter( const _Filter & filter_r )
+      : _filter( filter_r )
+      {}
+
+      iterator begin() const
+      { return ResPool::instance().filterBegin(_filter); }
+
+      iterator end() const
+      { return ResPool::instance().filterEnd(_filter); }
+
+    private:
+      _Filter _filter;
+  };
+
+  template <class _Filter>
+  PoolFilter<_Filter> makePoolFilter( const _Filter & filter_r )
+  { return PoolFilter<_Filter>( filter_r ); }
 }
 
 void tt( const std::string & name_r, ResKind kind_r = ResKind::package )
@@ -456,6 +491,141 @@ void tt( const std::string & name_r, ResKind kind_r = ResKind::package )
   }
 }
 
+bool myfilter( const PoolItem & pi )
+{
+  if ( pi->name() == "ruby" )
+    return true;
+  return false;
+}
+
+struct Foo : private debug::TraceCAD<Foo>
+{};
+
+namespace zypp
+{
+  namespace sat
+  {
+
+    class LookupAttr
+    {
+      public:
+        LookupAttr()
+        {}
+        LookupAttr( SolvAttr attr_r, Repository repo_r )
+        : _attr( attr_r ), _repo( repo_r )
+        {}
+        LookupAttr( SolvAttr attr_r, Solvable slv_r )
+        : _attr( attr_r ), _repo( slv_r.repository() ), _slv( slv_r )
+        {}
+
+      public:
+        class iterator
+        {
+          friend bool operator==( const iterator & lhs, const iterator & rhs );
+
+          public:
+            iterator()
+            : _valid( false )
+            {}
+
+          public:
+            iterator & operator++()
+            { _valid = ::dataiterator_step( &_di ); return *this; }
+
+            IdString operator*() const
+            { return IdString( _valid ? ::repodata_globalize_id( _di.data, _di.kv.id ) : detail::noId ); }
+
+          private:
+            friend class LookupAttr;
+            iterator( ::Dataiterator di_r )
+            : _di( di_r ), _valid( ::dataiterator_step( &_di ) )
+            {}
+
+          private:
+            ::Dataiterator _di;
+            bool           _valid;
+        };
+
+      public:
+        iterator begin() const
+        {
+          if ( ! (_attr && _repo ) )
+            return iterator();
+          ::Dataiterator di;
+          ::dataiterator_init( &di, _repo.id(), _slv.id(), _attr.id(), 0, SEARCH_NO_STORAGE_SOLVABLE );
+          return iterator( di );
+        }
+
+        iterator end() const
+        { return iterator(); }
+
+      private:
+        SolvAttr   _attr;
+        Repository _repo;
+        Solvable   _slv;
+    };
+
+    inline bool operator==( const LookupAttr::iterator & lhs, const LookupAttr::iterator & rhs )
+    { return( lhs._valid == rhs._valid && ( !lhs._valid || lhs._di == rhs._di ) ); }
+
+    inline bool operator!=( const LookupAttr::iterator & lhs, const LookupAttr::iterator & rhs )
+    { return ! (lhs == rhs); }
+  }
+
+}
+
+
+void ditest( sat::Solvable slv_r )
+{
+  MIL << slv_r << endl;
+
+  sat::LookupAttr q( sat::SolvAttr::keywords, slv_r );
+  dumpRange( MIL, q.begin(), q.end() ) << endl;
+  sat::LookupAttr::iterator a1( q.begin() );
+  SEC << ( a1 == q.begin() ) << endl;
+  ++a1;
+  SEC << ( a1 == q.begin() ) << endl;
+  SEC << ( a1 == ++q.begin() ) << endl;
+  return;
+  ::_Pool * pool = sat::Pool::instance().get();
+  ::_Repo * repo = slv_r.repository().get();
+  sat::SolvAttr attr( "susetags:datadir" );
+  attr = sat::SolvAttr::keywords;
+  attr = sat::SolvAttr::keywords;
+
+  if ( attr )
+  {
+    INT << attr << endl;
+    unsigned steps = 3;
+    ::Dataiterator di;
+    ::dataiterator_init( &di, repo, 0, attr.id(), 0, SEARCH_NO_STORAGE_SOLVABLE );
+    ::Dataiterator di2 = di;
+    while ( dataiterator_step( &di ) && --steps )
+    {
+      MIL << sat::Solvable(di.solvid) << endl;
+      DBG << dump(IdString(di.keyname)) << endl;
+      DBG << dump(IdString(::repodata_globalize_id(di.data, di.kv.id))) << endl;
+    }
+    SEC << endl;
+    di = di2;
+    steps = 5;
+    while ( dataiterator_step( &di ) && --steps )
+    {
+      MIL << sat::Solvable(di.solvid) << endl;
+      DBG << dump(IdString(di.keyname)) << endl;
+      DBG << dump(IdString(::repodata_globalize_id(di.data, di.kv.id))) << endl;
+    }
+
+
+  }
+}
+
+void ditest( const PoolItem & pi_r )
+{
+  ditest( pi_r.satSolvable() );
+}
+
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -465,6 +635,7 @@ int main( int argc, char * argv[] )
 try {
   zypp::base::LogControl::instance().logToStdErr();
   INT << "===[START]==========================================" << endl;
+  ZConfig::instance().setTextLocale(Locale("de"));
 
   sat::Pool satpool( sat::Pool::instance() );
   ResPool   pool( ResPool::instance() );
@@ -491,8 +662,8 @@ try {
           SEC << "cleanCache" << endl;
           repoManager.cleanCache( nrepo );
         }
-        SEC << "refreshMetadata" << endl;
-        repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced );
+        //SEC << "refreshMetadata" << endl;
+        //repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced );
         SEC << "buildCache" << endl;
         repoManager.buildCache( nrepo );
       }
@@ -541,15 +712,28 @@ try {
   USR << "pool: " << pool << endl;
 
   ///////////////////////////////////////////////////////////////////
-// Dataiterator di;
-// Id keyname = std2id (pool, "susetags:datadir");
-// if (keyname)
-//   {
-//     Dataitertor di;
-//     dataiterator_init(&di, repo, 0, keyname, 0, SEARCH_NO_STORAGE_SOLVABLE);
-//     if (dataiterator_step(&di))
-//       printf ("datadir: %s\n", di.kv.str);
-//   }
+  if ( 0 )
+  {
+    Measure x( "Upgrade" );
+    UpgradeStatistics u;
+    getZYpp()->resolver()->doUpgrade( u );
+  }
+  ///////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+
+
+  Repository repo( satpool.reposFind("openSUSE-10.3-DVD 10.3") );
+  if(0)//for_( it, repo.solvablesBegin(), repo.solvablesEnd() )
+  {
+    //testDump( MIL, PoolItem(*it) );
+  }
+
+
+  PoolItem pi ( getPi<Package>("CheckHardware",Edition("0.1-1088"),Arch_i586) );
+  MIL << pi << endl;
+  ditest( pi );
+
+
 
 #if 0
   const LocaleSet & avlocales( ResPool::instance().getAvailableLocales() );
@@ -585,94 +769,50 @@ try {
 #endif
 
 
-#if 0
-  sat::SolvAttr flist( "solvable:filelist" );
-
-  for_( it, pool.byIdentBegin<Package>("zypper"), pool.byIdentEnd<Package>("zypper") )
-  {
-    INT << *it << endl;
-    sat::Solvable s( it->satSolvable() );
-    MIL << sat::SolvAttr::summary << endl;
-    MIL << s.lookupStrAttribute( sat::SolvAttr::summary ) << endl;
-    MIL << s.lookupStrAttribute( sat::SolvAttr::noAttr ) << endl;
-
-    ::Dataitertor di;
-    ::dataiterator_init( &di, 0, s.id(), flist.id(), 0, SEARCH_NO_STORAGE_SOLVABLE );
-    while ( ::dataiterator_step( &di ) )
-    {
-
-    }
 
-  }
-#endif
 
 #if 0
-  for_( it, pool.byKindBegin<SrcPackage>(), pool.byKindEnd<SrcPackage>() )
+#define POOL_FILTER( N, V ) typeof(makePoolFilter(V)) N( (V) )
+
+  SEC << endl;
   {
-    MIL << *it << endl;
-    //tt( (*it)->name() );
+    POOL_FILTER( pf, &myfilter );
+    std::for_each( pf.begin(), pf.end(), Print() );
   }
-
-  IdString id ("amarok");
-  sat::WhatProvides w( Capability(id.id()) );
-
-  for_( it, w.begin(), w.end() )
   {
-    WAR << *it << endl;
-    MIL << PoolItem(*it) << endl;
-    Package_Ptr p( asKind<Package>(PoolItem(*it)) );
-    MIL << p << endl;
-    if ( p )
-    {
-      OnMediaLocation l( p->location() );
-      MIL << l << endl;
-    }
-    //OnMediaLocation
+    POOL_FILTER( pf, resfilter::ByName("zlib") );
+    std::for_each( pf.begin(), pf.end(), Print() );
   }
-
-  sat::Solvable a(65241);
-  PoolItem p( a );
-  USR << p << endl;
-  p.status().setTransact( true, ResStatus::USER );
-  USR << p << endl;
-  USR << PoolItem() << endl;
-#endif
-
-  if ( 0 )
+  SEC << endl;
   {
-    Measure x( "Upgrade" );
-    UpgradeStatistics u;
-    getZYpp()->resolver()->doUpgrade( u );
+    POOL_FILTER( pf, resfilter::ByName("zlib") );
+    std::for_each( pf.begin(), pf.end(), Print() );
   }
-
-
-  PoolItem pi ( getPi<Package>("vim") );
-  MIL << pi << endl;
-  if ( pi )
+  SEC << endl;
   {
-    testDump( MIL, pi );
+    POOL_FILTER( pf, or_c( chain( resfilter::ByName("zlib"),
+                                  resfilter::ByKind(ResKind::package) ),
+                           &myfilter )
+               );
+    std::for_each( pf.begin(), pf.end(), Print() );
   }
-  getZYpp()->resolver()->addRequire( Capability("vim") );
-  solve();
-  vdumpPoolStats( USR << "Transacting:"<< endl,
-                  make_filter_begin<resfilter::ByTransact>(pool),
-                      make_filter_end<resfilter::ByTransact>(pool) ) << endl;
-
-
+  SEC << endl;
+#endif
 
 
-  if ( 0 ) {
-  PoolItem pi ( getPi<Package>("amarok") );
-  MIL << pi << endl;
-  if ( pi )
+  if ( 0 )
   {
-    pi.status().setTransact( true, ResStatus::USER );
-    solve();
-    vdumpPoolStats( USR << "Transacting:"<< endl,
+    PoolItem pi ( getPi<Package>("amarok") );
+    MIL << pi << endl;
+    if ( pi )
+    {
+      pi.status().setTransact( true, ResStatus::USER );
+      solve();
+      vdumpPoolStats( USR << "Transacting:"<< endl,
                     make_filter_begin<resfilter::ByTransact>(pool),
                     make_filter_end<resfilter::ByTransact>(pool) ) << endl;
 
-  }
+    }
   }
   //vdumpPoolStats( USR << "Pool:"<< endl, pool.begin(), pool.end() ) << endl;
   //waitForInput();
index 3e87d79..e0c0f78 100644 (file)
@@ -1,9 +1,16 @@
 -------------------------------------------------------------------
+Thu Apr  3 12:55:50 CEST 2008 - ma@suse.de
+
+- Fixed some missing package and source package attributes.
+- revision 9348
+
+-------------------------------------------------------------------
 Thu Apr  3 11:59:13 CEST 2008 - ma@suse.de
 
 - Allow to store a media label in MediaSetAccess. This label is
   passed to a media change requests to describe which CD is 
   requested.  (bnc #330094)
+- Fixed some missing package and source package attributes.
 - revision 9347
 
 -------------------------------------------------------------------
index 8f7b76f..17bd467 100644 (file)
@@ -52,6 +52,9 @@ namespace zypp
     const char * c_str() const
     { return asString().c_str(); }
 
+    IdString::IdType id() const
+    { return idStr().id(); }
+
     /** Test for an empty Arch (this is "", not Arch_noarch). */
     bool empty() const
     { return asString().empty(); }
index 7fbe077..99c7836 100644 (file)
@@ -51,7 +51,7 @@ namespace zypp
 
       if ( op_r != Rel::ANY && ed_r != Edition::noedition )
       {
-        nid = ::rel2id( pool_r, nid, ed_r.idStr().id(), op_r.bits(), /*create*/true );
+        nid = ::rel2id( pool_r, nid, ed_r.id(), op_r.bits(), /*create*/true );
       }
 
       return nid;
index 398a553..99236dd 100644 (file)
@@ -36,7 +36,7 @@ namespace zypp
      * Creates a checksum for algorithm \param type
      * \throws CheckSumException if the checksum is invalid and can't be constructed
      */
-    CheckSum( const std::string & type, const std::string & checksum);
+    CheckSum( const std::string & type, const std::string & checksum );
     CheckSum( const std::string & type, std::istream & input_r );
     CheckSum();
 
index aec486d..c40a564 100644 (file)
@@ -77,7 +77,7 @@ namespace zypp
       Edition() {}
 
       /** Ctor taking edition as string. */
-      explicit Edition( sat::detail::IdType id_r )  : _str( IdString(id_r).c_str() ) {}
+      explicit Edition( IdString::IdType id_r )     : _str( IdString(id_r).c_str() ) {}
       explicit Edition( const IdString & idstr_r )  : _str( idstr_r.c_str() ) {}
       explicit Edition( const std::string & str_r ) : _str( str_r ) {}
       explicit Edition( const char * cstr_r )       : _str( cstr_r ) {}
index 4791f68..31f48ef 100644 (file)
@@ -74,6 +74,11 @@ namespace zypp
     return str << obj.c_str();
   }
 
+  std::ostream & dumpOn( std::ostream & str, const IdString & obj )
+  {
+    return str << '(' << obj.id() << ')' << obj.c_str();
+  }
+
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
index ac82cc6..a43fc71 100644 (file)
@@ -39,11 +39,14 @@ namespace zypp
                    private base::SafeBool<IdString>
   {
     public:
+      typedef sat::detail::IdType IdType;
+
+    public:
       /** Default ctor, empty string. */
       IdString() : _id( sat::detail::emptyId ) {}
 
       /** Ctor from id. */
-      explicit IdString( sat::detail::IdType id_r ) : _id( id_r ) {}
+      explicit IdString( IdType id_r ) : _id( id_r ) {}
 
       /** Ctor from string. */
       explicit IdString( const char * str_r );
@@ -96,19 +99,22 @@ namespace zypp
 
     public:
       /** Expert backdoor. */
-      sat::detail::IdType id() const
+      IdType id() const
       { return _id; }
     private:
       friend base::SafeBool<IdString>::operator bool_type() const;
       bool boolTest() const { return _id; }
     private:
-      sat::detail::IdType _id;
+      IdType _id;
   };
   ///////////////////////////////////////////////////////////////////
 
   /** \relates IdString Stream output */
   std::ostream & operator<<( std::ostream & str, const IdString & obj );
 
+  /** \relates IdString Stream output */
+  std::ostream & dumpOn( std::ostream & str, const IdString & obj );
+
   /** \relates IdString Equal */
   inline bool operator==( const IdString & lhs, const IdString & rhs )
   { return lhs.compareEQ( rhs ); }
index 1b0a4f2..15fc69d 100644 (file)
@@ -91,6 +91,7 @@ namespace zypp
       IdStringType() {}
       IdStringType(const IdStringType &) {}
       void operator=(const IdStringType &) {}
+      ~IdStringType() {}
 
     private:
       const Derived & self() const { return *static_cast<const Derived*>( this ); }
@@ -103,6 +104,8 @@ namespace zypp
       const char *  c_str()       const { return idStr().c_str(); }
       std::string   asString()    const { return idStr().asString(); }
 
+      IdString::IdType id()       const { return idStr().id(); }
+
     public:
       /** Evaluate in a boolean context <tt>( ! empty() )</tt>. */
       using base::SafeBool<Derived>::operator bool_type;
index 0674ead..c0c3f78 100644 (file)
@@ -90,26 +90,26 @@ namespace zypp
   std::list<std::string> Package::filenames() const
   { return std::list<std::string>(); }
 
+  CheckSum Package::checksum() const
+  { return lookupCheckSumAttribute( sat::SolvAttr::checksum ); }
+
   OnMediaLocation Package::location() const
-  {
-#warning MISSING checkdums in OnMediaLocation
-    OnMediaLocation loc;
-    unsigned medianr;
-    std::string filename = lookupLocation( medianr );
-    /* XXX This datadir should be part of RepoInfo.  */
-    if (repoInfo().type().toEnum() == repo::RepoType::YAST2_e)
-      filename = std::string("suse/") + filename;
-    loc.setLocation(filename, medianr);
-    return loc;
-  }
-
-#warning DUMMY sourcePkgName
+  { return lookupLocation(); }
+
  std::string Package::sourcePkgName() const
-  { return std::string(); }
+ {
+   // no id means same as package
+   sat::detail::IdType id( lookupIdAttribute( sat::SolvAttr::sourcename ) );
+   id = lookupIdAttribute(sat::SolvAttr::sourcearch);
+   return id ? IdString( id ).asString() : name();
+ }
 
-#warning DUMMY sourcePkgEdition
  Edition Package::sourcePkgEdition() const
-  { return Edition(); }
+ {
+   // no id means same as package
+   sat::detail::IdType id( lookupIdAttribute( sat::SolvAttr::sourceevr ) );
+   return id ? Edition( id ) : edition();
+ }
 
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
index cb56846..741d7ee 100644 (file)
@@ -66,12 +66,10 @@ namespace zypp
     std::list<std::string> filenames() const;
 
     /** Name of the source rpm this package was built from.
-     * Empty if unknown.
      */
     std::string sourcePkgName() const;
 
     /** Edition of the source rpm this package was built from.
-     * Empty if unknown.
      */
     Edition sourcePkgEdition() const;
 
@@ -79,8 +77,7 @@ namespace zypp
      * Checksum the source says this package should have.
      * \see \ref location
      */
-    CheckSum checksum() const
-    { return location().checksum(); }
+    CheckSum checksum() const;
 
     /** Location of the resolvable in the repository.
      * \ref OnMediaLocation conatins all information required to
index 79fff6b..3474485 100644 (file)
@@ -41,7 +41,7 @@ namespace zypp
   ///////////////////////////////////////////////////////////////////
 
   OnMediaLocation SrcPackage::location() const
-  { return OnMediaLocation(); }
+  { return lookupLocation(); }
 
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
index ea9c2bd..dd106ec 100644 (file)
@@ -44,6 +44,7 @@ namespace sat
   const SolvAttr SolvAttr::diskusage    ( SOLVABLE_DISKUSAGE );
 
   //package
+  const SolvAttr SolvAttr::checksum     ( SOLVABLE_CHECKSUM );
   const SolvAttr SolvAttr::medianr     ( SOLVABLE_MEDIANR );
   const SolvAttr SolvAttr::mediafile   ( SOLVABLE_MEDIAFILE );
   const SolvAttr SolvAttr::mediadir    ( SOLVABLE_MEDIADIR );
@@ -57,8 +58,6 @@ namespace sat
   const SolvAttr SolvAttr::sourcesize   ( "sourcesize" );
   const SolvAttr SolvAttr::authors      ( SOLVABLE_AUTHORS );
   const SolvAttr SolvAttr::filenames    ( "filenames" );
-  const SolvAttr SolvAttr::srcpkgname   ( "srcpkgname" );
-  const SolvAttr SolvAttr::srcpkgedition( "srcpkgedition" );
   const SolvAttr SolvAttr::filelist     ( SOLVABLE_FILELIST );
   const SolvAttr SolvAttr::sourcearch   ( SOLVABLE_SOURCEARCH );
   const SolvAttr SolvAttr::sourcename   ( SOLVABLE_SOURCENAME );
index 252a7c3..13d8e88 100644 (file)
@@ -51,6 +51,7 @@ namespace sat
       static const SolvAttr diskusage;
 
       //package
+      static const SolvAttr checksum;
       static const SolvAttr mediadir;
       static const SolvAttr medianr;
       static const SolvAttr mediafile;
@@ -64,8 +65,6 @@ namespace sat
       static const SolvAttr sourcesize;
       static const SolvAttr authors;
       static const SolvAttr filenames;
-      static const SolvAttr srcpkgname;
-      static const SolvAttr srcpkgedition;
       static const SolvAttr filelist;
       static const SolvAttr sourcearch;
       static const SolvAttr sourcename;
index 417ce53..4b341b8 100644 (file)
@@ -20,6 +20,7 @@
 #include "zypp/sat/detail/PoolImpl.h"
 #include "zypp/sat/Solvable.h"
 #include "zypp/Repository.h"
+#include "zypp/OnMediaLocation.h"
 
 using std::endl;
 
@@ -79,7 +80,7 @@ namespace zypp
     std::string Solvable::lookupStrAttribute( const SolvAttr & attr ) const
     {
       NO_SOLVABLE_RETURN( std::string() );
-      const char * s = ::solvable_lookup_str( _solvable, attr.idStr().id() );
+      const char * s = ::solvable_lookup_str( _solvable, attr.id() );
       return s ? s : std::string();
     }
 
@@ -89,11 +90,11 @@ namespace zypp
       const char * s = 0;
       if ( lang_r == Locale::noCode )
       {
-        s = ::solvable_lookup_str_poollang( _solvable, attr.idStr().id() );
+        s = ::solvable_lookup_str_poollang( _solvable, attr.id() );
       }
       else
       {
-        s = ::solvable_lookup_str_lang( _solvable, attr.idStr().id(), lang_r.code().c_str() );
+        s = ::solvable_lookup_str_lang( _solvable, attr.id(), lang_r.code().c_str() );
       }
       return s ? s : std::string();
    }
@@ -101,25 +102,64 @@ namespace zypp
     unsigned Solvable::lookupNumAttribute( const SolvAttr & attr ) const
     {
       NO_SOLVABLE_RETURN( 0 );
-      return ::solvable_lookup_num( _solvable, attr.idStr().id(), 0 );
+      return ::solvable_lookup_num( _solvable, attr.id(), 0 );
     }
 
     bool Solvable::lookupBoolAttribute( const SolvAttr & attr ) const
     {
       NO_SOLVABLE_RETURN( false );
-      return ::solvable_lookup_bool( _solvable, attr.idStr().id() );
+      return ::solvable_lookup_bool( _solvable, attr.id() );
     }
 
-    std::string Solvable::lookupLocation(unsigned &medianr) const
+    detail::IdType Solvable::lookupIdAttribute( const SolvAttr & attr ) const
     {
-      NO_SOLVABLE_RETURN( std::string() );
-      unsigned int nr;
-      char *l = solvable_get_location(_solvable, &nr);
-      medianr = nr;
-//     /* XXX This datadir should be part of RepoInfo.  */
-//     if (repoInfo().type().toEnum() == repo::RepoType::YAST2_e)
-//       filename = std::string("suse/") + filename;
-      return l ? std::string(l) : std::string();
+      NO_SOLVABLE_RETURN( detail::noId );
+      return ::solvable_lookup_id( _solvable, attr.id() );
+    }
+
+    CheckSum Solvable::lookupCheckSumAttribute( const SolvAttr & attr ) const
+    {
+      NO_SOLVABLE_RETURN( CheckSum() );
+      detail::IdType chksumtype = 0;
+      const char * s = ::solvable_lookup_checksum( _solvable, attr.id(), &chksumtype );
+      if ( ! s )
+        return CheckSum();
+      switch ( chksumtype )
+      {
+        case REPOKEY_TYPE_MD5:    return CheckSum::md5( s );
+        case REPOKEY_TYPE_SHA1:   return CheckSum::sha1( s );
+        case REPOKEY_TYPE_SHA256: return CheckSum::sha256( s );
+      }
+      return CheckSum( std::string(), s ); // try to autodetect
+    }
+
+    OnMediaLocation Solvable::lookupLocation() const
+    //std::string Solvable::lookupLocation( unsigned & medianr ) const
+    {
+      NO_SOLVABLE_RETURN( OnMediaLocation() );
+      // medianumber and path
+      unsigned medianr;
+      char * file = ::solvable_get_location( _solvable, &medianr );
+      if ( ! file )
+        return OnMediaLocation();
+
+      OnMediaLocation ret;
+
+      Pathname path;
+      if ( repository().info().type().toEnum() == repo::RepoType::YAST2_e )
+      {
+#warning STILL HARDCODED /suse PREFIX in location
+        // (ma@) loading a susetags repo search for a solvable with attribute
+        // susetags:datadir. this is the prefix. store it in RepoInfo(?).
+        path = "suse";
+      }
+      ret.setLocation    ( path/file, medianr );
+      ret.setDownloadSize( ByteCount( lookupNumAttribute( SolvAttr::downloadsize ), ByteCount::K ) );
+      ret.setChecksum    ( lookupCheckSumAttribute( SolvAttr::checksum ) );
+      // Not needed/available for solvables?
+      //ret.setOpenSize    ( ByteCount( lookupNumAttribute( SolvAttr::opensize ), ByteCount::K ) );
+      //ret.setOpenChecksum( lookupCheckSumAttribute( SolvAttr::openchecksum ) );
+      return ret;
     }
 
     ResKind Solvable::kind() const
index c372852..27c6a64 100644 (file)
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
+
+  class CheckSum;
+  class OnMediaLocation;
+
   ///////////////////////////////////////////////////////////////////
   namespace sat
   { /////////////////////////////////////////////////////////////////
@@ -111,12 +115,25 @@ namespace zypp
          */
         bool lookupBoolAttribute( const SolvAttr & attr ) const;
 
+       /**
+         * returns the id attribute value for \ref attr
+         * or \ref detail::noId if it does not exists.
+         */
+        detail::IdType lookupIdAttribute( const SolvAttr & attr ) const;
+
+
+
+       /**
+         * returns the CheckSum attribute value for \ref attr
+         * or an empty CheckSum if ir does not exist.
+         */
+        CheckSum lookupCheckSumAttribute( const SolvAttr & attr ) const;
+
         /**
-         * returns the media location: media number in \ref medianr,
-         * file name as return value.  The file name is possibly prepended
-         * with a subdirectory.
+         * returns OnMediaLocation data: This is everything we need to
+         * download e.g. an rpm (path, checksum, downloadsize, etc.).
          */
-        std::string lookupLocation( unsigned & medianr ) const;
+        OnMediaLocation lookupLocation() const;
 
       public:
         /** The identifier.
index 2af3853..f42ef3a 100644 (file)
@@ -195,7 +195,7 @@ namespace zypp
           {
             Arch::CompatSet sysarchs( Arch::compatSet( ZConfig::instance().systemArchitecture() ) );
             for_( it, sysarchs.begin(), sysarchs.end() )
-              sysids.insert( it->idStr().id() );
+              sysids.insert( it->id() );
 
             // unfortunately satsolver treats src/nosrc as architecture:
             sysids.insert( ARCH_SRC );