libzypp 17.37.11
RepoManager.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_REPOMANAGER_H
13#define ZYPP_REPOMANAGER_H
14
15#include <iosfwd>
16#include <list>
17
18#include <zypp/base/PtrTypes.h>
19#include <zypp/base/Iterator.h>
20#include <zypp/base/Flags.h>
21
22#include <zypp/Pathname.h>
23#include <zypp/ZConfig.h>
24#include <zypp/RepoInfo.h>
26#include <zypp/repo/RepoType.h>
28#include <zypp/ServiceInfo.h>
29#include <zypp/RepoStatus.h>
32#include <utility>
33#include <zypp-core/ui/ProgressData>
34
36namespace zypp
37{
38
52 std::list<RepoInfo> readRepoFile(const Url & repo_file) ZYPP_API;
53
59 {
60 friend std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
61
62 public:
64 struct Impl;
65
67 using ServiceSet = std::set<ServiceInfo>;
68 using ServiceConstIterator = ServiceSet::const_iterator;
69 using ServiceSizeType = ServiceSet::size_type;
70
72 using RepoSet = std::set<RepoInfo>;
73 using RepoConstIterator = RepoSet::const_iterator;
74 using RepoSizeType = RepoSet::size_type;
75
76 public:
80
85
87 static constexpr CacheBuildPolicy BuildIfNeeded = CacheBuildPolicy::BuildIfNeeded;
88 static constexpr CacheBuildPolicy BuildForced = CacheBuildPolicy::BuildForced;
89
92 static constexpr RefreshServiceBit RefreshService_restoreStatus = RefreshServiceBit::RefreshService_restoreStatus;
93 static constexpr RefreshServiceBit RefreshService_forceRefresh = RefreshServiceBit::RefreshService_forceRefresh;
94
95 using RefreshServiceFlags = RepoManagerFlags::RefreshServiceFlags;
96
98 using RefreshServiceOptions = RepoManagerFlags::RefreshServiceFlags;
99
107 bool repoEmpty() const;
108 RepoSizeType repoSize() const;
112
114 std::list<RepoInfo> knownRepositories() const
115 { return std::list<RepoInfo>(repoBegin(),repoEnd()); }
116
118 RepoInfo getRepo( const std::string & alias ) const;
120 RepoInfo getRepo( const RepoInfo & info_r ) const
121 { return getRepo( info_r.alias() ); }
122
124 bool hasRepo( const std::string & alias ) const;
126 bool hasRepo( const RepoInfo & info_r ) const
127 { return hasRepo( info_r.alias() ); }
128
132 static std::string makeStupidAlias( const Url & url_r = Url() );
134
138 RepoStatus metadataStatus( const RepoInfo &info ) const;
139
141 static constexpr RefreshCheckStatus REFRESH_NEEDED = RefreshCheckStatus::REFRESH_NEEDED;
142 static constexpr RefreshCheckStatus REPO_UP_TO_DATE = RefreshCheckStatus::REPO_UP_TO_DATE;
143 static constexpr RefreshCheckStatus REPO_CHECK_DELAYED = RefreshCheckStatus::REPO_CHECK_DELAYED;
144
200 const Url &url,
202
211 const zypp::MirroredOrigin &origin,
213
224 Pathname metadataPath( const RepoInfo &info ) const;
225
226
237 Pathname packagesPath( const RepoInfo &info ) const;
238
239
255 void refreshMetadata( const RepoInfo &info,
258
267 void cleanMetadata( const RepoInfo &info,
269
278 void cleanPackages( const RepoInfo &info,
280
284 RepoStatus cacheStatus( const RepoInfo &info ) const;
285
305 void buildCache( const RepoInfo &info,
308
321 void cleanCache( const RepoInfo &info,
323
329 bool isCached( const RepoInfo &info ) const;
330
331
341 void loadFromCache( const RepoInfo &info,
343
352
360 repo::RepoType probe( const Url & url, const Pathname & path ) const;
364 repo::RepoType probe( const Url & url ) const;
365
366
381 void addRepository( const RepoInfo &info,
383
396 void addRepositories( const Url &url,
403 void removeRepository( const RepoInfo & info,
405
415 void modifyRepository( const std::string &alias,
416 const RepoInfo & newinfo,
419 void modifyRepository( const RepoInfo & newinfo,
421 { modifyRepository( newinfo.alias(), newinfo, progressrcv ); }
422
436 RepoInfo getRepositoryInfo( const std::string &alias,
438
458 RepoInfo getRepositoryInfo( const Url & url,
459 const url::ViewOption & urlview = url::ViewOption::DEFAULTS,
461
462
470
475 bool serviceEmpty() const;
476
482 ServiceSizeType serviceSize() const;
483
489 ServiceConstIterator serviceBegin() const;
490
495 ServiceConstIterator serviceEnd() const;
496
498 Iterable<ServiceConstIterator> services() const;
499
501 std::list<ServiceInfo> knownServices() const
502 { return std::list<ServiceInfo>(serviceBegin(),serviceEnd()); }
503
510 ServiceInfo getService( const std::string & alias ) const;
511
513 bool hasService( const std::string & alias ) const;
515
519 repo::ServiceType probeService( const Url &url ) const;
520
529 void addService( const std::string & alias, const Url& url );
530
538 void addService( const ServiceInfo & service );
539
548 void removeService( const std::string & alias );
550 void removeService( const ServiceInfo & service );
551
552
558 void refreshServices( const RefreshServiceOptions & options_r = RefreshServiceOptions() );
559
568 void refreshService( const std::string & alias, const RefreshServiceOptions & options_r = RefreshServiceOptions() );
570 void refreshService( const ServiceInfo & service, const RefreshServiceOptions & options_r = RefreshServiceOptions() );
571
588 void modifyService( const std::string & oldAlias, const ServiceInfo & service );
590 void modifyService( const ServiceInfo & service )
591 { modifyService( service.alias(), service ); }
592
597 void refreshGeoIp ( const RepoInfo::url_set &urls );
598
599 private:
604 {
605 public:
606 MatchServiceAlias( std::string alias_ ) : alias(std::move(alias_)) {}
607 bool operator()( const RepoInfo & info ) const
608 { return info.service() == alias; }
609 private:
610 std::string alias;
611 };
612
613 public:
614
647 template<typename OutputIterator>
648 void getRepositoriesInService( const std::string & alias,
649 OutputIterator out ) const
650 {
652
653 std::copy( boost::make_filter_iterator( filter, repoBegin(), repoEnd() ),
654 boost::make_filter_iterator( filter, repoEnd(), repoEnd() ),
655 out);
656 }
657
658 private:
661 };
662
663
665 std::ostream & operator<<( std::ostream & str, const RepoManager & obj ) ZYPP_API;
666
670
674
676} // namespace zypp
678#endif // ZYPP2_REPOMANAGER_H
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
convenient construction.
Definition Iterable.h:88
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
What is known about a repository.
Definition RepoInfo.h:72
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:778
std::list< Url > url_set
Definition RepoInfo.h:108
creates and provides information about known sources.
Definition RepoManager.h:59
bool hasRepo(const std::string &alias) const
Return whether there is a known repository for alias.
static constexpr RefreshCheckStatus REPO_UP_TO_DATE
repository not changed
void cleanCacheDirGarbage(const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove any subdirectories of cache directories which no longer belong to any of known repositories.
void cleanMetadata(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local metadata.
static constexpr RawMetadataRefreshPolicy RefreshIfNeeded
Definition RepoManager.h:82
RepoInfo getRepo(const RepoInfo &info_r) const
static constexpr RawMetadataRefreshPolicy RefreshIfNeededIgnoreDelay
Definition RepoManager.h:84
ServiceSet::const_iterator ServiceConstIterator
Definition RepoManager.h:68
static constexpr RefreshServiceBit RefreshService_restoreStatus
Definition RepoManager.h:92
static constexpr CacheBuildPolicy BuildForced
Definition RepoManager.h:88
bool isCached(const RepoInfo &info) const
Whether a repository exists in cache.
bool hasRepo(const RepoInfo &info_r) const
RepoInfo getRepo(const std::string &alias) const
Find RepoInfo by alias or return RepoInfo::noRepo.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
std::list< ServiceInfo > knownServices() const
List of known services.
RepoManagerFlags::RawMetadataRefreshPolicy RawMetadataRefreshPolicy
Definition RepoManager.h:81
void cleanCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
clean local cache
void addRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds a repository to the list of known repositories.
bool repoEmpty() const
Pathname metadataPath(const RepoInfo &info) const
Path where the metadata is downloaded and kept.
static constexpr RefreshServiceBit RefreshService_forceRefresh
Definition RepoManager.h:93
ServiceSet::size_type ServiceSizeType
Definition RepoManager.h:69
RepoManagerFlags::RefreshServiceFlags RefreshServiceFlags
Definition RepoManager.h:95
Pathname packagesPath(const RepoInfo &info) const
Path where the rpm packages are downloaded and kept.
RepoStatus cacheStatus(const RepoInfo &info) const
Status of metadata cache.
void addRepositories(const Url &url, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds repositores from a repo file to the list of known repositories.
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy=RefreshIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local raw cache.
static constexpr RefreshCheckStatus REFRESH_NEEDED
refresh is needed
ServiceConstIterator serviceEnd() const
Iterator to place behind last service in internal storage.
RepoManagerFlags::CacheBuildPolicy CacheBuildPolicy
Definition RepoManager.h:86
static constexpr RefreshCheckStatus REPO_CHECK_DELAYED
refresh is delayed due to settings
static constexpr RawMetadataRefreshPolicy RefreshForced
Definition RepoManager.h:83
ServiceConstIterator serviceBegin() const
Iterator to first service in internal storage.
RepoManagerFlags::RefreshCheckStatus RefreshCheckStatus
void modifyService(const ServiceInfo &service)
RepoSizeType repoSize() const
void modifyRepository(const std::string &alias, const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Modify repository attributes.
Iterable< ServiceConstIterator > services() const
Iterate the known services.
void removeRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove the best matching repository from known repos list.
void modifyRepository(const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
static constexpr CacheBuildPolicy BuildIfNeeded
Definition RepoManager.h:87
RepoManagerFlags::RefreshServiceBit RefreshServiceBit
Flags for tuning RefreshService.
Definition RepoManager.h:91
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy=RefreshIfNeeded)
Checks whether to refresh metadata for specified repository and url.
RepoSet::size_type RepoSizeType
Definition RepoManager.h:74
std::list< RepoInfo > knownRepositories() const
List of known repositories.
RepoConstIterator repoBegin() const
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
Definition RepoManager.h:72
Iterable< RepoConstIterator > repos() const
Iterate the known repositories.
void buildCache(const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local cache.
RepoManagerFlags::RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
Definition RepoManager.h:98
RepoManager(RepoManagerOptions options=RepoManagerOptions())
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
fill to output iterator repositories in service name.
void loadFromCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Load resolvables into the pool.
void cleanPackages(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local package cache.
RepoConstIterator repoEnd() const
void modifyService(const std::string &oldAlias, const ServiceInfo &service)
Modifies service file (rewrites it with new values) and underlying repositories if needed.
RepoSet::const_iterator RepoConstIterator
Definition RepoManager.h:73
repo::RepoType probe(const Url &url, const Pathname &path) const
Probe repo metadata type.
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
Definition RepoManager.h:67
Track changing files or directories.
Definition RepoStatus.h:41
Service data.
Definition ServiceInfo.h:37
Url manipulation class.
Definition Url.h:93
std::string alias() const
unique identifier for this source.
Definition Arch.h:364
String related utilities and Regular expression matching.
RefreshCheckStatus
Possibly return state of RepoManager::checkIfToRefreshMetadata function.
RefreshServiceBit
Flags for tuning RefreshService.
Url details namespace.
Definition UrlBase.cc:58
Easy-to use interface to the ZYPP dependency resolver.
std::list< RepoInfo > readRepoFile(const Url &repo_file)
Parses repo_file and returns a list of RepoInfo objects corresponding to repositories found within th...
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
RW_pointer supporting 'copy on write' functionality.
Definition PtrTypes.h:469
Repo manager settings.
RepoManager implementation.
Functor thats filter RepoInfo by service which it belongs to.
MatchServiceAlias(std::string alias_)
bool operator()(const RepoInfo &info) const
Repository type enumeration.
Definition RepoType.h:29
Service type enumeration.
Definition ServiceType.h:27
Url::asString() view options.
Definition UrlBase.h:41