libzypp  17.37.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>
27 #include <zypp/repo/ServiceType.h>
28 #include <zypp/ServiceInfo.h>
29 #include <zypp/RepoStatus.h>
30 #include <zypp/RepoManagerFlags.h>
32 #include <utility>
33 #include <zypp-core/ui/ProgressData>
34 
36 namespace zypp
37 {
38 
52  std::list<RepoInfo> readRepoFile(const Url & repo_file) ZYPP_API;
53 
58  class ZYPP_API RepoManager
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;
70 
72  using RepoSet = std::set<RepoInfo>;
73  using RepoConstIterator = RepoSet::const_iterator;
75 
76  public:
79  ~RepoManager();
80 
85 
89 
94 
95  using RefreshServiceFlags = RepoManagerFlags::RefreshServiceFlags;
96 
98  using RefreshServiceOptions = RepoManagerFlags::RefreshServiceFlags;
99 
107  bool repoEmpty() const;
108  RepoSizeType repoSize() const;
109  RepoConstIterator repoBegin() const;
110  RepoConstIterator repoEnd() const;
111  Iterable<RepoConstIterator> repos() 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 
200  const Url &url,
202 
212  const std::vector<Url> &url,
214 
225  Pathname metadataPath( const RepoInfo &info ) const;
226 
227 
238  Pathname packagesPath( const RepoInfo &info ) const;
239 
240 
256  void refreshMetadata( const RepoInfo &info,
258  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
259 
268  void cleanMetadata( const RepoInfo &info,
269  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
270 
279  void cleanPackages( const RepoInfo &info,
280  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
281 
285  RepoStatus cacheStatus( const RepoInfo &info ) const;
286 
306  void buildCache( const RepoInfo &info,
308  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
309 
322  void cleanCache( const RepoInfo &info,
323  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
324 
330  bool isCached( const RepoInfo &info ) const;
331 
332 
342  void loadFromCache( const RepoInfo &info,
343  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
344 
352  void cleanCacheDirGarbage( const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
353 
361  repo::RepoType probe( const Url & url, const Pathname & path ) const;
365  repo::RepoType probe( const Url & url ) const;
366 
367 
382  void addRepository( const RepoInfo &info,
383  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
384 
397  void addRepositories( const Url &url,
398  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
404  void removeRepository( const RepoInfo & info,
405  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
406 
416  void modifyRepository( const std::string &alias,
417  const RepoInfo & newinfo,
418  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
420  void modifyRepository( const RepoInfo & newinfo,
421  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() )
422  { modifyRepository( newinfo.alias(), newinfo, progressrcv ); }
423 
437  RepoInfo getRepositoryInfo( const std::string &alias,
438  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
439 
459  RepoInfo getRepositoryInfo( const Url & url,
460  const url::ViewOption & urlview = url::ViewOption::DEFAULTS,
461  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
462 
463 
476  bool serviceEmpty() const;
477 
483  ServiceSizeType serviceSize() const;
484 
490  ServiceConstIterator serviceBegin() const;
491 
496  ServiceConstIterator serviceEnd() const;
497 
499  Iterable<ServiceConstIterator> services() const;
500 
502  std::list<ServiceInfo> knownServices() const
503  { return std::list<ServiceInfo>(serviceBegin(),serviceEnd()); }
504 
511  ServiceInfo getService( const std::string & alias ) const;
512 
514  bool hasService( const std::string & alias ) const;
516 
520  repo::ServiceType probeService( const Url &url ) const;
521 
530  void addService( const std::string & alias, const Url& url );
531 
539  void addService( const ServiceInfo & service );
540 
549  void removeService( const std::string & alias );
551  void removeService( const ServiceInfo & service );
552 
553 
559  void refreshServices( const RefreshServiceOptions & options_r = RefreshServiceOptions() );
560 
569  void refreshService( const std::string & alias, const RefreshServiceOptions & options_r = RefreshServiceOptions() );
571  void refreshService( const ServiceInfo & service, const RefreshServiceOptions & options_r = RefreshServiceOptions() );
572 
589  void modifyService( const std::string & oldAlias, const ServiceInfo & service );
591  void modifyService( const ServiceInfo & service )
592  { modifyService( service.alias(), service ); }
593 
598  void refreshGeoIp ( const RepoInfo::url_set &urls );
599 
600  private:
605  {
606  public:
607  MatchServiceAlias( std::string alias_ ) : alias(std::move(alias_)) {}
608  bool operator()( const RepoInfo & info ) const
609  { return info.service() == alias; }
610  private:
611  std::string alias;
612  };
613 
614  public:
615 
648  template<typename OutputIterator>
649  void getRepositoriesInService( const std::string & alias,
650  OutputIterator out ) const
651  {
652  MatchServiceAlias filter(alias);
653 
654  std::copy( boost::make_filter_iterator( filter, repoBegin(), repoEnd() ),
655  boost::make_filter_iterator( filter, repoEnd(), repoEnd() ),
656  out);
657  }
658 
659  private:
662  };
664 
666  std::ostream & operator<<( std::ostream & str, const RepoManager & obj ) ZYPP_API;
667 
670  { return makeIterable( repoBegin(), repoEnd() ); }
671 
674  { return makeIterable( serviceBegin(), serviceEnd() ); }
675 
677 } // namespace zypp
679 #endif // ZYPP2_REPOMANAGER_H
Service data.
Definition: ServiceInfo.h:36
Force restoring repo enabled/disabled status.
RepoSet::size_type RepoSizeType
Definition: RepoManager.h:74
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
fill to output iterator repositories in service name.
Definition: RepoManager.h:649
RepoManagerFlags::RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
Definition: RepoManager.h:98
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:795
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
Force refresh even if TTL is not reached.
AsyncOpRef< expected< repo::AsyncRefreshContextRef > > refreshMetadata(repo::AsyncRefreshContextRef refCtx, LazyMediaHandle< Provide > medium, ProgressObserverRef progressObserver)
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Definition: progressdata.h:140
void modifyRepository(const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Definition: RepoManager.h:420
bool hasRepo(const RepoInfo &info_r) const
Definition: RepoManager.h:126
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
Definition: Arch.h:363
What is known about a repository.
Definition: RepoInfo.h:71
AsyncOpRef< expected< repo::AsyncRefreshContextRef > > buildCache(repo::AsyncRefreshContextRef refCtx, zypp::RepoManagerFlags::CacheBuildPolicy policy, ProgressObserverRef progressObserver)
Url::asString() view options.
Definition: UrlBase.h:40
Repo manager settings.
RepoInfo getRepo(const RepoInfo &info_r) const
Definition: RepoManager.h:120
std::list< RepoInfo > readRepoFile(const Url &repo_file)
Parses repo_file and returns a list of RepoInfo objects corresponding to repositories found within th...
Definition: RepoManager.cc:275
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
Definition: RepoManager.h:67
std::string alias() const
unique identifier for this source.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition: ResTraits.h:93
Service type enumeration.
Definition: ServiceType.h:26
MatchServiceAlias(std::string alias_)
Definition: RepoManager.h:607
ServiceSet::size_type ServiceSizeType
Definition: RepoManager.h:69
Iterable< RepoConstIterator > repos() const
Iterate the known repositories.
Definition: RepoManager.h:669
std::list< Url > url_set
Definition: RepoInfo.h:108
RepoManagerFlags::RefreshServiceFlags RefreshServiceFlags
Definition: RepoManager.h:95
ServiceConstIterator serviceBegin() const
Iterator to first service in internal storage.
Definition: RepoManager.cc:228
ServiceConstIterator serviceEnd() const
Iterator to place behind last service in internal storage.
Definition: RepoManager.cc:231
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
Definition: IOStream.h:51
zypp::Url Url
Definition: url.h:15
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoManager.h:661
bool operator()(const RepoInfo &info) const
Definition: RepoManager.h:608
std::list< RepoInfo > knownRepositories() const
List of known repositories.
Definition: RepoManager.h:114
RepoConstIterator repoBegin() const
Definition: RepoManager.cc:93
refresh is delayed due to settings
Functor thats filter RepoInfo by service which it belongs to.
Definition: RepoManager.h:604
AsyncOpRef< expected< void > > refreshService(AsyncRepoManagerRef repoMgr, ServiceInfo info, zypp::RepoManagerFlags::RefreshServiceOptions options)
Definition: serviceswf.cc:763
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
Definition: RepoManager.h:72
RepoSet::const_iterator RepoConstIterator
Definition: RepoManager.h:73
AsyncOpRef< expected< repo::RefreshCheckStatus > > checkIfToRefreshMetadata(repo::AsyncRefreshContextRef refCtx, LazyMediaHandle< Provide > medium, ProgressObserverRef progressObserver)
void modifyService(const ServiceInfo &service)
Definition: RepoManager.h:591
RefreshCheckStatus
Possibly return state of RepoManager::checkIfToRefreshMetadata function.
Track changing files or directories.
Definition: RepoStatus.h:40
AsyncOpRef< expected< RepoInfo > > addRepository(AsyncRepoManagerRef mgr, RepoInfo info, ProgressObserverRef myProgress)
Iterable< ServiceConstIterator > services() const
Iterate the known services.
Definition: RepoManager.h:673
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
RefreshServiceBit
Flags for tuning RefreshService.
AsyncOpRef< expected< void > > addRepositories(AsyncRepoManagerRef mgr, zypp::Url url, ProgressObserverRef myProgress)
SolvableIdType size_type
Definition: PoolMember.h:126
RepoConstIterator repoEnd() const
Definition: RepoManager.cc:96
zypp::RepoManagerOptions RepoManagerOptions
Definition: repomanager.h:40
Url manipulation class.
Definition: Url.h:92
std::list< ServiceInfo > knownServices() const
List of known services.
Definition: RepoManager.h:502
Repository type enumeration.
Definition: RepoType.h:28
ServiceSet::const_iterator ServiceConstIterator
Definition: RepoManager.h:68