22#include <solv/solvversion.h>
24#include <zypp-core/base/InputStream>
25#include <zypp/base/LogTools.h>
26#include <zypp/base/Gettext.h>
27#include <zypp-core/base/DefaultIntegral>
28#include <zypp/base/Function.h>
29#include <zypp/base/Regex.h>
30#include <zypp/PathInfo.h>
31#include <zypp/TmpPath.h>
38#include <zypp-media/auth/CredentialManager>
39#include <zypp-media/MediaException>
41#include <zypp/ExternalProgram.h>
42#include <zypp/ManagedFile.h>
48#include <zypp/repo/yum/Downloader.h>
49#include <zypp/repo/susetags/Downloader.h>
65#define OPT_PROGRESS const ProgressData::ReceiverFnc & = ProgressData::ReceiverFnc()
77 const char * env = getenv(
"ZYPP_PLUGIN_APPDATA_FORCE_COLLECT");
107 class UrlCredentialExtractor
110 UrlCredentialExtractor(
Pathname & root_r )
114 ~UrlCredentialExtractor()
115 {
if ( _cmPtr )
_cmPtr->save(); }
118 bool collect(
const Url & url_r )
123 if ( !_cmPtr )
_cmPtr.reset(
new media::CredentialManager( _root ) );
124 _cmPtr->addUserCred( url_r );
129 template<
class TContainer>
130 bool collect(
const TContainer & urls_r )
131 {
bool ret =
false;
for (
const Url & url : urls_r ) {
if ( collect( url ) && !ret ) ret =
true; }
return ret; }
134 bool extract(
Url & url_r )
136 bool ret = collect( url_r );
142 template<
class TContainer>
143 bool extract( TContainer & urls_r )
144 {
bool ret =
false;
for (
Url & url : urls_r ) {
if ( extract( url ) && !ret ) ret =
true; }
return ret; }
163 MediaMounter(
const Url & url_r )
175 mediamanager.
close( _mid );
185 return mediamanager.
localPath( _mid, path_r );
194 template <
class Iterator>
195 inline bool foundAliasIn(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
197 for_( it, begin_r, end_r )
198 if ( it->alias() == alias_r )
203 template <
class Container>
204 inline bool foundAliasIn(
const std::string & alias_r,
const Container & cont_r )
205 {
return foundAliasIn( alias_r, cont_r.begin(), cont_r.end() ); }
208 template <
class Iterator>
209 inline Iterator findAlias(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
211 for_( it, begin_r, end_r )
212 if ( it->alias() == alias_r )
217 template <
class Container>
218 inline typename Container::iterator findAlias(
const std::string & alias_r, Container & cont_r )
219 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
221 template <
class Container>
222 inline typename Container::const_iterator findAlias(
const std::string & alias_r,
const Container & cont_r )
223 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
227 inline std::string filenameFromAlias(
const std::string & alias_r,
const std::string & stem_r )
229 std::string filename( alias_r );
234 MIL <<
"generating filename for " << stem_r <<
" [" << alias_r <<
"] : '" << filename <<
"'" << endl;
258 RepoCollector(
const std::string & targetDistro_)
262 bool collect(
const RepoInfo &repo )
271 <<
"' distribution (current distro is '"
277 repos.push_back(repo);
291 std::list<RepoInfo> repositories_in_file(
const Pathname & file )
293 MIL <<
"repo file: " << file << endl;
294 RepoCollector collector;
296 return std::move(collector.repos);
309 std::list<RepoInfo> repositories_in_dir(
const Pathname &dir )
311 MIL <<
"directory " << dir << endl;
312 std::list<RepoInfo>
repos;
313 bool nonroot( geteuid() != 0 );
314 if ( nonroot && !
PathInfo(dir).userMayRX() )
320 std::list<Pathname> entries;
327 str::regex allowedRepoExt(
"^\\.repo(_[0-9]+)?$");
328 for ( std::list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
338 const std::list<RepoInfo> & tmp( repositories_in_file( *it ) );
339 repos.insert(
repos.end(), tmp.begin(), tmp.end() );
349 inline void assert_alias(
const RepoInfo & info )
351 if ( info.
alias().empty() )
355 if ( info.
alias()[0] ==
'.')
357 info,
_(
"Repository alias cannot start with dot.")));
360 inline void assert_alias(
const ServiceInfo & info )
362 if ( info.
alias().empty() )
366 if ( info.
alias()[0] ==
'.')
368 info,
_(
"Service alias cannot start with dot.")));
373 inline void assert_urls(
const RepoInfo & info )
391 inline bool isTmpRepo(
const RepoInfo & info_r )
415 {
return rawcache_path_for_repoinfo( opt, info ) / info.
path(); }
438 class ServiceCollector
441 typedef std::set<ServiceInfo> ServiceSet;
443 ServiceCollector( ServiceSet & services_r )
447 bool operator()(
const ServiceInfo & service_r )
const
465 DBG <<
"reading repo file " << repo_file <<
", local path: " << local << endl;
467 return repositories_in_file(local);
506#define OUTS(X) str << " " #X "\t" << obj.X << endl
507 str <<
"RepoManagerOptions (" << obj.
rootDir <<
") {" << endl;
508 OUTS( repoRawCachePath );
509 OUTS( repoSolvCachePath );
510 OUTS( repoPackagesCachePath );
511 OUTS( knownReposPath );
512 OUTS( knownServicesPath );
529 , _pluginRepoverification( _options.pluginsPath/
"repoverification", _options.rootDir )
531 init_knownServices();
532 init_knownRepositories();
538 if ( ( _reposDirty || env::ZYPP_PLUGIN_APPDATA_FORCE_COLLECT() )
539 && geteuid() == 0 && ( _options.rootDir.empty() || _options.rootDir ==
"/" ) )
542 std::list<Pathname> entries;
543 filesystem::readdir( entries, _options.pluginsPath/
"appdata",
false );
544 if ( ! entries.empty() )
547 cmd.push_back(
"<" );
548 cmd.push_back(
">" );
549 cmd.push_back(
"PROGRAM" );
550 for (
const auto & rinfo :
repos() )
552 if ( ! rinfo.enabled() )
554 cmd.push_back(
"-R" );
555 cmd.push_back( rinfo.alias() );
556 cmd.push_back(
"-t" );
557 cmd.push_back( rinfo.type().asString() );
558 cmd.push_back(
"-p" );
559 cmd.push_back( (rinfo.metadataPath()/rinfo.path()).asString() );
562 for_( it, entries.begin(), entries.end() )
585 bool hasRepo(
const std::string & alias )
const
586 {
return foundAliasIn( alias,
repos() ); }
591 return it ==
repos().end() ? RepoInfo::noRepo : *it;
596 {
return rawcache_path_for_repoinfo( _options, info ); }
599 {
return packagescache_path_for_repoinfo( _options, info ); }
603 RefreshCheckStatus checkIfToRefreshMetadata(
const RepoInfo & info,
const Url & url, RawMetadataRefreshPolicy policy );
621 {
return PathInfo(solv_path_for_repoinfo( _options, info ) /
"solv").
isExist(); }
624 {
return RepoStatus::fromCookieFile(solv_path_for_repoinfo(_options, info) /
"cookie"); }
646 {
return foundAliasIn( alias,
_services ); }
651 return it ==
_services.end() ? ServiceInfo::noService : *it;
659 void removeService(
const std::string & alias );
661 { removeService( service.
alias() ); }
663 void refreshServices(
const RefreshServiceOptions & options_r );
665 void refreshService(
const std::string & alias,
const RefreshServiceOptions & options_r );
667 { refreshService( service.
alias(), options_r ); }
669 void modifyService(
const std::string & oldAlias,
const ServiceInfo & newService );
681 {
return filenameFromAlias( info.
alias(),
"repo" ); }
684 {
return filenameFromAlias( info.
alias(),
"service" ); }
688 Pathname base = solv_path_for_repoinfo( _options, info );
689 filesystem::assert_dir(base);
695 template<
typename OutputIterator>
699 std::copy( boost::make_filter_iterator( filter,
repos().begin(),
repos().end() ),
700 boost::make_filter_iterator( filter,
repos().end(),
repos().end() ),
721 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
724 {
return new Impl( *
this ); }
730 {
return str <<
"RepoManager::Impl"; }
734 void RepoManager::Impl::saveService(
ServiceInfo & service )
const
737 Pathname servfile = generateNonExistingName( _options.knownServicesPath,
738 generateFilename( service ) );
741 MIL <<
"saving service in " << servfile << endl;
743 std::ofstream file( servfile.
c_str() );
750 MIL <<
"done" << endl;
769 const std::string & basefilename )
const
771 std::string final_filename = basefilename;
773 while (
PathInfo(dir + final_filename).isExist() )
778 return dir +
Pathname(final_filename);
783 void RepoManager::Impl::init_knownServices()
785 Pathname dir = _options.knownServicesPath;
786 std::list<Pathname> entries;
796 for_(it, entries.begin(), entries.end() )
812 inline void cleanupNonRepoMetadtaFolders(
const Pathname & cachePath_r,
813 const Pathname & defaultCachePath_r,
814 const std::list<std::string> & repoEscAliases_r )
816 if ( cachePath_r != defaultCachePath_r )
819 std::list<std::string> entries;
823 std::set<std::string> oldfiles;
824 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
825 std::inserter( oldfiles, oldfiles.end() ) );
831 for (
const std::string & old : oldfiles )
835 pi( cachePath_r/old );
845 void RepoManager::Impl::init_knownRepositories()
847 MIL <<
"start construct known repos" << endl;
851 std::list<std::string> repoEscAliases;
852 std::list<RepoInfo> orphanedRepos;
853 for (
RepoInfo & repoInfo : repositories_in_dir(_options.knownReposPath) )
856 repoInfo.setMetadataPath( rawcache_path_for_repoinfo(_options, repoInfo) );
858 repoInfo.setPackagesPath( packagescache_path_for_repoinfo(_options, repoInfo) );
860 _reposX.insert( repoInfo );
863 const std::string & serviceAlias( repoInfo.service() );
864 if ( ! ( serviceAlias.empty() || hasService( serviceAlias ) ) )
866 WAR <<
"Schedule orphaned service repo for deletion: " << repoInfo << endl;
867 orphanedRepos.push_back( repoInfo );
871 repoEscAliases.push_back(repoInfo.escaped_alias());
875 if ( ! orphanedRepos.empty() )
877 for (
const auto & repoInfo : orphanedRepos )
879 MIL <<
"Delete orphaned service repo " << repoInfo.alias() << endl;
885 % repoInfo.alias() );
887 removeRepository( repoInfo );
901 repoEscAliases.sort();
902 cleanupNonRepoMetadtaFolders( _options.repoRawCachePath,
905 cleanupNonRepoMetadtaFolders( _options.repoSolvCachePath,
908 cleanupNonRepoMetadtaFolders( _options.repoPackagesCachePath,
912 MIL <<
"end construct known repos" << endl;
919 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
920 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
925 repokind = probeCache( productdatapath );
932 switch ( repokind.
toEnum() )
935 status =
RepoStatus( productdatapath/
"repodata/repomd.xml");
937 status = status &&
RepoStatus( mediarootpath/
"media.1/media" );
941 status =
RepoStatus( productdatapath/
"content" ) &&
RepoStatus( mediarootpath/
"media.1/media" );
955 if ( ! status.
empty() )
962 void RepoManager::Impl::touchIndexFile(
const RepoInfo & info )
964 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
969 repokind = probeCache( productdatapath );
975 switch ( repokind.
toEnum() )
978 p =
Pathname(productdatapath +
"/repodata/repomd.xml");
982 p =
Pathname(productdatapath +
"/content");
986 p =
Pathname(productdatapath +
"/cookie");
1004 MIL <<
"Check if to refresh repo " << info.
alias() <<
" at " << url <<
" (" << info.
type() <<
")" << endl;
1009 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1011 RepoStatus oldstatus = metadataStatus( info );
1013 if ( oldstatus.
empty() )
1015 MIL <<
"No cached metadata, going to refresh" << endl;
1016 return REFRESH_NEEDED;
1021 MIL <<
"Never refresh CD/DVD" << endl;
1022 return REPO_UP_TO_DATE;
1025 if ( policy == RefreshForced )
1027 MIL <<
"Forced refresh!" << endl;
1028 return REFRESH_NEEDED;
1033 policy = RefreshIfNeededIgnoreDelay;
1037 if ( policy != RefreshIfNeededIgnoreDelay )
1042 RepoStatus cachestatus = cacheStatus( info );
1044 if ( oldstatus == cachestatus )
1052 WAR <<
"Repository '" << info.
alias() <<
"' was refreshed in the future!" << endl;
1056 MIL <<
"Repository '" << info.
alias()
1057 <<
"' has been refreshed less than repo.refresh.delay ("
1059 <<
") minutes ago. Advising to skip refresh" << endl;
1060 return REPO_CHECK_DELAYED;
1065 MIL <<
"Metadata and solv cache don't match. Check data on server..." << endl;
1072 repokind = probe( url, info.
path() );
1076 switch ( repokind.
toEnum() )
1103 if ( oldstatus == newstatus )
1105 MIL <<
"repo has not changed" << endl;
1106 touchIndexFile( info );
1107 return REPO_UP_TO_DATE;
1111 MIL <<
"repo has changed, going to refresh" << endl;
1112 return REFRESH_NEEDED;
1118 ERR <<
"refresh check failed for " << url << endl;
1122 return REFRESH_NEEDED;
1135 RepoException rexception( info,
PL_(
"Valid metadata not found at specified URL",
1136 "Valid metadata not found at specified URLs",
1150 if (checkIfToRefreshMetadata(info, url, policy)!=REFRESH_NEEDED)
1153 MIL <<
"Going to refresh metadata from " << url << endl;
1161 if ( repokind != probed )
1165 for_( it, repoBegin(), repoEnd() )
1167 if ( info.
alias() == (*it).alias() )
1170 modifiedrepo.
setType( repokind );
1184 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1193 if( tmpdir.path().empty() )
1195 Exception ex(
_(
"Can't create metadata cache directory."));
1205 MIL <<
"Creating downloader for [ " << info.
alias() <<
" ]" << endl;
1209 if ( _pluginRepoverification.checkIfNeeded() )
1210 downloader_ptr->setPluginRepoverification( _pluginRepoverification );
1221 for_( it, repoBegin(), repoEnd() )
1223 Pathname cachepath(rawcache_path_for_repoinfo( _options, *it ));
1224 if (
PathInfo(cachepath).isExist() )
1225 downloader_ptr->addCachePath(cachepath);
1228 downloader_ptr->download( media, tmpdir.path() );
1233 MediaMounter media( url );
1248 if ( ! isTmpRepo( info ) )
1257 ERR <<
"Trying another url..." << endl;
1263 rexception.remember(e);
1269 ERR <<
"No more urls..." << endl;
1278 progress.sendTo(progressfnc);
1288 progress.sendTo(progressfnc);
1298 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1299 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
1306 RepoStatus raw_metadata_status = metadataStatus(info);
1307 if ( raw_metadata_status.
empty() )
1312 refreshMetadata(info, RefreshIfNeeded, progressrcv );
1313 raw_metadata_status = metadataStatus(info);
1316 bool needs_cleaning =
false;
1317 if ( isCached( info ) )
1319 MIL << info.
alias() <<
" is already cached." << endl;
1322 if ( cache_status == raw_metadata_status )
1324 MIL << info.
alias() <<
" cache is up to date with metadata." << endl;
1325 if ( policy == BuildIfNeeded )
1328 const Pathname & base = solv_path_for_repoinfo( _options, info);
1329 if ( !
PathInfo(base/
"solv.idx").isExist() )
1335 MIL << info.
alias() <<
" cache rebuild is forced" << endl;
1339 needs_cleaning =
true;
1345 progress.name(
str::form(
_(
"Building repository '%s' cache"), info.
label().c_str()));
1353 MIL << info.
alias() <<
" building cache..." << info.
type() << endl;
1355 Pathname base = solv_path_for_repoinfo( _options, info);
1374 switch ( repokind.
toEnum() )
1378 repokind = probeCache( productdatapath );
1384 MIL <<
"repo type is " << repokind << endl;
1386 switch ( repokind.
toEnum() )
1397 cmd.push_back(
PathInfo(
"/usr/bin/repo2solv" ).isFile() ?
"repo2solv" :
"repo2solv.sh" );
1399 cmd.push_back(
"-o" );
1400 cmd.push_back( solvfile.
asString() );
1401 cmd.push_back(
"-X" );
1406 forPlainDirs.reset(
new MediaMounter( info.
url() ) );
1408 cmd.push_back(
"-R" );
1410 cmd.push_back( forPlainDirs->getPathName( info.
path() ).c_str() );
1413 cmd.push_back( productdatapath.
asString() );
1416 std::string errdetail;
1418 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() ) {
1419 WAR <<
" " << output;
1420 errdetail += output;
1423 int ret = prog.close();
1427 ex.addHistory(
str::Str() << prog.command() << endl << errdetail << prog.execError() );
1432 guard.resetDispose();
1441 setCacheStatus(info, raw_metadata_status);
1442 MIL <<
"Commit cache.." << endl;
1457 MIL <<
"going to probe the repo type at " << url <<
" (" << path <<
")" << endl;
1463 MIL <<
"Probed type NONE (not exists) at " << url <<
" (" << path <<
")" << endl;
1475 bool gotMediaException =
false;
1481 if ( access.doesFileExist(path/
"/repodata/repomd.xml") )
1483 MIL <<
"Probed type RPMMD at " << url <<
" (" << path <<
")" << endl;
1487 catch (
const media::MediaException &e )
1490 DBG <<
"problem checking for repodata/repomd.xml file" << endl;
1492 gotMediaException =
true;
1497 if ( access.doesFileExist(path/
"/content") )
1499 MIL <<
"Probed type YAST2 at " << url <<
" (" << path <<
")" << endl;
1503 catch (
const media::MediaException &e )
1506 DBG <<
"problem checking for content file" << endl;
1508 gotMediaException =
true;
1514 MediaMounter media( url );
1518 MIL <<
"Probed type RPMPLAINDIR at " << url <<
" (" << path <<
")" << endl;
1532 if (gotMediaException)
1535 MIL <<
"Probed type NONE at " << url <<
" (" << path <<
")" << endl;
1546 MIL <<
"going to probe the cached repo at " << path_r << endl;
1550 if (
PathInfo(path_r/
"/repodata/repomd.xml").isFile() )
1552 else if (
PathInfo(path_r/
"/content").isFile() )
1554 else if (
PathInfo(path_r).isDir() )
1557 MIL <<
"Probed cached type " << ret <<
" at " << path_r << endl;
1565 MIL <<
"Going to clean up garbage in cache dirs" << endl;
1568 progress.sendTo(progressrcv);
1571 std::list<Pathname> cachedirs;
1572 cachedirs.push_back(_options.repoRawCachePath);
1573 cachedirs.push_back(_options.repoPackagesCachePath);
1574 cachedirs.push_back(_options.repoSolvCachePath);
1576 for_( dir, cachedirs.begin(), cachedirs.end() )
1580 std::list<Pathname> entries;
1585 unsigned sdircount = entries.size();
1586 unsigned sdircurrent = 1;
1587 for_( subdir, entries.begin(), entries.end() )
1591 for_( r, repoBegin(), repoEnd() )
1592 if ( subdir->basename() == r->escaped_alias() )
1593 { found =
true;
break; }
1598 progress.set( progress.val() + sdircurrent * 100 / sdircount );
1603 progress.set( progress.val() + 100 );
1613 progress.sendTo(progressrcv);
1616 MIL <<
"Removing raw metadata cache for " << info.
alias() << endl;
1627 Pathname solvfile = solv_path_for_repoinfo(_options, info) /
"solv";
1629 if ( !
PathInfo(solvfile).isExist() )
1639 if ( toolversion != LIBSOLV_TOOLVERSION )
1648 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1649 cleanCache( info, progressrcv );
1650 buildCache( info, BuildIfNeeded, progressrcv );
1665 progress.name(
str::form(
_(
"Adding repository '%s'"), info.
label().c_str()));
1668 MIL <<
"Try adding repo " << info << endl;
1675 if ( _options.probe )
1677 DBG <<
"unknown repository type, probing" << endl;
1678 assert_urls(tosave);
1692 Pathname repofile = generateNonExistingName(
1693 _options.knownReposPath, generateFilename(tosave));
1695 MIL <<
"Saving repo in " << repofile << endl;
1697 std::ofstream file(repofile.
c_str());
1706 tosave.
setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1707 tosave.
setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1712 oinfo.setFilepath(repofile);
1713 oinfo.setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1714 oinfo.setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1716 reposManip().insert(tosave);
1721 UrlCredentialExtractor( _options.rootDir ).collect( tosave.
baseUrls() );
1726 MIL <<
"done" << endl;
1733 for ( std::list<RepoInfo>::const_iterator it =
repos.begin();
1738 for_ ( kit, repoBegin(), repoEnd() )
1740 if ( (*it).alias() == (*kit).alias() )
1742 ERR <<
"To be added repo " << (*it).alias() <<
" conflicts with existing repo " << (*kit).alias() << endl;
1759 Pathname repofile = generateNonExistingName(_options.knownReposPath, filename);
1761 MIL <<
"Saving " <<
repos.size() <<
" repo" << (
repos.size() ?
"s" :
"" ) <<
" in " << repofile << endl;
1763 std::ofstream file(repofile.
c_str());
1770 for ( std::list<RepoInfo>::iterator it =
repos.begin();
1774 MIL <<
"Saving " << (*it).alias() << endl;
1775 it->dumpAsIniOn(file);
1776 it->setFilepath(repofile);
1777 it->setMetadataPath( rawcache_path_for_repoinfo( _options, *it ) );
1778 it->setPackagesPath( packagescache_path_for_repoinfo( _options, *it ) );
1779 reposManip().insert(*it);
1784 MIL <<
"done" << endl;
1796 MIL <<
"Going to delete repo " << info.
alias() << endl;
1798 for_( it, repoBegin(), repoEnd() )
1803 if ( (!info.
alias().empty()) && ( info.
alias() != (*it).alias() ) )
1818 std::list<RepoInfo> filerepos = repositories_in_file(todelete.
filepath());
1819 if ( filerepos.size() == 0
1820 ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.
alias() ) )
1824 if ( ! ( ret == 0 || ret == ENOENT ) )
1829 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1847 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1848 fit != filerepos.end();
1851 if ( (*fit).alias() != todelete.
alias() )
1852 (*fit).dumpAsIniOn(file);
1860 if ( isCached(todelete) )
1861 cleanCache( todelete, cSubprogrcv);
1863 cleanMetadata( todelete, mSubprogrcv );
1864 cleanPackages( todelete, pSubprogrcv );
1865 reposManip().erase(todelete);
1866 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1880 RepoInfo toedit = getRepositoryInfo(alias);
1884 if ( alias != newinfo.alias() && hasRepo( newinfo.alias() ) )
1896 std::list<RepoInfo> filerepos = repositories_in_file(toedit.
filepath());
1912 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1913 fit != filerepos.end();
1918 if ( (*fit).alias() != toedit.
alias() )
1919 (*fit).dumpAsIniOn(file);
1921 newinfo.dumpAsIniOn(file);
1924 if ( toedit.
enabled() && !newinfo.enabled() )
1927 const Pathname & solvidx = solv_path_for_repoinfo(_options, newinfo)/
"solv.idx";
1932 newinfo.setFilepath(toedit.
filepath());
1933 newinfo.setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1934 newinfo.setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1939 oinfo.setFilepath(toedit.
filepath());
1940 oinfo.setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1941 oinfo.setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1943 reposManip().erase(toedit);
1944 reposManip().insert(newinfo);
1946 UrlCredentialExtractor( _options.rootDir ).collect( newinfo.baseUrls() );
1948 MIL <<
"repo " << alias <<
" modified" << endl;
1956 RepoConstIterator it( findAlias( alias,
repos() ) );
1957 if ( it !=
repos().end() )
1967 for_( it, repoBegin(), repoEnd() )
1969 for_( urlit, (*it).baseUrlsBegin(), (*it).baseUrlsEnd() )
1971 if ( (*urlit).asString(urlview) == url.
asString(urlview) )
1986 void RepoManager::Impl::addService(
const ServiceInfo & service )
1988 assert_alias( service );
1991 if ( hasService( service.
alias() ) )
1997 saveService( toSave );
2001 UrlCredentialExtractor( _options.rootDir ).collect( toSave.url() );
2003 MIL <<
"added service " << toSave.alias() << endl;
2008 void RepoManager::Impl::removeService(
const std::string & alias )
2010 MIL <<
"Going to delete service " << alias << endl;
2012 const ServiceInfo & service = getService( alias );
2015 if( location.
empty() )
2024 if ( tmpSet.size() == 1 )
2031 MIL << alias <<
" successfully deleted." << endl;
2037 std::ofstream file(location.
c_str());
2044 for_(it, tmpSet.begin(), tmpSet.end())
2046 if( it->alias() != alias )
2047 it->dumpAsIniOn(file);
2050 MIL << alias <<
" successfully deleted from file " << location << endl;
2054 RepoCollector rcollector;
2055 getRepositoriesInService( alias,
2056 boost::make_function_output_iterator( bind( &RepoCollector::collect, &rcollector, _1 ) ) );
2058 for_(rit, rcollector.repos.begin(), rcollector.repos.end())
2059 removeRepository(*rit);
2064 void RepoManager::
Impl::refreshServices( const RefreshServiceOptions & options_r )
2068 ServiceSet services( serviceBegin(), serviceEnd() );
2069 for_( it, services.begin(), services.end() )
2071 if ( !it->enabled() )
2075 refreshService(*it, options_r);
2082 void RepoManager::Impl::refreshService(
const std::string & alias,
const RefreshServiceOptions & options_r )
2085 assert_alias( service );
2086 assert_url( service );
2087 MIL <<
"Going to refresh service '" << service.
alias() <<
"', url: " << service.
url() <<
", opts: " << options_r << endl;
2089 if ( service.
ttl() && !( options_r.testFlag( RefreshService_forceRefresh) || options_r.testFlag( RefreshService_restoreStatus ) ) )
2098 if ( (lrf+=service.
ttl()) > now )
2100 MIL <<
"Skip: '" << service.
alias() <<
"' metadata valid until " << lrf << endl;
2105 WAR <<
"Force: '" << service.
alias() <<
"' metadata last refresh in the future: " << lrf << endl;
2112 bool serviceModified =
false;
2123 serviceModified =
true;
2128 std::string servicesTargetDistro = _options.servicesTargetDistro;
2129 if ( servicesTargetDistro.empty() )
2133 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << endl;
2137 RepoCollector collector(servicesTargetDistro);
2150 ServiceRepos( _options.rootDir, service, bind( &RepoCollector::collect, &collector, _1 ) );
2155 uglyHack.first =
true;
2156 uglyHack.second = e;
2158 if ( service.
ttl() != origTtl )
2160 if ( !service.
ttl() )
2162 serviceModified =
true;
2170 for_( it, collector.repos.begin(), collector.repos.end() )
2173 it->setAlias(
str::form(
"%s:%s", service.
alias().c_str(), it->alias().c_str() ) );
2175 it->setService( service.
alias() );
2178 newRepoStates[it->alias()] = *it;
2186 if ( !it->path().empty() )
2188 if ( it->path() !=
"/" )
2193 if ( it->baseUrlsEmpty() )
2196 if ( !path.
empty() )
2198 it->setBaseUrl( std::move(url) );
2200 else if ( !path.
empty() )
2203 for (
Url & url : urls )
2207 it->setBaseUrls( std::move(urls) );
2214 RepoInfoList oldRepos;
2215 getRepositoriesInService( service.
alias(), std::back_inserter( oldRepos ) );
2219 for_( oldRepo, oldRepos.begin(), oldRepos.end() )
2221 if ( ! foundAliasIn( oldRepo->alias(), collector.repos ) )
2223 if ( oldRepo->enabled() )
2226 const auto & last = service.
repoStates().find( oldRepo->alias() );
2227 if ( last != service.
repoStates().end() && ! last->second.enabled )
2229 DBG <<
"Service removes user enabled repo " << oldRepo->alias() << endl;
2231 serviceModified =
true;
2234 DBG <<
"Service removes enabled repo " << oldRepo->alias() << endl;
2237 DBG <<
"Service removes disabled repo " << oldRepo->alias() << endl;
2239 removeRepository( *oldRepo );
2245 UrlCredentialExtractor urlCredentialExtractor( _options.rootDir );
2246 for_( it, collector.repos.begin(), collector.repos.end() )
2252 TriBool toBeEnabled( indeterminate );
2253 DBG <<
"Service request to " << (it->enabled()?
"enable":
"disable") <<
" service repo " << it->alias() << endl;
2255 if ( options_r.testFlag( RefreshService_restoreStatus ) )
2257 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() << endl;
2269 DBG <<
"User request to enable service repo " << it->alias() << endl;
2275 serviceModified =
true;
2279 DBG <<
"User request to disable service repo " << it->alias() << endl;
2280 toBeEnabled =
false;
2284 RepoInfoList::iterator oldRepo( findAlias( it->alias(), oldRepos ) );
2285 if ( oldRepo == oldRepos.end() )
2290 if ( ! indeterminate(toBeEnabled) )
2291 it->setEnabled( (
bool ) toBeEnabled );
2293 DBG <<
"Service adds repo " << it->alias() <<
" " << (it->enabled()?
"enabled":
"disabled") << endl;
2294 addRepository( *it );
2299 bool oldRepoModified =
false;
2301 if ( indeterminate(toBeEnabled) )
2305 if ( oldRepo->enabled() == it->enabled() )
2306 toBeEnabled = it->enabled();
2307 else if (options_r.testFlag( RefreshService_restoreStatus ) )
2309 toBeEnabled = it->enabled();
2310 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() <<
" forces " << (toBeEnabled?
"enabled":
"disabled") << endl;
2314 const auto & last = service.
repoStates().find( oldRepo->alias() );
2315 if ( last == service.
repoStates().end() || last->second.enabled != it->enabled() )
2316 toBeEnabled = it->enabled();
2319 toBeEnabled = oldRepo->enabled();
2320 DBG <<
"User modified service repo " << it->alias() <<
" may stay " << (toBeEnabled?
"enabled":
"disabled") << endl;
2326 if ( toBeEnabled == oldRepo->enabled() )
2328 DBG <<
"Service repo " << it->alias() <<
" stays " << (oldRepo->enabled()?
"enabled":
"disabled") << endl;
2330 else if ( toBeEnabled )
2332 DBG <<
"Service repo " << it->alias() <<
" gets enabled" << endl;
2333 oldRepo->setEnabled(
true );
2334 oldRepoModified =
true;
2338 DBG <<
"Service repo " << it->alias() <<
" gets disabled" << endl;
2339 oldRepo->setEnabled(
false );
2340 oldRepoModified =
true;
2346 if ( oldRepo->rawName() != it->rawName() )
2348 DBG <<
"Service repo " << it->alias() <<
" gets new NAME " << it->rawName() << endl;
2349 oldRepo->setName( it->rawName() );
2350 oldRepoModified =
true;
2354 if ( oldRepo->autorefresh() != it->autorefresh() )
2356 DBG <<
"Service repo " << it->alias() <<
" gets new AUTOREFRESH " << it->autorefresh() << endl;
2357 oldRepo->setAutorefresh( it->autorefresh() );
2358 oldRepoModified =
true;
2362 if ( oldRepo->priority() != it->priority() )
2364 DBG <<
"Service repo " << it->alias() <<
" gets new PRIORITY " << it->priority() << endl;
2365 oldRepo->setPriority( it->priority() );
2366 oldRepoModified =
true;
2372 urlCredentialExtractor.extract( newUrls );
2373 if ( oldRepo->rawBaseUrls() != newUrls )
2375 DBG <<
"Service repo " << it->alias() <<
" gets new URLs " << newUrls << endl;
2376 oldRepo->setBaseUrls( std::move(newUrls) );
2377 oldRepoModified =
true;
2387 oldRepo->getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
2388 it-> getRawGpgChecks( ngpg[0], ngpg[1], ngpg[2] );
2389#define Z_CHKGPG(I,N) \
2390 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \
2392 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \
2393 oldRepo->set##N##Check( ngpg[I] ); \
2394 oldRepoModified = true; \
2403 if ( oldRepoModified )
2405 modifyRepository( oldRepo->alias(), *oldRepo );
2414 serviceModified =
true;
2421 serviceModified =
true;
2428 if ( service.
ttl() )
2431 serviceModified =
true;
2434 if ( serviceModified )
2437 modifyService( service.
alias(), service );
2441 if ( uglyHack.first )
2443 throw( uglyHack.second );
2449 void RepoManager::Impl::modifyService(
const std::string & oldAlias,
const ServiceInfo & newService )
2451 MIL <<
"Going to modify service " << oldAlias << endl;
2462 const ServiceInfo & oldService = getService(oldAlias);
2465 if( location.
empty() )
2475 std::ofstream file(location.
c_str());
2476 for_(it, tmpSet.begin(), tmpSet.end())
2478 if( *it != oldAlias )
2479 it->dumpAsIniOn(file);
2488 UrlCredentialExtractor( _options.rootDir ).collect( service.
url() );
2492 if ( oldAlias != service.
alias()
2495 std::vector<RepoInfo> toModify;
2496 getRepositoriesInService(oldAlias, std::back_inserter(toModify));
2497 for_( it, toModify.begin(), toModify.end() )
2504 const auto & last = service.
repoStates().find( it->alias() );
2506 it->setEnabled( last->second.enabled );
2509 it->setEnabled(
false );
2512 if ( oldAlias != service.
alias() )
2513 it->setService(service.
alias());
2515 modifyRepository(it->alias(), *it);
2529 if ( access.doesFileExist(
"/repo/repoindex.xml") )
2532 catch (
const media::MediaException &e )
2552 void RepoManager::Impl::refreshGeoIPData ()
2557 MIL <<
"GeoIp disabled via ZConfig, not refreshing the GeoIP information." << std::endl;
2563 static auto lastCheck = std::chrono::steady_clock::time_point::min();
2564 if ( lastCheck != std::chrono::steady_clock::time_point::min()
2565 && (std::chrono::steady_clock::now() - lastCheck) < std::chrono::hours(24) )
2568 lastCheck = std::chrono::steady_clock::now();
2573 MIL <<
"Unable to create cache directory for GeoIP." << std::endl;
2577 if ( !
PathInfo(geoIPCache).userMayRWX() ) {
2578 MIL <<
"No access rights for the GeoIP cache directory." << std::endl;
2588 auto age = std::chrono::system_clock::now() - std::chrono::system_clock::from_time_t( pi.
mtime() );
2589 if ( age < std::chrono::hours(24) )
2592 MIL <<
"Removing GeoIP file for " << entry.
name <<
" since it's older than 24hrs." << std::endl;
2599 std::for_each( hosts.begin(), hosts.end(), [ & ](
const std::string &hostname ) {
2602 if ( zypp::PathInfo( geoIPCache / hostname ).isExist() ) {
2603 MIL <<
"Skipping GeoIP request for " << hostname <<
" since a valid cache entry exists." << std::endl;
2607 MIL <<
"Query GeoIP for " << hostname << std::endl;
2612 url.setHost(hostname);
2613 url.setScheme(
"https");
2618 MIL <<
"Ignoring invalid GeoIP hostname: " << hostname << std::endl;
2630 MIL <<
"Failed to query GeoIP from hostname: " << hostname << std::endl;
2633 if ( !file->empty() ) {
2635 constexpr auto writeHostToFile = [](
const Pathname &fName,
const std::string &host ){
2637 out.open( fName.
asString(), std::ios_base::trunc );
2638 if ( out.is_open() ) {
2639 out << host << std::endl;
2641 MIL <<
"Failed to create/open GeoIP cache file " << fName << std::endl;
2645 std::string geoipMirror;
2648 if ( reader.seekToNode( 1,
"host" ) ) {
2649 const auto &
str = reader.nodeText().asString();
2657 MIL <<
"Storing geoIP redirection: " << hostname <<
" -> " <<
str << std::endl;
2662 MIL <<
"No host entry or empty file returned for GeoIP, remembering for 24hrs" << std::endl;
2666 MIL <<
"Empty or invalid GeoIP file, not requesting again for 24hrs" << std::endl;
2669 writeHostToFile( geoIPCache / hostname, geoipMirror );
2675 MIL <<
"Failed to query GeoIP data." << std::endl;
2686 : _pimpl( new
Impl(opt) )
2693 {
return _pimpl->repoEmpty(); }
2696 {
return _pimpl->repoSize(); }
2699 {
return _pimpl->repoBegin(); }
2702 {
return _pimpl->repoEnd(); }
2705 {
return _pimpl->getRepo( alias ); }
2708 {
return _pimpl->hasRepo( alias ); }
2718 std::string host( url_r.
getHost() );
2719 if ( ! host.empty() )
2731 {
return _pimpl->metadataStatus( info ); }
2734 {
return _pimpl->checkIfToRefreshMetadata( info, url, policy ); }
2737 {
return _pimpl->metadataPath( info ); }
2740 {
return _pimpl->packagesPath( info ); }
2743 {
return _pimpl->refreshMetadata( info, policy, progressrcv ); }
2746 {
return _pimpl->cleanMetadata( info, progressrcv ); }
2749 {
return _pimpl->cleanPackages( info, progressrcv ); }
2752 {
return _pimpl->cacheStatus( info ); }
2755 {
return _pimpl->buildCache( info, policy, progressrcv ); }
2758 {
return _pimpl->cleanCache( info, progressrcv ); }
2761 {
return _pimpl->isCached( info ); }
2764 {
return _pimpl->loadFromCache( info, progressrcv ); }
2767 {
return _pimpl->cleanCacheDirGarbage( progressrcv ); }
2770 {
return _pimpl->probe( url, path ); }
2773 {
return _pimpl->probe( url ); }
2776 {
return _pimpl->addRepository( info, progressrcv ); }
2779 {
return _pimpl->addRepositories( url, progressrcv ); }
2782 {
return _pimpl->removeRepository( info, progressrcv ); }
2785 {
return _pimpl->modifyRepository( alias, newinfo, progressrcv ); }
2788 {
return _pimpl->getRepositoryInfo( alias, progressrcv ); }
2791 {
return _pimpl->getRepositoryInfo( url, urlview, progressrcv ); }
2794 {
return _pimpl->serviceEmpty(); }
2797 {
return _pimpl->serviceSize(); }
2800 {
return _pimpl->serviceBegin(); }
2803 {
return _pimpl->serviceEnd(); }
2806 {
return _pimpl->getService( alias ); }
2809 {
return _pimpl->hasService( alias ); }
2812 {
return _pimpl->probeService( url ); }
2815 {
return _pimpl->addService( alias, url ); }
2818 {
return _pimpl->addService( service ); }
2821 {
return _pimpl->removeService( alias ); }
2824 {
return _pimpl->removeService( service ); }
2827 {
return _pimpl->refreshServices( options_r ); }
2830 {
return _pimpl->refreshService( alias, options_r ); }
2833 {
return _pimpl->refreshService( service, options_r ); }
2836 {
return _pimpl->modifyService( oldAlias, service ); }
2839 {
return _pimpl->refreshGeoIPData(); }
media::MediaAccessId _mid
scoped_ptr< media::CredentialManager > _cmPtr
RepoManager implementation.
std::ostream & operator<<(std::ostream &str, const RepoManager::Impl &obj)
Stream output.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Progress callback from another progress.
Store and operate on date (time_t).
static const ValueType day
static Date now()
Return the current time.
Integral type with defined initial value when default constructed.
std::string digest()
get hex string representation of the digest
static const std::string & sha1()
sha1
Base class for Exception.
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
std::string asUserString() const
Translated error message as string suitable for the user.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::vector< std::string > Arguments
Writing the zypp history file.
void modifyRepository(const RepoInfo &oldrepo, const RepoInfo &newrepo)
Log certain modifications to a repository.
void addRepository(const RepoInfo &repo)
Log a newly added repository.
void removeRepository(const RepoInfo &repo)
Log recently removed repository.
Maintain [min,max] and counter (value) for progress counting.
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
void name(const std::string &name_r)
Set counter name.
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
What is known about a repository.
Pathname metadataPath() const
Path where this repo metadata was read from.
bool baseUrlsEmpty() const
whether repository urls are available
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
repo::RepoType type() const
Type of repository,.
urls_size_type baseUrlsSize() const
number of repository urls
Url url() const
Pars pro toto: The first repository url.
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Pathname path() const
Repository path.
url_set baseUrls() const
The complete set of repository urls.
bool requireStatusWithMediaFile() const
Returns true if this repository requires the media.1/media file to be included in the metadata status...
bool usesAutoMethadataPaths() const
Whether metadataPath uses AUTO% setup.
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects.
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Pathname packagesPath() const
Path where this repo packages are cached.
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
std::string targetDistribution() const
Distribution for which is this repository meant.
void setType(const repo::RepoType &t)
set the repository type
Track changing files or directories.
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
Date timestamp() const
The time the data were changed the last time.
bool empty() const
Whether the status is empty (empty checksum)
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
void eraseFromPool()
Remove this Repository from its Pool.
repo::ServiceType type() const
Service type.
Date::Duration ttl() const
Sugested TTL between two metadata auto-refreshs.
void setLrf(Date lrf_r)
Set date of last refresh.
Date lrf() const
Date of last refresh (if known).
bool repoToDisableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToDisable.
bool repoToEnableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToEnable.
const RepoStates & repoStates() const
Access the remembered repository states.
Url url() const
The service url.
void setProbedType(const repo::ServiceType &t) const
Lazy init service type.
std::map< std::string, RepoState > RepoStates
Url rawUrl() const
The service raw url (no variables replaced)
void addRepoToEnable(const std::string &alias_r)
Add alias_r to the set of ReposToEnable.
void clearReposToDisable()
Clear the set of ReposToDisable.
void delRepoToEnable(const std::string &alias_r)
Remove alias_r from the set of ReposToEnable.
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Writes ServiceInfo to stream in ".service" format.
void setRepoStates(RepoStates newStates_r)
Remember a new set of repository states.
bool reposToDisableEmpty() const
std::string targetDistribution() const
This is register.target attribute of the installed base product.
std::string getScheme() const
Returns the scheme name of the URL.
std::string asCompleteString() const
Returns a complete string representation of the Url object.
std::string asString() const
Returns a default string representation of the Url object.
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
static bool schemeIsLocal(const std::string &scheme_r)
hd cd dvd dir file iso
bool isValid() const
Verifies the Url.
void setPassword(const std::string &pass, EEncoding eflag=zypp::url::E_DECODED)
Set the password in the URL authority.
static bool schemeIsPlugin(const std::string &scheme_r)
plugin
bool hasCredentialsInAuthority() const
Returns true if username and password are encoded in the authority component.
void setScheme(const std::string &scheme)
Set the scheme name in the URL.
static bool schemeIsDownloading(const std::string &scheme_r)
http https ftp sftp tftp
static bool schemeIsVolatile(const std::string &scheme_r)
cd dvd
unsigned repo_refresh_delay() const
Amount of time in minutes that must pass before another refresh.
const std::vector< std::string > geoipHostnames() const
All hostnames we want to rewrite using the geoip feature.
Pathname builtinRepoSolvfilesPath() const
The builtin config file value.
bool repo_add_probe() const
Whether repository urls should be probed.
Pathname geoipCachePath() const
Path where the geoip caches are kept (/var/cache/zypp/geoip)
static ZConfig & instance()
Singleton ctor.
Pathname builtinRepoPackagesPath() const
The builtin config file value.
Pathname builtinRepoMetadataPath() const
The builtin config file value.
Wrapper class for stat/lstat.
const Pathname & path() const
Return current Pathname.
bool isExist() const
Return whether valid stat info exists.
const std::string & asString() const
Return current Pathname as String.
Pathname extend(const std::string &r) const
Append string r to the last component of the path.
Pathname dirname() const
Return all but the last component od this path.
const char * c_str() const
String representation.
const std::string & asString() const
String representation.
std::string basename() const
Return the last component of this path.
bool empty() const
Test for an empty path.
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r prefixed with root_r, unless it is already prefixed.
Provide a new empty temporary directory and recursively delete it when no longer needed.
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Read repository data from a .repo file.
Read service data from a .service file.
Repository already exists and some unique attribute can't be duplicated.
Exception for repository handling.
std::string label() const
Label for use in messages for the user interface.
std::string escaped_alias() const
Same as alias(), just escaped in a way to be a valid file name.
void setFilepath(const Pathname &filename)
set the path to the .repo file
void setAlias(const std::string &alias)
set the repository alias
Pathname filepath() const
File where this repo was read from.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
std::string alias() const
unique identifier for this source.
Thrown when the repo alias is found to be invalid.
thrown when it was impossible to determine an alias for this repo.
thrown when it was impossible to determine one url for this repo.
The repository cache is not built yet so you can't create the repostories from the cache.
thrown when it was impossible to match a repository
thrown when it was impossible to determine this repo type.
Service already exists and some unique attribute can't be duplicated.
Base Exception for service handling.
Thrown when the repo alias is found to be invalid.
Service without alias was used in an operation.
Service has no or invalid url defined.
Service plugin is immutable.
Retrieval of repository list for a service.
Downloader for YUM (rpm-nmd) repositories Encapsulates all the knowledge of which files have to be do...
RepoStatus status(MediaSetAccess &media_r) override
Status of the remote repository.
Lightweight repository attribute value lookup.
void reposErase(const std::string &alias_r)
Remove a Repository named alias_r.
Repository addRepoSolv(const Pathname &file_r, const std::string &name_r)
Load Solvables from a solv-file into a Repository named name_r.
static Pool instance()
Singleton ctor.
static const SolvAttr repositoryToolVersion
xmlTextReader based interface to iterate xml streams.
Repository metadata verification beyond GPG.
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
std::string asString(TInt val, char zero='0', char one='1')
For printing bits.
bool ZYPP_PLUGIN_APPDATA_FORCE_COLLECT()
To trigger appdata refresh unconditionally.
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
int unlink(const Pathname &path)
Like 'unlink'.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
int touch(const Pathname &path)
Change file's modification and access times.
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
int dirForEachExt(const Pathname &dir_r, const function< bool(const Pathname &, const DirEntry &)> &fnc_r)
Simiar to.
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
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).
std::string numstring(char n, int w=0)
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
std::string hexstring(char n, int w=4)
Easy-to use interface to the ZYPP dependency resolver.
std::list< RepoInfo > readRepoFile(const Url &repo_file)
Parses repo_file and returns a list of RepoInfo objects corresponding to repositories found within th...
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
static bool error(const std::string &msg_r, const UserData &userData_r=UserData())
send error text
static RepoManagerOptions makeTestSetup(const Pathname &root_r)
Test setup adjusting all paths to be located below one root_r directory.
Pathname repoSolvCachePath
Pathname rootDir
remembers root_r value for later use
Pathname knownServicesPath
Pathname repoRawCachePath
Pathname repoPackagesCachePath
RepoManagerOptions(const Pathname &root_r=Pathname())
Default ctor following ZConfig global settings.
Functor thats filter RepoInfo by service which it belongs to.
creates and provides information about known sources.
bool hasRepo(const std::string &alias) const
ServiceSet::const_iterator ServiceConstIterator
bool serviceEmpty() const
bool hasService(const std::string &alias) const
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy)
Impl * clone() const
clone for RWCOW_pointer
void refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
void addRepository(const RepoInfo &info, OPT_PROGRESS)
RepoSet::const_iterator RepoConstIterator
RepoInfo getRepositoryInfo(const Url &url, const url::ViewOption &urlview, OPT_PROGRESS)
void addService(const std::string &alias, const Url &url)
std::string generateFilename(const ServiceInfo &info) const
bool isCached(const RepoInfo &info) const
void modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, OPT_PROGRESS)
void loadFromCache(const RepoInfo &info, OPT_PROGRESS)
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, OPT_PROGRESS)
void removeService(const std::string &alias)
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
void buildCache(const RepoInfo &info, CacheBuildPolicy policy, OPT_PROGRESS)
RepoManager(const RepoManagerOptions &options=RepoManagerOptions())
RepoInfo getRepo(const std::string &alias) const
repo::ServiceType probeService(const Url &url) const
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
RepoInfo getRepositoryInfo(const std::string &alias, OPT_PROGRESS)
void cleanCacheDirGarbage(OPT_PROGRESS)
void addService(const ServiceInfo &service)
void init_knownRepositories()
Pathname metadataPath(const RepoInfo &info) const
ServiceSet::size_type ServiceSizeType
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
Pathname packagesPath(const RepoInfo &info) const
DefaultIntegral< bool, false > _reposDirty
RepoManagerOptions _options
RepoStatus cacheStatus(const RepoInfo &info) const
void touchIndexFile(const RepoInfo &info)
repo::RepoType probeCache(const Pathname &path_r) const
void modifyService(const std::string &oldAlias, const ServiceInfo &newService)
ServiceConstIterator serviceEnd() const
ServiceConstIterator serviceBegin() const
void cleanCache(const RepoInfo &info, OPT_PROGRESS)
repo::RepoType probe(const Url &url, const Pathname &path=Pathname()) const
void removeRepository(const RepoInfo &info, OPT_PROGRESS)
RepoSizeType repoSize() const
void removeService(const ServiceInfo &service)
ServiceSizeType serviceSize() const
void cleanPackages(const RepoInfo &info, OPT_PROGRESS)
RepoSet::size_type RepoSizeType
void saveService(ServiceInfo &service) const
void addRepositories(const Url &url, OPT_PROGRESS)
void cleanMetadata(const RepoInfo &info, OPT_PROGRESS)
ServiceInfo getService(const std::string &alias) const
Pathname generateNonExistingName(const Pathname &dir, const std::string &basefilename) const
void refreshServices(const RefreshServiceOptions &options_r)
RepoConstIterator repoBegin() const
const RepoSet & repos() const
Iterate the known repositories.
void init_knownServices()
Impl(const RepoManagerOptions &opt)
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
RepoConstIterator repoEnd() const
void setCacheStatus(const RepoInfo &info, const RepoStatus &status)
RepoStatus metadataStatus(const RepoInfo &info) 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.
std::string generateFilename(const RepoInfo &info) const
PluginRepoverification _pluginRepoverification
Listentry returned by readdir.
Repository type enumeration.
static const RepoType YAST2
static const RepoType RPMMD
static const RepoType NONE
static const RepoType RPMPLAINDIR
Service type enumeration.
static const ServiceType NONE
No service set.
static const ServiceType RIS
Repository Index Service (RIS) (formerly known as 'Novell Update' (NU) service)
static const ServiceType PLUGIN
Plugin services are scripts installed on your system that provide the package manager with repositori...
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Url::asString() view options.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
#define PL_(MSG1, MSG2, N)