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;
92 unsigned & snapshotClaimingRef() const
93 { return _snapshotClaiming; }
94
95
96 private:
100 void setDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
101
104 void localeSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
105
108 void depSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
109
111 static detail::IdType nsCallback( CPool *, void * data, detail::IdType lhs, detail::IdType rhs );
112
113 public:
115 static const std::string & systemRepoAlias();
116
117 bool isSystemRepo( CRepo * repo_r ) const
118 { return repo_r && _pool->installed == repo_r; }
119
121 { return _pool->installed; }
122
125 {
126 const char * rd = ::pool_get_rootdir( _pool );
127 return( rd ? rd : "/" );
128 }
129
131 void rootDir( const Pathname & root_r )
132 {
133 if ( root_r.empty() || root_r == "/" )
134 ::pool_set_rootdir( _pool, nullptr );
135 else
136 ::pool_set_rootdir( _pool, root_r.c_str() );
137 }
138
139 public:
145
146 CRepo * _createRepo( const std::string & name_r );
147
149 void _deleteRepo( CRepo * repo_r );
150
155 int _addSolv( CRepo * repo_r, FILE * file_r );
156
161 int _addHelix( CRepo * repo_r, FILE * file_r );
162
167 int _addTesttags( CRepo * repo_r, FILE * file_r );
168
170 detail::SolvableIdType _addSolvables( CRepo * repo_r, unsigned count_r );
172
174 void _postRepoAdd( CRepo * repo_r );
175
176 public:
178 bool validSolvable( const CSolvable & slv_r ) const
179 { return slv_r.repo; }
180
181 bool validSolvable( SolvableIdType id_r ) const
182 { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); }
183
184 bool validSolvable( const CSolvable * slv_r ) const
185 { return _pool->solvables <= slv_r && slv_r <= _pool->solvables+_pool->nsolvables && validSolvable( *slv_r ); }
186
187 public:
188 CPool * getPool() const
189 { return _pool; }
190
192 CRepo * getRepo( RepoIdType id_r ) const
193 { return id_r; }
194
199 {
200 if ( validSolvable( id_r ) )
201 return &_pool->solvables[id_r];
202 return 0;
203 }
204
205 public:
207 sat::detail::IdType parserpmrichdep( const char * capstr_r )
208 { return ::pool_parserpmrichdep( _pool, capstr_r ); }
209
210 public:
215 { return getNextId( 1 ); }
216
223 {
224 for( ++id_r; id_r < unsigned(_pool->nsolvables); ++id_r )
225 {
226 if ( validSolvable( _pool->solvables[id_r] ) )
227 return id_r;
228 }
229 return noSolvableId;
230 }
231
232#ifndef ZYPPNG
233 public:
236 { return _repoinfos[id_r]; }
237
238 void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r );
241 { _repoinfos.erase( id_r ); }
242#endif
243
244 public:
248 const sat::detail::IdType whatProvidesData( unsigned offset_r )
249 { return _pool->whatprovidesdata[offset_r]; }
250
254 unsigned whatProvides( Capability cap_r )
255 { prepare(); return ::pool_whatprovides( _pool, cap_r.id() ); }
256
257 public:
264
265
266 void setTextLocale( const Locale & locale_r );
267
268
272 void initRequestedLocales( const LocaleSet & locales_r );
273
277
281
285
286 bool isRequestedLocale( const Locale & locale_r ) const
287 { return _requestedLocalesTracker.contains( locale_r ); }
288
290 void setRequestedLocales( const LocaleSet & locales_r );
292 bool addRequestedLocale( const Locale & locale_r );
294 bool eraseRequestedLocale( const Locale & locale_r );
295
297 const LocaleSet & getAvailableLocales() const;
298
299 bool isAvailableLocale( const Locale & locale_r ) const
300 {
301 const LocaleSet & avl( getAvailableLocales() );
302 LocaleSet::const_iterator it( avl.find( locale_r ) );
303 return it != avl.end();
304 }
305
307
309 const TrackedLocaleIds & trackedLocaleIds() const;
311
312 public:
316
317 const MultiversionList & multiversionList() const;
318
319 bool isMultiversion( const Solvable & solv_r ) const;
320
323
324 public:
327
329 { return _autoinstalled; }
330
332 void setAutoInstalled( const StringQueue & autoInstalled_r )
333 { _autoinstalled = autoInstalled_r; }
334
335 bool isOnSystemByUser( IdString ident_r ) const
336 { return !_autoinstalled.contains( ident_r.id() ); }
337
338 bool isOnSystemByAuto( IdString ident_r ) const
339 { return _autoinstalled.contains( ident_r.id() ); }
340
341
342 public:
345
346 void setNeedrebootSpec( sat::SolvableSpec needrebootSpec_r )
347 {
348 _needrebootSpec = std::move(needrebootSpec_r);
349 _needrebootSpec.setDirty();
350 }
351
353 bool isNeedreboot( const Solvable & solv_r ) const
354 { return _needrebootSpec.contains( solv_r ); }
355
356
357 public:
360 bool isRetracted( const Solvable & solv_r ) const
361 { return _retractedSpec.contains( solv_r ); }
362 bool isPtfMaster( const Solvable & solv_r ) const
363 { return _ptfMasterSpec.contains( solv_r ); }
364 bool isPtfPackage( const Solvable & solv_r ) const
365 { return _ptfPackageSpec.contains( solv_r ); }
366
367
368 public:
370 const std::set<std::string> & requiredFilesystems() const;
371
372 private:
378 mutable std::string _snapshotCookie;
380 mutable std::vector<std::string> _snapshotAliases;
382 mutable std::set<RepoIdType> _snapshotUnclaimed;
385 mutable bool _snapshotFileProvides = false;
387 mutable unsigned _snapshotClaiming = 0;
392
393#ifndef ZYPPNG
395 std::map<RepoIdType,RepoInfo> _repoinfos;
396#endif
397
401
403
405 void multiversionListInit() const;
407
410
412 sat::SolvableSpec _needrebootSpec;
413
415 sat::SolvableSpec _retractedSpec;
416 sat::SolvableSpec _ptfMasterSpec;
417 sat::SolvableSpec _ptfPackageSpec;
418
421 };
422
423
425 } // namespace detail
428 } // namespace sat
431} // namespace zypp
433#define POOL_SETDIRTY
434#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
bool contains(value_type val_r) const
Return whether the Queue contais at lest one element with value val_r.
Definition Queue.h:58
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:412
CPool * operator->()
Pointer style access forwarded to sat-pool.
Definition PoolImpl.h:69
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
Definition PoolImpl.h:400
bool _snapshotFileProvides
Whether the pool still holds exactly what the snapshot restored, i.e.
Definition PoolImpl.h:385
std::string _snapshotCookie
Experimental pool snapshot (see Pool::mapSnapshot).
Definition PoolImpl.h:378
unsigned & snapshotClaimingRef() const
Nesting level of Pool::ClaimingSnapshotRepos.
Definition PoolImpl.h:92
base::SetTracker< IdStringSet > TrackedLocaleIds
Definition PoolImpl.h:306
CPool * getPool() const
Definition PoolImpl.h:188
sat::SolvableSpec _retractedSpec
Blacklisted specs:
Definition PoolImpl.h:415
scoped_ptr< LocaleSet > _availableLocalesPtr
Definition PoolImpl.h:402
CRepo * systemRepo() const
Definition PoolImpl.h:120
bool isPtfMaster(const Solvable &solv_r) const
Definition PoolImpl.h:362
Pathname rootDir() const
Get rootdir (for file conflicts check).
Definition PoolImpl.h:124
scoped_ptr< MultiversionList > _multiversionListPtr
Definition PoolImpl.h:406
StringQueue autoInstalled() const
Get ident list of all autoinstalled solvables.
Definition PoolImpl.h:328
bool isSystemRepo(CRepo *repo_r) const
Definition PoolImpl.h:117
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:145
CRepo * getRepo(RepoIdType id_r) const
Definition PoolImpl.h:192
void setTextLocale(const Locale &locale_r)
Definition PoolImpl.cc:619
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Definition PoolImpl.cc:644
sat::StringQueue _autoinstalled
Definition PoolImpl.h:409
int _addTesttags(CRepo *repo_r, FILE *file_r)
Adding testtags file to a repo.
Definition PoolImpl.cc:524
unsigned whatProvides(Capability cap_r)
Returns offset into the internal whatprovidesdata array.
Definition PoolImpl.h:254
void multiversionListInit() const
Definition PoolImpl.cc:774
const RepoInfo & repoInfo(RepoIdType id_r)
Definition PoolImpl.h:235
unsigned _snapshotClaiming
>0 while a repo load may still claim snapshot repos, see prepare.
Definition PoolImpl.h:387
bool isPtfPackage(const Solvable &solv_r) const
Definition PoolImpl.h:364
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
Definition PoolImpl.cc:754
bool isRequestedLocale(const Locale &locale_r) const
Definition PoolImpl.h:286
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:395
void _deleteRepo(CRepo *repo_r)
Delete repo repo_r from pool.
Definition PoolImpl.cc:489
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition PoolImpl.cc:673
const LocaleSet & getRequestedLocales() const
Current set of requested Locales.
Definition PoolImpl.h:283
sat::SolvableSpec _ptfMasterSpec
Definition PoolImpl.h:416
void eraseRepoInfo(RepoIdType id_r)
Definition PoolImpl.h:240
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
Definition PoolImpl.cc:685
const sat::detail::IdType whatProvidesData(unsigned offset_r)
Returns the id stored at offset_r in the internal whatprovidesdata array.
Definition PoolImpl.h:248
void rootDir(const Pathname &root_r)
Set rootdir (for file conflicts check).
Definition PoolImpl.h:131
bool validSolvable(SolvableIdType id_r) const
Definition PoolImpl.h:181
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:420
base::SetTracker< LocaleSet > _requestedLocalesTracker
Definition PoolImpl.h:399
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
Definition PoolImpl.cc:653
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
Definition PoolImpl.h:279
std::vector< std::string > _snapshotAliases
Definition PoolImpl.h:380
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Set new Solvable specs.
Definition PoolImpl.h:346
const MultiversionList & multiversionList() const
Definition PoolImpl.cc:800
void snapshotWriteIfNeeded() const
Definition PoolImpl.cc:371
bool isAvailableLocale(const Locale &locale_r) const
Definition PoolImpl.h:299
CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition PoolImpl.cc:480
SerialNumberWatcher _watcher
Watch serial number.
Definition PoolImpl.h:391
bool isNeedreboot(const Solvable &solv_r) const
Whether solv_r matches the spec.
Definition PoolImpl.h:353
bool validSolvable(const CSolvable *slv_r) const
Definition PoolImpl.h:184
sat::detail::IdType parserpmrichdep(const char *capstr_r)
libsolv capability parser
Definition PoolImpl.h:207
SerialNumber _serial
Serial number - changes with each Pool content change.
Definition PoolImpl.h:376
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:812
void _postRepoAdd(CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
Definition PoolImpl.cc:533
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
Definition PoolImpl.h:275
bool mapSnapshot(const Pathname &path_r, const std::string &cookie_r)
Experimental pool snapshot (see Pool::mapSnapshot).
Definition PoolImpl.cc:297
bool isOnSystemByAuto(IdString ident_r) const
Definition PoolImpl.h:338
void setAutoInstalled(const StringQueue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Definition PoolImpl.h:332
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition PoolImpl.cc:662
int _addSolv(CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition PoolImpl.cc:506
int _addHelix(CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition PoolImpl.cc:515
sat::SolvableSpec _ptfPackageSpec
Definition PoolImpl.h:417
bool isRetracted(const Solvable &solv_r) const
Definition PoolImpl.h:360
bool validSolvable(const CSolvable &slv_r) const
a valid Solvable has a non NULL repo pointer.
Definition PoolImpl.h:178
detail::SolvableIdType _addSolvables(CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition PoolImpl.cc:579
std::set< RepoIdType > _snapshotUnclaimed
Snapshot repos not (yet) requested via setRepoInfo; erased in prepare.
Definition PoolImpl.h:382
CSolvable * getSolvable(SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
Definition PoolImpl.h:198
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate its PoolIt...
Definition PoolImpl.h:389
bool isMultiversion(const Solvable &solv_r) const
Definition PoolImpl.cc:807
void prepare() const
Update housekeeping data (e.g.
Definition PoolImpl.cc:398
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition PoolImpl.cc:108
SolvableIdType getNextId(SolvableIdType id_r) const
Get id of the next valid Solvable.
Definition PoolImpl.h:222
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition PoolImpl.h:74
CPool * _pool
sat-pool.
Definition PoolImpl.h:374
SolvableIdType getFirstId() const
Get id of the first valid Solvable.
Definition PoolImpl.h:214
bool isOnSystemByUser(IdString ident_r) const
Definition PoolImpl.h:335
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
Definition PoolImpl.cc:586
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
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
const set_type & current() const
Return the current set.
Definition SetTracker.h:140
const set_type & added() const
Return the set of added items.
Definition SetTracker.h:143
const set_type & removed() const
Return the set of removed items.
Definition SetTracker.h:146
bool contains(const key_type &key_r) const
Whether val_r is in the set.
Definition SetTracker.h:130