libzypp 17.38.7
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-core/base/Hash.h>
31#include <zypp/sat/Queue.h>
32
33#ifndef ZYPPNG
34#include <zypp/RepoInfo.h>
35#endif
36
37#include <zypp/Locale.h>
38#include <zypp/Capability.h>
39#include <zypp/IdString.h>
40
42namespace zypp
43{
45 namespace sat
46 {
47 class SolvableSet;
49 namespace detail
50 {
51
53 //
54 // CLASS NAME : PoolImpl
55 //
58 {
59 public:
61 PoolImpl();
62
64 ~PoolImpl();
65
68 { return _pool; }
69
70 public:
72 const SerialNumber & serial() const
73 { return _serial; }
74
76 const SerialNumber & serialIDs() const
77 { return _serialIDs; }
78
82 void prepare() const;
83
84 private:
88 void setDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
89
92 void localeSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
93
96 void depSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
97
99 static detail::IdType nsCallback( CPool *, void * data, detail::IdType lhs, detail::IdType rhs );
100
101 public:
103 static const std::string & systemRepoAlias();
104
105 bool isSystemRepo( CRepo * repo_r ) const
106 { return repo_r && _pool->installed == repo_r; }
107
109 { return _pool->installed; }
110
113 {
114 const char * rd = ::pool_get_rootdir( _pool );
115 return( rd ? rd : "/" );
116 }
117
119 void rootDir( const Pathname & root_r )
120 {
121 if ( root_r.empty() || root_r == "/" )
122 ::pool_set_rootdir( _pool, nullptr );
123 else
124 ::pool_set_rootdir( _pool, root_r.c_str() );
125 }
126
127 public:
133
134 CRepo * _createRepo( const std::string & name_r );
135
137 void _deleteRepo( CRepo * repo_r );
138
143 int _addSolv( CRepo * repo_r, FILE * file_r );
144
149 int _addHelix( CRepo * repo_r, FILE * file_r );
150
155 int _addTesttags( CRepo * repo_r, FILE * file_r );
156
158 detail::SolvableIdType _addSolvables( CRepo * repo_r, unsigned count_r );
160
162 void _postRepoAdd( CRepo * repo_r );
163
164 public:
166 bool validSolvable( const CSolvable & slv_r ) const
167 { return slv_r.repo; }
168
169 bool validSolvable( SolvableIdType id_r ) const
170 { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); }
171
172 bool validSolvable( const CSolvable * slv_r ) const
173 { return _pool->solvables <= slv_r && slv_r <= _pool->solvables+_pool->nsolvables && validSolvable( *slv_r ); }
174
175 public:
176 CPool * getPool() const
177 { return _pool; }
178
180 CRepo * getRepo( RepoIdType id_r ) const
181 { return id_r; }
182
187 {
188 if ( validSolvable( id_r ) )
189 return &_pool->solvables[id_r];
190 return 0;
191 }
192
193 public:
195 sat::detail::IdType parserpmrichdep( const char * capstr_r )
196 { return ::pool_parserpmrichdep( _pool, capstr_r ); }
197
198 public:
203 { return getNextId( 1 ); }
204
211 {
212 for( ++id_r; id_r < unsigned(_pool->nsolvables); ++id_r )
213 {
214 if ( validSolvable( _pool->solvables[id_r] ) )
215 return id_r;
216 }
217 return noSolvableId;
218 }
219
220#ifndef ZYPPNG
221 public:
224 { return _repoinfos[id_r]; }
225
226 void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r );
229 { _repoinfos.erase( id_r ); }
230#endif
231
232 public:
236 const sat::detail::IdType whatProvidesData( unsigned offset_r )
237 { return _pool->whatprovidesdata[offset_r]; }
238
242 unsigned whatProvides( Capability cap_r )
243 { prepare(); return ::pool_whatprovides( _pool, cap_r.id() ); }
244
245 public:
252
253
254 void setTextLocale( const Locale & locale_r );
255
256
260 void initRequestedLocales( const LocaleSet & locales_r );
261
264 { return _requestedLocalesTracker.added(); }
265
268 { return _requestedLocalesTracker.removed(); }
269
272 { return _requestedLocalesTracker.current(); }
273
274 bool isRequestedLocale( const Locale & locale_r ) const
275 { return _requestedLocalesTracker.contains( locale_r ); }
276
278 void setRequestedLocales( const LocaleSet & locales_r );
280 bool addRequestedLocale( const Locale & locale_r );
282 bool eraseRequestedLocale( const Locale & locale_r );
283
285 const LocaleSet & getAvailableLocales() const;
286
287 bool isAvailableLocale( const Locale & locale_r ) const
288 {
289 const LocaleSet & avl( getAvailableLocales() );
290 LocaleSet::const_iterator it( avl.find( locale_r ) );
291 return it != avl.end();
292 }
293
295
297 const TrackedLocaleIds & trackedLocaleIds() const;
299
300 public:
304
305 const MultiversionList & multiversionList() const;
306
307 bool isMultiversion( const Solvable & solv_r ) const;
308
311
312 public:
315
317 { return _autoinstalled; }
318
320 void setAutoInstalled( const StringQueue & autoInstalled_r )
321 { _autoinstalled = autoInstalled_r; }
322
323 bool isOnSystemByUser( IdString ident_r ) const
324 { return !_autoinstalled.contains( ident_r.id() ); }
325
326 bool isOnSystemByAuto( IdString ident_r ) const
327 { return _autoinstalled.contains( ident_r.id() ); }
328
329
330 public:
333
334 void setNeedrebootSpec( sat::SolvableSpec needrebootSpec_r )
335 {
336 _needrebootSpec = std::move(needrebootSpec_r);
337 _needrebootSpec.setDirty();
338 }
339
341 bool isNeedreboot( const Solvable & solv_r ) const
342 { return _needrebootSpec.contains( solv_r ); }
343
344
345 public:
348 bool isRetracted( const Solvable & solv_r ) const
349 { return _retractedSpec.contains( solv_r ); }
350 bool isPtfMaster( const Solvable & solv_r ) const
351 { return _ptfMasterSpec.contains( solv_r ); }
352 bool isPtfPackage( const Solvable & solv_r ) const
353 { return _ptfPackageSpec.contains( solv_r ); }
354
355
356 public:
358 const std::set<std::string> & requiredFilesystems() const;
359
360 private:
369
370#ifndef ZYPPNG
372 std::map<RepoIdType,RepoInfo> _repoinfos;
373#endif
374
378
380
382 void multiversionListInit() const;
384
387
389 sat::SolvableSpec _needrebootSpec;
390
392 sat::SolvableSpec _retractedSpec;
393 sat::SolvableSpec _ptfMasterSpec;
394 sat::SolvableSpec _ptfPackageSpec;
395
398 };
399
400
402 } // namespace detail
405 } // namespace sat
408} // namespace zypp
410#define POOL_SETDIRTY
411#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:389
CPool * operator->()
Pointer style access forwarded to sat-pool.
Definition PoolImpl.h:67
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
Definition PoolImpl.h:377
base::SetTracker< IdStringSet > TrackedLocaleIds
Definition PoolImpl.h:294
CPool * getPool() const
Definition PoolImpl.h:176
sat::SolvableSpec _retractedSpec
Blacklisted specs:
Definition PoolImpl.h:392
scoped_ptr< LocaleSet > _availableLocalesPtr
Definition PoolImpl.h:379
CRepo * systemRepo() const
Definition PoolImpl.h:108
bool isPtfMaster(const Solvable &solv_r) const
Definition PoolImpl.h:350
Pathname rootDir() const
Get rootdir (for file conflicts check).
Definition PoolImpl.h:112
scoped_ptr< MultiversionList > _multiversionListPtr
Definition PoolImpl.h:383
StringQueue autoInstalled() const
Get ident list of all autoinstalled solvables.
Definition PoolImpl.h:316
bool isSystemRepo(CRepo *repo_r) const
Definition PoolImpl.h:105
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:139
CRepo * getRepo(RepoIdType id_r) const
Definition PoolImpl.h:180
void setTextLocale(const Locale &locale_r)
Definition PoolImpl.cc:448
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Definition PoolImpl.cc:473
sat::StringQueue _autoinstalled
Definition PoolImpl.h:386
int _addTesttags(CRepo *repo_r, FILE *file_r)
Adding testtags file to a repo.
Definition PoolImpl.cc:357
unsigned whatProvides(Capability cap_r)
Returns offset into the internal whatprovidesdata array.
Definition PoolImpl.h:242
void multiversionListInit() const
Definition PoolImpl.cc:603
const RepoInfo & repoInfo(RepoIdType id_r)
Definition PoolImpl.h:223
bool isPtfPackage(const Solvable &solv_r) const
Definition PoolImpl.h:352
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
Definition PoolImpl.cc:583
bool isRequestedLocale(const Locale &locale_r) const
Definition PoolImpl.h:274
const SerialNumber & serialIDs() const
Serial number changing whenever resusePoolIDs==true was used.
Definition PoolImpl.h:76
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
Definition PoolImpl.h:372
void _deleteRepo(CRepo *repo_r)
Delete repo repo_r from pool.
Definition PoolImpl.cc:323
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition PoolImpl.cc:502
const LocaleSet & getRequestedLocales() const
Current set of requested Locales.
Definition PoolImpl.h:271
sat::SolvableSpec _ptfMasterSpec
Definition PoolImpl.h:393
void eraseRepoInfo(RepoIdType id_r)
Definition PoolImpl.h:228
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
Definition PoolImpl.cc:514
const sat::detail::IdType whatProvidesData(unsigned offset_r)
Returns the id stored at offset_r in the internal whatprovidesdata array.
Definition PoolImpl.h:236
void rootDir(const Pathname &root_r)
Set rootdir (for file conflicts check).
Definition PoolImpl.h:119
bool validSolvable(SolvableIdType id_r) const
Definition PoolImpl.h:169
void localeSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate locale related housekeeping data.
Definition PoolImpl.cc:260
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
Definition PoolImpl.h:397
base::SetTracker< LocaleSet > _requestedLocalesTracker
Definition PoolImpl.h:376
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
Definition PoolImpl.cc:482
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
Definition PoolImpl.h:267
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Set new Solvable specs.
Definition PoolImpl.h:334
const MultiversionList & multiversionList() const
Definition PoolImpl.cc:629
bool isAvailableLocale(const Locale &locale_r) const
Definition PoolImpl.h:287
CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition PoolImpl.cc:314
SerialNumberWatcher _watcher
Watch serial number.
Definition PoolImpl.h:368
bool isNeedreboot(const Solvable &solv_r) const
Whether solv_r matches the spec.
Definition PoolImpl.h:341
bool validSolvable(const CSolvable *slv_r) const
Definition PoolImpl.h:172
sat::detail::IdType parserpmrichdep(const char *capstr_r)
libsolv capability parser
Definition PoolImpl.h:195
SerialNumber _serial
Serial number - changes with each Pool content change.
Definition PoolImpl.h:364
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
Definition PoolImpl.cc:641
void _postRepoAdd(CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
Definition PoolImpl.cc:366
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
Definition PoolImpl.h:263
bool isOnSystemByAuto(IdString ident_r) const
Definition PoolImpl.h:326
void setAutoInstalled(const StringQueue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Definition PoolImpl.h:320
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition PoolImpl.cc:491
int _addSolv(CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition PoolImpl.cc:339
int _addHelix(CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition PoolImpl.cc:348
sat::SolvableSpec _ptfPackageSpec
Definition PoolImpl.h:394
bool isRetracted(const Solvable &solv_r) const
Definition PoolImpl.h:348
bool validSolvable(const CSolvable &slv_r) const
a valid Solvable has a non NULL repo pointer.
Definition PoolImpl.h:166
detail::SolvableIdType _addSolvables(CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition PoolImpl.cc:410
CSolvable * getSolvable(SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
Definition PoolImpl.h:186
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate its PoolIt...
Definition PoolImpl.h:366
bool isMultiversion(const Solvable &solv_r) const
Definition PoolImpl.cc:636
void prepare() const
Update housekeeping data (e.g.
Definition PoolImpl.cc:283
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition PoolImpl.cc:102
SolvableIdType getNextId(SolvableIdType id_r) const
Get id of the next valid Solvable.
Definition PoolImpl.h:210
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition PoolImpl.h:72
CPool * _pool
sat-pool.
Definition PoolImpl.h:362
SolvableIdType getFirstId() const
Get id of the first valid Solvable.
Definition PoolImpl.h:202
bool isOnSystemByUser(IdString ident_r) const
Definition PoolImpl.h:323
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
Definition PoolImpl.cc:416
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition PoolImpl.cc:272
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:63
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition PoolDefines.h:36
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
int IdType
Generic Id type.
Definition PoolDefines.h:42
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
Definition PoolDefines.h:37
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition PoolDefines.h:34
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
Definition PoolDefines.h:71
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