libzypp  17.23.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
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 }
22 #include <iosfwd>
23 
24 #include <zypp/base/Hash.h>
25 #include <zypp/base/NonCopyable.h>
26 #include <zypp/base/SerialNumber.h>
27 #include <zypp/base/SetTracker.h>
29 #include <zypp/sat/SolvableSpec.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 
37 namespace zypp
38 {
39  namespace sat
41  {
42  class SolvableSet;
44  namespace detail
45  {
46 
48  //
49  // CLASS NAME : PoolImpl
50  //
52  class PoolImpl : private base::NonCopyable
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 
103  CRepo * systemRepo() const
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 
147  detail::SolvableIdType _addSolvables( CRepo * repo_r, unsigned count_r );
149 
151  void _postRepoAdd( CRepo * repo_r );
152 
153  public:
155  bool validSolvable( const CSolvable & slv_r ) const
156  { return slv_r.repo; }
158  bool validSolvable( SolvableIdType id_r ) const
159  { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); }
161  bool validSolvable( const CSolvable * slv_r ) const
162  { return _pool->solvables <= slv_r && slv_r <= _pool->solvables+_pool->nsolvables && validSolvable( *slv_r ); }
163 
164  public:
165  CPool * getPool() const
166  { return _pool; }
167 
169  CRepo * getRepo( RepoIdType id_r ) const
170  { return id_r; }
171 
176  {
177  if ( validSolvable( id_r ) )
178  return &_pool->solvables[id_r];
179  return 0;
180  }
181 
182  public:
187  { return getNextId( 1 ); }
188 
195  {
196  for( ++id_r; id_r < unsigned(_pool->nsolvables); ++id_r )
197  {
198  if ( validSolvable( _pool->solvables[id_r] ) )
199  return id_r;
200  }
201  return noSolvableId;
202  }
203 
204  public:
206  const RepoInfo & repoInfo( RepoIdType id_r )
207  { return _repoinfos[id_r]; }
209  void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r );
212  { _repoinfos.erase( id_r ); }
213 
214  public:
218  const sat::detail::IdType whatProvidesData( unsigned offset_r )
219  { return _pool->whatprovidesdata[offset_r]; }
220 
224  unsigned whatProvides( Capability cap_r )
225  { prepare(); return ::pool_whatprovides( _pool, cap_r.id() ); }
226 
227  public:
234 
235 
236  void setTextLocale( const Locale & locale_r );
237 
238 
242  void initRequestedLocales( const LocaleSet & locales_r );
243 
246  { return _requestedLocalesTracker.added(); }
247 
250  { return _requestedLocalesTracker.removed(); }
251 
254  { return _requestedLocalesTracker.current(); }
255 
256  bool isRequestedLocale( const Locale & locale_r ) const
257  { return _requestedLocalesTracker.contains( locale_r ); }
258 
260  void setRequestedLocales( const LocaleSet & locales_r );
262  bool addRequestedLocale( const Locale & locale_r );
264  bool eraseRequestedLocale( const Locale & locale_r );
265 
267  const LocaleSet & getAvailableLocales() const;
268 
269  bool isAvailableLocale( const Locale & locale_r ) const
270  {
271  const LocaleSet & avl( getAvailableLocales() );
272  LocaleSet::const_iterator it( avl.find( locale_r ) );
273  return it != avl.end();
274  }
275 
277 
279  const TrackedLocaleIds & trackedLocaleIds() const;
281 
282  public:
286 
287  const MultiversionList & multiversionList() const;
288 
289  bool isMultiversion( const Solvable & solv_r ) const;
290 
293 
294  public:
299  { return _autoinstalled; }
300 
302  void setAutoInstalled( const StringQueue & autoInstalled_r )
303  { _autoinstalled = autoInstalled_r; }
304 
305  bool isOnSystemByUser( IdString ident_r ) const
306  { return !_autoinstalled.contains( ident_r.id() ); }
307 
308  bool isOnSystemByAuto( IdString ident_r ) const
309  { return _autoinstalled.contains( ident_r.id() ); }
311 
312  public:
316  void setNeedrebootSpec( sat::SolvableSpec needrebootSpec_r )
317  {
318  _needrebootSpec = std::move(needrebootSpec_r);
320  }
321 
323  bool isNeedreboot( const Solvable & solv_r ) const
324  { return _needrebootSpec.contains( solv_r ); }
326 
327  public:
329  const std::set<std::string> & requiredFilesystems() const;
330 
331  private:
341  std::map<RepoIdType,RepoInfo> _repoinfos;
342 
345  mutable scoped_ptr<TrackedLocaleIds> _trackedLocaleIdsPtr;
346 
347  mutable scoped_ptr<LocaleSet> _availableLocalesPtr;
348 
350  void multiversionListInit() const;
351  mutable scoped_ptr<MultiversionList> _multiversionListPtr;
352 
355 
358 
360  mutable scoped_ptr<std::set<std::string> > _requiredFilesystemsPtr;
361  };
363 
365  } // namespace detail
368  } // namespace sat
371 } // namespace zypp
373 #define POOL_SETDIRTY
374 #endif // ZYPP_SAT_DETAIL_POOLIMPL_H
zypp::sat::detail::PoolImpl::isAvailableLocale
bool isAvailableLocale(const Locale &locale_r) const
Definition: PoolImpl.h:269
zypp::Capability::id
sat::detail::IdType id() const
Expert backdoor.
Definition: Capability.h:253
zypp::sat::detail::PoolImpl::_autoinstalled
sat::StringQueue _autoinstalled
Definition: PoolImpl.h:354
zypp::sat::detail::PoolImpl::multiversionSpecChanged
void multiversionSpecChanged()
Definition: PoolImpl.cc:607
zypp::sat::detail::PoolImpl::isOnSystemByUser
bool isOnSystemByUser(IdString ident_r) const
Definition: PoolImpl.h:305
zypp::sat::detail::PoolImpl::getFirstId
SolvableIdType getFirstId() const
Get id of the first valid Solvable.
Definition: PoolImpl.h:186
zypp::sat::detail::PoolImpl::setDirty
void setDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:232
zypp::sat::detail::PoolImpl::systemRepoAlias
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition: PoolImpl.cc:94
zypp::sat::SolvableSet
Solvable set wrapper to allow adding additional convenience iterators.
Definition: SolvableSet.h:35
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition: Solvable.h:53
zypp::sat::detail::PoolImpl::operator->
CPool * operator->()
Pointer style access forwarded to sat-pool.
Definition: PoolImpl.h:62
zypp::sat::detail::PoolImpl::PoolImpl
PoolImpl()
Default ctor.
Definition: PoolImpl.cc:187
zypp::sat::detail::PoolImpl::validSolvable
bool validSolvable(const CSolvable *slv_r) const
Definition: PoolImpl.h:161
zypp::sat::detail::PoolImpl::TrackedLocaleIds
base::SetTracker< IdStringSet > TrackedLocaleIds
Definition: PoolImpl.h:276
SetTracker.h
zypp::sat::detail::PoolImpl::rootDir
void rootDir(const Pathname &root_r)
Set rootdir (for file conflicts check)
Definition: PoolImpl.h:114
zypp::RepoInfo
What is known about a repository.
Definition: RepoInfo.h:71
zypp::sat::detail::CPool
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:61
zypp::sat::detail::PoolImpl::_addHelix
int _addHelix(CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition: PoolImpl.cc:336
zypp::sat::detail::PoolImpl::_addSolv
int _addSolv(CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition: PoolImpl.cc:327
zypp::sat::detail::PoolImpl::_needrebootSpec
sat::SolvableSpec _needrebootSpec
Solvables which should trigger the reboot-needed hint if installed/updated.
Definition: PoolImpl.h:357
zypp::sat::detail::PoolImpl::whatProvides
unsigned whatProvides(Capability cap_r)
Returns offset into the internal whatprovidesdata array.
Definition: PoolImpl.h:224
zypp::base::SetTracker::added
const set_type & added() const
Return the set of added items.
Definition: SetTracker.h:142
zypp::sat::detail::PoolImpl::_createRepo
CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition: PoolImpl.cc:302
zypp::sat::detail::PoolImpl::prepare
void prepare() const
Update housekeeping data (e.g.
Definition: PoolImpl.cc:271
zypp::base::SetTracker::current
const set_type & current() const
Return the current set.
Definition: SetTracker.h:139
zypp::sat::detail::PoolImpl
Definition: PoolImpl.h:52
PoolMember.h
zypp::sat::detail::PoolImpl::_serial
SerialNumber _serial
Serial number - changes with each Pool content change.
Definition: PoolImpl.h:335
zypp::base::SetTracker::contains
bool contains(const key_type &key_r) const
Whether val_r is in the set.
Definition: SetTracker.h:129
Capability.h
zypp::sat::SolvableSpec
Define a set of Solvables by ident and provides.
Definition: SolvableSpec.h:44
zypp::sat::detail::PoolImpl::eraseRepoInfo
void eraseRepoInfo(RepoIdType id_r)
Definition: PoolImpl.h:211
zypp::sat::detail::PoolImpl::_trackedLocaleIdsPtr
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
Definition: PoolImpl.h:345
zypp::sat::detail::PoolImpl::getPool
CPool * getPool() const
Definition: PoolImpl.h:165
zypp::sat::detail::PoolImpl::depSetDirty
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:260
zypp::sat::SolvableSpec::setDirty
void setDirty() const
Explicitly flag the cache as dirty, so it will be rebuilt on the next request.
Definition: SolvableSpec.cc:152
SolvableSpec.h
zypp::sat::detail::PoolImpl::serialIDs
const SerialNumber & serialIDs() const
Serial number changing whenever resusePoolIDs==true was used.
Definition: PoolImpl.h:71
zypp::sat::detail::PoolImpl::getRequestedLocales
const LocaleSet & getRequestedLocales() const
Current set of requested Locales.
Definition: PoolImpl.h:253
zypp::sat::detail::PoolImpl::addRequestedLocale
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition: PoolImpl.cc:470
zypp::sat::detail::PoolImpl::autoInstalled
StringQueue autoInstalled() const
Get ident list of all autoinstalled solvables.
Definition: PoolImpl.h:298
zypp::IdString
Access to the sat-pools string space.
Definition: IdString.h:41
zypp::sat::detail::PoolImpl::_serialIDs
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate it's PoolI...
Definition: PoolImpl.h:337
zypp::sat::detail::PoolImpl::nsCallback
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:129
zypp::sat::detail::PoolImpl::isNeedreboot
bool isNeedreboot(const Solvable &solv_r) const
Whether solv_r matches the spec.
Definition: PoolImpl.h:323
zypp::sat::detail::PoolImpl::setNeedrebootSpec
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Set new Solvable specs.
Definition: PoolImpl.h:316
zypp::sat::detail::PoolImpl::_deleteRepo
void _deleteRepo(CRepo *repo_r)
Delete repo repo_r from pool.
Definition: PoolImpl.cc:311
RepoInfo.h
zypp::sat::detail::PoolImpl::getAvailableLocales
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
Definition: PoolImpl.cc:564
zypp::sat::detail::SolvableIdType
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolMember.h:125
zypp::sat::detail::PoolImpl::getSolvable
CSolvable * getSolvable(SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
Definition: PoolImpl.h:175
zypp::sat::Queue::contains
bool contains(value_type val_r) const
Return whether the Queue contais at lest one element with value val_r.
Definition: Queue.h:57
zypp::sat::detail::noSolvableId
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
zypp::filesystem::Pathname::c_str
const char * c_str() const
String representation.
Definition: Pathname.h:110
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
zypp::sat::detail::PoolImpl::requiredFilesystems
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
Definition: PoolImpl.cc:622
zypp::sat::detail::RepoIdType
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolMember.h:133
zypp::sat::detail::IdType
int IdType
Generic Id type.
Definition: PoolMember.h:104
zypp::sat::detail::PoolImpl::setRepoInfo
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
Definition: PoolImpl.cc:395
IdString.h
zypp::sat::detail::PoolImpl::setRequestedLocales
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
Definition: PoolImpl.cc:461
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::sat::detail::PoolImpl::_watcher
SerialNumberWatcher _watcher
Watch serial number.
Definition: PoolImpl.h:339
zypp::sat::detail::PoolImpl::getRemovedRequestedLocales
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
Definition: PoolImpl.h:249
zypp::sat::detail::PoolImpl::whatProvidesData
const sat::detail::IdType whatProvidesData(unsigned offset_r)
Returns the id stored at offset_r in the internal whatprovidesdata array.
Definition: PoolImpl.h:218
Queue.h
zypp::sat::detail::PoolImpl::serial
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition: PoolImpl.h:67
zypp::sat::detail::PoolImpl::validSolvable
bool validSolvable(SolvableIdType id_r) const
Definition: PoolImpl.h:158
zypp::sat::Queue
Libsolv Id queue wrapper.
Definition: Queue.h:34
zypp::sat::detail::PoolImpl::localeSetDirty
void localeSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate locale related housekeeping data.
Definition: PoolImpl.cc:248
SerialNumber.h
zypp::sat::detail::PoolImpl::multiversionListInit
void multiversionListInit() const
Definition: PoolImpl.cc:584
zypp::IdString::id
IdType id() const
Expert backdoor.
Definition: IdString.h:115
zypp::sat::detail::PoolImpl::_requestedLocalesTracker
base::SetTracker< LocaleSet > _requestedLocalesTracker
Definition: PoolImpl.h:344
zypp::sat::SolvableSpec::contains
bool contains(const sat::Solvable &solv_r) const
Test whether solv_r matches the spec.
Definition: SolvableSpec.cc:146
zypp::sat::detail::PoolImpl::eraseRequestedLocale
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition: PoolImpl.cc:481
zypp::sat::detail::PoolImpl::multiversionList
const MultiversionList & multiversionList() const
Definition: PoolImpl.cc:610
zypp::sat::detail::CSolvable
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:64
zypp::sat::detail::PoolImpl::validSolvable
bool validSolvable(const CSolvable &slv_r) const
a valid Solvable has a non NULL repo pointer.
Definition: PoolImpl.h:155
zypp::sat::detail::PoolImpl::isRequestedLocale
bool isRequestedLocale(const Locale &locale_r) const
Definition: PoolImpl.h:256
zypp::sat::detail::PoolImpl::_pool
CPool * _pool
sat-pool.
Definition: PoolImpl.h:333
zypp::Capability
A sat capability.
Definition: Capability.h:59
zypp::sat::detail::PoolImpl::isSystemRepo
bool isSystemRepo(CRepo *repo_r) const
Definition: PoolImpl.h:100
zypp::sat::detail::PoolImpl::isMultiversion
bool isMultiversion(const Solvable &solv_r) const
Definition: PoolImpl.cc:617
zypp::SerialNumber
Simple serial number provider.
Definition: SerialNumber.h:44
zypp::sat::detail::PoolImpl::MultiversionList
SolvableSet MultiversionList
Definition: PoolImpl.h:285
zypp::sat::detail::PoolImpl::_repoinfos
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
Definition: PoolImpl.h:341
zypp::sat::detail::PoolImpl::_multiversionListPtr
scoped_ptr< MultiversionList > _multiversionListPtr
Definition: PoolImpl.h:351
zypp::sat::detail::PoolImpl::~PoolImpl
~PoolImpl()
Dtor.
Definition: PoolImpl.cc:225
zypp::sat::detail::PoolImpl::initRequestedLocales
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Definition: PoolImpl.cc:452
zypp::filesystem::Pathname::empty
bool empty() const
Test for an empty path.
Definition: Pathname.h:114
zypp::LocaleSet
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
zypp::sat::detail::PoolImpl::setTextLocale
void setTextLocale(const Locale &locale_r)
Definition: PoolImpl.cc:427
zypp::sat::detail::PoolImpl::trackedLocaleIds
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
Definition: PoolImpl.cc:493
Locale.h
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:44
zypp::sat::detail::PoolImpl::_requiredFilesystemsPtr
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
Definition: PoolImpl.h:360
zypp::sat::detail::PoolImpl::getAddedRequestedLocales
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
Definition: PoolImpl.h:245
zypp::sat::detail::PoolImpl::getRepo
CRepo * getRepo(RepoIdType id_r) const
Definition: PoolImpl.h:169
zypp::sat::detail::PoolImpl::_availableLocalesPtr
scoped_ptr< LocaleSet > _availableLocalesPtr
Definition: PoolImpl.h:347
zypp::sat::detail::PoolImpl::getNextId
SolvableIdType getNextId(SolvableIdType id_r) const
Get id of the next valid Solvable.
Definition: PoolImpl.h:194
Hash.h
zypp::sat::detail::PoolImpl::_addSolvables
detail::SolvableIdType _addSolvables(CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition: PoolImpl.cc:389
zypp::base::SetTracker::removed
const set_type & removed() const
Return the set of removed items.
Definition: SetTracker.h:145
zypp::base::SetTracker
Track added/removed set items based on an initial set.
Definition: SetTracker.h:37
zypp::sat::detail::PoolImpl::rootDir
Pathname rootDir() const
Get rootdir (for file conflicts check)
Definition: PoolImpl.h:107
zypp::Locale
'Language[_Country]' codes.
Definition: Locale.h:49
zypp::sat::detail::CRepo
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:63
zypp::sat::detail::PoolImpl::setAutoInstalled
void setAutoInstalled(const StringQueue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Definition: PoolImpl.h:302
zypp::sat::detail::PoolImpl::_postRepoAdd
void _postRepoAdd(CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
Definition: PoolImpl.cc:345
zypp::SerialNumberWatcher
Simple serial number watcher.
Definition: SerialNumber.h:122
zypp::sat::detail::PoolImpl::repoInfo
const RepoInfo & repoInfo(RepoIdType id_r)
Definition: PoolImpl.h:206
NonCopyable.h
zypp::sat::detail::PoolImpl::isOnSystemByAuto
bool isOnSystemByAuto(IdString ident_r) const
Definition: PoolImpl.h:308
zypp::sat::detail::PoolImpl::systemRepo
CRepo * systemRepo() const
Definition: PoolImpl.h:103