libzypp 17.32.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
28
30namespace 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 ~RepoInfo() override;
78
79 RepoInfo(const RepoInfo &) = default;
80 RepoInfo(RepoInfo &&) = default;
81 RepoInfo &operator=(const RepoInfo &) = default;
82 RepoInfo &operator=(RepoInfo &&) = default;
83
85 static const RepoInfo noRepo;
86
87 public:
91 static unsigned defaultPriority();
95 static unsigned noPriority();
100 unsigned priority() const;
106 void setPriority( unsigned newval_r );
107
108 using url_set = std::list<Url>;
109 using urls_size_type = url_set::size_type;
114 bool baseUrlsEmpty() const;
119 bool baseUrlSet() const;
132
136 Url url() const
137 { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
141 Url rawUrl() const;
142
149 url_set baseUrls() const;
153 url_set rawBaseUrls() const;
154
162 void addBaseUrl( Url url );
166 void setBaseUrl( Url url );
170 void setBaseUrls( url_set urls );
171
192 Pathname path() const;
197 void setPath( const Pathname &path );
198
202 Url mirrorListUrl() const;
206 Url rawMirrorListUrl() const;
211 void setMirrorListUrl( const Url &url );
213 void setMirrorListUrls( url_set urls );
214
216 void setMetalinkUrl( const Url &url );
218 void setMetalinkUrls( url_set urls );
219
224 repo::RepoType type() const;
231 void setProbedType( const repo::RepoType &t ) const;
236 void setType( const repo::RepoType &t );
237
244 Pathname metadataPath() const;
271 void setMetadataPath( const Pathname &path );
272
274 bool usesAutoMetadataPaths() const;
275
279 Pathname packagesPath() const;
285 void setPackagesPath( const Pathname &path );
286
287
345 bool gpgCheck() const;
349 void setGpgCheck( bool value_r );
350
352 bool repoGpgCheck() const;
354 bool repoGpgCheckIsMandatory() const;
357
359 bool pkgGpgCheck() const;
361 bool pkgGpgCheckIsMandatory() const;
364
371
373 enum class GpgCheck {
374 indeterminate, //< not specified
375 On, //< 1** --gpgcheck
376 Strict, //< 111 --gpgcheck-strict
377 AllowUnsigned, //< 100 --gpgcheck-allow-unsigned
378 AllowUnsignedRepo, //< 10* --gpgcheck-allow-unsigned-repo
379 AllowUnsignedPackage, //< 1*0 --gpgcheck-allow-unsigned-package
380 Default, //< *** --default-gpgcheck
381 Off, //< 0** --no-gpgcheck
382 };
383
390
391
393 bool gpgKeyUrlsEmpty() const;
396
398 url_set gpgKeyUrls() const;
400 url_set rawGpgKeyUrls() const;
402 void setGpgKeyUrls( url_set urls );
403
405 Url gpgKeyUrl() const;
407 Url rawGpgKeyUrl() const;
409 void setGpgKeyUrl( const Url &gpgkey );
410
412 Pathname provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r ) const;
413
417 bool keepPackages() const;
427 void setKeepPackages( bool keep );
428
433 std::string service() const;
437 void setService( const std::string& name );
438
442 std::string targetDistribution() const;
448 void setTargetDistribution(const std::string & targetDistribution);
449
450
452 const std::set<std::string> & contentKeywords() const;
453
455 void addContent( const std::string & keyword_r );
457 template <class TIterator>
458 void addContentFrom( TIterator begin_r, TIterator end_r )
459 { for_( it, begin_r, end_r ) addContent( *it ); }
461 template <class TContainer>
462 void addContentFrom( const TContainer & container_r )
463 { addContentFrom( container_r.begin(), container_r.end() ); }
464
468 bool hasContent() const;
470 bool hasContent( const std::string & keyword_r ) const;
472 template <class TIterator>
473 bool hasContentAll( TIterator begin_r, TIterator end_r ) const
474 { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
476 template <class TContainer>
477 bool hasContentAll( const TContainer & container_r ) const
478 { return hasContentAll( container_r.begin(), container_r.end() ); }
480 template <class TIterator>
481 bool hasContentAny( TIterator begin_r, TIterator end_r ) const
482 { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
484 template <class TContainer>
485 bool hasContentAny( const TContainer & container_r ) const
486 { return hasContentAny( container_r.begin(), container_r.end() ); }
487
488 public:
502 bool hasLicense() const;
504 bool hasLicense( const std::string & name_r ) const;
505
509 bool needToAcceptLicense() const;
511 bool needToAcceptLicense( const std::string & name_r ) const;
512
514 std::string getLicense( const Locale & lang_r = Locale() ) const;
516 std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
518 std::string getLicense( const std::string & name_r, const Locale & lang_r = Locale() ) const;
519
526 LocaleSet getLicenseLocales( const std::string & name_r ) const;
528
533 bool requireStatusWithMediaFile () const;
534
535 public:
540 std::ostream & dumpOn( std::ostream & str ) const override;
541
546 std::ostream & dumpAsIniOn( std::ostream & str ) const override;
547
556 std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const override;
557
558 struct Impl;
559 private:
560 friend class RepoManager;
562 void getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const;
563
566 };
568
574 using RepoInfoList = std::list<RepoInfo>;
575
577 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
578
580 std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj );
581
583} // namespace zypp
585#endif // ZYPP2_REPOSITORYINFO_H
RepoManager implementation.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
'Language[_Country]' codes.
Definition Locale.h:50
What is known about a repository.
Definition RepoInfo.h:72
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition RepoInfo.cc:442
std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const override
Write an XML representation of this RepoInfo object.
Definition RepoInfo.cc:901
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
Definition RepoInfo.cc:534
void setMirrorListUrls(url_set urls)
Like setMirrorListUrl but take an url_set.
Definition RepoInfo.cc:525
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition RepoInfo.cc:528
std::ostream & dumpOn(std::ostream &str) const override
Write a human-readable representation of this RepoInfo object into the str stream.
Definition RepoInfo.cc:798
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition RepoInfo.cc:593
bool hasContentAny(const TContainer &container_r) const
Definition RepoInfo.h:485
RepoInfo(RepoInfo &&)=default
url_set::size_type urls_size_type
Definition RepoInfo.h:109
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
Definition RepoInfo.cc:537
bool usesAutoMetadataPaths() const
Whether metadataPath uses AUTO% setup.
Definition RepoInfo.cc:599
void addContentFrom(TIterator begin_r, TIterator end_r)
Definition RepoInfo.h:458
GpgCheck
Some predefined settings.
Definition RepoInfo.h:373
bool baseUrlsEmpty() const
whether repository urls are available
Definition RepoInfo.cc:656
bool hasContent() const
Check for content keywords.
Definition RepoInfo.cc:668
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition RepoInfo.cc:581
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition RepoInfo.cc:617
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced)
Definition RepoInfo.cc:626
~RepoInfo() override
Definition RepoInfo.cc:395
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition RepoInfo.h:110
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition RepoInfo.cc:522
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition RepoInfo.cc:644
Pathname provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r) const
downloads all configured gpg keys into the defined directory
Definition RepoInfo.cc:544
repo::RepoType type() const
Type of repository,.
Definition RepoInfo.cc:602
std::list< RepoInfo > RepoInfoList
Definition RepoInfo.h:574
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
Definition RepoInfo.cc:620
RepoInfo & operator=(const RepoInfo &)=default
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition RepoInfo.cc:404
urls_size_type baseUrlsSize() const
number of repository urls
Definition RepoInfo.cc:653
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition RepoInfo.cc:590
Url url() const
Pars pro toto: The first repository url.
Definition RepoInfo.h:136
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition RepoInfo.h:85
void setBaseUrl(Url url)
Clears current base URL list and adds url.
Definition RepoInfo.cc:556
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Definition RepoInfo.cc:662
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition RepoInfo.cc:650
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition RepoInfo.cc:578
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition RepoInfo.cc:718
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition RepoInfo.cc:659
void setService(const std::string &name)
sets service which added this repository
Definition RepoInfo.cc:584
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition RepoInfo.cc:414
Pathname path() const
Repository path.
Definition RepoInfo.cc:635
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition RepoInfo.cc:614
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition RepoInfo.cc:762
url_set baseUrls() const
The complete set of repository urls.
Definition RepoInfo.cc:629
bool requireStatusWithMediaFile() const
Returns true if this repository requires the media.1/media file to be included in the metadata status...
Definition RepoInfo.cc:964
void addBaseUrl(Url url)
Add a base url.
Definition RepoInfo.cc:548
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition RepoInfo.cc:439
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition RepoInfo.cc:632
bool hasContentAny(TIterator begin_r, TIterator end_r) const
Definition RepoInfo.h:481
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition RepoInfo.cc:605
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:571
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition RepoInfo.cc:562
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:638
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition RepoInfo.cc:587
std::ostream & dumpAsIniOn(std::ostream &str) const override
Write this RepoInfo object into str in a .repo file format.
Definition RepoInfo.cc:846
unsigned priority() const
Repository priority for solver.
Definition RepoInfo.cc:398
bool gpgCheck() const
Whether default signature checking should be performed.
Definition RepoInfo.cc:411
void setPath(const Pathname &path)
set the product path.
Definition RepoInfo.cc:565
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition RepoInfo.cc:623
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition RepoInfo.cc:461
static unsigned defaultPriority()
The default priority (99).
Definition RepoInfo.cc:401
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition RepoInfo.cc:683
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition RepoInfo.cc:407
RepoInfo(const RepoInfo &)=default
void addContentFrom(const TContainer &container_r)
Definition RepoInfo.h:462
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition RepoInfo.h:565
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition RepoInfo.cc:647
bool hasContentAll(const TContainer &container_r) const
Definition RepoInfo.h:477
bool hasLicense() const
Whether there is a license associated with the repo.
Definition RepoInfo.cc:676
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition RepoInfo.cc:424
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Definition RepoInfo.cc:575
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned.
Definition RepoInfo.cc:454
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition RepoInfo.cc:432
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
Definition RepoInfo.cc:941
void setMetalinkUrls(url_set urls)
Like setMirrorListUrls but expect metalink format.
Definition RepoInfo.cc:531
Pathname packagesPath() const
Path where this repo packages are cached.
Definition RepoInfo.cc:596
bool hasContentAll(TIterator begin_r, TIterator end_r) const
Definition RepoInfo.h:473
void addContent(const std::string &keyword_r)
Add content keywords.
Definition RepoInfo.cc:665
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition RepoInfo.cc:421
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition RepoInfo.cc:641
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
Definition RepoInfo.cc:446
void setType(const repo::RepoType &t)
set the repository type
Definition RepoInfo.cc:568
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition RepoInfo.cc:436
std::list< Url > url_set
Definition RepoInfo.h:108
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition RepoInfo.cc:608
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition RepoInfo.cc:611
RepoInfo & operator=(RepoInfo &&)=default
Url manipulation class.
Definition Url.h:92
Base class implementing common features of RepoInfo and ServiceInfo.
std::string name() const
Repository name.
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
std::unordered_set< Locale > LocaleSet
Definition Locale.h:28
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:30
creates and provides information about known sources.
Repository type enumeration.
Definition RepoType.h:28
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:28