14 #include <boost/mpl/int.hpp>
46 #undef ZYPP_BASE_LOGGER_LOGGROUP
47 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::satpool"
58 const char * envp = getenv(
"LIBSOLV_DEBUGMASK");
59 return envp ? str::strtonum<int>( envp ) : 0;
91 static const std::string _val(
"@System" );
97 static const Pathname _val(
"/etc/sysconfig/storage" );
104 static void logSat(
struct _Pool *,
void *data,
int type,
const char *logString )
106 if ( type & (SOLV_FATAL|SOLV_ERROR) ) {
107 _ERR(
"libsolv") << logString;
108 }
else if ( type & SOLV_DEBUG_STATS ) {
109 _DBG(
"libsolv") << logString;
111 _MIL(
"libsolv") << logString;
127 case NAMESPACE_LANGUAGE:
130 const std::tr1::unordered_set<IdString> & locale2Solver( reinterpret_cast<PoolImpl*>(data)->
_locale2Solver );
131 if ( locale2Solver.empty() )
133 return rhs == en.
id() ? RET_systemProperty : RET_unsupported;
135 return locale2Solver.find(
IdString(rhs) ) != locale2Solver.end() ? RET_systemProperty : RET_unsupported;
139 case NAMESPACE_MODALIAS:
149 case NAMESPACE_FILESYSTEM:
152 return requiredFilesystems.find(
IdString(rhs).
asString() ) != requiredFilesystems.end() ? RET_systemProperty : RET_unsupported;
159 return RET_unsupported;
179 : _pool( ::pool_create() )
181 MIL <<
"Creating sat-pool." << endl;
187 ::pool_setdisttype(
_pool, DISTTYPE_RPM );
196 if ( getenv(
"ZYPP_LIBSOLV_FULLLOG") || getenv(
"ZYPP_LIBSAT_FULLLOG") )
197 ::pool_setdebuglevel(
_pool, 3 );
198 else if ( getenv(
"ZYPP_FULLLOG") )
199 ::pool_setdebuglevel(
_pool, 2 );
201 ::pool_setdebugmask(
_pool, SOLV_DEBUG_JOB|SOLV_DEBUG_STATS );
208 _pool->nscallbackdata = (
void*)
this;
218 ::pool_free(
_pool );
227 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
228 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
229 else MIL << a1 << endl;
243 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
244 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
245 else MIL << a1 << endl;
247 ::pool_freewhatprovides(
_pool );
258 if ( !
_pool->whatprovides )
260 MIL <<
"pool_createwhatprovides..." << endl;
262 ::pool_addfileprovides(
_pool );
263 ::pool_createwhatprovides(
_pool );
265 if ( !
_pool->languages )
289 setDirty(__FUNCTION__, name_r.c_str() );
290 ::_Repo * ret = ::repo_create(
_pool, name_r.c_str() );
292 ::pool_set_installed(
_pool, ret );
298 setDirty(__FUNCTION__, repo_r->name );
302 ::repo_free( repo_r,
false );
307 setDirty(__FUNCTION__, repo_r->name );
308 int ret = ::repo_add_solv( repo_r, file_r, 0 );
316 setDirty(__FUNCTION__, repo_r->name );
328 std::set<detail::IdType> sysids;
331 for_( it, sysarchs.begin(), sysarchs.end() )
332 sysids.insert( it->id() );
335 sysids.insert( ARCH_SRC );
336 sysids.insert( ARCH_NOSRC );
340 unsigned blockSize = 0;
343 ::_Solvable * s(
_pool->solvables + i );
344 if ( s->repo == repo_r && sysids.find( s->arch ) == sysids.end() )
351 else if ( blockSize )
354 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
355 blockBegin = blockSize = 0;
361 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
362 blockBegin = blockSize = 0;
369 setDirty(__FUNCTION__, repo_r->name );
370 return ::repo_add_solvable_block( repo_r, count_r );
375 ::_Repo * repo(
getRepo( id_r ) );
382 if ( repo->priority !=
int(-info_r.
priority()) )
384 repo->priority = -info_r.
priority();
391 if ( repo->subpriority != mediaPriority )
393 repo->subpriority = mediaPriority;
407 std::tr1::unordered_set<IdString> & locale2Solver )
409 std::tr1::unordered_set<IdString>( 2*locales_r.size() ).swap( locale2Solver );
410 for_( it, locales_r.begin(),locales_r.end() )
413 locale2Solver.insert(
IdString( l.code() ) );
415 MIL <<
"New Solver Locales: " << locale2Solver << endl;
420 std::vector<std::string> fallbacklist;
423 fallbacklist.push_back( l.code() );
425 dumpRangeLine(
MIL <<
"pool_set_languages: ", fallbacklist.begin(), fallbacklist.end() ) << endl;
427 std::vector<const char *> fallbacklist_cstr;
428 for_( it, fallbacklist.begin(), fallbacklist.end() )
430 fallbacklist_cstr.push_back( it->c_str() );
432 ::pool_set_languages(
_pool, &fallbacklist_cstr.front(), fallbacklist_cstr.size() );
439 MIL <<
"New RequestedLocales: " << locales_r << endl;
471 switch ( detail.
capRel() )
481 if ( detail.
lhs().
id() == NAMESPACE_LANGUAGE )
483 store_r.insert( detail.
rhs().
id() );
500 std::tr1::unordered_set<sat::detail::IdType> tmp;
505 for_( cit, cap.begin(), cap.end() )
510 #warning immediately build LocaleSet as soon as Loale is an Id based type
512 for_( it, tmp.begin(), tmp.end() )
525 const std::set<std::string> & multiversionSpec(
ZConfig::instance().multiversionSpec() );
526 for_( it, multiversionSpec.begin(), multiversionSpec.end() )
528 static const std::string prefix(
"provides:" );
532 if ( provides.
empty() )
534 MIL <<
"Multiversion install not provided (" << *it <<
")" << endl;
540 if ( multiversionList.insert( pit->ident() ).second )
541 MIL <<
"Multiversion install " << pit->ident() <<
" (" << *it <<
")" << endl;
547 MIL <<
"Multiversion install " << *it << endl;
548 multiversionList.insert(
IdString( *it ) );
560 std::inserter( requiredFilesystems, requiredFilesystems.end() ) );
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
static const Locale noCode
No or empty code.
const Pathname & sysconfigStoragePath()
bool isSystemRepo(::_Repo *repo_r) const
int IdType
Generic Id type.
std::string alias() const
unique identifier for this source.
Container of Solvable providing a Capability (read only).
bool eraseRequestedLocale(const Locale &locale_r)
scoped_ptr< LocaleSet > _availableLocalesPtr
Container of Capability (currently read only).
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
static ZConfig & instance()
Singleton ctor.
::_Repo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Helper providing more detailed information about a Capability.
unsigned split(const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=" \t")
Split line_r into words.
bool query(IdString cap_r) const
Checks if a device on the system matches a modalias pattern.
bool empty() const
Whether the container is empty.
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
IdType id() const
Expert backdoor.
bool addRequestedLocale(const Locale &locale_r)
void setDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
void prepareForSolving() const
prepare plus some expensive checks done before solving only.
::_Repo * RepoIdType
Id type to connect Repo and sat-repo.
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
void eraseRepoInfo(RepoIdType id_r)
What is known about a repository.
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
Access to the sat-pools string space.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
static const IdType solvableFileMarker(16)
map< string, string > read(const Pathname &_path)
Read sysconfig file path_r and return (key,valye) pairs.
void _deleteRepo(::_Repo *repo_r)
Creating a new repo named name_r.
unsigned priority() const
Repository priority for solver.
Remember a files attributes to detect content changes.
static void _getLocaleDeps(Capability cap_r, std::tr1::unordered_set< sat::detail::IdType > &store_r)
void multiversionListInit() const
const LocaleSet & getAvailableLocales() const
int _addSolv(::_Repo *repo_r, FILE *file_r)
Adding solv file to a repo.
int repo_add_helix(::Repo *repo, FILE *fp, int flags)
detail::SolvableIdType _addSolvables(::_Repo *repo_r, unsigned count_r)
Adding Solvables to a repo.
void _locale_hack(const LocaleSet &locales_r, std::tr1::unordered_set< IdString > &locale2Solver)
static Pool instance()
Singleton ctor.
Locale fallback() const
Return a fallback locale for this locale, when giving up, returns empty Locale()
static const IdType emptyId(1)
const_iterator begin() const
Iterator pointing to the first Solvable.
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
const_iterator end() const
Iterator pointing behind the last Solvable.
SerialNumberWatcher _watcher
Watch serial number.
static const SolvableIdType systemSolvableId(1)
Id to denote the usually hidden Solvable::systemSolvable.
void setRequestedLocales(const LocaleSet &locales_r)
static void logSat(struct _Pool *, void *data, int type, const char *logString)
std::tr1::unordered_set< IdString > _locale2Solver
sat::StringQueue _autoinstalled
int _addHelix(::_Repo *repo_r, FILE *file_r)
Adding helix file to a repo.
std::tr1::unordered_set< Locale > LocaleSet
static PoolImpl & myPool()
BOOST_MPL_ASSERT_RELATION(noId,==, STRID_NULL)
std::ostream & dumpRangeLine(std::ostream &str, _Iterator begin, _Iterator end)
Print range defined by iterators (single line style).
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
std::string asString(const Patch::SeverityFlag &obj)
SerialNumber _serial
Serial number.
scoped_ptr< MultiversionList > _multiversionListPtr
::_Repo * getRepo(RepoIdType id_r) const
std::string code() const
Return the locale code.
static Modalias & instance()
Singleton access.
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Base class for Exception.
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
void setTextLocale(const Locale &locale_r)
void clear()
Clear the queue.
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
void prepare() const
Update housekeeping data (e.g.
static const std::string & systemRepoAlias()
Reserved system repository alias .
static const IdType noId(0)
Url url() const
Pars pro toto: The first repository url.
static const IdType solvablePrereqMarker(15)
Internal ids satlib includes in dependencies.
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Locale textLocale() const
The locale for translated texts zypp uses.
IdStringSet MultiversionList
const MultiversionList & multiversionList() const
Easy-to use interface to the ZYPP dependency resolver.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
void _postRepoAdd(::_Repo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
LocaleSet _requestedLocales
std::string hexdecode(const C_Str &str_r)
Decode hexencoded XX sequences.
sat::detail::IdType id() const
Expert backdoor.
bool remember(unsigned serial_r) const
Return isDirty, storing serial_r as new value.
static detail::IdType nsCallback(::_Pool *, void *data, detail::IdType lhs, detail::IdType rhs)
Callback to resolve namespace dependencies (language, modalias, filesystem, etc.).