libzypp  14.48.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/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();
92  unsigned priority() const;
98  void setPriority( unsigned newval_r );
99 
100  typedef std::list<Url> url_set;
102  typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
106  bool baseUrlsEmpty() const;
111  bool baseUrlSet() const;
124 
128  Url url() const
129  { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
133  Url rawUrl() const;
134 
141  url_set baseUrls() const;
145  url_set rawBaseUrls() const;
146 
154  void addBaseUrl( const Url &url );
158  void setBaseUrl( const Url &url );
162  void setBaseUrls( url_set urls );
163 
184  Pathname path() const;
189  void setPath( const Pathname &path );
190 
194  Url mirrorListUrl() const;
198  Url rawMirrorListUrl() const;
203  void setMirrorListUrl( const Url &url );
204 
209  repo::RepoType type() const;
216  void setProbedType( const repo::RepoType &t ) const;
221  void setType( const repo::RepoType &t );
222 
229  Pathname metadataPath() const;
238  void setMetadataPath( const Pathname &path );
239 
243  Pathname packagesPath() const;
249  void setPackagesPath( const Pathname &path );
250 
251 
309  bool gpgCheck() const;
311  void setGpgCheck( TriBool value_r );
313  void setGpgCheck( bool value_r );
314 
316  bool repoGpgCheck() const;
318  bool repoGpgCheckIsMandatory() const;
320  void setRepoGpgCheck( TriBool value_r );
321 
323  bool pkgGpgCheck() const;
325  bool pkgGpgCheckIsMandatory() const;
327  void setPkgGpgCheck( TriBool value_r );
328 
332  TriBool validRepoSignature() const;
334  void setValidRepoSignature( TriBool value_r );
335 
337  struct GpgCheckDef {
338  enum Enum {
339  indeterminate, //< not specified
340  On, //< 1** --gpgcheck
341  Strict, //< 111 --gpgcheck-strict
342  AllowUnsigned, //< 100 --gpgcheck-allow-unsigned
343  AllowUnsignedRepo, //< 10* --gpgcheck-allow-unsigned-repo
344  AllowUnsignedPackage, //< 1*0 --gpgcheck-allow-unsigned-package
345  Default, //< *** --default-gpgcheck
346  Off, //< 0** --no-gpgcheck
347  };
348  };
349  typedef base::EnumClass<GpgCheckDef> GpgCheck;
350 
355  bool setGpgCheck( GpgCheck mode_r );
357 
358 
360  bool gpgKeyUrlsEmpty() const;
363 
365  url_set gpgKeyUrls() const;
367  url_set rawGpgKeyUrls() const;
369  void setGpgKeyUrls( url_set urls );
370 
372  Url gpgKeyUrl() const;
374  Url rawGpgKeyUrl() const;
376  void setGpgKeyUrl( const Url &gpgkey );
377 
378 
382  bool keepPackages() const;
392  void setKeepPackages( bool keep );
393 
398  std::string service() const;
402  void setService( const std::string& name );
403 
407  std::string targetDistribution() const;
413  void setTargetDistribution(const std::string & targetDistribution);
414 
416  void addContent( const std::string & keyword_r );
418  template <class _Iterator>
419  void addContentFrom( _Iterator begin_r, _Iterator end_r )
420  { for_( it, begin_r, end_r ) addContent( *it ); }
422  template <class _Container>
423  void addContentFrom( const _Container & container_r )
424  { addContentFrom( container_r.begin(), container_r.end() ); }
425 
431  bool hasContent( const std::string & keyword_r = std::string() ) const;
433  template <class _Iterator>
434  bool hasContentAll( _Iterator begin_r, _Iterator end_r ) const
435  { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
437  template <class _Container>
438  bool hasContentAll( const _Container & container_r ) const
439  { return hasContentAll( container_r.begin(), container_r.end() ); }
441  template <class _Iterator>
442  bool hasContentAny( _Iterator begin_r, _Iterator end_r ) const
443  { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
445  template <class _Container>
446  bool hasContentAny( const _Container & container_r ) const
447  { return hasContentAny( container_r.begin(), container_r.end() ); }
448 
449  public:
454  bool hasLicense() const;
455 
459  bool needToAcceptLicense() const;
460 
462  std::string getLicense( const Locale & lang_r = Locale() ) const;
463  std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
464 
471 
472  public:
477  virtual std::ostream & dumpOn( std::ostream & str ) const;
478 
483  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
484 
493  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
494 
495  class Impl;
496  private:
497  friend class RepoManager;
499  void getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const;
500 
503  };
505 
507  typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
509  typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
511  typedef std::list<RepoInfo> RepoInfoList;
512 
514  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
515 
517  std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj );
518 
520 } // namespace zypp
522 #endif // ZYPP2_REPOSITORYINFO_H
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:629
std::string name() const
Repository name.
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:519
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition: RepoInfo.cc:489
bool hasContentAll(const _Container &container_r) const
Definition: RepoInfo.h:438
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
Definition: RepoInfo.cc:423
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:299
bool hasContentAll(_Iterator begin_r, _Iterator end_r) const
Definition: RepoInfo.h:434
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition: RepoInfo.cc:522
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:709
void addContentFrom(_Iterator begin_r, _Iterator end_r)
Definition: RepoInfo.h:419
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:302
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:502
shared_ptr< RepoInfo > RepoInfo_Ptr
Definition: RepoInfo.h:507
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:495
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:417
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:525
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:474
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:331
std::list< Url > url_set
Definition: RepoInfo.h:100
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:452
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:341
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:309
#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:437
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:528
shared_ptr< const RepoInfo > RepoInfo_constPtr
Definition: RepoInfo.h:509
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:477
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:296
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:356
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:316
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
Definition: RepoInfo.cc:498
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:29
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:102
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition: RepoInfo.cc:334
RepoInfo implementation.
Definition: RepoInfo.cc:43
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:471
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:555
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:486
virtual ~RepoInfo()
Definition: RepoInfo.cc:293
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:327
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:483
Provides API related macros.
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:446
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:465
void setMetadataPath(const Pathname &path)
set the path where the local metadata is stored
Definition: RepoInfo.cc:456
bool gpgCheck() const
Whether default signature checking should be performed.
Definition: RepoInfo.cc:306
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition: RepoInfo.cc:492
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:449
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:537
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:462
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:516
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:429
SolvableIdType size_type
Definition: PoolMember.h:147
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:459
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:507
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:510
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:534
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:420
creates and provides information about known sources.
Definition: RepoManager.h:105
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:480
url_set::size_type urls_size_type
Definition: RepoInfo.h:101
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:468
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:587
bool hasContentAny(const _Container &container_r) const
Definition: RepoInfo.h:446
Some predefined settings (use like 'enum class GpgCheck')
Definition: RepoInfo.h:337
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:549
bool hasContent(const std::string &keyword_r=std::string()) const
Check for content keywords.
Definition: RepoInfo.cc:544
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition: RepoInfo.cc:319
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition: RepoInfo.cc:501
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:128
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition: RepoInfo.cc:443
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:81
std::list< RepoInfo > RepoInfoList
Definition: RepoInfo.h:511
base::EnumClass< GpgCheckDef > GpgCheck
'enum class GpgCheck'
Definition: RepoInfo.h:349
bool hasContentAny(_Iterator begin_r, _Iterator end_r) const
Definition: RepoInfo.h:442
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:541
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:763
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Definition: RepoInfo.cc:349
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:531
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:337
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) ...
Definition: RepoInfo.cc:504
Url manipulation class.
Definition: Url.h:87
Pathname path() const
Repository path.
Definition: RepoInfo.cc:513
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:662
Repository type enumeration.
Definition: RepoType.h:27
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
Definition: RepoInfo.cc:796
void addContentFrom(const _Container &container_r)
Definition: RepoInfo.h:423