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;
193 if ( getenv(
"ZYPP_LIBSOLV_FULLLOG") || getenv(
"ZYPP_LIBSAT_FULLLOG") )
194 ::pool_setdebuglevel(
_pool, 3 );
195 else if ( getenv(
"ZYPP_FULLLOG") )
196 ::pool_setdebuglevel(
_pool, 2 );
198 ::pool_setdebugmask(
_pool, SOLV_DEBUG_JOB|SOLV_DEBUG_STATS );
205 _pool->nscallbackdata = (
void*)
this;
215 ::pool_free(
_pool );
224 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
225 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
226 else MIL << a1 << endl;
240 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
241 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
242 else MIL << a1 << endl;
244 ::pool_freewhatprovides(
_pool );
255 if ( !
_pool->whatprovides )
257 MIL <<
"pool_createwhatprovides..." << endl;
259 ::pool_addfileprovides(
_pool );
260 ::pool_createwhatprovides(
_pool );
262 if ( !
_pool->languages )
286 setDirty(__FUNCTION__, name_r.c_str() );
287 ::_Repo * ret = ::repo_create(
_pool, name_r.c_str() );
289 ::pool_set_installed(
_pool, ret );
295 setDirty(__FUNCTION__, repo_r->name );
299 ::repo_free( repo_r,
false );
304 setDirty(__FUNCTION__, repo_r->name );
305 int ret = ::repo_add_solv( repo_r, file_r, 0 );
313 setDirty(__FUNCTION__, repo_r->name );
325 std::set<detail::IdType> sysids;
328 for_( it, sysarchs.begin(), sysarchs.end() )
329 sysids.insert( it->id() );
332 sysids.insert( ARCH_SRC );
333 sysids.insert( ARCH_NOSRC );
337 unsigned blockSize = 0;
340 ::_Solvable * s(
_pool->solvables + i );
341 if ( s->repo == repo_r && sysids.find( s->arch ) == sysids.end() )
348 else if ( blockSize )
351 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
352 blockBegin = blockSize = 0;
358 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
359 blockBegin = blockSize = 0;
366 setDirty(__FUNCTION__, repo_r->name );
367 return ::repo_add_solvable_block( repo_r, count_r );
372 ::_Repo * repo(
getRepo( id_r ) );
379 if ( repo->priority !=
int(-info_r.
priority()) )
381 repo->priority = -info_r.
priority();
388 if ( repo->subpriority != mediaPriority )
390 repo->subpriority = mediaPriority;
404 std::tr1::unordered_set<IdString> & locale2Solver )
406 std::tr1::unordered_set<IdString>( 2*locales_r.size() ).swap( locale2Solver );
407 for_( it, locales_r.begin(),locales_r.end() )
410 locale2Solver.insert(
IdString( l.code() ) );
412 MIL <<
"New Solver Locales: " << locale2Solver << endl;
417 std::vector<std::string> fallbacklist;
420 fallbacklist.push_back( l.code() );
422 dumpRangeLine(
MIL <<
"pool_set_languages: ", fallbacklist.begin(), fallbacklist.end() ) << endl;
424 std::vector<const char *> fallbacklist_cstr;
425 for_( it, fallbacklist.begin(), fallbacklist.end() )
427 fallbacklist_cstr.push_back( it->c_str() );
429 ::pool_set_languages(
_pool, &fallbacklist_cstr.front(), fallbacklist_cstr.size() );
436 MIL <<
"New RequestedLocales: " << locales_r << endl;
468 switch ( detail.
capRel() )
478 if ( detail.
lhs().
id() == NAMESPACE_LANGUAGE )
480 store_r.insert( detail.
rhs().
id() );
497 std::tr1::unordered_set<sat::detail::IdType> tmp;
502 for_( cit, cap.begin(), cap.end() )
507 #warning immediately build LocaleSet as soon as Loale is an Id based type
509 for_( it, tmp.begin(), tmp.end() )
522 const std::set<std::string> & multiversionSpec(
ZConfig::instance().multiversionSpec() );
523 for_( it, multiversionSpec.begin(), multiversionSpec.end() )
525 static const std::string prefix(
"provides:" );
529 if ( provides.
empty() )
531 MIL <<
"Multiversion install not provided (" << *it <<
")" << endl;
537 if ( multiversionList.insert( pit->ident() ).second )
538 MIL <<
"Multiversion install " << pit->ident() <<
" (" << *it <<
")" << endl;
544 MIL <<
"Multiversion install " << *it << endl;
545 multiversionList.insert(
IdString( *it ) );
557 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
#define _(MSG)
Return translated text.
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.).