bool isTrue() { return true; }
bool isFalse() { return false; }
+void dumpIdStr()
+{
+ for ( unsigned i = 0; i < 30; ++i )
+ {
+ DBG << i << '\t' << sat::IdStr( i ) << endl;
+ }
+}
/******************************************************************
**
sat::Pool satpool( sat::Pool::instance() );
#if 0
+ //sat::Repo r( satpool.addRepoSolv( "sl10.1-beta7-packages.solv" ) );
+ sat::Repo s( satpool.addRepoSolv( "sl10.1-beta7-selections.solv" ) );
+
+ std::for_each( satpool.solvablesBegin(), satpool.solvablesEnd(), Print() );
+
///////////////////////////////////////////////////////////////////
INT << "===[END]============================================" << endl << endl;
zypp::base::LogControl::instance().logNothing();
--- /dev/null
+0 <NULL>
+1
+2 solvable:name
+3 solvable:arch
+4 solvable:evr
+5 solvable:vendor
+6 solvable:provides
+7 solvable:obsoletes
+8 solvable:conflicts
+9 solvable:requires
+10 solvable:recommends
+11 solvable:suggests
+12 solvable:supplements
+13 solvable:enhances
+14 solvable:freshens
+15 rpm:dbid
+16 solvable:prereqmarker
+17 solvable:filemarker
+18 namespace:installed
+19 namespace:modalias
+20 system:system
+21 src
+22 nosrc
+23 noarch
+24 <NULL>
+25 <NULL>
+26 <NULL>
+27 <NULL>
+28 <NULL>
+29 <NULL>
+
pool/GetResolvablesToInsDel.cc
pool/PoolImpl.cc
pool/PoolStats.cc
+ pool/Res2Sat.cc
)
SET( zypp_pool_HEADERS
namespace pool
{ /////////////////////////////////////////////////////////////////
+ void pi2sat( const PoolItem & pi_r, sat::Solvable & slv_r );
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : NameHash::NameHash
debug::Measure mnf( "Sync changes to sat-pool..." );
MIL << "Pool: " << _serial << ": Sync changes to sat-pool... " << _satSyncRequired << endl;
+ // collect unsynced PoolItems per repository.
std::map<std::string, std::list<PoolItem> > todo;
for_( it, begin(), end() )
{
}
}
+ // add the missing PoolItems.
DBG << "Update missing repos... " << todo.size() << endl;
+ void res2sat( const ResObject::constPtr & res_r, sat::Solvable & slv_r );
+
for_( it, todo.begin(), todo.end() )
{
- DBG << "Update " << it->first << ": " << it->second.size() << endl;
+ DBG << "Update repo " << it->first << ": " << it->second.size() << endl;
sat::Repo repo( sat::Pool::instance().reposInsert( it->first ) );
sat::Solvable first( repo.addSolvables( it->second.size() ) );
DBG << " starting at " << first << endl;
+
+ sat::Solvable cur( first );
for_( pit, it->second.begin(), it->second.end() )
{
- // *pit to sat::Solvable
+ res2sat( *pit, cur );
+ (*pit).rememberSatSolvable( cur );
+ cur = cur.nextInRepo();
}
+ break;
}
//_satSyncRequired.remember( _serial );
///////////////////////////////////////////////////////////////////
//
- // METHOD NAME : PoolImpl::satSync
- // METHOD TYPE : void
+ // METHOD NAME : PoolImpl::find
+ // METHOD TYPE : PoolItem
//
PoolItem PoolImpl::find( const sat::Solvable & slv_r ) const
{
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/pool/Res2Sat.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/base/Easy.h"
+#include "zypp/base/LogTools.h"
+#include "zypp/base/Gettext.h"
+#include "zypp/base/Exception.h"
+#include "zypp/base/String.h"
+
+#include "zypp/ResObject.h"
+#include "zypp/Capability.h"
+#include "zypp/capability/VersionedCap.h"
+
+#include "zypp/sat/detail/PoolImpl.h"
+#include "zypp/sat/Solvable.h"
+#include "zypp/sat/Repo.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace pool
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ namespace
+ { /////////////////////////////////////////////////////////////////
+
+ inline void store( ::Id & where_r, const::std::string & str_r )
+ {
+ where_r = sat::IdStr( str_r ).id();
+ }
+
+ inline void store( ::Offset & where_r, ::_Solvable * slv_r, const Dependencies & dep_r, Dep which_r )
+ {
+ const CapSet & caps( dep_r[which_r] );
+ if ( caps.empty() )
+ return;
+
+ for_( it, caps.begin(), caps.end() )
+ {
+ // check PREREQUIRES later
+ int isreq = ( which_r == Dep::REQUIRES ? 1 : 0 );
+
+ std::string name;
+ Rel op;
+ Edition ed;
+
+ using capability::VersionedCap;
+ VersionedCap::constPtr vercap = capability::asKind<VersionedCap>(*it);
+ if ( vercap )
+ {
+ name = vercap->name();
+ op = vercap->op();
+ ed = vercap->edition();
+ }
+ else
+ {
+ name = (*it).asString();
+ }
+
+ sat::IdStr nid;
+ if ( refersTo<Package>( *it ) )
+ {
+ nid = sat::IdStr( name );
+ }
+ else
+ {
+ nid = sat::IdStr( str::form( "%s:%s",
+ (*it).refers().asString().c_str(),
+ name.c_str() ) );
+ }
+
+ if ( op != Rel::ANY && ed != Edition::noedition )
+ {
+ sat::IdStr eid( ed.asString() );
+#warning TBD calc rel and prereqcheck
+ ::Id rid = ::rel2id( slv_r->repo->pool, nid.id(), eid.id(), REL_EQ, true );
+ where_r = ::repo_addid_dep( slv_r->repo, where_r, rid, isreq );
+ }
+ else
+ {
+ where_r = ::repo_addid_dep( slv_r->repo, where_r, nid.id(), isreq );
+ }
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace
+ ///////////////////////////////////////////////////////////////////
+
+
+ void res2sat( const ResObject::constPtr & res_r, sat::Solvable & slv_r )
+ {
+ ::_Solvable * slv( slv_r.get() );
+ if ( ! ( res_r && slv ) )
+ {
+ INT << res_r << " -> " << slv_r << endl;
+ ZYPP_THROW( Exception( _("Can't store data in NULL objlect") ) );
+ }
+
+ if ( isKind<Package>( res_r ) )
+ {
+ store( slv->name, res_r->name() );
+ }
+ else
+ {
+ store( slv->name, str::form( "%s:%s",
+ res_r->kind().asString().c_str(),
+ res_r->name().c_str() ) );
+ }
+ store( slv->arch, res_r->arch().asString() );
+ store( slv->evr, res_r->edition().asString() );
+ store( slv->vendor, res_r->vendor() );
+
+ store( slv->provides, slv, res_r->deps(), Dep::PROVIDES );
+ store( slv->obsoletes, slv, res_r->deps(), Dep::OBSOLETES );
+ store( slv->conflicts, slv, res_r->deps(), Dep::CONFLICTS );
+ store( slv->requires, slv, res_r->deps(), Dep::REQUIRES );
+ store( slv->recommends, slv, res_r->deps(), Dep::RECOMMENDS );
+ store( slv->suggests, slv, res_r->deps(), Dep::SUGGESTS );
+ store( slv->supplements, slv, res_r->deps(), Dep::SUPPLEMENTS );
+ store( slv->enhances, slv, res_r->deps(), Dep::ENHANCES );
+ store( slv->freshens, slv, res_r->deps(), Dep::FRESHENS );
+
+ //DBG << " " << res_r << " -> " << slv_r << endl;
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace pool
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
namespace sat
{ /////////////////////////////////////////////////////////////////
- static const IdStr::IdStr Null( STRID_NULL );
+ const IdStr IdStr::Null( unsigned(STRID_NULL) );
+ const IdStr IdStr::Empty( unsigned(STRID_EMPTY) );
/////////////////////////////////////////////////////////////////
+ IdStr::IdStr( const char * str_r )
+ : _id( ::stringpool_str2id( &myPool()->ss, str_r, true ) )
+ {}
+
+ IdStr::IdStr( const std::string & str_r )
+ : _id( ::stringpool_str2id( &myPool()->ss, str_r.c_str(), true ) )
+ {}
+
const char * IdStr::c_str() const
{
return ::id2str( myPool().getPool(), _id );
//
// CLASS NAME : IdStr
//
- /** */
+ /** Access to the sat-pools string space.
+ * Construction from string will place a copy of the string in the
+ * string space, if it is not already present.
+ */
class IdStr: protected detail::PoolMember
{
friend std::ostream & operator<<( std::ostream & str, const IdStr & obj );
public:
- IdStr() : _id( 0 ) {}
- explicit IdStr( int id_r ) : _id( id_r ) {}
+ /** Default ctor, empty string. */
+ IdStr() : _id( Empty.id() ) {}
+ /** Ctor from id. */
+ explicit IdStr( unsigned id_r ) : _id( id_r ) {}
+ /** Ctor from string. */
explicit IdStr( const char * str_r );
+ /** Ctor from string. */
explicit IdStr( const std::string & str_r );
public:
+ /** No or Null string. */
static const IdStr Null;
+ /** Empty string. */
+ static const IdStr::IdStr Empty;
public:
+ bool empty() const
+ { return( _id == Empty.id() ); }
+
+ public:
+ /** Conversion to <tt>const char *</tt> */
const char * c_str() const;
+ /** Conversion to <tt>std::string</tt> */
std::string string() const;
+ /** \overload */
+ std::string asString() const
+ { return string(); }
+
public:
- int get() const { return _id; }
+ /** Expert backdoor. */
+ unsigned id() const
+ { return _id; }
private:
- int _id;
+ unsigned _id;
};
///////////////////////////////////////////////////////////////////
/** \relates IdStr */
inline bool operator==( const IdStr & lhs, const IdStr & rhs )
- { return lhs.get() == rhs.get(); }
+ { return lhs.id() == rhs.id(); }
/** \relates IdStr */
inline bool operator!=( const IdStr & lhs, const IdStr & rhs )
- { return lhs.get() != rhs.get(); }
+ { return lhs.id() != rhs.id(); }
/////////////////////////////////////////////////////////////////
{ /////////////////////////////////////////////////////////////////
class Pathname;
+ class SerialNumber;
///////////////////////////////////////////////////////////////////
namespace sat
void Repo::addSolv( const Pathname & file_r )
{
- NO_REPO_THROW( Exception( "Can't add solvables to noepo." ) );
+ NO_REPO_THROW( Exception( _("Can't add solvables to noepo.") ) );
AutoDispose<FILE*> file( ::fopen( file_r.c_str(), "r" ), ::fclose );
if ( file == NULL )
{
file.resetDispose();
- ZYPP_THROW( Exception( "Can't read solv-file "+file_r.asString() ) );
+ ZYPP_THROW( Exception( _("Can't read solv-file: ")+file_r.asString() ) );
}
myPool().setDirty();
detail::SolvableIdType Repo::addSolvable()
{
- NO_REPO_THROW( Exception( "Can't add solvables to noepo." ) );
+ NO_REPO_THROW( Exception( _("Can't add solvables to noepo.") ) );
myPool().setDirty();
return ::repo_add_solvable( _repo );
}
detail::SolvableIdType Repo::addSolvables( unsigned count_r )
{
- NO_REPO_THROW( Exception( "Can't add solvables to noepo." ) );
+ NO_REPO_THROW( Exception( _("Can't add solvables to noepo.") ) );
myPool().setDirty();
return ::repo_add_solvable_block( _repo, count_r );
}
::_Solvable * Solvable::get() const
{ return myPool().getSolvable( _id ); }
- Solvable Solvable::nextInPool() const
- { return Solvable( myPool().getNextId( _id ) ); }
-
#define NO_SOLVABLE_RETURN( VAL ) \
::_Solvable * _solvable( get() ); \
if ( ! _solvable ) return VAL
+ Solvable Solvable::nextInPool() const
+ { return Solvable( myPool().getNextId( _id ) ); }
+
+ Solvable Solvable::nextInRepo() const
+ {
+ NO_SOLVABLE_RETURN( nosolvable );
+ for ( detail::SolvableIdType next = _id+1; next < unsigned(_solvable->repo->end); ++next )
+ {
+ ::_Solvable * nextS( myPool().getSolvable( next ) );
+ if ( nextS && nextS->repo == _solvable->repo )
+ {
+ return Solvable( next );
+ }
+ }
+ return nosolvable;
+ }
+
NameId Solvable::name() const
{
NO_SOLVABLE_RETURN( NameId() );
#include "zypp/base/SafeBool.h"
#include "zypp/sat/detail/PoolMember.h"
+#include "zypp/sat/IdStr.h"
///////////////////////////////////////////////////////////////////
namespace zypp