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 420 return it ==
_services.end() ? ServiceInfo::noService : *it;
466 template<
typename OutputIterator>
510 #endif //ZYPP_NG_REPOMANAGER_INCLUDED expected< void > modifyService(const std::string &oldAlias, const ServiceInfo &newService)
Pathname filepath() const
File where this repo was read from.
Pathname path() const
Repository path.
Thrown when the repo alias is found to be invalid.
zypp::RepoStatus RepoStatus
expected< void > addService(const ServiceInfo &service)
RepoSizeType repoSize() const
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
ContextRefType _zyppContext
RepoManagerOptions _options
Pathname repoRawCachePath
ServiceSet::size_type ServiceSizeType
Repository metadata verification beyond GPG.
const RepoManagerOptions & options() const
std::string service() const
Gets name of the service to which this repository belongs or empty string if it has been added manual...
expected< void > removeService(const std::string &alias)
RepoCollector(std::string targetDistro_)
expected< void > removeRepository(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
zypp::RepoManagerFlags::RawMetadataRefreshPolicy RawMetadataRefreshPolicy
expected< RefreshCheckStatus > checkIfToRefreshMetadata(const RepoInfo &info, const zypp::MirroredOrigin &origin, RawMetadataRefreshPolicy policy)
expected< std::list< RepoInfo > > repositories_in_file(const zypp::Pathname &file)
Reads RepoInfo's from a repo file.
ZYPP_ADD_PRIVATE_CONSTR_HELPER()
expected< void > cleanCacheDirGarbage(ProgressObserverRef myProgress=nullptr)
bool operator()(const RepoInfo &info) const
const RepoSet & repos() const
expected< void > refreshGeoIp(const RepoInfo::url_set &urls)
std::list< RepoInfo > RepoInfoList
relates: RepoInfo
expected< void > refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
RepoConstIterator repoEnd() const
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< RepoInfo > addProbedRepository(RepoInfo info, zypp::repo::RepoType probedType)
std::string escaped_alias() const
Same as alias(), just escaped in a way to be a valid file name.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
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
Pathname repoSolvCachePath
expected< zypp::Pathname > packagescache_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the packages cache path for a repository.
zypp::RepoInfoList RepoInfoList
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
expected< bool > isCached(const RepoInfo &info) const
Simple callback to collect the results.
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
RepoSet::size_type RepoSizeType
bool empty() const
Test for an empty path.
zypp::RepoManagerFlags::CacheBuildPolicy CacheBuildPolicy
bool hasService(const std::string &alias) const
bool foundAliasIn(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Check if alias_r is present in repo/service container.
RepoInfo getRepo(const std::string &alias) const
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
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...
RepoConstIterator repoBegin() const
bool collect(const RepoInfo &repo)
PluginRepoverification pluginRepoverification() const
Functor thats filter RepoInfo by service which it belongs to.
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
zypp::Pathname generateNonExistingName(const zypp::Pathname &dir, const std::string &basefilename) const
Generate a non existing filename in a directory, using a base name.
ContextRefType zyppContext() const
std::string alias() const
unique identifier for this source.
std::set< ServiceInfo > ServiceSet
expected< void > cleanCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
expected< void > assert_alias(const RepoInfo &info)
expected< void > removeService(const ServiceInfo &service)
Pathname dirname() const
Return all but the last component od this path.
expected< void > refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
ZYPP_DECL_PRIVATE_CONSTR_ARGS(RepoManager, ContextRef zyppCtx, RepoManagerOptions opt)
expected< RepoInfo > getRepositoryInfo(const std::string &alias)
zypp::DefaultIntegral< bool, false > _reposDirty
MatchServiceAlias(std::string alias_)
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.
std::string generateFilename(const ServiceInfo &info) const
PluginRepoverification _pluginRepoverification
bool isValid() const
Verifies the Url.
expected< RepoInfo > addRepository(const RepoInfo &info, const ProgressObserverRef myProgress=nullptr, const zypp::TriBool &forcedProbe=zypp::indeterminate)
ServiceConstIterator serviceEnd() const
expected< zypp::Pathname > metadataPath(const RepoInfo &info) const
expected< void > setCacheStatus(const RepoInfo &info, const RepoStatus &status)
expected< void > init_knownServices()
Pathname metadataPath() const
Path where this repo metadata was read from.
RepoSet::const_iterator RepoConstIterator
std::string generateFilename(const RepoInfo &info) const
expected< void > loadFromCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
static expected success(ConsParams &&...params)
Url url() const
The service url.
zypp::ServiceInfo ServiceInfo
bool usesAutoMetadataPaths() const
Whether metadataPath uses AUTO% setup.
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.
expected< zypp::Pathname > packagesPath(const RepoInfo &info) const
bool autoPruneInDir(const zypp::Pathname &path_r)
bsc#1204956: Tweak to prevent auto pruning package caches.
ServiceSizeType serviceSize() const
expected< RepoStatus > cacheStatus(const RepoInfo &info) const
expected< void > init_knownRepositories()
expected< void > refreshServices(const RefreshServiceOptions &options_r)
thrown when it was impossible to determine an alias for this repo.
expected< void > assert_urls(const RepoInfo &info)
expected< void > addService(const std::string &alias, const zypp::Url &url)
expected< void > initialize()
Base class for Exception.
FilterIterator< Pred, Base > make_filter_iterator(Pred p, Base it, Base end)
Helper function to deduce types and construct a FilterIterator.
zypp_private::repo::PluginRepoverification PluginRepoverification
ServiceInfo getService(const std::string &alias) const
static expected< void > touchIndexFile(const RepoInfo &info, const RepoManagerOptions &options)
ZYPP_FWD_DECL_TYPE_WITH_REFS(EventDispatcher)
ServiceCollector(ServiceSet &services_r)
expected< RefreshCheckStatus > checkIfToRefreshMetadata(const RepoInfo &info, const zypp::Url &url, RawMetadataRefreshPolicy policy)
Iterator findAlias(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Find alias_r in repo/service container.
auto and_then(Fun &&function)
ServiceSet::const_iterator ServiceConstIterator
Pathname repoPackagesCachePath
static expected< std::shared_ptr< RepoManager > > create(Args &&...args)
Pathname packagesPath() const
packagesPath Checks if the effective user is allowed to write into the system package cache...
Wrapper class for ::stat/::lstat.
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Thrown when the repo alias is found to be invalid.
expected< void > cleanMetadata(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
static expected< RepoStatus > cacheStatus(const RepoInfo &info, const RepoManagerOptions &options)
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< 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.
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::repo::ServiceType > probeService(const zypp::Url &url) const
static zypp::repo::RepoType probeCache(const zypp::Pathname &path_r)
Probe Metadata in a local cache directory.
zypp::RepoManagerFlags::RefreshServiceOptions RefreshServiceOptions
RefreshServiceBit
Flags for tuning RefreshService.
bool hasRepo(const std::string &alias) const
ServiceConstIterator serviceBegin() const
expected< void > refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, ProgressObserverRef myProgress=nullptr)
Refresh local raw cache.
expected< void > addRepositories(const zypp::Url &url, ProgressObserverRef myProgress=nullptr)
Service has no or invalid url defined.
zypp::RepoManagerOptions RepoManagerOptions
expected< RepoInfo > modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, ProgressObserverRef myProgress=nullptr)
Functor collecting ServiceInfos into a ServiceSet.
expected< void > cleanPackages(const RepoInfo &info, ProgressObserverRef myProgress=nullptr, bool isAutoClean=false)
expected< zypp::Pathname > solv_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the solv cache path for a repository.
static expected< RepoStatus > metadataStatus(const RepoInfo &info, const RepoManagerOptions &options)
expected< void > saveService(ServiceInfo &service) const
Repository type enumeration.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
ContextRef ContextRefType