libzypp 17.31.23
PoolImpl.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_SAT_DETAIL_POOLIMPL_H
13#define ZYPP_SAT_DETAIL_POOLIMPL_H
14extern "C"
15{
16#include <solv/pool.h>
17#include <solv/repo.h>
18#include <solv/solvable.h>
19#include <solv/poolarch.h>
20#include <solv/repo_solv.h>
21#include <solv/pool_parserpmrichdep.h>
22}
23#include <iosfwd>
24
25#include <zypp/base/Hash.h>
26#include <zypp/base/NonCopyable.h>
31#include <zypp/sat/Queue.h>
32#include <zypp/RepoInfo.h>
33#include <zypp/Locale.h>
34#include <zypp/Capability.h>
35#include <zypp/IdString.h>
36
38namespace zypp
39{
41 namespace sat
42 {
43 class SolvableSet;
45 namespace detail
46 {
47
49 //
50 // CLASS NAME : PoolImpl
51 //
54 {
55 public:
57 PoolImpl();
58
60 ~PoolImpl();
61
64 { return _pool; }
65
66 public:
68 const SerialNumber & serial() const
69 { return _serial; }
70
72 const SerialNumber & serialIDs() const
73 { return _serialIDs; }
74
78 void prepare() const;
79
80 private:
84 void setDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
85
88 void localeSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
89
92 void depSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
93
95 static detail::IdType nsCallback( CPool *, void * data, detail::IdType lhs, detail::IdType rhs );
96
97 public:
99 static const std::string & systemRepoAlias();
100
101 bool isSystemRepo( CRepo * repo_r ) const
102 { return repo_r && _pool->installed == repo_r; }
103
105 { return _pool->installed; }
106
109 {
110 const char * rd = ::pool_get_rootdir( _pool );
111 return( rd ? rd : "/" );
112 }
113
115 void rootDir( const Pathname & root_r )
116 {
117 if ( root_r.empty() || root_r == "/" )
118 ::pool_set_rootdir( _pool, nullptr );
119 else
120 ::pool_set_rootdir( _pool, root_r.c_str() );
121 }
122
123 public:
130 CRepo * _createRepo( const std::string & name_r );
131
133 void _deleteRepo( CRepo * repo_r );
134
139 int _addSolv( CRepo * repo_r, FILE * file_r );
140
145 int _addHelix( CRepo * repo_r, FILE * file_r );
146
151 int _addTesttags( CRepo * repo_r, FILE * file_r );
152
154 detail::SolvableIdType _addSolvables( CRepo * repo_r, unsigned count_r );
156
158 void _postRepoAdd( CRepo * repo_r );
159
160 public:
162 bool validSolvable( const CSolvable & slv_r ) const
163 { return slv_r.repo; }
165 bool validSolvable( SolvableIdType id_r ) const
166 { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); }
168 bool validSolvable( const CSolvable * slv_r ) const
169 { return _pool->solvables <= slv_r && slv_r <= _pool->solvables+_pool->nsolvables && validSolvable( *slv_r ); }
170
171 public:
172 CPool * getPool() const
173 { return _pool; }
174
176 CRepo * getRepo( RepoIdType id_r ) const
177 { return id_r; }
178
183 {
184 if ( validSolvable( id_r ) )
185 return &_pool->solvables[id_r];
186 return 0;
187 }
188
189 public:
191 sat::detail::IdType parserpmrichdep( const char * capstr_r )
192 { return ::pool_parserpmrichdep( _pool, capstr_r ); }
193
194 public:
199 { return getNextId( 1 ); }
200
207 {
208 for( ++id_r; id_r < unsigned(_pool->nsolvables); ++id_r )
209 {
210 if ( validSolvable( _pool->solvables[id_r] ) )
211 return id_r;
212 }
213 return noSolvableId;
214 }
215
216 public:
219 { return _repoinfos[id_r]; }
221 void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r );
224 { _repoinfos.erase( id_r ); }
225
226 public:
230 const sat::detail::IdType whatProvidesData( unsigned offset_r )
231 { return _pool->whatprovidesdata[offset_r]; }
232
236 unsigned whatProvides( Capability cap_r )
237 { prepare(); return ::pool_whatprovides( _pool, cap_r.id() ); }
238
239 public:
246
247
248 void setTextLocale( const Locale & locale_r );
249
250
254 void initRequestedLocales( const LocaleSet & locales_r );
255
258 { return _requestedLocalesTracker.added(); }
259
263
267
268 bool isRequestedLocale( const Locale & locale_r ) const
269 { return _requestedLocalesTracker.contains( locale_r ); }
270
272 void setRequestedLocales( const LocaleSet & locales_r );
274 bool addRequestedLocale( const Locale & locale_r );
276 bool eraseRequestedLocale( const Locale & locale_r );
277
279 const LocaleSet & getAvailableLocales() const;
280
281 bool isAvailableLocale( const Locale & locale_r ) const
282 {
283 const LocaleSet & avl( getAvailableLocales() );
284 LocaleSet::const_iterator it( avl.find( locale_r ) );
285 return it != avl.end();
286 }
287
289
291 const TrackedLocaleIds & trackedLocaleIds() const;
293
294 public:
298
299 const MultiversionList & multiversionList() const;
300
301 bool isMultiversion( const Solvable & solv_r ) const;
302
305
306 public:
311 { return _autoinstalled; }
312
314 void setAutoInstalled( const StringQueue & autoInstalled_r )
315 { _autoinstalled = autoInstalled_r; }
316
317 bool isOnSystemByUser( IdString ident_r ) const
318 { return !_autoinstalled.contains( ident_r.id() ); }
319
320 bool isOnSystemByAuto( IdString ident_r ) const
321 { return _autoinstalled.contains( ident_r.id() ); }
323
324 public:
328 void setNeedrebootSpec( sat::SolvableSpec needrebootSpec_r )
329 {
330 _needrebootSpec = std::move(needrebootSpec_r);
332 }
333
335 bool isNeedreboot( const Solvable & solv_r ) const
336 { return _needrebootSpec.contains( solv_r ); }
338
339 public:
342 bool isRetracted( const Solvable & solv_r ) const
343 { return _retractedSpec.contains( solv_r ); }
344 bool isPtfMaster( const Solvable & solv_r ) const
345 { return _ptfMasterSpec.contains( solv_r ); }
346 bool isPtfPackage( const Solvable & solv_r ) const
347 { return _ptfPackageSpec.contains( solv_r ); }
349
350 public:
352 const std::set<std::string> & requiredFilesystems() const;
353
354 private:
364 std::map<RepoIdType,RepoInfo> _repoinfos;
365
368 mutable scoped_ptr<TrackedLocaleIds> _trackedLocaleIdsPtr;
369
370 mutable scoped_ptr<LocaleSet> _availableLocalesPtr;
371
373 void multiversionListInit() const;
374 mutable scoped_ptr<MultiversionList> _multiversionListPtr;
375
378
381
386
388 mutable scoped_ptr<std::set<std::string> > _requiredFilesystemsPtr;
389 };
391
393 } // namespace detail
396 } // namespace sat
399} // namespace zypp
401#define POOL_SETDIRTY
402#endif // ZYPP_SAT_DETAIL_POOLIMPL_H
A sat capability.
Definition: Capability.h:63
sat::detail::IdType id() const
Expert backdoor.
Definition: Capability.h:263
Access to the sat-pools string space.
Definition: IdString.h:43
IdType id() const
Expert backdoor.
Definition: IdString.h:122
'Language[_Country]' codes.
Definition: Locale.h:50
What is known about a repository.
Definition: RepoInfo.h:72
Simple serial number watcher.
Definition: SerialNumber.h:123
Simple serial number provider.
Definition: SerialNumber.h:45
const char * c_str() const
String representation.
Definition: Pathname.h:110
bool empty() const
Test for an empty path.
Definition: Pathname.h:114
Libsolv Id queue wrapper.
Definition: Queue.h:35
bool contains(value_type val_r) const
Return whether the Queue contais at lest one element with value val_r.
Definition: Queue.h:57
Solvable set wrapper to allow adding additional convenience iterators.
Definition: SolvableSet.h:36
Define a set of Solvables by ident and provides.
Definition: SolvableSpec.h:45
bool contains(const sat::Solvable &solv_r) const
Test whether solv_r matches the spec.
void setDirty() const
Explicitly flag the cache as dirty, so it will be rebuilt on the next request.
A Solvable object within the sat Pool.
Definition: Solvable.h:54
sat::SolvableSpec _needrebootSpec
Solvables which should trigger the reboot-needed hint if installed/updated.
Definition: PoolImpl.h:380
CPool * operator->()
Pointer style access forwarded to sat-pool.
Definition: PoolImpl.h:63
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
Definition: PoolImpl.h:368
base::SetTracker< IdStringSet > TrackedLocaleIds
Definition: PoolImpl.h:288
CPool * getPool() const
Definition: PoolImpl.h:172
sat::SolvableSpec _retractedSpec
Blacklisted specs:
Definition: PoolImpl.h:383
scoped_ptr< LocaleSet > _availableLocalesPtr
Definition: PoolImpl.h:370
CRepo * systemRepo() const
Definition: PoolImpl.h:104
bool isPtfMaster(const Solvable &solv_r) const
Definition: PoolImpl.h:344
Pathname rootDir() const
Get rootdir (for file conflicts check)
Definition: PoolImpl.h:108
scoped_ptr< MultiversionList > _multiversionListPtr
Definition: PoolImpl.h:374
StringQueue autoInstalled() const
Get ident list of all autoinstalled solvables.
Definition: PoolImpl.h:310
bool isSystemRepo(CRepo *repo_r) const
Definition: PoolImpl.h:101
static detail::IdType nsCallback(CPool *, void *data, detail::IdType lhs, detail::IdType rhs)
Callback to resolve namespace dependencies (language, modalias, filesystem, etc.).
Definition: PoolImpl.cc:137
CRepo * getRepo(RepoIdType id_r) const
Definition: PoolImpl.h:176
void setTextLocale(const Locale &locale_r)
Definition: PoolImpl.cc:462
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Definition: PoolImpl.cc:487
sat::StringQueue _autoinstalled
Definition: PoolImpl.h:377
int _addTesttags(CRepo *repo_r, FILE *file_r)
Adding testtags file to a repo.
Definition: PoolImpl.cc:371
unsigned whatProvides(Capability cap_r)
Returns offset into the internal whatprovidesdata array.
Definition: PoolImpl.h:236
void multiversionListInit() const
Definition: PoolImpl.cc:617
const RepoInfo & repoInfo(RepoIdType id_r)
Definition: PoolImpl.h:218
bool isPtfPackage(const Solvable &solv_r) const
Definition: PoolImpl.h:346
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
Definition: PoolImpl.cc:597
bool isRequestedLocale(const Locale &locale_r) const
Definition: PoolImpl.h:268
const SerialNumber & serialIDs() const
Serial number changing whenever resusePoolIDs==true was used.
Definition: PoolImpl.h:72
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
Definition: PoolImpl.h:364
void _deleteRepo(CRepo *repo_r)
Delete repo repo_r from pool.
Definition: PoolImpl.cc:337
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition: PoolImpl.cc:516
const LocaleSet & getRequestedLocales() const
Current set of requested Locales.
Definition: PoolImpl.h:265
sat::SolvableSpec _ptfMasterSpec
Definition: PoolImpl.h:384
void eraseRepoInfo(RepoIdType id_r)
Definition: PoolImpl.h:223
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
Definition: PoolImpl.cc:528
const sat::detail::IdType whatProvidesData(unsigned offset_r)
Returns the id stored at offset_r in the internal whatprovidesdata array.
Definition: PoolImpl.h:230
void rootDir(const Pathname &root_r)
Set rootdir (for file conflicts check)
Definition: PoolImpl.h:115
bool validSolvable(SolvableIdType id_r) const
Definition: PoolImpl.h:165
void localeSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate locale related housekeeping data.
Definition: PoolImpl.cc:274
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
Definition: PoolImpl.h:388
base::SetTracker< LocaleSet > _requestedLocalesTracker
Definition: PoolImpl.h:367
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
Definition: PoolImpl.cc:496
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
Definition: PoolImpl.h:261
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Set new Solvable specs.
Definition: PoolImpl.h:328
const MultiversionList & multiversionList() const
Definition: PoolImpl.cc:643
bool isAvailableLocale(const Locale &locale_r) const
Definition: PoolImpl.h:281
CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition: PoolImpl.cc:328
SerialNumberWatcher _watcher
Watch serial number.
Definition: PoolImpl.h:362
bool isNeedreboot(const Solvable &solv_r) const
Whether solv_r matches the spec.
Definition: PoolImpl.h:335
bool validSolvable(const CSolvable *slv_r) const
Definition: PoolImpl.h:168
sat::detail::IdType parserpmrichdep(const char *capstr_r)
libsolv capability parser
Definition: PoolImpl.h:191
SerialNumber _serial
Serial number - changes with each Pool content change.
Definition: PoolImpl.h:358
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
Definition: PoolImpl.cc:655
void _postRepoAdd(CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
Definition: PoolImpl.cc:380
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
Definition: PoolImpl.h:257
bool isOnSystemByAuto(IdString ident_r) const
Definition: PoolImpl.h:320
void setAutoInstalled(const StringQueue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Definition: PoolImpl.h:314
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition: PoolImpl.cc:505
int _addSolv(CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition: PoolImpl.cc:353
SolvableSet MultiversionList
Definition: PoolImpl.h:297
int _addHelix(CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition: PoolImpl.cc:362
sat::SolvableSpec _ptfPackageSpec
Definition: PoolImpl.h:385
bool isRetracted(const Solvable &solv_r) const
Definition: PoolImpl.h:342
bool validSolvable(const CSolvable &slv_r) const
a valid Solvable has a non NULL repo pointer.
Definition: PoolImpl.h:162
detail::SolvableIdType _addSolvables(CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition: PoolImpl.cc:424
CSolvable * getSolvable(SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
Definition: PoolImpl.h:182
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate its PoolIt...
Definition: PoolImpl.h:360
bool isMultiversion(const Solvable &solv_r) const
Definition: PoolImpl.cc:650
void prepare() const
Update housekeeping data (e.g.
Definition: PoolImpl.cc:297
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition: PoolImpl.cc:100
SolvableIdType getNextId(SolvableIdType id_r) const
Get id of the next valid Solvable.
Definition: PoolImpl.h:206
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition: PoolImpl.h:68
CPool * _pool
sat-pool.
Definition: PoolImpl.h:356
SolvableIdType getFirstId() const
Get id of the first valid Solvable.
Definition: PoolImpl.h:198
bool isOnSystemByUser(IdString ident_r) const
Definition: PoolImpl.h:317
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
Definition: PoolImpl.cc:430
void setDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:247
PoolImpl()
Default ctor.
Definition: PoolImpl.cc:195
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:286
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:63
int IdType
Generic Id type.
Definition: PoolMember.h:104
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:64
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:61
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolMember.h:125
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolMember.h:133
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
Track added/removed set items based on an initial set.
Definition: SetTracker.h:38
const set_type & current() const
Return the current set.
Definition: SetTracker.h:139
const set_type & added() const
Return the set of added items.
Definition: SetTracker.h:142
const set_type & removed() const
Return the set of removed items.
Definition: SetTracker.h:145
bool contains(const key_type &key_r) const
Whether val_r is in the set.
Definition: SetTracker.h:129