libzypp 17.28.8
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}
22#include <iosfwd>
23
24#include <zypp/base/Hash.h>
25#include <zypp/base/NonCopyable.h>
30#include <zypp/sat/Queue.h>
31#include <zypp/RepoInfo.h>
32#include <zypp/Locale.h>
33#include <zypp/Capability.h>
34#include <zypp/IdString.h>
35
37namespace zypp
38{
40 namespace sat
41 {
42 class SolvableSet;
44 namespace detail
45 {
46
48 //
49 // CLASS NAME : PoolImpl
50 //
53 {
54 public:
56 PoolImpl();
57
59 ~PoolImpl();
60
63 { return _pool; }
64
65 public:
67 const SerialNumber & serial() const
68 { return _serial; }
69
71 const SerialNumber & serialIDs() const
72 { return _serialIDs; }
73
77 void prepare() const;
78
79 private:
83 void setDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
84
87 void localeSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
88
91 void depSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
92
94 static detail::IdType nsCallback( CPool *, void * data, detail::IdType lhs, detail::IdType rhs );
95
96 public:
98 static const std::string & systemRepoAlias();
99
100 bool isSystemRepo( CRepo * repo_r ) const
101 { return repo_r && _pool->installed == repo_r; }
102
104 { return _pool->installed; }
105
108 {
109 const char * rd = ::pool_get_rootdir( _pool );
110 return( rd ? rd : "/" );
111 }
112
114 void rootDir( const Pathname & root_r )
115 {
116 if ( root_r.empty() || root_r == "/" )
117 ::pool_set_rootdir( _pool, nullptr );
118 else
119 ::pool_set_rootdir( _pool, root_r.c_str() );
120 }
121
122 public:
129 CRepo * _createRepo( const std::string & name_r );
130
132 void _deleteRepo( CRepo * repo_r );
133
138 int _addSolv( CRepo * repo_r, FILE * file_r );
139
144 int _addHelix( CRepo * repo_r, FILE * file_r );
145
150 int _addTesttags( CRepo * repo_r, FILE * file_r );
151
153 detail::SolvableIdType _addSolvables( CRepo * repo_r, unsigned count_r );
155
157 void _postRepoAdd( CRepo * repo_r );
158
159 public:
161 bool validSolvable( const CSolvable & slv_r ) const
162 { return slv_r.repo; }
164 bool validSolvable( SolvableIdType id_r ) const
165 { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); }
167 bool validSolvable( const CSolvable * slv_r ) const
168 { return _pool->solvables <= slv_r && slv_r <= _pool->solvables+_pool->nsolvables && validSolvable( *slv_r ); }
169
170 public:
171 CPool * getPool() const
172 { return _pool; }
173
175 CRepo * getRepo( RepoIdType id_r ) const
176 { return id_r; }
177
182 {
183 if ( validSolvable( id_r ) )
184 return &_pool->solvables[id_r];
185 return 0;
186 }
187
188 public:
193 { return getNextId( 1 ); }
194
201 {
202 for( ++id_r; id_r < unsigned(_pool->nsolvables); ++id_r )
203 {
204 if ( validSolvable( _pool->solvables[id_r] ) )
205 return id_r;
206 }
207 return noSolvableId;
208 }
209
210 public:
213 { return _repoinfos[id_r]; }
215 void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r );
218 { _repoinfos.erase( id_r ); }
219
220 public:
224 const sat::detail::IdType whatProvidesData( unsigned offset_r )
225 { return _pool->whatprovidesdata[offset_r]; }
226
230 unsigned whatProvides( Capability cap_r )
231 { prepare(); return ::pool_whatprovides( _pool, cap_r.id() ); }
232
233 public:
240
241
242 void setTextLocale( const Locale & locale_r );
243
244
248 void initRequestedLocales( const LocaleSet & locales_r );
249
252 { return _requestedLocalesTracker.added(); }
253
256 { return _requestedLocalesTracker.removed(); }
257
260 { return _requestedLocalesTracker.current(); }
261
262 bool isRequestedLocale( const Locale & locale_r ) const
263 { return _requestedLocalesTracker.contains( locale_r ); }
264
266 void setRequestedLocales( const LocaleSet & locales_r );
268 bool addRequestedLocale( const Locale & locale_r );
270 bool eraseRequestedLocale( const Locale & locale_r );
271
273 const LocaleSet & getAvailableLocales() const;
274
275 bool isAvailableLocale( const Locale & locale_r ) const
276 {
277 const LocaleSet & avl( getAvailableLocales() );
278 LocaleSet::const_iterator it( avl.find( locale_r ) );
279 return it != avl.end();
280 }
281
283
285 const TrackedLocaleIds & trackedLocaleIds() const;
287
288 public:
292
293 const MultiversionList & multiversionList() const;
294
295 bool isMultiversion( const Solvable & solv_r ) const;
296
299
300 public:
305 { return _autoinstalled; }
306
308 void setAutoInstalled( const StringQueue & autoInstalled_r )
309 { _autoinstalled = autoInstalled_r; }
310
311 bool isOnSystemByUser( IdString ident_r ) const
312 { return !_autoinstalled.contains( ident_r.id() ); }
313
314 bool isOnSystemByAuto( IdString ident_r ) const
315 { return _autoinstalled.contains( ident_r.id() ); }
317
318 public:
322 void setNeedrebootSpec( sat::SolvableSpec needrebootSpec_r )
323 {
324 _needrebootSpec = std::move(needrebootSpec_r);
326 }
327
329 bool isNeedreboot( const Solvable & solv_r ) const
330 { return _needrebootSpec.contains( solv_r ); }
332
333 public:
336 bool isRetracted( const Solvable & solv_r ) const
337 { return _retractedSpec.contains( solv_r ); }
338 bool isPtfMaster( const Solvable & solv_r ) const
339 { return _ptfMasterSpec.contains( solv_r ); }
340 bool isPtfPackage( const Solvable & solv_r ) const
341 { return _ptfPackageSpec.contains( solv_r ); }
343
344 public:
346 const std::set<std::string> & requiredFilesystems() const;
347
348 private:
358 std::map<RepoIdType,RepoInfo> _repoinfos;
359
362 mutable scoped_ptr<TrackedLocaleIds> _trackedLocaleIdsPtr;
363
364 mutable scoped_ptr<LocaleSet> _availableLocalesPtr;
365
367 void multiversionListInit() const;
368 mutable scoped_ptr<MultiversionList> _multiversionListPtr;
369
372
375
380
382 mutable scoped_ptr<std::set<std::string> > _requiredFilesystemsPtr;
383 };
385
387 } // namespace detail
390 } // namespace sat
393} // namespace zypp
395#define POOL_SETDIRTY
396#endif // ZYPP_SAT_DETAIL_POOLIMPL_H
A sat capability.
Definition: Capability.h:60
sat::detail::IdType id() const
Expert backdoor.
Definition: Capability.h:253
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:374
CPool * operator->()
Pointer style access forwarded to sat-pool.
Definition: PoolImpl.h:62
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
Definition: PoolImpl.h:362
base::SetTracker< IdStringSet > TrackedLocaleIds
Definition: PoolImpl.h:282
CPool * getPool() const
Definition: PoolImpl.h:171
sat::SolvableSpec _retractedSpec
Blacklisted specs:
Definition: PoolImpl.h:377
scoped_ptr< LocaleSet > _availableLocalesPtr
Definition: PoolImpl.h:364
CRepo * systemRepo() const
Definition: PoolImpl.h:103
bool isPtfMaster(const Solvable &solv_r) const
Definition: PoolImpl.h:338
Pathname rootDir() const
Get rootdir (for file conflicts check)
Definition: PoolImpl.h:107
scoped_ptr< MultiversionList > _multiversionListPtr
Definition: PoolImpl.h:368
StringQueue autoInstalled() const
Get ident list of all autoinstalled solvables.
Definition: PoolImpl.h:304
bool isSystemRepo(CRepo *repo_r) const
Definition: PoolImpl.h:100
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:131
CRepo * getRepo(RepoIdType id_r) const
Definition: PoolImpl.h:175
void setTextLocale(const Locale &locale_r)
Definition: PoolImpl.cc:456
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Definition: PoolImpl.cc:481
sat::StringQueue _autoinstalled
Definition: PoolImpl.h:371
int _addTesttags(CRepo *repo_r, FILE *file_r)
Adding testtags file to a repo.
Definition: PoolImpl.cc:365
unsigned whatProvides(Capability cap_r)
Returns offset into the internal whatprovidesdata array.
Definition: PoolImpl.h:230
void multiversionListInit() const
Definition: PoolImpl.cc:613
const RepoInfo & repoInfo(RepoIdType id_r)
Definition: PoolImpl.h:212
bool isPtfPackage(const Solvable &solv_r) const
Definition: PoolImpl.h:340
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
Definition: PoolImpl.cc:593
bool isRequestedLocale(const Locale &locale_r) const
Definition: PoolImpl.h:262
const SerialNumber & serialIDs() const
Serial number changing whenever resusePoolIDs==true was used.
Definition: PoolImpl.h:71
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
Definition: PoolImpl.h:358
void _deleteRepo(CRepo *repo_r)
Delete repo repo_r from pool.
Definition: PoolImpl.cc:331
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition: PoolImpl.cc:510
const LocaleSet & getRequestedLocales() const
Current set of requested Locales.
Definition: PoolImpl.h:259
sat::SolvableSpec _ptfMasterSpec
Definition: PoolImpl.h:378
void eraseRepoInfo(RepoIdType id_r)
Definition: PoolImpl.h:217
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
Definition: PoolImpl.cc:522
const sat::detail::IdType whatProvidesData(unsigned offset_r)
Returns the id stored at offset_r in the internal whatprovidesdata array.
Definition: PoolImpl.h:224
void rootDir(const Pathname &root_r)
Set rootdir (for file conflicts check)
Definition: PoolImpl.h:114
bool validSolvable(SolvableIdType id_r) const
Definition: PoolImpl.h:164
void localeSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate locale related housekeeping data.
Definition: PoolImpl.cc:268
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
Definition: PoolImpl.h:382
base::SetTracker< LocaleSet > _requestedLocalesTracker
Definition: PoolImpl.h:361
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
Definition: PoolImpl.cc:490
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
Definition: PoolImpl.h:255
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Set new Solvable specs.
Definition: PoolImpl.h:322
const MultiversionList & multiversionList() const
Definition: PoolImpl.cc:639
bool isAvailableLocale(const Locale &locale_r) const
Definition: PoolImpl.h:275
CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition: PoolImpl.cc:322
SerialNumberWatcher _watcher
Watch serial number.
Definition: PoolImpl.h:356
bool isNeedreboot(const Solvable &solv_r) const
Whether solv_r matches the spec.
Definition: PoolImpl.h:329
bool validSolvable(const CSolvable *slv_r) const
Definition: PoolImpl.h:167
SerialNumber _serial
Serial number - changes with each Pool content change.
Definition: PoolImpl.h:352
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
Definition: PoolImpl.cc:651
void _postRepoAdd(CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
Definition: PoolImpl.cc:374
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
Definition: PoolImpl.h:251
bool isOnSystemByAuto(IdString ident_r) const
Definition: PoolImpl.h:314
void setAutoInstalled(const StringQueue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Definition: PoolImpl.h:308
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition: PoolImpl.cc:499
int _addSolv(CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition: PoolImpl.cc:347
SolvableSet MultiversionList
Definition: PoolImpl.h:291
int _addHelix(CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition: PoolImpl.cc:356
sat::SolvableSpec _ptfPackageSpec
Definition: PoolImpl.h:379
bool isRetracted(const Solvable &solv_r) const
Definition: PoolImpl.h:336
bool validSolvable(const CSolvable &slv_r) const
a valid Solvable has a non NULL repo pointer.
Definition: PoolImpl.h:161
detail::SolvableIdType _addSolvables(CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition: PoolImpl.cc:418
CSolvable * getSolvable(SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
Definition: PoolImpl.h:181
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate it's PoolI...
Definition: PoolImpl.h:354
bool isMultiversion(const Solvable &solv_r) const
Definition: PoolImpl.cc:646
void prepare() const
Update housekeeping data (e.g.
Definition: PoolImpl.cc:291
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition: PoolImpl.cc:96
SolvableIdType getNextId(SolvableIdType id_r) const
Get id of the next valid Solvable.
Definition: PoolImpl.h:200
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition: PoolImpl.h:67
CPool * _pool
sat-pool.
Definition: PoolImpl.h:350
SolvableIdType getFirstId() const
Get id of the first valid Solvable.
Definition: PoolImpl.h:192
bool isOnSystemByUser(IdString ident_r) const
Definition: PoolImpl.h:311
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
Definition: PoolImpl.cc:424
void setDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:241
PoolImpl()
Default ctor.
Definition: PoolImpl.cc:189
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:280
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
typedef::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:63
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
int IdType
Generic Id type.
Definition: PoolMember.h:104
typedef::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
typedef::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:64
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
Track added/removed set items based on an initial set.
Definition: SetTracker.h:38