17#include <zypp-core/ng/pipelines/Lift>
23#undef ZYPP_BASE_LOGGER_LOGGROUP
24#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::repomanager"
30#define OPT_PROGRESS const ProgressData::ReceiverFnc & = ProgressData::ReceiverFnc()
74 {
return str <<
"RepoManager::Impl"; }
90 {
return _pimpl->ngMgr().repoEmpty(); }
93 {
return _pimpl->ngMgr().repoSize(); }
96 {
return _pimpl->ngMgr().repoBegin(); }
99 {
return _pimpl->ngMgr().repoEnd(); }
102 {
return _pimpl->ngMgr().getRepo( alias ); }
105 {
return _pimpl->ngMgr().hasRepo( alias ); }
115 std::string host( url_r.
getHost() );
116 if ( ! host.empty() )
128 {
return _pimpl->ngMgr().metadataStatus( info ).unwrap(); }
131 {
return _pimpl->ngMgr().checkIfToRefreshMetadata( info, origin, policy ).unwrap(); }
134 {
return _pimpl->ngMgr().checkIfToRefreshMetadata( info,
url, policy ).unwrap(); }
137 {
return _pimpl->ngMgr().metadataPath( info ).unwrap(); }
140 {
return _pimpl->ngMgr().packagesPath( info ).unwrap(); }
146 return _pimpl->ngMgr().refreshMetadata( info, policy,
nullptr ).unwrap();
150 {
return _pimpl->ngMgr().cleanMetadata( info,
nullptr ).unwrap(); }
153 {
return _pimpl->ngMgr().cleanPackages( info,
nullptr ).unwrap(); }
156 {
return _pimpl->ngMgr().cacheStatus( info ).unwrap(); }
162 return _pimpl->ngMgr().buildCache( info, policy, adapt.observer() ).unwrap();
166 {
return _pimpl->ngMgr().cleanCache( info,
nullptr ).unwrap(); }
169 {
return _pimpl->ngMgr().isCached( info ).unwrap(); }
172 {
return _pimpl->ngMgr().loadFromCache( info,
nullptr ).unwrap(); }
175 {
return _pimpl->ngMgr().cleanCacheDirGarbage(
nullptr ).unwrap(); }
178 {
return _pimpl->ngMgr().probe( {
url}, path ).unwrap(); }
181 {
return _pimpl->ngMgr().probe( {
url} ).unwrap(); }
187 RepoInfo updatedRepo =
_pimpl->ngMgr().addRepository( info, adapt.observer(), forcedProbe ).unwrap();
201 {
return _pimpl->ngMgr().addRepositories(
url,
nullptr ).unwrap(); }
207 return _pimpl->ngMgr().removeRepository( info, adapt.observer() ).unwrap();
212 RepoInfo updated =
_pimpl->ngMgr().modifyRepository( alias, newinfo,
nullptr ).unwrap();
222 {
return _pimpl->ngMgr().getRepositoryInfo( alias ).unwrap(); }
225 {
return _pimpl->ngMgr().getRepositoryInfo(
url, urlview ).unwrap(); }
228 {
return _pimpl->ngMgr().serviceEmpty(); }
231 {
return _pimpl->ngMgr().serviceSize(); }
234 {
return _pimpl->ngMgr().serviceBegin(); }
237 {
return _pimpl->ngMgr().serviceEnd(); }
240 {
return _pimpl->ngMgr().getService( alias ); }
243 {
return _pimpl->ngMgr().hasService( alias ); }
246 {
return _pimpl->ngMgr().probeService(
url ).unwrap(); }
249 {
return _pimpl->ngMgr().addService( alias,
url ).unwrap(); }
252 {
return _pimpl->ngMgr().addService( service ).unwrap(); }
255 {
return _pimpl->ngMgr().removeService( alias ).unwrap(); }
258 {
return _pimpl->ngMgr().removeService( service ).unwrap(); }
261 {
return _pimpl->ngMgr().refreshServices( options_r ).unwrap(); }
264 {
return _pimpl->ngMgr().refreshService( alias, options_r ).unwrap(); }
267 {
return _pimpl->ngMgr().refreshService( service, options_r ).unwrap(); }
270 {
return _pimpl->ngMgr().modifyService( oldAlias, service ).unwrap(); }
273 { (void)
_pimpl->ngMgr().refreshGeoIp( urls ); }
static Date now()
Return the current time.
std::string digest()
get hex string representation of the digest
static const std::string & sha1()
sha1
bool hasFallbackUrls() const
Whether this set contains more than one Url in total (authorities or mirrors).
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.
MirroredOriginSet repoOrigins() const
The repodata origins.
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
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.
ServiceSet::const_iterator ServiceConstIterator
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 removeService(const std::string &alias)
Removes service specified by its name.
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.
RepoManagerFlags::RawMetadataRefreshPolicy RawMetadataRefreshPolicy
void cleanCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
clean local cache
void refreshServices(const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refreshes all enabled services.
void addRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds a repository to the list of known repositories.
Pathname metadataPath(const RepoInfo &info) const
Path where the metadata is downloaded and kept.
ServiceSet::size_type ServiceSizeType
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.
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.
RepoManagerFlags::CacheBuildPolicy CacheBuildPolicy
ServiceConstIterator serviceBegin() const
Iterator to first service in internal storage.
RepoManagerFlags::RefreshCheckStatus RefreshCheckStatus
RepoSizeType repoSize() const
void modifyRepository(const std::string &alias, const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Modify repository attributes.
void removeRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove the best matching repository from known repos list.
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).
ServiceInfo getService(const std::string &alias) const
Finds ServiceInfo by alias or return ServiceInfo::noService.
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
RepoConstIterator repoBegin() const
void buildCache(const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local cache.
RepoManagerFlags::RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
RepoManager(RepoManagerOptions options=RepoManagerOptions())
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
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
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.
Track changing files or directories.
std::string getScheme() const
Returns the scheme name of the URL.
std::string asCompleteString() const
Returns a complete string representation of the Url object.
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
void setFilepath(const Pathname &filename)
set the path to the .repo file
Pathname filepath() const
File where this repo was read from.
static ContextRef defaultContext()
The RepoManager class Provides knowledge and methods to maintain repo settings and metadata for a giv...
static expected< std::shared_ptr< RepoManager > > create(Args &&...args)
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
String related utilities and Regular expression matching.
std::string hexstring(char n, int w=4)
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...
MaybeAwaitable< expected< std::list< RepoInfo > > > readRepoFile(ContextRef ctx, zypp::Url repoFileUrl)
expected< zypp::Pathname > rawcache_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the raw cache path for a repository, this is usually /var/cache/zypp/alias.
expected< zypp::Pathname > packagescache_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the packages cache path for a repository.
RepoManager implementation.
Impl & operator=(const Impl &)=delete
Impl(const Impl &)=delete
std::ostream & operator<<(std::ostream &str, const RepoManager::Impl &obj)
Stream output.
friend Impl * rwcowClone(const Impl *rhs)
zyppng::RepoManager & ngMgr()
Impl * clone() const
clone for RWCOW_pointer
zyppng::RepoManagerRef _ngMgr
const zyppng::RepoManager & ngMgr() const
Impl(zyppng::ContextRef &&ctx, RepoManagerOptions &&opt)
Impl & operator=(Impl &&)=delete
Repository type enumeration.
Service type enumeration.
Url::asString() view options.