12#ifndef ZYPP_NG_REPOMANAGER_INCLUDED
13#define ZYPP_NG_REPOMANAGER_INCLUDED
27#include <zypp-core/base/DefaultIntegral>
31#include <zypp-core/zyppng/base/Base>
60 if ( info.
alias().empty() )
64 if ( info.
alias()[0] ==
'.')
66 info,
_(
"Repository alias cannot start with dot."))) );
72 if (info.
alias().empty())
76 if (info.
alias()[0] ==
'.')
78 info,
_(
"Service alias cannot start with dot."))));
84 template <
class Iterator>
85 inline bool foundAliasIn(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
87 for_( it, begin_r, end_r )
88 if ( it->alias() == alias_r )
93 template <
class Container>
94 inline bool foundAliasIn(
const std::string & alias_r,
const Container & cont_r )
95 {
return foundAliasIn( alias_r, cont_r.begin(), cont_r.end() ); }
98 template <
class Iterator>
99 inline Iterator
findAlias(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
101 for_( it, begin_r, end_r )
102 if ( it->alias() == alias_r )
107 template <
class Container>
108 inline typename Container::iterator
findAlias(
const std::string & alias_r, Container & cont_r )
109 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
111 template <
class Container>
112 inline typename Container::const_iterator
findAlias(
const std::string & alias_r,
const Container & cont_r )
113 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
117 std::string
filenameFromAlias(
const std::string & alias_r,
const std::string & stem_r );
246 template <
typename ZyppContextRefType>
270 template <
typename ...Args >
273 auto mgr = std::make_shared< RepoManager<ZyppContextRefType> >( private_constr_t{}, std::forward<Args>(args)... );
320 bool hasRepo(
const std::string & alias )
const
429 return it ==
_services.end() ? ServiceInfo::noService : *it;
475 template<
typename OutputIterator>
478 MatchServiceAlias
filter( alias );
479 std::copy( boost::make_filter_iterator(
filter,
repos().begin(),
repos().end() ),
Integral type with defined initial value when default constructed.
Base class for Exception.
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
What is known about a repository.
Pathname metadataPath() const
Path where this repo metadata was read from.
bool usesAutoMetadataPaths() const
Whether metadataPath uses AUTO% setup.
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Pathname path() const
Repository path.
std::string service() const
Gets name of the service to which this repository belongs or empty string if it has been added manual...
Pathname packagesPath() const
Path where this repo packages are cached.
Track changing files or directories.
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
Url url() const
The service url.
bool isValid() const
Verifies the Url.
Wrapper class for stat/lstat.
Pathname dirname() const
Return all but the last component od this path.
bool empty() const
Test for an empty path.
std::string escaped_alias() const
Same as alias(), just escaped in a way to be a valid file name.
Pathname filepath() const
File where this repo was read from.
std::string alias() const
unique identifier for this source.
Thrown when the repo alias is found to be invalid.
thrown when it was impossible to determine an alias for this repo.
Thrown when the repo alias is found to be invalid.
Service without alias was used in an operation.
Service has no or invalid url defined.
Repository metadata verification beyond GPG.
The RepoManager class Provides knowledge and methods to maintain repo settings and metadata for a giv...
zypp::RepoManagerFlags::RefreshCheckStatus RefreshCheckStatus
RepoSet::size_type RepoSizeType
ServiceInfo getService(const std::string &alias) const
expected< void > refreshServices(const RefreshServiceOptions &options_r)
static expected< std::shared_ptr< RepoManager< ZyppContextRefType > > > create(Args &&...args)
expected< RepoStatus > cacheStatus(const RepoInfo &info) const
std::set< ServiceInfo > ServiceSet
RepoInfo getRepo(const std::string &alias) const
expected< void > refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, ProgressObserverRef myProgress=nullptr)
Refresh local raw cache.
expected< void > modifyService(const std::string &oldAlias, const ServiceInfo &newService)
zypp::RepoManagerFlags::RefreshServiceBit RefreshServiceBit
static expected< RepoStatus > cacheStatus(const RepoInfo &info, const RepoManagerOptions &options)
expected< zypp::Pathname > packagesPath(const RepoInfo &info) const
ServiceConstIterator serviceBegin() const
expected< void > addService(const ServiceInfo &service)
expected< void > refreshGeoIp(const RepoInfo::url_set &urls)
expected< void > removeService(const std::string &alias)
ZYPP_ENABLE_MAYBE_ASYNC_MIXIN((std::is_same_v< ZyppContextRefType, ContextRef >))
expected< void > cleanPackages(const RepoInfo &info, ProgressObserverRef myProgress=nullptr, bool isAutoClean=false)
expected< void > removeService(const ServiceInfo &service)
expected< RefreshCheckStatus > checkIfToRefreshMetadata(const RepoInfo &info, const zypp::Url &url, RawMetadataRefreshPolicy policy)
bool serviceEmpty() const
static expected< void > touchIndexFile(const RepoInfo &info, const RepoManagerOptions &options)
expected< RepoInfo > getRepositoryInfo(const std::string &alias)
expected< RepoStatus > metadataStatus(const RepoInfo &info) const
expected< void > refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
expected< RepoInfo > getRepositoryInfo(const zypp::Url &url, const zypp::url::ViewOption &urlview)
expected< RepoInfo > modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, ProgressObserverRef myProgress=nullptr)
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
zypp::RepoManagerFlags::RawMetadataRefreshPolicy RawMetadataRefreshPolicy
ServiceConstIterator serviceEnd() const
static zypp::repo::RepoType probeCache(const zypp::Pathname &path_r)
Probe Metadata in a local cache directory.
expected< void > addService(const std::string &alias, const zypp::Url &url)
expected< void > init_knownServices()
SyncContextRef ContextRefType
expected< RepoInfo > addProbedRepository(RepoInfo info, zypp::repo::RepoType probedType)
expected< void > setCacheStatus(const RepoInfo &info, const RepoStatus &status)
const RepoSet & repos() const
ServiceSet::size_type ServiceSizeType
expected< void > cleanCacheDirGarbage(ProgressObserverRef myProgress=nullptr)
expected< bool > isCached(const RepoInfo &info) const
expected< zypp::repo::ServiceType > probeService(const zypp::Url &url) const
ServiceSizeType serviceSize() const
std::string generateFilename(const ServiceInfo &info) const
expected< void > initialize()
zypp::Pathname generateNonExistingName(const zypp::Pathname &dir, const std::string &basefilename) const
Generate a non existing filename in a directory, using a base name.
expected< void > buildCache(const RepoInfo &info, CacheBuildPolicy policy, ProgressObserverRef myProgress=nullptr)
expected< void > touchIndexFile(const RepoInfo &info)
expected< RefreshCheckStatus > checkIfToRefreshMetadata(const RepoInfo &info, const zypp::MirroredOrigin &origin, RawMetadataRefreshPolicy policy)
RepoSet::const_iterator RepoConstIterator
expected< zypp::Pathname > metadataPath(const RepoInfo &info) const
expected< zypp::repo::RepoType > probe(const zypp::MirroredOrigin &origin, const zypp::Pathname &path=zypp::Pathname()) const
Probe the metadata type of a repository located at url.
RepoSizeType repoSize() const
PluginRepoverification pluginRepoverification() const
expected< void > addRepositories(const zypp::Url &url, ProgressObserverRef myProgress=nullptr)
PluginRepoverification _pluginRepoverification
ZYPP_ADD_PRIVATE_CONSTR_HELPER()
expected< RepoInfo > addRepository(const RepoInfo &info, const ProgressObserverRef myProgress=nullptr, const zypp::TriBool &forcedProbe=zypp::indeterminate)
ServiceSet::const_iterator ServiceConstIterator
ContextRefType zyppContext() const
RepoManagerOptions _options
expected< void > init_knownRepositories()
expected< void > cleanCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
zypp::DefaultIntegral< bool, false > _reposDirty
expected< void > loadFromCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
std::set< RepoInfo > RepoSet
expected< void > cleanMetadata(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
static expected< RepoStatus > metadataStatus(const RepoInfo &info, const RepoManagerOptions &options)
expected< void > removeRepository(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
bool hasService(const std::string &alias) const
RepoConstIterator repoBegin() const
expected< void > saveService(ServiceInfo &service) const
bool hasRepo(const std::string &alias) const
std::string generateFilename(const RepoInfo &info) const
ZYPP_DECL_PRIVATE_CONSTR_ARGS(RepoManager, ZyppContextRefType zyppCtx, RepoManagerOptions opt)
typename SyncContextRef::element_type ContextType
RepoConstIterator repoEnd() const
std::vector< std::pair< RepoInfo, expected< void > > > refreshMetadata(std::vector< RepoInfo > infos, RawMetadataRefreshPolicy policy, ProgressObserverRef myProgress=nullptr)
zypp::RepoManagerFlags::RefreshServiceOptions RefreshServiceOptions
expected< void > refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
const RepoManagerOptions & options() const
zypp::RepoManagerFlags::CacheBuildPolicy CacheBuildPolicy
ContextRefType _zyppContext
ServiceCollector(ServiceSet &services_r)
bool operator()(const ServiceInfo &service_r) const
std::set< ServiceInfo > ServiceSet
static expected success(ConsParams &&...params)
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
RefreshCheckStatus
Possibly return state of RepoManager::checkIfToRefreshMetadata function.
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
RefreshServiceBit
Flags for tuning RefreshService.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
detail::collect_helper collect()
bool isTmpRepo(const RepoInfo &info_r)
Whether repo is not under RM control and provides its own methadata paths.
expected< void > assert_url(const ServiceInfo &info)
expected< void > assert_urls(const RepoInfo &info)
RepoManager< SyncContextRef > SyncRepoManager
std::string filenameFromAlias(const std::string &alias_r, const std::string &stem_r)
Generate a related filename from a repo/service infos alias.
static expected< std::decay_t< Type >, Err > make_expected_success(Type &&t)
RepoManager< ContextRef > AsyncRepoManager
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< void > assert_alias(const RepoInfo &info)
ResultType and_then(const expected< T, E > &exp, Function &&f)
zypp::ServiceInfo ServiceInfo
RepoManagerRef< SyncContextRef > SyncRepoManagerRef
expected< zypp::Pathname > solv_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the solv cache path for a repository.
expected< std::list< RepoInfo > > repositories_in_file(const zypp::Pathname &file)
Reads RepoInfo's from a repo file.
RepoManagerRef< ContextRef > AsyncRepoManagerRef
Iterator findAlias(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Find alias_r in repo/service container.
zypp_private::repo::PluginRepoverification PluginRepoverification
bool foundAliasIn(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Check if alias_r is present in repo/service container.
expected< zypp::Pathname > packagescache_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the packages cache path for a repository.
expected< zypp::Pathname > rawproductdata_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the raw product metadata path for a repository, this is inside the raw cache dir,...
zypp::RepoInfoList RepoInfoList
bool autoPruneInDir(const zypp::Pathname &path_r)
bsc#1204956: Tweak to prevent auto pruning package caches.
Pathname repoSolvCachePath
Pathname repoRawCachePath
Pathname repoPackagesCachePath
Repository type enumeration.
Url::asString() view options.
RepoCollector(std::string targetDistro_)
MatchServiceAlias(std::string alias_)
bool operator()(const RepoInfo &info) const
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
#define ZYPP_FWD_DECL_TEMPL_TYPE_WITH_REFS_ARG1(T, TArg1)
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)