12#ifndef ZYPP_NG_REPOMANAGER_INCLUDED
13#define ZYPP_NG_REPOMANAGER_INCLUDED
28#include <zypp-core/base/DefaultIntegral>
32#include <zypp-core/ng/base/Base>
54 if ( info.
alias().empty() )
58 if ( info.
alias()[0] ==
'.')
60 info,
_(
"Repository alias cannot start with dot."))) );
66 if (info.
alias().empty())
70 if (info.
alias()[0] ==
'.')
72 info,
_(
"Service alias cannot start with dot."))));
78 template <
class Iterator>
79 inline bool foundAliasIn(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
81 for_( it, begin_r, end_r )
82 if ( it->alias() == alias_r )
87 template <
class Container>
88 inline bool foundAliasIn(
const std::string & alias_r,
const Container & cont_r )
89 {
return foundAliasIn( alias_r, cont_r.begin(), cont_r.end() ); }
92 template <
class Iterator>
93 inline Iterator
findAlias(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
95 for_( it, begin_r, end_r )
96 if ( it->alias() == alias_r )
101 template <
class Container>
102 inline typename Container::iterator
findAlias(
const std::string & alias_r, Container & cont_r )
103 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
105 template <
class Container>
106 inline typename Container::const_iterator
findAlias(
const std::string & alias_r,
const Container & cont_r )
107 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
111 std::string
filenameFromAlias(
const std::string & alias_r,
const std::string & stem_r );
261 template <
typename ...Args >
264 auto mgr = std::make_shared< RepoManager >( private_constr_t{}, std::forward<Args>(args)... );
311 bool hasRepo(
const std::string & alias )
const
395 std::vector<std::pair<RepoInfo, expected<void> > >
refreshMetadata(std::vector<RepoInfo> infos, RawMetadataRefreshPolicy policy, ProgressObserverRef myProgress =
nullptr );
420 return it ==
_services.end() ? ServiceInfo::noService : *it;
466 template<
typename OutputIterator>
470 std::copy( boost::make_filter_iterator(
filter,
repos().begin(),
repos().end() ),
#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.
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
packagesPath Checks if the effective user is allowed to write into the system package cache.
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< void > refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
static expected< RepoStatus > cacheStatus(const RepoInfo &info, const RepoManagerOptions &options)
RepoSet::size_type RepoSizeType
RepoInfo getRepo(const std::string &alias) const
expected< void > cleanPackages(const RepoInfo &info, ProgressObserverRef myProgress=nullptr, bool isAutoClean=false)
static expected< void > touchIndexFile(const RepoInfo &info, const RepoManagerOptions &options)
ContextRef ContextRefType
expected< RefreshCheckStatus > checkIfToRefreshMetadata(const RepoInfo &info, const zypp::MirroredOrigin &origin, RawMetadataRefreshPolicy policy)
expected< RepoStatus > cacheStatus(const RepoInfo &info) const
expected< void > removeRepository(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
RepoSet::const_iterator RepoConstIterator
expected< bool > isCached(const RepoInfo &info) const
expected< void > refreshGeoIp(const RepoInfo::url_set &urls)
ZYPP_DECL_PRIVATE_CONSTR_ARGS(RepoManager, ContextRef zyppCtx, RepoManagerOptions opt)
expected< void > buildCache(const RepoInfo &info, CacheBuildPolicy policy, ProgressObserverRef myProgress=nullptr)
expected< RepoInfo > addProbedRepository(RepoInfo info, zypp::repo::RepoType probedType)
std::string generateFilename(const RepoInfo &info) const
expected< void > init_knownServices()
ServiceInfo getService(const std::string &alias) const
ContextRefType zyppContext() const
zypp::RepoManagerFlags::RefreshServiceOptions RefreshServiceOptions
expected< RepoInfo > modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, ProgressObserverRef myProgress=nullptr)
zypp::DefaultIntegral< bool, false > _reposDirty
expected< void > cleanCacheDirGarbage(ProgressObserverRef myProgress=nullptr)
static expected< RepoStatus > metadataStatus(const RepoInfo &info, const RepoManagerOptions &options)
static expected< std::shared_ptr< RepoManager > > create(Args &&...args)
expected< void > setCacheStatus(const RepoInfo &info, const RepoStatus &status)
bool hasRepo(const std::string &alias) const
expected< void > saveService(ServiceInfo &service) const
expected< void > refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, ProgressObserverRef myProgress=nullptr)
Refresh local raw cache.
expected< RefreshCheckStatus > checkIfToRefreshMetadata(const RepoInfo &info, const zypp::Url &url, RawMetadataRefreshPolicy policy)
expected< RepoInfo > getRepositoryInfo(const std::string &alias)
expected< void > removeService(const std::string &alias)
expected< void > addService(const ServiceInfo &service)
zypp::RepoManagerFlags::RawMetadataRefreshPolicy RawMetadataRefreshPolicy
ServiceSet::const_iterator ServiceConstIterator
zypp::RepoManagerFlags::RefreshServiceBit RefreshServiceBit
Flags for tuning RefreshService.
expected< void > refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
expected< void > loadFromCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
static zypp::repo::RepoType probeCache(const zypp::Pathname &path_r)
Probe Metadata in a local cache directory.
const RepoSet & repos() const
ServiceConstIterator serviceBegin() const
zypp::Pathname generateNonExistingName(const zypp::Pathname &dir, const std::string &basefilename) const
ContextRefType _zyppContext
expected< void > removeService(const ServiceInfo &service)
expected< void > touchIndexFile(const RepoInfo &info)
PluginRepoverification pluginRepoverification() const
PluginRepoverification _pluginRepoverification
ZYPP_ADD_PRIVATE_CONSTR_HELPER()
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
RepoConstIterator repoEnd() const
expected< void > cleanCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
RepoConstIterator repoBegin() const
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
expected< void > refreshServices(const RefreshServiceOptions &options_r)
expected< void > initialize()
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
bool serviceEmpty() const
expected< RepoInfo > addRepository(const RepoInfo &info, const ProgressObserverRef myProgress=nullptr, const zypp::TriBool &forcedProbe=zypp::indeterminate)
RepoManagerOptions _options
expected< void > init_knownRepositories()
expected< void > addService(const std::string &alias, const zypp::Url &url)
zypp::RepoManagerFlags::RefreshCheckStatus RefreshCheckStatus
expected< void > addRepositories(const zypp::Url &url, ProgressObserverRef myProgress=nullptr)
expected< zypp::Pathname > packagesPath(const RepoInfo &info) const
ServiceSizeType serviceSize() const
expected< void > cleanMetadata(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
RepoSizeType repoSize() const
expected< void > modifyService(const std::string &oldAlias, const ServiceInfo &newService)
expected< zypp::Pathname > metadataPath(const RepoInfo &info) const
ServiceConstIterator serviceEnd() const
bool hasService(const std::string &alias) const
const RepoManagerOptions & options() const
zypp::RepoManagerFlags::CacheBuildPolicy CacheBuildPolicy
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.
expected< zypp::repo::ServiceType > probeService(const zypp::Url &url) const
ServiceSet::size_type ServiceSizeType
std::string generateFilename(const ServiceInfo &info) const
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)
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)
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
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.
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_)
Functor thats filter RepoInfo by service which it belongs to.
MatchServiceAlias(std::string alias_)
bool operator()(const RepoInfo &info) const
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)