libzypp  16.22.5
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 );
165  void setBaseUrls( url_set urls );
166 
187  Pathname path() const;
192  void setPath( const Pathname &path );
193 
197  Url mirrorListUrl() const;
201  Url rawMirrorListUrl() const;
206  void setMirrorListUrl( const Url &url );
210  void setMetalinkUrl( const Url &url );
211 
216  repo::RepoType type() const;
223  void setProbedType( const repo::RepoType &t ) const;
228  void setType( const repo::RepoType &t );
229 
236  Pathname metadataPath() const;
263  void setMetadataPath( const Pathname &path );
264 
266  bool usesAutoMethadataPaths() const;
267 
271  Pathname packagesPath() const;
277  void setPackagesPath( const Pathname &path );
278 
279 
337  bool gpgCheck() const;
339  void setGpgCheck( TriBool value_r );
341  void setGpgCheck( bool value_r );
342 
344  bool repoGpgCheck() const;
346  bool repoGpgCheckIsMandatory() const;
348  void setRepoGpgCheck( TriBool value_r );
349 
351  bool pkgGpgCheck() const;
353  bool pkgGpgCheckIsMandatory() const;
355  void setPkgGpgCheck( TriBool value_r );
356 
360  TriBool validRepoSignature() const;
362  void setValidRepoSignature( TriBool value_r );
363 
365  enum class GpgCheck {
366  indeterminate, //< not specified
367  On, //< 1** --gpgcheck
368  Strict, //< 111 --gpgcheck-strict
369  AllowUnsigned, //< 100 --gpgcheck-allow-unsigned
370  AllowUnsignedRepo, //< 10* --gpgcheck-allow-unsigned-repo
371  AllowUnsignedPackage, //< 1*0 --gpgcheck-allow-unsigned-package
372  Default, //< *** --default-gpgcheck
373  Off, //< 0** --no-gpgcheck
374  };
375 
380  bool setGpgCheck( GpgCheck mode_r );
382 
383 
385  bool gpgKeyUrlsEmpty() const;
388 
390  url_set gpgKeyUrls() const;
392  url_set rawGpgKeyUrls() const;
394  void setGpgKeyUrls( url_set urls );
395 
397  Url gpgKeyUrl() const;
399  Url rawGpgKeyUrl() const;
401  void setGpgKeyUrl( const Url &gpgkey );
402 
403 
407  bool keepPackages() const;
417  void setKeepPackages( bool keep );
418 
423  std::string service() const;
427  void setService( const std::string& name );
428 
432  std::string targetDistribution() const;
438  void setTargetDistribution(const std::string & targetDistribution);
439 
440 
442  const std::set<std::string> & contentKeywords() const;
443 
445  void addContent( const std::string & keyword_r );
447  template <class TIterator>
448  void addContentFrom( TIterator begin_r, TIterator end_r )
449  { for_( it, begin_r, end_r ) addContent( *it ); }
451  template <class TContainer>
452  void addContentFrom( const TContainer & container_r )
453  { addContentFrom( container_r.begin(), container_r.end() ); }
454 
458  bool hasContent() const;
460  bool hasContent( const std::string & keyword_r ) const;
462  template <class TIterator>
463  bool hasContentAll( TIterator begin_r, TIterator end_r ) const
464  { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
466  template <class TContainer>
467  bool hasContentAll( const TContainer & container_r ) const
468  { return hasContentAll( container_r.begin(), container_r.end() ); }
470  template <class TIterator>
471  bool hasContentAny( TIterator begin_r, TIterator end_r ) const
472  { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
474  template <class TContainer>
475  bool hasContentAny( const TContainer & container_r ) const
476  { return hasContentAny( container_r.begin(), container_r.end() ); }
477 
478  public:
492  bool hasLicense() const;
494  bool hasLicense( const std::string & name_r ) const;
495 
499  bool needToAcceptLicense() const;
501  bool needToAcceptLicense( const std::string & name_r ) const;
502 
504  std::string getLicense( const Locale & lang_r = Locale() ) const;
506  std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
508  std::string getLicense( const std::string & name_r, const Locale & lang_r = Locale() ) const;
509 
516  LocaleSet getLicenseLocales( const std::string & name_r ) const;
518 
519  public:
524  virtual std::ostream & dumpOn( std::ostream & str ) const;
525 
530  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
531 
540  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
541 
542  class Impl;
543  private:
544  friend class RepoManager;
546  void getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const;
547 
550  };
552 
554  typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
556  typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
558  typedef std::list<RepoInfo> RepoInfoList;
559 
561  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
562 
564  std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj );
565 
567 } // namespace zypp
569 #endif // ZYPP2_REPOSITORYINFO_H
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:708
std::string name() const
Repository name.
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:587
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition: RepoInfo.cc:557
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
Definition: RepoInfo.cc:488
bool hasContentAll(TIterator begin_r, TIterator end_r) const
Definition: RepoInfo.h:463
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:358
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition: RepoInfo.cc:590
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:792
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:364
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:549
shared_ptr< RepoInfo > RepoInfo_Ptr
Definition: RepoInfo.h:554
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:563
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:479
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:593
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:539
bool hasContentAny(TIterator begin_r, TIterator end_r) const
Definition: RepoInfo.h:471
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:393
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:517
bool hasContentAll(const TContainer &container_r) const
Definition: RepoInfo.h:467
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:403
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:371
#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:502
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:596
shared_ptr< const RepoInfo > RepoInfo_constPtr
Definition: RepoInfo.h:556
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:542
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:355
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:418
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:378
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
Definition: RepoInfo.cc:566
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
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition: RepoInfo.cc:396
RepoInfo implementation.
Definition: RepoInfo.cc:44
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:536
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:629
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:554
virtual ~RepoInfo()
Definition: RepoInfo.cc:352
GpgCheck
Some predefined settings.
Definition: RepoInfo.h:365
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:389
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:551
Provides API related macros.
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:511
bool hasContent() const
Check for content keywords.
Definition: RepoInfo.cc:614
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:530
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Definition: RepoInfo.cc:521
bool gpgCheck() const
Whether default signature checking should be performed.
Definition: RepoInfo.cc:368
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition: RepoInfo.cc:560
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:514
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:605
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:527
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:584
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:494
SolvableIdType size_type
Definition: PoolMember.h:152
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:524
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:575
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:578
'Language[_Country]' codes.
Definition: Locale.h:49
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition: RepoInfo.cc:482
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:602
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:485
creates and provides information about known sources.
Definition: RepoManager.h:105
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:548
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:533
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:664
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:622
void addContentFrom(TIterator begin_r, TIterator end_r)
Definition: RepoInfo.h:448
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition: RepoInfo.cc:381
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition: RepoInfo.cc:569
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:608
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition: RepoInfo.cc:508
bool usesAutoMethadataPaths() const
Whether metadataPath uses AUTO% setup.
Definition: RepoInfo.cc:545
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:80
std::list< RepoInfo > RepoInfoList
Definition: RepoInfo.h:558
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:611
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:846
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Definition: RepoInfo.cc:411
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:599
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition: RepoInfo.cc:361
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:399
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
bool hasContentAny(const TContainer &container_r) const
Definition: RepoInfo.h:475
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) ...
Definition: RepoInfo.cc:572
Url manipulation class.
Definition: Url.h:87
Pathname path() const
Repository path.
Definition: RepoInfo.cc:581
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:744
void addContentFrom(const TContainer &container_r)
Definition: RepoInfo.h:452
Repository type enumeration.
Definition: RepoType.h:27
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
Definition: RepoInfo.cc:879