libzypp  15.21.4
RepoInfo.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP2_REPOSITORYINFO_H
13 #define ZYPP2_REPOSITORYINFO_H
14 
15 #include <list>
16 #include <set>
17 
18 #include "zypp/base/Iterator.h"
19 #include "zypp/APIConfig.h"
20 
21 #include "zypp/Url.h"
22 #include "zypp/Locale.h"
23 #include "zypp/TriBool.h"
24 #include "zypp/repo/RepoType.h"
26 
27 #include "zypp/repo/RepoInfoBase.h"
28 
30 namespace zypp
31 {
32 
34  //
35  // CLASS NAME : RepoInfo
36  //
72  {
73  friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
74 
75  public:
76  RepoInfo();
77  virtual ~RepoInfo();
78 
80  static const RepoInfo noRepo;
81 
82  public:
86  static unsigned defaultPriority();
90  static unsigned noPriority();
95  unsigned priority() const;
101  void setPriority( unsigned newval_r );
102 
103  typedef std::list<Url> url_set;
105  typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
109  bool baseUrlsEmpty() const;
114  bool baseUrlSet() const;
127 
131  Url url() const
132  { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
136  Url rawUrl() const;
137 
144  url_set baseUrls() const;
148  url_set rawBaseUrls() const;
149 
157  void addBaseUrl( const Url &url );
161  void setBaseUrl( const Url &url );
162 
183  Pathname path() const;
188  void setPath( const Pathname &path );
189 
193  Url mirrorListUrl() const;
197  Url rawMirrorListUrl() const;
202  void setMirrorListUrl( const Url &url );
206  void setMetalinkUrl( const Url &url );
207 
212  repo::RepoType type() const;
219  void setProbedType( const repo::RepoType &t ) const;
224  void setType( const repo::RepoType &t );
225 
232  Pathname metadataPath() const;
241  void setMetadataPath( const Pathname &path );
242 
246  Pathname packagesPath() const;
252  void setPackagesPath( const Pathname &path );
253 
254 
262  bool gpgCheck() const;
264  void setGpgCheck( TriBool value_r );
266  void setGpgCheck( bool value_r );
267 
271  bool repoGpgCheck() const;
273  void setRepoGpgCheck( TriBool value_r );
274 
278  bool pkgGpgCheck() const;
280  void setPkgGpgCheck( TriBool value_r );
281 
285  TriBool validRepoSignature() const;
287  void setValidRepoSignature( TriBool value_r );
288 
298  Url gpgKeyUrl() const;
302  Url rawGpgKeyUrl() const;
312  void setGpgKeyUrl( const Url &gpgkey );
313 
317  bool keepPackages() const;
327  void setKeepPackages( bool keep );
328 
333  std::string service() const;
337  void setService( const std::string& name );
338 
342  std::string targetDistribution() const;
348  void setTargetDistribution(const std::string & targetDistribution);
349 
350 
352  const std::set<std::string> & contentKeywords() const;
353 
355  void addContent( const std::string & keyword_r );
357  template <class TIterator>
358  void addContentFrom( TIterator begin_r, TIterator end_r )
359  { for_( it, begin_r, end_r ) addContent( *it ); }
361  template <class TContainer>
362  void addContentFrom( const TContainer & container_r )
363  { addContentFrom( container_r.begin(), container_r.end() ); }
364 
368  bool hasContent() const;
370  bool hasContent( const std::string & keyword_r ) const;
372  template <class TIterator>
373  bool hasContentAll( TIterator begin_r, TIterator end_r ) const
374  { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
376  template <class TContainer>
377  bool hasContentAll( const TContainer & container_r ) const
378  { return hasContentAll( container_r.begin(), container_r.end() ); }
380  template <class TIterator>
381  bool hasContentAny( TIterator begin_r, TIterator end_r ) const
382  { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
384  template <class TContainer>
385  bool hasContentAny( const TContainer & container_r ) const
386  { return hasContentAny( container_r.begin(), container_r.end() ); }
387 
388  public:
393  bool hasLicense() const;
394 
398  bool needToAcceptLicense() const;
399 
401  std::string getLicense( const Locale & lang_r = Locale() ) const;
402  std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
403 
410 
411  public:
416  virtual std::ostream & dumpOn( std::ostream & str ) const;
417 
422  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
423 
432  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
433 
434  class Impl;
435  private:
436  friend class RepoManager;
438  void getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const;
439 
442  };
444 
446  typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
448  typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
450  typedef std::list<RepoInfo> RepoInfoList;
451 
453  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
454 
455 
457 } // namespace zypp
459 #endif // ZYPP2_REPOSITORYINFO_H
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:523
std::string name() const
Repository name.
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:411
void setGpgKeyUrl(const Url &gpgkey)
Key to use for gpg checking of this repository.
Definition: RepoInfo.cc:333
bool hasContentAll(TIterator begin_r, TIterator end_r) const
Definition: RepoInfo.h:373
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:265
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition: RepoInfo.cc:414
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:600
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:271
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:441
shared_ptr< RepoInfo > RepoInfo_Ptr
Definition: RepoInfo.h:446
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:327
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:417
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:378
bool hasContentAny(TIterator begin_r, TIterator end_r) const
Definition: RepoInfo.h:381
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:296
std::list< Url > url_set
Definition: RepoInfo.h:103
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects...
Definition: RepoInfo.cc:356
bool hasContentAll(const TContainer &container_r) const
Definition: RepoInfo.h:377
What is known about a repository.
Definition: RepoInfo.h:71
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
Definition: RepoInfo.cc:307
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:278
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
Definition: RepoInfo.cc:344
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:420
shared_ptr< const RepoInfo > RepoInfo_constPtr
Definition: RepoInfo.h:448
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:381
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:262
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:323
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:285
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:30
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:105
RepoInfo implementation.
Definition: RepoInfo.cc:43
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:375
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:452
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:390
virtual ~RepoInfo()
Definition: RepoInfo.cc:259
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:292
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:387
Provides API related macros.
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:350
bool hasContent() const
Check for content keywords.
Definition: RepoInfo.cc:438
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:369
void setMetadataPath(const Pathname &path)
set the path where the local metadata is stored
Definition: RepoInfo.cc:360
bool gpgCheck() const
Whether default signature checking should be performed for this repo.
Definition: RepoInfo.cc:275
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:353
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:429
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:366
std::string service() const
Gets name of the service to which this repository belongs or empty string if it has been added manual...
Definition: RepoInfo.cc:408
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:336
SolvableIdType size_type
Definition: PoolMember.h:126
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:363
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:399
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:402
'Language[_Country]' codes.
Definition: Locale.h:49
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition: RepoInfo.cc:330
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:426
creates and provides information about known sources.
Definition: RepoManager.h:105
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:384
url_set::size_type urls_size_type
Definition: RepoInfo.h:104
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:372
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:483
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:446
void addContentFrom(TIterator begin_r, TIterator end_r)
Definition: RepoInfo.h:358
Url gpgKeyUrl() const
Key to use for gpg checking of this repository.
Definition: RepoInfo.cc:393
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:131
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Definition: RepoInfo.cc:432
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:80
std::list< RepoInfo > RepoInfoList
Definition: RepoInfo.h:450
Base class implementing common features of RepoInfo and ServiceInfo.
Definition: RepoInfoBase.h:39
void addContent(const std::string &keyword_r)
Add content keywords.
Definition: RepoInfo.cc:435
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:647
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Definition: RepoInfo.cc:314
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:423
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition: RepoInfo.cc:268
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:304
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
bool hasContentAny(const TContainer &container_r) const
Definition: RepoInfo.h:385
Url rawGpgKeyUrl() const
The raw gpgKeyUrl (no variables replaced).
Definition: RepoInfo.cc:396
Url manipulation class.
Definition: Url.h:87
Pathname path() const
Repository path.
Definition: RepoInfo.cc:405
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:556
void addContentFrom(const TContainer &container_r)
Definition: RepoInfo.h:362
Repository type enumeration.
Definition: RepoType.h:27
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
Definition: RepoInfo.cc:680