15#include <boost/mpl/int.hpp>
16#include <boost/mpl/assert.hpp>
23#include <zypp-core/fs/WatchFile>
24#include <zypp-core/parser/Sysconfig>
32#include <solv/pool_snapshot.h>
57#undef ZYPP_BASE_LOGGER_LOGGROUP
58#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::satpool"
69 const char * envp = getenv(
"LIBSOLV_DEBUGMASK");
110 static const std::string _val(
"@System" );
116 static const Pathname _val(
"/etc/sysconfig/storage" );
122 static void logSat(
CPool *,
void *data,
int type,
const char *logString )
125 if ( 0 == strncmp( logString,
"job: drop orphaned", 18 ) )
127 if ( 0 == strncmp( logString,
"job: user installed", 19 ) )
129 if ( 0 == strncmp( logString,
"job: multiversion", 17 ) )
131 if ( 0 == strncmp( logString,
" - no rule created", 19 ) )
133 if ( 0 == strncmp( logString,
" next rules: 0 0", 19 ) )
136 if ( type & (SOLV_FATAL|SOLV_ERROR) ) {
137 L_ERR(
"libsolv") << logString;
138 }
else if ( type & SOLV_DEBUG_STATS ) {
139 L_DBG(
"libsolv") << logString;
141 L_MIL(
"libsolv") << logString;
157 case NAMESPACE_LANGUAGE:
160 return localeIds.
contains(
IdString(rhs) ) ? RET_systemProperty : RET_unsupported;
164 case NAMESPACE_MODALIAS:
174 case NAMESPACE_FILESYSTEM:
184 return RET_unsupported;
206 if ( getenv(
"ZYPP_LIBSOLV_FULLLOG") || getenv(
"ZYPP_LIBSAT_FULLLOG") )
207 ::pool_setdebuglevel(
_pool, 3 );
208 else if ( getenv(
"ZYPP_FULLLOG") )
209 ::pool_setdebuglevel(
_pool, 2 );
211 ::pool_setdebugmask(
_pool, SOLV_DEBUG_JOB|SOLV_DEBUG_STATS );
222 ::pool_set_flag(
_pool, POOL_FLAG_KEEPIDHASHES, 1 );
226 _pool->nscallbackdata = (
void*)
this;
258 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
259 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
260 else MIL << a1 << endl;
278 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
279 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
280 else MIL << a1 << endl;
290 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
291 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
292 else MIL << a1 << endl;
294 ::pool_freewhatprovides(
_pool );
302 unsigned char buf[4096];
303 unsigned int len =
sizeof(buf);
304 if ( ::pool_snapshot_read_cookie( fp, buf, &len ) != 0
305 || cookie_r != std::string(
reinterpret_cast<char*
>(buf), len ) )
307 MIL <<
"Pool snapshot " << path_r <<
" is stale" << endl;
319 int res = ::pool_snapshot_map(
_pool, fp );
327 MIL <<
"Pool snapshot " << path_r <<
" not usable by this run, not replacing it" << endl;
333 WAR <<
"Pool snapshot " << path_r <<
" failed to map" << endl;
336 MIL <<
"Mapped pool snapshot " << path_r << endl;
355 info.setAutorefresh(
true );
356 info.setEnabled(
true );
377 std::vector<std::string> aliases;
382 aliases.push_back(
repo->name ?
repo->name :
"" );
383 std::sort( aliases.begin(), aliases.end() );
386 MIL <<
"Not writing pool snapshot: pool does not match the known repos" << endl;
414 std::set<RepoIdType> unclaimed;
418 MIL <<
"Erase unclaimed snapshot repo " << (
repo->name ?
repo->name :
"" ) << endl;
435 if ( !
_pool->whatprovides )
437 MIL <<
"pool_createwhatprovides..." << endl;
456 ::pool_set_flag(
_pool, POOL_FLAG_NOWHATPROVIDESSHRINK, willWriteSnapshot ? 0 : 1 );
467 ::pool_addfileprovides(
_pool );
468 ::pool_createwhatprovides(
_pool );
471 if ( !
_pool->languages )
482 setDirty(__FUNCTION__, name_r.c_str() );
483 CRepo * ret = ::repo_create(
_pool, name_r.c_str() );
485 ::pool_set_installed(
_pool, ret );
491 setDirty(__FUNCTION__, repo_r->name );
496 ::repo_free( repo_r,
false );
499 if ( !
_pool->urepos )
502 ::pool_freeallrepos(
_pool,
true );
508 setDirty(__FUNCTION__, repo_r->name );
509 int ret = ::repo_add_solv( repo_r, file_r, 0 );
517 setDirty(__FUNCTION__, repo_r->name );
526 setDirty(__FUNCTION__, repo_r->name );
540 std::set<detail::IdType> sysids;
543 for_( it, sysarchs.begin(), sysarchs.end() )
544 sysids.insert( it->id() );
547 sysids.insert( ARCH_SRC );
548 sysids.insert( ARCH_NOSRC );
552 unsigned blockSize = 0;
556 if (
s->repo == repo_r && sysids.find(
s->arch ) == sysids.end() )
563 else if ( blockSize )
566 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
567 blockBegin = blockSize = 0;
573 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
574 blockBegin = blockSize = 0;
581 setDirty(__FUNCTION__, repo_r->name );
583 return ::repo_add_solvable_block( repo_r, count_r );
605 if (
repo->subpriority != mediaPriority )
607 repo->subpriority = mediaPriority;
624 const char *needone[] {
"en" };
625 ::pool_set_languages(
_pool, needone, 1 );
629 std::vector<std::string> fallbacklist;
632 fallbacklist.push_back( l.code() );
634 dumpRangeLine(
MIL <<
"pool_set_languages: ", fallbacklist.begin(), fallbacklist.end() ) << endl;
636 std::vector<const char *> fallbacklist_cstr;
637 for_( it, fallbacklist.begin(), fallbacklist.end() )
639 fallbacklist_cstr.push_back( it->c_str() );
641 ::pool_set_languages(
_pool, &fallbacklist_cstr.front(), fallbacklist_cstr.size() );
697 if ( localesTracker.
wasAdded( lang ) )
699 for ( ; lang; lang = lang.fallback() )
706 for ( ; lang && localeIds.
current().insert(
IdString(lang) ).second; lang = lang.fallback() )
713 for ( ; lang && ! localeIds.
current().count(
IdString(lang) ); lang = lang.fallback() )
732 switch (
detail.capRel() )
742 if (
detail.lhs().id() == NAMESPACE_LANGUAGE )
763 for (
const Capability & cap : pi.dep_supplements() )
782 static const std::string prefix(
"provides:" );
787 if ( provides || solv.ident() == spec )
792 MIL <<
"Multiversion install " << spec <<
": " << (nsize-size) <<
" matches" << endl;
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
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.
Capability()
Default ctor, Empty capability.
@ CAP_ARCH
Used internally.
constexpr IdString()
Default ctor, empty string.
'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.
Locale()
Default Ctor: noCode.
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.
bool remember(unsigned serial_r) const
Return isDirty, storing serial_r as new value.
Remember a files attributes to detect content changes.
static ZConfig & instance()
Singleton ctor.
const char * c_str() const
String representation.
std::string alias() const
unique identifier for this source.
static Pool instance()
Singleton ctor.
static bool snapshotMapped()
Whether mapSnapshot succeeded in this process.
void clear()
Clear the queue.
Container::size_type size_type
size_type size() const
Size of the set.
bool insert(const TSolv &solv_r)
Insert a Solvable.
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().
WhatProvides()
Default ctor.
sat::SolvableSpec _needrebootSpec
Solvables which should trigger the reboot-needed hint if installed/updated.
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
bool _snapshotFileProvides
Whether the pool still holds exactly what the snapshot restored, i.e.
std::string _snapshotCookie
Experimental pool snapshot (see Pool::mapSnapshot).
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
unsigned _snapshotClaiming
>0 while a repo load may still claim snapshot repos, see prepare.
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).
std::vector< std::string > _snapshotAliases
const MultiversionList & multiversionList() const
void snapshotWriteIfNeeded() 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 mapSnapshot(const Pathname &path_r, const std::string &cookie_r)
Experimental pool snapshot (see Pool::mapSnapshot).
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.
std::set< RepoIdType > _snapshotUnclaimed
Snapshot repos not (yet) requested via setRepoInfo; erased in prepare.
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.
Singleton manager for the underlying libsolv string pool.
CURL handle void p CURLversion age struct curl_slist list CURLM multi CURLM CURL handle CURLM curl_socket_t int int running_handles CURLINFO info
CURL handle void p CURLversion age struct curl_slist list CURLM multi CURLM CURL handle CURLM curl_socket_t s
std::map< std::string, std::string > read(const Pathname &_path)
Read sysconfig file path_r and return (key,valye) pairs.
static void _getLocaleDeps(const Capability &cap_r, LocaleSet &store_r)
unsigned int SolvableIdType
Id type to connect Solvable and sat-solvable.
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
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)
CRepo * RepoIdType
Id to denote Solvable::noSolvable.
static void logSat(CPool *, void *data, int type, const char *logString)
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)
relates: Patch::Category string representation.
int repo_add_helix(::Repo *repo, FILE *fp, int flags)
int testcase_add_testtags(Repo *repo, FILE *fp, int flags)
AutoDispose<FILE*> calling fclose
Track added/removed set items based on an initial set.
const set_type & current() const
Return the current set.
bool set(set_type new_r)
Set a new_r set and track changes.
bool add(const value_type &val_r)
Add an element to the set and track changes.
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.
bool remove(const value_type &val_r)
Remove an element from the set and track changes.
const set_type & removed() const
Return the set of removed items.
bool setInitial()
(Re-)Start tracking the current set (discards previously tracked changes).
bool contains(const key_type &key_r) const
Whether val_r is in the set.