libzypp  17.25.10
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 );
208  void setMirrorListUrls( url_set urls );
209 
211  void setMetalinkUrl( const Url &url );
213  void setMetalinkUrls( url_set urls );
214 
219  repo::RepoType type() const;
226  void setProbedType( const repo::RepoType &t ) const;
231  void setType( const repo::RepoType &t );
232 
239  Pathname metadataPath() const;
266  void setMetadataPath( const Pathname &path );
267 
269  bool usesAutoMethadataPaths() const;
270 
274  Pathname packagesPath() const;
280  void setPackagesPath( const Pathname &path );
281 
282 
340  bool gpgCheck() const;
342  void setGpgCheck( TriBool value_r );
344  void setGpgCheck( bool value_r );
345 
347  bool repoGpgCheck() const;
349  bool repoGpgCheckIsMandatory() const;
351  void setRepoGpgCheck( TriBool value_r );
352 
354  bool pkgGpgCheck() const;
356  bool pkgGpgCheckIsMandatory() const;
358  void setPkgGpgCheck( TriBool value_r );
359 
363  TriBool validRepoSignature() const;
365  void setValidRepoSignature( TriBool value_r );
366 
368  enum class GpgCheck {
369  indeterminate, //< not specified
370  On, //< 1** --gpgcheck
371  Strict, //< 111 --gpgcheck-strict
372  AllowUnsigned, //< 100 --gpgcheck-allow-unsigned
373  AllowUnsignedRepo, //< 10* --gpgcheck-allow-unsigned-repo
374  AllowUnsignedPackage, //< 1*0 --gpgcheck-allow-unsigned-package
375  Default, //< *** --default-gpgcheck
376  Off, //< 0** --no-gpgcheck
377  };
378 
383  bool setGpgCheck( GpgCheck mode_r );
385 
386 
388  bool gpgKeyUrlsEmpty() const;
391 
393  url_set gpgKeyUrls() const;
395  url_set rawGpgKeyUrls() const;
397  void setGpgKeyUrls( url_set urls );
398 
400  Url gpgKeyUrl() const;
402  Url rawGpgKeyUrl() const;
404  void setGpgKeyUrl( const Url &gpgkey );
405 
407  Pathname provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r ) const;
408 
412  bool keepPackages() const;
422  void setKeepPackages( bool keep );
423 
428  std::string service() const;
432  void setService( const std::string& name );
433 
437  std::string targetDistribution() const;
443  void setTargetDistribution(const std::string & targetDistribution);
444 
445 
447  const std::set<std::string> & contentKeywords() const;
448 
450  void addContent( const std::string & keyword_r );
452  template <class TIterator>
453  void addContentFrom( TIterator begin_r, TIterator end_r )
454  { for_( it, begin_r, end_r ) addContent( *it ); }
456  template <class TContainer>
457  void addContentFrom( const TContainer & container_r )
458  { addContentFrom( container_r.begin(), container_r.end() ); }
459 
463  bool hasContent() const;
465  bool hasContent( const std::string & keyword_r ) const;
467  template <class TIterator>
468  bool hasContentAll( TIterator begin_r, TIterator end_r ) const
469  { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
471  template <class TContainer>
472  bool hasContentAll( const TContainer & container_r ) const
473  { return hasContentAll( container_r.begin(), container_r.end() ); }
475  template <class TIterator>
476  bool hasContentAny( TIterator begin_r, TIterator end_r ) const
477  { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
479  template <class TContainer>
480  bool hasContentAny( const TContainer & container_r ) const
481  { return hasContentAny( container_r.begin(), container_r.end() ); }
482 
483  public:
497  bool hasLicense() const;
499  bool hasLicense( const std::string & name_r ) const;
500 
504  bool needToAcceptLicense() const;
506  bool needToAcceptLicense( const std::string & name_r ) const;
507 
509  std::string getLicense( const Locale & lang_r = Locale() ) const;
511  std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
513  std::string getLicense( const std::string & name_r, const Locale & lang_r = Locale() ) const;
514 
521  LocaleSet getLicenseLocales( const std::string & name_r ) const;
523 
524  public:
529  virtual std::ostream & dumpOn( std::ostream & str ) const;
530 
535  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
536 
545  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
546 
547  struct Impl;
548  private:
549  friend class RepoManager;
551  void getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const;
552 
555  };
557 
559  typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
561  typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
563  typedef std::list<RepoInfo> RepoInfoList;
564 
566  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
567 
569  std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj );
570 
572 } // namespace zypp
574 #endif // ZYPP2_REPOSITORYINFO_H
zypp::RepoInfo::setPkgGpgCheck
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:435
RepoVariables.h
zypp::RepoInfo::addContentFrom
void addContentFrom(TIterator begin_r, TIterator end_r)
Definition: RepoInfo.h:453
zypp::RepoInfo::getLicenseLocales
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:849
RepoType.h
zypp::RepoInfo::setBaseUrl
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
Definition: RepoInfo.cc:643
zypp::RepoInfo::gpgKeyUrlsEmpty
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition: RepoInfo.cc:698
zypp::RepoInfo::rawBaseUrls
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:719
zypp::RepoInfo::GpgCheck
GpgCheck
Some predefined settings.
Definition: RepoInfo.h:368
zypp::RepoInfo::gpgKeyUrlsSize
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition: RepoInfo.cc:701
zypp::RepoInfo::hasContentAny
bool hasContentAny(const TContainer &container_r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: RepoInfo.h:480
zypp::RepoInfo::setPackagesPath
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:665
zypp::RepoInfo::addContentFrom
void addContentFrom(const TContainer &container_r)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: RepoInfo.h:457
zypp::RepoInfo::RepoInfo_constPtr
shared_ptr< const RepoInfo > RepoInfo_constPtr
Definition: RepoInfo.h:561
zypp::RepoInfo::GpgCheck::Strict
@ Strict
zypp::RepoInfo::RepoInfo_Ptr
shared_ptr< RepoInfo > RepoInfo_Ptr
Definition: RepoInfo.h:559
zypp::RepoInfo
What is known about a repository.
Definition: RepoInfo.h:72
zypp::RepoInfo::urls_const_iterator
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:105
zypp::RepoInfo::setGpgKeyUrl
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
Definition: RepoInfo.cc:530
zypp::RepoInfo::RepoInfoList
std::list< RepoInfo > RepoInfoList
Definition: RepoInfo.h:563
zypp::RepoInfo::baseUrlsEmpty
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:743
zypp::RepoInfo::_pimpl
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:554
zypp::RepoInfo::setBaseUrls
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition: RepoInfo.cc:649
zypp::RepoInfo::noRepo
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:80
zypp::RepoInfo::setGpgCheck
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:407
zypp::RepoInfo::priority
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:391
zypp::RepoInfo::addContent
void addContent(const std::string &keyword_r)
Add content keywords.
Definition: RepoInfo.cc:752
zypp::RepoInfo::baseUrlSet
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:746
zypp::RepoInfo::packagesPath
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:683
zypp::RepoInfo::gpgCheck
bool gpgCheck() const
Whether default signature checking should be performed.
Definition: RepoInfo.cc:404
zypp::RepoInfo::setPath
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:652
zypp::RepoInfo::setPriority
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:400
zypp::RepoInfo::mirrorListUrl
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:692
zypp::RepoInfo::rawGpgKeyUrls
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
Definition: RepoInfo.cc:707
zypp::RepoInfo::dumpAsXmlOn
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:988
zypp::RepoInfo::provideKey
Pathname provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r) const
downloads all configured gpg keys into the defined directory
Definition: RepoInfo.cc:536
zypp::RepoInfo::usesAutoMethadataPaths
bool usesAutoMethadataPaths() const
Whether metadataPath uses AUTO% setup.
Definition: RepoInfo.cc:686
zypp::RepoInfo::hasContentAny
bool hasContentAny(TIterator begin_r, TIterator end_r) const
Definition: RepoInfo.h:476
Url.h
zypp::RepoInfo::setMetadataPath
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Definition: RepoInfo.cc:662
zypp::RepoInfo::setGpgKeyUrls
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:527
zypp::RepoInfo::setType
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:655
zypp::RepoInfo::setMetalinkUrls
void setMetalinkUrls(url_set urls)
Like setMirrorListUrls but expect metalink format.
Definition: RepoInfo.cc:524
zypp::repo::RepoType
Repository type enumeration.
Definition: RepoType.h:28
zypp::RepoInfo::setTargetDistribution
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:674
zypp::RepoInfo::setKeepPackages
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:668
zypp::RepoInfo::repoGpgCheckIsMandatory
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition: RepoInfo.cc:417
zypp::RepoInfo::setMirrorListUrls
void setMirrorListUrls(url_set urls)
Like setMirrorListUrl but take an url_set.
Definition: RepoInfo.cc:518
zypp::repo::RepoInfoBase::name
std::string name() const
Repository name.
Definition: RepoInfoBase.cc:117
zypp::RepoInfo::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:885
zypp::RepoInfo::addBaseUrl
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:635
zypp::RepoInfo::getRawGpgChecks
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
Definition: RepoInfo.cc:439
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::RepoInfo::GpgCheck::On
@ On
zypp::RepoInfo::baseUrlsBegin
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:734
zypp::RepoInfo::hasLicense
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:763
zypp::RepoInfo::rawUrl
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition: RepoInfo.cc:731
zypp::RepoInfo::setValidRepoSignature
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:454
RepoInfoBase.h
zypp::RepoInfo::validRepoSignature
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned.
Definition: RepoInfo.cc:447
zypp::RepoInfo::hasContentAll
bool hasContentAll(TIterator begin_r, TIterator end_r) const
Definition: RepoInfo.h:468
zypp::RepoInfo::setProbedType
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:658
Iterator.h
zypp::RepoInfo::pkgGpgCheck
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:429
zypp::RepoInfo::targetDistribution
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:728
Impl
zypp::RepoInfo::hasContentAll
bool hasContentAll(const TContainer &container_r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: RepoInfo.h:472
zypp::RepoInfo::gpgKeyUrls
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:704
zypp::repo::RepoInfoBase
Base class implementing common features of RepoInfo and ServiceInfo.
Definition: RepoInfoBase.h:40
TriBool.h
zypp::RepoInfo::url_set
std::list< Url > url_set
Definition: RepoInfo.h:103
zypp::RepoInfo::hasContent
bool hasContent() const
Check for content keywords.
Definition: RepoInfo.cc:755
zypp::RepoInfo::noPriority
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition: RepoInfo.cc:397
zypp::RepoInfo::GpgCheck::AllowUnsigned
@ AllowUnsigned
zypp::RepoInfo::operator<<
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
Definition: RepoInfo.cc:1021
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
zypp::RepoInfo::url
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:131
zypp::RepoInfo::GpgCheck::Off
@ Off
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
zypp::RepoInfo::GpgCheck::AllowUnsignedRepo
@ AllowUnsignedRepo
zypp::RepoInfo::dumpAsIniOn
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:933
zypp::RepoInfo::metadataPath
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:680
zypp::RepoInfo::pkgGpgCheckIsMandatory
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition: RepoInfo.cc:432
zypp::RepoInfo::baseUrls
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:716
zypp::RepoInfo::RepoInfo
RepoInfo()
Definition: RepoInfo.cc:384
zypp::RepoInfo::defaultPriority
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:394
zypp::RepoInfo::repoGpgCheck
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:414
zypp::LocaleSet
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
Locale.h
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:45
zypp::RepoInfo::setMirrorListUrl
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:515
zypp::RepoInfo::setRepoGpgCheck
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:425
zypp::sat::detail::size_type
SolvableIdType size_type
Definition: PoolMember.h:126
zypp::RepoInfo::urls_size_type
url_set::size_type urls_size_type
Definition: RepoInfo.h:104
zypp::RepoInfo::service
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:725
zypp::RepoInfo::needToAcceptLicense
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:770
zypp::RWCOW_pointer< Impl >
zypp::RepoInfo::setService
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:671
zypp::RepoInfo::gpgKeyUrl
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition: RepoInfo.cc:710
str
String related utilities and Regular expression matching.
zypp::RepoInfo::baseUrlsEnd
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:737
zypp::TriBool
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:30
zypp::Url
Url manipulation class.
Definition: Url.h:92
zypp::RepoInfo::rawGpgKeyUrl
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced)
Definition: RepoInfo.cc:713
zypp::Locale
'Language[_Country]' codes.
Definition: Locale.h:50
zypp::RepoInfo::setMetalinkUrl
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition: RepoInfo.cc:521
zypp::RepoInfo::rawMirrorListUrl
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:695
zypp::RepoInfo::GpgCheck::Default
@ Default
zypp::RepoManager
creates and provides information about known sources.
Definition: RepoManager.h:106
zypp::RepoInfo::keepPackages
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:677
zypp::RepoInfo::GpgCheck::AllowUnsignedPackage
@ AllowUnsignedPackage
zypp::RepoInfo::type
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:689
zypp::RepoInfo::~RepoInfo
virtual ~RepoInfo()
Definition: RepoInfo.cc:388
zypp::RepoInfo::GpgCheck::indeterminate
@ indeterminate
zypp::RepoInfo::getLicense
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:805
zypp::RepoInfo::contentKeywords
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Definition: RepoInfo.cc:749
zypp::RepoInfo::path
Pathname path() const
Repository path.
Definition: RepoInfo.cc:722
zypp::RepoInfo::baseUrlsSize
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:740