13 #include <solv/solvversion.h> 18 #include <zypp-core/zyppng/pipelines/MTry> 19 #include <zypp-core/zyppng/pipelines/Transform> 20 #include <zypp-core/zyppng/ui/ProgressObserver> 42 #undef ZYPP_BASE_LOGGER_LOGGROUP 43 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::repomanager" 57 const char *
env = getenv(
"ZYPP_PLUGIN_APPDATA_FORCE_COLLECT");
68 inline void cleanupNonRepoMetadataFolders(
const zypp::Pathname & cachePath_r,
70 const std::list<std::string> & repoEscAliases_r )
72 if ( cachePath_r != defaultCachePath_r )
75 std::list<std::string> entries;
79 std::set<std::string> oldfiles;
80 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
81 std::inserter( oldfiles, oldfiles.end() ) );
87 for (
const std::string & old : oldfiles )
91 pi( cachePath_r/old );
104 #define OUTS(V) case zypp::RepoManagerFlags::V: str << #V; break 116 #define OUTS(V) case zypp::RepoManagerFlags::V: str << #V; break 128 #define OUTS(V) case zypp::RepoManagerFlags::V: str << #V; break 139 std::string filename( alias_r );
144 MIL <<
"generating filename for " << stem_r <<
" [" << alias_r <<
"] : '" << filename <<
"'" << std::endl;
157 <<
"' distribution (current distro is '" 163 repos.push_back(repo);
170 MIL <<
"repo file: " << file << std::endl;
188 template <
typename ZContextRef>
191 MIL <<
"directory " << dir << std::endl;
192 std::list<RepoInfo> repos;
193 bool nonroot( geteuid() != 0 );
200 std::list<zypp::Pathname> entries;
208 for ( std::list<zypp::Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
219 repos.insert( repos.end(), tmp.begin(), tmp.end() );
238 template <
typename ZyppContextRefType>
242 , _pluginRepoverification(
_options.pluginsPath /
"repoverification",
248 template <
typename ZyppContextRefType>
253 && geteuid() == 0 && (
_options.rootDir.empty() ||
_options.rootDir ==
"/" ) )
256 std::list<zypp::Pathname> entries;
258 if ( ! entries.empty() )
261 cmd.push_back(
"<" );
262 cmd.push_back(
">" );
263 cmd.push_back(
"PROGRAM" );
264 for (
const auto & rinfo : repos() )
266 if ( ! rinfo.enabled() )
268 cmd.push_back(
"-R" );
269 cmd.push_back( rinfo.alias() );
270 cmd.push_back(
"-t" );
271 cmd.push_back( rinfo.type().asString() );
272 cmd.push_back(
"-p" );
273 cmd.push_back( (rinfo.metadataPath()/rinfo.path()).
asString() );
276 for_( it, entries.begin(), entries.end() )
293 template<
typename ZyppContextRefType>
299 |
and_then( [
this](){
return init_knownRepositories(); } );
302 template<
typename ZyppContextRefType>
308 template <
typename ZyppContextRefType>
322 mediarootpath = std::move(mrPath);
329 repokind = probeCache( productdatapath );
336 switch ( repokind.
toEnum() )
339 status =
RepoStatus( productdatapath/
"repodata/repomd.xml");
341 status = status &&
RepoStatus( mediarootpath/
"media.1/media" );
345 status =
RepoStatus( productdatapath/
"content" ) &&
RepoStatus( mediarootpath/
"media.1/media" );
362 if ( ! status.
empty() )
372 template <
typename ZyppContextRefType>
375 return metadataStatus( info,
_options );
378 template <
typename ZyppContextRefType>
383 ProgressObserver::setup( myProgress,
_(
"Cleaning metadata"), 100 );
384 ProgressObserver::start( myProgress );
386 ProgressObserver::setCurrent ( myProgress, 50 );
388 ProgressObserver::finish ( myProgress );
397 template <
typename ZyppContextRefType>
401 ProgressObserver::setup( myProgress,
_(
"Cleaning packages"), 100 );
402 ProgressObserver::start( myProgress );
409 ProgressObserver::finish ( myProgress );
424 template <
typename ZyppContextRefType>
427 MIL <<
"going to probe the cached repo at " << path_r << std::endl;
438 MIL <<
"Probed cached type " << ret <<
" at " << path_r << std::endl;
442 template <
typename ZyppContextRefType>
446 MIL <<
"Going to clean up garbage in cache dirs" << std::endl;
448 std::list<zypp::Pathname> cachedirs;
449 cachedirs.push_back(
_options.repoRawCachePath);
450 cachedirs.push_back(
_options.repoPackagesCachePath);
451 cachedirs.push_back(
_options.repoSolvCachePath);
453 ProgressObserver::setup( myProgress,
_(
"Cleaning up cache dirs"), cachedirs.size() );
454 ProgressObserver::start( myProgress );
456 for(
const auto &dir : cachedirs )
460 ProgressObserver::increase( myProgress );
465 std::list<zypp::Pathname> entries;
470 if ( !entries.size() )
473 auto dirProgress = ProgressObserver::makeSubTask( myProgress, 1.0,
zypp::str::Format(
_(
"Cleaning up directory: %1%") ) % dir, entries.size() );
474 for(
const auto &subdir : entries )
478 for_( r, repoBegin(), repoEnd() )
479 if ( subdir.basename() == r->escaped_alias() )
480 { found =
true;
break; }
485 ProgressObserver::increase( dirProgress );
487 ProgressObserver::finish( dirProgress );
495 ProgressObserver::finish ( myProgress );
499 template <
typename ZyppContextRefType>
503 ProgressObserver::setup( myProgress,
_(
"Cleaning cache"), 100 );
504 ProgressObserver::start( myProgress );
506 MIL <<
"Removing raw metadata cache for " << info.
alias() << std::endl;
509 ProgressObserver::finish( myProgress );
519 template <
typename ZyppContextRefType>
524 ProgressObserver::setup( myProgress,
_(
"Loading from cache"), 3 );
525 ProgressObserver::start( myProgress );
535 ProgressObserver::increase ( myProgress );
539 ProgressObserver::increase ( myProgress );
544 if ( toolversion != LIBSOLV_TOOLVERSION ) {
549 |
or_else( [
this, info, myProgress]( std::exception_ptr exp ) {
551 MIL <<
"Try to handle exception by rebuilding the solv-file" << std::endl;
552 return cleanCache( info, ProgressObserver::makeSubTask( myProgress ) )
553 |
and_then([
this, info, myProgress]{
561 ProgressObserver::finish ( myProgress );
564 |
or_else([myProgress](
auto ex ){
571 template <
typename ZyppContextRefType>
581 _options.knownReposPath, generateFilename(tosave));
583 MIL <<
"Saving repo in " << repofile << std::endl;
585 std::ofstream file(repofile.
c_str());
592 tosave.dumpAsIniOn(file);
593 tosave.setFilepath(repofile);
596 reposManip().insert(tosave);
611 template <
typename ZyppContextRefType>
615 ProgressObserver::setup( myProgress,
zypp::str::form(
_(
"Removing repository '%s'"), info.
label().c_str()), 1 );
616 ProgressObserver::start( myProgress );
618 MIL <<
"Going to delete repo " << info.
alias() << std::endl;
620 for(
const auto &repo : repos() )
625 if ( (!info.
alias().empty()) && ( info.
alias() != repo.alias() ) )
641 if ( filerepos.size() == 0
642 ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.
alias() ) )
646 if ( ! ( ret == 0 || ret == ENOENT ) )
651 MIL << todelete.
alias() <<
" successfully deleted." << std::endl;
669 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
670 fit != filerepos.end();
673 if ( (*fit).alias() != todelete.
alias() )
674 (*fit).dumpAsIniOn(file);
679 if ( isCached(todelete) )
680 cleanCache( todelete, ProgressObserver::makeSubTask( myProgress, 0.2 )).unwrap();
682 cleanMetadata( todelete, ProgressObserver::makeSubTask( myProgress, 0.4 )).unwrap();
683 cleanPackages( todelete, ProgressObserver::makeSubTask( myProgress, 0.4 ),
true ).unwrap();
684 reposManip().erase(todelete);
685 MIL << todelete.
alias() <<
" successfully deleted." << std::endl;
688 ProgressObserver::finish(myProgress);
700 template <
typename ZyppContextRefType>
705 ProgressObserver::setup( myProgress,
_(
"Modifying repository"), 5 );
706 ProgressObserver::start( myProgress );
708 RepoInfo toedit = getRepositoryInfo(alias).unwrap();
712 if ( alias != newinfo.
alias() && hasRepo( newinfo.
alias() ) )
723 ProgressObserver::increase( myProgress );
741 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
742 fit != filerepos.end();
747 if ( (*fit).alias() != toedit.
alias() )
748 (*fit).dumpAsIniOn(file);
753 ProgressObserver::increase( myProgress );
767 ProgressObserver::increase( myProgress );
769 reposManip().erase(toedit);
770 reposManip().insert(newinfo);
772 ProgressObserver::increase( myProgress );
777 MIL <<
"repo " << alias <<
" modified" << std::endl;
779 ProgressObserver::finish ( myProgress );
789 template <
typename ZyppContextRefType>
794 if ( it != repos().end() )
805 template <
typename ZyppContextRefType>
810 for_( it, repoBegin(), repoEnd() )
812 for_( urlit, (*it).baseUrlsBegin(), (*it).baseUrlsEnd() )
814 if ( (*urlit).asString(urlview) == url.
asString(urlview) )
827 template<
typename ZyppContextRefType>
834 |
and_then( [
this, url, policy]( zyppng::repo::RefreshContextRef<ZyppContextRefType> &&refCtx ) {
835 refCtx->setPolicy ( static_cast<zyppng::repo::RawMetadataRefreshPolicy>( policy ) );
842 template<
typename ZyppContextRefType>
850 for(
const auto &repo : repos() ) {
851 if ( info.
alias() == repo.alias() )
854 modifiedrepo.
setType( repokind );
866 |
and_then( [policy, myProgress, cb = updateProbedType]( repo::RefreshContextRef<ZyppContextRefType> refCtx ) {
867 refCtx->setPolicy( static_cast<repo::RawMetadataRefreshPolicy>( policy ) );
882 template<
typename ZyppContextRefType>
887 ProgressObserver::setup( myProgress,
"Refreshing repositories" , 1 );
889 auto r = std::move(infos)
892 auto subProgress = ProgressObserver::makeSubTask( myProgress, 1.0,
zypp::str::Str() <<
_(
"Refreshing Repository: ") << info.
alias(), 3 );
898 for(
const auto &repo : repos() ) {
899 if ( info.
alias() == repo.alias() )
902 modifiedrepo.
setType( repokind );
910 auto sharedThis = shared_this<RepoManager<ZyppContextRefType>>();
917 |
and_then( [policy, subProgress, cb = updateProbedType]( repo::RefreshContextRef<ZyppContextRefType> refCtx ) {
918 refCtx->setPolicy( static_cast<repo::RawMetadataRefreshPolicy>( policy ) );
925 |
and_then([subProgress]( repo::RefreshContextRef<ZyppContextRefType> ctx ) {
928 ctx->repoManager()->reposManip();
933 | [ info = info, subProgress ](
expected<repo::RefreshContextRef<ZyppContextRefType>> result ) {
943 | [myProgress](
auto res ) {
958 template<
typename ZyppContextRefType>
965 |
and_then( [
this, path = path](
auto mediaHandle ) {
970 template<
typename ZyppContextRefType>
976 |
and_then( [policy, myProgress]( repo::RefreshContextRef<ZyppContextRefType> refCtx ) {
983 template<
typename ZyppContextRefType>
989 template<
typename ZyppContextRefType>
996 template <
typename ZyppContextRefType>
1002 template <
typename ZyppContextRefType>
1010 if ( hasService( service.
alias() ) )
1016 saveService( toSave ).unwrap();
1017 _services.insert( toSave );
1022 MIL <<
"added service " << toSave.
alias() << std::endl;
1031 template<
typename ZyppContextRefType>
1040 template<
typename ZyppContextRefType>
1046 ServiceSet servicesCopy( serviceBegin(), serviceEnd() );
1049 std::vector<ServiceInfo> servicesVec;
1050 std::copy( std::make_move_iterator(servicesCopy.begin()), std::make_move_iterator(servicesCopy.end()), std::back_inserter(servicesVec));
1053 std::move(servicesVec)
1062 template <
typename ZyppContextRefType>
1066 MIL <<
"Going to delete service " << alias << std::endl;
1068 const ServiceInfo & service = getService( alias );
1071 if( location.
empty() )
1080 if ( tmpSet.size() == 1 )
1087 MIL << alias <<
" successfully deleted." << std::endl;
1093 std::ofstream file(location.
c_str());
1100 for_(it, tmpSet.begin(), tmpSet.end())
1102 if( it->alias() != alias )
1103 it->dumpAsIniOn(file);
1106 MIL << alias <<
" successfully deleted from file " << location << std::endl;
1111 getRepositoriesInService( alias,
1112 boost::make_function_output_iterator( std::bind( &
RepoCollector::collect, &rcollector, std::placeholders::_1 ) ) );
1115 removeRepository(*rit).unwrap();
1124 template <
typename ZyppContextRefType>
1129 MIL <<
"Going to modify service " << oldAlias << std::endl;
1135 if ( service.
type() == zypp::repo::ServiceType::PLUGIN )
1140 const ServiceInfo & oldService = getService(oldAlias);
1143 if( location.
empty() )
1153 std::ofstream file(location.
c_str());
1154 for_(it, tmpSet.begin(), tmpSet.end())
1156 if( *it != oldAlias )
1157 it->dumpAsIniOn(file);
1163 _services.erase(oldAlias);
1164 _services.insert(service);
1170 if ( oldAlias != service.
alias()
1173 std::vector<RepoInfo> toModify;
1174 getRepositoriesInService(oldAlias, std::back_inserter(toModify));
1175 for_( it, toModify.begin(), toModify.end() )
1182 const auto & last = service.
repoStates().find( it->alias() );
1184 it->setEnabled( last->second.enabled );
1187 it->setEnabled(
false );
1190 if ( oldAlias != service.
alias() )
1191 it->setService(service.
alias());
1193 modifyRepository(it->alias(), *it).unwrap();
1207 template <
typename ZyppContextRefType>
1214 generateFilename( service ) );
1217 MIL <<
"saving service in " << servfile << std::endl;
1219 std::ofstream file( servfile.
c_str() );
1226 MIL <<
"done" << std::endl;
1250 template <
typename ZyppContextRefType>
1252 const std::string & basefilename )
const 1254 std::string final_filename = basefilename;
1264 template <
typename ZyppContextRefType>
1273 repokind = probeCache( productdatapath );
1279 switch ( repokind.
toEnum() )
1306 template<
typename ZyppContextRefType>
1312 template <
typename ZyppContextRefType>
1315 return touchIndexFile( info,
_options );
1318 template <
typename ZyppContextRefType>
1323 std::list<zypp::Pathname> entries;
1333 for_(it, entries.begin(), entries.end() )
1356 inline void cleanupNonRepoMetadtaFolders(
const zypp::Pathname & cachePath_r,
1358 const std::list<std::string> & repoEscAliases_r )
1363 if ( cachePath_r != defaultCachePath_r )
1366 std::list<std::string> entries;
1370 std::set<std::string> oldfiles;
1371 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
1372 std::inserter( oldfiles, oldfiles.end() ) );
1378 for (
const std::string & old : oldfiles )
1382 pi( cachePath_r/old );
1392 template <
typename ZyppContextRefType>
1397 MIL <<
"start construct known repos" << std::endl;
1401 std::list<std::string> repoEscAliases;
1402 std::list<RepoInfo> orphanedRepos;
1410 _reposX.insert( repoInfo );
1413 const std::string & serviceAlias( repoInfo.service() );
1414 if ( ! ( serviceAlias.empty() || hasService( serviceAlias ) ) )
1416 WAR <<
"Schedule orphaned service repo for deletion: " << repoInfo << std::endl;
1417 orphanedRepos.push_back( repoInfo );
1421 repoEscAliases.push_back(repoInfo.escaped_alias());
1425 if ( ! orphanedRepos.empty() )
1427 for (
const auto & repoInfo : orphanedRepos )
1429 MIL <<
"Delete orphaned service repo " << repoInfo.alias() << std::endl;
1434 % repoInfo.service()
1435 % repoInfo.alias() );
1437 removeRepository( repoInfo ).unwrap();
1453 repoEscAliases.sort();
1454 cleanupNonRepoMetadtaFolders(
_options.repoRawCachePath,
1457 cleanupNonRepoMetadtaFolders(
_options.repoSolvCachePath,
1462 cleanupNonRepoMetadtaFolders(
_options.repoPackagesCachePath,
1467 MIL <<
"end construct known repos" << std::endl;
std::string asString(const Patch::Category &obj)
Pathname filepath() const
File where this repo was read from.
static const ValueType day
void setBaseUrl(Url url)
Clears current base URL list and adds url.
void loadFromCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Load resolvables into the pool.
std::ostream & dumpAsIniOn(std::ostream &str) const override
Writes ServiceInfo to stream in ".service" format.
thrown when it was impossible to match a repository
zypp::RepoStatus RepoStatus
bool empty() const
Whether the status is empty (empty checksum)
Namespace intended to collect all environment variables we use.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
repo::RepoType probe(const Url &url, const Pathname &path) const
Probe repo metadata type.
const Pathname & path() const
Return current Pathname.
Read service data from a .service file.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
std::enable_if_t<!std::is_same_v< void, T >, expected< Container< T >, E > > collect(Container< expected< T, E >, CArgs... > &&in)
bool warning(std::string msg_r, UserData userData_r=UserData())
send warning text
expected< T, E > inspect(expected< T, E > exp, Function &&f)
AsyncOpRef< expected< zypp::repo::ServiceType > > probeServiceType(ContextRef ctx, const zypp::Url &url)
std::string join(TIterator begin, TIterator end, const C_Str &sep_r=" ")
Join strings using separator sep_r (defaults to BLANK).
void removeService(const std::string &alias)
Removes service specified by its name.
Service plugin is immutable.
void cleanCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
clean local cache
AsyncOpRef< expected< repo::AsyncRefreshContextRef > > refreshMetadata(repo::AsyncRefreshContextRef refCtx, LazyMediaHandle< Provide > medium, ProgressObserverRef progressObserver)
expected< std::list< RepoInfo > > repositories_in_file(const zypp::Pathname &file)
Reads RepoInfo's from a repo file.
Pathname extend(const std::string &r) const
Append string r to the last component of the path.
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy=RefreshIfNeeded)
Checks whether to refresh metadata for specified repository and url.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
const char * c_str() const
String representation.
void setAlias(const std::string &alias)
set the repository alias
std::list< RepoInfo > repositories_in_dir(ZContextRef zyppContext, const zypp::Pathname &dir)
List of RepoInfo's from a directory.
String related utilities and Regular expression matching.
void setFilepath(const Pathname &filename)
set the path to the .repo file
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)
AsyncOpRef< expected< repo::AsyncRefreshContextRef > > buildCache(repo::AsyncRefreshContextRef refCtx, zypp::RepoManagerFlags::CacheBuildPolicy policy, ProgressObserverRef progressObserver)
Service already exists and some unique attribute can't be duplicated.
void buildCache(const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local cache.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
repo::ServiceType probeService(const Url &url) const
Probe the type or the service.
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
ZyppContextRefType _zyppContext
Url::asString() view options.
zypp::RepoManager::RefreshServiceOptions _options
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
expected< zypp::Pathname > packagescache_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the packages cache path for a repository.
static expected< repo::RefreshContextRef< ZyppContextRefType > > create(ZyppContextRefType zyppContext, zypp::RepoInfo info, RepoManagerRef< ContextRefType > repoManager)
void cleanCacheDirGarbage(const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove any subdirectories of cache directories which no longer belong to any of known repositories...
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refresh specific service.
bool baseUrlsEmpty() const
whether repository urls are available
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy=RefreshIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local raw cache.
ResultType or_else(const expected< T, E > &exp, Function &&f)
Simple callback to collect the results.
Container< Ret > transform(Container< Msg, CArgs... > &&val, Transformation &&transformation)
void modifyRepository(const std::string &alias, const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Modify repository attributes.
Exp mtry(F &&f, Args &&...args)
bool empty() const
Test for an empty path.
std::string asString() const
Returns a default string representation of the Url object.
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...
static RepoStatus fromCookieFileUseMtime(const Pathname &path)
Reads the status from a cookie file but uses the files mtime.
void refreshServices(const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refreshes all enabled services.
void cleanPackages(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local package cache.
RepoInfo getRepositoryInfo(const std::string &alias, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Find a matching repository info.
bool collect(const RepoInfo &repo)
void removeRepository(const RepoInfo &repo)
Log recently removed repository.
int touch(const Pathname &path)
Change file's modification and access times.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Lightweight repository attribute value lookup.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
thrown when it was impossible to determine one url for this repo.
const std::string & asString() const
String representation.
std::string alias() const
unique identifier for this source.
bool isExist() const
Return whether valid stat info exists.
void addService(const std::string &alias, const Url &url)
Adds a new service by its alias and URL.
auto joinPipeline(ContextRef ctx, AsyncOpRef< T > res)
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
static const SolvAttr repositoryToolVersion
expected< void > assert_alias(const RepoInfo &info)
creates and provides information about known sources.
Pathname dirname() const
Return all but the last component od this path.
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r prefixed with root_r, unless it is already prefixed.
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
void setType(const repo::RepoType &t)
set the repository type
bool ZYPP_PLUGIN_APPDATA_FORCE_COLLECT()
To trigger appdata refresh unconditionally.
void addRepository(const RepoInfo &repo)
Log a newly added repository.
Writing the zypp history fileReference counted signleton for writhing the zypp history file...
Read repository data from a .repo file.
void modifyService(const std::string &oldAlias, const ServiceInfo &service)
Modifies service file (rewrites it with new values) and underlying repositories if needed...
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
Base Exception for service handling.
bool requireStatusWithMediaFile() const
Returns true if this repository requires the media.1/media file to be included in the metadata status...
RepoSet::const_iterator RepoConstIterator
std::vector< std::string > Arguments
const std::string & asString() const
Return current Pathname as String.
std::string numstring(char n, int w=0)
int unlink(const Pathname &path)
Like 'unlink'.
static const RepoType NONE
static expected success(ConsParams &&...params)
Url url() const
The service url.
zypp::RepoManagerFlags::RefreshServiceOptions RefreshServiceOptions
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
static const RepoType RPMMD
bool autoPruneInDir(const zypp::Pathname &path_r)
bsc#1204956: Tweak to prevent auto pruning package caches.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_PRIVATE_CONSTR_ARG
AsyncOpRef< expected< void > > refreshGeoIPData(ContextRef ctx, RepoInfo::url_set urls)
static const RepoType YAST2
bool error(std::string msg_r, UserData userData_r=UserData())
send error text
AsyncOpRef< expected< zypp::repo::RepoType > > probeRepoType(ContextRef ctx, AsyncLazyMediaHandle medium, zypp::Pathname path, std::optional< zypp::Pathname > targetPath)
expected< void > assert_urls(const RepoInfo &info)
void addRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds a repository to the list of known repositories.
const RepoStates & repoStates() const
Access the remembered repository states.
Base class for Exception.
std::ostream & dumpAsIniOn(std::ostream &str) const override
Write this RepoInfo object into str in a .repo file format.
Exception for repository handling.
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
refresh is delayed due to settings
static Date now()
Return the current time.
AsyncOpRef< expected< void > > refreshService(AsyncRepoManagerRef repoMgr, ServiceInfo info, zypp::RepoManagerFlags::RefreshServiceOptions options)
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Iterator findAlias(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Find alias_r in repo/service container.
The repository cache is not built yet so you can't create the repostories from the cache...
void eraseFromPool()
Remove this Repository from its Pool.
std::string targetDistribution() const
Distribution for which is this repository meant.
Wrapper class for ::stat/::lstat.
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
regex ZYPP_STR_REGEX regex ZYPP_STR_REGEX
void removeRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove the best matching repository from known repos list.
AsyncOpRef< expected< repo::RefreshCheckStatus > > checkIfToRefreshMetadata(repo::AsyncRefreshContextRef refCtx, LazyMediaHandle< Provide > medium, ProgressObserverRef progressObserver)
RefreshCheckStatus
Possibly return state of RepoManager::checkIfToRefreshMetadata function.
ResultType and_then(const expected< T, E > &exp, Function &&f)
static const RepoType RPMPLAINDIR
static const std::string & systemRepoAlias()
Reserved system repository 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.
RepoStatus metadataStatus(const RepoInfo &info) const
Status of local metadata.
Track changing files or directories.
The RepoManager class Provides knowledge and methods to maintain repo settings and metadata for a giv...
AsyncOpRef< expected< RepoInfo > > addRepository(AsyncRepoManagerRef mgr, RepoInfo info, ProgressObserverRef myProgress)
Repository already exists and some unique attribute can't be duplicated.
std::string filenameFromAlias(const std::string &alias_r, const std::string &stem_r)
Generate a related filename from a repo/service infos alias.
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).
void modifyRepository(const RepoInfo &oldrepo, const RepoInfo &newrepo)
Log certain modifications to a repository.
#define ZYPP_FWD_CURRENT_EXCPT()
Drops a logline and returns the current Exception as a std::exception_ptr.
std::ostream & operator<<(std::ostream &str, zypp::RepoManagerFlags::RawMetadataRefreshPolicy obj)
AsyncOpRef< expected< void > > addRepositories(AsyncRepoManagerRef mgr, zypp::Url url, ProgressObserverRef myProgress)
void refreshGeoIp(const RepoInfo::url_set &urls)
repo::ServiceType type() const
Service type.
std::string label() const
Label for use in messages for the user interface.
url_set baseUrls() const
The complete set of repository urls.
repo::RepoType type() const
Type of repository,.
auto incProgress(ProgressObserverRef progressObserver, double progrIncrease=1.0, std::optional< std::string > newStr={})
void cleanMetadata(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local metadata.
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.
Repository type enumeration.
void addRepositories(const Url &url, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds repositores from a repo file to the list of known repositories.