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 )
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 );
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::FormatNAC(
_(
"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::FormatNAC(
_(
"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 467 DBG <<
"reading repo file " << repo_file <<
", local path: " << local << endl;
469 return repositories_in_file(local);
480 repoCachePath = Pathname::assertprefix( root_r,
ZConfig::instance().repoCachePath() );
481 repoRawCachePath = Pathname::assertprefix( root_r,
ZConfig::instance().repoMetadataPath() );
482 repoSolvCachePath = Pathname::assertprefix( root_r,
ZConfig::instance().repoSolvfilesPath() );
483 repoPackagesCachePath = Pathname::assertprefix( root_r,
ZConfig::instance().repoPackagesPath() );
484 knownReposPath = Pathname::assertprefix( root_r,
ZConfig::instance().knownReposPath() );
485 knownServicesPath = Pathname::assertprefix( root_r,
ZConfig::instance().knownServicesPath() );
486 pluginsPath = Pathname::assertprefix( root_r,
ZConfig::instance().pluginsPath() );
508 #define OUTS(X) str << " " #X "\t" << obj.X << endl 509 str <<
"RepoManagerOptions (" << obj.
rootDir <<
") {" << endl;
510 OUTS( repoRawCachePath );
511 OUTS( repoSolvCachePath );
512 OUTS( repoPackagesCachePath );
513 OUTS( knownReposPath );
514 OUTS( knownServicesPath );
532 init_knownServices();
533 init_knownRepositories();
540 && geteuid() == 0 && ( _options.rootDir.empty() || _options.rootDir ==
"/" ) )
543 std::list<Pathname> entries;
545 if ( ! entries.empty() )
548 cmd.push_back(
"<" );
549 cmd.push_back(
">" );
550 cmd.push_back(
"PROGRAM" );
551 for (
const auto & rinfo :
repos() )
553 if ( ! rinfo.enabled() )
555 cmd.push_back(
"-R" );
556 cmd.push_back( rinfo.alias() );
557 cmd.push_back(
"-t" );
558 cmd.push_back( rinfo.type().asString() );
559 cmd.push_back(
"-p" );
560 cmd.push_back( rinfo.metadataPath().asString() );
563 for_( it, entries.begin(), entries.end() )
567 if ( pi.isFile() && pi.userMayRX() )
570 cmd[2] = pi.asString();
586 bool hasRepo(
const std::string & alias )
const 587 {
return foundAliasIn( alias,
repos() ); }
597 {
return rawcache_path_for_repoinfo( _options, info ); }
600 {
return packagescache_path_for_repoinfo( _options, info ); }
614 repo::RepoType probe(
const Url & url,
const Pathname & path = Pathname() )
const;
622 {
return PathInfo(solv_path_for_repoinfo( _options, info ) /
"solv").isExist(); }
647 {
return foundAliasIn( alias,
_services ); }
660 void removeService(
const std::string & alias );
662 { removeService( service.
alias() ); }
668 { refreshService( service.
alias(), options_r ); }
670 void modifyService(
const std::string & oldAlias,
const ServiceInfo & newService );
677 Pathname generateNonExistingName(
const Pathname & dir,
const std::string & basefilename )
const;
680 {
return filenameFromAlias( info.
alias(),
"repo" ); }
683 {
return filenameFromAlias( info.
alias(),
"service" ); }
687 Pathname base = solv_path_for_repoinfo( _options, info );
692 void touchIndexFile(
const RepoInfo & info );
694 template<
typename OutputIterator>
699 boost::make_filter_iterator( filter,
repos().end(),
repos().end() ),
704 void init_knownServices();
705 void init_knownRepositories();
718 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
721 {
return new Impl( *
this ); }
727 {
return str <<
"RepoManager::Impl"; }
734 Pathname servfile = generateNonExistingName( _options.knownServicesPath,
735 generateFilename( service ) );
738 MIL <<
"saving service in " << servfile << endl;
740 std::ofstream file( servfile.c_str() );
747 MIL <<
"done" << endl;
766 const std::string & basefilename )
const 768 std::string final_filename = basefilename;
770 while ( PathInfo(dir + final_filename).isExist() )
775 return dir + Pathname(final_filename);
782 Pathname dir = _options.knownServicesPath;
783 std::list<Pathname> entries;
784 if (PathInfo(dir).isExist())
793 for_(it, entries.begin(), entries.end() )
809 inline void cleanupNonRepoMetadtaFolders(
const Pathname & cachePath_r,
810 const Pathname & defaultCachePath_r,
811 const std::list<std::string> & repoEscAliases_r )
813 if ( cachePath_r != defaultCachePath_r )
816 std::list<std::string> entries;
820 std::set<std::string> oldfiles;
821 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
822 std::inserter( oldfiles, oldfiles.end() ) );
823 for (
const std::string & old : oldfiles )
835 MIL <<
"start construct known repos" << endl;
837 if ( PathInfo(_options.knownReposPath).isExist() )
839 std::list<std::string> repoEscAliases;
840 std::list<RepoInfo> orphanedRepos;
841 for (
RepoInfo & repoInfo : repositories_in_dir(_options.knownReposPath) )
844 repoInfo.setMetadataPath( rawcache_path_for_repoinfo(_options, repoInfo) );
846 repoInfo.setPackagesPath( packagescache_path_for_repoinfo(_options, repoInfo) );
848 _reposX.insert( repoInfo );
851 const std::string & serviceAlias( repoInfo.service() );
852 if ( ! ( serviceAlias.empty() || hasService( serviceAlias ) ) )
854 WAR <<
"Schedule orphaned service repo for deletion: " << repoInfo << endl;
855 orphanedRepos.push_back( repoInfo );
859 repoEscAliases.push_back(repoInfo.escaped_alias());
863 if ( ! orphanedRepos.empty() )
865 for (
const auto & repoInfo : orphanedRepos )
867 MIL <<
"Delete orphaned service repo " << repoInfo.alias() << endl;
873 % repoInfo.alias() );
875 removeRepository( repoInfo );
889 repoEscAliases.sort();
891 cleanupNonRepoMetadtaFolders( _options.repoRawCachePath, defaultCache.
repoRawCachePath, repoEscAliases );
892 cleanupNonRepoMetadtaFolders( _options.repoSolvCachePath, defaultCache.
repoSolvCachePath, repoEscAliases );
893 cleanupNonRepoMetadtaFolders( _options.repoPackagesCachePath, defaultCache.
repoPackagesCachePath, repoEscAliases );
895 MIL <<
"end construct known repos" << endl;
902 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
903 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
908 repokind = probeCache( productdatapath );
911 switch ( repokind.
toEnum() )
914 status =
RepoStatus( productdatapath/
"repodata/repomd.xml") &&
RepoStatus( mediarootpath/
"media.1/media" );
918 status =
RepoStatus( productdatapath/
"content" ) &&
RepoStatus( mediarootpath/
"media.1/media" );
937 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
942 repokind = probeCache( productdatapath );
948 switch ( repokind.
toEnum() )
951 p = Pathname(productdatapath +
"/repodata/repomd.xml");
955 p = Pathname(productdatapath +
"/content");
959 p = Pathname(productdatapath +
"/cookie");
977 MIL <<
"Going to try to check whether refresh is needed for " << url <<
" (" << info.
type() <<
")" << endl;
980 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
982 RepoStatus oldstatus = metadataStatus( info );
983 if ( oldstatus.
empty() )
985 MIL <<
"No cached metadata, going to refresh" << endl;
986 return REFRESH_NEEDED;
991 MIL <<
"Never refresh CD/DVD" << endl;
992 return REPO_UP_TO_DATE;
995 if ( policy == RefreshForced )
997 MIL <<
"Forced refresh!" << endl;
998 return REFRESH_NEEDED;
1003 policy = RefreshIfNeededIgnoreDelay;
1007 if ( policy != RefreshIfNeededIgnoreDelay )
1010 double diff = difftime(
1016 DBG <<
"last refresh = " << diff <<
" minutes ago" << endl;
1022 WAR <<
"Repository '" << info.
alias() <<
"' was refreshed in the future!" << endl;
1026 MIL <<
"Repository '" << info.
alias()
1027 <<
"' has been refreshed less than repo.refresh.delay (" 1029 <<
") minutes ago. Advising to skip refresh" << endl;
1030 return REPO_CHECK_DELAYED;
1038 repokind = probe( url, info.
path() );
1042 switch ( repokind.
toEnum() )
1059 newstatus =
RepoStatus( MediaMounter(url).getPathName(info.
path()) );
1069 if ( oldstatus == newstatus )
1071 MIL <<
"repo has not changed" << endl;
1072 touchIndexFile( info );
1073 return REPO_UP_TO_DATE;
1077 MIL <<
"repo has changed, going to refresh" << endl;
1078 return REFRESH_NEEDED;
1084 ERR <<
"refresh check failed for " << url << endl;
1088 return REFRESH_NEEDED;
1098 RepoException rexception( info,
PL_(
"Valid metadata not found at specified URL",
1099 "Valid metadata not found at specified URLs",
1113 if (checkIfToRefreshMetadata(info, url, policy)!=REFRESH_NEEDED)
1116 MIL <<
"Going to refresh metadata from " << url << endl;
1124 if ( repokind != probed )
1130 for_( it, repoBegin(), repoEnd() )
1132 if ( info.
alias() == (*it).alias() )
1135 modifiedrepo.
setType( repokind );
1136 modifyRepository( info.
alias(), modifiedrepo );
1143 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1154 Exception ex(
_(
"Can't create metadata cache directory."));
1162 shared_ptr<repo::Downloader> downloader_ptr;
1164 MIL <<
"Creating downloader for [ " << info.
alias() <<
" ]" << endl;
1177 for_( it, repoBegin(), repoEnd() )
1179 Pathname cachepath(rawcache_path_for_repoinfo( _options, *it ));
1180 if ( PathInfo(cachepath).isExist() )
1181 downloader_ptr->addCachePath(cachepath);
1184 downloader_ptr->download( media, tmpdir.
path() );
1188 MediaMounter media( url );
1191 Pathname productpath( tmpdir.
path() / info.
path() );
1203 if ( ! isTmpRepo( info ) )
1212 ERR <<
"Trying another url..." << endl;
1224 ERR <<
"No more urls..." << endl;
1233 progress.
sendTo(progressfnc);
1243 progress.
sendTo(progressfnc);
1253 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1254 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
1261 RepoStatus raw_metadata_status = metadataStatus(info);
1262 if ( raw_metadata_status.
empty() )
1267 refreshMetadata(info, RefreshIfNeeded, progressrcv );
1268 raw_metadata_status = metadataStatus(info);
1271 bool needs_cleaning =
false;
1272 if ( isCached( info ) )
1274 MIL << info.
alias() <<
" is already cached." << endl;
1277 if ( cache_status == raw_metadata_status )
1279 MIL << info.
alias() <<
" cache is up to date with metadata." << endl;
1280 if ( policy == BuildIfNeeded )
1283 const Pathname & base = solv_path_for_repoinfo( _options, info);
1284 if ( ! PathInfo(base/
"solv.idx").isExist() )
1290 MIL << info.
alias() <<
" cache rebuild is forced" << endl;
1294 needs_cleaning =
true;
1308 MIL << info.
alias() <<
" building cache..." << info.
type() << endl;
1310 Pathname base = solv_path_for_repoinfo( _options, info);
1318 if( ! PathInfo(base).userMayW() )
1320 Exception ex(
str::form(
_(
"Can't create cache at %s - no writing permissions."), base.c_str()) );
1323 Pathname solvfile = base /
"solv";
1329 switch ( repokind.
toEnum() )
1333 repokind = probeCache( productdatapath );
1339 MIL <<
"repo type is " << repokind << endl;
1341 switch ( repokind.
toEnum() )
1349 scoped_ptr<MediaMounter> forPlainDirs;
1352 cmd.push_back( PathInfo(
"/usr/bin/repo2solv" ).isFile() ?
"repo2solv" :
"repo2solv.sh" );
1354 cmd.push_back(
"-o" );
1355 cmd.push_back( solvfile.asString() );
1356 cmd.push_back(
"-X" );
1360 forPlainDirs.reset(
new MediaMounter( info.
url() ) );
1362 cmd.push_back(
"-R" );
1364 cmd.push_back( forPlainDirs->getPathName( info.
path() ).c_str() );
1367 cmd.push_back( productdatapath.asString() );
1370 std::string errdetail;
1373 WAR <<
" " << output;
1374 if ( errdetail.empty() ) {
1378 errdetail += output;
1381 int ret = prog.
close();
1399 setCacheStatus(info, raw_metadata_status);
1400 MIL <<
"Commit cache.." << endl;
1415 MIL <<
"going to probe the repo type at " << url <<
" (" << path <<
")" << endl;
1421 MIL <<
"Probed type NONE (not exists) at " << url <<
" (" << path <<
")" << endl;
1433 bool gotMediaException =
false;
1441 MIL <<
"Probed type RPMMD at " << url <<
" (" << path <<
")" << endl;
1448 DBG <<
"problem checking for repodata/repomd.xml file" << endl;
1450 gotMediaException =
true;
1457 MIL <<
"Probed type YAST2 at " << url <<
" (" << path <<
")" << endl;
1464 DBG <<
"problem checking for content file" << endl;
1466 gotMediaException =
true;
1472 MediaMounter media( url );
1473 if ( PathInfo(media.getPathName()/path).isDir() )
1476 MIL <<
"Probed type RPMPLAINDIR at " << url <<
" (" << path <<
")" << endl;
1490 if (gotMediaException)
1493 MIL <<
"Probed type NONE at " << url <<
" (" << path <<
")" << endl;
1504 MIL <<
"going to probe the cached repo at " << path_r << endl;
1508 if ( PathInfo(path_r/
"/repodata/repomd.xml").isFile() )
1510 else if ( PathInfo(path_r/
"/content").isFile() )
1512 else if ( PathInfo(path_r).isDir() )
1515 MIL <<
"Probed cached type " << ret <<
" at " << path_r << endl;
1523 MIL <<
"Going to clean up garbage in cache dirs" << endl;
1526 progress.
sendTo(progressrcv);
1529 std::list<Pathname> cachedirs;
1530 cachedirs.push_back(_options.repoRawCachePath);
1531 cachedirs.push_back(_options.repoPackagesCachePath);
1532 cachedirs.push_back(_options.repoSolvCachePath);
1534 for_( dir, cachedirs.begin(), cachedirs.end() )
1536 if ( PathInfo(*dir).isExist() )
1538 std::list<Pathname> entries;
1543 unsigned sdircount = entries.size();
1544 unsigned sdircurrent = 1;
1545 for_( subdir, entries.begin(), entries.end() )
1549 for_( r, repoBegin(), repoEnd() )
1550 if ( subdir->basename() == r->escaped_alias() )
1551 { found =
true;
break; }
1556 progress.
set( progress.
val() + sdircurrent * 100 / sdircount );
1561 progress.
set( progress.
val() + 100 );
1571 progress.
sendTo(progressrcv);
1574 MIL <<
"Removing raw metadata cache for " << info.
alias() << endl;
1585 Pathname solvfile = solv_path_for_repoinfo(_options, info) /
"solv";
1587 if ( ! PathInfo(solvfile).isExist() )
1597 if ( toolversion != LIBSOLV_TOOLVERSION )
1606 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1607 cleanCache( info, progressrcv );
1608 buildCache( info, BuildIfNeeded, progressrcv );
1626 MIL <<
"Try adding repo " << info << endl;
1633 if ( _options.probe )
1635 DBG <<
"unknown repository type, probing" << endl;
1636 assert_urls(tosave);
1650 Pathname repofile = generateNonExistingName(
1651 _options.knownReposPath, generateFilename(tosave));
1653 MIL <<
"Saving repo in " << repofile << endl;
1655 std::ofstream file(repofile.c_str());
1664 tosave.
setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1665 tosave.
setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1669 RepoInfo & oinfo( const_cast<RepoInfo &>(info) );
1671 oinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1672 oinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1674 reposManip().insert(tosave);
1679 UrlCredentialExtractor( _options.rootDir ).collect( tosave.
baseUrls() );
1684 MIL <<
"done" << endl;
1691 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
1696 for_ ( kit, repoBegin(), repoEnd() )
1698 if ( (*it).alias() == (*kit).alias() )
1700 ERR <<
"To be added repo " << (*it).alias() <<
" conflicts with existing repo " << (*kit).alias() << endl;
1706 std::string filename = Pathname(url.
getPathName()).basename();
1708 if ( filename == Pathname() )
1717 Pathname repofile = generateNonExistingName(_options.knownReposPath, filename);
1719 MIL <<
"Saving " << repos.size() <<
" repo" << ( repos.size() ?
"s" :
"" ) <<
" in " << repofile << endl;
1721 std::ofstream file(repofile.c_str());
1728 for ( std::list<RepoInfo>::iterator it = repos.begin();
1732 MIL <<
"Saving " << (*it).alias() << endl;
1733 it->dumpAsIniOn(file);
1734 it->setFilepath(repofile);
1735 it->setMetadataPath( rawcache_path_for_repoinfo( _options, *it ) );
1736 it->setPackagesPath( packagescache_path_for_repoinfo( _options, *it ) );
1737 reposManip().insert(*it);
1742 MIL <<
"done" << endl;
1754 MIL <<
"Going to delete repo " << info.
alias() << endl;
1756 for_( it, repoBegin(), repoEnd() )
1761 if ( (!info.
alias().empty()) && ( info.
alias() != (*it).alias() ) )
1776 std::list<RepoInfo> filerepos = repositories_in_file(todelete.
filepath());
1777 if ( filerepos.size() == 0
1778 ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.
alias() ) )
1782 if ( ! ( ret == 0 || ret == ENOENT ) )
1787 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1799 std::ofstream file(todelete.
filepath().c_str());
1805 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1806 fit != filerepos.end();
1809 if ( (*fit).alias() != todelete.
alias() )
1810 (*fit).dumpAsIniOn(file);
1818 if ( isCached(todelete) )
1819 cleanCache( todelete, cSubprogrcv);
1821 cleanMetadata( todelete, mSubprogrcv );
1822 cleanPackages( todelete, pSubprogrcv );
1823 reposManip().erase(todelete);
1824 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1838 RepoInfo toedit = getRepositoryInfo(alias);
1842 if ( alias != newinfo.
alias() && hasRepo( newinfo.
alias() ) )
1854 std::list<RepoInfo> filerepos = repositories_in_file(toedit.
filepath());
1864 std::ofstream file(toedit.
filepath().c_str());
1870 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1871 fit != filerepos.end();
1876 if ( (*fit).alias() != toedit.
alias() )
1877 (*fit).dumpAsIniOn(file);
1885 const Pathname & solvidx = solv_path_for_repoinfo(_options, newinfo)/
"solv.idx";
1886 if ( PathInfo(solvidx).isExist() )
1891 newinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1892 newinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1896 RepoInfo & oinfo( const_cast<RepoInfo &>(newinfo_r) );
1898 oinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1899 oinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1901 reposManip().erase(toedit);
1902 reposManip().insert(newinfo);
1904 UrlCredentialExtractor( _options.rootDir ).collect( newinfo.
baseUrls() );
1906 MIL <<
"repo " << alias <<
" modified" << endl;
1915 if ( it !=
repos().end() )
1925 for_( it, repoBegin(), repoEnd() )
1927 for_( urlit, (*it).baseUrlsBegin(), (*it).baseUrlsEnd() )
1929 if ( (*urlit).asString(urlview) == url.
asString(urlview) )
1946 assert_alias( service );
1949 if ( hasService( service.
alias() ) )
1955 saveService( toSave );
1959 UrlCredentialExtractor( _options.rootDir ).collect( toSave.
url() );
1961 MIL <<
"added service " << toSave.
alias() << endl;
1968 MIL <<
"Going to delete service " << alias << endl;
1970 const ServiceInfo & service = getService( alias );
1972 Pathname location = service.
filepath();
1973 if( location.empty() )
1982 if ( tmpSet.size() == 1 )
1989 MIL << alias <<
" successfully deleted." << endl;
1995 std::ofstream file(location.c_str());
2002 for_(it, tmpSet.begin(), tmpSet.end())
2004 if( it->alias() != alias )
2005 it->dumpAsIniOn(file);
2008 MIL << alias <<
" successfully deleted from file " << location << endl;
2012 RepoCollector rcollector;
2013 getRepositoriesInService( alias,
2014 boost::make_function_output_iterator( bind( &RepoCollector::collect, &rcollector, _1 ) ) );
2016 for_(rit, rcollector.repos.begin(), rcollector.repos.end())
2017 removeRepository(*rit);
2026 ServiceSet services( serviceBegin(), serviceEnd() );
2027 for_( it, services.begin(), services.end() )
2029 if ( !it->enabled() )
2033 refreshService(*it, options_r);
2043 assert_alias( service );
2044 assert_url( service );
2045 MIL <<
"Going to refresh service '" << service.
alias() <<
"', url: " << service.
url() <<
", opts: " << options_r << endl;
2047 if ( service.
ttl() && !( options_r.testFlag( RefreshService_forceRefresh) || options_r.testFlag( RefreshService_restoreStatus ) ) )
2056 if ( (lrf+=service.
ttl()) > now )
2058 MIL <<
"Skip: '" << service.
alias() <<
"' metadata valid until " << lrf << endl;
2063 WAR <<
"Force: '" << service.
alias() <<
"' metadata last refresh in the future: " << lrf << endl;
2070 bool serviceModified =
false;
2081 serviceModified =
true;
2086 std::string servicesTargetDistro = _options.servicesTargetDistro;
2087 if ( servicesTargetDistro.empty() )
2091 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << endl;
2095 RepoCollector collector(servicesTargetDistro);
2102 ServiceRepos( service, bind( &RepoCollector::collect, &collector, _1 ) );
2107 uglyHack.first =
true;
2108 uglyHack.second = e;
2110 if ( service.
ttl() != origTtl )
2112 if ( !service.
ttl() )
2114 serviceModified =
true;
2122 for_( it, collector.repos.begin(), collector.repos.end() )
2125 it->setAlias(
str::form(
"%s:%s", service.
alias().c_str(), it->alias().c_str() ) );
2127 it->setService( service.
alias() );
2130 newRepoStates[it->alias()] = *it;
2138 if ( !it->path().empty() )
2140 if ( it->path() !=
"/" )
2145 if ( it->baseUrlsEmpty() )
2148 if ( !path.empty() )
2150 it->setBaseUrl( std::move(url) );
2152 else if ( !path.empty() )
2155 for (
Url & url : urls )
2159 it->setBaseUrls( std::move(urls) );
2166 RepoInfoList oldRepos;
2167 getRepositoriesInService( service.
alias(), std::back_inserter( oldRepos ) );
2171 for_( oldRepo, oldRepos.begin(), oldRepos.end() )
2173 if ( ! foundAliasIn( oldRepo->alias(), collector.repos ) )
2175 if ( oldRepo->enabled() )
2178 const auto & last = service.
repoStates().find( oldRepo->alias() );
2179 if ( last != service.
repoStates().end() && ! last->second.enabled )
2181 DBG <<
"Service removes user enabled repo " << oldRepo->alias() << endl;
2183 serviceModified =
true;
2186 DBG <<
"Service removes enabled repo " << oldRepo->alias() << endl;
2189 DBG <<
"Service removes disabled repo " << oldRepo->alias() << endl;
2191 removeRepository( *oldRepo );
2197 UrlCredentialExtractor urlCredentialExtractor( _options.rootDir );
2198 for_( it, collector.repos.begin(), collector.repos.end() )
2204 TriBool toBeEnabled( indeterminate );
2205 DBG <<
"Service request to " << (it->enabled()?
"enable":
"disable") <<
" service repo " << it->alias() << endl;
2207 if ( options_r.testFlag( RefreshService_restoreStatus ) )
2209 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() << endl;
2221 DBG <<
"User request to enable service repo " << it->alias() << endl;
2227 serviceModified =
true;
2231 DBG <<
"User request to disable service repo " << it->alias() << endl;
2232 toBeEnabled =
false;
2236 RepoInfoList::iterator oldRepo( findAlias( it->alias(), oldRepos ) );
2237 if ( oldRepo == oldRepos.end() )
2242 if ( ! indeterminate(toBeEnabled) )
2243 it->setEnabled( toBeEnabled );
2245 DBG <<
"Service adds repo " << it->alias() <<
" " << (it->enabled()?
"enabled":
"disabled") << endl;
2246 addRepository( *it );
2251 bool oldRepoModified =
false;
2253 if ( indeterminate(toBeEnabled) )
2257 if ( oldRepo->enabled() == it->enabled() )
2258 toBeEnabled = it->enabled();
2259 else if (options_r.testFlag( RefreshService_restoreStatus ) )
2261 toBeEnabled = it->enabled();
2262 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() <<
" forces " << (toBeEnabled?
"enabled":
"disabled") << endl;
2266 const auto & last = service.
repoStates().find( oldRepo->alias() );
2267 if ( last == service.
repoStates().end() || last->second.enabled != it->enabled() )
2268 toBeEnabled = it->enabled();
2271 toBeEnabled = oldRepo->enabled();
2272 DBG <<
"User modified service repo " << it->alias() <<
" may stay " << (toBeEnabled?
"enabled":
"disabled") << endl;
2278 if ( toBeEnabled == oldRepo->enabled() )
2280 DBG <<
"Service repo " << it->alias() <<
" stays " << (oldRepo->enabled()?
"enabled":
"disabled") << endl;
2282 else if ( toBeEnabled )
2284 DBG <<
"Service repo " << it->alias() <<
" gets enabled" << endl;
2285 oldRepo->setEnabled(
true );
2286 oldRepoModified =
true;
2290 DBG <<
"Service repo " << it->alias() <<
" gets disabled" << endl;
2291 oldRepo->setEnabled(
false );
2292 oldRepoModified =
true;
2298 if ( oldRepo->rawName() != it->rawName() )
2300 DBG <<
"Service repo " << it->alias() <<
" gets new NAME " << it->rawName() << endl;
2301 oldRepo->setName( it->rawName() );
2302 oldRepoModified =
true;
2306 if ( oldRepo->autorefresh() != it->autorefresh() )
2308 DBG <<
"Service repo " << it->alias() <<
" gets new AUTOREFRESH " << it->autorefresh() << endl;
2309 oldRepo->setAutorefresh( it->autorefresh() );
2310 oldRepoModified =
true;
2314 if ( oldRepo->priority() != it->priority() )
2316 DBG <<
"Service repo " << it->alias() <<
" gets new PRIORITY " << it->priority() << endl;
2317 oldRepo->setPriority( it->priority() );
2318 oldRepoModified =
true;
2324 urlCredentialExtractor.extract( newUrls );
2325 if ( oldRepo->rawBaseUrls() != newUrls )
2327 DBG <<
"Service repo " << it->alias() <<
" gets new URLs " << newUrls << endl;
2328 oldRepo->setBaseUrls( std::move(newUrls) );
2329 oldRepoModified =
true;
2339 oldRepo->getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
2340 it-> getRawGpgChecks( ngpg[0], ngpg[1], ngpg[2] );
2341 #define Z_CHKGPG(I,N) \ 2342 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \ 2344 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \ 2345 oldRepo->set##N##Check( ngpg[I] ); \ 2346 oldRepoModified = true; \ 2355 if ( oldRepoModified )
2357 modifyRepository( oldRepo->alias(), *oldRepo );
2366 serviceModified =
true;
2373 serviceModified =
true;
2380 if ( service.
ttl() )
2383 serviceModified =
true;
2386 if ( serviceModified )
2389 modifyService( service.
alias(), service );
2393 if ( uglyHack.first )
2395 throw( uglyHack.second );
2403 MIL <<
"Going to modify service " << oldAlias << endl;
2414 const ServiceInfo & oldService = getService(oldAlias);
2416 Pathname location = oldService.
filepath();
2417 if( location.empty() )
2427 std::ofstream file(location.c_str());
2428 for_(it, tmpSet.begin(), tmpSet.end())
2430 if( *it != oldAlias )
2431 it->dumpAsIniOn(file);
2440 UrlCredentialExtractor( _options.rootDir ).collect( service.
url() );
2444 if ( oldAlias != service.
alias()
2447 std::vector<RepoInfo> toModify;
2448 getRepositoriesInService(oldAlias, std::back_inserter(toModify));
2449 for_( it, toModify.begin(), toModify.end() )
2456 const auto & last = service.
repoStates().find( it->alias() );
2458 it->setEnabled( last->second.enabled );
2461 it->setEnabled(
false );
2464 if ( oldAlias != service.
alias() )
2465 it->setService(service.
alias());
2467 modifyRepository(it->alias(), *it);
2511 : _pimpl( new
Impl(opt) )
2543 std::string host( url_r.
getHost() );
2544 if ( ! host.empty() )
2666 {
return str << *obj.
_pimpl; }
void setPassword(const std::string &pass, EEncoding eflag=zypp::url::E_DECODED)
Set the password in the URL authority.
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
Pathname packagesPath(const RepoInfo &info) const
RepoManager(const RepoManagerOptions &options=RepoManagerOptions())
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.
thrown when it was impossible to match a repository
Thrown when the repo alias is found to be invalid.
RepoManagerOptions(const Pathname &root_r=Pathname())
Default ctor following ZConfig global settings.
bool hasService(const std::string &alias) const
std::string alias() const
unique identifier for this source.
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.
void setCacheStatus(const RepoInfo &info, const RepoStatus &status)
std::string generateFilename(const ServiceInfo &info) const
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.
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
void refreshServices(const RefreshServiceOptions &options_r)
Pathname repoRawCachePath
bool serviceEmpty() const
Gets true if no service is in RepoManager (so no one in specified location)
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.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Date timestamp() const
The time the data were changed the last time.
ServiceConstIterator serviceBegin() const
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)
scoped_ptr< media::CredentialManager > _cmPtr
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
void cleanCacheDirGarbage(const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove any subdirectories of cache directories which no longer belong to any of known repositories...
RepoConstIterator repoBegin() const
Pathname filepath() const
File where this repo was read from.
bool isCached(const RepoInfo &info) const
void refreshServices(const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refreshes all enabled services.
Service plugin is immutable.
RepoStatus metadataStatus(const RepoInfo &info) const
Status of local metadata.
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
bool empty() const
Test for an empty path.
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
Pathname metadataPath(const RepoInfo &info) const
Path where the metadata is downloaded and kept.
const std::string & command() const
The command we're executing.
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
RepoSet::size_type RepoSizeType
bool empty() const
Whether the status is empty (default constucted)
void loadFromCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Load resolvables into the pool.
ServiceConstIterator serviceEnd() const
Iterator to place behind last service in internal storage.
repo::RepoType probe(const Url &url, const Pathname &path) const
Probe repo metadata type.
std::string generateFilename(const RepoInfo &info) const
RepoConstIterator repoBegin() const
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.
Pathname packagesPath(const RepoInfo &info) const
Path where the rpm packages are downloaded and kept.
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).
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects...
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.
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.
const RepoSet & repos() const
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
const RepoStates & repoStates() const
Access the remembered repository states.
Pathname knownServicesPath
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
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)
bool repo_add_probe() const
Whether repository urls should be probed.
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
std::string targetDistribution() const
This is register.target attribute of the installed base product.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
Service without alias was used in an operation.
RepoStatus metadataStatus(const RepoInfo &info) const
RepoSet::const_iterator RepoConstIterator
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Url::asString() view options.
void cleanMetadata(const RepoInfo &info, OPT_PROGRESS)
repo::RepoType probeCache(const Pathname &path_r) const
Probe Metadata in a local cache directory.
#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
RepoManagerOptions _options
std::string asString() const
Returns a default string representation of the Url object.
ServiceInfo getService(const std::string &alias) const
RepoSizeType repoSize() const
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
std::string label() const
Label for use in messages for the user interface.
void addRepository(const RepoInfo &info, OPT_PROGRESS)
static const ServiceType RIS
Repository Index Service (RIS) (formerly known as 'Novell Update' (NU) service)
RepoManager implementation.
#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.
Store and operate on date (time_t).
static Pool instance()
Singleton ctor.
bool serviceEmpty() 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
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...
void clearReposToDisable()
Clear the set of ReposToDisable.
Lightweight repository attribute value lookup.
std::string asCompleteString() const
Returns a complete string representation of the Url object.
RepoConstIterator repoEnd() const
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.
static const ServiceType NONE
No service set.
static const SolvAttr repositoryToolVersion
Service type enumeration.
void modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, OPT_PROGRESS)
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)
repo::ServiceType probeService(const Url &url) const
Probe the type or the service.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
void setType(const repo::RepoType &t)
set the repository type
Maintain [min,max] and counter (value) for progress counting.
Date::Duration ttl() const
Sugested TTL between two metadata auto-refreshs.
RepoStatus cacheStatus(const RepoInfo &info) const
Pathname generateNonExistingName(const Pathname &dir, const std::string &basefilename) const
Generate a non existing filename in a directory, using a base name.
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.
RepoInfo getRepo(const std::string &alias) const
Writing the zypp history fileReference counted signleton for writhing the zypp history file...
static bool schemeIsVolatile(const std::string &scheme_r)
cd dvd
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.
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
void cleanCache(const RepoInfo &info, OPT_PROGRESS)
std::string numstring(char n, int w=0)
ServiceSet::size_type ServiceSizeType
bool reposToDisableEmpty() const
static const RepoType NONE
int touch(const Pathname &path)
Change file's modification and access times.
void resetDispose()
Set no dispose function.
ServiceInfo getService(const std::string &alias) const
Finds ServiceInfo by alias or return ServiceInfo::noService.
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
url_set baseUrls() const
The complete set of repository urls.
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
int close()
Wait for the progamm to complete.
bool hasRepo(const std::string &alias) const
Return whether there is a known repository for alias.
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).
RepoStatus cacheStatus(const RepoInfo &info) const
Status of metadata cache.
repo::RepoType type() const
Type of repository,.
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
RepoSizeType repoSize() const
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...
RepoInfo getRepo(const std::string &alias) const
Find RepoInfo by alias or return RepoInfo::noRepo.
Url rawUrl() const
The service raw url (no variables replaced)
static const RepoType YAST2
thrown when it was impossible to determine an alias for this repo.
void buildCache(const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local cache.
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.
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
Exception for repository handling.
void saveService(ServiceInfo &service) const
Impl(const RepoManagerOptions &opt)
media::MediaAccessId _mid
static Date now()
Return the current time.
repo::RepoType probe(const Url &url, const Pathname &path=Pathname()) const
Probe the metadata type of a repository located at url.
bool ZYPP_PLUGIN_APPDATA_FORCE_COLLECT()
To trigger appdata refresh unconditionally.
DefaultIntegral< bool, false > _reposDirty
ServiceConstIterator serviceEnd() const
Functor thats filter RepoInfo by service which it belongs to.
bool isCached(const RepoInfo &info) const
Whether a repository exists in cache.
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
bool hasRepo(const std::string &alias) 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...
Url url() const
Pars pro toto: The first repository url.
void eraseFromPool()
Remove this Repository from it's Pool.
Pathname repoPackagesCachePath
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
static const ServiceInfo noService
Represents an empty service.
RepoConstIterator repoEnd() const
bool hasService(const std::string &alias) const
Return whether there is a known service for alias.
void removeService(const std::string &alias)
void buildCache(const RepoInfo &info, CacheBuildPolicy policy, OPT_PROGRESS)
bool repoToDisableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToDisable.
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.
friend std::ostream & operator<<(std::ostream &str, const RepoManager &obj)
ServiceSizeType serviceSize() const
Gets count of service in RepoManager (in specified location)
static const RepoType RPMPLAINDIR
static const std::string & systemRepoAlias()
Reserved system repository alias .
bool repoToEnableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToEnable.
ServiceSizeType serviceSize() const
Track changing files or directories.
void cleanPackages(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local package cache.
unsigned repo_refresh_delay() const
Amount of time in minutes that must pass before another refresh.
Repository already exists and some unique attribute can't be duplicated.
ServiceConstIterator serviceBegin() const
Iterator to first service in internal storage.
bool set(value_type val_r)
Set new counter value.
std::string getScheme() const
Returns the scheme name of the URL.
Url url() const
The service url.
static bool schemeIsDownloading(const std::string &scheme_r)
http https ftp sftp tftp
void modifyRepository(const RepoInfo &oldrepo, const RepoInfo &newrepo)
Log certain modifications to a repository.
std::ostream & operator<<(std::ostream &str, const RepoManager::Impl &obj)
Impl * clone() const
clone for RWCOW_pointer
urls_size_type baseUrlsSize() const
number of repository urls
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...
Pathname metadataPath(const RepoInfo &info) const
Easy-to use interface to the ZYPP dependency resolver.
void setProbedType(const repo::ServiceType &t) const
Lazy init service type.
void cleanPackages(const RepoInfo &info, OPT_PROGRESS)
void loadFromCache(const RepoInfo &info, OPT_PROGRESS)
std::string hexstring(char n, int w=4)
std::string asUserString() const
Translated error message as string suitable for the user.
void addService(const std::string &alias, const Url &url)
Adds new service by it's alias and url.
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, OPT_PROGRESS)
Service has no or invalid url defined.
static bool schemeIsLocal(const std::string &scheme_r)
hd cd dvd dir file iso
Date lrf() const
Date of last refresh (if known).
void addRepositories(const Url &url, OPT_PROGRESS)
void cleanMetadata(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local metadata.
Pathname path() const
Repository path.
bool hasCredentialsInAuthority() const
Returns true if username and password are encoded in the authority component.
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Writes ServiceInfo to stream in ".service" format.
repo::ServiceType type() const
Service type.
Repository type enumeration.
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy)
repo::ServiceType probeService(const Url &url) const