12#ifndef ZYPP_NG_REPOMANAGER_INCLUDED
13#define ZYPP_NG_REPOMANAGER_INCLUDED
26#include <zypp-core/base/DefaultIntegral>
30#include <zypp-core/zyppng/base/Base>
59 if ( info.
alias().empty() )
63 if ( info.
alias()[0] ==
'.')
65 info,
_(
"Repository alias cannot start with dot."))) );
71 if (info.
alias().empty())
75 if (info.
alias()[0] ==
'.')
77 info,
_(
"Service alias cannot start with dot."))));
83 template <
class Iterator>
84 inline bool foundAliasIn(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
86 for_( it, begin_r, end_r )
87 if ( it->alias() == alias_r )
92 template <
class Container>
93 inline bool foundAliasIn(
const std::string & alias_r,
const Container & cont_r )
94 {
return foundAliasIn( alias_r, cont_r.begin(), cont_r.end() ); }
97 template <
class Iterator>
98 inline Iterator
findAlias(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
100 for_( it, begin_r, end_r )
101 if ( it->alias() == alias_r )
106 template <
class Container>
107 inline typename Container::iterator
findAlias(
const std::string & alias_r, Container & cont_r )
108 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
110 template <
class Container>
111 inline typename Container::const_iterator
findAlias(
const std::string & alias_r,
const Container & cont_r )
112 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
116 std::string
filenameFromAlias(
const std::string & alias_r,
const std::string & stem_r );
245 template <
typename ZyppContextRefType>
269 template <
typename ...Args >
272 auto mgr = std::make_shared< RepoManager<ZyppContextRefType> >( private_constr_t{}, std::forward<Args>(args)... );
319 bool hasRepo(
const std::string & alias )
const
424 return it ==
_services.end() ? ServiceInfo::noService : *it;
470 template<
typename OutputIterator>
473 MatchServiceAlias
filter( alias );
474 std::copy( boost::make_filter_iterator(
filter,
repos().begin(),
repos().end() ),
Integral type with defined initial value when default constructed.
Base class for Exception.
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...
expected< RepoStatus > cacheStatus(const RepoInfo &info) const
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
expected< void > refreshServices(const RefreshServiceOptions &options_r)
expected< void > addService(const std::string &alias, const zypp::Url &url)
static expected< RepoStatus > cacheStatus(const RepoInfo &info, const RepoManagerOptions &options)
RepoInfo getRepo(const std::string &alias) const
bool serviceEmpty() 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_ENABLE_MAYBE_ASYNC_MIXIN((std::is_same_v< ZyppContextRefType, ContextRef >))
ServiceConstIterator serviceBegin() const
std::set< RepoInfo > RepoSet
RepoConstIterator repoBegin() const
std::string generateFilename(const ServiceInfo &info) const
expected< zypp::Pathname > metadataPath(const RepoInfo &info) const
const RepoSet & repos() const
expected< void > addService(const ServiceInfo &service)
expected< void > refreshGeoIp(const RepoInfo::url_set &urls)
expected< void > removeService(const std::string &alias)
expected< void > cleanPackages(const RepoInfo &info, ProgressObserverRef myProgress=nullptr, bool isAutoClean=false)
ServiceSizeType serviceSize() const
std::string generateFilename(const RepoInfo &info) 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< RepoInfo > getRepositoryInfo(const zypp::Url &url, const zypp::url::ViewOption &urlview)
RepoSet::const_iterator RepoConstIterator
expected< RepoInfo > modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, ProgressObserverRef myProgress=nullptr)
RepoSet::size_type RepoSizeType
ContextRefType zyppContext() const
static zypp::repo::RepoType probeCache(const zypp::Pathname &path_r)
Probe Metadata in a local cache directory.
expected< void > init_knownServices()
expected< void > refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
expected< RepoInfo > addProbedRepository(RepoInfo info, zypp::repo::RepoType probedType)
expected< zypp::repo::RepoType > probe(const zypp::Url &url, const zypp::Pathname &path=zypp::Pathname()) const
Probe the metadata type of a repository located at url.
RepoSizeType repoSize() const
expected< void > cleanCacheDirGarbage(ProgressObserverRef myProgress=nullptr)
expected< RefreshCheckStatus > checkIfToRefreshMetadata(const RepoInfo &info, const zypp::Url &url, RawMetadataRefreshPolicy policy)
bool hasRepo(const std::string &alias) const
std::set< ServiceInfo > ServiceSet
expected< RepoInfo > addRepository(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
RepoConstIterator repoEnd() const
ContextRefType _zyppContext
expected< zypp::repo::ServiceType > probeService(const zypp::Url &url) const
bool hasService(const std::string &alias) 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< zypp::Pathname > packagesPath(const RepoInfo &info) const
zypp::RepoManagerFlags::RefreshServiceOptions RefreshServiceOptions
zypp::DefaultIntegral< bool, false > _reposDirty
ServiceInfo getService(const std::string &alias) const
zypp::RepoManagerFlags::RawMetadataRefreshPolicy RawMetadataRefreshPolicy
ZYPP_DECL_PRIVATE_CONSTR_ARGS(RepoManager, ZyppContextRefType zyppCtx, RepoManagerOptions opt)
ZyppContextRefType ContextRefType
expected< void > addRepositories(const zypp::Url &url, ProgressObserverRef myProgress=nullptr)
static expected< std::shared_ptr< RepoManager< ZyppContextRefType > > > create(Args &&...args)
expected< void > setCacheStatus(const RepoInfo &info, const RepoStatus &status)
RepoManagerOptions _options
zypp_private::repo::PluginRepoverification _pluginRepoverification
typename ZyppContextRefType::element_type ContextType
ServiceSet::size_type ServiceSizeType
expected< void > init_knownRepositories()
expected< void > cleanCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
expected< void > loadFromCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
expected< bool > isCached(const RepoInfo &info) const
expected< void > cleanMetadata(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
static expected< RepoStatus > metadataStatus(const RepoInfo &info, const RepoManagerOptions &options)
ZYPP_ADD_PRIVATE_CONSTR_HELPER()
zypp::RepoManagerFlags::RefreshServiceBit RefreshServiceBit
expected< void > removeRepository(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
zypp::RepoManagerFlags::RefreshCheckStatus RefreshCheckStatus
expected< void > saveService(ServiceInfo &service) const
std::vector< std::pair< RepoInfo, expected< void > > > refreshMetadata(std::vector< RepoInfo > infos, RawMetadataRefreshPolicy policy, ProgressObserverRef myProgress=nullptr)
expected< void > refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
const RepoManagerOptions & options() const
ServiceConstIterator serviceEnd() const
expected< void > removeService(const ServiceInfo &service)
ServiceSet::const_iterator ServiceConstIterator
zypp::RepoManagerFlags::CacheBuildPolicy CacheBuildPolicy
ServiceCollector(ServiceSet &services_r)
bool operator()(const ServiceInfo &service_r) const
std::set< ServiceInfo > ServiceSet
static expected success(ConsParams &&...params)
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.
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_)
bool operator()(const RepoInfo &info) const
MatchServiceAlias(std::string alias_)
#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)