21 #include <zypp-core/base/InputStream> 25 #include <zypp-core/base/DefaultIntegral> 38 #include <zypp-media/auth/CredentialManager> 39 #include <zypp-media/MediaException> 61 #include <zypp-core/zyppng/pipelines/Lift> 71 #define OPT_PROGRESS const ProgressData::ReceiverFnc & = ProgressData::ReceiverFnc() 82 const char *
env = getenv(
"ZYPP_PLUGIN_APPDATA_FORCE_COLLECT");
97 MediaMounter(
const Url & url_r )
99 media::MediaManager mediamanager;
100 _mid = mediamanager.open( url_r );
101 mediamanager.attach(
_mid );
104 MediaMounter(
const MediaMounter &) =
delete;
105 MediaMounter(MediaMounter &&) =
delete;
106 MediaMounter &operator=(
const MediaMounter &) =
delete;
107 MediaMounter &operator=(MediaMounter &&) =
delete;
112 media::MediaManager mediamanager;
113 mediamanager.release(
_mid );
114 mediamanager.close(
_mid );
121 Pathname getPathName(
const Pathname & path_r = Pathname() )
const 123 media::MediaManager mediamanager;
124 return mediamanager.localPath(
_mid, path_r );
137 Url repoFileUrl { replaceVars(repo_file) };
140 DBG <<
"reading repo file " << repoFileUrl <<
", local path: " << local << endl;
148 #define OUTS(V) case RepoManager::V: str << #V; break 160 #define OUTS(V) case RepoManager::V: str << #V; break 172 #define OUTS(V) case RepoManager::V: str << #V; break 173 OUTS( BuildIfNeeded );
190 _pluginRepoverification(_options.pluginsPath /
"repoverification",
192 init_knownServices();
193 init_knownRepositories();
198 Impl &operator=(
const Impl &) =
delete;
205 && geteuid() == 0 && ( _options.rootDir.empty() || _options.rootDir ==
"/" ) )
208 std::list<Pathname> entries;
210 if ( ! entries.empty() )
213 cmd.push_back(
"<" );
214 cmd.push_back(
">" );
215 cmd.push_back(
"PROGRAM" );
216 for (
const auto & rinfo : repos() )
218 if ( ! rinfo.enabled() )
220 cmd.push_back(
"-R" );
221 cmd.push_back( rinfo.alias() );
222 cmd.push_back(
"-t" );
223 cmd.push_back( rinfo.type().asString() );
224 cmd.push_back(
"-p" );
225 cmd.push_back( (rinfo.metadataPath()/rinfo.path()).
asString() );
228 for_( it, entries.begin(), entries.end() )
263 void refreshServices(
const RefreshServiceOptions & options_r );
265 void refreshService(
const std::string & alias,
const RefreshServiceOptions & options_r );
267 { refreshService( service.
alias(), options_r ); }
277 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
280 {
return new Impl( *
this ); }
286 {
return str <<
"RepoManager::Impl"; }
291 if ( url.schemeIsVolatile() ) {
296 using zyppng::operators::operator|;
298 refreshGeoIPData( { url } );
300 auto ctx = zyppng::SyncContext::create();
302 |
and_then( [&]( zyppng::repo::SyncRefreshContextRef &&refCtx ) {
303 refCtx->setPolicy ( static_cast<zyppng::repo::RawMetadataRefreshPolicy>( policy ) );
319 using zyppng::operators::operator|;
322 refreshGeoIPData( info.baseUrls() );
328 RepoException rexception( info,
PL_(
"Valid metadata not found at specified URL",
329 "Valid metadata not found at specified URLs",
330 info.baseUrlsSize() ) );
333 auto ctx = SyncContext::create();
336 const auto &updateProbedType = [&]( repo::RepoType repokind ) {
338 for_( it, repoBegin(), repoEnd() )
340 if ( info.alias() == (*it).alias() )
342 RepoInfo modifiedrepo = *it;
343 modifiedrepo.setType( repokind );
355 if ( it->schemeIsVolatile() && not metadataStatus( info ).empty() ) {
362 |
and_then( [&]( zyppng::repo::SyncRefreshContextRef refCtx ) {
363 refCtx->setPolicy( static_cast<zyppng::repo::RawMetadataRefreshPolicy>( policy ) );
380 ERR <<
"Trying another url..." << endl;
385 if (it == info.baseUrlsBegin())
386 rexception.remember( e );
391 ERR <<
"No more urls..." << endl;
404 Exception ex(
str::form(
_(
"Can't create %s"), _options.repoCachePath.c_str()) );
407 RepoStatus raw_metadata_status = metadataStatus(info);
408 if ( raw_metadata_status.empty() )
414 raw_metadata_status = metadataStatus(info);
417 bool needs_cleaning =
false;
418 if ( isCached( info ) )
420 MIL << info.alias() <<
" is already cached." << endl;
421 RepoStatus cache_status = cacheStatus(info);
423 if ( cache_status == raw_metadata_status )
425 MIL << info.alias() <<
" cache is up to date with metadata." << endl;
426 if ( policy == BuildIfNeeded )
430 if ( ! PathInfo(base/
"solv.idx").isExist() )
436 MIL << info.alias() <<
" cache rebuild is forced" << endl;
440 needs_cleaning =
true;
443 ProgressData progress(100);
444 callback::SendReport<ProgressReport> report;
445 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
446 progress.name(
str::form(
_(
"Building repository '%s' cache"), info.label().c_str()));
454 MIL << info.alias() <<
" building cache..." << info.type() << endl;
460 Exception ex(
str::form(
_(
"Can't create %s"), base.c_str()) );
464 if( ! PathInfo(base).userMayW() )
466 Exception ex(
str::form(
_(
"Can't create cache at %s - no writing permissions."), base.c_str()) );
469 Pathname solvfile = base /
"solv";
472 repo::RepoType repokind = info.type();
475 switch ( repokind.toEnum() )
479 repokind = probeCache( productdatapath );
485 MIL <<
"repo type is " << repokind << endl;
487 switch ( repokind.toEnum() )
495 scoped_ptr<MediaMounter> forPlainDirs;
498 cmd.push_back( PathInfo(
"/usr/bin/repo2solv" ).isFile() ?
"repo2solv" :
"repo2solv.sh" );
500 cmd.push_back(
"-o" );
501 cmd.push_back( solvfile.asString() );
502 cmd.push_back(
"-X" );
507 forPlainDirs.reset(
new MediaMounter( info.url() ) );
509 cmd.push_back(
"-R" );
511 cmd.push_back( forPlainDirs->getPathName( info.path() ).c_str() );
514 cmd.push_back( productdatapath.asString() );
517 std::string errdetail;
519 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() ) {
520 WAR <<
" " << output;
524 int ret = prog.close();
528 ex.addHistory( str::Str() << prog.command() << endl << errdetail << prog.execError() );
533 guard.resetDispose();
542 setCacheStatus(info, raw_metadata_status);
543 MIL <<
"Commit cache.." << endl;
556 repo::RepoType RepoManager::Impl::probe(
const Url & url,
const Pathname & path )
const 560 using zyppng::operators::operator|;
562 auto ctx = zyppng::SyncContext::create();
564 |
and_then( [&](
auto mediaHandle ) {
582 catch (
const Exception & exp )
585 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
586 cleanCache( info, progressrcv );
587 buildCache( info, BuildIfNeeded, progressrcv );
599 ProgressData progress(100);
600 callback::SendReport<ProgressReport> report;
601 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
602 progress.name(
str::form(
_(
"Adding repository '%s'"), info.label().c_str()));
605 MIL <<
"Try adding repo " << info << endl;
607 RepoInfo tosave = info;
608 if ( repos().find(tosave) != repos().end() )
612 if ( _options.probe )
614 DBG <<
"unknown repository type, probing" << endl;
617 RepoType probedtype( probe( tosave.url(), info.path() ) );
621 tosave.setType(probedtype);
629 MIL <<
"done" << endl;
636 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
641 for_ ( kit, repoBegin(), repoEnd() )
643 if ( (*it).alias() == (*kit).alias() )
645 ERR <<
"To be added repo " << (*it).alias() <<
" conflicts with existing repo " << (*kit).alias() << endl;
651 std::string filename = Pathname(url.getPathName()).basename();
653 if ( filename == Pathname() )
662 Pathname repofile = generateNonExistingName(_options.knownReposPath, filename);
664 MIL <<
"Saving " << repos.size() <<
" repo" << ( repos.size() ?
"s" :
"" ) <<
" in " << repofile << endl;
666 std::ofstream file(repofile.c_str());
673 for ( std::list<RepoInfo>::iterator it = repos.begin();
677 MIL <<
"Saving " << (*it).alias() << endl;
678 it->dumpAsIniOn(file);
679 it->setFilepath(repofile);
682 reposManip().insert(*it);
684 HistoryLog(_options.rootDir).addRepository(*it);
687 MIL <<
"done" << endl;
692 callback::SendReport<ProgressReport> report;
693 ProgressReportAdaptor adapt( progressrcv, report );
694 removeRepositoryImpl( info, std::ref(adapt) );
703 void RepoManager::Impl::refreshServices(
const RefreshServiceOptions & options_r )
707 ServiceSet services( serviceBegin(), serviceEnd() );
708 for_( it, services.begin(), services.end() )
710 if ( !it->enabled() )
714 refreshService(*it, options_r);
716 catch (
const repo::ServicePluginInformalException & e )
721 void RepoManager::Impl::refreshService(
const std::string & alias,
const RefreshServiceOptions & options_r )
723 ServiceInfo service( getService( alias ) );
726 MIL <<
"Going to refresh service '" << service.alias() <<
"', url: " << service.url() <<
", opts: " << options_r << endl;
728 if ( service.ttl() && !( options_r.testFlag( RefreshService_forceRefresh) || options_r.testFlag( RefreshService_restoreStatus ) ) )
731 Date lrf = service.lrf();
737 if ( (lrf+=service.ttl()) > now )
739 MIL <<
"Skip: '" << service.alias() <<
"' metadata valid until " << lrf << endl;
744 WAR <<
"Force: '" << service.alias() <<
"' metadata last refresh in the future: " << lrf << endl;
751 bool serviceModified =
false;
756 if ( service.type() == repo::ServiceType::NONE )
758 repo::ServiceType type = probeService( service.url() );
759 if ( type != ServiceType::NONE )
761 service.setProbedType( type );
762 serviceModified =
true;
767 std::string servicesTargetDistro = _options.servicesTargetDistro;
768 if ( servicesTargetDistro.empty() )
772 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << endl;
776 RepoCollector collector(servicesTargetDistro);
781 std::pair<DefaultIntegral<bool,false>, repo::ServicePluginInformalException> uglyHack;
791 catch (
const repo::ServicePluginInformalException & e )
794 uglyHack.first =
true;
797 if ( service.ttl() != origTtl )
799 if ( !service.ttl() )
800 service.setLrf( Date() );
801 serviceModified =
true;
809 for_( it, collector.repos.begin(), collector.repos.end() )
812 it->setAlias(
str::form(
"%s:%s", service.alias().c_str(), it->alias().c_str() ) );
814 it->setService( service.alias() );
817 newRepoStates[it->alias()] = *it;
825 if ( !it->path().empty() )
827 if ( it->path() !=
"/" )
832 if ( it->baseUrlsEmpty() )
834 Url url( service.rawUrl() );
837 it->setBaseUrl( std::move(url) );
839 else if ( !path.empty() )
842 for ( Url & url : urls )
844 url.setPathName( url.getPathName() / path );
846 it->setBaseUrls( std::move(urls) );
853 RepoInfoList oldRepos;
854 getRepositoriesInService( service.alias(), std::back_inserter( oldRepos ) );
858 for_( oldRepo, oldRepos.begin(), oldRepos.end() )
860 if ( !
foundAliasIn( oldRepo->alias(), collector.repos ) )
862 if ( oldRepo->enabled() )
865 const auto & last = service.repoStates().find( oldRepo->alias() );
866 if ( last != service.repoStates().end() && ! last->second.enabled )
868 DBG <<
"Service removes user enabled repo " << oldRepo->alias() << endl;
869 service.addRepoToEnable( oldRepo->alias() );
870 serviceModified =
true;
873 DBG <<
"Service removes enabled repo " << oldRepo->alias() << endl;
876 DBG <<
"Service removes disabled repo " << oldRepo->alias() << endl;
878 removeRepository( *oldRepo );
884 UrlCredentialExtractor urlCredentialExtractor( _options.rootDir );
885 for_( it, collector.repos.begin(), collector.repos.end() )
891 TriBool toBeEnabled( indeterminate );
892 DBG <<
"Service request to " << (it->enabled()?
"enable":
"disable") <<
" service repo " << it->alias() << endl;
894 if ( options_r.testFlag( RefreshService_restoreStatus ) )
896 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() << endl;
901 service.delRepoToEnable( it->alias() );
906 if ( service.repoToEnableFind( it->alias() ) )
908 DBG <<
"User request to enable service repo " << it->alias() << endl;
913 service.delRepoToEnable( it->alias() );
914 serviceModified =
true;
916 else if ( service.repoToDisableFind( it->alias() ) )
918 DBG <<
"User request to disable service repo " << it->alias() << endl;
923 RepoInfoList::iterator oldRepo(
findAlias( it->alias(), oldRepos ) );
924 if ( oldRepo == oldRepos.end() )
929 if ( ! indeterminate(toBeEnabled) )
930 it->setEnabled( (
bool ) toBeEnabled );
932 DBG <<
"Service adds repo " << it->alias() <<
" " << (it->enabled()?
"enabled":
"disabled") << endl;
933 addRepository( *it );
938 bool oldRepoModified =
false;
940 if ( indeterminate(toBeEnabled) )
944 if ( oldRepo->enabled() == it->enabled() )
945 toBeEnabled = it->enabled();
946 else if (options_r.testFlag( RefreshService_restoreStatus ) )
948 toBeEnabled = it->enabled();
949 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() <<
" forces " << (toBeEnabled?
"enabled":
"disabled") << endl;
953 const auto & last = service.repoStates().find( oldRepo->alias() );
954 if ( last == service.repoStates().end() || last->second.enabled != it->enabled() )
955 toBeEnabled = it->enabled();
958 toBeEnabled = oldRepo->enabled();
959 DBG <<
"User modified service repo " << it->alias() <<
" may stay " << (toBeEnabled?
"enabled":
"disabled") << endl;
965 if ( toBeEnabled == oldRepo->enabled() )
967 DBG <<
"Service repo " << it->alias() <<
" stays " << (oldRepo->enabled()?
"enabled":
"disabled") << endl;
969 else if ( toBeEnabled )
971 DBG <<
"Service repo " << it->alias() <<
" gets enabled" << endl;
972 oldRepo->setEnabled(
true );
973 oldRepoModified =
true;
977 DBG <<
"Service repo " << it->alias() <<
" gets disabled" << endl;
978 oldRepo->setEnabled(
false );
979 oldRepoModified =
true;
985 if ( oldRepo->rawName() != it->rawName() )
987 DBG <<
"Service repo " << it->alias() <<
" gets new NAME " << it->rawName() << endl;
988 oldRepo->setName( it->rawName() );
989 oldRepoModified =
true;
993 if ( oldRepo->autorefresh() != it->autorefresh() )
995 DBG <<
"Service repo " << it->alias() <<
" gets new AUTOREFRESH " << it->autorefresh() << endl;
996 oldRepo->setAutorefresh( it->autorefresh() );
997 oldRepoModified =
true;
1001 if ( oldRepo->priority() != it->priority() )
1003 DBG <<
"Service repo " << it->alias() <<
" gets new PRIORITY " << it->priority() << endl;
1004 oldRepo->setPriority( it->priority() );
1005 oldRepoModified =
true;
1011 urlCredentialExtractor.extract( newUrls );
1012 if ( oldRepo->rawBaseUrls() != newUrls )
1014 DBG <<
"Service repo " << it->alias() <<
" gets new URLs " << newUrls << endl;
1015 oldRepo->setBaseUrls( std::move(newUrls) );
1016 oldRepoModified =
true;
1022 if ( service.type() == ServiceType::PLUGIN )
1026 oldRepo->getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
1027 it-> getRawGpgChecks( ngpg[0], ngpg[1], ngpg[2] );
1028 #define Z_CHKGPG(I,N) \ 1029 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \ 1031 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \ 1032 oldRepo->set##N##Check( ngpg[I] ); \ 1033 oldRepoModified = true; \ 1042 if ( oldRepoModified )
1044 modifyRepository( oldRepo->alias(), *oldRepo );
1050 if ( ! service.reposToDisableEmpty() )
1052 service.clearReposToDisable();
1053 serviceModified =
true;
1057 if ( service.repoStates() != newRepoStates )
1059 service.setRepoStates( std::move(newRepoStates) );
1060 serviceModified =
true;
1065 if ( service.type() != ServiceType::PLUGIN )
1067 if ( service.ttl() )
1070 serviceModified =
true;
1073 if ( serviceModified )
1076 modifyService( service.alias(), service );
1080 if ( uglyHack.first )
1082 throw( uglyHack.second );
1088 repo::ServiceType RepoManager::Impl::probeService(
const Url & url )
const 1093 if ( access.doesFileExist(
"/repo/repoindex.xml") )
1094 return repo::ServiceType::RIS;
1096 catch (
const media::MediaException &e )
1104 catch (
const Exception &e )
1108 Exception enew(
str::form(
_(
"Unknown error reading from '%s'"), url.asString().c_str() ));
1113 return repo::ServiceType::NONE;
1121 MIL <<
"GeoIp disabled via ZConfig, not refreshing the GeoIP information." << std::endl;
1125 std::vector<std::string> hosts;
1126 for (
const auto &baseUrl : urls ) {
1127 const auto &host = baseUrl.getHost();
1129 hosts.push_back( host );
1134 if ( hosts.empty() ) {
1135 MIL <<
"No configured geoip URL found, not updating geoip data" << std::endl;
1142 MIL <<
"Unable to create cache directory for GeoIP." << std::endl;
1146 if ( !PathInfo(geoIPCache).userMayRWX() ) {
1147 MIL <<
"No access rights for the GeoIP cache directory." << std::endl;
1156 PathInfo pi( dir/entry.name );
1157 auto age = std::chrono::system_clock::now() - std::chrono::system_clock::from_time_t( pi.mtime() );
1158 if ( age < std::chrono::hours(24) )
1161 MIL <<
"Removing GeoIP file for " << entry.name <<
" since it's older than 24hrs." << std::endl;
1167 std::for_each( hosts.begin(), hosts.end(), [ & ](
const std::string &hostname ) {
1171 MIL <<
"Skipping GeoIP request for " << hostname <<
" since a valid cache entry exists." << std::endl;
1175 MIL <<
"Query GeoIP for " << hostname << std::endl;
1186 MIL <<
"Ignoring invalid GeoIP hostname: " << hostname << std::endl;
1198 MIL <<
"Failed to query GeoIP from hostname: " << hostname << std::endl;
1201 if ( !file->
empty() ) {
1203 constexpr
auto writeHostToFile = [](
const Pathname &fName,
const std::string &host ){
1205 out.open( fName.asString(), std::ios_base::trunc );
1206 if ( out.is_open() ) {
1207 out << host << std::endl;
1209 MIL <<
"Failed to create/open GeoIP cache file " << fName << std::endl;
1213 std::string geoipMirror;
1216 if ( reader.seekToNode( 1,
"host" ) ) {
1217 const auto &
str = reader.nodeText().asString();
1225 MIL <<
"Storing geoIP redirection: " << hostname <<
" -> " <<
str << std::endl;
1230 MIL <<
"No host entry or empty file returned for GeoIP, remembering for 24hrs" << std::endl;
1234 MIL <<
"Empty or invalid GeoIP file, not requesting again for 24hrs" << std::endl;
1237 writeHostToFile( geoIPCache / hostname, geoipMirror );
1243 MIL <<
"Failed to query GeoIP data." << std::endl;
1254 : _pimpl( new
Impl(
std::move(opt)) )
1261 {
return _pimpl->repoEmpty(); }
1264 {
return _pimpl->repoSize(); }
1267 {
return _pimpl->repoBegin(); }
1270 {
return _pimpl->repoEnd(); }
1273 {
return _pimpl->getRepo( alias ); }
1276 {
return _pimpl->hasRepo( alias ); }
1286 std::string host( url_r.
getHost() );
1287 if ( ! host.empty() )
1299 {
return _pimpl->metadataStatus( info ); }
1302 {
return _pimpl->checkIfToRefreshMetadata( info, url, policy ); }
1305 {
return _pimpl->metadataPath( info ); }
1308 {
return _pimpl->packagesPath( info ); }
1311 {
return _pimpl->refreshMetadata( info, policy, progressrcv ); }
1314 {
return _pimpl->cleanMetadata( info, progressrcv ); }
1317 {
return _pimpl->cleanPackages( info, progressrcv ); }
1320 {
return _pimpl->cacheStatus( info ); }
1323 {
return _pimpl->buildCache( info, policy, progressrcv ); }
1326 {
return _pimpl->cleanCache( info, progressrcv ); }
1329 {
return _pimpl->isCached( info ); }
1332 {
return _pimpl->loadFromCache( info, progressrcv ); }
1335 {
return _pimpl->cleanCacheDirGarbage( progressrcv ); }
1338 {
return _pimpl->probe( url, path ); }
1341 {
return _pimpl->probe( url ); }
1344 {
return _pimpl->addRepository( info, progressrcv ); }
1347 {
return _pimpl->addRepositories( url, progressrcv ); }
1350 {
return _pimpl->removeRepository( info, progressrcv ); }
1353 {
return _pimpl->modifyRepository( alias, newinfo, progressrcv ); }
1356 {
return _pimpl->getRepositoryInfo( alias ); }
1359 {
return _pimpl->getRepositoryInfo( url, urlview ); }
1362 {
return _pimpl->serviceEmpty(); }
1365 {
return _pimpl->serviceSize(); }
1368 {
return _pimpl->serviceBegin(); }
1371 {
return _pimpl->serviceEnd(); }
1374 {
return _pimpl->getService( alias ); }
1377 {
return _pimpl->hasService( alias ); }
1380 {
return _pimpl->probeService( url ); }
1383 {
return _pimpl->addService( alias, url ); }
1386 {
return _pimpl->addService( service ); }
1389 {
return _pimpl->removeService( alias ); }
1392 {
return _pimpl->removeService( service ); }
1395 {
return _pimpl->refreshServices( options_r ); }
1398 {
return _pimpl->refreshService( alias, options_r ); }
1401 {
return _pimpl->refreshService( service, options_r ); }
1404 {
return _pimpl->modifyService( oldAlias, service ); }
1407 {
return _pimpl->refreshGeoIPData( urls ); }
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy)
std::string getScheme() const
Returns the scheme name of the URL.
std::string asString(const Patch::Category &obj)
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
std::string targetDistribution() const
This is register.target attribute of the installed base product.
RepoSet::size_type RepoSizeType
refresh is delayed due to settings
static const std::string & sha1()
sha1
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Namespace intended to collect all environment variables we use.
bool hasRepo(const std::string &alias) const
Return whether there is a known repository for alias.
Pathname solv_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the solv cache path for a repository.
thrown when it was impossible to determine this repo type.
std::string digest()
get hex string representation of the digest
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Retrieval of repository list for a service.
Repository metadata verification beyond GPG.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
static ZConfig & instance()
Singleton ctor.
std::list< RepoInfo > repositories_in_file(const Pathname &file)
Reads RepoInfo's from a repo file.
Impl * clone() const
clone for RWCOW_pointer
bool collect(const RepoInfo &repo)
void removeService(const std::string &alias)
Removes service specified by its name.
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
zypp_private::repo::PluginRepoverification _pluginRepoverification
void cleanCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
clean local cache
ServiceInfo getService(const std::string &alias) const
Finds ServiceInfo by alias or return ServiceInfo::noService.
RepoSizeType repoSize() const
void refreshServices(const RefreshServiceOptions &options_r)
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Pathname metadataPath(const RepoInfo &info) const
Path where the metadata is downloaded and kept.
void loadFromCache(const RepoInfo &info, OPT_PROGRESS)
SignalProxy< void(zypp::repo::RepoType)> sigProbedTypeChanged()
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
String related utilities and Regular expression matching.
Impl(RepoManagerOptions &&opt)
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
What is known about a repository.
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, zypp::RepoManagerOptions opts)
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
void addRepositories(const Url &url, OPT_PROGRESS)
RepoInfo getRepo(const std::string &alias) const
Find RepoInfo by alias or return RepoInfo::noRepo.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
repo::ServiceType probeService(const Url &url) const
void buildCache(const RepoInfo &info, CacheBuildPolicy policy, OPT_PROGRESS)
Url::asString() view options.
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.
repo::RepoType probe(const Url &url, const Pathname &path=Pathname()) const
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
void loadFromCache(const RepoInfo &info, OPT_PROGRESS)
void cleanCacheDirGarbage(const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove any subdirectories of cache directories which no longer belong to any of known repositories...
void modifyRepository(const std::string &alias, const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Modify repository attributes.
bool empty() const
Test for an empty path.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
void addRepository(const RepoInfo &info, OPT_PROGRESS)
static Pool instance()
Singleton ctor.
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.
void addProbedRepository(const RepoInfo &info, repo::RepoType probedType)
std::list< RepoInfo > readRepoFile(const Url &repo_file)
Parses repo_file and returns a list of RepoInfo objects corresponding to repositories found within th...
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
void setScheme(const std::string &scheme)
Set the scheme name in the URL.
void removeRepository(const RepoInfo &info, OPT_PROGRESS) override
void assert_alias(const RepoInfo &info)
Iterator findAlias(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Find alias_r in repo/service container.
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.
bool serviceEmpty() const
Gets true if no service is in RepoManager (so no one in specified location)
Service type enumeration.
std::string asUserString() const
Translated error message as string suitable for the user.
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...
std::ostream & operator<<(std::ostream &str, const DeltaCandidates &obj)
std::string asCompleteString() const
Returns a complete string representation of the Url object.
AsyncOpRef< expected< repo::RefreshCheckStatus > > checkIfToRefreshMetadata(repo::AsyncRefreshContextRef refCtx, ProvideMediaHandle medium, ProgressObserverRef progressObserver=nullptr)
ServiceSet::size_type ServiceSizeType
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
void modifyService(const std::string &oldAlias, const ServiceInfo &service)
Modifies service file (rewrites it with new values) and underlying repositories if needed...
bool isCached(const RepoInfo &info) const
Whether a repository exists in cache.
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
bool isValid() const
Verifies the Url.
Pathname geoipCachePath() const
Path where the geoip caches are kept (/var/cache/zypp/geoip)
ServiceConstIterator serviceBegin() const
Iterator to first service in internal storage.
std::vector< std::string > Arguments
const std::string & asString() const
Return current Pathname as String.
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
int unlink(const Pathname &path)
Like 'unlink'.
static const RepoType NONE
int compareCI(const C_Str &lhs, const C_Str &rhs)
bool isTmpRepo(const RepoInfo &info_r)
Whether repo is not under RM control and provides its own methadata paths.
ServiceConstIterator serviceEnd() const
Iterator to place behind last service in internal storage.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
void refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, OPT_PROGRESS)
Base class for Exception.
void assert_urls(const RepoInfo &info)
Exception for repository handling.
RepoConstIterator repoBegin() const
bool any_of(const Container &c, Fnc &&cb)
static std::string makeStupidAlias(const Url &url_r=Url())
Some stupid string but suitable as alias for your url if nothing better is available.
media::MediaAccessId _mid
static Date now()
Return the current time.
bool ZYPP_PLUGIN_APPDATA_FORCE_COLLECT()
To trigger appdata refresh unconditionally.
#define PL_(MSG1, MSG2, N)
AsyncOpRef< expected< zypp::repo::RepoType > > probeRepoType(ContextRef ctx, ProvideMediaHandle medium, zypp::Pathname path, std::optional< zypp::Pathname > targetPath={})
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
void assert_url(const ServiceInfo &info)
RepoSet::const_iterator RepoConstIterator
Wrapper class for ::stat/::lstat.
std::map< std::string, RepoState > RepoStates
AsyncOpRef< expected< repo::AsyncRefreshContextRef > > refreshMetadata(repo::AsyncRefreshContextRef refCtx, ProvideMediaHandle medium, ProgressObserverRef progressObserver)
ResultType and_then(const expected< T, E > &exp, Function &&f)
static const RepoType RPMPLAINDIR
RepoStatus metadataStatus(const RepoInfo &info) const
Status of local metadata.
Track changing files or directories.
Repository already exists and some unique attribute can't be duplicated.
ServiceSizeType serviceSize() const
Gets count of service in RepoManager (in specified location)
bool foundAliasIn(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Check if alias_r is present in repo/service container.
Functor replacing repository variables.
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
Repository addRepoSolv(const Pathname &file_r, const std::string &name_r)
Load Solvables from a solv-file into a Repository named name_r.
int dirForEachExt(const Pathname &dir_r, const function< bool(const Pathname &, const DirEntry &)> &fnc_r)
Simiar to.
Easy-to use interface to the ZYPP dependency resolver.
RepoConstIterator repoEnd() const
void refreshGeoIp(const RepoInfo::url_set &urls)
std::string hexstring(char n, int w=4)
RepoManager implementation.
std::ostream & operator<<(std::ostream &str, const RepoManager::Impl &obj)
void cleanMetadata(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local metadata.
RepoStatus cacheStatus(const RepoInfo &info) const
Status of metadata cache.
bool hasService(const std::string &alias) const
Return whether there is a known service for alias.
AsyncOpRef< expected< repo::AsyncRefreshContextRef > > buildCache(repo::AsyncRefreshContextRef refCtx, ProgressObserverRef progressObserver=nullptr)
RepoManager(RepoManagerOptions options=RepoManagerOptions())
Repository type enumeration.
ServiceSet::const_iterator ServiceConstIterator
Pathname packagesPath(const RepoInfo &info) const
Path where the rpm packages are downloaded and kept.