14 #include <boost/mpl/int.hpp> 21 #include <zypp-core/fs/WatchFile> 22 #include <zypp-core/parser/Sysconfig> 49 #undef ZYPP_BASE_LOGGER_LOGGROUP 50 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::satpool" 61 const char * envp = getenv(
"LIBSOLV_DEBUGMASK");
62 return envp ? str::strtonum<int>( envp ) : 0;
102 static const std::string _val(
"@System" );
108 static const Pathname _val(
"/etc/sysconfig/storage" );
114 static void logSat(
CPool *,
void *data,
int type,
const char *logString )
117 if ( 0 == strncmp( logString,
"job: drop orphaned", 18 ) )
119 if ( 0 == strncmp( logString,
"job: user installed", 19 ) )
121 if ( 0 == strncmp( logString,
"job: multiversion", 17 ) )
123 if ( 0 == strncmp( logString,
" - no rule created", 19 ) )
125 if ( 0 == strncmp( logString,
" next rules: 0 0", 19 ) )
128 if ( type & (SOLV_FATAL|SOLV_ERROR) ) {
129 L_ERR(
"libsolv") << logString;
130 }
else if ( type & SOLV_DEBUG_STATS ) {
131 L_DBG(
"libsolv") << logString;
133 L_MIL(
"libsolv") << logString;
149 case NAMESPACE_LANGUAGE:
152 return localeIds.
contains(
IdString(rhs) ) ? RET_systemProperty : RET_unsupported;
156 case NAMESPACE_MODALIAS:
166 case NAMESPACE_FILESYSTEM:
176 return RET_unsupported;
196 : _pool( ::pool_create() )
198 MIL <<
"Creating sat-pool." << endl;
204 ::pool_setdisttype(
_pool, DISTTYPE_RPM );
213 if ( getenv(
"ZYPP_LIBSOLV_FULLLOG") || getenv(
"ZYPP_LIBSAT_FULLLOG") )
214 ::pool_setdebuglevel(
_pool, 3 );
215 else if ( getenv(
"ZYPP_FULLLOG") )
216 ::pool_setdebuglevel(
_pool, 2 );
218 ::pool_setdebugmask(
_pool, SOLV_DEBUG_JOB|SOLV_DEBUG_STATS );
225 _pool->nscallbackdata = (
void*)
this;
242 ::pool_free(
_pool );
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 );
312 if ( !
_pool->whatprovides )
314 MIL <<
"pool_createwhatprovides..." << endl;
316 ::pool_addfileprovides(
_pool );
317 ::pool_createwhatprovides(
_pool );
319 if ( !
_pool->languages )
330 setDirty(__FUNCTION__, name_r.c_str() );
331 CRepo * ret = ::repo_create(
_pool, name_r.c_str() );
333 ::pool_set_installed(
_pool, ret );
339 setDirty(__FUNCTION__, repo_r->name );
343 ::repo_free( repo_r,
false );
346 if ( !
_pool->urepos )
349 ::pool_freeallrepos(
_pool,
true );
355 setDirty(__FUNCTION__, repo_r->name );
356 int ret = ::repo_add_solv( repo_r, file_r, 0 );
364 setDirty(__FUNCTION__, repo_r->name );
373 setDirty(__FUNCTION__, repo_r->name );
385 std::set<detail::IdType> sysids;
388 for_( it, sysarchs.begin(), sysarchs.end() )
389 sysids.insert( it->id() );
392 sysids.insert( ARCH_SRC );
393 sysids.insert( ARCH_NOSRC );
397 unsigned blockSize = 0;
401 if ( s->repo == repo_r && sysids.find( s->arch ) == sysids.end() )
408 else if ( blockSize )
411 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
412 blockBegin = blockSize = 0;
418 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
419 blockBegin = blockSize = 0;
426 setDirty(__FUNCTION__, repo_r->name );
427 return ::repo_add_solvable_block( repo_r, count_r );
439 if ( repo->priority !=
int(-info_r.
priority()) )
441 repo->priority = -info_r.
priority();
448 if ( repo->subpriority != mediaPriority )
450 repo->subpriority = mediaPriority;
467 const char *needone[] {
"en" };
468 ::pool_set_languages(
_pool, needone, 1 );
472 std::vector<std::string> fallbacklist;
475 fallbacklist.push_back( l.code() );
477 dumpRangeLine(
MIL <<
"pool_set_languages: ", fallbacklist.begin(), fallbacklist.end() ) << endl;
479 std::vector<const char *> fallbacklist_cstr;
480 for_( it, fallbacklist.begin(), fallbacklist.end() )
482 fallbacklist_cstr.push_back( it->c_str() );
484 ::pool_set_languages(
_pool, &fallbacklist_cstr.front(), fallbacklist_cstr.size() );
540 if ( localesTracker.
wasAdded( lang ) )
542 for ( ; lang; lang = lang.fallback() )
549 for ( ; lang && localeIds.
current().insert(
IdString(lang) ).second; lang = lang.fallback() )
556 for ( ; lang && ! localeIds.
current().count(
IdString(lang) ); lang = lang.fallback() )
575 switch ( detail.
capRel() )
585 if ( detail.
lhs().
id() == NAMESPACE_LANGUAGE )
606 for (
const Capability & cap : pi.supplements() )
625 static const std::string prefix(
"provides:" );
630 if ( provides || solv.ident() == spec )
635 MIL <<
"Multiversion install " << spec <<
": " << (nsize-size) <<
" matches" << endl;
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
std::string asString(const Patch::Category &obj)
static const IdType namespaceModalias(18)
int testcase_add_testtags(Repo *repo, FILE *fp, int flags)
bool contains(const TSolv &solv_r) const
bool contains(const key_type &key_r) const
Whether val_r is in the set.
unsigned priority() const
Repository priority for solver.
const Pathname & sysconfigStoragePath()
static const IdString ptfMasterToken
Indicator provides ptf()
A Solvable object within the sat Pool.
Container of Solvable providing a Capability (read only).
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
scoped_ptr< LocaleSet > _availableLocalesPtr
Namespace intended to collect all environment variables we use.
std::string code() const
Return the locale code asString.
Track added/removed set items based on an initial set.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
static ZConfig & instance()
Singleton ctor.
void multiversionListInit() const
bool remember(unsigned serial_r) const
Return isDirty, storing serial_r as new value.
Locale textLocale() const
The locale for translated texts zypp uses.
Helper providing more detailed information about a Capability.
int _addSolv(CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
base::SetTracker< LocaleSet > _requestedLocalesTracker
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
void setDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
bool set(set_type new_r)
Set a new_r set and track changes.
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
bool setInitial()
(Re-)Start tracking the current set (discards previously tracked changes).
const MultiversionList & multiversionList() const
std::unordered_set< Locale > LocaleSet
void _deleteRepo(CRepo *repo_r)
Delete repo repo_r from pool.
int _addTesttags(CRepo *repo_r, FILE *file_r)
Adding testtags file to a repo.
Locale fallback() const
Return the fallback locale for this locale, if no fallback exists the empty Locale::noCode.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
bool wasAdded(const key_type &key_r) const
Whether val_r is tracked as added.
void eraseRepoInfo(RepoIdType id_r)
int IdType
Generic Id type.
What is known about a repository.
detail::SolvableIdType _addSolvables(CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
void localeSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate locale related housekeeping data.
static const IdType solvableFileMarker(16)
sat::SolvableSpec _retractedSpec
Blacklisted specs:
std::map< std::string, std::string > read(const Pathname &_path)
Read sysconfig file path_r and return (key,valye) pairs.
CRepo * getRepo(RepoIdType id_r) const
Remember a files attributes to detect content changes.
const set_type & removed() const
Return the set of removed items.
sat::detail::IdType id() const
Expert backdoor.
bool isSystemRepo(CRepo *repo_r) const
int repo_add_helix(::Repo *repo, FILE *fp, int flags)
Url url() const
Pars pro toto: The first repository url.
static const IdString ptfPackageToken
Indicator provides ptf-package()
static detail::IdType nsCallback(CPool *, void *data, detail::IdType lhs, detail::IdType rhs)
Callback to resolve namespace dependencies (language, modalias, filesystem, etc.).
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \, const Trim trim_r=NO_TRIM)
Split line_r into words.
static Pool instance()
Singleton ctor.
static const IdType emptyId(1)
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
void setDirty() const
Explicitly flag the cache as dirty, so it will be rebuilt on the next request.
SerialNumberWatcher _watcher
Watch serial number.
std::string alias() const
unique identifier for this source.
static const SolvableIdType systemSolvableId(1)
Id to denote the usually hidden Solvable::systemSolvable.
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
const set_type & current() const
Return the current set.
bool add(const value_type &val_r)
Add an element to the set and track changes.
sat::StringQueue _autoinstalled
const set_type & added() const
Return the set of added items.
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Container::size_type size_type
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate its PoolIt...
static PoolImpl & myPool()
static const IdType namespaceFilesystem(21)
bool query(IdString cap_r) const
Checks if a device on the system matches a modalias pattern.
BOOST_MPL_ASSERT_RELATION(noId,==, STRID_NULL)
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
void prepare() const
Update housekeeping data (e.g.
void addProvides(Capability provides_r)
A all sat::Solvable matching this provides_r.
bool empty() const
Whether neither idents nor provides are set.
bool isMultiversion(const Solvable &solv_r) const
'Language[_Country]' codes.
void _postRepoAdd(CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
SerialNumber _serial
Serial number - changes with each Pool content change.
scoped_ptr< MultiversionList > _multiversionListPtr
sat::SolvableSpec _ptfPackageSpec
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
static Modalias & instance()
Singleton access.
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
constexpr std::string_view FILE("file")
static void logSat(CPool *, void *data, int type, const char *logString)
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.
static const IdType namespaceLanguage(20)
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
static const std::string & systemRepoAlias()
Reserved system repository alias .
static void _getLocaleDeps(const Capability &cap_r, LocaleSet &store_r)
static const IdType noId(0)
std::ostream & dumpRangeLine(std::ostream &str, TIterator begin, TIterator end)
Print range defined by iterators (single line style).
static const IdType solvablePrereqMarker(15)
Internal ids satlib includes in dependencies.
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
bool addIdenticalInstalledToo() const
Extend the provides set to include idential installed items as well.
unsigned int SolvableIdType
Id type to connect Solvable and sat-solvable.
bool remove(const value_type &val_r)
Remove an element from the set and track changes.
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
static const IdString retractedToken
Indicator provides retracted-patch-package()
sat::SolvableSpec _ptfMasterSpec
Easy-to use interface to the ZYPP dependency resolver.
size_type size() const
Size of the set.
int _addHelix(CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
sat::SolvableSpec _needrebootSpec
Solvables which should trigger the reboot-needed hint if installed/updated.
std::string hexdecode(const C_Str &str_r)
Decode hexencoded XX sequences.
void multiversionSpecChanged()
bool insert(const TSolv &solv_r)
Insert a Solvable.
Solvable set wrapper to allow adding additional convenience iterators.