14 #include <boost/mpl/int.hpp>
46 #undef ZYPP_BASE_LOGGER_LOGGROUP
47 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::satpool"
81 static const std::string _val(
"@System" );
87 static const Pathname _val(
"/etc/sysconfig/storage" );
94 static void logSat(
struct _Pool *,
void *data,
int type,
const char *logString )
96 if ( type & (SOLV_FATAL|SOLV_ERROR) ) {
97 _ERR(
"libsolv") << logString;
98 }
else if ( type & SOLV_DEBUG_STATS ) {
99 _DBG(
"libsolv") << logString;
101 _MIL(
"libsolv") << logString;
117 case NAMESPACE_LANGUAGE:
120 const std::tr1::unordered_set<IdString> & locale2Solver( reinterpret_cast<PoolImpl*>(data)->
_locale2Solver );
121 if ( locale2Solver.empty() )
123 return rhs == en.
id() ? RET_systemProperty : RET_unsupported;
125 return locale2Solver.find(
IdString(rhs) ) != locale2Solver.end() ? RET_systemProperty : RET_unsupported;
129 case NAMESPACE_MODALIAS:
139 case NAMESPACE_FILESYSTEM:
142 return requiredFilesystems.find(
IdString(rhs).
asString() ) != requiredFilesystems.end() ? RET_systemProperty : RET_unsupported;
146 case NAMESPACE_PRODUCTBUDDY:
156 return RET_unsupported;
176 : _pool( ::pool_create() )
178 MIL <<
"Creating sat-pool." << endl;
184 if ( getenv(
"ZYPP_LIBSOLV_FULLLOG") || getenv(
"ZYPP_LIBSAT_FULLLOG") )
185 ::pool_setdebuglevel(
_pool, 4 );
186 else if ( getenv(
"ZYPP_FULLLOG") )
187 ::pool_setdebuglevel(
_pool, 2 );
189 ::pool_setdebugmask(
_pool, SOLV_DEBUG_JOB|SOLV_DEBUG_STATS);
195 _pool->nscallbackdata = (
void*)
this;
205 ::pool_free(
_pool );
214 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
215 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
216 else MIL << a1 << endl;
230 if ( a3 )
MIL << a1 <<
" " << a2 <<
" " << a3 << endl;
231 else if ( a2 )
MIL << a1 <<
" " << a2 << endl;
232 else MIL << a1 << endl;
234 ::pool_freewhatprovides(
_pool );
245 if ( !
_pool->whatprovides )
247 MIL <<
"pool_createwhatprovides..." << endl;
249 ::pool_addfileprovides(
_pool );
250 ::pool_createwhatprovides(
_pool );
252 if ( !
_pool->languages )
276 setDirty(__FUNCTION__, name_r.c_str() );
277 ::_Repo * ret = ::repo_create(
_pool, name_r.c_str() );
279 ::pool_set_installed(
_pool, ret );
285 setDirty(__FUNCTION__, repo_r->name );
286 ::repo_free( repo_r,
false );
297 setDirty(__FUNCTION__, repo_r->name );
298 int ret = ::repo_add_solv( repo_r, file_r, 0 );
306 setDirty(__FUNCTION__, repo_r->name );
318 std::set<detail::IdType> sysids;
321 for_( it, sysarchs.begin(), sysarchs.end() )
322 sysids.insert( it->id() );
325 sysids.insert( ARCH_SRC );
326 sysids.insert( ARCH_NOSRC );
330 unsigned blockSize = 0;
333 ::_Solvable * s(
_pool->solvables + i );
334 if ( s->repo == repo_r && sysids.find( s->arch ) == sysids.end() )
341 else if ( blockSize )
344 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
345 blockBegin = blockSize = 0;
351 ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
false );
352 blockBegin = blockSize = 0;
364 setDirty(__FUNCTION__, repo_r->name );
365 return ::repo_add_solvable_block( repo_r, count_r );
370 ::_Repo * repo(
getRepo( id_r ) );
377 if ( repo->priority !=
int(-info_r.
priority()) )
379 repo->priority = -info_r.
priority();
386 if ( repo->subpriority != mediaPriority )
388 repo->subpriority = mediaPriority;
402 std::tr1::unordered_set<IdString> & locale2Solver )
404 std::tr1::unordered_set<IdString>( 2*locales_r.size() ).swap( locale2Solver );
405 for_( it, locales_r.begin(),locales_r.end() )
408 locale2Solver.insert(
IdString( l.code() ) );
410 MIL <<
"New Solver Locales: " << locale2Solver << endl;
415 std::vector<std::string> fallbacklist;
418 fallbacklist.push_back( l.code() );
420 dumpRangeLine(
MIL <<
"pool_set_languages: ", fallbacklist.begin(), fallbacklist.end() ) << endl;
422 std::vector<const char *> fallbacklist_cstr;
423 for_( it, fallbacklist.begin(), fallbacklist.end() )
425 fallbacklist_cstr.push_back( it->c_str() );
427 ::pool_set_languages(
_pool, &fallbacklist_cstr.front(), fallbacklist_cstr.size() );
434 MIL <<
"New RequestedLocales: " << locales_r << endl;
466 switch ( detail.
capRel() )
476 if ( detail.
lhs().
id() == NAMESPACE_LANGUAGE )
478 store_r.insert( detail.
rhs().
id() );
495 std::tr1::unordered_set<sat::detail::IdType> tmp;
500 for_( cit, cap.begin(), cap.end() )
505 #warning immediately build LocaleSet as soon as Loale is an Id based type
507 for_( it, tmp.begin(), tmp.end() )
520 const std::set<std::string> & multiversionSpec(
ZConfig::instance().multiversionSpec() );
521 for_( it, multiversionSpec.begin(), multiversionSpec.end() )
523 static const std::string prefix(
"provides:" );
527 if ( provides.
empty() )
529 MIL <<
"Multiversion install not provided (" << *it <<
")" << endl;
535 if ( multiversionList.insert( pit->ident() ).second )
536 MIL <<
"Multiversion install " << pit->ident() <<
" (" << *it <<
")" << endl;
542 MIL <<
"Multiversion install " << *it << endl;
543 multiversionList.insert(
IdString( *it ) );
556 MIL <<
"Target not initialized." << endl;
560 MIL <<
"onSystemByUserList from history: " << pi << endl;
566 std::ifstream infile( pi.path().c_str() );
569 const char * ch( (*in).c_str() );
571 if ( *ch <
'1' ||
'9' < *ch )
573 const char * sep1 = ::strchr( ch,
'|' );
578 bool installs =
true;
579 if ( ::strncmp( sep1,
"install|", 8 ) )
581 if ( ::strncmp( sep1,
"remove |", 8 ) )
588 const char * sep2 = ::strchr( sep1,
'|' );
589 if ( !sep2 || sep1 == sep2 )
591 (*in)[sep2-ch] =
'\0';
596 onSystemByUserList.erase( pkg );
600 if ( (sep1 = ::strchr( sep2+1,
'|' ))
601 && (sep1 = ::strchr( sep1+1,
'|' ))
602 && (sep2 = ::strchr( sep1+1,
'|' )) )
604 (*in)[sep2-ch] =
'\0';
605 if ( ::strchr( sep1+1,
'@' ) )
608 onSystemByUserList.insert( pkg );
613 MIL <<
"onSystemByUserList found: " << onSystemByUserList.size() << endl;
623 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.
A Solvable object within the sat Pool.
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.
bool next()
Advance to next line.
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.
Simple lineparser: Traverse each line in a file.
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
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.
const OnSystemByUserList & onSystemByUserList() const
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.
sat::Solvable buddy() const
Return the buddy we share our status object with.
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)
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
Reference to a PoolItem connecting ResObject and ResStatus.
IdType id() const
Expert backdoor.
scoped_ptr< OnSystemByUserList > _onSystemByUserListPtr
const MultiversionList & multiversionList() const
void onSystemByUserListInit() const
IdStringSet OnSystemByUserList
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.).