21 #include <solv/solvversion.h> 23 #include <zypp-core/base/InputStream> 24 #include <zypp/base/LogTools.h> 25 #include <zypp/base/Gettext.h> 26 #include <zypp-core/base/DefaultIntegral> 27 #include <zypp/base/Function.h> 28 #include <zypp/base/Regex.h> 29 #include <zypp/PathInfo.h> 30 #include <zypp/TmpPath.h> 37 #include <zypp-media/auth/CredentialManager> 38 #include <zypp-media/MediaException> 40 #include <zypp/ExternalProgram.h> 41 #include <zypp/ManagedFile.h> 46 #include <zypp/repo/yum/Downloader.h> 47 #include <zypp/repo/susetags/Downloader.h> 63 #define OPT_PROGRESS const ProgressData::ReceiverFnc & = ProgressData::ReceiverFnc() 75 const char * env = getenv(
"ZYPP_PLUGIN_APPDATA_FORCE_COLLECT");
105 class UrlCredentialExtractor
108 UrlCredentialExtractor( Pathname & root_r )
112 ~UrlCredentialExtractor()
116 bool collect(
const Url & url_r )
118 bool ret = url_r.hasCredentialsInAuthority();
122 _cmPtr->addUserCred( url_r );
127 template<
class TContainer>
128 bool collect(
const TContainer & urls_r )
129 {
bool ret =
false;
for (
const Url & url : urls_r ) {
if ( collect( url ) && !ret ) ret =
true; }
return ret; }
132 bool extract( Url & url_r )
134 bool ret = collect( url_r );
136 url_r.setPassword( std::string() );
140 template<
class TContainer>
141 bool extract( TContainer & urls_r )
142 {
bool ret =
false;
for ( Url & url : urls_r ) {
if ( extract( url ) && !ret ) ret =
true; }
return ret; }
146 scoped_ptr<media::CredentialManager>
_cmPtr;
161 MediaMounter(
const Url & url_r )
163 media::MediaManager mediamanager;
164 _mid = mediamanager.open( url_r );
165 mediamanager.attach(
_mid );
171 media::MediaManager mediamanager;
172 mediamanager.release(
_mid );
173 mediamanager.close(
_mid );
180 Pathname getPathName(
const Pathname & path_r = Pathname() )
const 182 media::MediaManager mediamanager;
183 return mediamanager.localPath(
_mid, path_r );
192 template <
class Iterator>
193 inline bool foundAliasIn(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
195 for_( it, begin_r, end_r )
196 if ( it->alias() == alias_r )
201 template <
class Container>
202 inline bool foundAliasIn(
const std::string & alias_r,
const Container & cont_r )
203 {
return foundAliasIn( alias_r, cont_r.begin(), cont_r.end() ); }
206 template <
class Iterator>
207 inline Iterator findAlias(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
209 for_( it, begin_r, end_r )
210 if ( it->alias() == alias_r )
215 template <
class Container>
216 inline typename Container::iterator findAlias(
const std::string & alias_r, Container & cont_r )
217 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
219 template <
class Container>
220 inline typename Container::const_iterator findAlias(
const std::string & alias_r,
const Container & cont_r )
221 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
225 inline std::string filenameFromAlias(
const std::string & alias_r,
const std::string & stem_r )
227 std::string filename( alias_r );
231 filename = Pathname(filename).extend(
"."+stem_r).asString();
232 MIL <<
"generating filename for " << stem_r <<
" [" << alias_r <<
"] : '" << filename <<
"'" << endl;
256 RepoCollector(
const std::string & targetDistro_)
260 bool collect(
const RepoInfo &repo )
264 && !repo.targetDistribution().empty()
268 <<
"Skipping repository meant for '" << repo.targetDistribution()
269 <<
"' distribution (current distro is '" 275 repos.push_back(repo);
289 std::list<RepoInfo> repositories_in_file(
const Pathname & file )
291 MIL <<
"repo file: " << file << endl;
292 RepoCollector collector;
293 parser::RepoFileReader parser( file, bind( &RepoCollector::collect, &collector, _1 ) );
294 return std::move(collector.repos);
307 std::list<RepoInfo> repositories_in_dir(
const Pathname &dir )
309 MIL <<
"directory " << dir << endl;
310 std::list<RepoInfo>
repos;
311 bool nonroot( geteuid() != 0 );
312 if ( nonroot && ! PathInfo(dir).userMayRX() )
314 JobReport::warning( str::Format(
_(
"Cannot read repo directory '%1%': Permission denied")) % dir );
318 std::list<Pathname> entries;
325 str::regex allowedRepoExt(
"^\\.repo(_[0-9]+)?$");
326 for ( std::list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
330 if ( nonroot && ! PathInfo(*it).userMayR() )
332 JobReport::warning( str::Format(
_(
"Cannot read repo file '%1%': Permission denied")) % *it );
336 const std::list<RepoInfo> & tmp( repositories_in_file( *it ) );
337 repos.insert(
repos.end(), tmp.begin(), tmp.end() );
347 inline void assert_alias(
const RepoInfo & info )
349 if ( info.alias().empty() )
353 if ( info.alias()[0] ==
'.')
355 info,
_(
"Repository alias cannot start with dot.")));
358 inline void assert_alias(
const ServiceInfo & info )
360 if ( info.alias().empty() )
364 if ( info.alias()[0] ==
'.')
366 info,
_(
"Service alias cannot start with dot.")));
371 inline void assert_urls(
const RepoInfo & info )
373 if ( info.baseUrlsEmpty() )
377 inline void assert_url(
const ServiceInfo & info )
379 if ( ! info.url().isValid() )
389 inline bool isTmpRepo(
const RepoInfo & info_r )
390 {
return( info_r.filepath().empty() && info_r.usesAutoMethadataPaths() ); }
398 inline Pathname rawcache_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
401 return isTmpRepo( info ) ? info.metadataPath() : opt.repoRawCachePath / info.escaped_alias();
412 inline Pathname rawproductdata_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
413 {
return rawcache_path_for_repoinfo( opt, info ) / info.path(); }
418 inline Pathname packagescache_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
421 return isTmpRepo( info ) ? info.packagesPath() : opt.repoPackagesCachePath / info.escaped_alias();
427 inline Pathname solv_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
430 return isTmpRepo( info ) ? info.metadataPath().dirname() /
"%SLV%" : opt.repoSolvCachePath / info.escaped_alias();
436 class ServiceCollector
439 typedef std::set<ServiceInfo> ServiceSet;
441 ServiceCollector( ServiceSet & services_r )
445 bool operator()(
const ServiceInfo & service_r )
const 463 DBG <<
"reading repo file " << repo_file <<
", local path: " << local << endl;
465 return repositories_in_file(local);
504 #define OUTS(X) str << " " #X "\t" << obj.X << endl 505 str <<
"RepoManagerOptions (" << obj.
rootDir <<
") {" << endl;
506 OUTS( repoRawCachePath );
507 OUTS( repoSolvCachePath );
508 OUTS( repoPackagesCachePath );
509 OUTS( knownReposPath );
510 OUTS( knownServicesPath );
527 , _pluginRepoverification( _options.pluginsPath/
"repoverification", _options.rootDir )
529 init_knownServices();
530 init_knownRepositories();
537 && geteuid() == 0 && ( _options.rootDir.empty() || _options.rootDir ==
"/" ) )
540 std::list<Pathname> entries;
542 if ( ! entries.empty() )
545 cmd.push_back(
"<" );
546 cmd.push_back(
">" );
547 cmd.push_back(
"PROGRAM" );
548 for (
const auto & rinfo :
repos() )
550 if ( ! rinfo.enabled() )
552 cmd.push_back(
"-R" );
553 cmd.push_back( rinfo.alias() );
554 cmd.push_back(
"-t" );
555 cmd.push_back( rinfo.type().asString() );
556 cmd.push_back(
"-p" );
557 cmd.push_back( (rinfo.metadataPath()/rinfo.path()).
asString() );
560 for_( it, entries.begin(), entries.end() )
583 bool hasRepo(
const std::string & alias )
const 584 {
return foundAliasIn( alias,
repos() ); }
594 {
return rawcache_path_for_repoinfo( _options, info ); }
597 {
return packagescache_path_for_repoinfo( _options, info ); }
601 RefreshCheckStatus checkIfToRefreshMetadata(
const RepoInfo & info,
const Url & url, RawMetadataRefreshPolicy policy );
619 {
return PathInfo(solv_path_for_repoinfo( _options, info ) /
"solv").
isExist(); }
644 {
return foundAliasIn( alias,
_services ); }
657 void removeService(
const std::string & alias );
659 { removeService( service.
alias() ); }
661 void refreshServices(
const RefreshServiceOptions & options_r );
663 void refreshService(
const std::string & alias,
const RefreshServiceOptions & options_r );
665 { refreshService( service.
alias(), options_r ); }
667 void modifyService(
const std::string & oldAlias,
const ServiceInfo & newService );
674 Pathname generateNonExistingName(
const Pathname & dir,
const std::string & basefilename )
const;
677 {
return filenameFromAlias( info.
alias(),
"repo" ); }
680 {
return filenameFromAlias( info.
alias(),
"service" ); }
684 Pathname base = solv_path_for_repoinfo( _options, info );
689 void touchIndexFile(
const RepoInfo & info );
691 template<
typename OutputIterator>
696 boost::make_filter_iterator( filter,
repos().end(),
repos().end() ),
701 void init_knownServices();
702 void init_knownRepositories();
717 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
720 {
return new Impl( *
this ); }
726 {
return str <<
"RepoManager::Impl"; }
730 void RepoManager::Impl::saveService( ServiceInfo & service )
const 733 Pathname servfile = generateNonExistingName( _options.knownServicesPath,
734 generateFilename( service ) );
735 service.setFilepath( servfile );
737 MIL <<
"saving service in " << servfile << endl;
739 std::ofstream file( servfile.c_str() );
745 service.dumpAsIniOn( file );
746 MIL <<
"done" << endl;
764 Pathname RepoManager::Impl::generateNonExistingName(
const Pathname & dir,
765 const std::string & basefilename )
const 767 std::string final_filename = basefilename;
769 while ( PathInfo(dir + final_filename).isExist() )
774 return dir + Pathname(final_filename);
779 void RepoManager::Impl::init_knownServices()
781 Pathname dir = _options.knownServicesPath;
782 std::list<Pathname> entries;
783 if (PathInfo(dir).isExist())
792 for_(it, entries.begin(), entries.end() )
794 parser::ServiceFileReader(*it, ServiceCollector(
_services));
798 repo::PluginServices(_options.pluginsPath/
"services", ServiceCollector(
_services));
808 inline void cleanupNonRepoMetadtaFolders(
const Pathname & cachePath_r,
809 const Pathname & defaultCachePath_r,
810 const std::list<std::string> & repoEscAliases_r )
812 if ( cachePath_r != defaultCachePath_r )
815 std::list<std::string> entries;
819 std::set<std::string> oldfiles;
820 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
821 std::inserter( oldfiles, oldfiles.end() ) );
827 for (
const std::string & old : oldfiles )
831 pi( cachePath_r/old );
841 void RepoManager::Impl::init_knownRepositories()
843 MIL <<
"start construct known repos" << endl;
845 if ( PathInfo(_options.knownReposPath).isExist() )
847 std::list<std::string> repoEscAliases;
848 std::list<RepoInfo> orphanedRepos;
849 for ( RepoInfo & repoInfo : repositories_in_dir(_options.knownReposPath) )
852 repoInfo.setMetadataPath( rawcache_path_for_repoinfo(_options, repoInfo) );
854 repoInfo.setPackagesPath( packagescache_path_for_repoinfo(_options, repoInfo) );
856 _reposX.insert( repoInfo );
859 const std::string & serviceAlias( repoInfo.service() );
860 if ( ! ( serviceAlias.empty() || hasService( serviceAlias ) ) )
862 WAR <<
"Schedule orphaned service repo for deletion: " << repoInfo << endl;
863 orphanedRepos.push_back( repoInfo );
867 repoEscAliases.push_back(repoInfo.escaped_alias());
871 if ( ! orphanedRepos.empty() )
873 for (
const auto & repoInfo : orphanedRepos )
875 MIL <<
"Delete orphaned service repo " << repoInfo.alias() << endl;
879 JobReport::warning( str::Format(
_(
"Unknown service '%1%': Removing orphaned service repository '%2%'"))
881 % repoInfo.alias() );
883 removeRepository( repoInfo );
885 catch (
const Exception & caugth )
897 repoEscAliases.sort();
898 cleanupNonRepoMetadtaFolders( _options.repoRawCachePath,
901 cleanupNonRepoMetadtaFolders( _options.repoSolvCachePath,
904 cleanupNonRepoMetadtaFolders( _options.repoPackagesCachePath,
908 MIL <<
"end construct known repos" << endl;
913 RepoStatus RepoManager::Impl::metadataStatus(
const RepoInfo & info )
const 915 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
916 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
921 repokind = probeCache( productdatapath );
928 switch ( repokind.
toEnum() )
931 status = RepoStatus( productdatapath/
"repodata/repomd.xml") && RepoStatus( mediarootpath/
"media.1/media" );
935 status = RepoStatus( productdatapath/
"content" ) && RepoStatus( mediarootpath/
"media.1/media" );
949 if ( ! status.empty() )
950 status = status && RepoStatus( info );
956 void RepoManager::Impl::touchIndexFile(
const RepoInfo & info )
958 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
963 repokind = probeCache( productdatapath );
969 switch ( repokind.
toEnum() )
972 p = Pathname(productdatapath +
"/repodata/repomd.xml");
976 p = Pathname(productdatapath +
"/content");
980 p = Pathname(productdatapath +
"/cookie");
998 MIL <<
"Check if to refresh repo " << info.alias() <<
" at " << url <<
" (" << info.type() <<
")" << endl;
1001 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1003 RepoStatus oldstatus = metadataStatus( info );
1005 if ( oldstatus.empty() )
1007 MIL <<
"No cached metadata, going to refresh" << endl;
1008 return REFRESH_NEEDED;
1011 if ( url.schemeIsVolatile() )
1013 MIL <<
"Never refresh CD/DVD" << endl;
1014 return REPO_UP_TO_DATE;
1017 if ( policy == RefreshForced )
1019 MIL <<
"Forced refresh!" << endl;
1020 return REFRESH_NEEDED;
1023 if ( url.schemeIsLocal() )
1025 policy = RefreshIfNeededIgnoreDelay;
1029 if ( policy != RefreshIfNeededIgnoreDelay )
1034 RepoStatus cachestatus = cacheStatus( info );
1036 if ( oldstatus == cachestatus )
1044 WAR <<
"Repository '" << info.alias() <<
"' was refreshed in the future!" << endl;
1048 MIL <<
"Repository '" << info.alias()
1049 <<
"' has been refreshed less than repo.refresh.delay (" 1051 <<
") minutes ago. Advising to skip refresh" << endl;
1052 return REPO_CHECK_DELAYED;
1057 MIL <<
"Metadata and solv cache don't match. Check data on server..." << endl;
1061 repo::RepoType repokind = info.type();
1064 repokind = probe( url, info.path() );
1067 RepoStatus newstatus;
1068 switch ( repokind.toEnum() )
1085 newstatus = RepoStatus( info ) && RepoStatus( MediaMounter(url).getPathName(info.path()) );
1095 if ( oldstatus == newstatus )
1097 MIL <<
"repo has not changed" << endl;
1098 touchIndexFile( info );
1099 return REPO_UP_TO_DATE;
1103 MIL <<
"repo has changed, going to refresh" << endl;
1104 return REFRESH_NEEDED;
1107 catch (
const Exception &e )
1110 ERR <<
"refresh check failed for " << url << endl;
1114 return REFRESH_NEEDED;
1118 void RepoManager::Impl::refreshMetadata(
const RepoInfo & info, RawMetadataRefreshPolicy policy,
const ProgressData::ReceiverFnc & progress )
1124 RepoException rexception( info,
PL_(
"Valid metadata not found at specified URL",
1125 "Valid metadata not found at specified URLs",
1126 info.baseUrlsSize() ) );
1129 media::ScopedDisableMediaChangeReport guard( info.baseUrlsSize() > 1 );
1139 if (checkIfToRefreshMetadata(info, url, policy)!=REFRESH_NEEDED)
1142 MIL <<
"Going to refresh metadata from " << url << endl;
1147 repo::RepoType repokind = info.type();
1149 repo::RepoType probed = probe( *it, info.path() );
1150 if ( repokind != probed )
1154 for_( it, repoBegin(), repoEnd() )
1156 if ( info.alias() == (*it).alias() )
1158 RepoInfo modifiedrepo = *it;
1159 modifiedrepo.setType( repokind );
1166 info.setProbedType( repokind );
1173 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1176 Exception ex(
str::form(
_(
"Can't create %s"), mediarootpath.c_str()) );
1182 if( tmpdir.path().empty() )
1184 Exception ex(
_(
"Can't create metadata cache directory."));
1192 shared_ptr<repo::Downloader> downloader_ptr;
1194 MIL <<
"Creating downloader for [ " << info.alias() <<
" ]" << endl;
1198 if ( _pluginRepoverification.checkIfNeeded() )
1199 downloader_ptr->setPluginRepoverification( _pluginRepoverification );
1210 for_( it, repoBegin(), repoEnd() )
1212 Pathname cachepath(rawcache_path_for_repoinfo( _options, *it ));
1213 if ( PathInfo(cachepath).isExist() )
1214 downloader_ptr->addCachePath(cachepath);
1217 downloader_ptr->download( media, tmpdir.path() );
1222 MediaMounter media( url );
1223 RepoStatus newstatus = RepoStatus( media.getPathName( info.path() ) );
1225 Pathname productpath( tmpdir.path() / info.path() );
1227 newstatus.saveToCookieFile( productpath/
"cookie" );
1237 if ( ! isTmpRepo( info ) )
1243 catch (
const Exception &e )
1246 ERR <<
"Trying another url..." << endl;
1251 if (it == info.baseUrlsBegin())
1252 rexception.remember(e);
1254 rexception.addHistory( e.asUserString() );
1258 ERR <<
"No more urls..." << endl;
1266 ProgressData progress(100);
1267 progress.sendTo(progressfnc);
1276 ProgressData progress(100);
1277 progress.sendTo(progressfnc);
1284 void RepoManager::Impl::buildCache(
const RepoInfo & info, CacheBuildPolicy policy,
const ProgressData::ReceiverFnc & progressrcv )
1287 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1288 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
1292 Exception ex(
str::form(
_(
"Can't create %s"), _options.repoCachePath.c_str()) );
1295 RepoStatus raw_metadata_status = metadataStatus(info);
1296 if ( raw_metadata_status.empty() )
1301 refreshMetadata(info, RefreshIfNeeded, progressrcv );
1302 raw_metadata_status = metadataStatus(info);
1305 bool needs_cleaning =
false;
1306 if ( isCached( info ) )
1308 MIL << info.alias() <<
" is already cached." << endl;
1309 RepoStatus cache_status = cacheStatus(info);
1311 if ( cache_status == raw_metadata_status )
1313 MIL << info.alias() <<
" cache is up to date with metadata." << endl;
1314 if ( policy == BuildIfNeeded )
1317 const Pathname & base = solv_path_for_repoinfo( _options, info);
1318 if ( ! PathInfo(base/
"solv.idx").isExist() )
1324 MIL << info.alias() <<
" cache rebuild is forced" << endl;
1328 needs_cleaning =
true;
1331 ProgressData progress(100);
1332 callback::SendReport<ProgressReport> report;
1333 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
1334 progress.name(
str::form(
_(
"Building repository '%s' cache"), info.label().c_str()));
1342 MIL << info.alias() <<
" building cache..." << info.type() << endl;
1344 Pathname base = solv_path_for_repoinfo( _options, info);
1348 Exception ex(
str::form(
_(
"Can't create %s"), base.c_str()) );
1352 if( ! PathInfo(base).userMayW() )
1354 Exception ex(
str::form(
_(
"Can't create cache at %s - no writing permissions."), base.c_str()) );
1357 Pathname solvfile = base /
"solv";
1360 repo::RepoType repokind = info.type();
1363 switch ( repokind.toEnum() )
1367 repokind = probeCache( productdatapath );
1373 MIL <<
"repo type is " << repokind << endl;
1375 switch ( repokind.toEnum() )
1383 scoped_ptr<MediaMounter> forPlainDirs;
1386 cmd.push_back( PathInfo(
"/usr/bin/repo2solv" ).isFile() ?
"repo2solv" :
"repo2solv.sh" );
1388 cmd.push_back(
"-o" );
1389 cmd.push_back( solvfile.asString() );
1390 cmd.push_back(
"-X" );
1395 forPlainDirs.reset(
new MediaMounter( info.url() ) );
1397 cmd.push_back(
"-R" );
1399 cmd.push_back( forPlainDirs->getPathName( info.path() ).c_str() );
1402 cmd.push_back( productdatapath.asString() );
1405 std::string errdetail;
1407 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() ) {
1408 WAR <<
" " << output;
1409 errdetail += output;
1412 int ret = prog.close();
1416 ex.addHistory( str::Str() << prog.command() << endl << errdetail << prog.execError() );
1421 guard.resetDispose();
1430 setCacheStatus(info, raw_metadata_status);
1431 MIL <<
"Commit cache.." << endl;
1444 repo::RepoType RepoManager::Impl::probe(
const Url & url,
const Pathname & path )
const 1446 MIL <<
"going to probe the repo type at " << url <<
" (" << path <<
")" << endl;
1448 if ( url.getScheme() ==
"dir" && ! PathInfo( url.getPathName()/path ).isDir() )
1452 MIL <<
"Probed type NONE (not exists) at " << url <<
" (" << path <<
")" << endl;
1464 bool gotMediaException =
false;
1470 if ( access.doesFileExist(path/
"/repodata/repomd.xml") )
1472 MIL <<
"Probed type RPMMD at " << url <<
" (" << path <<
")" << endl;
1476 catch (
const media::MediaException &e )
1479 DBG <<
"problem checking for repodata/repomd.xml file" << endl;
1481 gotMediaException =
true;
1486 if ( access.doesFileExist(path/
"/content") )
1488 MIL <<
"Probed type YAST2 at " << url <<
" (" << path <<
")" << endl;
1492 catch (
const media::MediaException &e )
1495 DBG <<
"problem checking for content file" << endl;
1497 gotMediaException =
true;
1501 if ( ! ( url.schemeIsDownloading() || url.schemeIsPlugin() ) )
1503 MediaMounter media( url );
1504 if ( PathInfo(media.getPathName()/path).isDir() )
1507 MIL <<
"Probed type RPMPLAINDIR at " << url <<
" (" << path <<
")" << endl;
1512 catch (
const Exception &e )
1516 Exception enew(
str::form(
_(
"Unknown error reading from '%s'"), url.asString().c_str() ));
1521 if (gotMediaException)
1524 MIL <<
"Probed type NONE at " << url <<
" (" << path <<
")" << endl;
1533 repo::RepoType RepoManager::Impl::probeCache(
const Pathname & path_r )
const 1535 MIL <<
"going to probe the cached repo at " << path_r << endl;
1539 if ( PathInfo(path_r/
"/repodata/repomd.xml").isFile() )
1541 else if ( PathInfo(path_r/
"/content").isFile() )
1543 else if ( PathInfo(path_r).isDir() )
1546 MIL <<
"Probed cached type " << ret <<
" at " << path_r << endl;
1554 MIL <<
"Going to clean up garbage in cache dirs" << endl;
1556 ProgressData progress(300);
1557 progress.sendTo(progressrcv);
1560 std::list<Pathname> cachedirs;
1561 cachedirs.push_back(_options.repoRawCachePath);
1562 cachedirs.push_back(_options.repoPackagesCachePath);
1563 cachedirs.push_back(_options.repoSolvCachePath);
1565 for_( dir, cachedirs.begin(), cachedirs.end() )
1567 if ( PathInfo(*dir).isExist() )
1569 std::list<Pathname> entries;
1574 unsigned sdircount = entries.size();
1575 unsigned sdircurrent = 1;
1576 for_( subdir, entries.begin(), entries.end() )
1580 for_( r, repoBegin(), repoEnd() )
1581 if ( subdir->basename() == r->escaped_alias() )
1582 { found =
true;
break; }
1587 progress.set( progress.val() + sdircurrent * 100 / sdircount );
1592 progress.set( progress.val() + 100 );
1601 ProgressData progress(100);
1602 progress.sendTo(progressrcv);
1605 MIL <<
"Removing raw metadata cache for " << info.alias() << endl;
1616 Pathname solvfile = solv_path_for_repoinfo(_options, info) /
"solv";
1618 if ( ! PathInfo(solvfile).isExist() )
1628 if ( toolversion != LIBSOLV_TOOLVERSION )
1630 repo.eraseFromPool();
1631 ZYPP_THROW(Exception(str::Str() <<
"Solv-file was created by '"<<toolversion<<
"'-parser (want "<<LIBSOLV_TOOLVERSION<<
")."));
1634 catch (
const Exception & exp )
1637 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1638 cleanCache( info, progressrcv );
1639 buildCache( info, BuildIfNeeded, progressrcv );
1651 ProgressData progress(100);
1652 callback::SendReport<ProgressReport> report;
1653 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
1654 progress.name(
str::form(
_(
"Adding repository '%s'"), info.label().c_str()));
1657 MIL <<
"Try adding repo " << info << endl;
1659 RepoInfo tosave = info;
1664 if ( _options.probe )
1666 DBG <<
"unknown repository type, probing" << endl;
1667 assert_urls(tosave);
1669 RepoType probedtype( probe( tosave.url(), info.path() ) );
1673 tosave.setType(probedtype);
1681 Pathname repofile = generateNonExistingName(
1682 _options.knownReposPath, generateFilename(tosave));
1684 MIL <<
"Saving repo in " << repofile << endl;
1686 std::ofstream file(repofile.c_str());
1693 tosave.dumpAsIniOn(file);
1694 tosave.setFilepath(repofile);
1695 tosave.setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1696 tosave.setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1700 RepoInfo & oinfo( const_cast<RepoInfo &>(info) );
1701 oinfo.setFilepath(repofile);
1702 oinfo.setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1703 oinfo.setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1705 reposManip().insert(tosave);
1710 UrlCredentialExtractor( _options.rootDir ).collect( tosave.baseUrls() );
1712 HistoryLog(_options.rootDir).addRepository(tosave);
1715 MIL <<
"done" << endl;
1722 for ( std::list<RepoInfo>::const_iterator it =
repos.begin();
1727 for_ ( kit, repoBegin(), repoEnd() )
1729 if ( (*it).alias() == (*kit).alias() )
1731 ERR <<
"To be added repo " << (*it).alias() <<
" conflicts with existing repo " << (*kit).alias() << endl;
1737 std::string filename = Pathname(url.getPathName()).basename();
1739 if ( filename == Pathname() )
1748 Pathname repofile = generateNonExistingName(_options.knownReposPath, filename);
1750 MIL <<
"Saving " <<
repos.size() <<
" repo" << (
repos.size() ?
"s" :
"" ) <<
" in " << repofile << endl;
1752 std::ofstream file(repofile.c_str());
1759 for ( std::list<RepoInfo>::iterator it =
repos.begin();
1763 MIL <<
"Saving " << (*it).alias() << endl;
1764 it->dumpAsIniOn(file);
1765 it->setFilepath(repofile);
1766 it->setMetadataPath( rawcache_path_for_repoinfo( _options, *it ) );
1767 it->setPackagesPath( packagescache_path_for_repoinfo( _options, *it ) );
1768 reposManip().insert(*it);
1770 HistoryLog(_options.rootDir).addRepository(*it);
1773 MIL <<
"done" << endl;
1780 ProgressData progress;
1781 callback::SendReport<ProgressReport> report;
1782 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
1783 progress.name(
str::form(
_(
"Removing repository '%s'"), info.label().c_str()));
1785 MIL <<
"Going to delete repo " << info.alias() << endl;
1787 for_( it, repoBegin(), repoEnd() )
1792 if ( (!info.alias().empty()) && ( info.alias() != (*it).alias() ) )
1799 RepoInfo todelete = *it;
1800 if (todelete.filepath().empty())
1807 std::list<RepoInfo> filerepos = repositories_in_file(todelete.filepath());
1808 if ( filerepos.size() == 0
1809 ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.alias() ) )
1813 if ( ! ( ret == 0 || ret == ENOENT ) )
1818 MIL << todelete.alias() <<
" successfully deleted." << endl;
1830 std::ofstream file(todelete.filepath().c_str());
1834 ZYPP_THROW( Exception(
str::form(
_(
"Can't open file '%s' for writing."), todelete.filepath().c_str() )));
1836 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1837 fit != filerepos.end();
1840 if ( (*fit).alias() != todelete.alias() )
1841 (*fit).dumpAsIniOn(file);
1845 CombinedProgressData cSubprogrcv(progress, 20);
1846 CombinedProgressData mSubprogrcv(progress, 40);
1847 CombinedProgressData pSubprogrcv(progress, 40);
1849 if ( isCached(todelete) )
1850 cleanCache( todelete, cSubprogrcv);
1852 cleanMetadata( todelete, mSubprogrcv );
1853 cleanPackages( todelete, pSubprogrcv );
1854 reposManip().erase(todelete);
1855 MIL << todelete.alias() <<
" successfully deleted." << endl;
1856 HistoryLog(_options.rootDir).removeRepository(todelete);
1867 void RepoManager::Impl::modifyRepository(
const std::string & alias,
const RepoInfo & newinfo_r,
const ProgressData::ReceiverFnc & progressrcv )
1869 RepoInfo toedit = getRepositoryInfo(alias);
1870 RepoInfo newinfo( newinfo_r );
1873 if ( alias != newinfo.alias() && hasRepo( newinfo.alias() ) )
1878 if (toedit.filepath().empty())
1885 std::list<RepoInfo> filerepos = repositories_in_file(toedit.filepath());
1895 std::ofstream file(toedit.filepath().c_str());
1899 ZYPP_THROW( Exception(
str::form(
_(
"Can't open file '%s' for writing."), toedit.filepath().c_str() )));
1901 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1902 fit != filerepos.end();
1907 if ( (*fit).alias() != toedit.alias() )
1908 (*fit).dumpAsIniOn(file);
1910 newinfo.dumpAsIniOn(file);
1913 if ( toedit.enabled() && !newinfo.enabled() )
1916 const Pathname & solvidx = solv_path_for_repoinfo(_options, newinfo)/
"solv.idx";
1917 if ( PathInfo(solvidx).isExist() )
1921 newinfo.setFilepath(toedit.filepath());
1922 newinfo.setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1923 newinfo.setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1927 RepoInfo & oinfo( const_cast<RepoInfo &>(newinfo_r) );
1928 oinfo.setFilepath(toedit.filepath());
1929 oinfo.setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1930 oinfo.setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1932 reposManip().erase(toedit);
1933 reposManip().insert(newinfo);
1935 UrlCredentialExtractor( _options.rootDir ).collect( newinfo.baseUrls() );
1936 HistoryLog(_options.rootDir).modifyRepository(toedit, newinfo);
1937 MIL <<
"repo " << alias <<
" modified" << endl;
1943 RepoInfo RepoManager::Impl::getRepositoryInfo(
const std::string & alias,
const ProgressData::ReceiverFnc & progressrcv )
1945 RepoConstIterator it( findAlias( alias,
repos() ) );
1946 if ( it !=
repos().end() )
1949 info.setAlias( alias );
1954 RepoInfo RepoManager::Impl::getRepositoryInfo(
const Url & url,
const url::ViewOption & urlview,
const ProgressData::ReceiverFnc & progressrcv )
1956 for_( it, repoBegin(), repoEnd() )
1958 for_( urlit, (*it).baseUrlsBegin(), (*it).baseUrlsEnd() )
1960 if ( (*urlit).asString(urlview) == url.asString(urlview) )
1965 info.setBaseUrl( url );
1975 void RepoManager::Impl::addService(
const ServiceInfo & service )
1977 assert_alias( service );
1980 if ( hasService( service.alias() ) )
1985 ServiceInfo toSave( service );
1986 saveService( toSave );
1990 UrlCredentialExtractor( _options.rootDir ).collect( toSave.url() );
1992 MIL <<
"added service " << toSave.alias() << endl;
1997 void RepoManager::Impl::removeService(
const std::string & alias )
1999 MIL <<
"Going to delete service " << alias << endl;
2001 const ServiceInfo & service = getService( alias );
2003 Pathname location = service.filepath();
2004 if( location.empty() )
2010 parser::ServiceFileReader( location, ServiceCollector(tmpSet) );
2013 if ( tmpSet.size() == 1 )
2020 MIL << alias <<
" successfully deleted." << endl;
2026 std::ofstream file(location.c_str());
2033 for_(it, tmpSet.begin(), tmpSet.end())
2035 if( it->alias() != alias )
2036 it->dumpAsIniOn(file);
2039 MIL << alias <<
" successfully deleted from file " << location << endl;
2043 RepoCollector rcollector;
2044 getRepositoriesInService( alias,
2045 boost::make_function_output_iterator( bind( &RepoCollector::collect, &rcollector, _1 ) ) );
2047 for_(rit, rcollector.repos.begin(), rcollector.repos.end())
2048 removeRepository(*rit);
2053 void RepoManager::Impl::refreshServices(
const RefreshServiceOptions & options_r )
2057 ServiceSet services( serviceBegin(), serviceEnd() );
2058 for_( it, services.begin(), services.end() )
2060 if ( !it->enabled() )
2064 refreshService(*it, options_r);
2066 catch (
const repo::ServicePluginInformalException & e )
2071 void RepoManager::Impl::refreshService(
const std::string & alias,
const RefreshServiceOptions & options_r )
2073 ServiceInfo service( getService( alias ) );
2074 assert_alias( service );
2075 assert_url( service );
2076 MIL <<
"Going to refresh service '" << service.alias() <<
"', url: " << service.url() <<
", opts: " << options_r << endl;
2078 if ( service.ttl() && !( options_r.testFlag( RefreshService_forceRefresh) || options_r.testFlag( RefreshService_restoreStatus ) ) )
2081 Date lrf = service.lrf();
2087 if ( (lrf+=service.ttl()) > now )
2089 MIL <<
"Skip: '" << service.alias() <<
"' metadata valid until " << lrf << endl;
2094 WAR <<
"Force: '" << service.alias() <<
"' metadata last refresh in the future: " << lrf << endl;
2101 bool serviceModified =
false;
2108 repo::ServiceType type = probeService( service.url() );
2111 service.setProbedType( type );
2112 serviceModified =
true;
2117 std::string servicesTargetDistro = _options.servicesTargetDistro;
2118 if ( servicesTargetDistro.empty() )
2122 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << endl;
2126 RepoCollector collector(servicesTargetDistro);
2131 std::pair<DefaultIntegral<bool,false>, repo::ServicePluginInformalException> uglyHack;
2139 ServiceRepos( _options.rootDir, service, bind( &RepoCollector::collect, &collector, _1 ) );
2141 catch (
const repo::ServicePluginInformalException & e )
2144 uglyHack.first =
true;
2145 uglyHack.second = e;
2147 if ( service.ttl() != origTtl )
2149 if ( !service.ttl() )
2150 service.setLrf( Date() );
2151 serviceModified =
true;
2159 for_( it, collector.repos.begin(), collector.repos.end() )
2162 it->setAlias(
str::form(
"%s:%s", service.alias().c_str(), it->alias().c_str() ) );
2164 it->setService( service.alias() );
2167 newRepoStates[it->alias()] = *it;
2175 if ( !it->path().empty() )
2177 if ( it->path() !=
"/" )
2182 if ( it->baseUrlsEmpty() )
2184 Url url( service.rawUrl() );
2185 if ( !path.empty() )
2186 url.setPathName( url.getPathName() / path );
2187 it->setBaseUrl( std::move(url) );
2189 else if ( !path.empty() )
2192 for ( Url & url : urls )
2194 url.setPathName( url.getPathName() / path );
2196 it->setBaseUrls( std::move(urls) );
2203 RepoInfoList oldRepos;
2204 getRepositoriesInService( service.alias(), std::back_inserter( oldRepos ) );
2208 for_( oldRepo, oldRepos.begin(), oldRepos.end() )
2210 if ( ! foundAliasIn( oldRepo->alias(), collector.repos ) )
2212 if ( oldRepo->enabled() )
2215 const auto & last = service.repoStates().find( oldRepo->alias() );
2216 if ( last != service.repoStates().end() && ! last->second.enabled )
2218 DBG <<
"Service removes user enabled repo " << oldRepo->alias() << endl;
2219 service.addRepoToEnable( oldRepo->alias() );
2220 serviceModified =
true;
2223 DBG <<
"Service removes enabled repo " << oldRepo->alias() << endl;
2226 DBG <<
"Service removes disabled repo " << oldRepo->alias() << endl;
2228 removeRepository( *oldRepo );
2234 UrlCredentialExtractor urlCredentialExtractor( _options.rootDir );
2235 for_( it, collector.repos.begin(), collector.repos.end() )
2241 TriBool toBeEnabled( indeterminate );
2242 DBG <<
"Service request to " << (it->enabled()?
"enable":
"disable") <<
" service repo " << it->alias() << endl;
2244 if ( options_r.testFlag( RefreshService_restoreStatus ) )
2246 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() << endl;
2251 service.delRepoToEnable( it->alias() );
2256 if ( service.repoToEnableFind( it->alias() ) )
2258 DBG <<
"User request to enable service repo " << it->alias() << endl;
2263 service.delRepoToEnable( it->alias() );
2264 serviceModified =
true;
2266 else if ( service.repoToDisableFind( it->alias() ) )
2268 DBG <<
"User request to disable service repo " << it->alias() << endl;
2269 toBeEnabled =
false;
2273 RepoInfoList::iterator oldRepo( findAlias( it->alias(), oldRepos ) );
2274 if ( oldRepo == oldRepos.end() )
2279 if ( ! indeterminate(toBeEnabled) )
2280 it->setEnabled( (
bool ) toBeEnabled );
2282 DBG <<
"Service adds repo " << it->alias() <<
" " << (it->enabled()?
"enabled":
"disabled") << endl;
2283 addRepository( *it );
2288 bool oldRepoModified =
false;
2290 if ( indeterminate(toBeEnabled) )
2294 if ( oldRepo->enabled() == it->enabled() )
2295 toBeEnabled = it->enabled();
2296 else if (options_r.testFlag( RefreshService_restoreStatus ) )
2298 toBeEnabled = it->enabled();
2299 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() <<
" forces " << (toBeEnabled?
"enabled":
"disabled") << endl;
2303 const auto & last = service.repoStates().find( oldRepo->alias() );
2304 if ( last == service.repoStates().end() || last->second.enabled != it->enabled() )
2305 toBeEnabled = it->enabled();
2308 toBeEnabled = oldRepo->enabled();
2309 DBG <<
"User modified service repo " << it->alias() <<
" may stay " << (toBeEnabled?
"enabled":
"disabled") << endl;
2315 if ( toBeEnabled == oldRepo->enabled() )
2317 DBG <<
"Service repo " << it->alias() <<
" stays " << (oldRepo->enabled()?
"enabled":
"disabled") << endl;
2319 else if ( toBeEnabled )
2321 DBG <<
"Service repo " << it->alias() <<
" gets enabled" << endl;
2322 oldRepo->setEnabled(
true );
2323 oldRepoModified =
true;
2327 DBG <<
"Service repo " << it->alias() <<
" gets disabled" << endl;
2328 oldRepo->setEnabled(
false );
2329 oldRepoModified =
true;
2335 if ( oldRepo->rawName() != it->rawName() )
2337 DBG <<
"Service repo " << it->alias() <<
" gets new NAME " << it->rawName() << endl;
2338 oldRepo->setName( it->rawName() );
2339 oldRepoModified =
true;
2343 if ( oldRepo->autorefresh() != it->autorefresh() )
2345 DBG <<
"Service repo " << it->alias() <<
" gets new AUTOREFRESH " << it->autorefresh() << endl;
2346 oldRepo->setAutorefresh( it->autorefresh() );
2347 oldRepoModified =
true;
2351 if ( oldRepo->priority() != it->priority() )
2353 DBG <<
"Service repo " << it->alias() <<
" gets new PRIORITY " << it->priority() << endl;
2354 oldRepo->setPriority( it->priority() );
2355 oldRepoModified =
true;
2361 urlCredentialExtractor.extract( newUrls );
2362 if ( oldRepo->rawBaseUrls() != newUrls )
2364 DBG <<
"Service repo " << it->alias() <<
" gets new URLs " << newUrls << endl;
2365 oldRepo->setBaseUrls( std::move(newUrls) );
2366 oldRepoModified =
true;
2376 oldRepo->getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
2377 it-> getRawGpgChecks( ngpg[0], ngpg[1], ngpg[2] );
2378 #define Z_CHKGPG(I,N) \ 2379 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \ 2381 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \ 2382 oldRepo->set##N##Check( ngpg[I] ); \ 2383 oldRepoModified = true; \ 2392 if ( oldRepoModified )
2394 modifyRepository( oldRepo->alias(), *oldRepo );
2400 if ( ! service.reposToDisableEmpty() )
2402 service.clearReposToDisable();
2403 serviceModified =
true;
2407 if ( service.repoStates() != newRepoStates )
2409 service.setRepoStates( std::move(newRepoStates) );
2410 serviceModified =
true;
2417 if ( service.ttl() )
2420 serviceModified =
true;
2423 if ( serviceModified )
2426 modifyService( service.alias(), service );
2430 if ( uglyHack.first )
2432 throw( uglyHack.second );
2438 void RepoManager::Impl::modifyService(
const std::string & oldAlias,
const ServiceInfo & newService )
2440 MIL <<
"Going to modify service " << oldAlias << endl;
2444 ServiceInfo service(newService);
2451 const ServiceInfo & oldService = getService(oldAlias);
2453 Pathname location = oldService.filepath();
2454 if( location.empty() )
2461 parser::ServiceFileReader( location, ServiceCollector(tmpSet) );
2464 std::ofstream file(location.c_str());
2465 for_(it, tmpSet.begin(), tmpSet.end())
2467 if( *it != oldAlias )
2468 it->dumpAsIniOn(file);
2470 service.dumpAsIniOn(file);
2472 service.setFilepath(location);
2477 UrlCredentialExtractor( _options.rootDir ).collect( service.url() );
2481 if ( oldAlias != service.alias()
2482 || oldService.enabled() != service.enabled() )
2484 std::vector<RepoInfo> toModify;
2485 getRepositoriesInService(oldAlias, std::back_inserter(toModify));
2486 for_( it, toModify.begin(), toModify.end() )
2488 if ( oldService.enabled() != service.enabled() )
2490 if ( service.enabled() )
2493 const auto & last = service.repoStates().find( it->alias() );
2494 if ( last != service.repoStates().end() )
2495 it->setEnabled( last->second.enabled );
2498 it->setEnabled(
false );
2501 if ( oldAlias != service.alias() )
2502 it->setService(service.alias());
2504 modifyRepository(it->alias(), *it);
2513 repo::ServiceType RepoManager::Impl::probeService(
const Url & url )
const 2518 if ( access.doesFileExist(
"/repo/repoindex.xml") )
2521 catch (
const media::MediaException &e )
2529 catch (
const Exception &e )
2533 Exception enew(
str::form(
_(
"Unknown error reading from '%s'"), url.asString().c_str() ));
2548 : _pimpl( new
Impl(opt) )
2555 {
return _pimpl->repoEmpty(); }
2558 {
return _pimpl->repoSize(); }
2561 {
return _pimpl->repoBegin(); }
2564 {
return _pimpl->repoEnd(); }
2567 {
return _pimpl->getRepo( alias ); }
2570 {
return _pimpl->hasRepo( alias ); }
2580 std::string host( url_r.
getHost() );
2581 if ( ! host.empty() )
2593 {
return _pimpl->metadataStatus( info ); }
2596 {
return _pimpl->checkIfToRefreshMetadata( info, url, policy ); }
2599 {
return _pimpl->metadataPath( info ); }
2602 {
return _pimpl->packagesPath( info ); }
2605 {
return _pimpl->refreshMetadata( info, policy, progressrcv ); }
2608 {
return _pimpl->cleanMetadata( info, progressrcv ); }
2611 {
return _pimpl->cleanPackages( info, progressrcv ); }
2614 {
return _pimpl->cacheStatus( info ); }
2617 {
return _pimpl->buildCache( info, policy, progressrcv ); }
2620 {
return _pimpl->cleanCache( info, progressrcv ); }
2623 {
return _pimpl->isCached( info ); }
2626 {
return _pimpl->loadFromCache( info, progressrcv ); }
2629 {
return _pimpl->cleanCacheDirGarbage( progressrcv ); }
2632 {
return _pimpl->probe( url, path ); }
2635 {
return _pimpl->probe( url ); }
2638 {
return _pimpl->addRepository( info, progressrcv ); }
2641 {
return _pimpl->addRepositories( url, progressrcv ); }
2644 {
return _pimpl->removeRepository( info, progressrcv ); }
2647 {
return _pimpl->modifyRepository( alias, newinfo, progressrcv ); }
2650 {
return _pimpl->getRepositoryInfo( alias, progressrcv ); }
2653 {
return _pimpl->getRepositoryInfo( url, urlview, progressrcv ); }
2656 {
return _pimpl->serviceEmpty(); }
2659 {
return _pimpl->serviceSize(); }
2662 {
return _pimpl->serviceBegin(); }
2665 {
return _pimpl->serviceEnd(); }
2668 {
return _pimpl->getService( alias ); }
2671 {
return _pimpl->hasService( alias ); }
2674 {
return _pimpl->probeService( url ); }
2677 {
return _pimpl->addService( alias, url ); }
2680 {
return _pimpl->addService( service ); }
2683 {
return _pimpl->removeService( alias ); }
2686 {
return _pimpl->removeService( service ); }
2689 {
return _pimpl->refreshServices( options_r ); }
2692 {
return _pimpl->refreshService( alias, options_r ); }
2695 {
return _pimpl->refreshService( service, options_r ); }
2698 {
return _pimpl->modifyService( oldAlias, service ); }
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy)
std::string getScheme() const
Returns the scheme name of the URL.
std::string asString(const Patch::Category &obj)
static const ValueType day
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
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.
Pathname builtinRepoPackagesPath() const
The builtin config file value.
static const std::string & sha1()
sha1
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
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
bool hasRepo(const std::string &alias) 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.
Pathname repoRawCachePath
Repository metadata verification beyond GPG.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
static ZConfig & instance()
Singleton ctor.
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
scoped_ptr< media::CredentialManager > _cmPtr
Impl * clone() const
clone for RWCOW_pointer
void removeService(const std::string &alias)
Service plugin is immutable.
ServiceInfo getService(const std::string &alias) const
RepoSizeType repoSize() const
void refreshServices(const RefreshServiceOptions &options_r)
Pathname builtinRepoMetadataPath() const
The builtin config file value.
Pathname metadataPath(const RepoInfo &info) const
bool repo_add_probe() const
Whether repository urls should be probed.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
String related utilities and Regular expression matching.
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
What is known about a repository.
ServiceSet::size_type ServiceSizeType
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
RepoInfo getRepositoryInfo(const std::string &alias, OPT_PROGRESS)
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Pathname knownServicesPath
void addRepositories(const Url &url, OPT_PROGRESS)
RepoInfo getRepo(const std::string &alias) const
void reposErase(const std::string &alias_r)
Remove a Repository named alias_r.
Service already exists and some unique attribute can't be duplicated.
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.
repo::ServiceType probeService(const Url &url) const
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
void buildCache(const RepoInfo &info, CacheBuildPolicy policy, OPT_PROGRESS)
Url::asString() view options.
void modifyService(const std::string &oldAlias, const ServiceInfo &newService)
Pathname repoSolvCachePath
std::vector< std::string > Arguments
PluginRepoverification _pluginRepoverification
repo::RepoType probe(const Url &url, const Pathname &path=Pathname()) const
std::string generateFilename(const RepoInfo &info) const
void loadFromCache(const RepoInfo &info, OPT_PROGRESS)
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
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).
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
std::map< std::string, RepoState > RepoStates
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.
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
void addRepository(const RepoInfo &info, OPT_PROGRESS)
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
static Pool instance()
Singleton ctor.
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
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
int unlink(const Pathname &path)
Like 'unlink'.
thrown when it was impossible to determine one url for this repo.
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.
void addService(const std::string &alias, const Url &url)
unsigned repo_refresh_delay() const
Amount of time in minutes that must pass before another refresh.
bool serviceEmpty() const
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
static const ServiceType NONE
No service set.
static const SolvAttr repositoryToolVersion
Service type enumeration.
std::ostream & operator<<(std::ostream &str, const DeltaCandidates &obj)
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 cleanMetadata(const RepoInfo &info, OPT_PROGRESS)
std::string asCompleteString() const
Returns a complete string representation of the Url object.
const RepoSet & repos() const
Iterate the known repositories.
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
void removeService(const ServiceInfo &service)
static const ServiceType PLUGIN
Plugin services are scripts installed on your system that provide the package manager with repositori...
bool isCached(const RepoInfo &info) const
Base Exception for service handling.
ServiceSet::const_iterator ServiceConstIterator
ServiceConstIterator serviceBegin() const
const std::string & asString() const
Return current Pathname as String.
std::string numstring(char n, int w=0)
static const RepoType NONE
Impl(const RepoManagerOptions &opt)
int touch(const Pathname &path)
Change file's modification and access times.
ServiceConstIterator serviceEnd() const
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
static const RepoType RPMMD
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Pathname builtinRepoSolvfilesPath() const
The builtin config file value.
std::list< RepoInfo > readRepoFile(const Url &repo_file)
Parses repo_file and returns a list of RepoInfo objects corresponding to repositories found within th...
void refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
static const RepoType YAST2
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, OPT_PROGRESS)
thrown when it was impossible to determine an alias for this repo.
RepoSet::size_type RepoSizeType
std::string generateFilename(const ServiceInfo &info) const
Exception for repository handling.
RepoConstIterator repoBegin() const
static std::string makeStupidAlias(const Url &url_r=Url())
Some stupid string but suitable as alias for your url if nothing better is available.
media::MediaAccessId _mid
static Date now()
Return the current time.
bool ZYPP_PLUGIN_APPDATA_FORCE_COLLECT()
To trigger appdata refresh unconditionally.
#define PL_(MSG1, MSG2, N)
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 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...
Pathname repoPackagesCachePath
static const ServiceInfo noService
Represents an empty service.
void removeRepository(const RepoInfo &info, OPT_PROGRESS)
Wrapper class for ::stat/::lstat.
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.
static const RepoType RPMPLAINDIR
static const std::string & systemRepoAlias()
Reserved system repository alias .
RepoStatus metadataStatus(const RepoInfo &info) const
Track changing files or directories.
void modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, OPT_PROGRESS)
Repository already exists and some unique attribute can't be duplicated.
ServiceSizeType serviceSize() const
void cleanPackages(const RepoInfo &info, OPT_PROGRESS)
RepoManagerOptions _options
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
Repository addRepoSolv(const Pathname &file_r, const std::string &name_r)
Load Solvables from a solv-file into a Repository named name_r.
Downloader for YUM (rpm-nmd) repositories Encapsulates all the knowledge of which files have to be do...
void addService(const ServiceInfo &service)
Easy-to use interface to the ZYPP dependency resolver.
RepoManager(const RepoManagerOptions &options=RepoManagerOptions())
RepoConstIterator repoEnd() const
std::string hexstring(char n, int w=4)
RepoManager implementation.
void cleanCacheDirGarbage(OPT_PROGRESS)
std::ostream & operator<<(std::ostream &str, const RepoManager::Impl &obj)
Service has no or invalid url defined.
RepoStatus cacheStatus(const RepoInfo &info) const
bool hasService(const std::string &alias) const
void cleanCache(const RepoInfo &info, OPT_PROGRESS)
RepoSet::const_iterator RepoConstIterator
void setCacheStatus(const RepoInfo &info, const RepoStatus &status)
Repository type enumeration.
DefaultIntegral< bool, false > _reposDirty
Pathname packagesPath(const RepoInfo &info) const