libzypp 17.32.5
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>
31#include <utility>
32#include <zypp-core/ui/ProgressData>
33
35namespace zypp
36{
37
51 std::list<RepoInfo> readRepoFile(const Url & repo_file);
52
57 class RepoManager
58 {
59 friend std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
60
61 public:
63 struct Impl;
64
66 using ServiceSet = std::set<ServiceInfo>;
67 using ServiceConstIterator = ServiceSet::const_iterator;
68 using ServiceSizeType = ServiceSet::size_type;
69
71 using RepoSet = std::set<RepoInfo>;
72 using RepoConstIterator = RepoSet::const_iterator;
73 using RepoSizeType = RepoSet::size_type;
74
75 public:
79
86
92
100
103
104
112 bool repoEmpty() const;
113 RepoSizeType repoSize() const;
117
119 std::list<RepoInfo> knownRepositories() const
120 { return std::list<RepoInfo>(repoBegin(),repoEnd()); }
121
123 RepoInfo getRepo( const std::string & alias ) const;
126 { return getRepo( info_r.alias() ); }
127
129 bool hasRepo( const std::string & alias ) const;
131 bool hasRepo( const RepoInfo & info_r ) const
132 { return hasRepo( info_r.alias() ); }
133
137 static std::string makeStupidAlias( const Url & url_r = Url() );
139
143 RepoStatus metadataStatus( const RepoInfo &info ) const;
144
153
209 const Url &url,
211
222 Pathname metadataPath( const RepoInfo &info ) const;
223
224
235 Pathname packagesPath( const RepoInfo &info ) const;
236
237
252 void refreshMetadata( const RepoInfo &info,
255
264 void cleanMetadata( const RepoInfo &info,
266
275 void cleanPackages( const RepoInfo &info,
277
281 RepoStatus cacheStatus( const RepoInfo &info ) const;
282
301 void buildCache( const RepoInfo &info,
304
317 void cleanCache( const RepoInfo &info,
319
325 bool isCached( const RepoInfo &info ) const;
326
327
337 void loadFromCache( const RepoInfo &info,
339
348
356 repo::RepoType probe( const Url & url, const Pathname & path ) const;
360 repo::RepoType probe( const Url & url ) const;
361
362
377 void addRepository( const RepoInfo &info,
379
392 void addRepositories( const Url &url,
399 void removeRepository( const RepoInfo & info,
401
411 void modifyRepository( const std::string &alias,
412 const RepoInfo & newinfo,
418
432 RepoInfo getRepositoryInfo( const std::string &alias,
434
454 RepoInfo getRepositoryInfo( const Url & url,
457
458
471 bool serviceEmpty() const;
472
479
486
492
495
497 std::list<ServiceInfo> knownServices() const
498 { return std::list<ServiceInfo>(serviceBegin(),serviceEnd()); }
499
506 ServiceInfo getService( const std::string & alias ) const;
507
509 bool hasService( const std::string & alias ) const;
511
515 repo::ServiceType probeService( const Url &url ) const;
516
525 void addService( const std::string & alias, const Url& url );
526
534 void addService( const ServiceInfo & service );
535
544 void removeService( const std::string & alias );
546 void removeService( const ServiceInfo & service );
547
548
555
564 void refreshService( const std::string & alias, const RefreshServiceOptions & options_r = RefreshServiceOptions() );
567
584 void modifyService( const std::string & oldAlias, const ServiceInfo & service );
586 void modifyService( const ServiceInfo & service )
587 { modifyService( service.alias(), service ); }
588
593 void refreshGeoIp ( const RepoInfo::url_set &urls );
594
595 private:
600 {
601 public:
602 MatchServiceAlias( std::string alias_ ) : alias(std::move(alias_)) {}
603 bool operator()( const RepoInfo & info ) const
604 { return info.service() == alias; }
605 private:
606 std::string alias;
607 };
608
609 public:
610
643 template<typename OutputIterator>
644 void getRepositoriesInService( const std::string & alias,
645 OutputIterator out ) const
646 {
647 MatchServiceAlias filter(alias);
648
649 std::copy( boost::make_filter_iterator( filter, repoBegin(), repoEnd() ),
650 boost::make_filter_iterator( filter, repoEnd(), repoEnd() ),
651 out);
652 }
653
654 private:
657 };
658 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(RepoManager::RefreshServiceFlags);
660
662 std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
663
666 { return makeIterable( repoBegin(), repoEnd() ); }
667
671
673} // namespace zypp
675#endif // ZYPP2_REPOMANAGER_H
RepoManager implementation.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
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:638
std::list< Url > url_set
Definition RepoInfo.h:108
Track changing files or directories.
Definition RepoStatus.h:41
Service data.
Definition ServiceInfo.h:37
Url manipulation class.
Definition Url.h:92
std::string alias() const
unique identifier for this source.
Definition Arch.h:364
String related utilities and Regular expression matching.
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)
Repo manager settings.
Functor thats filter RepoInfo by service which it belongs to.
MatchServiceAlias(std::string alias_)
bool operator()(const RepoInfo &info) const
creates and provides information about known sources.
bool hasRepo(const std::string &alias) const
Return whether there is a known repository for alias.
void cleanCacheDirGarbage(const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove any subdirectories of cache directories which no longer belong to any of known repositories.
friend std::ostream & operator<<(std::ostream &str, const RepoManager &obj)
void cleanMetadata(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local metadata.
bool serviceEmpty() const
Gets true if no service is in RepoManager (so no one in specified location)
bool hasService(const std::string &alias) const
Return whether there is a known service for alias.
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
@ REFRESH_NEEDED
refresh is needed
@ REPO_UP_TO_DATE
repository not changed
@ REPO_CHECK_DELAYED
refresh is delayed due to settings
RepoInfo getRepo(const RepoInfo &info_r) const
ServiceSet::const_iterator ServiceConstIterator
Definition RepoManager.h:67
void addRepository(const RepoInfo &info, OPT_PROGRESS)
void addService(const std::string &alias, const Url &url)
Adds a new service by its alias and URL.
bool isCached(const RepoInfo &info) const
Whether a repository exists in cache.
void loadFromCache(const RepoInfo &info, OPT_PROGRESS)
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, OPT_PROGRESS)
void removeService(const std::string &alias)
Removes service specified by its name.
bool hasRepo(const RepoInfo &info_r) const
void buildCache(const RepoInfo &info, CacheBuildPolicy policy, OPT_PROGRESS)
RepoInfo getRepo(const std::string &alias) const
Find RepoInfo by alias or return RepoInfo::noRepo.
repo::ServiceType probeService(const Url &url) const
Probe the type or the service.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
std::list< ServiceInfo > knownServices() const
List of known services.
void cleanCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
clean local cache
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy=RefreshIfNeeded)
Checks whether to refresh metadata for specified repository and url.
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
void refreshServices(const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refreshes all enabled services.
bool repoEmpty() const
Pathname metadataPath(const RepoInfo &info) const
Path where the metadata is downloaded and kept.
ServiceSet::size_type ServiceSizeType
Definition RepoManager.h:68
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 removeRepository(const RepoInfo &info, OPT_PROGRESS) override
void refreshGeoIp(const RepoInfo::url_set &urls)
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refresh specific service.
ServiceConstIterator serviceEnd() const
Iterator to place behind last service in internal storage.
RefreshServiceBit
Flags for tuning RefreshService.
Definition RepoManager.h:95
@ RefreshService_forceRefresh
Force refresh even if TTL is not reached.
Definition RepoManager.h:97
@ RefreshService_restoreStatus
Force restoring repo enabled/disabled status.
Definition RepoManager.h:96
ServiceConstIterator serviceBegin() const
Iterator to first service in internal storage.
repo::RepoType probe(const Url &url, const Pathname &path=Pathname()) const
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 modifyRepository(const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
RepoInfo getRepositoryInfo(const std::string &alias, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Find a matching repository info.
ServiceSizeType serviceSize() const
Gets count of service in RepoManager (in specified location)
ZYPP_DECLARE_FLAGS(RefreshServiceFlags, RefreshServiceBit)
void addRepositories(const Url &url, OPT_PROGRESS)
ServiceInfo getService(const std::string &alias) const
Finds ServiceInfo by alias or return ServiceInfo::noService.
RepoSet::size_type RepoSizeType
Definition RepoManager.h:73
std::list< RepoInfo > knownRepositories() const
List of known repositories.
RepoConstIterator repoBegin() const
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
Definition RepoManager.h:71
Iterable< RepoConstIterator > repos() const
Iterate the known repositories.
void refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r=RefreshServiceOptions())
RepoManager(RepoManagerOptions options=RepoManagerOptions())
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
fill to output iterator repositories in service name.
void cleanPackages(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local package cache.
RepoConstIterator repoEnd() const
RepoStatus metadataStatus(const RepoInfo &info) const
Status of local metadata.
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:72
static std::string makeStupidAlias(const Url &url_r=Url())
Some stupid string but suitable as alias for your url if nothing better is available.
repo::RepoType probe(const Url &url, const Pathname &path) const
Probe repo metadata type.
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
Definition RepoManager.h:66
Repository type enumeration.
Definition RepoType.h:28
Service type enumeration.
Definition ServiceType.h:27
Url::asString() view options.
Definition UrlBase.h:40
static const ViewOption DEFAULTS
Default combination of view options.
Definition UrlBase.h:177
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition Flags.h:177