libzypp: zypp/RepoInfo.h Source File

libzypp 17.38.14

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-core/base/Iterator.h>
19#include <zypp-core/Globals.h>
20#include <zypp-core/MirroredOrigin.h>
21#include <zypp-core/TriBool.h>
22#include <zypp-core/Url.h>
23
24#include <zypp/Locale.h>
25#include <zypp/repo/RepoType.h>
26#include <zypp/repo/RepoVariables.h>
27#include <zypp/repo/RepoInfoBase.h>
28
30namespace zypp
31{
32
34 //
35 // CLASS NAME : RepoInfo
36 //
71 class ZYPP_API RepoInfo : public repo::RepoInfoBase
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;
110 using urls_const_iterator = transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator>;
114 bool baseUrlsEmpty() const;
119 bool baseUrlSet() const;
123 urls_size_type baseUrlsSize() const;
127 urls_const_iterator baseUrlsBegin() const;
131 urls_const_iterator baseUrlsEnd() const;
132
137 Url url() const;
142 Url rawUrl() const;
143
149 Url location() const;
150
154 url_set baseUrls() const;
158 url_set rawBaseUrls() const;
159
167 void addBaseUrl( Url url );
171 void setBaseUrl( Url url );
175 void setBaseUrls( url_set urls );
176
187 MirroredOriginSet repoOrigins() const;
188
192 bool repoOriginsEmpty() const;
193
214 Pathname path() const;
219 void setPath( const Pathname &path );
220
225 Url mirrorListUrl() const;
230 Url rawMirrorListUrl() const;
231
233 void setMirrorlistUrl( const Url &url );
235 void setMetalinkUrl( const Url &url );
236
238 Url rawCfgMirrorlistUrl() const;
240 Url rawCfgMetalinkUrl() const;
241
242#if LEGACY(1735)
247 void setMirrorListUrl( const Url &url ) ZYPP_DEPRECATED;
249 void setMetalinkUrls( url_set urls ) ZYPP_DEPRECATED;
251 void setMirrorListUrls( url_set urls ) ZYPP_DEPRECATED;
252#endif
253
258 repo::RepoType type() const;
265 void setProbedType( const repo::RepoType &t ) const;
270 void setType( const repo::RepoType &t );
271
278 Pathname metadataPath() const;
305 void setMetadataPath( const Pathname &path );
306
308 bool usesAutoMetadataPaths() const;
309
314 Pathname systemPackagesPath() const;
315
322 Pathname packagesPath() const;
323
329 void setPackagesPath( const Pathname &path );
330
334 Pathname predownloadPath() const;
335
336
393
394 bool gpgCheck() const;
396 void setGpgCheck( TriBool value_r );
398 void setGpgCheck( bool value_r );
399
401 bool repoGpgCheck() const;
403 bool repoGpgCheckIsMandatory() const;
405 void setRepoGpgCheck( TriBool value_r );
406
408 bool pkgGpgCheck() const;
410 bool pkgGpgCheckIsMandatory() const;
412 void setPkgGpgCheck( TriBool value_r );
413
417 TriBool validRepoSignature() const;
419 void setValidRepoSignature( TriBool value_r );
420
422 enum class GpgCheck {
423 indeterminate, //< not specified
424 On, //< 1** --gpgcheck
425 Strict, //< 111 --gpgcheck-strict
426 AllowUnsigned, //< 100 --gpgcheck-allow-unsigned
427 AllowUnsignedRepo, //< 10* --gpgcheck-allow-unsigned-repo
428 AllowUnsignedPackage, //< 1*0 --gpgcheck-allow-unsigned-package
429 Default, //< *** --default-gpgcheck
430 Off, //< 0** --no-gpgcheck
431 };
432
437 bool setGpgCheck( GpgCheck mode_r );
439
440
442 bool gpgKeyUrlsEmpty() const;
444 urls_size_type gpgKeyUrlsSize() const;
445
447 url_set gpgKeyUrls() const;
449 url_set rawGpgKeyUrls() const;
451 void setGpgKeyUrls( url_set urls );
452
454 Url gpgKeyUrl() const;
456 Url rawGpgKeyUrl() const;
458 void setGpgKeyUrl( const Url &gpgkey );
459
463 bool keepPackages() const;
473 void setKeepPackages( bool keep );
474
479 bool effectiveKeepPackages() const;
480
485 std::string service() const;
489 void setService( const std::string& name );
490
494 std::string targetDistribution() const;
500 void setTargetDistribution(const std::string & targetDistribution);
501
502
504 const std::set<std::string> & contentKeywords() const;
505
507 void addContent( const std::string & keyword_r );
509 template <class TIterator>
510 void addContentFrom( TIterator begin_r, TIterator end_r )
511 { for_( it, begin_r, end_r ) addContent( *it ); }
512
513 template <class TContainer>
514 void addContentFrom( const TContainer & container_r )
515 { addContentFrom( container_r.begin(), container_r.end() ); }
516
520 bool hasContent() const;
522 bool hasContent( const std::string & keyword_r ) const;
524 template <class TIterator>
525 bool hasContentAll( TIterator begin_r, TIterator end_r ) const
526 { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
527
528 template <class TContainer>
529 bool hasContentAll( const TContainer & container_r ) const
530 { return hasContentAll( container_r.begin(), container_r.end() ); }
531
532 template <class TIterator>
533 bool hasContentAny( TIterator begin_r, TIterator end_r ) const
534 { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
535
536 template <class TContainer>
537 bool hasContentAny( const TContainer & container_r ) const
538 { return hasContentAny( container_r.begin(), container_r.end() ); }
539
540 public:
553
554 bool hasLicense() const;
556 bool hasLicense( const std::string & name_r ) const;
557
561 bool needToAcceptLicense() const;
563 bool needToAcceptLicense( const std::string & name_r ) const;
564
566 std::string getLicense( const Locale & lang_r = Locale() ) const;
568 std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
570 std::string getLicense( const std::string & name_r, const Locale & lang_r = Locale() ) const;
571
576 LocaleSet getLicenseLocales() const;
578 LocaleSet getLicenseLocales( const std::string & name_r ) const;
580
585 bool requireStatusWithMediaFile () const;
586
587 public:
598
599 bool hasExtraValue( const std::string & key_r ) const;
600
602 std::string extraValue( const std::string & key_r ) const;
603
607 bool setExtraValue( const std::string & key_r, std::string value_r );
608
610 template <typename Fnc>
611 std::string extraValue( const std::string & key_r, Fnc && genDefault_r ) const
612 { return hasExtraValue( key_r ) ? extraValue( key_r ) : genDefault_r(); }
613
614
615 public:
620 std::ostream & dumpOn( std::ostream & str ) const override;
621
626 std::ostream & dumpAsIniOn( std::ostream & str ) const override;
627
636 std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const override;
637
641 void getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const;
642
648 std::string repoStatusString() const;
649
650 struct Impl;
651 private:
652 friend class RepoManager;
653
655 RWCOW_pointer<Impl> _pimpl;
656 };
657
658
660 using RepoInfo_Ptr = shared_ptr<RepoInfo>;
662 using RepoInfo_constPtr = shared_ptr<const RepoInfo>;
664 using RepoInfoList = std::list<RepoInfo>;
665
667 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj ) ZYPP_API;
668
670 std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj ) ZYPP_API;
671
673} // namespace zypp
675#endif // ZYPP2_REPOSITORYINFO_H
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
Globals.h
Provides API related macros.
ZYPP_DEPRECATED
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3....
Definition Globals.h:112
Iterator.h
Locale.h
MirroredOrigin.h
RepoInfoBase.h
RepoType.h
RepoVariables.h
TriBool.h
Url.h
Impl
shared_ptr
transform_iterator
An iterator over elements which are the result of applying some functional transformation to the elem...
zypp::Locale
'Language[_Country]' codes.
Definition Locale.h:51
zypp::Locale::Locale
Locale()
Default Ctor: noCode.
Definition Locale.cc:180
zypp::MirroredOriginSet
A smart container that manages a collection of MirroredOrigin objects, automatically grouping endpoin...
Definition MirroredOrigin.h:336
zypp::RepoInfo
What is known about a repository.
Definition RepoInfo.h:72
zypp::RepoInfo::setPkgGpgCheck
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition RepoInfo.cc:654
zypp::RepoInfo::setMetalinkUrl
void setMetalinkUrl(const Url &url)
Set the raw metalink url.
Definition RepoInfo.cc:737
zypp::RepoInfo::metadataPath
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition RepoInfo.cc:834
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:537
zypp::RepoInfo::hasExtraValue
bool hasExtraValue(const std::string &key_r) const
Whether an extra value for key_r is set.
Definition RepoInfo.cc:1263
zypp::RepoInfo::RepoInfo
RepoInfo(RepoInfo &&)=default
zypp::RepoInfo::setMirrorlistUrl
void setMirrorlistUrl(const Url &url)
Set the raw mirrorlist url.
Definition RepoInfo.cc:734
zypp::RepoInfo::urls_size_type
url_set::size_type urls_size_type
Definition RepoInfo.h:109
zypp::RepoInfo::usesAutoMetadataPaths
bool usesAutoMetadataPaths() const
Whether metadataPath uses AUTO% setup.
Definition RepoInfo.cc:843
zypp::RepoInfo::addContentFrom
void addContentFrom(TIterator begin_r, TIterator end_r)
Definition RepoInfo.h:510
zypp::RepoInfo::GpgCheck
GpgCheck
Some predefined settings.
Definition RepoInfo.h:422
zypp::RepoInfo::baseUrlsEmpty
bool baseUrlsEmpty() const
whether repository urls are available
Definition RepoInfo.cc:903
zypp::RepoInfo::predownloadPath
Pathname predownloadPath() const
Path where this repo packages are predownloaded.
Definition RepoInfo.cc:816
zypp::RepoInfo::hasContent
bool hasContent() const
Check for content keywords.
Definition RepoInfo.cc:920
zypp::RepoInfo::repoOrigins
MirroredOriginSet repoOrigins() const
The repodata origins.
Definition RepoInfo.cc:790
zypp::RepoInfo::urls_const_iterator
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition RepoInfo.h:110
zypp::RepoInfo::rawUrl
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced) this is either rawBaseUrls()....
Definition RepoInfo.cc:888
zypp::RepoInfo::type
repo::RepoType type() const
Type of repository,.
Definition RepoInfo.cc:846
zypp::RepoInfo::operator=
RepoInfo & operator=(const RepoInfo &)=default
zypp::RepoInfo::noPriority
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition RepoInfo.cc:616
zypp::RepoInfo::baseUrlsSize
urls_size_type baseUrlsSize() const
number of repository urls
Definition RepoInfo.cc:900
zypp::RepoInfo::url
Url url() const
Pars pro toto: The first repository url, this is either baseUrls().front() or if no baseUrl is define...
Definition RepoInfo.cc:909
zypp::RepoInfo::noRepo
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition RepoInfo.h:85
zypp::RepoInfo::setBaseUrl
void setBaseUrl(Url url)
Clears current base URL list and adds url.
Definition RepoInfo.cc:777
zypp::RepoInfo::baseUrlsEnd
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition RepoInfo.cc:897
zypp::RepoInfo::location
Url location() const
Returns the location URL for the repository, this is either the first configured baseUrl or a configu...
Definition RepoInfo.cc:891
zypp::RepoInfo::setPackagesPath
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition RepoInfo.cc:813
zypp::RepoInfo::rawCfgMetalinkUrl
Url rawCfgMetalinkUrl() const
The configured raw metalink url.
Definition RepoInfo.cc:743
zypp::RepoInfo::baseUrlSet
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition RepoInfo.cc:906
zypp::RepoInfo::setGpgCheck
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition RepoInfo.cc:626
zypp::RepoInfo::path
Pathname path() const
Repository path.
Definition RepoInfo.cc:879
zypp::RepoInfo::baseUrls
url_set baseUrls() const
The complete set of repository urls as configured.
Definition RepoInfo.cc:873
zypp::RepoInfo::addBaseUrl
void addBaseUrl(Url url)
Add a base url.
Definition RepoInfo.cc:767
zypp::RepoInfo::pkgGpgCheckIsMandatory
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition RepoInfo.cc:651
zypp::RepoInfo::rawBaseUrls
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced).
Definition RepoInfo.cc:876
zypp::RepoInfo::hasContentAny
bool hasContentAny(TIterator begin_r, TIterator end_r) const
Definition RepoInfo.h:533
zypp::RepoInfo::mirrorListUrl
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition RepoInfo.cc:849
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:806
zypp::RepoInfo::setBaseUrls
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition RepoInfo.cc:784
zypp::RepoInfo::priority
unsigned priority() const
Repository priority for solver.
Definition RepoInfo.cc:610
zypp::RepoInfo::gpgCheck
bool gpgCheck() const
Whether default signature checking should be performed.
Definition RepoInfo.cc:623
zypp::RepoInfo::setPath
void setPath(const Pathname &path)
set the product path.
Definition RepoInfo.cc:800
zypp::RepoInfo::setValidRepoSignature
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition RepoInfo.cc:673
zypp::RepoInfo::RepoInfo
RepoInfo()
Definition RepoInfo.cc:603
zypp::RepoInfo::defaultPriority
static unsigned defaultPriority()
The default priority (99).
Definition RepoInfo.cc:613
zypp::RepoInfo::setPriority
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition RepoInfo.cc:619
zypp::RepoInfo::RepoInfo
RepoInfo(const RepoInfo &)=default
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:514
zypp::RepoInfo::_pimpl
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition RepoInfo.h:655
zypp::RepoInfo::baseUrlsBegin
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition RepoInfo.cc:894
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:529
zypp::RepoInfo::repoGpgCheckIsMandatory
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition RepoInfo.cc:636
zypp::RepoInfo::RepoManager
friend class RepoManager
Definition RepoInfo.h:652
zypp::RepoInfo::setMetadataPath
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Definition RepoInfo.cc:810
zypp::RepoInfo::validRepoSignature
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned.
Definition RepoInfo.cc:666
zypp::RepoInfo::setRepoGpgCheck
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition RepoInfo.cc:644
zypp::RepoInfo::operator<<
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
relates: RepoInfo Stream output
Definition RepoInfo.cc:1217
zypp::RepoInfo::packagesPath
Pathname packagesPath() const
packagesPath Checks if the effective user is allowed to write into the system package cache.
Definition RepoInfo.cc:840
zypp::RepoInfo::hasContentAll
bool hasContentAll(TIterator begin_r, TIterator end_r) const
Definition RepoInfo.h:525
zypp::RepoInfo::addContent
void addContent(const std::string &keyword_r)
Add content keywords.
Definition RepoInfo.cc:917
zypp::RepoInfo::repoGpgCheck
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition RepoInfo.cc:633
zypp::RepoInfo::setType
void setType(const repo::RepoType &t)
set the repository type
Definition RepoInfo.cc:803
zypp::RepoInfo::pkgGpgCheck
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition RepoInfo.cc:648
zypp::RepoInfo::url_set
std::list< Url > url_set
Definition RepoInfo.h:108
zypp::RepoInfo::rawMirrorListUrl
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition RepoInfo.cc:852
zypp::RepoInfo::operator=
RepoInfo & operator=(RepoInfo &&)=default
zypp::RepoInfo::extraValue
std::string extraValue(const std::string &key_r) const
Return extra value for key_r or throws std::out_of_range.
Definition RepoInfo.cc:1266
zypp::RepoInfo::systemPackagesPath
Pathname systemPackagesPath() const
Returns a path to the system-defined package cache.
Definition RepoInfo.cc:837
zypp::RepoInfo::rawCfgMirrorlistUrl
Url rawCfgMirrorlistUrl() const
The configured raw mirrorlist url.
Definition RepoInfo.cc:740
zypp::RepoInfo::extraValue
std::string extraValue(const std::string &key_r, Fnc &&genDefault_r) const
Return extra value for key_r or the value returned by genDefault_r.
Definition RepoInfo.h:611
zypp::RepoInfo::repoOriginsEmpty
bool repoOriginsEmpty() const
whether repo origins are available
Definition RepoInfo.cc:795
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::repo::RepoInfoBase
Base class implementing common features of RepoInfo and ServiceInfo.
Definition RepoInfoBase.h:40
zypp::TriBool
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:31
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::RepoInfoList
std::list< RepoInfo > RepoInfoList
relates: RepoInfo
Definition RepoInfo.h:664
zypp::LocaleSet
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
zypp::ResolverFocus::Default
@ Default
Request the standard behavior (as defined in zypp.conf or 'Job').
Definition ResolverFocus.h:25
zypp::dumpAsXmlOn
std::ostream & dumpAsXmlOn(std::ostream &str, const Repository &obj)
relates: Repository XML output
Definition Repository.cc:411
zypp::RepoInfo_Ptr
shared_ptr< RepoInfo > RepoInfo_Ptr
relates: RepoInfo
Definition RepoInfo.h:660
zypp::RepoInfo_constPtr
shared_ptr< const RepoInfo > RepoInfo_constPtr
relates: RepoInfo
Definition RepoInfo.h:662
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
relates: Capability Detailed stream output
Definition Capability.cc:589
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Definition Capabilities.cc:65
zypp::RWCOW_pointer
RW_pointer supporting 'copy on write' functionality.
Definition PtrTypes.h:469
zypp::repo::RepoType
Repository type enumeration.
Definition RepoType.h:29