13#include <solv/solvversion.h>
14#include <solv/repo_solv.h>
22#include <zypp-core/ng/pipelines/MTry>
23#include <zypp-core/ng/pipelines/Transform>
25#include <zypp-core/ng/ui/ProgressObserver>
46#undef ZYPP_BASE_LOGGER_LOGGROUP
47#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::repomanager"
61 const char *
env = getenv(
"ZYPP_PLUGIN_APPDATA_FORCE_COLLECT");
72 inline void cleanupNonRepoMetadataFolders(
const zypp::Pathname & cachePath_r,
74 const std::list<std::string> & repoEscAliases_r )
76 if ( cachePath_r != defaultCachePath_r )
79 std::list<std::string> entries;
83 std::set<std::string> oldfiles;
84 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
85 std::inserter( oldfiles, oldfiles.end() ) );
91 for (
const std::string & old : oldfiles )
95 pi( cachePath_r/old );
108#define OUTS(V) case zypp::RepoManagerFlags::V: str << #V; break
109 OUTS( RefreshIfNeeded );
110 OUTS( RefreshForced );
111 OUTS( RefreshIfNeededIgnoreDelay );
120#define OUTS(V) case zypp::RepoManagerFlags::V: str << #V; break
121 OUTS( REFRESH_NEEDED );
122 OUTS( REPO_UP_TO_DATE );
123 OUTS( REPO_CHECK_DELAYED );
132#define OUTS(V) case zypp::RepoManagerFlags::V: str << #V; break
133 OUTS( BuildIfNeeded );
143 std::string filename( alias_r );
148 MIL <<
"generating filename for " << stem_r <<
" [" << alias_r <<
"] : '" << filename <<
"'" << std::endl;
156 && !
repo.targetDistribution().empty()
160 <<
"Skipping repository meant for '" <<
repo.targetDistribution()
161 <<
"' distribution (current distro is '"
174 MIL <<
"repo file: " << file << std::endl;
192 template <
typename ZContextRef>
195 MIL <<
"directory " << dir << std::endl;
196 std::list<RepoInfo> repos;
197 bool nonroot( geteuid() != 0 );
204 std::list<zypp::Pathname> entries;
212 for ( std::list<zypp::Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
223 repos.insert( repos.end(), tmp.begin(), tmp.end() );
233 if (
info.repoOriginsEmpty() )
243 : _zyppContext(
std::move(zyppCtx) )
244 , _options(
std::move(opt) )
245 , _pluginRepoverification( _options.pluginsPath /
"repoverification",
255 && geteuid() == 0 && (
_options.rootDir.empty() ||
_options.rootDir ==
"/" ) )
258 std::list<zypp::Pathname> entries;
260 if ( ! entries.empty() )
263 cmd.push_back(
"<" );
264 cmd.push_back(
">" );
265 cmd.push_back(
"PROGRAM" );
266 for (
const auto & rinfo :
repos() )
268 if ( ! rinfo.enabled() )
270 cmd.push_back(
"-R" );
271 cmd.push_back( rinfo.alias() );
272 cmd.push_back(
"-t" );
273 cmd.push_back( rinfo.type().asString() );
274 cmd.push_back(
"-p" );
275 cmd.push_back( (rinfo.metadataPath()/rinfo.path()).asString() );
278 for_( it, entries.begin(), entries.end() )
324 mediarootpath = std::move(mrPath);
338 switch ( repokind.
toEnum() )
341 status =
RepoStatus( productdatapath/
"repodata/repomd.xml");
342 if (
info.requireStatusWithMediaFile() )
343 status = status &&
RepoStatus( mediarootpath/
"media.1/media" );
347 status =
RepoStatus( productdatapath/
"content" ) &&
RepoStatus( mediarootpath/
"media.1/media" );
364 if ( ! status.
empty() )
429 MIL <<
"going to probe the cached repo at " << path_r << std::endl;
440 MIL <<
"Probed cached type " << ret <<
" at " << path_r << std::endl;
448 MIL <<
"Going to clean up garbage in cache dirs" << std::endl;
451 std::list<zypp::Pathname> cachedirs;
452 cachedirs.push_back(
_options.repoRawCachePath);
453 cachedirs.push_back(
_options.repoPackagesCachePath);
454 cachedirs.push_back(
_options.repoSolvCachePath);
459 for(
const auto &dir : cachedirs )
468 std::list<zypp::Pathname> entries;
473 if ( !entries.size() )
477 for(
const auto &subdir : entries )
482 if ( subdir.basename() == r->escaped_alias() )
483 { found =
true;
break; }
509 MIL <<
"Removing raw metadata cache for " <<
info.alias() << std::endl;
526 bool poolSnapshotEnabled()
528 const char * e = ::getenv(
"ZYPP_POOL_SNAPSHOT" );
529 return !( e && strcmp( e,
"0" ) == 0 );
534 {
return _options.repoCachePath /
"pool.snapshot"; }
544 MIL <<
"Removing pool snapshot " << snapshot << std::endl;
548 std::list<zypp::Pathname> entries;
554 MIL <<
"Removing leftover " << entry << std::endl;
570 std::vector<std::string> aliases;
571 std::vector<zypp::Pathname> cookiefiles;
574 if ( !
info.enabled() )
578 aliases.push_back(
info.alias() );
580 return std::string();
584 aliases.push_back(
"@System" );
585 cookiefiles.push_back(
_options.repoSolvCachePath /
"@System" /
"cookie" );
587 std::vector<size_t> idx( aliases.size() );
588 for (
size_t n = 0; n < idx.size(); n++ ) idx[n] = n;
589 std::sort( idx.begin(), idx.end(), [&](
size_t a,
size_t b ){ return aliases[a] < aliases[b]; } );
592 if ( ! dig.
create(
"sha256" ) )
593 return std::string();
598 const std::string version { std::string(::solv_toolversion) +
" " + ::solv_version };
599 dig.
update( version.c_str(), version.size() + 1 );
601 dig.
update( arch.c_str(), arch.size() );
602 for (
size_t n : idx )
604 std::ifstream is( cookiefiles[n].c_str() );
605 std::string content { std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>() };
606 if ( content.empty() )
608 if ( aliases[n] !=
"@System" )
613 MIL <<
"Not using the pool snapshot: repo " << aliases[n] <<
" has no solv cache" << std::endl;
614 return std::string();
626 dig.
update( aliases[n].c_str(), aliases[n].size() + 1 );
627 dig.
update( content.c_str(), content.size() );
637 if ( ! poolSnapshotEnabled() )
640 if ( cookie.empty() )
643 std::vector<std::string> aliases;
645 if (
info.enabled() )
646 aliases.push_back(
info.alias() );
647 aliases.push_back(
"@System" );
648 std::sort( aliases.begin(), aliases.end() );
650 if ( !
pool.reposEmpty() )
656 MIL <<
"Not using the pool snapshot: the pool already holds repos, "
657 "load the repos before the target to make use of it" << std::endl;
660 pool.setSnapshotCandidate( path, cookie, aliases );
661 if (
pool.mapSnapshot( path, cookie ) )
671 unsigned numid = 0, numrel = 0;
674 if ( !
info.enabled() )
682 FILE * fp = ::fopen( solvfile.
c_str(),
"re" );
685 unsigned nid = 0, nrel = 0;
686 if ( ::solv_read_idcounts( fp, &nid, &nrel ) == 0 )
693 if ( numid || numrel )
695 MIL <<
"Reserving pool ids for " << numid <<
" strings, " << numrel <<
" rels" << std::endl;
718 MIL <<
"Repo " <<
info.alias() <<
" provided by the pool snapshot" << std::endl;
743 if ( toolversion != LIBSOLV_TOOLVERSION ) {
744 repo.eraseFromPool();
748 |
or_else( [
this,
info, myProgress]( std::exception_ptr exp ) {
750 MIL <<
"Try to handle exception by rebuilding the solv-file" << std::endl;
763 |
or_else([myProgress](
auto ex ){
782 MIL <<
"Saving repo in " << repofile << std::endl;
784 std::ofstream file(repofile.
c_str());
791 tosave.dumpAsIniOn(file);
792 tosave.setFilepath(repofile);
817 MIL <<
"Going to delete repo " <<
info.alias() << std::endl;
824 if ( (!
info.alias().empty()) && (
info.alias() !=
repo.alias() ) )
840 if ( filerepos.size() == 0
841 ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.
alias() ) )
845 if ( ! ( ret == 0 || ret == ENOENT ) )
850 MIL << todelete.
alias() <<
" successfully deleted." << std::endl;
868 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
869 fit != filerepos.end();
872 if ( (*fit).alias() != todelete.
alias() )
873 (*fit).dumpAsIniOn(file);
884 MIL << todelete.
alias() <<
" successfully deleted." << std::endl;
940 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
941 fit != filerepos.end();
946 if ( (*fit).alias() != toedit.
alias() )
947 (*fit).dumpAsIniOn(file);
976 MIL <<
"repo " << alias <<
" modified" << std::endl;
993 if ( it !=
repos().end() )
994 return make_expected_success(*it);
996 info.setAlias( alias );
1011 for(
const auto &origin : it->repoOrigins() )
1013 if ( std::any_of( origin.begin(), origin.end(), [&
url, &urlview](
const zypp::OriginEndpoint &ep ){ return (ep.url().asString(urlview) == url.asString(urlview)); }) )
1014 return make_expected_success(*it);
1032 | [
this,
info](
auto) { return zyppng::repo::RefreshContext::create( _zyppContext, info, shared_this<RepoManager>() ); }
1033 |
and_then( [
this, origin, policy]( zyppng::repo::RefreshContextRef &&refCtx ) {
1051 if (
info.alias() ==
repo.alias() )
1054 modifiedrepo.
setType( repokind );
1063 auto urls =
info.baseUrls ();
1064 if (
info.mirrorListUrl ().isValid () )
1065 urls.push_back (
info.mirrorListUrl () );
1071 |
and_then( [policy, myProgress, cb = updateProbedType]( repo::RefreshContextRef refCtx ) {
1094 auto r = std::move(infos)
1104 if (
info.alias() ==
repo.alias() )
1107 modifiedrepo.
setType( repokind );
1122 |
and_then( [policy, subProgress, cb = updateProbedType]( repo::RefreshContextRef refCtx ) {
1130 |
and_then([subProgress]( repo::RefreshContextRef ctx ) {
1133 ctx->repoManager()->reposManip();
1148 | [myProgress](
auto res ) {
1169 std::transform( origin.
begin (), origin.
end(), std::back_inserter(allUrls), [](
const zypp::OriginEndpoint &ep ){ return ep.url(); } );
1174 |
and_then( [
this, path = path](
auto mediaHandle ) {
1192 |
and_then( [policy, myProgress]( repo::RefreshContextRef refCtx ) {
1197 if ( !statusBefore || !statusAfter || !( *statusBefore == *statusAfter ) )
1243 MIL <<
"added service " << toSave.
alias() << std::endl;
1270 std::vector<ServiceInfo> servicesVec;
1271 std::copy( std::make_move_iterator(servicesCopy.begin()), std::make_move_iterator(servicesCopy.end()), std::back_inserter(servicesVec));
1274 std::move(servicesVec)
1287 MIL <<
"Going to delete service " << alias << std::endl;
1292 if( location.
empty() )
1301 if ( tmpSet.size() == 1 )
1308 MIL << alias <<
" successfully deleted." << std::endl;
1314 std::ofstream file(location.
c_str());
1321 for_(it, tmpSet.begin(), tmpSet.end())
1323 if( it->alias() != alias )
1324 it->dumpAsIniOn(file);
1327 MIL << alias <<
" successfully deleted from file " << location << std::endl;
1333 boost::make_function_output_iterator( std::bind( &
RepoCollector::collect, &rcollector, std::placeholders::_1 ) ) );
1350 MIL <<
"Going to modify service " << oldAlias << std::endl;
1356 if ( service.
type() == zypp::repo::ServiceType::PLUGIN )
1364 if( location.
empty() )
1374 std::ofstream file(location.
c_str());
1375 for_(it, tmpSet.begin(), tmpSet.end())
1377 if( *it != oldAlias )
1378 it->dumpAsIniOn(file);
1391 if ( oldAlias != service.
alias()
1394 std::vector<RepoInfo> toModify;
1396 for_( it, toModify.begin(), toModify.end() )
1403 const auto & last = service.
repoStates().find( it->alias() );
1405 it->setEnabled( last->second.enabled );
1408 it->setEnabled(
false );
1411 if ( oldAlias != service.
alias() )
1412 it->setService(service.
alias());
1438 MIL <<
"saving service in " << servfile << std::endl;
1440 std::ofstream file( servfile.
c_str() );
1447 MIL <<
"done" << std::endl;
1473 const std::string & basefilename )
const
1475 std::string final_filename = basefilename;
1491 zypp::repo::RepoType repokind =
info.type();
1494 repokind = probeCache( productdatapath );
1497 return expected<void>::success();
1500 switch ( repokind.
toEnum() )
1503 p = zypp::Pathname(productdatapath +
"/repodata/repomd.xml");
1507 p = zypp::Pathname(productdatapath +
"/content");
1511 p = zypp::Pathname(productdatapath +
"/cookie");
1524 return expected<void>::success();
1529 return joinPipeline( _zyppContext, RepoManagerWorkflow::refreshGeoIPData( _zyppContext, urls) );
1532 expected<void> RepoManager::touchIndexFile(
const RepoInfo &
info )
1534 return touchIndexFile(
info, _options );
1538 expected<void> RepoManager::init_knownServices()
1541 zypp::Pathname dir = _options.knownServicesPath;
1542 std::list<zypp::Pathname> entries;
1543 if (zypp::PathInfo(dir).isExist())
1552 for_(it, entries.begin(), entries.end() )
1554 zypp::parser::ServiceFileReader(*it, ServiceCollector(_services));
1558 zypp::repo::PluginServices(_options.pluginsPath/
"services", ServiceCollector(_services));
1560 return expected<void>::success();
1563 return expected<void>::error( std::current_exception () );
1577 const std::list<std::string> & repoEscAliases_r )
1582 if ( cachePath_r != defaultCachePath_r )
1585 std::list<std::string> entries;
1589 std::set<std::string> oldfiles;
1590 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
1591 std::inserter( oldfiles, oldfiles.end() ) );
1597 for (
const std::string & old : oldfiles )
1601 pi( cachePath_r/old );
1616 MIL <<
"start construct known repos" << std::endl;
1620 std::list<std::string> repoEscAliases;
1621 std::list<RepoInfo> orphanedRepos;
1632 const std::string & serviceAlias( repoInfo.service() );
1633 if ( ! ( serviceAlias.empty() ||
hasService( serviceAlias ) ) )
1635 WAR <<
"Schedule orphaned service repo for deletion: " << repoInfo << std::endl;
1636 orphanedRepos.push_back( repoInfo );
1640 repoEscAliases.push_back(repoInfo.escaped_alias());
1644 if ( ! orphanedRepos.empty() )
1646 for (
const auto & repoInfo : orphanedRepos )
1648 MIL <<
"Delete orphaned service repo " << repoInfo.alias() << std::endl;
1653 % repoInfo.service()
1654 % repoInfo.alias() );
1672 repoEscAliases.sort();
1686 MIL <<
"end construct known repos" << std::endl;
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
#define ZYPP_FWD_CURRENT_EXCPT()
Drops a logline and returns the current Exception as a std::exception_ptr.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
const std::string & asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static const ValueType day
static Date now()
Return the current time.
Compute Message Digests (MD5, SHA1 etc).
std::string digest()
get hex string representation of the digest
bool update(const char *bytes, size_t len)
feed data into digest computation algorithm
bool create(const std::string &name)
initialize creation of a new message digest
Base class for Exception.
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::vector< std::string > Arguments
Writing the zypp history file.
void modifyRepository(const RepoInfo &oldrepo, const RepoInfo &newrepo)
Log certain modifications to a repository.
void addRepository(const RepoInfo &repo)
Log a newly added repository.
void removeRepository(const RepoInfo &repo)
Log recently removed repository.
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
endpoint_iterator begin()
Represents a single, configurable network endpoint, combining a URL with specific access settings.
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Unless path_r does not already denote a path below root_r, combine them.
What is known about a repository.
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
url_set baseUrls() const
The complete set of repository urls as configured.
std::ostream & dumpAsIniOn(std::ostream &str) const override
Write this RepoInfo object into str in a .repo file format.
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
void setType(const repo::RepoType &t)
set the repository type
void cleanCacheDirGarbage(const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove any subdirectories of cache directories which no longer belong to any of known repositories.
void cleanMetadata(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local metadata.
void addService(const std::string &alias, const Url &url)
Adds a new service by its alias and URL.
void removeService(const std::string &alias)
Removes service specified by its name.
repo::ServiceType probeService(const Url &url) const
Probe the type or the service.
void cleanCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
clean local cache
void refreshServices(const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refreshes all enabled services.
void addRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds a repository to the list of known repositories.
void addRepositories(const Url &url, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds repositores from a repo file to the list of known repositories.
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy=RefreshIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local raw cache.
void refreshGeoIp(const RepoInfo::url_set &urls)
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refresh specific service.
void modifyRepository(const std::string &alias, const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Modify repository attributes.
void removeRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove the best matching repository from known repos list.
RepoInfo getRepositoryInfo(const std::string &alias, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Find a matching repository info.
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy=RefreshIfNeeded)
Checks whether to refresh metadata for specified repository and url.
void buildCache(const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local cache.
RepoManager(RepoManagerOptions options=RepoManagerOptions())
void loadFromCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Load resolvables into the pool.
void cleanPackages(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local package cache.
RepoStatus metadataStatus(const RepoInfo &info) const
Status of local metadata.
void modifyService(const std::string &oldAlias, const ServiceInfo &service)
Modifies service file (rewrites it with new values) and underlying repositories if needed.
repo::RepoType probe(const Url &url, const Pathname &path) const
Probe repo metadata type.
Track changing files or directories.
static RepoStatus fromCookieFileUseMtime(const Pathname &path)
Reads the status from a cookie file but uses the files mtime.
bool empty() const
Whether the status is empty (empty checksum).
RepoStatus()
Default ctor.
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
repo::ServiceType type() const
Service type.
const RepoStates & repoStates() const
Access the remembered repository states.
Url url() const
The service url.
std::ostream & dumpAsIniOn(std::ostream &str) const override
Writes ServiceInfo to stream in ".service" format.
Arch systemArchitecture() const
The system architecture zypp uses.
static ZConfig & instance()
Singleton ctor.
Wrapper class for stat/lstat.
const Pathname & path() const
Return current Pathname.
bool isExist() const
Return whether valid stat info exists.
const std::string & asString() const
Return current Pathname as String.
Pathname extend(const std::string &r) const
Append string r to the last component of the path.
Pathname dirname() const
Return all but the last component od this path.
const char * c_str() const
String representation.
const std::string & asString() const
String representation.
bool empty() const
Test for an empty path.
Read repository data from a .repo file.
Read service data from a .service file.
Repository already exists and some unique attribute can't be duplicated.
Exception for repository handling.
void setFilepath(const Pathname &filename)
set the path to the .repo file
Pathname filepath() const
File where this repo was read from.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
std::string alias() const
unique identifier for this source.
thrown when it was impossible to determine one url for this repo.
The repository cache is not built yet so you can't create the repostories from the cache.
thrown when it was impossible to match a repository
Service already exists and some unique attribute can't be duplicated.
Base Exception for service handling.
Service plugin is immutable.
Lightweight repository attribute value lookup.
RAII: while any instance lives, detail::PoolImpl::prepare does not erase snapshot repos this run has ...
static const SolvAttr repositoryToolVersion
std::shared_ptr< T > shared_this() const
JobReportHelper(ContextRef r)
bool error(std::string msg_r, UserData userData_r=UserData())
send error text
bool warning(std::string msg_r, UserData userData_r=UserData())
send warning text
static void increase(ProgressObserverRef progress, double inc=1.0, const std::optional< std::string > &newLabel={})
static ProgressObserverRef makeSubTask(ProgressObserverRef parentProgress, float weight=1.0, const std::string &label=std::string(), int steps=100)
static void setup(ProgressObserverRef progress, const std::string &label=std::string(), int steps=100)
static void finish(ProgressObserverRef progress, ProgressObserver::FinishResult result=ProgressObserver::Success)
void setCurrent(double curr)
std::string poolSnapshotCookie() const
Cookie describing the enabled repos and their solv caches, empty if the pool snapshot cannot be used.
expected< void > cleanPackages(const RepoInfo &info, ProgressObserverRef myProgress=nullptr, bool isAutoClean=false)
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 > 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
zypp::Pathname poolSnapshotPath() const
Where the pool snapshot lives.
expected< void > init_knownServices()
ServiceInfo getService(const std::string &alias) const
zypp::RepoManagerFlags::RefreshServiceOptions RefreshServiceOptions
expected< RepoInfo > modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, ProgressObserverRef myProgress=nullptr)
zypp::DefaultIntegral< bool, false > _reposDirty
static expected< RepoStatus > metadataStatus(const RepoInfo &info, const RepoManagerOptions &options)
bool hasRepo(const std::string &alias) const
expected< void > saveService(ServiceInfo &service) const
expected< RepoInfo > getRepositoryInfo(const std::string &alias)
zypp::RepoManagerFlags::RawMetadataRefreshPolicy RawMetadataRefreshPolicy
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
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
RepoConstIterator repoEnd() const
expected< void > cleanCache(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
RepoConstIterator repoBegin() const
expected< void > initialize()
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
RepoManagerOptions _options
expected< void > init_knownRepositories()
int _poolSnapshotState
0 unknown, 1 mapped, -1 unusable
expected< void > cleanMetadata(const RepoInfo &info, ProgressObserverRef myProgress=nullptr)
bool tryLoadPoolSnapshot()
Try to map the pool snapshot on the first loadFromCache, and arm writing a fresh one after a normal l...
void reservePoolIds()
Peek at the solv files of all enabled repos and size the pool's id hashes once for their sum,...
ServiceConstIterator serviceEnd() const
bool hasService(const std::string &alias) const
const RepoManagerOptions & options() const
void cleanPoolSnapshot() const
Remove the pool snapshot and any leftover of an interrupted write.
zypp::RepoManagerFlags::CacheBuildPolicy CacheBuildPolicy
zypp::DefaultIntegral< bool, false > _poolIdsReserved
Functor collecting ServiceInfos into a ServiceSet.
static expected success(ConsParams &&...params)
static expected error(ConsParams &&...params)
SignalProxy< void(zypp::repo::RepoType)> sigProbedTypeChanged()
static expected< repo::RefreshContextRef > create(ContextRef zyppContext, zypp::RepoInfo info, RepoManagerRef repoManager)
CURL handle void p CURLversion age struct curl_slist list CURLM multi CURLM CURL handle CURLM curl_socket_t int int running_handles CURLINFO info
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
bool regex_match(const char *s, smatch &matches, const regex ®ex) ZYPP_API
Regular expression matching.
String related utilities and Regular expression matching.
RefreshCheckStatus
Possibly return state of RepoManager::checkIfToRefreshMetadata function.
Namespace intended to collect all environment variables we use.
bool ZYPP_PLUGIN_APPDATA_FORCE_COLLECT()
To trigger appdata refresh unconditionally.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
int unlink(const Pathname &path)
Like 'unlink'.
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
int touch(const Pathname &path)
Change file's modification and access times.
std::string & replaceAll(std::string &str_r, const std::string &from_r, const std::string &to_r)
Replace all occurrences of from_r with to_r in str_r (inplace).
std::string numstring(char n, int w=0)
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
MaybeAwaitable< expected< repo::RefreshCheckStatus > > checkIfToRefreshMetadata(repo::RefreshContextRef refCtx, LazyMediaHandle< Provide > medium, ProgressObserverRef progressObserver)
MaybeAwaitable< expected< void > > addRepositories(RepoManagerRef mgr, zypp::Url url, ProgressObserverRef myProgress)
MaybeAwaitable< expected< zypp::repo::RepoType > > probeRepoType(ContextRef ctx, Provide::LazyMediaHandle medium, zypp::Pathname path, std::optional< zypp::Pathname > targetPath)
MaybeAwaitable< expected< RepoInfo > > addRepository(RepoManagerRef mgr, RepoInfo info, ProgressObserverRef myProgress, const zypp::TriBool &forcedProbe)
MaybeAwaitable< expected< repo::RefreshContextRef > > refreshMetadata(repo::RefreshContextRef refCtx, LazyMediaHandle< Provide > medium, ProgressObserverRef progressObserver)
MaybeAwaitable< expected< repo::RefreshContextRef > > buildCache(repo::RefreshContextRef refCtx, zypp::RepoManagerFlags::CacheBuildPolicy policy, ProgressObserverRef progressObserver)
MaybeAwaitable< expected< void > > refreshGeoIPData(ContextRef ctx, RepoInfo::url_set urls)
MaybeAwaitable< expected< void > > refreshService(RepoManagerRef repoMgr, ServiceInfo info, zypp::RepoManagerFlags::RefreshServiceOptions options)
MaybeAwaitable< expected< zypp::repo::ServiceType > > probeServiceType(ContextRef ctx, const zypp::Url &url)
auto incProgress(ProgressObserverRef progressObserver, double progrIncrease=1.0, std::optional< std::string > newStr={})
zypp::RepoManagerFlags::RawMetadataRefreshPolicy RawMetadataRefreshPolicy
bool isTmpRepo(const RepoInfo &info_r)
Whether repo is not under RM control and provides its own methadata paths.
expected< void > assert_urls(const RepoInfo &info)
std::list< RepoInfo > repositories_in_dir(ZContextRef zyppContext, const zypp::Pathname &dir)
List of RepoInfo's from a directory.
void cleanupNonRepoMetadtaFolders(const zypp::Pathname &cachePath_r, const zypp::Pathname &defaultCachePath_r, const std::list< std::string > &repoEscAliases_r)
Generate a non existing filename in a directory, using a base name.
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 > 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 or_else(const expected< T, E > &exp, Function &&f)
ResultType and_then(const expected< T, E > &exp, Function &&f)
auto transform(Container< Msg, CArgs... > &&val, Transformation &&transformation)
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.
std::enable_if_t<!std::is_same_v< void, T >, expected< Container< T >, E > > collect(Container< expected< T, E >, CArgs... > &&in)
expected< zypp::Pathname > packagescache_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the packages cache path for a repository.
auto joinPipeline(ContextRef ctx, T &&val)
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,...
expected< T, E > inspect(expected< T, E > exp, Function &&f)
bool autoPruneInDir(const zypp::Pathname &path_r)
bsc#1204956: Tweak to prevent auto pruning package caches.
auto mtry(F &&f, Args &&...args)
Repository type enumeration.
static const RepoType YAST2
static const RepoType RPMMD
static const RepoType NONE
static const RepoType RPMPLAINDIR
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Url::asString() view options.
Simple callback to collect the results.
bool collect(const RepoInfo &repo)
#define ZYPP_PRIVATE_CONSTR_ARG