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
14 extern "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>
27 #include <zypp/base/SerialNumber.h>
28 #include <zypp/base/SetTracker.h>
30 #include <zypp/sat/SolvableSpec.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 
42 namespace zypp
43 {
44  namespace sat
46  {
47  class SolvableSet;
49  namespace detail
50  {
51 
53  //
54  // CLASS NAME : PoolImpl
55  //
57  class PoolImpl : private base::NonCopyable
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 
108  CRepo * systemRepo() const
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:
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; }
169  bool validSolvable( SolvableIdType id_r ) const
170  { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); }
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:
223  const RepoInfo & repoInfo( RepoIdType id_r )
224  { return _repoinfos[id_r]; }
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:
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() ); }
329 
330  public:
334  void setNeedrebootSpec( sat::SolvableSpec needrebootSpec_r )
335  {
336  _needrebootSpec = std::move(needrebootSpec_r);
338  }
339 
341  bool isNeedreboot( const Solvable & solv_r ) const
342  { return _needrebootSpec.contains( solv_r ); }
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 ); }
355 
356  public:
358  const std::set<std::string> & requiredFilesystems() const;
359 
360  private:
369 
370 #ifndef ZYPPNG
371 
372  std::map<RepoIdType,RepoInfo> _repoinfos;
373 #endif
374 
377  mutable scoped_ptr<TrackedLocaleIds> _trackedLocaleIdsPtr;
378 
379  mutable scoped_ptr<LocaleSet> _availableLocalesPtr;
380 
382  void multiversionListInit() const;
383  mutable scoped_ptr<MultiversionList> _multiversionListPtr;
384 
387 
390 
395 
397  mutable scoped_ptr<std::set<std::string> > _requiredFilesystemsPtr;
398  };
400 
402  } // namespace detail
405  } // namespace sat
408 } // namespace zypp
410 #define POOL_SETDIRTY
411 #endif // ZYPP_SAT_DETAIL_POOLIMPL_H
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
bool contains(const key_type &key_r) const
Whether val_r is in the set.
Definition: SetTracker.h:130
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition: PoolImpl.h:72
Simple serial number watcher.
Definition: SerialNumber.h:122
SolvableSet MultiversionList
Definition: PoolImpl.h:303
A Solvable object within the sat Pool.
Definition: Solvable.h:53
StringQueue autoInstalled() const
Get ident list of all autoinstalled solvables.
Definition: PoolImpl.h:316
const sat::detail::IdType whatProvidesData(unsigned offset_r)
Returns the id stored at offset_r in the internal whatprovidesdata array.
Definition: PoolImpl.h:236
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition: PoolImpl.cc:502
scoped_ptr< LocaleSet > _availableLocalesPtr
Definition: PoolImpl.h:379
Track added/removed set items based on an initial set.
Definition: SetTracker.h:38
bool isRequestedLocale(const Locale &locale_r) const
Definition: PoolImpl.h:274
void multiversionListInit() const
Definition: PoolImpl.cc:603
int _addSolv(CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition: PoolImpl.cc:339
base::SetTracker< LocaleSet > _requestedLocalesTracker
Definition: PoolImpl.h:376
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition: PoolImpl.cc:491
void setDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:233
unsigned whatProvides(Capability cap_r)
Returns offset into the internal whatprovidesdata array.
Definition: PoolImpl.h:242
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolDefines.h:36
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
Definition: PoolImpl.cc:641
const MultiversionList & multiversionList() const
Definition: PoolImpl.cc:629
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
Definition: PoolImpl.h:263
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:29
void _deleteRepo(CRepo *repo_r)
Delete repo repo_r from pool.
Definition: PoolImpl.cc:323
int _addTesttags(CRepo *repo_r, FILE *file_r)
Adding testtags file to a repo.
Definition: PoolImpl.cc:357
IdType id() const
Expert backdoor.
Definition: IdString.h:144
bool isOnSystemByAuto(IdString ident_r) const
Definition: PoolImpl.h:326
const char * c_str() const
String representation.
Definition: Pathname.h:113
void rootDir(const Pathname &root_r)
Set rootdir (for file conflicts check)
Definition: PoolImpl.h:119
void eraseRepoInfo(RepoIdType id_r)
Definition: PoolImpl.h:228
int IdType
Generic Id type.
Definition: PoolDefines.h:42
What is known about a repository.
Definition: RepoInfo.h:71
CRepo * systemRepo() const
Definition: PoolImpl.h:108
Access to the sat-pools string space.
Definition: IdString.h:51
detail::SolvableIdType _addSolvables(CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition: PoolImpl.cc:410
void localeSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate locale related housekeeping data.
Definition: PoolImpl.cc:260
bool isPtfMaster(const Solvable &solv_r) const
Definition: PoolImpl.h:350
sat::SolvableSpec _retractedSpec
Blacklisted specs:
Definition: PoolImpl.h:392
CRepo * getRepo(RepoIdType id_r) const
Definition: PoolImpl.h:180
const set_type & removed() const
Return the set of removed items.
Definition: SetTracker.h:146
Define a set of Solvables by ident and provides.
Definition: SolvableSpec.h:44
bool validSolvable(const CSolvable &slv_r) const
a valid Solvable has a non NULL repo pointer.
Definition: PoolImpl.h:166
sat::detail::IdType id() const
Expert backdoor.
Definition: Capability.h:289
bool isSystemRepo(CRepo *repo_r) const
Definition: PoolImpl.h:105
PoolImpl()
Default ctor.
Definition: PoolImpl.cc:186
bool empty() const
Test for an empty path.
Definition: Pathname.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:139
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolDefines.h:37
const SerialNumber & serialIDs() const
Serial number changing whenever resusePoolIDs==true was used.
Definition: PoolImpl.h:76
const LocaleSet & getRequestedLocales() const
Current set of requested Locales.
Definition: PoolImpl.h:271
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
Definition: PoolImpl.cc:416
CPool * getPool() const
Definition: PoolImpl.h:176
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
Definition: PoolImpl.cc:514
void setDirty() const
Explicitly flag the cache as dirty, so it will be rebuilt on the next request.
SerialNumberWatcher _watcher
Watch serial number.
Definition: PoolImpl.h:368
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
Definition: PoolImpl.cc:482
const set_type & current() const
Return the current set.
Definition: SetTracker.h:140
bool isNeedreboot(const Solvable &solv_r) const
Whether solv_r matches the spec.
Definition: PoolImpl.h:341
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Set new Solvable specs.
Definition: PoolImpl.h:334
bool validSolvable(SolvableIdType id_r) const
Definition: PoolImpl.h:169
sat::StringQueue _autoinstalled
Definition: PoolImpl.h:386
const set_type & added() const
Return the set of added items.
Definition: SetTracker.h:143
bool contains(const sat::Solvable &solv_r) const
Test whether solv_r matches the spec.
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
Definition: PoolImpl.h:267
base::SetTracker< IdStringSet > TrackedLocaleIds
Definition: PoolImpl.h:294
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate its PoolIt...
Definition: PoolImpl.h:366
SolvableIdType getNextId(SolvableIdType id_r) const
Get id of the next valid Solvable.
Definition: PoolImpl.h:210
void prepare() const
Update housekeeping data (e.g.
Definition: PoolImpl.cc:283
bool validSolvable(const CSolvable *slv_r) const
Definition: PoolImpl.h:172
Simple serial number provider.
Definition: SerialNumber.h:44
bool isMultiversion(const Solvable &solv_r) const
Definition: PoolImpl.cc:636
&#39;Language[_Country]&#39; codes.
Definition: Locale.h:50
void _postRepoAdd(CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
Definition: PoolImpl.cc:366
SerialNumber _serial
Serial number - changes with each Pool content change.
Definition: PoolImpl.h:364
Pathname rootDir() const
Get rootdir (for file conflicts check)
Definition: PoolImpl.h:112
scoped_ptr< MultiversionList > _multiversionListPtr
Definition: PoolImpl.h:383
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:58
sat::SolvableSpec _ptfPackageSpec
Definition: PoolImpl.h:394
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolDefines.h:71
bool isOnSystemByUser(IdString ident_r) const
Definition: PoolImpl.h:323
bool isRetracted(const Solvable &solv_r) const
Definition: PoolImpl.h:348
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:272
constexpr std::string_view FILE("file")
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
Definition: PoolImpl.h:397
void setTextLocale(const Locale &locale_r)
Definition: PoolImpl.cc:448
bool isPtfPackage(const Solvable &solv_r) const
Definition: PoolImpl.h:352
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
Definition: PoolImpl.h:372
A sat capability.
Definition: Capability.h:62
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolDefines.h:34
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Definition: PoolImpl.cc:473
static const std::string & systemRepoAlias()
Reserved system repository alias .
Definition: PoolImpl.cc:102
CPool * _pool
sat-pool.
Definition: PoolImpl.h:362
CSolvable * getSolvable(SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
Definition: PoolImpl.h:186
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
Definition: PoolImpl.cc:583
unsigned int SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolDefines.h:63
CPool * operator->()
Pointer style access forwarded to sat-pool.
Definition: PoolImpl.h:67
sat::detail::IdType parserpmrichdep(const char *capstr_r)
libsolv capability parser
Definition: PoolImpl.h:195
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
Definition: PoolImpl.h:377
sat::SolvableSpec _ptfMasterSpec
Definition: PoolImpl.h:393
const RepoInfo & repoInfo(RepoIdType id_r)
Definition: PoolImpl.h:223
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
bool isAvailableLocale(const Locale &locale_r) const
Definition: PoolImpl.h:287
int _addHelix(CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition: PoolImpl.cc:348
CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition: PoolImpl.cc:314
sat::SolvableSpec _needrebootSpec
Solvables which should trigger the reboot-needed hint if installed/updated.
Definition: PoolImpl.h:389
SolvableIdType getFirstId() const
Get id of the first valid Solvable.
Definition: PoolImpl.h:202
void setAutoInstalled(const StringQueue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Definition: PoolImpl.h:320
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
Solvable set wrapper to allow adding additional convenience iterators.
Definition: SolvableSet.h:35