libzypp 17.38.15
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#include <set>
25#include <vector>
26
27#include <zypp-core/base/Hash.h>
33#include <zypp/sat/Queue.h>
34
35#ifndef ZYPPNG
36#include <zypp/RepoInfo.h>
37#endif
38
39#include <zypp/Locale.h>
40#include <zypp/Capability.h>
41#include <zypp/IdString.h>
42
44namespace zypp
45{
47 namespace sat
48 {
49 class SolvableSet;
51 namespace detail
52 {
53
55 //
56 // CLASS NAME : PoolImpl
57 //
60 {
61 public:
63 PoolImpl();
64
66 ~PoolImpl();
67
70 { return _pool; }
71
72 public:
74 const SerialNumber & serial() const
75 { return _serial; }
76
78 const SerialNumber & serialIDs() const
79 { return _serialIDs; }
80
84 void prepare() const;
85
87 bool mapSnapshot( const Pathname & path_r, const std::string & cookie_r );
88 void setSnapshotCandidate( const Pathname & path_r, const std::string & cookie_r, const std::vector<std::string> & aliases_r )
89 { _snapshotPath = path_r; _snapshotCookie = cookie_r; _snapshotAliases = aliases_r; }
90 void snapshotWriteIfNeeded() const;
91
92 private:
96 void setDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
97
100 void localeSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
101
104 void depSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
105
107 static detail::IdType nsCallback( CPool *, void * data, detail::IdType lhs, detail::IdType rhs );
108
109 public:
111 static const std::string & systemRepoAlias();
112
113 bool isSystemRepo( CRepo * repo_r ) const
114 { return repo_r && _pool->installed == repo_r; }
115
117 { return _pool->installed; }
118
121 {
122 const char * rd = ::pool_get_rootdir( _pool );
123 return( rd ? rd : "/" );
124 }
125
127 void rootDir( const Pathname & root_r )
128 {
129 if ( root_r.empty() || root_r == "/" )
130 ::pool_set_rootdir( _pool, nullptr );
131 else
132 ::pool_set_rootdir( _pool, root_r.c_str() );
133 }
134
135 public:
141
142 CRepo * _createRepo( const std::string & name_r );
143
145 void _deleteRepo( CRepo * repo_r );
146
151 int _addSolv( CRepo * repo_r, FILE * file_r );
152
157 int _addHelix( CRepo * repo_r, FILE * file_r );
158
163 int _addTesttags( CRepo * repo_r, FILE * file_r );
164
166 detail::SolvableIdType _addSolvables( CRepo * repo_r, unsigned count_r );
168
170 void _postRepoAdd( CRepo * repo_r );
171
172 public:
174 bool validSolvable( const CSolvable & slv_r ) const
175 { return slv_r.repo; }
176
177 bool validSolvable( SolvableIdType id_r ) const
178 { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); }
179
180 bool validSolvable( const CSolvable * slv_r ) const
181 { return _pool->solvables <= slv_r && slv_r <= _pool->solvables+_pool->nsolvables && validSolvable( *slv_r ); }
182
183 public:
184 CPool * getPool() const
185 { return _pool; }
186
188 CRepo * getRepo( RepoIdType id_r ) const
189 { return id_r; }
190
195 {
196 if ( validSolvable( id_r ) )
197 return &_pool->solvables[id_r];
198 return 0;
199 }
200
201 public:
203 sat::detail::IdType parserpmrichdep( const char * capstr_r )
204 { return ::pool_parserpmrichdep( _pool, capstr_r ); }
205
206 public:
211 { return getNextId( 1 ); }
212
219 {
220 for( ++id_r; id_r < unsigned(_pool->nsolvables); ++id_r )
221 {
222 if ( validSolvable( _pool->solvables[id_r] ) )
223 return id_r;
224 }
225 return noSolvableId;
226 }
227
228#ifndef ZYPPNG
229 public:
232 { return _repoinfos[id_r]; }
233
234 void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r );
237 { _repoinfos.erase( id_r ); }
238#endif
239
240 public:
244 const sat::detail::IdType whatProvidesData( unsigned offset_r )
245 { return _pool->whatprovidesdata[offset_r]; }
246
250 unsigned whatProvides( Capability cap_r )
251 { prepare(); return ::pool_whatprovides( _pool, cap_r.id() ); }
252
253 public:
260
261
262 void setTextLocale( const Locale & locale_r );
263
264
268 void initRequestedLocales( const LocaleSet & locales_r );
269
272 { return _requestedLocalesTracker.added(); }
273
276 { return _requestedLocalesTracker.removed(); }
277
280 { return _requestedLocalesTracker.current(); }
281
282 bool isRequestedLocale( const Locale & locale_r ) const
283 { return _requestedLocalesTracker.contains( locale_r ); }
284
286 void setRequestedLocales( const LocaleSet & locales_r );
288 bool addRequestedLocale( const Locale & locale_r );
290 bool eraseRequestedLocale( const Locale & locale_r );
291
293 const LocaleSet & getAvailableLocales() const;
294
295 bool isAvailableLocale( const Locale & locale_r ) const
296 {
297 const LocaleSet & avl( getAvailableLocales() );
298 LocaleSet::const_iterator it( avl.find( locale_r ) );
299 return it != avl.end();
300 }
301
303
305 const TrackedLocaleIds & trackedLocaleIds() const;
307
308 public:
312
313 const MultiversionList & multiversionList() const;
314
315 bool isMultiversion( const Solvable & solv_r ) const;
316
319
320 public:
323
325 { return _autoinstalled; }
326
328 void setAutoInstalled( const StringQueue & autoInstalled_r )
329 { _autoinstalled = autoInstalled_r; }
330
331 bool isOnSystemByUser( IdString ident_r ) const
332 { return !_autoinstalled.contains( ident_r.id() ); }
333
334 bool isOnSystemByAuto( IdString ident_r ) const
335 { return _autoinstalled.contains( ident_r.id() ); }
336
337
338 public:
341
342 void setNeedrebootSpec( sat::SolvableSpec needrebootSpec_r )
343 {
344 _needrebootSpec = std::move(needrebootSpec_r);
345 _needrebootSpec.setDirty();
346 }
347
349 bool isNeedreboot( const Solvable & solv_r ) const
350 { return _needrebootSpec.contains( solv_r ); }
351
352
353 public:
356 bool isRetracted( const Solvable & solv_r ) const
357 { return _retractedSpec.contains( solv_r ); }
358 bool isPtfMaster( const Solvable & solv_r ) const
359 { return _ptfMasterSpec.contains( solv_r ); }
360 bool isPtfPackage( const Solvable & solv_r ) const
361 { return _ptfPackageSpec.contains( solv_r ); }
362
363
364 public:
366 const std::set<std::string> & requiredFilesystems() const;
367
368 private:
374 mutable std::string _snapshotCookie;
376 mutable std::vector<std::string> _snapshotAliases;
378 mutable std::set<RepoIdType> _snapshotUnclaimed;
383
384#ifndef ZYPPNG
386 std::map<RepoIdType,RepoInfo> _repoinfos;
387#endif
388
392
394
396 void multiversionListInit() const;
398
401
403 sat::SolvableSpec _needrebootSpec;
404
406 sat::SolvableSpec _retractedSpec;
407 sat::SolvableSpec _ptfMasterSpec;
408 sat::SolvableSpec _ptfPackageSpec;
409
412 };
413
414
416 } // namespace detail
419 } // namespace sat
422} // namespace zypp
424#define POOL_SETDIRTY
425#endif // ZYPP_SAT_DETAIL_POOLIMPL_H
A sat capability.
Definition Capability.h:63
sat::detail::IdType id() const
Expert backdoor.
Definition Capability.h:289
Access to the sat-pools string space.
Definition IdString.h:55
IdType id() const
Expert backdoor.
Definition IdString.h:144
'Language[_Country]' codes.
Definition Locale.h:51
What is known about a repository.
Definition RepoInfo.h:72
Simple serial number watcher.
Simple serial number provider.
const char * c_str() const
String representation.
Definition Pathname.h:113
bool empty() const
Test for an empty path.
Definition Pathname.h:117
Solvable set wrapper to allow adding additional convenience iterators.
Definition SolvableSet.h:36
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:403
CPool * operator->()
Pointer style access forwarded to sat-pool.
Definition PoolImpl.h:69
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
Definition PoolImpl.h:391
std::string _snapshotCookie
Experimental pool snapshot (see Pool::mapSnapshot)
Definition PoolImpl.h:374
base::SetTracker< IdStringSet > TrackedLocaleIds
Definition PoolImpl.h:302
CPool * getPool() const
Definition PoolImpl.h:184
sat::SolvableSpec _retractedSpec
Blacklisted specs:
Definition PoolImpl.h:406
scoped_ptr< LocaleSet > _availableLocalesPtr
Definition PoolImpl.h:393
CRepo * systemRepo() const
Definition PoolImpl.h:116
bool isPtfMaster(const Solvable &solv_r) const
Definition PoolImpl.h:358
Pathname rootDir() const
Get rootdir (for file conflicts check)
Definition PoolImpl.h:120
scoped_ptr< MultiversionList > _multiversionListPtr
Definition PoolImpl.h:397
StringQueue autoInstalled() const
Get ident list of all autoinstalled solvables.
Definition PoolImpl.h:324
bool isSystemRepo(CRepo *repo_r) const
Definition PoolImpl.h:113
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:153
CRepo * getRepo(RepoIdType id_r) const
Definition PoolImpl.h:188
void setTextLocale(const Locale &locale_r)
Definition PoolImpl.cc:584
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Definition PoolImpl.cc:609
sat::StringQueue _autoinstalled
Definition PoolImpl.h:400
int _addTesttags(CRepo *repo_r, FILE *file_r)
Adding testtags file to a repo.
Definition PoolImpl.cc:492
unsigned whatProvides(Capability cap_r)
Returns offset into the internal whatprovidesdata array.
Definition PoolImpl.h:250
void multiversionListInit() const
Definition PoolImpl.cc:739
const RepoInfo & repoInfo(RepoIdType id_r)
Definition PoolImpl.h:231
bool isPtfPackage(const Solvable &solv_r) const
Definition PoolImpl.h:360
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
Definition PoolImpl.cc:719
bool isRequestedLocale(const Locale &locale_r) const
Definition PoolImpl.h:282
const SerialNumber & serialIDs() const
Serial number changing whenever resusePoolIDs==true was used.
Definition PoolImpl.h:78
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
Definition PoolImpl.h:386
void _deleteRepo(CRepo *repo_r)
Delete repo repo_r from pool.
Definition PoolImpl.cc:457
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition PoolImpl.cc:638
const LocaleSet & getRequestedLocales() const
Current set of requested Locales.
Definition PoolImpl.h:279
sat::SolvableSpec _ptfMasterSpec
Definition PoolImpl.h:407
void eraseRepoInfo(RepoIdType id_r)
Definition PoolImpl.h:236
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
Definition PoolImpl.cc:650
const sat::detail::IdType whatProvidesData(unsigned offset_r)
Returns the id stored at offset_r in the internal whatprovidesdata array.
Definition PoolImpl.h:244
void rootDir(const Pathname &root_r)
Set rootdir (for file conflicts check)
Definition PoolImpl.h:127
bool validSolvable(SolvableIdType id_r) const
Definition PoolImpl.h:177
void localeSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate locale related housekeeping data.
Definition PoolImpl.cc:287
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
Definition PoolImpl.h:411
base::SetTracker< LocaleSet > _requestedLocalesTracker
Definition PoolImpl.h:390
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
Definition PoolImpl.cc:618
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
Definition PoolImpl.h:275
std::vector< std::string > _snapshotAliases
Definition PoolImpl.h:376
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Set new Solvable specs.
Definition PoolImpl.h:342
const MultiversionList & multiversionList() const
Definition PoolImpl.cc:765
void snapshotWriteIfNeeded() const
Definition PoolImpl.cc:376
bool isAvailableLocale(const Locale &locale_r) const
Definition PoolImpl.h:295
CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition PoolImpl.cc:448
SerialNumberWatcher _watcher
Watch serial number.
Definition PoolImpl.h:382
bool isNeedreboot(const Solvable &solv_r) const
Whether solv_r matches the spec.
Definition PoolImpl.h:349
bool validSolvable(const CSolvable *slv_r) const
Definition PoolImpl.h:180
sat::detail::IdType parserpmrichdep(const char *capstr_r)
libsolv capability parser
Definition PoolImpl.h:203
SerialNumber _serial
Serial number - changes with each Pool content change.
Definition PoolImpl.h:372
void setSnapshotCandidate(const Pathname &path_r, const std::string &cookie_r, const std::vector< std::string > &aliases_r)
Definition PoolImpl.h:88
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
Definition PoolImpl.cc:777
void _postRepoAdd(CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
Definition PoolImpl.cc:501
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
Definition PoolImpl.h:271
bool mapSnapshot(const Pathname &path_r, const std::string &cookie_r)
Experimental pool snapshot (see Pool::mapSnapshot)
Definition PoolImpl.cc:310
bool isOnSystemByAuto(IdString ident_r) const
Definition PoolImpl.h:334
void setAutoInstalled(const StringQueue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Definition PoolImpl.h:328
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition PoolImpl.cc:627
int _addSolv(CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition PoolImpl.cc:474
int _addHelix(CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition PoolImpl.cc:483
sat::SolvableSpec _ptfPackageSpec
Definition PoolImpl.h:408
bool isRetracted(const Solvable &solv_r) const
Definition PoolImpl.h:356
bool validSolvable(const CSolvable &slv_r) const
a valid Solvable has a non NULL repo pointer.
Definition PoolImpl.h:174
detail::SolvableIdType _addSolvables(CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition PoolImpl.cc:545
std::set< RepoIdType > _snapshotUnclaimed
Snapshot repos not (yet) requested via setRepoInfo; erased in prepare.
Definition PoolImpl.h:378
CSolvable * getSolvable(SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
Definition PoolImpl.h:194
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate its PoolIt...
Definition PoolImpl.h:380
bool isMultiversion(const Solvable &solv_r) const
Definition PoolImpl.cc:772
void prepare() const
Update housekeeping data (e.g.
Definition PoolImpl.cc:402
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition PoolImpl.cc:116
SolvableIdType getNextId(SolvableIdType id_r) const
Get id of the next valid Solvable.
Definition PoolImpl.h:218
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition PoolImpl.h:74
CPool * _pool
sat-pool.
Definition PoolImpl.h:370
SolvableIdType getFirstId() const
Get id of the first valid Solvable.
Definition PoolImpl.h:210
bool isOnSystemByUser(IdString ident_r) const
Definition PoolImpl.h:331
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
Definition PoolImpl.cc:551
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition PoolImpl.cc:299
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
unsigned int SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition PoolDefines.h:65
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition PoolDefines.h:38
int IdType
Generic Id type.
Definition PoolDefines.h:44
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
Definition PoolDefines.h:39
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition PoolDefines.h:36
CRepo * RepoIdType
Id to denote Solvable::noSolvable.
Definition PoolDefines.h:73
Libsolv interface
Queue StringQueue
Queue with String ids.
Definition Queue.h:28
void setDirty() const
Explicitly flag the cache as dirty, so it will be rebuilt on the next request.
Easy-to use interface to the ZYPP dependency resolver.
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
Track added/removed set items based on an initial set.
Definition SetTracker.h:39