if ( ! PathInfo(solvfile).isExist() )
ZYPP_THROW(RepoNotCachedException());
- sat::Repo repo = satpool.addRepoSolv(solvfile, info);
+ Repo repo = satpool.addRepoSolv(solvfile, info);
}
////////////////////////////////////////////////////////////////////////////
#include "zypp/sat/Solvable.h"
#include "zypp/sat/Repo.h"
-extern "C"
-{
-#include "satsolver/repo.h"
-}
-
using namespace zypp;
using namespace std;
-class SearchQuery
-{
- public:
-
- SearchQuery( const sat::Solvable &solvable_r )
- : _solvable(solvable_r)
- {
-
- }
-
- void lookup( const sat::SolvAttr &attr )
- {
- //search( _solvable.repo().get(), _solvable.id(), attr.idStr().id(), 0, 0 );
- //return repo_lookup_str(_solvable.get(), attr.idStr().id());
- }
-
- void search(Repo *repo, Id p, Id key, const char *match, int flags)
- {
- repo_search( repo, p, key, match, flags, SearchQuery::repo_search_cb, (void*) this);
- }
-
- static int repo_search_cb(void *cbdata, ::Solvable *s, ::Repodata *data, ::Repokey *key, ::KeyValue *kv)
- {
- cout << "found attribute" << endl;
- SearchQuery *q = (SearchQuery *) cbdata;
- const char *keyname;
- keyname = id2str(data->repo->pool, key->name);
- switch(key->type)
- {
- case TYPE_ID:
- //if (data->localpool)
- // kv->str = stringpool_id2str(&data->spool, kv->id);
- //else
- // kv->str = id2str(data->repo->pool, kv->id);
- // printf("%s: %s\n", keyname, kv->str);
- break;
- case TYPE_STR:
- q->_result = kv->str;
- break;
- }
- return 1;
- }
-
- sat::Solvable _solvable;
- std::string _result;
-};
-
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
{
public:
typedef detail::SolvableIterator SolvableIterator;
- typedef detail::RepoIterator RepoIterator;
+ typedef zypp::detail::RepoIterator RepoIterator;
typedef detail::size_type size_type;
public:
namespace zypp
{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- namespace sat
- { /////////////////////////////////////////////////////////////////
const Repo Repo::norepo;
bool Repo::isSystemRepo() const
{
- NO_REPO_RETURN( false );
- return( Pool::systemRepoName() == _repo->name );
+ NO_REPO_RETURN( false );
+ return( sat::Pool::systemRepoName() == _repo->name );
}
std::string Repo::name() const
{
- NO_REPO_RETURN( std::string() );
- if ( ! _repo->name )
- return std::string();
- return _repo->name;
+ NO_REPO_RETURN( std::string() );
+ if ( ! _repo->name )
+ return std::string();
+ return _repo->name;
}
bool Repo::solvablesEmpty() const
{
- NO_REPO_RETURN( true );
- return _repo->nsolvables;
+ NO_REPO_RETURN( true );
+ return _repo->nsolvables;
}
Repo::size_type Repo::solvablesSize() const
{
- NO_REPO_RETURN( 0 );
- return _repo->nsolvables;
+ NO_REPO_RETURN( 0 );
+ return _repo->nsolvables;
}
Repo::SolvableIterator Repo::solvablesBegin() const
{
- NO_REPO_RETURN( make_filter_iterator( detail::ByRepo( *this ),
- detail::SolvableIterator(),
- detail::SolvableIterator() ) );
- return make_filter_iterator( detail::ByRepo( *this ),
- detail::SolvableIterator(_repo->start),
- detail::SolvableIterator(_repo->end) );
+ NO_REPO_RETURN( make_filter_iterator( detail::ByRepo( *this ),
+ sat::detail::SolvableIterator(),
+ sat::detail::SolvableIterator() ) );
+ return make_filter_iterator( detail::ByRepo( *this ),
+ sat::detail::SolvableIterator(_repo->start),
+ sat::detail::SolvableIterator(_repo->end) );
}
Repo::SolvableIterator Repo::solvablesEnd() const
{
- NO_REPO_RETURN( make_filter_iterator( detail::ByRepo( *this ),
- detail::SolvableIterator(),
- detail::SolvableIterator() ) );
- return make_filter_iterator(detail::ByRepo( *this ),
- detail::SolvableIterator(_repo->end),
- detail::SolvableIterator(_repo->end) );
+ NO_REPO_RETURN( make_filter_iterator( detail::ByRepo( *this ),
+ sat::detail::SolvableIterator(),
+ sat::detail::SolvableIterator() ) );
+ return make_filter_iterator(detail::ByRepo( *this ),
+ sat::detail::SolvableIterator(_repo->end),
+ sat::detail::SolvableIterator(_repo->end) );
}
RepoInfo Repo::info() const
{
- NO_REPO_RETURN( RepoInfo() );
- return myPool().repoInfo( _repo );
+ NO_REPO_RETURN( RepoInfo() );
+ return myPool().repoInfo( _repo );
}
void Repo::setInfo( const RepoInfo & info_r )
{
- NO_REPO_THROW( Exception( _("Can't set RepoInfo for norepo.") ) );
- if ( info_r.alias() != name() )
- {
- ZYPP_THROW( Exception( str::form( _("RepoInfo alias (%s) does not match repository name (%s)"),
- info_r.alias().c_str(), name().c_str() ) ) );
- }
- myPool().setRepoInfo( _repo, info_r );
+ NO_REPO_THROW( Exception( _("Can't set RepoInfo for norepo.") ) );
+ if ( info_r.alias() != name() )
+ {
+ ZYPP_THROW( Exception( str::form( _("RepoInfo alias (%s) does not match repository name (%s)"),
+ info_r.alias().c_str(), name().c_str() ) ) );
+ }
+ myPool().setRepoInfo( _repo, info_r );
}
void Repo::clearInfo()
{
- NO_REPO_RETURN();
- myPool().setRepoInfo( _repo, RepoInfo() );
+ NO_REPO_RETURN();
+ myPool().setRepoInfo( _repo, RepoInfo() );
}
void Repo::eraseFromPool()
{
- NO_REPO_RETURN();
- myPool()._deleteRepo( _repo );
- _id = detail::noRepoId;
+ NO_REPO_RETURN();
+ myPool()._deleteRepo( _repo );
+ _id = sat::detail::noRepoId;
}
#warning NEED POOL MANIP EXEPTIONS
void Repo::addSolv( const Pathname & file_r )
{
- NO_REPO_THROW( Exception( _("Can't add solvables to norepo.") ) );
-
- AutoDispose<FILE*> file( ::fopen( file_r.c_str(), "r" ), ::fclose );
- if ( file == NULL )
- {
- file.resetDispose();
- ZYPP_THROW( Exception( _("Can't open solv-file: ")+file_r.asString() ) );
- }
-
- if ( myPool()._addSolv( _repo, file ) != 0 )
- {
- ZYPP_THROW( Exception( _("Error reading solv-file: ")+file_r.asString() ) );
- }
+ NO_REPO_THROW( Exception( _("Can't add solvables to norepo.") ) );
+
+ AutoDispose<FILE*> file( ::fopen( file_r.c_str(), "r" ), ::fclose );
+ if ( file == NULL )
+ {
+ file.resetDispose();
+ ZYPP_THROW( Exception( _("Can't open solv-file: ")+file_r.asString() ) );
+ }
+
+ if ( myPool()._addSolv( _repo, file ) != 0 )
+ {
+ ZYPP_THROW( Exception( _("Error reading solv-file: ")+file_r.asString() ) );
+ }
}
- detail::SolvableIdType Repo::addSolvables( unsigned count_r )
+ sat::detail::SolvableIdType Repo::addSolvables( unsigned count_r )
{
- NO_REPO_THROW( Exception( _("Can't add solvables to norepo.") ) );
- return myPool()._addSolvables( _repo, count_r );
+ NO_REPO_THROW( Exception( _("Can't add solvables to norepo.") ) );
+ return myPool()._addSolvables( _repo, count_r );
}
/******************************************************************
- **
- ** FUNCTION NAME : operator<<
- ** FUNCTION TYPE : std::ostream &
- */
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
std::ostream & operator<<( std::ostream & str, const Repo & obj )
{
- if ( ! obj )
- return str << "sat::repo()";
-
- return str << "sat::repo(" << obj.name() << ")"
- << "{"
- << obj.solvablesSize()
- << ' ' << obj.get()->start << ' ' << obj.get()->end << ' '
- << (obj.get()->start < 0 ? "_START_":"")
- << (obj.get()->nsolvables < 0 ?"_NUMSOLV_":"")
- <<"}";
+ if ( ! obj )
+ return str << "sat::repo()";
+
+ return str << "sat::repo(" << obj.name() << ")"
+ << "{"
+ << obj.solvablesSize()
+ << ' ' << obj.get()->start << ' ' << obj.get()->end << ' '
+ << (obj.get()->start < 0 ? "_START_":"")
+ << (obj.get()->nsolvables < 0 ?"_NUMSOLV_":"")
+ <<"}";
}
+
/////////////////////////////////////////////////////////////////
- } // namespace sat
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
- class Pathname;
- class RepoInfo;
+ class Pathname;
+ class RepoInfo;
- ///////////////////////////////////////////////////////////////////
- namespace sat
- { /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : Repo
//
/** */
- class Repo : protected detail::PoolMember,
+ class Repo : protected sat::detail::PoolMember,
private base::SafeBool<Repo>
{
- public:
- typedef filter_iterator<detail::ByRepo, detail::SolvableIterator> SolvableIterator;
- typedef detail::size_type size_type;
+ public:
+ typedef filter_iterator<detail::ByRepo, sat::detail::SolvableIterator> SolvableIterator;
+ typedef sat::detail::size_type size_type;
- public:
+ public:
/** Default ctor creates \ref norepo.*/
Repo()
- : _id( detail::noRepoId ) {}
+ : _id( sat::detail::noRepoId ) {}
/** \ref PoolImpl ctor. */
- explicit Repo( detail::RepoIdType id_r )
- : _id( id_r ) {}
+ explicit Repo( sat::detail::RepoIdType id_r )
+ : _id( id_r ) {}
- public:
+ public:
/** Represents no \ref Repo. */
static const Repo norepo;
/** Return whether this is the system repo. */
bool isSystemRepo() const;
- public:
+ public:
/** The repos name (alias). */
std::string name() const;
/** Iterator behind the last \ref Solvable. */
SolvableIterator solvablesEnd() const;
- public:
+ public:
/** Return any associated \ref RepoInfo. */
RepoInfo info() const;
* \throws Exception if this is \ref norepo
* \throws Exception if the \ref RepoInfo::alias
* does not match the \ref Repo::name.
- */
+ */
void setInfo( const RepoInfo & info_r );
- /** Remove any \ref RepoInfo set for this repository. */
+ /** Remove any \ref RepoInfo set for this repository. */
void clearInfo();
- public:
+ public:
/** Remove this \ref Repo from it's \ref Pool. */
void eraseFromPool();
/** Functor calling \ref eraseFromPool. */
struct EraseFromPool;
- public:
+ public:
/** \name Repo content manipulating methods.
* \todo maybe a separate Repo/Solvable content manip interface
* provided by the pool.
void addSolv( const Pathname & file_r );
/** Add \c count_r new empty \ref Solvable to this \ref Repo. */
- detail::SolvableIdType addSolvables( unsigned count_r );
+ sat::detail::SolvableIdType addSolvables( unsigned count_r );
/** \overload Add only one new \ref Solvable. */
- detail::SolvableIdType addSolvable()
- { return addSolvables( 1 ); }
+ sat::detail::SolvableIdType addSolvable()
+ { return addSolvables( 1 ); }
//@}
- public:
+ public:
/** Expert backdoor. */
::_Repo * get() const;
/** Expert backdoor. */
- detail::RepoIdType id() const { return _id; }
- private:
+ sat::detail::RepoIdType id() const { return _id; }
+ private:
friend base::SafeBool<Repo>::operator bool_type() const;
bool boolTest() const { return get(); }
- private:
- detail::RepoIdType _id;
+ private:
+ sat::detail::RepoIdType _id;
};
///////////////////////////////////////////////////////////////////
*/
struct Repo::EraseFromPool
{
- void operator()( Repo repo_r ) const
- { repo_r.eraseFromPool(); }
+ void operator()( Repo repo_r ) const
+ { repo_r.eraseFromPool(); }
};
///////////////////////////////////////////////////////////////////
// CLASS NAME : RepoIterator
//
/** */
- class RepoIterator : public boost::iterator_adaptor<
- RepoIterator // Derived
- , ::_Repo ** // Base
- , Repo // Value
- , boost::forward_traversal_tag // CategoryOrTraversal
- , Repo // Reference
- >
- {
+ class RepoIterator : public boost::iterator_adaptor<
+ RepoIterator // Derived
+ , ::_Repo ** // Base
+ , Repo // Value
+ , boost::forward_traversal_tag // CategoryOrTraversal
+ , Repo // Reference
+ >
+ {
public:
- RepoIterator()
- : RepoIterator::iterator_adaptor_( 0 )
- {}
+ RepoIterator()
+ : RepoIterator::iterator_adaptor_( 0 )
+ {}
- explicit RepoIterator( ::_Repo ** p )
- : RepoIterator::iterator_adaptor_( p )
- {}
+ explicit RepoIterator( ::_Repo ** p )
+ : RepoIterator::iterator_adaptor_( p )
+ {}
private:
- friend class boost::iterator_core_access;
-
- Repo dereference() const
- { return Repo( *base() ); }
- };
- ///////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ByRepo
- //
- /** Functor filtering \ref Solvable by \ref Repo.*/
- struct ByRepo
- {
+ friend class boost::iterator_core_access;
+
+ Repo dereference() const
+ { return Repo( *base() ); }
+ };
+ ///////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ByRepo
+ //
+ /** Functor filtering \ref Solvable by \ref Repo.*/
+ struct ByRepo
+ {
public:
- ByRepo( const Repo & repo_r ) : _repo( repo_r ) {}
- ByRepo( RepoIdType id_r ) : _repo( id_r ) {}
- ByRepo() {}
+ ByRepo( const Repo & repo_r ) : _repo( repo_r ) {}
+ ByRepo( sat::detail::RepoIdType id_r ) : _repo( id_r ) {}
+ ByRepo() {}
- bool operator()( const Solvable & slv_r ) const
- { return slv_r.repo() == _repo; }
+ bool operator()( const sat::Solvable & slv_r ) const
+ { return slv_r.repo() == _repo; }
private:
- Repo _repo;
- };
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
+ Repo _repo;
+ };
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
} // namespace detail
///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
- } // namespace sat
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_SAT_REPO_H
bool SATResolver::doesObsoleteItem (PoolItem candidate, PoolItem installed) {
Solvable *sCandidate = _SATPool->solvables + candidate.satSolvable().id();
- Repo *installedRepo = sat::Pool::instance().systemRepo().get();
+ ::_Repo *installedRepo = sat::Pool::instance().systemRepo().get();
Id p, *pp, obsolete, *obsoleteIt;
class IdString;
class Capability;
class Capabilities;
+ class Repo;
+ ///////////////////////////////////////////////////////////////////
+ namespace detail
+ {
+ class RepoIterator;
+ class ByRepo;
+ }
///////////////////////////////////////////////////////////////////
namespace sat
{ /////////////////////////////////////////////////////////////////
class Solvable;
- class Repo;
class Pool;
///////////////////////////////////////////////////////////////////
{ /////////////////////////////////////////////////////////////////
class SolvableIterator;
- class RepoIterator;
- class ByRepo;
/////////////////////////////////////////////////////////////////
} // namespace detail
system.addResolvable (*it);
} else {
// repo channels
- sat::Repo repo = it->resolvable()->satSolvable().repo();
+ Repo repo = it->resolvable()->satSolvable().repo();
if (repoTable.find (repo) == repoTable.end()) {
repoTable[repo] = new HelixResolvable(dumpPath + "/"
+ str::numstring((long)repo.id())
system->addResolvable (*it);
} else {
// repo channels
- sat::Repo repo = it->resolvable()->satSolvable().repo();
+ Repo repo = it->resolvable()->satSolvable().repo();
if (dumpPool) {
if (repoTable.find (repo) == repoTable.end()) {
repoTable[repo] = new HelixResolvable(dumpPath + "/"
};
DEFINE_PTR_TYPE(HelixResolvable);
-typedef std::map<sat::Repo, HelixResolvable_Ptr> RepositoryTable;
+typedef std::map<Repo, HelixResolvable_Ptr> RepositoryTable;
///////////////////////////////////////////////////////////////////
//
//now add the repos to the pool
MIL << "adding " << rpmsolv << " to pool(" << sat::Pool::instance().systemRepoName() << ")";
- sat::Repo system = sat::Pool::instance().systemRepo();
+ Repo system = sat::Pool::instance().systemRepo();
system.addSolv(rpmsolv);
MIL << "Target loaded: " << system.solvablesSize() << " resolvables" << endl;