libzypp  15.28.6
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/base/EnumClass.h"
25 #include "zypp/repo/RepoType.h"
27 
28 #include "zypp/repo/RepoInfoBase.h"
29 
31 namespace zypp
32 {
33 
35  //
36  // CLASS NAME : RepoInfo
37  //
73  {
74  friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
75 
76  public:
77  RepoInfo();
78  virtual ~RepoInfo();
79 
81  static const RepoInfo noRepo;
82 
83  public:
87  static unsigned defaultPriority();
91  static unsigned noPriority();
96  unsigned priority() const;
102  void setPriority( unsigned newval_r );
103 
104  typedef std::list<Url> url_set;
106  typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
110  bool baseUrlsEmpty() const;
115  bool baseUrlSet() const;
128 
132  Url url() const
133  { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
137  Url rawUrl() const;
138 
145  url_set baseUrls() const;
149  url_set rawBaseUrls() const;
150 
158  void addBaseUrl( const Url &url );
162  void setBaseUrl( const Url &url );
166  void setBaseUrls( url_set urls );
167 
188  Pathname path() const;
193  void setPath( const Pathname &path );
194 
198  Url mirrorListUrl() const;
202  Url rawMirrorListUrl() const;
207  void setMirrorListUrl( const Url &url );
211  void setMetalinkUrl( const Url &url );
212 
217  repo::RepoType type() const;
224  void setProbedType( const repo::RepoType &t ) const;
229  void setType( const repo::RepoType &t );
230 
237  Pathname metadataPath() const;
246  void setMetadataPath( const Pathname &path );
247 
251  Pathname packagesPath() const;
257  void setPackagesPath( const Pathname &path );
258 
259 
317  bool gpgCheck() const;
319  void setGpgCheck( TriBool value_r );
321  void setGpgCheck( bool value_r );
322 
324  bool repoGpgCheck() const;
326  bool repoGpgCheckIsMandatory() const;
328  void setRepoGpgCheck( TriBool value_r );
329 
331  bool pkgGpgCheck() const;
333  bool pkgGpgCheckIsMandatory() const;
335  void setPkgGpgCheck( TriBool value_r );
336 
340  TriBool validRepoSignature() const;
342  void setValidRepoSignature( TriBool value_r );
343 
345  struct GpgCheckDef {
346  enum Enum {
347  indeterminate, //< not specified
348  On, //< 1** --gpgcheck
349  Strict, //< 111 --gpgcheck-strict
350  AllowUnsigned, //< 100 --gpgcheck-allow-unsigned
351  AllowUnsignedRepo, //< 10* --gpgcheck-allow-unsigned-repo
352  AllowUnsignedPackage, //< 1*0 --gpgcheck-allow-unsigned-package
353  Default, //< *** --default-gpgcheck
354  Off, //< 0** --no-gpgcheck
355  };
356  };
357  typedef base::EnumClass<GpgCheckDef> GpgCheck;
358 
363  bool setGpgCheck( GpgCheck mode_r );
365 
366 
368  bool gpgKeyUrlsEmpty() const;
371 
373  url_set gpgKeyUrls() const;
375  url_set rawGpgKeyUrls() const;
377  void setGpgKeyUrls( url_set urls );
378 
380  Url gpgKeyUrl() const;
382  Url rawGpgKeyUrl() const;
384  void setGpgKeyUrl( const Url &gpgkey );
385 
386 
390  bool keepPackages() const;
400  void setKeepPackages( bool keep );
401 
406  std::string service() const;
410  void setService( const std::string& name );
411 
415  std::string targetDistribution() const;
421  void setTargetDistribution(const std::string & targetDistribution);
422 
423 
425  const std::set<std::string> & contentKeywords() const;
426 
428  void addContent( const std::string & keyword_r );
430  template <class TIterator>
431  void addContentFrom( TIterator begin_r, TIterator end_r )
432  { for_( it, begin_r, end_r ) addContent( *it ); }
434  template <class TContainer>
435  void addContentFrom( const TContainer & container_r )
436  { addContentFrom( container_r.begin(), container_r.end() ); }
437 
441  bool hasContent() const;
443  bool hasContent( const std::string & keyword_r ) const;
445  template <class TIterator>
446  bool hasContentAll( TIterator begin_r, TIterator end_r ) const
447  { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
449  template <class TContainer>
450  bool hasContentAll( const TContainer & container_r ) const
451  { return hasContentAll( container_r.begin(), container_r.end() ); }
453  template <class TIterator>
454  bool hasContentAny( TIterator begin_r, TIterator end_r ) const
455  { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
457  template <class TContainer>
458  bool hasContentAny( const TContainer & container_r ) const
459  { return hasContentAny( container_r.begin(), container_r.end() ); }
460 
461  public:
466  bool hasLicense() const;
467 
471  bool needToAcceptLicense() const;
472 
474  std::string getLicense( const Locale & lang_r = Locale() ) const;
475  std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
476 
483 
484  public:
489  virtual std::ostream & dumpOn( std::ostream & str ) const;
490 
495  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
496 
505  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
506 
507  class Impl;
508  private:
509  friend class RepoManager;
511  void getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const;
512 
515  };
517 
519  typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
521  typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
523  typedef std::list<RepoInfo> RepoInfoList;
524 
526  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
527 
529  std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj );
530 
532 } // namespace zypp
534 #endif // ZYPP2_REPOSITORYINFO_H
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:648
std::string name() const
Repository name.
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:535
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition: RepoInfo.cc:505
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
Definition: RepoInfo.cc:439
bool hasContentAll(TIterator begin_r, TIterator end_r) const
Definition: RepoInfo.h:446
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:309
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition: RepoInfo.cc:538
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:728
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:315
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:514
shared_ptr< RepoInfo > RepoInfo_Ptr
Definition: RepoInfo.h:519
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:511
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:430
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:541
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:490
bool hasContentAny(TIterator begin_r, TIterator end_r) const
Definition: RepoInfo.h:454
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:344
std::list< Url > url_set
Definition: RepoInfo.h:104
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:468
bool hasContentAll(const TContainer &container_r) const
Definition: RepoInfo.h:450
What is known about a repository.
Definition: RepoInfo.h:72
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
Definition: RepoInfo.cc:354
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:322
#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:453
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:544
shared_ptr< const RepoInfo > RepoInfo_constPtr
Definition: RepoInfo.h:521
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:493
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:306
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:369
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:329
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
Definition: RepoInfo.cc:514
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:106
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition: RepoInfo.cc:347
RepoInfo implementation.
Definition: RepoInfo.cc:43
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:487
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:576
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:502
virtual ~RepoInfo()
Definition: RepoInfo.cc:303
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:340
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:499
Provides API related macros.
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:462
bool hasContent() const
Check for content keywords.
Definition: RepoInfo.cc:562
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:481
void setMetadataPath(const Pathname &path)
set the path where the local metadata is stored
Definition: RepoInfo.cc:472
bool gpgCheck() const
Whether default signature checking should be performed.
Definition: RepoInfo.cc:319
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition: RepoInfo.cc:508
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:465
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:553
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:478
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:532
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:445
SolvableIdType size_type
Definition: PoolMember.h:152
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:475
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:523
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:526
'Language[_Country]' codes.
Definition: Locale.h:49
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition: RepoInfo.cc:433
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:550
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:436
creates and provides information about known sources.
Definition: RepoManager.h:105
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:496
url_set::size_type urls_size_type
Definition: RepoInfo.h:105
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:484
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:608
Some predefined settings (use like 'enum class GpgCheck')
Definition: RepoInfo.h:345
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:570
void addContentFrom(TIterator begin_r, TIterator end_r)
Definition: RepoInfo.h:431
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition: RepoInfo.cc:332
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition: RepoInfo.cc:517
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:132
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Definition: RepoInfo.cc:556
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition: RepoInfo.cc:459
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:81
std::list< RepoInfo > RepoInfoList
Definition: RepoInfo.h:523
base::EnumClass< GpgCheckDef > GpgCheck
'enum class GpgCheck'
Definition: RepoInfo.h:357
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:559
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:782
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Definition: RepoInfo.cc:362
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:547
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition: RepoInfo.cc:312
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:350
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
bool hasContentAny(const TContainer &container_r) const
Definition: RepoInfo.h:458
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) ...
Definition: RepoInfo.cc:520
Url manipulation class.
Definition: Url.h:87
Pathname path() const
Repository path.
Definition: RepoInfo.cc:529
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:681
void addContentFrom(const TContainer &container_r)
Definition: RepoInfo.h:435
Repository type enumeration.
Definition: RepoType.h:27
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
Definition: RepoInfo.cc:815