14#include <boost/mpl/int.hpp>
15#include <boost/mpl/assert.hpp>
22#include <zypp-core/fs/WatchFile>
23#include <zypp-core/parser/Sysconfig>
50#undef ZYPP_BASE_LOGGER_LOGGROUP
51#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::satpool"
62 const char * envp = getenv(
"LIBSOLV_DEBUGMASK");
103 static const std::string _val(
"@System" );
109 static const Pathname _val(
"/etc/sysconfig/storage" );
115 static void logSat(
CPool *,
void *data,
int type,
const char *logString )
118 if ( 0 == strncmp( logString,
"job: drop orphaned", 18 ) )
120 if ( 0 == strncmp( logString,
"job: user installed", 19 ) )
122 if ( 0 == strncmp( logString,
"job: multiversion", 17 ) )
124 if ( 0 == strncmp( logString,
" - no rule created", 19 ) )
126 if ( 0 == strncmp( logString,
" next rules: 0 0", 19 ) )
129 if ( type & (SOLV_FATAL|SOLV_ERROR) ) {
130 L_ERR(
"libsolv") << logString;
131 }
else if ( type & SOLV_DEBUG_STATS ) {
132 L_DBG(
"libsolv") << logString;
134 L_MIL(
"libsolv") << logString;
150 case NAMESPACE_LANGUAGE:
153 return localeIds.
contains(
IdString(rhs) ) ? RET_systemProperty : RET_unsupported;
157 case NAMESPACE_MODALIAS:
167 case NAMESPACE_FILESYSTEM:
177 return RET_unsupported;
197 :
_pool( ::pool_create() )
199 MIL <<
"Creating sat-pool." << endl;
205 ::pool_setdisttype(
_pool, DISTTYPE_RPM );
214 if ( getenv(
"ZYPP_LIBSOLV_FULLLOG") || getenv(
"ZYPP_LIBSAT_FULLLOG") )
215 ::pool_setdebuglevel(
_pool, 3 );
216 else if ( getenv(
"ZYPP_FULLLOG") )
217 ::pool_setdebuglevel(
_pool, 2 );
219 ::pool_setdebugmask(
_pool, SOLV_DEBUG_JOB|SOLV_DEBUG_STATS );
226 _pool->nscallbackdata = (
void*)
this;
243 ::pool_free(
_pool );
259 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
260 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
261 else MIL << a1 << endl;
279 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
280 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
281 else MIL << a1 << endl;
291 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
292 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
293 else MIL << a1 << endl;
295 ::pool_freewhatprovides(
_pool );
313 if ( !
_pool->whatprovides )
315 MIL <<
"pool_createwhatprovides..." << endl;
317 ::pool_addfileprovides(
_pool );
318 ::pool_createwhatprovides(
_pool );
320 if ( !
_pool->languages )
331 setDirty(__FUNCTION__, name_r.c_str() );
332 CRepo * ret = ::repo_create(
_pool, name_r.c_str() );
334 ::pool_set_installed(
_pool, ret );
340 setDirty(__FUNCTION__, repo_r->name );
344 ::repo_free( repo_r,
false );
347 if ( !
_pool->urepos )
350 ::pool_freeallrepos(
_pool,
true );
356 setDirty(__FUNCTION__, repo_r->name );
357 int ret = ::repo_add_solv( repo_r, file_r, 0 );
365 setDirty(__FUNCTION__, repo_r->name );
374 setDirty(__FUNCTION__, repo_r->name );
386 std::set<detail::IdType> sysids;
389 for_( it, sysarchs.begin(), sysarchs.end() )
390 sysids.insert( it->id() );
393 sysids.insert( ARCH_SRC );
394 sysids.insert( ARCH_NOSRC );
398 unsigned blockSize = 0;
402 if ( s->repo == repo_r && sysids.find( s->arch ) == sysids.end() )
409 else if ( blockSize )
412 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
413 blockBegin = blockSize = 0;
419 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
420 blockBegin = blockSize = 0;
427 setDirty(__FUNCTION__, repo_r->name );
428 return ::repo_add_solvable_block( repo_r, count_r );
449 if (
repo->subpriority != mediaPriority )
451 repo->subpriority = mediaPriority;
468 const char *needone[] {
"en" };
469 ::pool_set_languages(
_pool, needone, 1 );
473 std::vector<std::string> fallbacklist;
476 fallbacklist.push_back( l.code() );
478 dumpRangeLine(
MIL <<
"pool_set_languages: ", fallbacklist.begin(), fallbacklist.end() ) << endl;
480 std::vector<const char *> fallbacklist_cstr;
481 for_( it, fallbacklist.begin(), fallbacklist.end() )
483 fallbacklist_cstr.push_back( it->c_str() );
485 ::pool_set_languages(
_pool, &fallbacklist_cstr.front(), fallbacklist_cstr.size() );
541 if ( localesTracker.
wasAdded( lang ) )
543 for ( ; lang; lang = lang.fallback() )
550 for ( ; lang && localeIds.
current().insert(
IdString(lang) ).second; lang = lang.fallback() )
557 for ( ; lang && ! localeIds.
current().count(
IdString(lang) ); lang = lang.fallback() )
576 switch (
detail.capRel() )
586 if (
detail.lhs().id() == NAMESPACE_LANGUAGE )
607 for (
const Capability & cap : pi.dep_supplements() )
626 static const std::string prefix(
"provides:" );
631 if ( provides || solv.ident() == spec )
636 MIL <<
"Multiversion install " << spec <<
": " << (nsize-size) <<
" matches" << endl;
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Helper providing more detailed information about a Capability.
@ CAP_ARCH
Used internally.
Base class for Exception.
Access to the sat-pools string space.
'Language[_Country]' codes.
Locale fallback() const
Return the fallback locale for this locale, if no fallback exists the empty Locale::noCode.
std::string code() const
Return the locale code asString.
What is known about a repository.
Url url() const
Pars pro toto: The first repository url, this is either baseUrls().front() or if no baseUrl is define...
unsigned priority() const
Repository priority for solver.
Remember a files attributes to detect content changes.
static ZConfig & instance()
Singleton ctor.
std::string alias() const
unique identifier for this source.
static Pool instance()
Singleton ctor.
Container::size_type size_type
bool contains(const TSolv &solv_r) const
A Solvable object within the sat Pool.
static const IdString ptfMasterToken
Indicator provides ptf()
static const IdString ptfPackageToken
Indicator provides ptf-package()
static const IdString retractedToken
Indicator provides retracted-patch-package()
Container of Solvable providing a Capability (read only).
sat::SolvableSpec _needrebootSpec
Solvables which should trigger the reboot-needed hint if installed/updated.
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
base::SetTracker< IdStringSet > TrackedLocaleIds
sat::SolvableSpec _retractedSpec
Blacklisted specs:
scoped_ptr< LocaleSet > _availableLocalesPtr
scoped_ptr< MultiversionList > _multiversionListPtr
bool isSystemRepo(CRepo *repo_r) const
static detail::IdType nsCallback(CPool *, void *data, detail::IdType lhs, detail::IdType rhs)
Callback to resolve namespace dependencies (language, modalias, filesystem, etc.).
CRepo * getRepo(RepoIdType id_r) const
void setTextLocale(const Locale &locale_r)
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
sat::StringQueue _autoinstalled
int _addTesttags(CRepo *repo_r, FILE *file_r)
Adding testtags file to a repo.
void multiversionListInit() const
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
void _deleteRepo(CRepo *repo_r)
Delete repo repo_r from pool.
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
sat::SolvableSpec _ptfMasterSpec
void eraseRepoInfo(RepoIdType id_r)
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
void localeSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate locale related housekeeping data.
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
base::SetTracker< LocaleSet > _requestedLocalesTracker
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
const MultiversionList & multiversionList() const
CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
SerialNumberWatcher _watcher
Watch serial number.
SerialNumber _serial
Serial number - changes with each Pool content change.
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
void _postRepoAdd(CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
int _addSolv(CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
SolvableSet MultiversionList
int _addHelix(CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
sat::SolvableSpec _ptfPackageSpec
detail::SolvableIdType _addSolvables(CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate its PoolIt...
bool isMultiversion(const Solvable &solv_r) const
void prepare() const
Update housekeeping data (e.g.
void multiversionSpecChanged()
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
void setDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
bool query(IdString cap_r) const
Checks if a device on the system matches a modalias pattern.
static Modalias & instance()
Singleton access.
std::map< std::string, std::string > read(const Pathname &_path)
Read sysconfig file path_r and return (key,valye) pairs.
static const IdType namespaceLanguage(20)
static const IdType solvablePrereqMarker(15)
Internal ids satlib includes in dependencies.
static void _getLocaleDeps(const Capability &cap_r, LocaleSet &store_r)
static const IdType solvableFileMarker(16)
static const IdType emptyId(1)
unsigned int SolvableIdType
Id type to connect Solvable and sat-solvable.
static const IdType namespaceModalias(18)
static const IdType namespaceFilesystem(21)
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
static const IdType noId(0)
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
const Pathname & sysconfigStoragePath()
int IdType
Generic Id type.
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
BOOST_MPL_ASSERT_RELATION(noId,==, STRID_NULL)
static const SolvableIdType systemSolvableId(1)
Id to denote the usually hidden Solvable::systemSolvable.
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
static void logSat(CPool *, void *data, int type, const char *logString)
void setDirty() const
Explicitly flag the cache as dirty, so it will be rebuilt on the next request.
bool dirty() const
Whether the cache is needed and dirty.
std::string hexdecode(const C_Str &str_r)
Decode hexencoded XX sequences.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", const Trim trim_r=NO_TRIM)
Split line_r into words.
TInt strtonum(const C_Str &str)
Parsing numbers from string.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpRangeLine(std::ostream &str, TIterator begin, TIterator end)
Print range defined by iterators (single line style).
std::unordered_set< Locale > LocaleSet
std::string asString(const Patch::Category &obj)
int repo_add_helix(::Repo *repo, FILE *fp, int flags)
int testcase_add_testtags(Repo *repo, FILE *fp, int flags)
Track added/removed set items based on an initial set.
const set_type & current() const
Return the current set.
bool wasAdded(const key_type &key_r) const
Whether val_r is tracked as added.
const set_type & added() const
Return the set of added items.
const set_type & removed() const
Return the set of removed items.
bool contains(const key_type &key_r) const
Whether val_r is in the set.
static PoolImpl & myPool()
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.