21 #include <solv/solvversion.h> 61 #define OPT_PROGRESS const ProgressData::ReceiverFnc & = ProgressData::ReceiverFnc() 90 class UrlCredentialExtractor
93 UrlCredentialExtractor( Pathname & root_r )
97 ~UrlCredentialExtractor()
101 bool collect(
const Url & url_r )
103 bool ret = url_r.hasCredentialsInAuthority();
107 _cmPtr->addUserCred( url_r );
112 template<
class TContainer>
113 bool collect(
const TContainer & urls_r )
114 {
bool ret =
false;
for (
const Url &
url : urls_r ) {
if ( collect(
url ) && !ret ) ret =
true; }
return ret; }
117 bool extract( Url & url_r )
119 bool ret = collect( url_r );
121 url_r.setPassword( std::string() );
125 template<
class TContainer>
126 bool extract( TContainer & urls_r )
127 {
bool ret =
false;
for ( Url &
url : urls_r ) {
if ( extract(
url ) && !ret ) ret =
true; }
return ret; }
131 scoped_ptr<media::CredentialManager>
_cmPtr;
146 MediaMounter(
const Url & url_r )
148 media::MediaManager mediamanager;
149 _mid = mediamanager.open( url_r );
150 mediamanager.attach(
_mid );
156 media::MediaManager mediamanager;
157 mediamanager.release(
_mid );
158 mediamanager.close(
_mid );
165 Pathname getPathName(
const Pathname & path_r = Pathname() )
const 167 media::MediaManager mediamanager;
168 return mediamanager.localPath(
_mid, path_r );
177 template <
class Iterator>
178 inline bool foundAliasIn(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
180 for_( it, begin_r, end_r )
181 if ( it->alias() == alias_r )
186 template <
class Container>
187 inline bool foundAliasIn(
const std::string & alias_r,
const Container & cont_r )
188 {
return foundAliasIn( alias_r, cont_r.begin(), cont_r.end() ); }
191 template <
class Iterator>
192 inline Iterator findAlias(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
194 for_( it, begin_r, end_r )
195 if ( it->alias() == alias_r )
200 template <
class Container>
201 inline typename Container::iterator findAlias(
const std::string & alias_r, Container & cont_r )
202 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
204 template <
class Container>
205 inline typename Container::const_iterator findAlias(
const std::string & alias_r,
const Container & cont_r )
206 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
210 inline std::string filenameFromAlias(
const std::string & alias_r,
const std::string & stem_r )
212 std::string filename( alias_r );
216 filename = Pathname(filename).extend(
"."+stem_r).asString();
217 MIL <<
"generating filename for " << stem_r <<
" [" << alias_r <<
"] : '" << filename <<
"'" << endl;
241 RepoCollector(
const std::string & targetDistro_)
245 bool collect(
const RepoInfo &repo )
249 && !repo.targetDistribution().empty()
253 <<
"Skipping repository meant for '" << repo.targetDistribution()
254 <<
"' distribution (current distro is '" 260 repos.push_back(repo);
274 std::list<RepoInfo> repositories_in_file(
const Pathname & file )
276 MIL <<
"repo file: " << file << endl;
277 RepoCollector collector;
278 parser::RepoFileReader parser( file, bind( &RepoCollector::collect, &collector, _1 ) );
279 return std::move(collector.repos);
292 std::list<RepoInfo> repositories_in_dir(
const Pathname &dir )
294 MIL <<
"directory " << dir << endl;
295 std::list<RepoInfo>
repos;
296 bool nonroot( geteuid() != 0 );
297 if ( nonroot && ! PathInfo(dir).userMayRX() )
299 JobReport::warning( str::FormatNAC(
_(
"Cannot read repo directory '%1%': Permission denied")) % dir );
303 std::list<Pathname> entries;
310 str::regex allowedRepoExt(
"^\\.repo(_[0-9]+)?$");
311 for ( std::list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
315 if ( nonroot && ! PathInfo(*it).userMayR() )
317 JobReport::warning( str::FormatNAC(
_(
"Cannot read repo file '%1%': Permission denied")) % *it );
321 const std::list<RepoInfo> & tmp( repositories_in_file( *it ) );
322 repos.insert( repos.end(), tmp.begin(), tmp.end() );
332 inline void assert_alias(
const RepoInfo & info )
334 if ( info.alias().empty() )
338 if ( info.alias()[0] ==
'.')
340 info,
_(
"Repository alias cannot start with dot.")));
343 inline void assert_alias(
const ServiceInfo & info )
345 if ( info.alias().empty() )
349 if ( info.alias()[0] ==
'.')
351 info,
_(
"Service alias cannot start with dot.")));
356 inline void assert_urls(
const RepoInfo & info )
358 if ( info.baseUrlsEmpty() )
362 inline void assert_url(
const ServiceInfo & info )
364 if ( ! info.url().isValid() )
374 inline Pathname rawcache_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
377 return opt.repoRawCachePath / info.escaped_alias();
388 inline Pathname rawproductdata_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
391 return opt.repoRawCachePath / info.escaped_alias() / info.path();
397 inline Pathname packagescache_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
400 return opt.repoPackagesCachePath / info.escaped_alias();
406 inline Pathname solv_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info)
409 return opt.repoSolvCachePath / info.escaped_alias();
415 class ServiceCollector
418 typedef std::set<ServiceInfo> ServiceSet;
420 ServiceCollector( ServiceSet & services_r )
424 bool operator()(
const ServiceInfo & service_r )
const 448 DBG <<
"reading repo file " << repo_file <<
", local path: " << local << endl;
450 return repositories_in_file(local);
489 #define OUTS(X) str << " " #X "\t" << obj.X << endl 490 str <<
"RepoManagerOptions (" << obj.
rootDir <<
") {" << endl;
491 OUTS( repoRawCachePath );
492 OUTS( repoSolvCachePath );
493 OUTS( repoPackagesCachePath );
494 OUTS( knownReposPath );
495 OUTS( knownServicesPath );
513 init_knownServices();
514 init_knownRepositories();
520 if ( _reposDirty && geteuid() == 0 && ( _options.rootDir.empty() || _options.rootDir ==
"/" ) )
523 std::list<Pathname> entries;
525 if ( ! entries.empty() )
528 cmd.push_back(
"<" );
529 cmd.push_back(
">" );
530 cmd.push_back(
"PROGRAM" );
531 for (
const auto & rinfo :
repos() )
533 if ( ! rinfo.enabled() )
535 cmd.push_back(
"-R" );
536 cmd.push_back( rinfo.alias() );
537 cmd.push_back(
"-t" );
538 cmd.push_back( rinfo.type().asString() );
539 cmd.push_back(
"-p" );
540 cmd.push_back( rinfo.metadataPath().asString() );
543 for_( it, entries.begin(), entries.end() )
566 bool hasRepo(
const std::string & alias )
const 567 {
return foundAliasIn( alias,
repos() ); }
577 {
return rawcache_path_for_repoinfo( _options, info ); }
580 {
return packagescache_path_for_repoinfo( _options, info ); }
602 {
return PathInfo(solv_path_for_repoinfo( _options, info ) /
"solv").
isExist(); }
627 {
return foundAliasIn( alias,
_services ); }
640 void removeService(
const std::string & alias );
642 { removeService( service.
alias() ); }
648 { refreshService( service.
alias(), options_r ); }
650 void modifyService(
const std::string & oldAlias,
const ServiceInfo & newService );
657 Pathname generateNonExistingName(
const Pathname & dir,
const std::string & basefilename )
const;
660 {
return filenameFromAlias( info.
alias(),
"repo" ); }
663 {
return filenameFromAlias( info.
alias(),
"service" ); }
667 Pathname base = solv_path_for_repoinfo( _options, info );
672 void touchIndexFile(
const RepoInfo & info );
674 template<
typename OutputIterator>
679 boost::make_filter_iterator( filter,
repos().end(),
repos().end() ),
684 void init_knownServices();
685 void init_knownRepositories();
698 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
701 {
return new Impl( *
this ); }
707 {
return str <<
"RepoManager::Impl"; }
714 Pathname servfile = generateNonExistingName( _options.knownServicesPath,
715 generateFilename( service ) );
718 MIL <<
"saving service in " << servfile << endl;
720 std::ofstream file( servfile.
c_str() );
727 MIL <<
"done" << endl;
746 const std::string & basefilename )
const 748 std::string final_filename = basefilename;
750 while (
PathInfo(dir + final_filename).isExist() )
755 return dir +
Pathname(final_filename);
762 Pathname dir = _options.knownServicesPath;
763 std::list<Pathname> entries;
773 for_(it, entries.begin(), entries.end() )
789 inline void cleanupNonRepoMetadtaFolders(
const Pathname & cachePath_r,
790 const Pathname & defaultCachePath_r,
791 const std::list<std::string> & repoEscAliases_r )
793 if ( cachePath_r != defaultCachePath_r )
796 std::list<std::string> entries;
800 std::set<std::string> oldfiles;
801 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
802 std::inserter( oldfiles, oldfiles.end() ) );
803 for (
const std::string & old : oldfiles )
815 MIL <<
"start construct known repos" << endl;
819 std::list<std::string> repoEscAliases;
820 std::list<RepoInfo> orphanedRepos;
821 for (
RepoInfo & repoInfo : repositories_in_dir(_options.knownReposPath) )
824 repoInfo.setMetadataPath( rawcache_path_for_repoinfo(_options, repoInfo) );
826 repoInfo.setPackagesPath( packagescache_path_for_repoinfo(_options, repoInfo) );
828 _reposX.insert( repoInfo );
831 const std::string & serviceAlias( repoInfo.service() );
832 if ( ! ( serviceAlias.empty() || hasService( serviceAlias ) ) )
834 WAR <<
"Schedule orphaned service repo for deletion: " << repoInfo << endl;
835 orphanedRepos.push_back( repoInfo );
839 repoEscAliases.push_back(repoInfo.escaped_alias());
843 if ( ! orphanedRepos.empty() )
845 for (
const auto & repoInfo : orphanedRepos )
847 MIL <<
"Delete orphaned service repo " << repoInfo.alias() << endl;
853 % repoInfo.alias() );
855 removeRepository( repoInfo );
869 repoEscAliases.sort();
871 cleanupNonRepoMetadtaFolders( _options.repoRawCachePath, defaultCache.
repoRawCachePath, repoEscAliases );
872 cleanupNonRepoMetadtaFolders( _options.repoSolvCachePath, defaultCache.
repoSolvCachePath, repoEscAliases );
873 cleanupNonRepoMetadtaFolders( _options.repoPackagesCachePath, defaultCache.
repoPackagesCachePath, repoEscAliases );
875 MIL <<
"end construct known repos" << endl;
882 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
883 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
888 repokind = probeCache( productdatapath );
891 switch ( repokind.
toEnum() )
894 status =
RepoStatus( productdatapath/
"repodata/repomd.xml") &&
RepoStatus( mediarootpath/
"media.1/media" );
898 status =
RepoStatus( productdatapath/
"content" ) &&
RepoStatus( mediarootpath/
"media.1/media" );
917 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
922 repokind = probeCache( productdatapath );
928 switch ( repokind.
toEnum() )
931 p =
Pathname(productdatapath +
"/repodata/repomd.xml");
935 p =
Pathname(productdatapath +
"/content");
939 p =
Pathname(productdatapath +
"/cookie");
957 MIL <<
"Going to try to check whether refresh is needed for " << url << endl;
960 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
962 RepoStatus oldstatus = metadataStatus( info );
963 if ( oldstatus.
empty() )
965 MIL <<
"No cached metadata, going to refresh" << endl;
966 return REFRESH_NEEDED;
971 MIL <<
"Never refresh CD/DVD" << endl;
972 return REPO_UP_TO_DATE;
975 if ( policy == RefreshForced )
977 MIL <<
"Forced refresh!" << endl;
978 return REFRESH_NEEDED;
983 policy = RefreshIfNeededIgnoreDelay;
987 if ( policy != RefreshIfNeededIgnoreDelay )
990 double diff = difftime(
996 DBG <<
"last refresh = " << diff <<
" minutes ago" << endl;
1002 WAR <<
"Repository '" << info.
alias() <<
"' was refreshed in the future!" << endl;
1006 MIL <<
"Repository '" << info.
alias()
1007 <<
"' has been refreshed less than repo.refresh.delay (" 1009 <<
") minutes ago. Advising to skip refresh" << endl;
1010 return REPO_CHECK_DELAYED;
1018 repokind = probe( url, info.
path() );
1022 switch ( repokind.
toEnum() )
1039 newstatus =
RepoStatus( MediaMounter(url).getPathName(info.
path()) );
1049 if ( oldstatus == newstatus )
1051 MIL <<
"repo has not changed" << endl;
1052 touchIndexFile( info );
1053 return REPO_UP_TO_DATE;
1057 MIL <<
"repo has changed, going to refresh" << endl;
1058 return REFRESH_NEEDED;
1064 ERR <<
"refresh check failed for " << url << endl;
1068 return REFRESH_NEEDED;
1078 RepoException rexception( info,
PL_(
"Valid metadata not found at specified URL",
1079 "Valid metadata not found at specified URLs",
1094 if (checkIfToRefreshMetadata(info, url, policy)!=REFRESH_NEEDED)
1097 MIL <<
"Going to refresh metadata from " << url << endl;
1105 repokind = probe( *it, info.
path() );
1112 for_( it, repoBegin(), repoEnd() )
1114 if ( info.
alias() == (*it).alias() )
1117 modifiedrepo.
setType( repokind );
1118 modifyRepository( info.
alias(), modifiedrepo );
1125 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1136 Exception ex(
_(
"Can't create metadata cache directory."));
1144 shared_ptr<repo::Downloader> downloader_ptr;
1146 MIL <<
"Creating downloader for [ " << info.
alias() <<
" ]" << endl;
1159 for_( it, repoBegin(), repoEnd() )
1161 Pathname cachepath(rawcache_path_for_repoinfo( _options, *it ));
1162 if (
PathInfo(cachepath).isExist() )
1163 downloader_ptr->addCachePath(cachepath);
1166 downloader_ptr->download( media, tmpdir.
path() );
1170 MediaMounter media( url );
1193 ERR <<
"Trying another url..." << endl;
1205 ERR <<
"No more urls..." << endl;
1214 progress.
sendTo(progressfnc);
1224 progress.
sendTo(progressfnc);
1234 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1235 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
1242 RepoStatus raw_metadata_status = metadataStatus(info);
1243 if ( raw_metadata_status.
empty() )
1248 refreshMetadata(info, RefreshIfNeeded, progressrcv );
1249 raw_metadata_status = metadataStatus(info);
1252 bool needs_cleaning =
false;
1253 if ( isCached( info ) )
1255 MIL << info.
alias() <<
" is already cached." << endl;
1258 if ( cache_status == raw_metadata_status )
1260 MIL << info.
alias() <<
" cache is up to date with metadata." << endl;
1261 if ( policy == BuildIfNeeded )
1264 const Pathname & base = solv_path_for_repoinfo( _options, info);
1265 if ( !
PathInfo(base/
"solv.idx").isExist() )
1271 MIL << info.
alias() <<
" cache rebuild is forced" << endl;
1275 needs_cleaning =
true;
1289 MIL << info.
alias() <<
" building cache..." << info.
type() << endl;
1291 Pathname base = solv_path_for_repoinfo( _options, info);
1310 switch ( repokind.
toEnum() )
1314 repokind = probeCache( productdatapath );
1320 MIL <<
"repo type is " << repokind << endl;
1322 switch ( repokind.
toEnum() )
1330 scoped_ptr<MediaMounter> forPlainDirs;
1333 cmd.push_back(
PathInfo(
"/usr/bin/repo2solv" ).isFile() ?
"repo2solv" :
"repo2solv.sh" );
1335 cmd.push_back(
"-o" );
1336 cmd.push_back( solvfile.
asString() );
1337 cmd.push_back(
"-X" );
1341 forPlainDirs.reset(
new MediaMounter( *info.
baseUrlsBegin() ) );
1343 cmd.push_back(
"-R" );
1345 cmd.push_back( forPlainDirs->getPathName( info.
path() ).c_str() );
1348 cmd.push_back( productdatapath.
asString() );
1351 std::string errdetail;
1354 WAR <<
" " << output;
1355 if ( errdetail.empty() ) {
1359 errdetail += output;
1362 int ret = prog.
close();
1380 setCacheStatus(info, raw_metadata_status);
1381 MIL <<
"Commit cache.." << endl;
1396 MIL <<
"going to probe the repo type at " << url <<
" (" << path <<
")" << endl;
1402 MIL <<
"Probed type NONE (not exists) at " << url <<
" (" << path <<
")" << endl;
1414 bool gotMediaException =
false;
1422 MIL <<
"Probed type RPMMD at " << url <<
" (" << path <<
")" << endl;
1429 DBG <<
"problem checking for repodata/repomd.xml file" << endl;
1431 gotMediaException =
true;
1438 MIL <<
"Probed type YAST2 at " << url <<
" (" << path <<
")" << endl;
1445 DBG <<
"problem checking for content file" << endl;
1447 gotMediaException =
true;
1453 MediaMounter media( url );
1454 if (
PathInfo(media.getPathName()/path).isDir() )
1457 MIL <<
"Probed type RPMPLAINDIR at " << url <<
" (" << path <<
")" << endl;
1471 if (gotMediaException)
1474 MIL <<
"Probed type NONE at " << url <<
" (" << path <<
")" << endl;
1485 MIL <<
"going to probe the cached repo at " << path_r << endl;
1489 if (
PathInfo(path_r/
"/repodata/repomd.xml").isFile() )
1491 else if (
PathInfo(path_r/
"/content").isFile() )
1493 else if (
PathInfo(path_r).isDir() )
1496 MIL <<
"Probed cached type " << ret <<
" at " << path_r << endl;
1504 MIL <<
"Going to clean up garbage in cache dirs" << endl;
1507 progress.
sendTo(progressrcv);
1510 std::list<Pathname> cachedirs;
1511 cachedirs.push_back(_options.repoRawCachePath);
1512 cachedirs.push_back(_options.repoPackagesCachePath);
1513 cachedirs.push_back(_options.repoSolvCachePath);
1515 for_( dir, cachedirs.begin(), cachedirs.end() )
1519 std::list<Pathname> entries;
1524 unsigned sdircount = entries.size();
1525 unsigned sdircurrent = 1;
1526 for_( subdir, entries.begin(), entries.end() )
1530 for_( r, repoBegin(), repoEnd() )
1531 if ( subdir->basename() == r->escaped_alias() )
1532 { found =
true;
break; }
1537 progress.
set( progress.
val() + sdircurrent * 100 / sdircount );
1542 progress.
set( progress.
val() + 100 );
1552 progress.
sendTo(progressrcv);
1555 MIL <<
"Removing raw metadata cache for " << info.
alias() << endl;
1566 Pathname solvfile = solv_path_for_repoinfo(_options, info) /
"solv";
1568 if ( !
PathInfo(solvfile).isExist() )
1578 if ( toolversion != LIBSOLV_TOOLVERSION )
1587 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1588 cleanCache( info, progressrcv );
1589 buildCache( info, BuildIfNeeded, progressrcv );
1607 MIL <<
"Try adding repo " << info << endl;
1614 if ( _options.probe )
1616 DBG <<
"unknown repository type, probing" << endl;
1634 Pathname repofile = generateNonExistingName(
1635 _options.knownReposPath, generateFilename(tosave));
1637 MIL <<
"Saving repo in " << repofile << endl;
1639 std::ofstream file(repofile.
c_str());
1653 RepoInfo & oinfo( const_cast<RepoInfo &>(info) );
1657 reposManip().insert(tosave);
1662 UrlCredentialExtractor( _options.rootDir ).collect( tosave.
baseUrls() );
1667 MIL <<
"done" << endl;
1674 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
1679 for_ ( kit, repoBegin(), repoEnd() )
1681 if ( (*it).alias() == (*kit).alias() )
1683 ERR <<
"To be added repo " << (*it).alias() <<
" conflicts with existing repo " << (*kit).alias() << endl;
1700 Pathname repofile = generateNonExistingName(_options.knownReposPath, filename);
1702 MIL <<
"Saving " << repos.size() <<
" repo" << ( repos.size() ?
"s" :
"" ) <<
" in " << repofile << endl;
1704 std::ofstream file(repofile.
c_str());
1711 for ( std::list<RepoInfo>::iterator it = repos.begin();
1715 MIL <<
"Saving " << (*it).alias() << endl;
1716 it->setFilepath(repofile.
asString());
1717 it->dumpAsIniOn(file);
1718 reposManip().insert(*it);
1723 MIL <<
"done" << endl;
1735 MIL <<
"Going to delete repo " << info.
alias() << endl;
1737 for_( it, repoBegin(), repoEnd() )
1742 if ( (!info.
alias().empty()) && ( info.
alias() != (*it).alias() ) )
1757 std::list<RepoInfo> filerepos = repositories_in_file(todelete.
filepath());
1758 if ( filerepos.size() == 0
1759 ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.
alias() ) )
1763 if ( ! ( ret == 0 || ret == ENOENT ) )
1768 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1786 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1787 fit != filerepos.end();
1790 if ( (*fit).alias() != todelete.
alias() )
1791 (*fit).dumpAsIniOn(file);
1799 if ( isCached(todelete) )
1800 cleanCache( todelete, cSubprogrcv);
1802 cleanMetadata( todelete, mSubprogrcv );
1803 cleanPackages( todelete, pSubprogrcv );
1804 reposManip().erase(todelete);
1805 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1819 RepoInfo toedit = getRepositoryInfo(alias);
1823 if ( alias != newinfo.
alias() && hasRepo( newinfo.
alias() ) )
1835 std::list<RepoInfo> filerepos = repositories_in_file(toedit.
filepath());
1851 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1852 fit != filerepos.end();
1857 if ( (*fit).alias() != toedit.
alias() )
1858 (*fit).dumpAsIniOn(file);
1866 const Pathname & solvidx = solv_path_for_repoinfo(_options, newinfo)/
"solv.idx";
1872 reposManip().erase(toedit);
1873 reposManip().insert(newinfo);
1875 UrlCredentialExtractor( _options.rootDir ).collect( newinfo.
baseUrls() );
1877 MIL <<
"repo " << alias <<
" modified" << endl;
1886 if ( it !=
repos().end() )
1896 for_( it, repoBegin(), repoEnd() )
1898 for_( urlit, (*it).baseUrlsBegin(), (*it).baseUrlsEnd() )
1900 if ( (*urlit).asString(urlview) == url.
asString(urlview) )
1917 assert_alias( service );
1920 if ( hasService( service.
alias() ) )
1926 saveService( toSave );
1930 UrlCredentialExtractor( _options.rootDir ).collect( toSave.
url() );
1932 MIL <<
"added service " << toSave.
alias() << endl;
1939 MIL <<
"Going to delete service " << alias << endl;
1941 const ServiceInfo & service = getService( alias );
1944 if( location.
empty() )
1953 if ( tmpSet.size() == 1 )
1960 MIL << alias <<
" successfully deleted." << endl;
1966 std::ofstream file(location.
c_str());
1973 for_(it, tmpSet.begin(), tmpSet.end())
1975 if( it->alias() != alias )
1976 it->dumpAsIniOn(file);
1979 MIL << alias <<
" successfully deleted from file " << location << endl;
1983 RepoCollector rcollector;
1984 getRepositoriesInService( alias,
1985 boost::make_function_output_iterator( bind( &RepoCollector::collect, &rcollector, _1 ) ) );
1987 for_(rit, rcollector.repos.begin(), rcollector.repos.end())
1988 removeRepository(*rit);
1997 ServiceSet services( serviceBegin(), serviceEnd() );
1998 for_( it, services.begin(), services.end() )
2000 if ( !it->enabled() )
2004 refreshService(*it, options_r);
2014 assert_alias( service );
2015 assert_url( service );
2016 MIL <<
"Going to refresh service '" << service.
alias() <<
"', url: " << service.
url() <<
", opts: " << options_r << endl;
2018 if ( service.
ttl() && !( options_r.testFlag( RefreshService_forceRefresh) || options_r.testFlag( RefreshService_restoreStatus ) ) )
2027 if ( (lrf+=service.
ttl()) > now )
2029 MIL <<
"Skip: '" << service.
alias() <<
"' metadata valid until " << lrf << endl;
2034 WAR <<
"Force: '" << service.
alias() <<
"' metadata last refresh in the future: " << lrf << endl;
2041 bool serviceModified =
false;
2052 serviceModified =
true;
2057 std::string servicesTargetDistro = _options.servicesTargetDistro;
2058 if ( servicesTargetDistro.empty() )
2062 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << endl;
2066 RepoCollector collector(servicesTargetDistro);
2073 ServiceRepos( service, bind( &RepoCollector::collect, &collector, _1 ) );
2078 uglyHack.first =
true;
2079 uglyHack.second = e;
2081 if ( service.
ttl() != origTtl )
2083 if ( !service.
ttl() )
2085 serviceModified =
true;
2093 for_( it, collector.repos.begin(), collector.repos.end() )
2096 it->setAlias(
str::form(
"%s:%s", service.
alias().c_str(), it->alias().c_str() ) );
2098 it->setService( service.
alias() );
2101 newRepoStates[it->alias()] = *it;
2109 if ( !it->path().empty() )
2111 if ( it->path() !=
"/" )
2116 if ( it->baseUrlsEmpty() )
2119 if ( !path.
empty() )
2121 it->setBaseUrl( std::move(url) );
2123 else if ( !path.
empty() )
2126 for (
Url & url : urls )
2130 it->setBaseUrls( std::move(urls) );
2137 RepoInfoList oldRepos;
2138 getRepositoriesInService( service.
alias(), std::back_inserter( oldRepos ) );
2142 for_( oldRepo, oldRepos.begin(), oldRepos.end() )
2144 if ( ! foundAliasIn( oldRepo->alias(), collector.repos ) )
2146 if ( oldRepo->enabled() )
2149 const auto & last = service.
repoStates().find( oldRepo->alias() );
2150 if ( last != service.
repoStates().end() && ! last->second.enabled )
2152 DBG <<
"Service removes user enabled repo " << oldRepo->alias() << endl;
2154 serviceModified =
true;
2157 DBG <<
"Service removes enabled repo " << oldRepo->alias() << endl;
2160 DBG <<
"Service removes disabled repo " << oldRepo->alias() << endl;
2162 removeRepository( *oldRepo );
2168 UrlCredentialExtractor urlCredentialExtractor( _options.rootDir );
2169 for_( it, collector.repos.begin(), collector.repos.end() )
2175 TriBool toBeEnabled( indeterminate );
2176 DBG <<
"Service request to " << (it->enabled()?
"enable":
"disable") <<
" service repo " << it->alias() << endl;
2178 if ( options_r.testFlag( RefreshService_restoreStatus ) )
2180 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() << endl;
2192 DBG <<
"User request to enable service repo " << it->alias() << endl;
2198 serviceModified =
true;
2202 DBG <<
"User request to disable service repo " << it->alias() << endl;
2203 toBeEnabled =
false;
2207 RepoInfoList::iterator oldRepo( findAlias( it->alias(), oldRepos ) );
2208 if ( oldRepo == oldRepos.end() )
2213 if ( ! indeterminate(toBeEnabled) )
2214 it->setEnabled( toBeEnabled );
2216 DBG <<
"Service adds repo " << it->alias() <<
" " << (it->enabled()?
"enabled":
"disabled") << endl;
2217 addRepository( *it );
2222 bool oldRepoModified =
false;
2224 if ( indeterminate(toBeEnabled) )
2228 if ( oldRepo->enabled() == it->enabled() )
2229 toBeEnabled = it->enabled();
2230 else if (options_r.testFlag( RefreshService_restoreStatus ) )
2232 toBeEnabled = it->enabled();
2233 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() <<
" forces " << (toBeEnabled?
"enabled":
"disabled") << endl;
2237 const auto & last = service.
repoStates().find( oldRepo->alias() );
2238 if ( last == service.
repoStates().end() || last->second.enabled != it->enabled() )
2239 toBeEnabled = it->enabled();
2242 toBeEnabled = oldRepo->enabled();
2243 DBG <<
"User modified service repo " << it->alias() <<
" may stay " << (toBeEnabled?
"enabled":
"disabled") << endl;
2249 if ( toBeEnabled == oldRepo->enabled() )
2251 DBG <<
"Service repo " << it->alias() <<
" stays " << (oldRepo->enabled()?
"enabled":
"disabled") << endl;
2253 else if ( toBeEnabled )
2255 DBG <<
"Service repo " << it->alias() <<
" gets enabled" << endl;
2256 oldRepo->setEnabled(
true );
2257 oldRepoModified =
true;
2261 DBG <<
"Service repo " << it->alias() <<
" gets disabled" << endl;
2262 oldRepo->setEnabled(
false );
2263 oldRepoModified =
true;
2269 if ( oldRepo->rawName() != it->rawName() )
2271 DBG <<
"Service repo " << it->alias() <<
" gets new NAME " << it->rawName() << endl;
2272 oldRepo->setName( it->rawName() );
2273 oldRepoModified =
true;
2277 if ( oldRepo->autorefresh() != it->autorefresh() )
2279 DBG <<
"Service repo " << it->alias() <<
" gets new AUTOREFRESH " << it->autorefresh() << endl;
2280 oldRepo->setAutorefresh( it->autorefresh() );
2281 oldRepoModified =
true;
2285 if ( oldRepo->priority() != it->priority() )
2287 DBG <<
"Service repo " << it->alias() <<
" gets new PRIORITY " << it->priority() << endl;
2288 oldRepo->setPriority( it->priority() );
2289 oldRepoModified =
true;
2295 urlCredentialExtractor.extract( newUrls );
2296 if ( oldRepo->rawBaseUrls() != newUrls )
2298 DBG <<
"Service repo " << it->alias() <<
" gets new URLs " << newUrls << endl;
2299 oldRepo->setBaseUrls( std::move(newUrls) );
2300 oldRepoModified =
true;
2310 oldRepo->getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
2311 it-> getRawGpgChecks( ngpg[0], ngpg[1], ngpg[2] );
2312 #define Z_CHKGPG(I,N) \ 2313 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \ 2315 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \ 2316 oldRepo->set##N##Check( ngpg[I] ); \ 2317 oldRepoModified = true; \ 2326 if ( oldRepoModified )
2328 modifyRepository( oldRepo->alias(), *oldRepo );
2337 serviceModified =
true;
2344 serviceModified =
true;
2351 if ( service.
ttl() )
2354 serviceModified =
true;
2357 if ( serviceModified )
2360 modifyService( service.
alias(), service );
2364 if ( uglyHack.first )
2366 throw( uglyHack.second );
2374 MIL <<
"Going to modify service " << oldAlias << endl;
2385 const ServiceInfo & oldService = getService(oldAlias);
2388 if( location.
empty() )
2398 std::ofstream file(location.
c_str());
2399 for_(it, tmpSet.begin(), tmpSet.end())
2401 if( *it != oldAlias )
2402 it->dumpAsIniOn(file);
2411 UrlCredentialExtractor( _options.rootDir ).collect( service.
url() );
2415 if ( oldAlias != service.
alias()
2418 std::vector<RepoInfo> toModify;
2419 getRepositoriesInService(oldAlias, std::back_inserter(toModify));
2420 for_( it, toModify.begin(), toModify.end() )
2427 const auto & last = service.
repoStates().find( it->alias() );
2429 it->setEnabled( last->second.enabled );
2432 it->setEnabled(
false );
2435 if ( oldAlias != service.
alias() )
2436 it->setService(service.
alias());
2438 modifyRepository(it->alias(), *it);
2482 : _pimpl( new
Impl(opt) )
2514 std::string host( url_r.
getHost() );
2515 if ( ! host.empty() )
2637 {
return str << *obj.
_pimpl; }
std::string getScheme() const
Returns the scheme name of the URL.
RepoManager(const RepoManagerOptions &options=RepoManagerOptions())
Pathname filepath() const
File where this repo was read from.
static const ValueType day
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
void removeService(const std::string &alias)
Removes service specified by its name.
Pathname path() const
Repository path.
RepoStatus cacheStatus(const RepoInfo &info) const
thrown when it was impossible to match a repository
Thrown when the repo alias is found to be invalid.
std::string targetDistribution() const
This is register.target attribute of the installed base product.
RepoManagerOptions(const Pathname &root_r=Pathname())
Default ctor following ZConfig global settings.
const std::string & command() const
The command we're executing.
bool empty() const
Whether the status is empty (default constucted)
static const std::string & sha1()
sha1
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
static bool error(const std::string &msg_r, const UserData &userData_r=UserData())
send error text
RepoStatus status(MediaSetAccess &media)
Status of the remote repository.
RepoConstIterator repoEnd() const
void setCacheStatus(const RepoInfo &info, const RepoStatus &status)
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.
void refreshServices(const RefreshServiceOptions &options_r)
Pathname repoRawCachePath
RepoStatus cacheStatus(const RepoInfo &info) const
Status of metadata cache.
bool hasRepo(const std::string &alias) const
Return whether there is a known repository for alias.
void modifyService(const std::string &oldAlias, const ServiceInfo &service)
Modifies service file (rewrites it with new values) and underlying repositories if needed...
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
Read service data from a .service file.
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
ServiceConstIterator serviceBegin() const
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
ServiceInfo getService(const std::string &alias) const
Finds ServiceInfo by alias or return ServiceInfo::noService.
static ZConfig & instance()
Singleton ctor.
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects...
scoped_ptr< media::CredentialManager > _cmPtr
Date lrf() const
Date of last refresh (if known).
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
repo::RepoType probeCache(const Pathname &path_r) const
Probe Metadata in a local cache directory.
RepoStatus metadataStatus(const RepoInfo &info) const
void cleanCacheDirGarbage(const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove any subdirectories of cache directories which no longer belong to any of known repositories...
bool hasService(const std::string &alias) const
Return whether there is a known service for alias.
const RepoSet & repos() const
void refreshServices(const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refreshes all enabled services.
Service plugin is immutable.
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
Url rawUrl() const
The service raw url (no variables replaced)
RepoSet::size_type RepoSizeType
void loadFromCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Load resolvables into the pool.
bool repo_add_probe() const
Whether repository urls should be probed.
repo::ServiceType probeService(const Url &url) const
const char * c_str() const
String representation.
void addHistory(const std::string &msg_r)
Add some message text to the history.
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy=RefreshIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local raw cache.
void addService(const std::string &alias, const Url &url)
void touchIndexFile(const RepoInfo &info)
void setAlias(const std::string &alias)
set the repository alias
void init_knownRepositories()
String related utilities and Regular expression matching.
void addRepoToEnable(const std::string &alias_r)
Add alias_r to the set of ReposToEnable.
void removeRepository(const RepoInfo &info, OPT_PROGRESS)
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
void modifyService(const std::string &oldAlias, const ServiceInfo &newService)
bool toMax()
Set counter value to current max value (unless no range).
bool serviceEmpty() const
Gets true if no service is in RepoManager (so no one in specified location)
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refresh specific service.
void setFilepath(const Pathname &filename)
set the path to the .repo file
What is known about a repository.
bool isCached(const RepoInfo &info) const
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
void removeRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove the best matching repository from known repos list.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Pathname knownServicesPath
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
ServiceConstIterator serviceEnd() const
Iterator to place behind last service in internal storage.
void reposErase(const std::string &alias_r)
Remove a Repository named alias_r.
Service already exists and some unique attribute can't be duplicated.
void refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
repo::ServiceType probeService(const Url &url) const
Probe the type or the service.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
void setProbedType(const repo::ServiceType &t) const
Lazy init service type.
Service without alias was used in an operation.
RepoSet::const_iterator RepoConstIterator
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
RepoConstIterator repoBegin() const
Url::asString() view options.
Pathname metadataPath(const RepoInfo &info) const
Path where the metadata is downloaded and kept.
void cleanMetadata(const RepoInfo &info, OPT_PROGRESS)
#define PL_(MSG1, MSG2, N)
void modifyRepository(const std::string &alias, const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Modify repository attributes.
Pathname repoSolvCachePath
std::vector< std::string > Arguments
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
RepoManagerOptions _options
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
void remember(const Exception &old_r)
Store an other Exception as history.
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 removeService(const ServiceInfo &service)
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Progress callback from another progress.
std::map< std::string, RepoState > RepoStates
void addRepository(const RepoInfo &info, OPT_PROGRESS)
bool repoToEnableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToEnable.
static const ServiceType RIS
Repository Index Service (RIS) (formerly known as 'Novell Update' (NU) service)
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
RepoStatus metadataStatus(const RepoInfo &info) const
Status of local metadata.
RepoManager implementation.
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.
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
bool toMin()
Set counter value to current min value.
RepoInfo getRepositoryInfo(const std::string &alias, OPT_PROGRESS)
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
RepoConstIterator repoBegin() const
Store and operate on date (time_t).
std::string asString() const
Returns a default string representation of the Url object.
static Pool instance()
Singleton ctor.
ServiceSizeType serviceSize() const
static RepoManagerOptions makeTestSetup(const Pathname &root_r)
Test setup adjusting all paths to be located below one root_r directory.
Pathname rootDir
remembers root_r value for later use
Pathname packagesPath(const RepoInfo &info) const
void removeRepository(const RepoInfo &repo)
Log recently removed repository.
Provide a new empty temporary directory and recursively delete it when no longer needed.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
RepoSizeType repoSize() const
Impl * clone() const
clone for RWCOW_pointer
void clearReposToDisable()
Clear the set of ReposToDisable.
Lightweight repository attribute value lookup.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
void cleanCacheDirGarbage(OPT_PROGRESS)
int unlink(const Pathname &path)
Like 'unlink'.
thrown when it was impossible to determine one url for this repo.
const std::string & asString() const
String representation.
std::string alias() const
unique identifier for this source.
bool isExist() const
Return whether valid stat info exists.
unsigned repo_refresh_delay() const
Amount of time in minutes that must pass before another refresh.
static const ServiceType NONE
No service set.
ServiceConstIterator serviceBegin() const
Iterator to first service in internal storage.
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
static const SolvAttr repositoryToolVersion
Service type enumeration.
void modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, OPT_PROGRESS)
std::string asUserString() const
Translated error message as string suitable for the user.
ServiceSet::const_iterator ServiceConstIterator
void setRepoStates(RepoStates newStates_r)
Remember a new set of repository states.
std::ostream & operator<<(std::ostream &str, const DeltaCandidates &obj)
Pathname dirname() const
Return all but the last component od this path.
bool reposToDisableEmpty() const
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r prefixed with root_r, unless it is already prefixed.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
void setMetadataPath(const Pathname &path)
set the path where the local metadata is stored
std::string asCompleteString() const
Returns a complete string representation of the Url object.
void setType(const repo::RepoType &t)
set the repository type
Maintain [min,max] and counter (value) for progress counting.
void addRepository(const RepoInfo &repo)
Log a newly added repository.
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
Writing the zypp history fileReference counted signleton for writhing the zypp history file...
RepoConstIterator repoEnd() const
static bool schemeIsVolatile(const std::string &scheme_r)
cd dvd
repo::RepoType probe(const Url &url, const Pathname &path=Pathname()) const
Probe the metadata type of a repository located at url.
void addRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds a repository to the list of known repositories.
RepoInfo getRepositoryInfo(const std::string &alias, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Find a matching repository info.
static const ServiceType PLUGIN
Plugin services are scripts installed on your system that provide the package manager with repositori...
Base Exception for service handling.
std::string receiveLine()
Read one line from the input stream.
RepoInfo getRepo(const std::string &alias) const
void init_knownServices()
void delRepoToEnable(const std::string &alias_r)
Remove alias_r from the set of ReposToEnable.
static std::string makeStupidAlias(const Url &url_r=Url())
Some stupid string but suitable as alias for your url if nothing better is available.
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy=RefreshIfNeeded)
Checks whether to refresh metadata for specified repository and url.
void cleanCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
clean local cache
const std::string & asString() const
Return current Pathname as String.
void cleanCache(const RepoInfo &info, OPT_PROGRESS)
std::string numstring(char n, int w=0)
ServiceSet::size_type ServiceSizeType
Date::Duration ttl() const
Sugested TTL between two metadata auto-refreshs.
static const RepoType NONE
bool hasService(const std::string &alias) const
int touch(const Pathname &path)
Change file's modification and access times.
void resetDispose()
Set no dispose function.
Url url() const
The service url.
RepoSizeType repoSize() const
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
ServiceSizeType serviceSize() const
Gets count of service in RepoManager (in specified location)
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
int close()
Wait for the progamm to complete.
void setLrf(Date lrf_r)
Set date of last refresh.
static const RepoType RPMMD
creates and provides information about known sources.
#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.
void addService(const ServiceInfo &service)
std::list< RepoInfo > readRepoFile(const Url &repo_file)
Parses repo_file and returns a list of RepoInfo objects corresponding to repositories found within th...
static const RepoType YAST2
thrown when it was impossible to determine an alias for this repo.
std::string generateFilename(const RepoInfo &info) const
void buildCache(const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local cache.
const RepoStates & repoStates() const
Access the remembered repository states.
Base class for Exception.
void addRepositories(const Url &url, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds repositores from a repo file to the list of known repositories.
Date timestamp() const
The time the data were changed the last time.
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
Exception for repository handling.
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Writes ServiceInfo to stream in ".service" format.
Impl(const RepoManagerOptions &opt)
Pathname packagesPath(const RepoInfo &info) const
Path where the rpm packages are downloaded and kept.
media::MediaAccessId _mid
static Date now()
Return the current time.
bool repoToDisableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToDisable.
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
DefaultIntegral< bool, false > _reposDirty
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
Functor thats filter RepoInfo by service which it belongs to.
bool serviceEmpty() const
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
The repository cache is not built yet so you can't create the repostories from the cache...
void eraseFromPool()
Remove this Repository from it's Pool.
Pathname repoPackagesCachePath
repo::RepoType probe(const Url &url, const Pathname &path) const
Probe repo metadata type.
bool hasRepo(const std::string &alias) const
static const ServiceInfo noService
Represents an empty service.
void saveService(ServiceInfo &service) const
Wrapper class for ::stat/::lstat.
void removeService(const std::string &alias)
void buildCache(const RepoInfo &info, CacheBuildPolicy policy, OPT_PROGRESS)
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
regex ZYPP_STR_REGEX regex ZYPP_STR_REGEX
Thrown when the repo alias is found to be invalid.
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
friend std::ostream & operator<<(std::ostream &str, const RepoManager &obj)
static const RepoType RPMPLAINDIR
static const std::string & systemRepoAlias()
Reserved system repository alias .
ServiceInfo getService(const std::string &alias) const
Track changing files or directories.
void cleanPackages(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local package cache.
Repository already exists and some unique attribute can't be duplicated.
bool set(value_type val_r)
Set new counter value.
urls_size_type baseUrlsSize() const
number of repository urls
static bool schemeIsDownloading(const std::string &scheme_r)
http https ftp sftp tftp
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
void modifyRepository(const RepoInfo &oldrepo, const RepoInfo &newrepo)
Log certain modifications to a repository.
std::ostream & operator<<(std::ostream &str, const RepoManager::Impl &obj)
ServiceConstIterator serviceEnd() const
Repository addRepoSolv(const Pathname &file_r, const std::string &name_r)
Load Solvables from a solv-file into a Repository named name_r.
void name(const std::string &name_r)
Set counter name.
Downloader for YUM (rpm-nmd) repositories Encapsulates all the knowledge of which files have to be do...
Easy-to use interface to the ZYPP dependency resolver.
Pathname metadataPath(const RepoInfo &info) const
void cleanPackages(const RepoInfo &info, OPT_PROGRESS)
std::string generateFilename(const ServiceInfo &info) const
RepoInfo getRepo(const std::string &alias) const
Find RepoInfo by alias or return RepoInfo::noRepo.
void loadFromCache(const RepoInfo &info, OPT_PROGRESS)
std::string hexstring(char n, int w=4)
bool isCached(const RepoInfo &info) const
Whether a repository exists in cache.
void addService(const std::string &alias, const Url &url)
Adds new service by it's alias and url.
repo::ServiceType type() const
Service type.
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, OPT_PROGRESS)
std::string label() const
Label for use in messages for the user interface.
url_set baseUrls() const
The complete set of repository urls.
Service has no or invalid url defined.
repo::RepoType type() const
Type of repository,.
static bool schemeIsLocal(const std::string &scheme_r)
hd cd dvd dir file iso
void addRepositories(const Url &url, OPT_PROGRESS)
Pathname generateNonExistingName(const Pathname &dir, const std::string &basefilename) const
Generate a non existing filename in a directory, using a base name.
void cleanMetadata(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local metadata.
Repository type enumeration.
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy)