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;
155 _pluginRepoverification(_options.pluginsPath /
"repoverification",
157 init_knownServices();
158 init_knownRepositories();
163 Impl &operator=(
const Impl &) =
delete;
170 && geteuid() == 0 && ( _options.rootDir.empty() || _options.rootDir ==
"/" ) )
173 std::list<Pathname> entries;
175 if ( ! entries.empty() )
178 cmd.push_back(
"<" );
179 cmd.push_back(
">" );
180 cmd.push_back(
"PROGRAM" );
181 for (
const auto & rinfo : repos() )
183 if ( ! rinfo.enabled() )
185 cmd.push_back(
"-R" );
186 cmd.push_back( rinfo.alias() );
187 cmd.push_back(
"-t" );
188 cmd.push_back( rinfo.type().asString() );
189 cmd.push_back(
"-p" );
190 cmd.push_back( (rinfo.metadataPath()/rinfo.path()).
asString() );
193 for_( it, entries.begin(), entries.end() )
228 void refreshServices(
const RefreshServiceOptions & options_r );
230 void refreshService(
const std::string & alias,
const RefreshServiceOptions & options_r );
232 { refreshService( service.
alias(), options_r ); }
242 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
245 {
return new Impl( *
this ); }
251 {
return str <<
"RepoManager::Impl"; }
256 using zyppng::operators::operator|;
258 refreshGeoIPData( { url } );
260 auto ctx = zyppng::SyncContext::create();
262 | and_then( [&]( zyppng::repo::SyncRefreshContextRef &&refCtx ) {
263 refCtx->setPolicy ( static_cast<zyppng::repo::RawMetadataRefreshPolicy>( policy ) );
279 using zyppng::operators::operator|;
282 refreshGeoIPData( info.baseUrls() );
285 media::ScopedDisableMediaChangeReport guard( info.baseUrlsSize() > 1 );
288 RepoException rexception( info,
PL_(
"Valid metadata not found at specified URL",
289 "Valid metadata not found at specified URLs",
290 info.baseUrlsSize() ) );
293 auto ctx = SyncContext::create();
296 const auto &updateProbedType = [&]( repo::RepoType repokind ) {
298 for_( it, repoBegin(), repoEnd() )
300 if ( info.alias() == (*it).alias() )
302 RepoInfo modifiedrepo = *it;
303 modifiedrepo.setType( repokind );
316 | and_then( [&]( zyppng::repo::SyncRefreshContextRef refCtx ) {
317 refCtx->setPolicy( static_cast<zyppng::repo::RawMetadataRefreshPolicy>( policy ) );
334 ERR <<
"Trying another url..." << endl;
339 if (it == info.baseUrlsBegin())
340 rexception.remember( e );
345 ERR <<
"No more urls..." << endl;
358 Exception ex(
str::form(
_(
"Can't create %s"), _options.repoCachePath.c_str()) );
361 RepoStatus raw_metadata_status = metadataStatus(info);
362 if ( raw_metadata_status.empty() )
368 raw_metadata_status = metadataStatus(info);
371 bool needs_cleaning =
false;
372 if ( isCached( info ) )
374 MIL << info.alias() <<
" is already cached." << endl;
375 RepoStatus cache_status = cacheStatus(info);
377 if ( cache_status == raw_metadata_status )
379 MIL << info.alias() <<
" cache is up to date with metadata." << endl;
380 if ( policy == BuildIfNeeded )
384 if ( ! PathInfo(base/
"solv.idx").isExist() )
390 MIL << info.alias() <<
" cache rebuild is forced" << endl;
394 needs_cleaning =
true;
397 ProgressData progress(100);
398 callback::SendReport<ProgressReport> report;
399 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
400 progress.name(
str::form(
_(
"Building repository '%s' cache"), info.label().c_str()));
408 MIL << info.alias() <<
" building cache..." << info.type() << endl;
414 Exception ex(
str::form(
_(
"Can't create %s"), base.c_str()) );
418 if( ! PathInfo(base).userMayW() )
420 Exception ex(
str::form(
_(
"Can't create cache at %s - no writing permissions."), base.c_str()) );
423 Pathname solvfile = base /
"solv";
426 repo::RepoType repokind = info.type();
429 switch ( repokind.toEnum() )
433 repokind = probeCache( productdatapath );
439 MIL <<
"repo type is " << repokind << endl;
441 switch ( repokind.toEnum() )
449 scoped_ptr<MediaMounter> forPlainDirs;
452 cmd.push_back( PathInfo(
"/usr/bin/repo2solv" ).isFile() ?
"repo2solv" :
"repo2solv.sh" );
454 cmd.push_back(
"-o" );
455 cmd.push_back( solvfile.asString() );
456 cmd.push_back(
"-X" );
461 forPlainDirs.reset(
new MediaMounter( info.url() ) );
463 cmd.push_back(
"-R" );
465 cmd.push_back( forPlainDirs->getPathName( info.path() ).c_str() );
468 cmd.push_back( productdatapath.asString() );
471 std::string errdetail;
473 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() ) {
474 WAR <<
" " << output;
478 int ret = prog.close();
482 ex.addHistory( str::Str() << prog.command() << endl << errdetail << prog.execError() );
487 guard.resetDispose();
496 setCacheStatus(info, raw_metadata_status);
497 MIL <<
"Commit cache.." << endl;
510 repo::RepoType RepoManager::Impl::probe(
const Url & url,
const Pathname & path )
const 514 using zyppng::operators::operator|;
516 auto ctx = zyppng::SyncContext::create();
518 | and_then( [&](
auto mediaHandle ) {
536 catch (
const Exception & exp )
539 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
540 cleanCache( info, progressrcv );
541 buildCache( info, BuildIfNeeded, progressrcv );
553 ProgressData progress(100);
554 callback::SendReport<ProgressReport> report;
555 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
556 progress.name(
str::form(
_(
"Adding repository '%s'"), info.label().c_str()));
559 MIL <<
"Try adding repo " << info << endl;
561 RepoInfo tosave = info;
562 if ( repos().find(tosave) != repos().end() )
566 if ( _options.probe )
568 DBG <<
"unknown repository type, probing" << endl;
571 RepoType probedtype( probe( tosave.url(), info.path() ) );
575 tosave.setType(probedtype);
583 MIL <<
"done" << endl;
590 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
595 for_ ( kit, repoBegin(), repoEnd() )
597 if ( (*it).alias() == (*kit).alias() )
599 ERR <<
"To be added repo " << (*it).alias() <<
" conflicts with existing repo " << (*kit).alias() << endl;
605 std::string filename = Pathname(url.getPathName()).basename();
607 if ( filename == Pathname() )
616 Pathname repofile = generateNonExistingName(_options.knownReposPath, filename);
618 MIL <<
"Saving " << repos.size() <<
" repo" << ( repos.size() ?
"s" :
"" ) <<
" in " << repofile << endl;
620 std::ofstream file(repofile.c_str());
627 for ( std::list<RepoInfo>::iterator it = repos.begin();
631 MIL <<
"Saving " << (*it).alias() << endl;
632 it->dumpAsIniOn(file);
633 it->setFilepath(repofile);
636 reposManip().insert(*it);
638 HistoryLog(_options.rootDir).addRepository(*it);
641 MIL <<
"done" << endl;
646 callback::SendReport<ProgressReport> report;
647 ProgressReportAdaptor adapt( progressrcv, report );
648 removeRepositoryImpl( info, std::ref(adapt) );
657 void RepoManager::Impl::refreshServices(
const RefreshServiceOptions & options_r )
661 ServiceSet services( serviceBegin(), serviceEnd() );
662 for_( it, services.begin(), services.end() )
664 if ( !it->enabled() )
668 refreshService(*it, options_r);
670 catch (
const repo::ServicePluginInformalException & e )
675 void RepoManager::Impl::refreshService(
const std::string & alias,
const RefreshServiceOptions & options_r )
677 ServiceInfo service( getService( alias ) );
680 MIL <<
"Going to refresh service '" << service.alias() <<
"', url: " << service.url() <<
", opts: " << options_r << endl;
682 if ( service.ttl() && !( options_r.testFlag( RefreshService_forceRefresh) || options_r.testFlag( RefreshService_restoreStatus ) ) )
685 Date lrf = service.lrf();
691 if ( (lrf+=service.ttl()) > now )
693 MIL <<
"Skip: '" << service.alias() <<
"' metadata valid until " << lrf << endl;
698 WAR <<
"Force: '" << service.alias() <<
"' metadata last refresh in the future: " << lrf << endl;
705 bool serviceModified =
false;
712 repo::ServiceType type = probeService( service.url() );
715 service.setProbedType( type );
716 serviceModified =
true;
721 std::string servicesTargetDistro = _options.servicesTargetDistro;
722 if ( servicesTargetDistro.empty() )
726 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << endl;
730 RepoCollector collector(servicesTargetDistro);
735 std::pair<DefaultIntegral<bool,false>, repo::ServicePluginInformalException> uglyHack;
745 catch (
const repo::ServicePluginInformalException & e )
748 uglyHack.first =
true;
751 if ( service.ttl() != origTtl )
753 if ( !service.ttl() )
754 service.setLrf( Date() );
755 serviceModified =
true;
763 for_( it, collector.repos.begin(), collector.repos.end() )
766 it->setAlias(
str::form(
"%s:%s", service.alias().c_str(), it->alias().c_str() ) );
768 it->setService( service.alias() );
771 newRepoStates[it->alias()] = *it;
779 if ( !it->path().empty() )
781 if ( it->path() !=
"/" )
786 if ( it->baseUrlsEmpty() )
788 Url url( service.rawUrl() );
790 url.setPathName( url.getPathName() / path );
791 it->setBaseUrl( std::move(url) );
793 else if ( !path.empty() )
796 for ( Url & url : urls )
798 url.setPathName( url.getPathName() / path );
800 it->setBaseUrls( std::move(urls) );
807 RepoInfoList oldRepos;
808 getRepositoriesInService( service.alias(), std::back_inserter( oldRepos ) );
812 for_( oldRepo, oldRepos.begin(), oldRepos.end() )
814 if ( !
foundAliasIn( oldRepo->alias(), collector.repos ) )
816 if ( oldRepo->enabled() )
819 const auto & last = service.repoStates().find( oldRepo->alias() );
820 if ( last != service.repoStates().end() && ! last->second.enabled )
822 DBG <<
"Service removes user enabled repo " << oldRepo->alias() << endl;
823 service.addRepoToEnable( oldRepo->alias() );
824 serviceModified =
true;
827 DBG <<
"Service removes enabled repo " << oldRepo->alias() << endl;
830 DBG <<
"Service removes disabled repo " << oldRepo->alias() << endl;
832 removeRepository( *oldRepo );
838 UrlCredentialExtractor urlCredentialExtractor( _options.rootDir );
839 for_( it, collector.repos.begin(), collector.repos.end() )
845 TriBool toBeEnabled( indeterminate );
846 DBG <<
"Service request to " << (it->enabled()?
"enable":
"disable") <<
" service repo " << it->alias() << endl;
848 if ( options_r.testFlag( RefreshService_restoreStatus ) )
850 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() << endl;
855 service.delRepoToEnable( it->alias() );
860 if ( service.repoToEnableFind( it->alias() ) )
862 DBG <<
"User request to enable service repo " << it->alias() << endl;
867 service.delRepoToEnable( it->alias() );
868 serviceModified =
true;
870 else if ( service.repoToDisableFind( it->alias() ) )
872 DBG <<
"User request to disable service repo " << it->alias() << endl;
877 RepoInfoList::iterator oldRepo(
findAlias( it->alias(), oldRepos ) );
878 if ( oldRepo == oldRepos.end() )
883 if ( ! indeterminate(toBeEnabled) )
884 it->setEnabled( (
bool ) toBeEnabled );
886 DBG <<
"Service adds repo " << it->alias() <<
" " << (it->enabled()?
"enabled":
"disabled") << endl;
887 addRepository( *it );
892 bool oldRepoModified =
false;
894 if ( indeterminate(toBeEnabled) )
898 if ( oldRepo->enabled() == it->enabled() )
899 toBeEnabled = it->enabled();
900 else if (options_r.testFlag( RefreshService_restoreStatus ) )
902 toBeEnabled = it->enabled();
903 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() <<
" forces " << (toBeEnabled?
"enabled":
"disabled") << endl;
907 const auto & last = service.repoStates().find( oldRepo->alias() );
908 if ( last == service.repoStates().end() || last->second.enabled != it->enabled() )
909 toBeEnabled = it->enabled();
912 toBeEnabled = oldRepo->enabled();
913 DBG <<
"User modified service repo " << it->alias() <<
" may stay " << (toBeEnabled?
"enabled":
"disabled") << endl;
919 if ( toBeEnabled == oldRepo->enabled() )
921 DBG <<
"Service repo " << it->alias() <<
" stays " << (oldRepo->enabled()?
"enabled":
"disabled") << endl;
923 else if ( toBeEnabled )
925 DBG <<
"Service repo " << it->alias() <<
" gets enabled" << endl;
926 oldRepo->setEnabled(
true );
927 oldRepoModified =
true;
931 DBG <<
"Service repo " << it->alias() <<
" gets disabled" << endl;
932 oldRepo->setEnabled(
false );
933 oldRepoModified =
true;
939 if ( oldRepo->rawName() != it->rawName() )
941 DBG <<
"Service repo " << it->alias() <<
" gets new NAME " << it->rawName() << endl;
942 oldRepo->setName( it->rawName() );
943 oldRepoModified =
true;
947 if ( oldRepo->autorefresh() != it->autorefresh() )
949 DBG <<
"Service repo " << it->alias() <<
" gets new AUTOREFRESH " << it->autorefresh() << endl;
950 oldRepo->setAutorefresh( it->autorefresh() );
951 oldRepoModified =
true;
955 if ( oldRepo->priority() != it->priority() )
957 DBG <<
"Service repo " << it->alias() <<
" gets new PRIORITY " << it->priority() << endl;
958 oldRepo->setPriority( it->priority() );
959 oldRepoModified =
true;
965 urlCredentialExtractor.extract( newUrls );
966 if ( oldRepo->rawBaseUrls() != newUrls )
968 DBG <<
"Service repo " << it->alias() <<
" gets new URLs " << newUrls << endl;
969 oldRepo->setBaseUrls( std::move(newUrls) );
970 oldRepoModified =
true;
980 oldRepo->getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
981 it-> getRawGpgChecks( ngpg[0], ngpg[1], ngpg[2] );
982 #define Z_CHKGPG(I,N) \ 983 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \ 985 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \ 986 oldRepo->set##N##Check( ngpg[I] ); \ 987 oldRepoModified = true; \ 996 if ( oldRepoModified )
998 modifyRepository( oldRepo->alias(), *oldRepo );
1004 if ( ! service.reposToDisableEmpty() )
1006 service.clearReposToDisable();
1007 serviceModified =
true;
1011 if ( service.repoStates() != newRepoStates )
1013 service.setRepoStates( std::move(newRepoStates) );
1014 serviceModified =
true;
1021 if ( service.ttl() )
1024 serviceModified =
true;
1027 if ( serviceModified )
1030 modifyService( service.alias(), service );
1034 if ( uglyHack.first )
1036 throw( uglyHack.second );
1042 repo::ServiceType RepoManager::Impl::probeService(
const Url & url )
const 1047 if ( access.doesFileExist(
"/repo/repoindex.xml") )
1050 catch (
const media::MediaException &e )
1058 catch (
const Exception &e )
1062 Exception enew(
str::form(
_(
"Unknown error reading from '%s'"), url.asString().c_str() ));
1075 MIL <<
"GeoIp disabled via ZConfig, not refreshing the GeoIP information." << std::endl;
1079 std::vector<std::string> hosts;
1080 for (
const auto &baseUrl : urls ) {
1081 const auto &host = baseUrl.getHost();
1083 hosts.push_back( host );
1088 if ( hosts.empty() ) {
1089 MIL <<
"No configured geoip URL found, not updating geoip data" << std::endl;
1096 MIL <<
"Unable to create cache directory for GeoIP." << std::endl;
1100 if ( !PathInfo(geoIPCache).userMayRWX() ) {
1101 MIL <<
"No access rights for the GeoIP cache directory." << std::endl;
1110 PathInfo pi( dir/entry.name );
1111 auto age = std::chrono::system_clock::now() - std::chrono::system_clock::from_time_t( pi.mtime() );
1112 if ( age < std::chrono::hours(24) )
1115 MIL <<
"Removing GeoIP file for " << entry.name <<
" since it's older than 24hrs." << std::endl;
1121 std::for_each( hosts.begin(), hosts.end(), [ & ](
const std::string &hostname ) {
1125 MIL <<
"Skipping GeoIP request for " << hostname <<
" since a valid cache entry exists." << std::endl;
1129 MIL <<
"Query GeoIP for " << hostname << std::endl;
1140 MIL <<
"Ignoring invalid GeoIP hostname: " << hostname << std::endl;
1152 MIL <<
"Failed to query GeoIP from hostname: " << hostname << std::endl;
1155 if ( !file->
empty() ) {
1157 constexpr
auto writeHostToFile = [](
const Pathname &fName,
const std::string &host ){
1159 out.open( fName.asString(), std::ios_base::trunc );
1160 if ( out.is_open() ) {
1161 out << host << std::endl;
1163 MIL <<
"Failed to create/open GeoIP cache file " << fName << std::endl;
1167 std::string geoipMirror;
1170 if ( reader.seekToNode( 1,
"host" ) ) {
1171 const auto &
str = reader.nodeText().asString();
1179 MIL <<
"Storing geoIP redirection: " << hostname <<
" -> " <<
str << std::endl;
1184 MIL <<
"No host entry or empty file returned for GeoIP, remembering for 24hrs" << std::endl;
1188 MIL <<
"Empty or invalid GeoIP file, not requesting again for 24hrs" << std::endl;
1191 writeHostToFile( geoIPCache / hostname, geoipMirror );
1197 MIL <<
"Failed to query GeoIP data." << std::endl;
1208 : _pimpl( new
Impl(
std::move(opt)) )
1215 {
return _pimpl->repoEmpty(); }
1218 {
return _pimpl->repoSize(); }
1221 {
return _pimpl->repoBegin(); }
1224 {
return _pimpl->repoEnd(); }
1227 {
return _pimpl->getRepo( alias ); }
1230 {
return _pimpl->hasRepo( alias ); }
1240 std::string host( url_r.
getHost() );
1241 if ( ! host.empty() )
1253 {
return _pimpl->metadataStatus( info ); }
1256 {
return _pimpl->checkIfToRefreshMetadata( info, url, policy ); }
1259 {
return _pimpl->metadataPath( info ); }
1262 {
return _pimpl->packagesPath( info ); }
1265 {
return _pimpl->refreshMetadata( info, policy, progressrcv ); }
1268 {
return _pimpl->cleanMetadata( info, progressrcv ); }
1271 {
return _pimpl->cleanPackages( info, progressrcv ); }
1274 {
return _pimpl->cacheStatus( info ); }
1277 {
return _pimpl->buildCache( info, policy, progressrcv ); }
1280 {
return _pimpl->cleanCache( info, progressrcv ); }
1283 {
return _pimpl->isCached( info ); }
1286 {
return _pimpl->loadFromCache( info, progressrcv ); }
1289 {
return _pimpl->cleanCacheDirGarbage( progressrcv ); }
1292 {
return _pimpl->probe( url, path ); }
1295 {
return _pimpl->probe( url ); }
1298 {
return _pimpl->addRepository( info, progressrcv ); }
1301 {
return _pimpl->addRepositories( url, progressrcv ); }
1304 {
return _pimpl->removeRepository( info, progressrcv ); }
1307 {
return _pimpl->modifyRepository( alias, newinfo, progressrcv ); }
1310 {
return _pimpl->getRepositoryInfo( alias ); }
1313 {
return _pimpl->getRepositoryInfo( url, urlview ); }
1316 {
return _pimpl->serviceEmpty(); }
1319 {
return _pimpl->serviceSize(); }
1322 {
return _pimpl->serviceBegin(); }
1325 {
return _pimpl->serviceEnd(); }
1328 {
return _pimpl->getService( alias ); }
1331 {
return _pimpl->hasService( alias ); }
1334 {
return _pimpl->probeService( url ); }
1337 {
return _pimpl->addService( alias, url ); }
1340 {
return _pimpl->addService( service ); }
1343 {
return _pimpl->removeService( alias ); }
1346 {
return _pimpl->removeService( service ); }
1349 {
return _pimpl->refreshServices( options_r ); }
1352 {
return _pimpl->refreshService( alias, options_r ); }
1355 {
return _pimpl->refreshService( service, options_r ); }
1358 {
return _pimpl->modifyService( oldAlias, service ); }
1361 {
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.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
std::string targetDistribution() const
This is register.target attribute of the installed base product.
RepoSet::size_type RepoSizeType
constexpr std::string_view Url("url")
static const std::string & sha1()
sha1
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
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
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...
static const ServiceType RIS
Repository Index Service (RIS) (formerly known as 'Novell Update' (NU) service)
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 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)
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.
int unlink(const Pathname &path)
Like 'unlink'.
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)
static const ServiceType NONE
No service set.
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::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...
static const ServiceType PLUGIN
Plugin services are scripts installed on your system that provide the package manager with repositori...
bool isCached(const RepoInfo &info) const
Whether a repository exists in cache.
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
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).
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
std::list< RepoInfo > readRepoFile(const Url &repo_file)
Parses repo_file and returns a list of RepoInfo objects corresponding to repositories found within th...
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
int dirForEachExt(const Pathname &dir_r, const function< bool(const Pathname &, const DirEntry &)> &fnc_r)
Simiar to.
Wrapper class for ::stat/::lstat.
std::map< std::string, RepoState > RepoStates
AsyncOpRef< expected< repo::AsyncRefreshContextRef > > refreshMetadata(repo::AsyncRefreshContextRef refCtx, ProvideMediaHandle medium, ProgressObserverRef progressObserver)
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.
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.