Go to the documentation of this file.
21 #include <solv/solvversion.h>
63 #define OPT_PROGRESS const ProgressData::ReceiverFnc & = ProgressData::ReceiverFnc()
75 const char * env = getenv(
"ZYPP_PLUGIN_APPDATA_FORCE_COLLECT");
105 class UrlCredentialExtractor
108 UrlCredentialExtractor( Pathname & root_r )
112 ~UrlCredentialExtractor()
116 bool collect(
const Url & url_r )
118 bool ret = url_r.hasCredentialsInAuthority();
122 _cmPtr->addUserCred( url_r );
127 template<
class TContainer>
128 bool collect(
const TContainer & urls_r )
129 {
bool ret =
false;
for (
const Url &
url : urls_r ) {
if ( collect(
url ) && !ret ) ret =
true; }
return ret; }
132 bool extract( Url & url_r )
134 bool ret = collect( url_r );
136 url_r.setPassword( std::string() );
140 template<
class TContainer>
141 bool extract( TContainer & urls_r )
142 {
bool ret =
false;
for ( Url &
url : urls_r ) {
if ( extract(
url ) && !ret ) ret =
true; }
return ret; }
146 scoped_ptr<media::CredentialManager>
_cmPtr;
161 MediaMounter(
const Url & url_r )
163 media::MediaManager mediamanager;
164 _mid = mediamanager.open( url_r );
165 mediamanager.attach(
_mid );
171 media::MediaManager mediamanager;
172 mediamanager.release(
_mid );
173 mediamanager.close(
_mid );
180 Pathname getPathName(
const Pathname & path_r = Pathname() )
const
182 media::MediaManager mediamanager;
183 return mediamanager.localPath(
_mid, path_r );
192 template <
class Iterator>
193 inline bool foundAliasIn(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
195 for_( it, begin_r, end_r )
196 if ( it->alias() == alias_r )
201 template <
class Container>
202 inline bool foundAliasIn(
const std::string & alias_r,
const Container & cont_r )
203 {
return foundAliasIn( alias_r, cont_r.begin(), cont_r.end() ); }
206 template <
class Iterator>
207 inline Iterator findAlias(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
209 for_( it, begin_r, end_r )
210 if ( it->alias() == alias_r )
215 template <
class Container>
216 inline typename Container::iterator findAlias(
const std::string & alias_r, Container & cont_r )
217 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
219 template <
class Container>
220 inline typename Container::const_iterator findAlias(
const std::string & alias_r,
const Container & cont_r )
221 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
225 inline std::string filenameFromAlias(
const std::string & alias_r,
const std::string & stem_r )
227 std::string filename( alias_r );
231 filename = Pathname(filename).extend(
"."+stem_r).asString();
232 MIL <<
"generating filename for " << stem_r <<
" [" << alias_r <<
"] : '" << filename <<
"'" << endl;
256 RepoCollector(
const std::string & targetDistro_)
260 bool collect(
const RepoInfo &repo )
264 && !repo.targetDistribution().empty()
268 <<
"Skipping repository meant for '" << repo.targetDistribution()
269 <<
"' distribution (current distro is '"
275 repos.push_back(repo);
289 std::list<RepoInfo> repositories_in_file(
const Pathname & file )
291 MIL <<
"repo file: " << file << endl;
292 RepoCollector collector;
293 parser::RepoFileReader parser( file, bind( &RepoCollector::collect, &collector, _1 ) );
294 return std::move(collector.repos);
307 std::list<RepoInfo> repositories_in_dir(
const Pathname &dir )
309 MIL <<
"directory " << dir << endl;
310 std::list<RepoInfo>
repos;
311 bool nonroot( geteuid() != 0 );
312 if ( nonroot && ! PathInfo(dir).userMayRX() )
314 JobReport::warning( str::Format(
_(
"Cannot read repo directory '%1%': Permission denied")) % dir );
318 std::list<Pathname> entries;
325 str::regex allowedRepoExt(
"^\\.repo(_[0-9]+)?$");
326 for ( std::list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
330 if ( nonroot && ! PathInfo(*it).userMayR() )
332 JobReport::warning( str::Format(
_(
"Cannot read repo file '%1%': Permission denied")) % *it );
336 const std::list<RepoInfo> & tmp( repositories_in_file( *it ) );
337 repos.insert(
repos.end(), tmp.begin(), tmp.end() );
347 inline void assert_alias(
const RepoInfo & info )
349 if ( info.alias().empty() )
353 if ( info.alias()[0] ==
'.')
355 info,
_(
"Repository alias cannot start with dot.")));
358 inline void assert_alias(
const ServiceInfo & info )
360 if ( info.alias().empty() )
364 if ( info.alias()[0] ==
'.')
366 info,
_(
"Service alias cannot start with dot.")));
371 inline void assert_urls(
const RepoInfo & info )
373 if ( info.baseUrlsEmpty() )
377 inline void assert_url(
const ServiceInfo & info )
379 if ( ! info.url().isValid() )
389 inline bool isTmpRepo(
const RepoInfo & info_r )
390 {
return( info_r.filepath().empty() && info_r.usesAutoMethadataPaths() ); }
398 inline Pathname rawcache_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
401 return isTmpRepo( info ) ? info.metadataPath() : opt.repoRawCachePath / info.escaped_alias();
412 inline Pathname rawproductdata_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
413 {
return rawcache_path_for_repoinfo( opt, info ) / info.path(); }
418 inline Pathname packagescache_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
421 return isTmpRepo( info ) ? info.packagesPath() : opt.repoPackagesCachePath / info.escaped_alias();
427 inline Pathname solv_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
430 return isTmpRepo( info ) ? info.metadataPath().dirname() /
"%SLV%" : opt.repoSolvCachePath / info.escaped_alias();
436 class ServiceCollector
439 typedef std::set<ServiceInfo> ServiceSet;
441 ServiceCollector( ServiceSet & services_r )
445 bool operator()(
const ServiceInfo & service_r )
const
463 DBG <<
"reading repo file " << repo_file <<
", local path: " << local << endl;
465 return repositories_in_file(local);
504 #define OUTS(X) str << " " #X "\t" << obj.X << endl
505 str <<
"RepoManagerOptions (" << obj.
rootDir <<
") {" << endl;
506 OUTS( repoRawCachePath );
507 OUTS( repoSolvCachePath );
508 OUTS( repoPackagesCachePath );
509 OUTS( knownReposPath );
510 OUTS( knownServicesPath );
528 init_knownServices();
529 init_knownRepositories();
536 && geteuid() == 0 && ( _options.rootDir.empty() || _options.rootDir ==
"/" ) )
539 std::list<Pathname> entries;
541 if ( ! entries.empty() )
544 cmd.push_back(
"<" );
545 cmd.push_back(
">" );
546 cmd.push_back(
"PROGRAM" );
547 for (
const auto & rinfo :
repos() )
549 if ( ! rinfo.enabled() )
551 cmd.push_back(
"-R" );
552 cmd.push_back( rinfo.alias() );
553 cmd.push_back(
"-t" );
554 cmd.push_back( rinfo.type().asString() );
555 cmd.push_back(
"-p" );
556 cmd.push_back( rinfo.metadataPath().asString() );
559 for_( it, entries.begin(), entries.end() )
582 bool hasRepo(
const std::string & alias )
const
583 {
return foundAliasIn( alias,
repos() ); }
593 {
return rawcache_path_for_repoinfo( _options, info ); }
596 {
return packagescache_path_for_repoinfo( _options, info ); }
618 {
return PathInfo(solv_path_for_repoinfo( _options, info ) /
"solv").
isExist(); }
643 {
return foundAliasIn( alias,
_services ); }
656 void removeService(
const std::string & alias );
658 { removeService( service.
alias() ); }
664 { refreshService( service.
alias(), options_r ); }
666 void modifyService(
const std::string & oldAlias,
const ServiceInfo & newService );
673 Pathname generateNonExistingName(
const Pathname & dir,
const std::string & basefilename )
const;
676 {
return filenameFromAlias( info.
alias(),
"repo" ); }
679 {
return filenameFromAlias( info.
alias(),
"service" ); }
683 Pathname base = solv_path_for_repoinfo( _options, info );
688 void touchIndexFile(
const RepoInfo & info );
690 template<
typename OutputIterator>
695 boost::make_filter_iterator( filter,
repos().end(),
repos().end() ),
700 void init_knownServices();
701 void init_knownRepositories();
714 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
717 {
return new Impl( *
this ); }
723 {
return str <<
"RepoManager::Impl"; }
730 Pathname servfile = generateNonExistingName( _options.knownServicesPath,
731 generateFilename( service ) );
734 MIL <<
"saving service in " << servfile << endl;
736 std::ofstream file( servfile.
c_str() );
743 MIL <<
"done" << endl;
762 const std::string & basefilename )
const
764 std::string final_filename = basefilename;
766 while (
PathInfo(dir + final_filename).isExist() )
771 return dir +
Pathname(final_filename);
778 Pathname dir = _options.knownServicesPath;
779 std::list<Pathname> entries;
789 for_(it, entries.begin(), entries.end() )
805 inline void cleanupNonRepoMetadtaFolders(
const Pathname & cachePath_r,
806 const Pathname & defaultCachePath_r,
807 const std::list<std::string> & repoEscAliases_r )
809 if ( cachePath_r != defaultCachePath_r )
812 std::list<std::string> entries;
816 std::set<std::string> oldfiles;
817 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
818 std::inserter( oldfiles, oldfiles.end() ) );
819 for (
const std::string & old : oldfiles )
831 MIL <<
"start construct known repos" << endl;
835 std::list<std::string> repoEscAliases;
836 std::list<RepoInfo> orphanedRepos;
837 for (
RepoInfo & repoInfo : repositories_in_dir(_options.knownReposPath) )
840 repoInfo.setMetadataPath( rawcache_path_for_repoinfo(_options, repoInfo) );
842 repoInfo.setPackagesPath( packagescache_path_for_repoinfo(_options, repoInfo) );
844 _reposX.insert( repoInfo );
847 const std::string & serviceAlias( repoInfo.service() );
848 if ( ! ( serviceAlias.empty() || hasService( serviceAlias ) ) )
850 WAR <<
"Schedule orphaned service repo for deletion: " << repoInfo << endl;
851 orphanedRepos.push_back( repoInfo );
855 repoEscAliases.push_back(repoInfo.escaped_alias());
859 if ( ! orphanedRepos.empty() )
861 for (
const auto & repoInfo : orphanedRepos )
863 MIL <<
"Delete orphaned service repo " << repoInfo.alias() << endl;
869 % repoInfo.alias() );
871 removeRepository( repoInfo );
885 repoEscAliases.sort();
887 cleanupNonRepoMetadtaFolders( _options.repoRawCachePath, defaultCache.
repoRawCachePath, repoEscAliases );
888 cleanupNonRepoMetadtaFolders( _options.repoSolvCachePath, defaultCache.
repoSolvCachePath, repoEscAliases );
889 cleanupNonRepoMetadtaFolders( _options.repoPackagesCachePath, defaultCache.
repoPackagesCachePath, repoEscAliases );
891 MIL <<
"end construct known repos" << endl;
898 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
899 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
904 repokind = probeCache( productdatapath );
907 switch ( repokind.
toEnum() )
910 status =
RepoStatus( productdatapath/
"repodata/repomd.xml") &&
RepoStatus( mediarootpath/
"media.1/media" );
914 status =
RepoStatus( productdatapath/
"content" ) &&
RepoStatus( mediarootpath/
"media.1/media" );
933 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
938 repokind = probeCache( productdatapath );
944 switch ( repokind.
toEnum() )
947 p =
Pathname(productdatapath +
"/repodata/repomd.xml");
951 p =
Pathname(productdatapath +
"/content");
955 p =
Pathname(productdatapath +
"/cookie");
973 MIL <<
"Going to try to check whether refresh is needed for " <<
url <<
" (" << info.
type() <<
")" << endl;
976 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
978 RepoStatus oldstatus = metadataStatus( info );
979 if ( oldstatus.
empty() )
981 MIL <<
"No cached metadata, going to refresh" << endl;
982 return REFRESH_NEEDED;
985 if (
url.schemeIsVolatile() )
987 MIL <<
"Never refresh CD/DVD" << endl;
988 return REPO_UP_TO_DATE;
991 if ( policy == RefreshForced )
993 MIL <<
"Forced refresh!" << endl;
994 return REFRESH_NEEDED;
997 if (
url.schemeIsLocal() )
999 policy = RefreshIfNeededIgnoreDelay;
1003 if ( policy != RefreshIfNeededIgnoreDelay )
1006 double diff = difftime(
1012 DBG <<
"last refresh = " << diff <<
" minutes ago" << endl;
1018 WAR <<
"Repository '" << info.
alias() <<
"' was refreshed in the future!" << endl;
1022 MIL <<
"Repository '" << info.
alias()
1023 <<
"' has been refreshed less than repo.refresh.delay ("
1025 <<
") minutes ago. Advising to skip refresh" << endl;
1026 return REPO_CHECK_DELAYED;
1034 repokind = probe(
url, info.
path() );
1038 switch ( repokind.
toEnum() )
1065 if ( oldstatus == newstatus )
1067 MIL <<
"repo has not changed" << endl;
1068 touchIndexFile( info );
1069 return REPO_UP_TO_DATE;
1073 MIL <<
"repo has changed, going to refresh" << endl;
1074 return REFRESH_NEEDED;
1080 ERR <<
"refresh check failed for " <<
url << endl;
1084 return REFRESH_NEEDED;
1094 RepoException rexception( info,
PL_(
"Valid metadata not found at specified URL",
1095 "Valid metadata not found at specified URLs",
1109 if (checkIfToRefreshMetadata(info,
url, policy)!=REFRESH_NEEDED)
1112 MIL <<
"Going to refresh metadata from " <<
url << endl;
1120 if ( repokind != probed )
1126 for_( it, repoBegin(), repoEnd() )
1128 if ( info.
alias() == (*it).alias() )
1131 modifiedrepo.
setType( repokind );
1132 modifyRepository( info.
alias(), modifiedrepo );
1139 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1150 Exception ex(
_(
"Can't create metadata cache directory."));
1158 shared_ptr<repo::Downloader> downloader_ptr;
1160 MIL <<
"Creating downloader for [ " << info.
alias() <<
" ]" << endl;
1173 for_( it, repoBegin(), repoEnd() )
1175 Pathname cachepath(rawcache_path_for_repoinfo( _options, *it ));
1176 if (
PathInfo(cachepath).isExist() )
1177 downloader_ptr->addCachePath(cachepath);
1180 downloader_ptr->download( media, tmpdir.
path() );
1184 MediaMounter media(
url );
1199 if ( ! isTmpRepo( info ) )
1208 ERR <<
"Trying another url..." << endl;
1220 ERR <<
"No more urls..." << endl;
1229 progress.
sendTo(progressfnc);
1239 progress.
sendTo(progressfnc);
1249 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1250 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
1257 RepoStatus raw_metadata_status = metadataStatus(info);
1258 if ( raw_metadata_status.
empty() )
1263 refreshMetadata(info, RefreshIfNeeded, progressrcv );
1264 raw_metadata_status = metadataStatus(info);
1267 bool needs_cleaning =
false;
1268 if ( isCached( info ) )
1270 MIL << info.
alias() <<
" is already cached." << endl;
1273 if ( cache_status == raw_metadata_status )
1275 MIL << info.
alias() <<
" cache is up to date with metadata." << endl;
1276 if ( policy == BuildIfNeeded )
1279 const Pathname & base = solv_path_for_repoinfo( _options, info);
1280 if ( !
PathInfo(base/
"solv.idx").isExist() )
1286 MIL << info.
alias() <<
" cache rebuild is forced" << endl;
1290 needs_cleaning =
true;
1304 MIL << info.
alias() <<
" building cache..." << info.
type() << endl;
1306 Pathname base = solv_path_for_repoinfo( _options, info);
1325 switch ( repokind.
toEnum() )
1329 repokind = probeCache( productdatapath );
1335 MIL <<
"repo type is " << repokind << endl;
1337 switch ( repokind.
toEnum() )
1345 scoped_ptr<MediaMounter> forPlainDirs;
1348 cmd.push_back(
PathInfo(
"/usr/bin/repo2solv" ).isFile() ?
"repo2solv" :
"repo2solv.sh" );
1350 cmd.push_back(
"-o" );
1351 cmd.push_back( solvfile.
asString() );
1352 cmd.push_back(
"-X" );
1357 forPlainDirs.reset(
new MediaMounter( info.
url() ) );
1359 cmd.push_back(
"-R" );
1361 cmd.push_back( forPlainDirs->getPathName( info.
path() ).c_str() );
1364 cmd.push_back( productdatapath.
asString() );
1367 std::string errdetail;
1370 WAR <<
" " << output;
1371 if ( errdetail.empty() ) {
1375 errdetail += output;
1378 int ret = prog.
close();
1396 setCacheStatus(info, raw_metadata_status);
1397 MIL <<
"Commit cache.." << endl;
1412 MIL <<
"going to probe the repo type at " <<
url <<
" (" << path <<
")" << endl;
1418 MIL <<
"Probed type NONE (not exists) at " <<
url <<
" (" << path <<
")" << endl;
1430 bool gotMediaException =
false;
1438 MIL <<
"Probed type RPMMD at " <<
url <<
" (" << path <<
")" << endl;
1445 DBG <<
"problem checking for repodata/repomd.xml file" << endl;
1447 gotMediaException =
true;
1454 MIL <<
"Probed type YAST2 at " <<
url <<
" (" << path <<
")" << endl;
1461 DBG <<
"problem checking for content file" << endl;
1463 gotMediaException =
true;
1467 if ( !
url.schemeIsDownloading() )
1469 MediaMounter media(
url );
1473 MIL <<
"Probed type RPMPLAINDIR at " <<
url <<
" (" << path <<
")" << endl;
1487 if (gotMediaException)
1490 MIL <<
"Probed type NONE at " <<
url <<
" (" << path <<
")" << endl;
1501 MIL <<
"going to probe the cached repo at " << path_r << endl;
1505 if (
PathInfo(path_r/
"/repodata/repomd.xml").isFile() )
1507 else if (
PathInfo(path_r/
"/content").isFile() )
1509 else if (
PathInfo(path_r).isDir() )
1512 MIL <<
"Probed cached type " << ret <<
" at " << path_r << endl;
1520 MIL <<
"Going to clean up garbage in cache dirs" << endl;
1523 progress.
sendTo(progressrcv);
1526 std::list<Pathname> cachedirs;
1527 cachedirs.push_back(_options.repoRawCachePath);
1528 cachedirs.push_back(_options.repoPackagesCachePath);
1529 cachedirs.push_back(_options.repoSolvCachePath);
1531 for_( dir, cachedirs.begin(), cachedirs.end() )
1535 std::list<Pathname> entries;
1540 unsigned sdircount = entries.size();
1541 unsigned sdircurrent = 1;
1542 for_( subdir, entries.begin(), entries.end() )
1546 for_( r, repoBegin(), repoEnd() )
1547 if ( subdir->basename() == r->escaped_alias() )
1548 { found =
true;
break; }
1553 progress.
set( progress.
val() + sdircurrent * 100 / sdircount );
1558 progress.
set( progress.
val() + 100 );
1568 progress.
sendTo(progressrcv);
1571 MIL <<
"Removing raw metadata cache for " << info.
alias() << endl;
1582 Pathname solvfile = solv_path_for_repoinfo(_options, info) /
"solv";
1584 if ( !
PathInfo(solvfile).isExist() )
1594 if ( toolversion != LIBSOLV_TOOLVERSION )
1603 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1604 cleanCache( info, progressrcv );
1605 buildCache( info, BuildIfNeeded, progressrcv );
1623 MIL <<
"Try adding repo " << info << endl;
1630 if ( _options.probe )
1632 DBG <<
"unknown repository type, probing" << endl;
1633 assert_urls(tosave);
1647 Pathname repofile = generateNonExistingName(
1648 _options.knownReposPath, generateFilename(tosave));
1650 MIL <<
"Saving repo in " << repofile << endl;
1652 std::ofstream file(repofile.
c_str());
1661 tosave.
setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1662 tosave.
setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1668 oinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1669 oinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1671 reposManip().insert(tosave);
1676 UrlCredentialExtractor( _options.rootDir ).collect( tosave.
baseUrls() );
1681 MIL <<
"done" << endl;
1688 for ( std::list<RepoInfo>::const_iterator it =
repos.begin();
1693 for_ ( kit, repoBegin(), repoEnd() )
1695 if ( (*it).alias() == (*kit).alias() )
1697 ERR <<
"To be added repo " << (*it).alias() <<
" conflicts with existing repo " << (*kit).alias() << endl;
1714 Pathname repofile = generateNonExistingName(_options.knownReposPath, filename);
1716 MIL <<
"Saving " <<
repos.size() <<
" repo" << (
repos.size() ?
"s" :
"" ) <<
" in " << repofile << endl;
1718 std::ofstream file(repofile.
c_str());
1725 for ( std::list<RepoInfo>::iterator it =
repos.begin();
1729 MIL <<
"Saving " << (*it).alias() << endl;
1730 it->dumpAsIniOn(file);
1731 it->setFilepath(repofile);
1732 it->setMetadataPath( rawcache_path_for_repoinfo( _options, *it ) );
1733 it->setPackagesPath( packagescache_path_for_repoinfo( _options, *it ) );
1734 reposManip().insert(*it);
1739 MIL <<
"done" << endl;
1751 MIL <<
"Going to delete repo " << info.
alias() << endl;
1753 for_( it, repoBegin(), repoEnd() )
1758 if ( (!info.
alias().empty()) && ( info.
alias() != (*it).alias() ) )
1773 std::list<RepoInfo> filerepos = repositories_in_file(todelete.
filepath());
1774 if ( filerepos.size() == 0
1775 ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.
alias() ) )
1779 if ( ! ( ret == 0 || ret == ENOENT ) )
1784 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1802 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1803 fit != filerepos.end();
1806 if ( (*fit).alias() != todelete.
alias() )
1807 (*fit).dumpAsIniOn(file);
1815 if ( isCached(todelete) )
1816 cleanCache( todelete, cSubprogrcv);
1818 cleanMetadata( todelete, mSubprogrcv );
1819 cleanPackages( todelete, pSubprogrcv );
1820 reposManip().erase(todelete);
1821 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1835 RepoInfo toedit = getRepositoryInfo(alias);
1839 if ( alias != newinfo.
alias() && hasRepo( newinfo.
alias() ) )
1851 std::list<RepoInfo> filerepos = repositories_in_file(toedit.
filepath());
1867 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1868 fit != filerepos.end();
1873 if ( (*fit).alias() != toedit.
alias() )
1874 (*fit).dumpAsIniOn(file);
1882 const Pathname & solvidx = solv_path_for_repoinfo(_options, newinfo)/
"solv.idx";
1888 newinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1889 newinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1895 oinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1896 oinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1898 reposManip().erase(toedit);
1899 reposManip().insert(newinfo);
1901 UrlCredentialExtractor( _options.rootDir ).collect( newinfo.
baseUrls() );
1903 MIL <<
"repo " << alias <<
" modified" << endl;
1912 if ( it !=
repos().end() )
1922 for_( it, repoBegin(), repoEnd() )
1924 for_( urlit, (*it).baseUrlsBegin(), (*it).baseUrlsEnd() )
1926 if ( (*urlit).asString(urlview) ==
url.asString(urlview) )
1943 assert_alias( service );
1946 if ( hasService( service.
alias() ) )
1952 saveService( toSave );
1956 UrlCredentialExtractor( _options.rootDir ).collect( toSave.
url() );
1958 MIL <<
"added service " << toSave.
alias() << endl;
1965 MIL <<
"Going to delete service " << alias << endl;
1967 const ServiceInfo & service = getService( alias );
1970 if( location.
empty() )
1979 if ( tmpSet.size() == 1 )
1986 MIL << alias <<
" successfully deleted." << endl;
1992 std::ofstream file(location.
c_str());
1999 for_(it, tmpSet.begin(), tmpSet.end())
2001 if( it->alias() != alias )
2002 it->dumpAsIniOn(file);
2005 MIL << alias <<
" successfully deleted from file " << location << endl;
2009 RepoCollector rcollector;
2010 getRepositoriesInService( alias,
2011 boost::make_function_output_iterator( bind( &RepoCollector::collect, &rcollector, _1 ) ) );
2013 for_(rit, rcollector.repos.begin(), rcollector.repos.end())
2014 removeRepository(*rit);
2023 ServiceSet services( serviceBegin(), serviceEnd() );
2024 for_( it, services.begin(), services.end() )
2026 if ( !it->enabled() )
2030 refreshService(*it, options_r);
2040 assert_alias( service );
2041 assert_url( service );
2042 MIL <<
"Going to refresh service '" << service.
alias() <<
"', url: " << service.
url() <<
", opts: " << options_r << endl;
2044 if ( service.
ttl() && !( options_r.testFlag( RefreshService_forceRefresh) || options_r.testFlag( RefreshService_restoreStatus ) ) )
2053 if ( (lrf+=service.
ttl()) > now )
2055 MIL <<
"Skip: '" << service.
alias() <<
"' metadata valid until " << lrf << endl;
2060 WAR <<
"Force: '" << service.
alias() <<
"' metadata last refresh in the future: " << lrf << endl;
2067 bool serviceModified =
false;
2078 serviceModified =
true;
2083 std::string servicesTargetDistro = _options.servicesTargetDistro;
2084 if ( servicesTargetDistro.empty() )
2088 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << endl;
2092 RepoCollector collector(servicesTargetDistro);
2105 ServiceRepos( _options.rootDir, service, bind( &RepoCollector::collect, &collector, _1 ) );
2110 uglyHack.first =
true;
2111 uglyHack.second = e;
2113 if ( service.
ttl() != origTtl )
2115 if ( !service.
ttl() )
2117 serviceModified =
true;
2125 for_( it, collector.repos.begin(), collector.repos.end() )
2128 it->setAlias(
str::form(
"%s:%s", service.
alias().c_str(), it->alias().c_str() ) );
2130 it->setService( service.
alias() );
2133 newRepoStates[it->alias()] = *it;
2141 if ( !it->path().empty() )
2143 if ( it->path() !=
"/" )
2148 if ( it->baseUrlsEmpty() )
2151 if ( !path.
empty() )
2152 url.setPathName(
url.getPathName() / path );
2153 it->setBaseUrl( std::move(
url) );
2155 else if ( !path.
empty() )
2160 url.setPathName(
url.getPathName() / path );
2162 it->setBaseUrls( std::move(urls) );
2169 RepoInfoList oldRepos;
2170 getRepositoriesInService( service.
alias(), std::back_inserter( oldRepos ) );
2174 for_( oldRepo, oldRepos.begin(), oldRepos.end() )
2176 if ( ! foundAliasIn( oldRepo->alias(), collector.repos ) )
2178 if ( oldRepo->enabled() )
2181 const auto & last = service.
repoStates().find( oldRepo->alias() );
2182 if ( last != service.
repoStates().end() && ! last->second.enabled )
2184 DBG <<
"Service removes user enabled repo " << oldRepo->alias() << endl;
2186 serviceModified =
true;
2189 DBG <<
"Service removes enabled repo " << oldRepo->alias() << endl;
2192 DBG <<
"Service removes disabled repo " << oldRepo->alias() << endl;
2194 removeRepository( *oldRepo );
2200 UrlCredentialExtractor urlCredentialExtractor( _options.rootDir );
2201 for_( it, collector.repos.begin(), collector.repos.end() )
2207 TriBool toBeEnabled( indeterminate );
2208 DBG <<
"Service request to " << (it->enabled()?
"enable":
"disable") <<
" service repo " << it->alias() << endl;
2210 if ( options_r.testFlag( RefreshService_restoreStatus ) )
2212 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() << endl;
2224 DBG <<
"User request to enable service repo " << it->alias() << endl;
2230 serviceModified =
true;
2234 DBG <<
"User request to disable service repo " << it->alias() << endl;
2235 toBeEnabled =
false;
2239 RepoInfoList::iterator oldRepo( findAlias( it->alias(), oldRepos ) );
2240 if ( oldRepo == oldRepos.end() )
2245 if ( ! indeterminate(toBeEnabled) )
2246 it->setEnabled( (
bool ) toBeEnabled );
2248 DBG <<
"Service adds repo " << it->alias() <<
" " << (it->enabled()?
"enabled":
"disabled") << endl;
2249 addRepository( *it );
2254 bool oldRepoModified =
false;
2256 if ( indeterminate(toBeEnabled) )
2260 if ( oldRepo->enabled() == it->enabled() )
2261 toBeEnabled = it->enabled();
2262 else if (options_r.testFlag( RefreshService_restoreStatus ) )
2264 toBeEnabled = it->enabled();
2265 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() <<
" forces " << (toBeEnabled?
"enabled":
"disabled") << endl;
2269 const auto & last = service.
repoStates().find( oldRepo->alias() );
2270 if ( last == service.
repoStates().end() || last->second.enabled != it->enabled() )
2271 toBeEnabled = it->enabled();
2274 toBeEnabled = oldRepo->enabled();
2275 DBG <<
"User modified service repo " << it->alias() <<
" may stay " << (toBeEnabled?
"enabled":
"disabled") << endl;
2281 if ( toBeEnabled == oldRepo->enabled() )
2283 DBG <<
"Service repo " << it->alias() <<
" stays " << (oldRepo->enabled()?
"enabled":
"disabled") << endl;
2285 else if ( toBeEnabled )
2287 DBG <<
"Service repo " << it->alias() <<
" gets enabled" << endl;
2288 oldRepo->setEnabled(
true );
2289 oldRepoModified =
true;
2293 DBG <<
"Service repo " << it->alias() <<
" gets disabled" << endl;
2294 oldRepo->setEnabled(
false );
2295 oldRepoModified =
true;
2301 if ( oldRepo->rawName() != it->rawName() )
2303 DBG <<
"Service repo " << it->alias() <<
" gets new NAME " << it->rawName() << endl;
2304 oldRepo->setName( it->rawName() );
2305 oldRepoModified =
true;
2309 if ( oldRepo->autorefresh() != it->autorefresh() )
2311 DBG <<
"Service repo " << it->alias() <<
" gets new AUTOREFRESH " << it->autorefresh() << endl;
2312 oldRepo->setAutorefresh( it->autorefresh() );
2313 oldRepoModified =
true;
2317 if ( oldRepo->priority() != it->priority() )
2319 DBG <<
"Service repo " << it->alias() <<
" gets new PRIORITY " << it->priority() << endl;
2320 oldRepo->setPriority( it->priority() );
2321 oldRepoModified =
true;
2327 urlCredentialExtractor.extract( newUrls );
2328 if ( oldRepo->rawBaseUrls() != newUrls )
2330 DBG <<
"Service repo " << it->alias() <<
" gets new URLs " << newUrls << endl;
2331 oldRepo->setBaseUrls( std::move(newUrls) );
2332 oldRepoModified =
true;
2342 oldRepo->getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
2343 it-> getRawGpgChecks( ngpg[0], ngpg[1], ngpg[2] );
2344 #define Z_CHKGPG(I,N) \
2345 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \
2347 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \
2348 oldRepo->set##N##Check( ngpg[I] ); \
2349 oldRepoModified = true; \
2358 if ( oldRepoModified )
2360 modifyRepository( oldRepo->alias(), *oldRepo );
2369 serviceModified =
true;
2376 serviceModified =
true;
2383 if ( service.
ttl() )
2386 serviceModified =
true;
2389 if ( serviceModified )
2392 modifyService( service.
alias(), service );
2396 if ( uglyHack.first )
2398 throw( uglyHack.second );
2406 MIL <<
"Going to modify service " << oldAlias << endl;
2417 const ServiceInfo & oldService = getService(oldAlias);
2420 if( location.
empty() )
2430 std::ofstream file(location.
c_str());
2431 for_(it, tmpSet.begin(), tmpSet.end())
2433 if( *it != oldAlias )
2434 it->dumpAsIniOn(file);
2443 UrlCredentialExtractor( _options.rootDir ).collect( service.
url() );
2447 if ( oldAlias != service.
alias()
2450 std::vector<RepoInfo> toModify;
2451 getRepositoriesInService(oldAlias, std::back_inserter(toModify));
2452 for_( it, toModify.begin(), toModify.end() )
2459 const auto & last = service.
repoStates().find( it->alias() );
2461 it->setEnabled( last->second.enabled );
2464 it->setEnabled(
false );
2467 if ( oldAlias != service.
alias() )
2468 it->setService(service.
alias());
2470 modifyRepository(it->alias(), *it);
2514 : _pimpl( new
Impl(opt) )
2546 std::string host( url_r.
getHost() );
2547 if ( ! host.empty() )
media::MediaAccessId _mid
Retrieval of repository list for a service.
Service type enumeration.
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, OPT_PROGRESS)
static Pool instance()
Singleton ctor.
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
static const ServiceInfo noService
Represents an empty service.
bool repo_add_probe() const
Whether repository urls should be probed.
Track changing files or directories.
void buildCache(const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local cache.
Url url() const
The service url.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
void cleanPackages(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local package cache.
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
Downloader for YUM (rpm-nmd) repositories Encapsulates all the knowledge of which files have to be do...
std::string getScheme() const
Returns the scheme name of the URL.
void setLrf(Date lrf_r)
Set date of last refresh.
Pathname generateNonExistingName(const Pathname &dir, const std::string &basefilename) const
Generate a non existing filename in a directory, using a base name.
std::string hexstring(char n, int w=4)
std::list< RepoInfo > readRepoFile(const Url &repo_file)
Parses repo_file and returns a list of RepoInfo objects corresponding to repositories found within th...
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy=RefreshIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local raw cache.
bool set(value_type val_r)
Set new counter value.
bool isExist() const
Return whether valid stat info exists.
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Pathname rootDir
remembers root_r value for later use
Pathname packagesPath(const RepoInfo &info) const
Path where the rpm packages are downloaded and kept.
const RepoStates & repoStates() const
Access the remembered repository states.
Impl * clone() const
clone for RWCOW_pointer
Pathname knownServicesPath
ServiceSet::const_iterator ServiceConstIterator
Base class for Exception.
std::string generateFilename(const ServiceInfo &info) const
static const std::string & sha1()
sha1
RepoStatus cacheStatus(const RepoInfo &info) const
void reposErase(const std::string &alias_r)
Remove a Repository named alias_r.
std::string targetDistribution() const
This is register.target attribute of the installed base product.
bool isCached(const RepoInfo &info) const
Whether a repository exists in cache.
What is known about a repository.
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
bool repoToDisableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToDisable.
DefaultIntegral< bool, false > _reposDirty
static const ValueType day
void removeService(const std::string &alias)
Removes service specified by its name.
void addRepoToEnable(const std::string &alias_r)
Add alias_r to the set of ReposToEnable.
bool ZYPP_PLUGIN_APPDATA_FORCE_COLLECT()
To trigger appdata refresh unconditionally.
#define PL_(MSG1, MSG2, N)
bool empty() const
Whether the status is empty (default constucted)
Service already exists and some unique attribute can't be duplicated.
thrown when it was impossible to determine this repo type.
void cleanCacheDirGarbage(const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove any subdirectories of cache directories which no longer belong to any of known repositories.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
RepoSet::const_iterator RepoConstIterator
void removeRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove the best matching repository from known repos list.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
std::map< std::string, RepoState > RepoStates
RepoStatus metadataStatus(const RepoInfo &info) const
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Functor thats filter RepoInfo by service which it belongs to.
void refreshServices(const RefreshServiceOptions &options_r)
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
int touch(const Pathname &path)
Change file's modification and access times.
static const ServiceType RIS
Repository Index Service (RIS) (formerly known as 'Novell Update' (NU) service)
void addHistory(const std::string &msg_r)
Add some message text to the history.
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r prefixed with root_r, unless it is already prefixed.
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
Pathname packagesPath(const RepoInfo &info) const
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
void setFilepath(const Pathname &filename)
set the path to the .repo file
void cleanCache(const RepoInfo &info, OPT_PROGRESS)
static const RepoType NONE
RepoSet::size_type RepoSizeType
ServiceSizeType serviceSize() const
RepoInfo getRepo(const std::string &alias) const
int unlink(const Pathname &path)
Like 'unlink'.
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Writes ServiceInfo to stream in ".service" format.
void addRepository(const RepoInfo &info, OPT_PROGRESS)
Date lrf() const
Date of last refresh (if known).
ServiceSet::size_type ServiceSizeType
void loadFromCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Load resolvables into the pool.
void loadFromCache(const RepoInfo &info, OPT_PROGRESS)
thrown when it was impossible to match a repository
void name(const std::string &name_r)
Set counter name.
Service without alias was used in an operation.
void removeRepository(const RepoInfo &info, OPT_PROGRESS)
RepoInfo getRepositoryInfo(const std::string &alias, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Find a matching repository info.
RepoManager(const RepoManagerOptions &options=RepoManagerOptions())
std::string generateFilename(const RepoInfo &info) const
const RepoSet & repos() const
repo::RepoType probeCache(const Pathname &path_r) const
Probe Metadata in a local cache directory.
Date::Duration ttl() const
Sugested TTL between two metadata auto-refreshs.
static const RepoType YAST2
thrown when it was impossible to determine an alias for this repo.
RepoManagerOptions _options
RepoSizeType repoSize() const
ServiceSizeType serviceSize() const
Gets count of service in RepoManager (in specified location)
Thrown when the repo alias is found to be invalid.
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
void addService(const ServiceInfo &service)
ServiceConstIterator serviceBegin() const
Iterator to first service in internal storage.
std::vector< std::string > Arguments
static std::string makeStupidAlias(const Url &url_r=Url())
Some stupid string but suitable as alias for your url if nothing better is available.
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
void refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
std::string asUserString() const
Translated error message as string suitable for the user.
void remember(const Exception &old_r)
Store an other Exception as history.
std::ostream & operator<<(std::ostream &str, const DeltaCandidates &obj)
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
RepoInfo getRepo(const std::string &alias) const
Find RepoInfo by alias or return RepoInfo::noRepo.
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Wrapper class for ::stat/::lstat.
bool repoToEnableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToEnable.
static const SolvAttr repositoryToolVersion
Pathname repoSolvCachePath
bool reposToDisableEmpty() const
void cleanCacheDirGarbage(OPT_PROGRESS)
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Provide a new empty temporary directory and recursively delete it when no longer needed.
void setType(const repo::RepoType &t)
set the repository type
RepoInfo getRepositoryInfo(const std::string &alias, OPT_PROGRESS)
const char * c_str() const
String representation.
void cleanMetadata(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local metadata.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Writing the zypp history file.
RepoStatus status(MediaSetAccess &media)
Status of the remote repository.
std::string alias() const
unique identifier for this source.
Repository type enumeration.
RepoManagerOptions(const Pathname &root_r=Pathname())
Default ctor following ZConfig global settings.
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy)
void touchIndexFile(const RepoInfo &info)
bool serviceEmpty() const
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refresh specific service.
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 addRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds a repository to the list of known repositories.
Pathname metadataPath(const RepoInfo &info) const
Path where the metadata is downloaded and kept.
RepoConstIterator repoBegin() const
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
void delRepoToEnable(const std::string &alias_r)
Remove alias_r from the set of ReposToEnable.
Repository already exists and some unique attribute can't be duplicated.
static ZConfig & instance()
Singleton ctor.
RepoConstIterator repoBegin() const
static const ServiceType PLUGIN
Plugin services are scripts installed on your system that provide the package manager with repositori...
bool hasRepo(const std::string &alias) const
Easy-to use interface to the ZYPP dependency resolver.
repo::RepoType probe(const Url &url, const Pathname &path=Pathname()) const
Probe the metadata type of a repository located at url.
std::string numstring(char n, int w=0)
std::string asCompleteString() const
Returns a complete string representation of the Url object.
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Url rawUrl() const
The service raw url (no variables replaced)
repo::RepoType probe(const Url &url, const Pathname &path) const
Probe repo metadata type.
bool hasService(const std::string &alias) const
Impl(const RepoManagerOptions &opt)
std::string label() const
Label for use in messages for the user interface.
std::string digest()
get hex string representation of the digest
void modifyService(const std::string &oldAlias, const ServiceInfo &newService)
Lightweight repository attribute value lookup.
ServiceInfo getService(const std::string &alias) const
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
static const RepoType RPMMD
static RepoManagerOptions makeTestSetup(const Pathname &root_r)
Test setup adjusting all paths to be located below one root_r directory.
int close()
Wait for the progamm to complete.
const std::string & asString() const
Return current Pathname as String.
void addRepositories(const Url &url, OPT_PROGRESS)
Pathname filepath() const
File where this repo was read from.
ServiceConstIterator serviceEnd() const
Iterator to place behind last service in internal storage.
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects.
thrown when it was impossible to determine one url for this repo.
Service has no or invalid url defined.
ServiceConstIterator serviceEnd() const
repo::ServiceType probeService(const Url &url) const
Read service data from a .service file.
RepoManager implementation.
void init_knownRepositories()
RepoSizeType repoSize() const
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
RepoStatus metadataStatus(const RepoInfo &info) const
Status of local metadata.
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
static const RepoType RPMPLAINDIR
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
std::string receiveLine()
Read one line from the input stream.
ServiceConstIterator serviceBegin() const
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
repo::ServiceType type() const
Service type.
repo::ServiceType probeService(const Url &url) const
Probe the type or the service.
void setProbedType(const repo::ServiceType &t) const
Lazy init service type.
RepoStatus cacheStatus(const RepoInfo &info) const
Status of metadata cache.
The repository cache is not built yet so you can't create the repostories from the cache.
static const ServiceType NONE
No service set.
Date timestamp() const
The time the data were changed the last time.
void cleanCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
clean local cache
bool hasService(const std::string &alias) const
Return whether there is a known service for alias.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
bool isCached(const RepoInfo &info) const
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Pathname repoRawCachePath
Url url() const
Pars pro toto: The first repository url.
Pathname dirname() const
Return all but the last component od this path.
Store and operate on date (time_t).
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
bool serviceEmpty() const
Gets true if no service is in RepoManager (so no one in specified location)
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
bool toMax()
Set counter value to current max value (unless no range).
void clearReposToDisable()
Clear the set of ReposToDisable.
void cleanPackages(const RepoInfo &info, OPT_PROGRESS)
RepoConstIterator repoEnd() const
url_set baseUrls() const
The complete set of repository urls.
void addRepositories(const Url &url, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds repositores from a repo file to the list of known repositories.
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
bool empty() const
Test for an empty path.
void buildCache(const RepoInfo &info, CacheBuildPolicy policy, OPT_PROGRESS)
void eraseFromPool()
Remove this Repository from it's Pool.
static Date now()
Return the current time.
void removeService(const ServiceInfo &service)
void modifyRepository(const std::string &alias, const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Modify repository attributes.
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
void removeService(const std::string &alias)
void setCacheStatus(const RepoInfo &info, const RepoStatus &status)
Service plugin is immutable.
Base Exception for service handling.
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
Repository addRepoSolv(const Pathname &file_r, const std::string &name_r)
Load Solvables from a solv-file into a Repository named name_r.
bool toMin()
Set counter value to current min value.
Progress callback from another progress.
ServiceInfo getService(const std::string &alias) const
Finds ServiceInfo by alias or return ServiceInfo::noService.
std::string basename() const
Return the last component of this path.
scoped_ptr< media::CredentialManager > _cmPtr
Thrown when the repo alias is found to be invalid.
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
Exception for repository handling.
void removeRepository(const RepoInfo &repo)
Log recently removed repository.
String related utilities and Regular expression matching.
void setAlias(const std::string &alias)
set the repository alias
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
void resetDispose()
Set no dispose function.
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
void addService(const std::string &alias, const Url &url)
Adds new service by it's alias and url.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Url::asString() view options.
void setRepoStates(RepoStates newStates_r)
Remember a new set of repository states.
void addService(const std::string &alias, const Url &url)
void init_knownServices()
const std::string & asString() const
String representation.
void modifyRepository(const RepoInfo &oldrepo, const RepoInfo &newrepo)
Log certain modifications to a repository.
std::ostream & operator<<(std::ostream &str, const RepoManager::Impl &obj)
bool hasRepo(const std::string &alias) const
Return whether there is a known repository for alias.
unsigned repo_refresh_delay() const
Amount of time in minutes that must pass before another refresh.
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy=RefreshIfNeeded)
Checks whether to refresh metadata for specified repository and url.
Pathname repoPackagesCachePath
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
creates and provides information about known sources.
void saveService(ServiceInfo &service) const
void refreshServices(const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refreshes all enabled services.
void modifyService(const std::string &oldAlias, const ServiceInfo &service)
Modifies service file (rewrites it with new values) and underlying repositories if needed.
repo::RepoType type() const
Type of repository,.
Maintain [min,max] and counter (value) for progress counting.
void addRepository(const RepoInfo &repo)
Log a newly added repository.
RepoConstIterator repoEnd() const
Pathname metadataPath(const RepoInfo &info) const
static bool error(const std::string &msg_r, const UserData &userData_r=UserData())
send error text
Pathname path() const
Repository path.
urls_size_type baseUrlsSize() const
number of repository urls
void modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, OPT_PROGRESS)
const std::string & command() const
The command we're executing.
void cleanMetadata(const RepoInfo &info, OPT_PROGRESS)