21 #include <solv/solvversion.h> 61 #define OPT_PROGRESS const ProgressData::ReceiverFnc & = ProgressData::ReceiverFnc() 73 const char * env = getenv(
"ZYPP_PLUGIN_APPDATA_FORCE_COLLECT");
103 class UrlCredentialExtractor
106 UrlCredentialExtractor( Pathname & root_r )
110 ~UrlCredentialExtractor()
114 bool collect(
const Url & url_r )
116 bool ret = url_r.hasCredentialsInAuthority();
120 _cmPtr->addUserCred( url_r );
125 template<
class TContainer>
126 bool collect(
const TContainer & urls_r )
127 {
bool ret =
false;
for (
const Url &
url : urls_r ) {
if ( collect(
url ) && !ret ) ret =
true; }
return ret; }
130 bool extract( Url & url_r )
132 bool ret = collect( url_r );
134 url_r.setPassword( std::string() );
138 template<
class TContainer>
139 bool extract( TContainer & urls_r )
140 {
bool ret =
false;
for ( Url &
url : urls_r ) {
if ( extract(
url ) && !ret ) ret =
true; }
return ret; }
144 scoped_ptr<media::CredentialManager>
_cmPtr;
159 MediaMounter(
const Url & url_r )
161 media::MediaManager mediamanager;
162 _mid = mediamanager.open( url_r );
163 mediamanager.attach(
_mid );
169 media::MediaManager mediamanager;
170 mediamanager.release(
_mid );
171 mediamanager.close(
_mid );
178 Pathname getPathName(
const Pathname & path_r = Pathname() )
const 180 media::MediaManager mediamanager;
181 return mediamanager.localPath(
_mid, path_r );
190 template <
class Iterator>
191 inline bool foundAliasIn(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
193 for_( it, begin_r, end_r )
194 if ( it->alias() == alias_r )
199 template <
class Container>
200 inline bool foundAliasIn(
const std::string & alias_r,
const Container & cont_r )
201 {
return foundAliasIn( alias_r, cont_r.begin(), cont_r.end() ); }
204 template <
class Iterator>
205 inline Iterator findAlias(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
207 for_( it, begin_r, end_r )
208 if ( it->alias() == alias_r )
213 template <
class Container>
214 inline typename Container::iterator findAlias(
const std::string & alias_r, Container & cont_r )
215 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
217 template <
class Container>
218 inline typename Container::const_iterator findAlias(
const std::string & alias_r,
const Container & cont_r )
219 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
223 inline std::string filenameFromAlias(
const std::string & alias_r,
const std::string & stem_r )
225 std::string filename( alias_r );
229 filename = Pathname(filename).extend(
"."+stem_r).asString();
230 MIL <<
"generating filename for " << stem_r <<
" [" << alias_r <<
"] : '" << filename <<
"'" << endl;
254 RepoCollector(
const std::string & targetDistro_)
258 bool collect(
const RepoInfo &repo )
262 && !repo.targetDistribution().empty()
266 <<
"Skipping repository meant for '" << repo.targetDistribution()
267 <<
"' distribution (current distro is '" 273 repos.push_back(repo);
287 std::list<RepoInfo> repositories_in_file(
const Pathname & file )
289 MIL <<
"repo file: " << file << endl;
290 RepoCollector collector;
291 parser::RepoFileReader parser( file, bind( &RepoCollector::collect, &collector, _1 ) );
292 return std::move(collector.repos);
305 std::list<RepoInfo> repositories_in_dir(
const Pathname &dir )
307 MIL <<
"directory " << dir << endl;
308 std::list<RepoInfo>
repos;
309 bool nonroot( geteuid() != 0 );
310 if ( nonroot && ! PathInfo(dir).userMayRX() )
312 JobReport::warning( str::Format(
_(
"Cannot read repo directory '%1%': Permission denied")) % dir );
316 std::list<Pathname> entries;
323 str::regex allowedRepoExt(
"^\\.repo(_[0-9]+)?$");
324 for ( std::list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
328 if ( nonroot && ! PathInfo(*it).userMayR() )
330 JobReport::warning( str::Format(
_(
"Cannot read repo file '%1%': Permission denied")) % *it );
334 const std::list<RepoInfo> & tmp( repositories_in_file( *it ) );
335 repos.insert(
repos.end(), tmp.begin(), tmp.end() );
345 inline void assert_alias(
const RepoInfo & info )
347 if ( info.alias().empty() )
351 if ( info.alias()[0] ==
'.')
353 info,
_(
"Repository alias cannot start with dot.")));
356 inline void assert_alias(
const ServiceInfo & info )
358 if ( info.alias().empty() )
362 if ( info.alias()[0] ==
'.')
364 info,
_(
"Service alias cannot start with dot.")));
369 inline void assert_urls(
const RepoInfo & info )
371 if ( info.baseUrlsEmpty() )
375 inline void assert_url(
const ServiceInfo & info )
377 if ( ! info.url().isValid() )
387 inline bool isTmpRepo(
const RepoInfo & info_r )
388 {
return( info_r.filepath().empty() && info_r.usesAutoMethadataPaths() ); }
396 inline Pathname rawcache_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
399 return isTmpRepo( info ) ? info.metadataPath() : opt.repoRawCachePath / info.escaped_alias();
410 inline Pathname rawproductdata_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
411 {
return rawcache_path_for_repoinfo( opt, info ) / info.path(); }
416 inline Pathname packagescache_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
419 return isTmpRepo( info ) ? info.packagesPath() : opt.repoPackagesCachePath / info.escaped_alias();
425 inline Pathname solv_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
428 return isTmpRepo( info ) ? info.metadataPath().dirname() /
"%SLV%" : opt.repoSolvCachePath / info.escaped_alias();
434 class ServiceCollector
437 typedef std::set<ServiceInfo> ServiceSet;
439 ServiceCollector( ServiceSet & services_r )
443 bool operator()(
const ServiceInfo & service_r )
const 461 DBG <<
"reading repo file " << repo_file <<
", local path: " << local << endl;
463 return repositories_in_file(local);
502 #define OUTS(X) str << " " #X "\t" << obj.X << endl 503 str <<
"RepoManagerOptions (" << obj.
rootDir <<
") {" << endl;
504 OUTS( repoRawCachePath );
505 OUTS( repoSolvCachePath );
506 OUTS( repoPackagesCachePath );
507 OUTS( knownReposPath );
508 OUTS( knownServicesPath );
526 init_knownServices();
527 init_knownRepositories();
534 && geteuid() == 0 && ( _options.rootDir.empty() || _options.rootDir ==
"/" ) )
537 std::list<Pathname> entries;
539 if ( ! entries.empty() )
542 cmd.push_back(
"<" );
543 cmd.push_back(
">" );
544 cmd.push_back(
"PROGRAM" );
545 for (
const auto & rinfo :
repos() )
547 if ( ! rinfo.enabled() )
549 cmd.push_back(
"-R" );
550 cmd.push_back( rinfo.alias() );
551 cmd.push_back(
"-t" );
552 cmd.push_back( rinfo.type().asString() );
553 cmd.push_back(
"-p" );
554 cmd.push_back( rinfo.metadataPath().asString() );
557 for_( it, entries.begin(), entries.end() )
580 bool hasRepo(
const std::string & alias )
const 581 {
return foundAliasIn( alias,
repos() ); }
591 {
return rawcache_path_for_repoinfo( _options, info ); }
594 {
return packagescache_path_for_repoinfo( _options, info ); }
616 {
return PathInfo(solv_path_for_repoinfo( _options, info ) /
"solv").
isExist(); }
641 {
return foundAliasIn( alias,
_services ); }
654 void removeService(
const std::string & alias );
656 { removeService( service.
alias() ); }
662 { refreshService( service.
alias(), options_r ); }
664 void modifyService(
const std::string & oldAlias,
const ServiceInfo & newService );
671 Pathname generateNonExistingName(
const Pathname & dir,
const std::string & basefilename )
const;
674 {
return filenameFromAlias( info.
alias(),
"repo" ); }
677 {
return filenameFromAlias( info.
alias(),
"service" ); }
681 Pathname base = solv_path_for_repoinfo( _options, info );
686 void touchIndexFile(
const RepoInfo & info );
688 template<
typename OutputIterator>
693 boost::make_filter_iterator( filter,
repos().end(),
repos().end() ),
698 void init_knownServices();
699 void init_knownRepositories();
712 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
715 {
return new Impl( *
this ); }
721 {
return str <<
"RepoManager::Impl"; }
728 Pathname servfile = generateNonExistingName( _options.knownServicesPath,
729 generateFilename( service ) );
732 MIL <<
"saving service in " << servfile << endl;
734 std::ofstream file( servfile.
c_str() );
741 MIL <<
"done" << endl;
760 const std::string & basefilename )
const 762 std::string final_filename = basefilename;
764 while (
PathInfo(dir + final_filename).isExist() )
769 return dir +
Pathname(final_filename);
776 Pathname dir = _options.knownServicesPath;
777 std::list<Pathname> entries;
787 for_(it, entries.begin(), entries.end() )
803 inline void cleanupNonRepoMetadtaFolders(
const Pathname & cachePath_r,
804 const Pathname & defaultCachePath_r,
805 const std::list<std::string> & repoEscAliases_r )
807 if ( cachePath_r != defaultCachePath_r )
810 std::list<std::string> entries;
814 std::set<std::string> oldfiles;
815 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
816 std::inserter( oldfiles, oldfiles.end() ) );
817 for (
const std::string & old : oldfiles )
829 MIL <<
"start construct known repos" << endl;
833 std::list<std::string> repoEscAliases;
834 std::list<RepoInfo> orphanedRepos;
835 for (
RepoInfo & repoInfo : repositories_in_dir(_options.knownReposPath) )
838 repoInfo.setMetadataPath( rawcache_path_for_repoinfo(_options, repoInfo) );
840 repoInfo.setPackagesPath( packagescache_path_for_repoinfo(_options, repoInfo) );
842 _reposX.insert( repoInfo );
845 const std::string & serviceAlias( repoInfo.service() );
846 if ( ! ( serviceAlias.empty() || hasService( serviceAlias ) ) )
848 WAR <<
"Schedule orphaned service repo for deletion: " << repoInfo << endl;
849 orphanedRepos.push_back( repoInfo );
853 repoEscAliases.push_back(repoInfo.escaped_alias());
857 if ( ! orphanedRepos.empty() )
859 for (
const auto & repoInfo : orphanedRepos )
861 MIL <<
"Delete orphaned service repo " << repoInfo.alias() << endl;
867 % repoInfo.alias() );
869 removeRepository( repoInfo );
883 repoEscAliases.sort();
885 cleanupNonRepoMetadtaFolders( _options.repoRawCachePath, defaultCache.
repoRawCachePath, repoEscAliases );
886 cleanupNonRepoMetadtaFolders( _options.repoSolvCachePath, defaultCache.
repoSolvCachePath, repoEscAliases );
887 cleanupNonRepoMetadtaFolders( _options.repoPackagesCachePath, defaultCache.
repoPackagesCachePath, repoEscAliases );
889 MIL <<
"end construct known repos" << endl;
896 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
897 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
902 repokind = probeCache( productdatapath );
905 switch ( repokind.
toEnum() )
908 status =
RepoStatus( productdatapath/
"repodata/repomd.xml") &&
RepoStatus( mediarootpath/
"media.1/media" );
912 status =
RepoStatus( productdatapath/
"content" ) &&
RepoStatus( mediarootpath/
"media.1/media" );
931 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
936 repokind = probeCache( productdatapath );
942 switch ( repokind.
toEnum() )
945 p =
Pathname(productdatapath +
"/repodata/repomd.xml");
949 p =
Pathname(productdatapath +
"/content");
953 p =
Pathname(productdatapath +
"/cookie");
971 MIL <<
"Going to try to check whether refresh is needed for " <<
url <<
" (" << info.
type() <<
")" << endl;
974 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
976 RepoStatus oldstatus = metadataStatus( info );
977 if ( oldstatus.
empty() )
979 MIL <<
"No cached metadata, going to refresh" << endl;
980 return REFRESH_NEEDED;
983 if (
url.schemeIsVolatile() )
985 MIL <<
"Never refresh CD/DVD" << endl;
986 return REPO_UP_TO_DATE;
989 if ( policy == RefreshForced )
991 MIL <<
"Forced refresh!" << endl;
992 return REFRESH_NEEDED;
995 if (
url.schemeIsLocal() )
997 policy = RefreshIfNeededIgnoreDelay;
1001 if ( policy != RefreshIfNeededIgnoreDelay )
1004 double diff = difftime(
1010 DBG <<
"last refresh = " << diff <<
" minutes ago" << endl;
1016 WAR <<
"Repository '" << info.
alias() <<
"' was refreshed in the future!" << endl;
1020 MIL <<
"Repository '" << info.
alias()
1021 <<
"' has been refreshed less than repo.refresh.delay (" 1023 <<
") minutes ago. Advising to skip refresh" << endl;
1024 return REPO_CHECK_DELAYED;
1032 repokind = probe(
url, info.
path() );
1036 switch ( repokind.
toEnum() )
1063 if ( oldstatus == newstatus )
1065 MIL <<
"repo has not changed" << endl;
1066 touchIndexFile( info );
1067 return REPO_UP_TO_DATE;
1071 MIL <<
"repo has changed, going to refresh" << endl;
1072 return REFRESH_NEEDED;
1078 ERR <<
"refresh check failed for " <<
url << endl;
1082 return REFRESH_NEEDED;
1092 RepoException rexception( info,
PL_(
"Valid metadata not found at specified URL",
1093 "Valid metadata not found at specified URLs",
1107 if (checkIfToRefreshMetadata(info,
url, policy)!=REFRESH_NEEDED)
1110 MIL <<
"Going to refresh metadata from " <<
url << endl;
1118 if ( repokind != probed )
1122 for_( it, repoBegin(), repoEnd() )
1124 if ( info.
alias() == (*it).alias() )
1127 modifiedrepo.
setType( repokind );
1141 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1152 Exception ex(
_(
"Can't create metadata cache directory."));
1160 shared_ptr<repo::Downloader> downloader_ptr;
1162 MIL <<
"Creating downloader for [ " << info.
alias() <<
" ]" << endl;
1175 for_( it, repoBegin(), repoEnd() )
1177 Pathname cachepath(rawcache_path_for_repoinfo( _options, *it ));
1178 if (
PathInfo(cachepath).isExist() )
1179 downloader_ptr->addCachePath(cachepath);
1182 downloader_ptr->download( media, tmpdir.
path() );
1186 MediaMounter media(
url );
1201 if ( ! isTmpRepo( info ) )
1210 ERR <<
"Trying another url..." << endl;
1222 ERR <<
"No more urls..." << endl;
1231 progress.
sendTo(progressfnc);
1241 progress.
sendTo(progressfnc);
1251 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1252 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
1259 RepoStatus raw_metadata_status = metadataStatus(info);
1260 if ( raw_metadata_status.
empty() )
1265 refreshMetadata(info, RefreshIfNeeded, progressrcv );
1266 raw_metadata_status = metadataStatus(info);
1269 bool needs_cleaning =
false;
1270 if ( isCached( info ) )
1272 MIL << info.
alias() <<
" is already cached." << endl;
1275 if ( cache_status == raw_metadata_status )
1277 MIL << info.
alias() <<
" cache is up to date with metadata." << endl;
1278 if ( policy == BuildIfNeeded )
1281 const Pathname & base = solv_path_for_repoinfo( _options, info);
1282 if ( !
PathInfo(base/
"solv.idx").isExist() )
1288 MIL << info.
alias() <<
" cache rebuild is forced" << endl;
1292 needs_cleaning =
true;
1306 MIL << info.
alias() <<
" building cache..." << info.
type() << endl;
1308 Pathname base = solv_path_for_repoinfo( _options, info);
1327 switch ( repokind.
toEnum() )
1331 repokind = probeCache( productdatapath );
1337 MIL <<
"repo type is " << repokind << endl;
1339 switch ( repokind.
toEnum() )
1347 scoped_ptr<MediaMounter> forPlainDirs;
1350 cmd.push_back(
PathInfo(
"/usr/bin/repo2solv" ).isFile() ?
"repo2solv" :
"repo2solv.sh" );
1352 cmd.push_back(
"-o" );
1353 cmd.push_back( solvfile.
asString() );
1354 cmd.push_back(
"-X" );
1359 forPlainDirs.reset(
new MediaMounter( info.
url() ) );
1361 cmd.push_back(
"-R" );
1363 cmd.push_back( forPlainDirs->getPathName( info.
path() ).c_str() );
1366 cmd.push_back( productdatapath.
asString() );
1369 std::string errdetail;
1372 WAR <<
" " << output;
1373 if ( errdetail.empty() ) {
1377 errdetail += output;
1380 int ret = prog.
close();
1398 setCacheStatus(info, raw_metadata_status);
1399 MIL <<
"Commit cache.." << endl;
1414 MIL <<
"going to probe the repo type at " <<
url <<
" (" << path <<
")" << endl;
1416 if (
url.getScheme() ==
"dir" && !
PathInfo(
url.getPathName()/path ).isDir() )
1420 MIL <<
"Probed type NONE (not exists) at " <<
url <<
" (" << path <<
")" << endl;
1432 bool gotMediaException =
false;
1440 MIL <<
"Probed type RPMMD at " <<
url <<
" (" << path <<
")" << endl;
1447 DBG <<
"problem checking for repodata/repomd.xml file" << endl;
1449 gotMediaException =
true;
1456 MIL <<
"Probed type YAST2 at " <<
url <<
" (" << path <<
")" << endl;
1463 DBG <<
"problem checking for content file" << endl;
1465 gotMediaException =
true;
1469 if ( !
url.schemeIsDownloading() )
1471 MediaMounter media(
url );
1472 if (
PathInfo(media.getPathName()/path).isDir() )
1475 MIL <<
"Probed type RPMPLAINDIR at " <<
url <<
" (" << path <<
")" << endl;
1489 if (gotMediaException)
1492 MIL <<
"Probed type NONE at " <<
url <<
" (" << path <<
")" << endl;
1503 MIL <<
"going to probe the cached repo at " << path_r << endl;
1507 if (
PathInfo(path_r/
"/repodata/repomd.xml").isFile() )
1509 else if (
PathInfo(path_r/
"/content").isFile() )
1511 else if (
PathInfo(path_r).isDir() )
1514 MIL <<
"Probed cached type " << ret <<
" at " << path_r << endl;
1522 MIL <<
"Going to clean up garbage in cache dirs" << endl;
1525 progress.
sendTo(progressrcv);
1528 std::list<Pathname> cachedirs;
1529 cachedirs.push_back(_options.repoRawCachePath);
1530 cachedirs.push_back(_options.repoPackagesCachePath);
1531 cachedirs.push_back(_options.repoSolvCachePath);
1533 for_( dir, cachedirs.begin(), cachedirs.end() )
1537 std::list<Pathname> entries;
1542 unsigned sdircount = entries.size();
1543 unsigned sdircurrent = 1;
1544 for_( subdir, entries.begin(), entries.end() )
1548 for_( r, repoBegin(), repoEnd() )
1549 if ( subdir->basename() == r->escaped_alias() )
1550 { found =
true;
break; }
1555 progress.
set( progress.
val() + sdircurrent * 100 / sdircount );
1560 progress.
set( progress.
val() + 100 );
1570 progress.
sendTo(progressrcv);
1573 MIL <<
"Removing raw metadata cache for " << info.
alias() << endl;
1584 Pathname solvfile = solv_path_for_repoinfo(_options, info) /
"solv";
1586 if ( !
PathInfo(solvfile).isExist() )
1596 if ( toolversion != LIBSOLV_TOOLVERSION )
1605 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1606 cleanCache( info, progressrcv );
1607 buildCache( info, BuildIfNeeded, progressrcv );
1625 MIL <<
"Try adding repo " << info << endl;
1632 if ( _options.probe )
1634 DBG <<
"unknown repository type, probing" << endl;
1635 assert_urls(tosave);
1649 Pathname repofile = generateNonExistingName(
1650 _options.knownReposPath, generateFilename(tosave));
1652 MIL <<
"Saving repo in " << repofile << endl;
1654 std::ofstream file(repofile.
c_str());
1663 tosave.
setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1664 tosave.
setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1668 RepoInfo & oinfo( const_cast<RepoInfo &>(info) );
1670 oinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1671 oinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1673 reposManip().insert(tosave);
1678 UrlCredentialExtractor( _options.rootDir ).collect( tosave.
baseUrls() );
1683 MIL <<
"done" << endl;
1690 for ( std::list<RepoInfo>::const_iterator it =
repos.begin();
1695 for_ ( kit, repoBegin(), repoEnd() )
1697 if ( (*it).alias() == (*kit).alias() )
1699 ERR <<
"To be added repo " << (*it).alias() <<
" conflicts with existing repo " << (*kit).alias() << endl;
1705 std::string filename =
Pathname(
url.getPathName()).basename();
1716 Pathname repofile = generateNonExistingName(_options.knownReposPath, filename);
1718 MIL <<
"Saving " <<
repos.size() <<
" repo" << (
repos.size() ?
"s" :
"" ) <<
" in " << repofile << endl;
1720 std::ofstream file(repofile.
c_str());
1727 for ( std::list<RepoInfo>::iterator it =
repos.begin();
1731 MIL <<
"Saving " << (*it).alias() << endl;
1732 it->dumpAsIniOn(file);
1733 it->setFilepath(repofile);
1734 it->setMetadataPath( rawcache_path_for_repoinfo( _options, *it ) );
1735 it->setPackagesPath( packagescache_path_for_repoinfo( _options, *it ) );
1736 reposManip().insert(*it);
1741 MIL <<
"done" << endl;
1753 MIL <<
"Going to delete repo " << info.
alias() << endl;
1755 for_( it, repoBegin(), repoEnd() )
1760 if ( (!info.
alias().empty()) && ( info.
alias() != (*it).alias() ) )
1775 std::list<RepoInfo> filerepos = repositories_in_file(todelete.
filepath());
1776 if ( filerepos.size() == 0
1777 ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.
alias() ) )
1781 if ( ! ( ret == 0 || ret == ENOENT ) )
1786 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1804 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1805 fit != filerepos.end();
1808 if ( (*fit).alias() != todelete.
alias() )
1809 (*fit).dumpAsIniOn(file);
1817 if ( isCached(todelete) )
1818 cleanCache( todelete, cSubprogrcv);
1820 cleanMetadata( todelete, mSubprogrcv );
1821 cleanPackages( todelete, pSubprogrcv );
1822 reposManip().erase(todelete);
1823 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1837 RepoInfo toedit = getRepositoryInfo(alias);
1841 if ( alias != newinfo.
alias() && hasRepo( newinfo.
alias() ) )
1853 std::list<RepoInfo> filerepos = repositories_in_file(toedit.
filepath());
1869 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1870 fit != filerepos.end();
1875 if ( (*fit).alias() != toedit.
alias() )
1876 (*fit).dumpAsIniOn(file);
1884 const Pathname & solvidx = solv_path_for_repoinfo(_options, newinfo)/
"solv.idx";
1890 newinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1891 newinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1895 RepoInfo & oinfo( const_cast<RepoInfo &>(newinfo_r) );
1897 oinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1898 oinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1900 reposManip().erase(toedit);
1901 reposManip().insert(newinfo);
1903 UrlCredentialExtractor( _options.rootDir ).collect( newinfo.
baseUrls() );
1905 MIL <<
"repo " << alias <<
" modified" << endl;
1914 if ( it !=
repos().end() )
1924 for_( it, repoBegin(), repoEnd() )
1926 for_( urlit, (*it).baseUrlsBegin(), (*it).baseUrlsEnd() )
1928 if ( (*urlit).asString(urlview) ==
url.asString(urlview) )
1945 assert_alias( service );
1948 if ( hasService( service.
alias() ) )
1954 saveService( toSave );
1958 UrlCredentialExtractor( _options.rootDir ).collect( toSave.
url() );
1960 MIL <<
"added service " << toSave.
alias() << endl;
1967 MIL <<
"Going to delete service " << alias << endl;
1969 const ServiceInfo & service = getService( alias );
1972 if( location.
empty() )
1981 if ( tmpSet.size() == 1 )
1988 MIL << alias <<
" successfully deleted." << endl;
1994 std::ofstream file(location.
c_str());
2001 for_(it, tmpSet.begin(), tmpSet.end())
2003 if( it->alias() != alias )
2004 it->dumpAsIniOn(file);
2007 MIL << alias <<
" successfully deleted from file " << location << endl;
2011 RepoCollector rcollector;
2012 getRepositoriesInService( alias,
2013 boost::make_function_output_iterator( bind( &RepoCollector::collect, &rcollector, _1 ) ) );
2015 for_(rit, rcollector.repos.begin(), rcollector.repos.end())
2016 removeRepository(*rit);
2025 ServiceSet services( serviceBegin(), serviceEnd() );
2026 for_( it, services.begin(), services.end() )
2028 if ( !it->enabled() )
2032 refreshService(*it, options_r);
2042 assert_alias( service );
2043 assert_url( service );
2044 MIL <<
"Going to refresh service '" << service.
alias() <<
"', url: " << service.
url() <<
", opts: " << options_r << endl;
2046 if ( service.
ttl() && !( options_r.testFlag( RefreshService_forceRefresh) || options_r.testFlag( RefreshService_restoreStatus ) ) )
2055 if ( (lrf+=service.
ttl()) > now )
2057 MIL <<
"Skip: '" << service.
alias() <<
"' metadata valid until " << lrf << endl;
2062 WAR <<
"Force: '" << service.
alias() <<
"' metadata last refresh in the future: " << lrf << endl;
2069 bool serviceModified =
false;
2080 serviceModified =
true;
2085 std::string servicesTargetDistro = _options.servicesTargetDistro;
2086 if ( servicesTargetDistro.empty() )
2090 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << endl;
2094 RepoCollector collector(servicesTargetDistro);
2107 ServiceRepos( _options.rootDir, service, bind( &RepoCollector::collect, &collector, _1 ) );
2112 uglyHack.first =
true;
2113 uglyHack.second = e;
2115 if ( service.
ttl() != origTtl )
2117 if ( !service.
ttl() )
2119 serviceModified =
true;
2127 for_( it, collector.repos.begin(), collector.repos.end() )
2130 it->setAlias(
str::form(
"%s:%s", service.
alias().c_str(), it->alias().c_str() ) );
2132 it->setService( service.
alias() );
2135 newRepoStates[it->alias()] = *it;
2143 if ( !it->path().empty() )
2145 if ( it->path() !=
"/" )
2150 if ( it->baseUrlsEmpty() )
2153 if ( !path.
empty() )
2154 url.setPathName(
url.getPathName() / path );
2155 it->setBaseUrl( std::move(
url) );
2157 else if ( !path.
empty() )
2162 url.setPathName(
url.getPathName() / path );
2164 it->setBaseUrls( std::move(urls) );
2171 RepoInfoList oldRepos;
2172 getRepositoriesInService( service.
alias(), std::back_inserter( oldRepos ) );
2176 for_( oldRepo, oldRepos.begin(), oldRepos.end() )
2178 if ( ! foundAliasIn( oldRepo->alias(), collector.repos ) )
2180 if ( oldRepo->enabled() )
2183 const auto & last = service.
repoStates().find( oldRepo->alias() );
2184 if ( last != service.
repoStates().end() && ! last->second.enabled )
2186 DBG <<
"Service removes user enabled repo " << oldRepo->alias() << endl;
2188 serviceModified =
true;
2191 DBG <<
"Service removes enabled repo " << oldRepo->alias() << endl;
2194 DBG <<
"Service removes disabled repo " << oldRepo->alias() << endl;
2196 removeRepository( *oldRepo );
2202 UrlCredentialExtractor urlCredentialExtractor( _options.rootDir );
2203 for_( it, collector.repos.begin(), collector.repos.end() )
2209 TriBool toBeEnabled( indeterminate );
2210 DBG <<
"Service request to " << (it->enabled()?
"enable":
"disable") <<
" service repo " << it->alias() << endl;
2212 if ( options_r.testFlag( RefreshService_restoreStatus ) )
2214 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() << endl;
2226 DBG <<
"User request to enable service repo " << it->alias() << endl;
2232 serviceModified =
true;
2236 DBG <<
"User request to disable service repo " << it->alias() << endl;
2237 toBeEnabled =
false;
2241 RepoInfoList::iterator oldRepo( findAlias( it->alias(), oldRepos ) );
2242 if ( oldRepo == oldRepos.end() )
2247 if ( ! indeterminate(toBeEnabled) )
2248 it->setEnabled( (
bool ) toBeEnabled );
2250 DBG <<
"Service adds repo " << it->alias() <<
" " << (it->enabled()?
"enabled":
"disabled") << endl;
2251 addRepository( *it );
2256 bool oldRepoModified =
false;
2258 if ( indeterminate(toBeEnabled) )
2262 if ( oldRepo->enabled() == it->enabled() )
2263 toBeEnabled = it->enabled();
2264 else if (options_r.testFlag( RefreshService_restoreStatus ) )
2266 toBeEnabled = it->enabled();
2267 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() <<
" forces " << (toBeEnabled?
"enabled":
"disabled") << endl;
2271 const auto & last = service.
repoStates().find( oldRepo->alias() );
2272 if ( last == service.
repoStates().end() || last->second.enabled != it->enabled() )
2273 toBeEnabled = it->enabled();
2276 toBeEnabled = oldRepo->enabled();
2277 DBG <<
"User modified service repo " << it->alias() <<
" may stay " << (toBeEnabled?
"enabled":
"disabled") << endl;
2283 if ( toBeEnabled == oldRepo->enabled() )
2285 DBG <<
"Service repo " << it->alias() <<
" stays " << (oldRepo->enabled()?
"enabled":
"disabled") << endl;
2287 else if ( toBeEnabled )
2289 DBG <<
"Service repo " << it->alias() <<
" gets enabled" << endl;
2290 oldRepo->setEnabled(
true );
2291 oldRepoModified =
true;
2295 DBG <<
"Service repo " << it->alias() <<
" gets disabled" << endl;
2296 oldRepo->setEnabled(
false );
2297 oldRepoModified =
true;
2303 if ( oldRepo->rawName() != it->rawName() )
2305 DBG <<
"Service repo " << it->alias() <<
" gets new NAME " << it->rawName() << endl;
2306 oldRepo->setName( it->rawName() );
2307 oldRepoModified =
true;
2311 if ( oldRepo->autorefresh() != it->autorefresh() )
2313 DBG <<
"Service repo " << it->alias() <<
" gets new AUTOREFRESH " << it->autorefresh() << endl;
2314 oldRepo->setAutorefresh( it->autorefresh() );
2315 oldRepoModified =
true;
2319 if ( oldRepo->priority() != it->priority() )
2321 DBG <<
"Service repo " << it->alias() <<
" gets new PRIORITY " << it->priority() << endl;
2322 oldRepo->setPriority( it->priority() );
2323 oldRepoModified =
true;
2329 urlCredentialExtractor.extract( newUrls );
2330 if ( oldRepo->rawBaseUrls() != newUrls )
2332 DBG <<
"Service repo " << it->alias() <<
" gets new URLs " << newUrls << endl;
2333 oldRepo->setBaseUrls( std::move(newUrls) );
2334 oldRepoModified =
true;
2344 oldRepo->getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
2345 it-> getRawGpgChecks( ngpg[0], ngpg[1], ngpg[2] );
2346 #define Z_CHKGPG(I,N) \ 2347 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \ 2349 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \ 2350 oldRepo->set##N##Check( ngpg[I] ); \ 2351 oldRepoModified = true; \ 2360 if ( oldRepoModified )
2362 modifyRepository( oldRepo->alias(), *oldRepo );
2371 serviceModified =
true;
2378 serviceModified =
true;
2385 if ( service.
ttl() )
2388 serviceModified =
true;
2391 if ( serviceModified )
2394 modifyService( service.
alias(), service );
2398 if ( uglyHack.first )
2400 throw( uglyHack.second );
2408 MIL <<
"Going to modify service " << oldAlias << endl;
2419 const ServiceInfo & oldService = getService(oldAlias);
2422 if( location.
empty() )
2432 std::ofstream file(location.
c_str());
2433 for_(it, tmpSet.begin(), tmpSet.end())
2435 if( *it != oldAlias )
2436 it->dumpAsIniOn(file);
2445 UrlCredentialExtractor( _options.rootDir ).collect( service.
url() );
2449 if ( oldAlias != service.
alias()
2452 std::vector<RepoInfo> toModify;
2453 getRepositoriesInService(oldAlias, std::back_inserter(toModify));
2454 for_( it, toModify.begin(), toModify.end() )
2461 const auto & last = service.
repoStates().find( it->alias() );
2463 it->setEnabled( last->second.enabled );
2466 it->setEnabled(
false );
2469 if ( oldAlias != service.
alias() )
2470 it->setService(service.
alias());
2472 modifyRepository(it->alias(), *it);
2516 : _pimpl( new
Impl(opt) )
2548 std::string host( url_r.
getHost() );
2549 if ( ! host.empty() )
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
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
std::string receiveLine()
Read one line from the input stream.
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)
Url url() const
Pars pro toto: The first repository url.
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.
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).
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.
std::ostream & operator<<(std::ostream &str, const Exception &obj)
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.
RepoStatus status(MediaSetAccess &media_r) override
Status of the remote repository.
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
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.
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.
bool ZYPP_PLUGIN_APPDATA_FORCE_COLLECT()
To trigger appdata refresh unconditionally.
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
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
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
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
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,.
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)