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> 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 425 return it ==
_services.end() ? ServiceInfo::noService : *it;
471 template<
typename OutputIterator>
476 boost::make_filter_iterator( filter,
repos().end(),
repos().end() ),
515 #endif //ZYPP_NG_REPOMANAGER_INCLUDED static expected< std::shared_ptr< RepoManager< ZyppContextRefType > > > create(Args &&...args)
Pathname filepath() const
File where this repo was read from.
expected< void > modifyService(const std::string &oldAlias, const ServiceInfo &newService)
ZyppContextRefType ContextRefType
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
Pathname path() const
Repository path.
Thrown when the repo alias is found to be invalid.
zypp::RepoStatus RepoStatus
RepoInfo getRepo(const std::string &alias) const
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
expected< void > init_knownServices()
bool operator()(const RepoInfo &info) const
Pathname repoRawCachePath
Repository metadata verification beyond GPG.
expected< void > saveService(ServiceInfo &service) const
std::string service() const
Gets name of the service to which this repository belongs or empty string if it has been added manual...
RepoCollector(std::string targetDistro_)
bool hasRepo(const std::string &alias) const
const RepoManagerOptions & options() const
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
expected< void > addService(const std::string &alias, const zypp::Url &url)
ServiceConstIterator serviceBegin() const
bool hasService(const std::string &alias) const
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< zypp::Pathname > metadataPath(const RepoInfo &info) const
expected< std::list< RepoInfo > > repositories_in_file(const zypp::Pathname &file)
Reads RepoInfo's from a repo file.
expected< void > removeService(const ServiceInfo &service)
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
expected< RepoInfo > addProbedRepository(RepoInfo info, zypp::repo::RepoType probedType)
zypp::RepoManagerFlags::CacheBuildPolicy CacheBuildPolicy
bool isTmpRepo(const RepoInfo &info_r)
Whether repo is not under RM control and provides its own methadata paths.
What is known about a repository.
static expected< std::decay_t< Type >, Err > make_expected_success(Type &&t)
expected< void > cleanCacheDirGarbage(ProgressObserverRef myProgress=nullptr)
std::string escaped_alias() const
Same as alias(), just escaped in a way to be a valid file name.
zypp::DefaultIntegral< bool, false > _reposDirty
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
Service without alias was used in an operation.
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
Url::asString() view options.
expected< void > assert_url(const ServiceInfo &info)
bool serviceEmpty() const
expected< void > refreshServices(const RefreshServiceOptions &options_r)
static zypp::repo::RepoType probeCache(const zypp::Pathname &path_r)
Probe Metadata in a local cache directory.
static expected< void > touchIndexFile(const RepoInfo &info, const RepoManagerOptions &options)
Pathname repoSolvCachePath
expected< zypp::Pathname > packagescache_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the packages cache path for a repository.
RepoSet::size_type RepoSizeType
ContextRefType _zyppContext
zypp::RepoInfoList RepoInfoList
static expected< RepoStatus > metadataStatus(const RepoInfo &info, const RepoManagerOptions &options)
ZYPP_DECL_PRIVATE_CONSTR_ARGS(RepoManager, ZyppContextRefType zyppCtx, RepoManagerOptions opt)
RepoConstIterator repoEnd() const
ZYPP_ADD_PRIVATE_CONSTR_HELPER()
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
Simple callback to collect the results.
std::string generateFilename(const ServiceInfo &info) const
expected< void > addRepositories(const zypp::Url &url, ProgressObserverRef myProgress=nullptr)
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
bool empty() const
Test for an empty path.
bool foundAliasIn(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Check if alias_r is present in repo/service container.
const RepoSet & repos() const
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_FWD_DECL_TYPE_WITH_REFS(Context)
PluginRepoverification _pluginRepoverification
bool collect(const RepoInfo &repo)
Functor thats filter RepoInfo by service which it belongs to.
expected< void > loadFromCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
std::string alias() const
unique identifier for this source.
std::set< ServiceInfo > ServiceSet
ServiceSizeType serviceSize() const
RepoManagerRef< SyncContextRef > SyncRepoManagerRef
expected< void > assert_alias(const RepoInfo &info)
Pathname dirname() const
Return all but the last component od this path.
ZYPP_FWD_DECL_TEMPL_TYPE_WITH_REFS_ARG1(RepoManager, ZyppContextRefType)
RepoConstIterator repoBegin() const
ServiceInfo getService(const std::string &alias) const
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 > refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
expected< RepoInfo > addRepository(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
expected< RefreshCheckStatus > checkIfToRefreshMetadata(const RepoInfo &info, const zypp::Url &url, RawMetadataRefreshPolicy policy)
bool isValid() const
Verifies the Url.
RepoSet::const_iterator RepoConstIterator
Pathname metadataPath() const
Path where this repo metadata was read from.
ZYPP_ENABLE_MAYBE_ASYNC_MIXIN((std::is_same_v< ZyppContextRefType, ContextRef >))
static expected success(ConsParams &&...params)
Url url() const
The service url.
zypp::ServiceInfo ServiceInfo
bool usesAutoMetadataPaths() const
Whether metadataPath uses AUTO% setup.
zypp::RepoManagerFlags::RefreshServiceOptions RefreshServiceOptions
expected< RepoInfo > getRepositoryInfo(const std::string &alias)
expected< void > buildCache(const RepoInfo &info, CacheBuildPolicy policy, ProgressObserverRef myProgress=nullptr)
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
static expected< RepoStatus > cacheStatus(const RepoInfo &info, const RepoManagerOptions &options)
bool autoPruneInDir(const zypp::Pathname &path_r)
bsc#1204956: Tweak to prevent auto pruning package caches.
expected< void > cleanMetadata(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
typename ZyppContextRefType::element_type ContextType
expected< RepoStatus > cacheStatus(const RepoInfo &info) const
thrown when it was impossible to determine an alias for this repo.
expected< void > assert_urls(const RepoInfo &info)
expected< void > refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, ProgressObserverRef myProgress=nullptr)
Refresh local raw cache.
ServiceConstIterator serviceEnd() const
Base class for Exception.
ServiceSet::size_type ServiceSizeType
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
zypp_private::repo::PluginRepoverification PluginRepoverification
expected< void > refreshGeoIp(const RepoInfo::url_set &urls)
ServiceCollector(ServiceSet &services_r)
expected< void > addService(const ServiceInfo &service)
expected< void > setCacheStatus(const RepoInfo &info, const RepoStatus &status)
zypp::RepoManagerFlags::RawMetadataRefreshPolicy RawMetadataRefreshPolicy
Iterator findAlias(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Find alias_r in repo/service container.
expected< void > removeRepository(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
auto and_then(Fun &&function)
RepoManagerOptions _options
expected< zypp::repo::ServiceType > probeService(const zypp::Url &url) const
Pathname repoPackagesCachePath
Pathname packagesPath() const
Path where this repo packages are cached.
expected< bool > isCached(const RepoInfo &info) const
Wrapper class for ::stat/::lstat.
expected< void > removeService(const std::string &alias)
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
expected< void > initialize()
Thrown when the repo alias is found to be invalid.
RepoManagerRef< ContextRef > AsyncRepoManagerRef
std::string generateFilename(const RepoInfo &info) const
bool operator()(const ServiceInfo &service_r) const
RefreshCheckStatus
Possibly return state of RepoManager::checkIfToRefreshMetadata function.
ResultType and_then(const expected< T, E > &exp, Function &&f)
expected< void > cleanPackages(const RepoInfo &info, ProgressObserverRef myProgress=nullptr, bool isAutoClean=false)
expected< void > init_knownRepositories()
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.
Track changing files or directories.
The RepoManager class Provides knowledge and methods to maintain repo settings and metadata for a giv...
MatchServiceAlias(std::string alias_)
std::string filenameFromAlias(const std::string &alias_r, const std::string &stem_r)
Generate a related filename from a repo/service infos alias.
expected< zypp::Pathname > packagesPath(const RepoInfo &info) const
ContextRefType zyppContext() const
ServiceSet::const_iterator ServiceConstIterator
RefreshServiceBit
Flags for tuning RefreshService.
expected< void > refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
PluginRepoverification pluginRepoverification() const
Service has no or invalid url defined.
zypp::RepoManagerOptions RepoManagerOptions
Functor collecting ServiceInfos into a ServiceSet.
expected< zypp::Pathname > solv_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the solv cache path for a repository.
expected< void > cleanCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
Repository type enumeration.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
expected< RepoInfo > modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, ProgressObserverRef myProgress=nullptr)