libzypp  16.2.1
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/ProgressData.h"
31 
33 namespace zypp
34 {
35 
47  std::list<RepoInfo> readRepoFile(const Url & repo_file);
48 
54  {
66  RepoManagerOptions( const Pathname & root_r = Pathname() );
67 
77  static RepoManagerOptions makeTestSetup( const Pathname & root_r );
78 
79  Pathname repoCachePath;
80  Pathname repoRawCachePath;
83  Pathname knownReposPath;
85  Pathname pluginsPath;
86  bool probe;
93  std::string servicesTargetDistro;
94 
96  Pathname rootDir;
97  };
98 
99 
100 
106  {
107  friend std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
108 
109  public:
111  class Impl;
112 
114  typedef std::set<ServiceInfo> ServiceSet;
115  typedef ServiceSet::const_iterator ServiceConstIterator;
117 
119  typedef std::set<RepoInfo> RepoSet;
120  typedef RepoSet::const_iterator RepoConstIterator;
122 
123  public:
124  RepoManager( const RepoManagerOptions &options = RepoManagerOptions() );
126  ~RepoManager();
127 
129  {
132  RefreshIfNeededIgnoreDelay
133  };
134 
136  {
138  BuildForced
139  };
140 
143  {
144  RefreshService_restoreStatus = (1<<0),
145  RefreshService_forceRefresh = (1<<1),
146  };
147  ZYPP_DECLARE_FLAGS(RefreshServiceFlags,RefreshServiceBit);
148 
150  typedef RefreshServiceFlags RefreshServiceOptions;
151 
152 
160  bool repoEmpty() const;
161  RepoSizeType repoSize() const;
162  RepoConstIterator repoBegin() const;
163  RepoConstIterator repoEnd() const;
164 
166  std::list<RepoInfo> knownRepositories() const
167  { return std::list<RepoInfo>(repoBegin(),repoEnd()); }
168 
170  RepoInfo getRepo( const std::string & alias ) const;
172  RepoInfo getRepo( const RepoInfo & info_r ) const
173  { return getRepo( info_r.alias() ); }
174 
176  bool hasRepo( const std::string & alias ) const;
178  bool hasRepo( const RepoInfo & info_r ) const
179  { return hasRepo( info_r.alias() ); }
180 
184  static std::string makeStupidAlias( const Url & url_r = Url() );
186 
190  RepoStatus metadataStatus( const RepoInfo &info ) const;
191 
198  REPO_CHECK_DELAYED
199  };
200 
255  RefreshCheckStatus checkIfToRefreshMetadata( const RepoInfo &info,
256  const Url &url,
257  RawMetadataRefreshPolicy policy = RefreshIfNeeded);
258 
269  Pathname metadataPath( const RepoInfo &info ) const;
270 
271 
282  Pathname packagesPath( const RepoInfo &info ) const;
283 
284 
299  void refreshMetadata( const RepoInfo &info,
300  RawMetadataRefreshPolicy policy = RefreshIfNeeded,
301  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
302 
311  void cleanMetadata( const RepoInfo &info,
312  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
313 
322  void cleanPackages( const RepoInfo &info,
323  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
324 
328  RepoStatus cacheStatus( const RepoInfo &info ) const;
329 
348  void buildCache( const RepoInfo &info,
349  CacheBuildPolicy policy = BuildIfNeeded,
350  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
351 
364  void cleanCache( const RepoInfo &info,
365  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
366 
372  bool isCached( const RepoInfo &info ) const;
373 
374 
384  void loadFromCache( const RepoInfo &info,
385  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
386 
394  void cleanCacheDirGarbage( const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
395 
403  repo::RepoType probe( const Url & url, const Pathname & path ) const;
407  repo::RepoType probe( const Url & url ) const;
408 
409 
424  void addRepository( const RepoInfo &info,
425  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
426 
439  void addRepositories( const Url &url,
440  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
446  void removeRepository( const RepoInfo & info,
447  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
448 
458  void modifyRepository( const std::string &alias,
459  const RepoInfo & newinfo,
460  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
462  void modifyRepository( const RepoInfo & newinfo,
463  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() )
464  { modifyRepository( newinfo.alias(), newinfo, progressrcv ); }
465 
479  RepoInfo getRepositoryInfo( const std::string &alias,
480  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
481 
501  RepoInfo getRepositoryInfo( const Url & url,
502  const url::ViewOption & urlview = url::ViewOption::DEFAULTS,
503  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
504 
505 
518  bool serviceEmpty() const;
519 
525  ServiceSizeType serviceSize() const;
526 
532  ServiceConstIterator serviceBegin() const;
533 
538  ServiceConstIterator serviceEnd() const;
539 
541  std::list<ServiceInfo> knownServices() const
542  { return std::list<ServiceInfo>(serviceBegin(),serviceEnd()); }
543 
550  ServiceInfo getService( const std::string & alias ) const;
551 
553  bool hasService( const std::string & alias ) const;
555 
559  repo::ServiceType probeService( const Url &url ) const;
560 
569  void addService( const std::string & alias, const Url& url );
570 
578  void addService( const ServiceInfo & service );
579 
588  void removeService( const std::string & alias );
590  void removeService( const ServiceInfo & service );
591 
592 
598  void refreshServices( const RefreshServiceOptions & options_r = RefreshServiceOptions() );
599 
608  void refreshService( const std::string & alias, const RefreshServiceOptions & options_r = RefreshServiceOptions() );
610  void refreshService( const ServiceInfo & service, const RefreshServiceOptions & options_r = RefreshServiceOptions() );
611 
628  void modifyService( const std::string & oldAlias, const ServiceInfo & service );
630  void modifyService( const ServiceInfo & service )
631  { modifyService( service.alias(), service ); }
632 
633  private:
638  {
639  public:
640  MatchServiceAlias( const std::string & alias_ ) : alias(alias_) {}
641  bool operator()( const RepoInfo & info ) const
642  { return info.service() == alias; }
643  private:
644  std::string alias;
645  };
646 
647  public:
648 
681  template<typename OutputIterator>
682  void getRepositoriesInService( const std::string & alias,
683  OutputIterator out ) const
684  {
685  MatchServiceAlias filter(alias);
686 
687  std::copy( boost::make_filter_iterator( filter, repoBegin(), repoEnd() ),
688  boost::make_filter_iterator( filter, repoEnd(), repoEnd() ),
689  out);
690  }
691 
692  private:
695  };
696  ZYPP_DECLARE_OPERATORS_FOR_FLAGS(RepoManager::RefreshServiceFlags);
698 
700  std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
701 
703 } // namespace zypp
705 #endif // ZYPP2_REPOMANAGER_H
Service data.
Definition: ServiceInfo.h:36
ZYPP_DECLARE_FLAGS(VendorSupportOptions, VendorSupportOption)
RepoManagerOptions(const Pathname &root_r=Pathname())
Default ctor following ZConfig global settings.
Definition: RepoManager.cc:459
std::string alias() const
unique identifier for this source.
void modifyService(const ServiceInfo &service)
Definition: RepoManager.h:630
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoManager.h:694
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
Definition: RepoManager.h:195
RepoSet::size_type RepoSizeType
Definition: RepoManager.h:121
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(DiskUsageCounter::MountPoint::HintFlags)
String related utilities and Regular expression matching.
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
Definition: RepoManager.h:150
What is known about a repository.
Definition: RepoInfo.h:71
RepoSet::const_iterator RepoConstIterator
Definition: RepoManager.h:120
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Definition: ProgressData.h:139
Url::asString() view options.
Definition: UrlBase.h:39
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
fill to output iterator repositories in service name.
Definition: RepoManager.h:682
RefreshServiceBit
Flags for tuning RefreshService.
Definition: RepoManager.h:142
Repo manager settings.
Definition: RepoManager.h:53
RepoManager implementation.
Definition: RepoManager.cc:507
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
Definition: RepoManager.h:119
static RepoManagerOptions makeTestSetup(const Pathname &root_r)
Test setup adjusting all paths to be located below one root_r directory.
Definition: RepoManager.cc:473
Pathname rootDir
remembers root_r value for later use
Definition: RepoManager.h:96
RepoInfo getRepo(const RepoInfo &info_r) const
Definition: RepoManager.h:172
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
bool hasRepo(const RepoInfo &info_r) const
Definition: RepoManager.h:178
MatchServiceAlias(const std::string &alias_)
Definition: RepoManager.h:640
Service type enumeration.
Definition: ServiceType.h:26
ServiceSet::const_iterator ServiceConstIterator
Definition: RepoManager.h:115
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:411
zypp::Url url
Definition: MediaCurl.cc:192
ServiceSet::size_type ServiceSizeType
Definition: RepoManager.h:116
SolvableIdType size_type
Definition: PoolMember.h:126
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
Definition: IOStream.h:50
creates and provides information about known sources.
Definition: RepoManager.h:105
bool operator()(const RepoInfo &info) const
Definition: RepoManager.h:641
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:438
repository not changed
Definition: RepoManager.h:197
void modifyRepository(const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Definition: RepoManager.h:462
std::list< RepoInfo > knownRepositories() const
List of known repositories.
Definition: RepoManager.h:166
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
Definition: RepoManager.h:111
std::string servicesTargetDistro
Target distro ID to be used when refreshing repo index services.
Definition: RepoManager.h:93
Functor thats filter RepoInfo by service which it belongs to.
Definition: RepoManager.h:637
Pathname repoPackagesCachePath
Definition: RepoManager.h:82
static const ViewOption DEFAULTS
Default combination of view options.
Definition: UrlBase.h:177
Track changing files or directories.
Definition: RepoStatus.h:38
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
std::list< ServiceInfo > knownServices() const
List of known services.
Definition: RepoManager.h:541
Url manipulation class.
Definition: Url.h:87
Repository type enumeration.
Definition: RepoType.h:27