libzypp 17.34.0
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) ZYPP_API;
52
57 class ZYPP_API 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
81 {
84 RefreshIfNeededIgnoreDelay
85 };
86
88 {
90 BuildForced
91 };
92
95 {
96 RefreshService_restoreStatus = (1<<0),
97 RefreshService_forceRefresh = (1<<1),
98 };
100
103
104
112 bool repoEmpty() const;
113 RepoSizeType repoSize() const;
114 RepoConstIterator repoBegin() const;
115 RepoConstIterator repoEnd() const;
116 Iterable<RepoConstIterator> repos() 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,
210 RawMetadataRefreshPolicy policy = RefreshIfNeeded);
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,
253 RawMetadataRefreshPolicy policy = RefreshIfNeeded,
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,
302 CacheBuildPolicy policy = BuildIfNeeded,
304
317 void cleanCache( const RepoInfo &info,
319
325 bool isCached( const RepoInfo &info ) const;
326
327
337 void loadFromCache( const RepoInfo &info,
339
347 void cleanCacheDirGarbage( const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
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,
417 { modifyRepository( newinfo.alias(), newinfo, progressrcv ); }
418
432 RepoInfo getRepositoryInfo( const std::string &alias,
434
454 RepoInfo getRepositoryInfo( const Url & url,
455 const url::ViewOption & urlview = url::ViewOption::DEFAULTS,
457
458
471 bool serviceEmpty() const;
472
478 ServiceSizeType serviceSize() const;
479
485 ServiceConstIterator serviceBegin() const;
486
491 ServiceConstIterator serviceEnd() const;
492
494 Iterable<ServiceConstIterator> services() const;
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 ) ZYPP_API;
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)
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
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.
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
@ REFRESH_NEEDED
refresh is needed
@ REPO_UP_TO_DATE
repository not changed
RepoInfo getRepo(const RepoInfo &info_r) const
ServiceSet::const_iterator ServiceConstIterator
Definition RepoManager.h:67
bool hasRepo(const RepoInfo &info_r) const
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.
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy=RefreshIfNeeded)
Checks whether to refresh metadata for specified repository and url.
void refreshServices(const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refreshes all enabled services.
ServiceSet::size_type ServiceSizeType
Definition RepoManager.h:68
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
ServiceConstIterator serviceBegin() const
Iterator to first service in internal storage.
void modifyService(const ServiceInfo &service)
Iterable< ServiceConstIterator > services() const
Iterate the known services.
void modifyRepository(const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
ZYPP_DECLARE_FLAGS(RefreshServiceFlags, RefreshServiceBit)
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())
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
fill to output iterator repositories in service name.
RepoConstIterator repoEnd() const
RepoSet::const_iterator RepoConstIterator
Definition RepoManager.h:72
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:29
Service type enumeration.
Definition ServiceType.h:27
Url::asString() view options.
Definition UrlBase.h:40
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition Flags.h:177