21#include <solv/solvversion.h>
24#include <zypp/base/LogTools.h>
25#include <zypp/base/Gettext.h>
27#include <zypp/base/Function.h>
28#include <zypp/base/Regex.h>
29#include <zypp/PathInfo.h>
30#include <zypp/TmpPath.h>
40#include <zypp/ExternalProgram.h>
41#include <zypp/ManagedFile.h>
46#include <zypp/repo/yum/Downloader.h>
47#include <zypp/repo/susetags/Downloader.h>
62#define OPT_PROGRESS const ProgressData::ReceiverFnc & = ProgressData::ReceiverFnc()
74 const char * env = getenv(
"ZYPP_PLUGIN_APPDATA_FORCE_COLLECT");
104 class UrlCredentialExtractor
107 UrlCredentialExtractor( Pathname & root_r )
111 ~UrlCredentialExtractor()
115 bool collect(
const Url & url_r )
117 bool ret = url_r.hasCredentialsInAuthority();
121 _cmPtr->addUserCred( url_r );
126 template<
class TContainer>
127 bool collect(
const TContainer & urls_r )
128 {
bool ret =
false;
for (
const Url & url : urls_r ) {
if ( collect( url ) && !ret ) ret =
true; }
return ret; }
131 bool extract( Url & url_r )
133 bool ret = collect( url_r );
135 url_r.setPassword( std::string() );
139 template<
class TContainer>
140 bool extract( TContainer & urls_r )
141 {
bool ret =
false;
for ( Url & url : urls_r ) {
if ( extract( url ) && !ret ) ret =
true; }
return ret; }
145 scoped_ptr<media::CredentialManager>
_cmPtr;
160 MediaMounter(
const Url & url_r )
162 media::MediaManager mediamanager;
163 _mid = mediamanager.open( url_r );
164 mediamanager.attach(
_mid );
170 media::MediaManager mediamanager;
171 mediamanager.release(
_mid );
172 mediamanager.close(
_mid );
179 Pathname getPathName(
const Pathname & path_r = Pathname() )
const
181 media::MediaManager mediamanager;
182 return mediamanager.localPath(
_mid, path_r );
191 template <
class Iterator>
192 inline bool foundAliasIn(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
194 for_( it, begin_r, end_r )
195 if ( it->alias() == alias_r )
200 template <
class Container>
201 inline bool foundAliasIn(
const std::string & alias_r,
const Container & cont_r )
202 {
return foundAliasIn( alias_r, cont_r.begin(), cont_r.end() ); }
205 template <
class Iterator>
206 inline Iterator findAlias(
const std::string & alias_r, Iterator begin_r, Iterator end_r )
208 for_( it, begin_r, end_r )
209 if ( it->alias() == alias_r )
214 template <
class Container>
215 inline typename Container::iterator findAlias(
const std::string & alias_r, Container & cont_r )
216 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
218 template <
class Container>
219 inline typename Container::const_iterator findAlias(
const std::string & alias_r,
const Container & cont_r )
220 {
return findAlias( alias_r, cont_r.begin(), cont_r.end() ); }
224 inline std::string filenameFromAlias(
const std::string & alias_r,
const std::string & stem_r )
226 std::string filename( alias_r );
230 filename = Pathname(filename).extend(
"."+stem_r).asString();
231 MIL <<
"generating filename for " << stem_r <<
" [" << alias_r <<
"] : '" << filename <<
"'" << endl;
255 RepoCollector(
const std::string & targetDistro_)
259 bool collect(
const RepoInfo &repo )
263 && !repo.targetDistribution().empty()
267 <<
"Skipping repository meant for '" << repo.targetDistribution()
268 <<
"' distribution (current distro is '"
274 repos.push_back(repo);
288 std::list<RepoInfo> repositories_in_file(
const Pathname & file )
290 MIL <<
"repo file: " << file << endl;
291 RepoCollector collector;
292 parser::RepoFileReader parser( file, bind( &RepoCollector::collect, &collector, _1 ) );
293 return std::move(collector.repos);
306 std::list<RepoInfo> repositories_in_dir(
const Pathname &dir )
308 MIL <<
"directory " << dir << endl;
309 std::list<RepoInfo>
repos;
310 bool nonroot( geteuid() != 0 );
311 if ( nonroot && ! PathInfo(dir).userMayRX() )
313 JobReport::warning( str::Format(
_(
"Cannot read repo directory '%1%': Permission denied")) % dir );
317 std::list<Pathname> entries;
324 str::regex allowedRepoExt(
"^\\.repo(_[0-9]+)?$");
325 for ( std::list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
329 if ( nonroot && ! PathInfo(*it).userMayR() )
331 JobReport::warning( str::Format(
_(
"Cannot read repo file '%1%': Permission denied")) % *it );
335 const std::list<RepoInfo> & tmp( repositories_in_file( *it ) );
336 repos.insert(
repos.end(), tmp.begin(), tmp.end() );
346 inline void assert_alias(
const RepoInfo & info )
348 if ( info.alias().empty() )
352 if ( info.alias()[0] ==
'.')
354 info,
_(
"Repository alias cannot start with dot.")));
357 inline void assert_alias(
const ServiceInfo & info )
359 if ( info.alias().empty() )
363 if ( info.alias()[0] ==
'.')
365 info,
_(
"Service alias cannot start with dot.")));
370 inline void assert_urls(
const RepoInfo & info )
372 if ( info.baseUrlsEmpty() )
376 inline void assert_url(
const ServiceInfo & info )
378 if ( ! info.url().isValid() )
388 inline bool isTmpRepo(
const RepoInfo & info_r )
389 {
return( info_r.filepath().empty() && info_r.usesAutoMethadataPaths() ); }
397 inline Pathname rawcache_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
400 return isTmpRepo( info ) ? info.metadataPath() : opt.repoRawCachePath / info.escaped_alias();
411 inline Pathname rawproductdata_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
412 {
return rawcache_path_for_repoinfo( opt, info ) / info.path(); }
417 inline Pathname packagescache_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
420 return isTmpRepo( info ) ? info.packagesPath() : opt.repoPackagesCachePath / info.escaped_alias();
426 inline Pathname solv_path_for_repoinfo(
const RepoManagerOptions &opt,
const RepoInfo &info )
429 return isTmpRepo( info ) ? info.metadataPath().dirname() /
"%SLV%" : opt.repoSolvCachePath / info.escaped_alias();
435 class ServiceCollector
438 typedef std::set<ServiceInfo> ServiceSet;
440 ServiceCollector( ServiceSet & services_r )
444 bool operator()(
const ServiceInfo & service_r )
const
462 DBG <<
"reading repo file " << repo_file <<
", local path: " << local << endl;
464 return repositories_in_file(local);
503#define OUTS(X) str << " " #X "\t" << obj.X << endl
504 str <<
"RepoManagerOptions (" << obj.
rootDir <<
") {" << endl;
505 OUTS( repoRawCachePath );
506 OUTS( repoSolvCachePath );
507 OUTS( repoPackagesCachePath );
508 OUTS( knownReposPath );
509 OUTS( knownServicesPath );
538 std::list<Pathname> entries;
540 if ( ! entries.empty() )
543 cmd.push_back(
"<" );
544 cmd.push_back(
">" );
545 cmd.push_back(
"PROGRAM" );
546 for (
const auto & rinfo :
repos() )
548 if ( ! rinfo.enabled() )
550 cmd.push_back(
"-R" );
551 cmd.push_back( rinfo.alias() );
552 cmd.push_back(
"-t" );
553 cmd.push_back( rinfo.type().asString() );
554 cmd.push_back(
"-p" );
555 cmd.push_back( rinfo.metadataPath().asString() );
558 for_( it, entries.begin(), entries.end() )
581 bool hasRepo(
const std::string & alias )
const
582 {
return foundAliasIn( alias,
repos() ); }
592 {
return rawcache_path_for_repoinfo(
_options, info ); }
595 {
return packagescache_path_for_repoinfo(
_options, info ); }
642 {
return foundAliasIn( alias,
_services ); }
675 {
return filenameFromAlias( info.
alias(),
"repo" ); }
678 {
return filenameFromAlias( info.
alias(),
"service" ); }
689 template<
typename OutputIterator>
694 boost::make_filter_iterator( filter,
repos().end(),
repos().end() ),
713 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
716 {
return new Impl( *
this ); }
722 {
return str <<
"RepoManager::Impl"; }
733 MIL <<
"saving service in " << servfile << endl;
735 std::ofstream file( servfile.
c_str() );
742 MIL <<
"done" << endl;
761 const std::string & basefilename )
const
763 std::string final_filename = basefilename;
765 while (
PathInfo(dir + final_filename).isExist() )
770 return dir +
Pathname(final_filename);
777 Pathname dir = _options.knownServicesPath;
778 std::list<Pathname> entries;
788 for_(it, entries.begin(), entries.end() )
804 inline void cleanupNonRepoMetadtaFolders(
const Pathname & cachePath_r,
805 const Pathname & defaultCachePath_r,
806 const std::list<std::string> & repoEscAliases_r )
808 if ( cachePath_r != defaultCachePath_r )
811 std::list<std::string> entries;
815 std::set<std::string> oldfiles;
816 set_difference( entries.begin(), entries.end(), repoEscAliases_r.begin(), repoEscAliases_r.end(),
817 std::inserter( oldfiles, oldfiles.end() ) );
823 for (
const std::string & old : oldfiles )
827 pi( cachePath_r/old );
839 MIL <<
"start construct known repos" << endl;
843 std::list<std::string> repoEscAliases;
844 std::list<RepoInfo> orphanedRepos;
845 for (
RepoInfo & repoInfo : repositories_in_dir(_options.knownReposPath) )
848 repoInfo.setMetadataPath( rawcache_path_for_repoinfo(_options, repoInfo) );
850 repoInfo.setPackagesPath( packagescache_path_for_repoinfo(_options, repoInfo) );
852 _reposX.insert( repoInfo );
855 const std::string & serviceAlias( repoInfo.service() );
856 if ( ! ( serviceAlias.empty() ||
hasService( serviceAlias ) ) )
858 WAR <<
"Schedule orphaned service repo for deletion: " << repoInfo << endl;
859 orphanedRepos.push_back( repoInfo );
863 repoEscAliases.push_back(repoInfo.escaped_alias());
867 if ( ! orphanedRepos.empty() )
869 for (
const auto & repoInfo : orphanedRepos )
871 MIL <<
"Delete orphaned service repo " << repoInfo.alias() << endl;
877 % repoInfo.alias() );
893 repoEscAliases.sort();
894 cleanupNonRepoMetadtaFolders( _options.repoRawCachePath,
897 cleanupNonRepoMetadtaFolders( _options.repoSolvCachePath,
900 cleanupNonRepoMetadtaFolders( _options.repoPackagesCachePath,
904 MIL <<
"end construct known repos" << endl;
911 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
912 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
916 if ( repokind == RepoType::NONE )
917 repokind = probeCache( productdatapath );
924 switch ( repokind.
toEnum() )
926 case RepoType::RPMMD_e :
927 status =
RepoStatus( productdatapath/
"repodata/repomd.xml") &&
RepoStatus( mediarootpath/
"media.1/media" );
930 case RepoType::YAST2_e :
931 status =
RepoStatus( productdatapath/
"content" ) &&
RepoStatus( mediarootpath/
"media.1/media" );
934 case RepoType::RPMPLAINDIR_e :
938 case RepoType::NONE_e :
945 if ( ! status.
empty() )
954 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
957 if ( repokind.
toEnum() == RepoType::NONE_e )
959 repokind = probeCache( productdatapath );
961 if (repokind == RepoType::NONE_e)
965 switch ( repokind.
toEnum() )
967 case RepoType::RPMMD_e :
968 p =
Pathname(productdatapath +
"/repodata/repomd.xml");
971 case RepoType::YAST2_e :
972 p =
Pathname(productdatapath +
"/content");
975 case RepoType::RPMPLAINDIR_e :
976 p =
Pathname(productdatapath +
"/cookie");
979 case RepoType::NONE_e :
994 MIL <<
"Check if to refresh repo " << info.
alias() <<
" at " << url <<
" (" << info.
type() <<
")" << endl;
997 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1001 if ( oldstatus.
empty() )
1003 MIL <<
"No cached metadata, going to refresh" << endl;
1009 MIL <<
"Never refresh CD/DVD" << endl;
1015 MIL <<
"Forced refresh!" << endl;
1032 if ( oldstatus == cachestatus )
1040 WAR <<
"Repository '" << info.
alias() <<
"' was refreshed in the future!" << endl;
1044 MIL <<
"Repository '" << info.
alias()
1045 <<
"' has been refreshed less than repo.refresh.delay ("
1047 <<
") minutes ago. Advising to skip refresh" << endl;
1053 MIL <<
"Metadata and solv cache don't match. Check data on server..." << endl;
1059 if ( repokind == RepoType::NONE )
1064 switch ( repokind.
toEnum() )
1066 case RepoType::RPMMD_e:
1073 case RepoType::YAST2_e:
1080 case RepoType::RPMPLAINDIR_e:
1085 case RepoType::NONE_e:
1091 if ( oldstatus == newstatus )
1093 MIL <<
"repo has not changed" << endl;
1094 touchIndexFile( info );
1099 MIL <<
"repo has changed, going to refresh" << endl;
1106 ERR <<
"refresh check failed for " << url << endl;
1120 RepoException rexception( info,
PL_(
"Valid metadata not found at specified URL",
1121 "Valid metadata not found at specified URLs",
1138 MIL <<
"Going to refresh metadata from " << url << endl;
1146 if ( repokind != probed )
1152 if ( info.
alias() == (*it).alias() )
1155 modifiedrepo.
setType( repokind );
1165 if ( repokind.
toEnum() == RepoType::NONE_e )
1169 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1180 Exception ex(
_(
"Can't create metadata cache directory."));
1184 if ( ( repokind.
toEnum() == RepoType::RPMMD_e ) ||
1185 ( repokind.
toEnum() == RepoType::YAST2_e ) )
1188 shared_ptr<repo::Downloader> downloader_ptr;
1190 MIL <<
"Creating downloader for [ " << info.
alias() <<
" ]" << endl;
1192 if ( repokind.
toEnum() == RepoType::RPMMD_e )
1205 Pathname cachepath(rawcache_path_for_repoinfo( _options, *it ));
1206 if (
PathInfo(cachepath).isExist() )
1207 downloader_ptr->addCachePath(cachepath);
1210 downloader_ptr->download( media, tmpdir.
path() );
1212 else if ( repokind.
toEnum() == RepoType::RPMPLAINDIR_e )
1215 MediaMounter media( url );
1230 if ( ! isTmpRepo( info ) )
1239 ERR <<
"Trying another url..." << endl;
1251 ERR <<
"No more urls..." << endl;
1260 progress.
sendTo(progressfnc);
1270 progress.
sendTo(progressfnc);
1280 Pathname mediarootpath = rawcache_path_for_repoinfo( _options, info );
1281 Pathname productdatapath = rawproductdata_path_for_repoinfo( _options, info );
1289 if ( raw_metadata_status.
empty() )
1298 bool needs_cleaning =
false;
1301 MIL << info.
alias() <<
" is already cached." << endl;
1304 if ( cache_status == raw_metadata_status )
1306 MIL << info.
alias() <<
" cache is up to date with metadata." << endl;
1310 const Pathname & base = solv_path_for_repoinfo( _options, info);
1311 if ( !
PathInfo(base/
"solv.idx").isExist() )
1317 MIL << info.
alias() <<
" cache rebuild is forced" << endl;
1321 needs_cleaning =
true;
1335 MIL << info.
alias() <<
" building cache..." << info.
type() << endl;
1337 Pathname base = solv_path_for_repoinfo( _options, info);
1356 switch ( repokind.
toEnum() )
1358 case RepoType::NONE_e:
1360 repokind = probeCache( productdatapath );
1366 MIL <<
"repo type is " << repokind << endl;
1368 switch ( repokind.
toEnum() )
1370 case RepoType::RPMMD_e :
1371 case RepoType::YAST2_e :
1372 case RepoType::RPMPLAINDIR_e :
1376 scoped_ptr<MediaMounter> forPlainDirs;
1379 cmd.push_back(
PathInfo(
"/usr/bin/repo2solv" ).isFile() ?
"repo2solv" :
"repo2solv.sh" );
1381 cmd.push_back(
"-o" );
1382 cmd.push_back( solvfile.
asString() );
1383 cmd.push_back(
"-X" );
1386 if ( repokind == RepoType::RPMPLAINDIR )
1388 forPlainDirs.reset(
new MediaMounter( info.
url() ) );
1390 cmd.push_back(
"-R" );
1392 cmd.push_back( forPlainDirs->getPathName( info.
path() ).c_str() );
1395 cmd.push_back( productdatapath.
asString() );
1398 std::string errdetail;
1401 WAR <<
" " << output;
1402 if ( errdetail.empty() ) {
1406 errdetail += output;
1409 int ret = prog.
close();
1427 setCacheStatus(info, raw_metadata_status);
1428 MIL <<
"Commit cache.." << endl;
1443 MIL <<
"going to probe the repo type at " << url <<
" (" << path <<
")" << endl;
1449 MIL <<
"Probed type NONE (not exists) at " << url <<
" (" << path <<
")" << endl;
1461 bool gotMediaException =
false;
1469 MIL <<
"Probed type RPMMD at " << url <<
" (" << path <<
")" << endl;
1476 DBG <<
"problem checking for repodata/repomd.xml file" << endl;
1478 gotMediaException =
true;
1485 MIL <<
"Probed type YAST2 at " << url <<
" (" << path <<
")" << endl;
1492 DBG <<
"problem checking for content file" << endl;
1494 gotMediaException =
true;
1500 MediaMounter media( url );
1504 MIL <<
"Probed type RPMPLAINDIR at " << url <<
" (" << path <<
")" << endl;
1518 if (gotMediaException)
1521 MIL <<
"Probed type NONE at " << url <<
" (" << path <<
")" << endl;
1532 MIL <<
"going to probe the cached repo at " << path_r << endl;
1536 if (
PathInfo(path_r/
"/repodata/repomd.xml").isFile() )
1538 else if (
PathInfo(path_r/
"/content").isFile() )
1540 else if (
PathInfo(path_r).isDir() )
1543 MIL <<
"Probed cached type " << ret <<
" at " << path_r << endl;
1551 MIL <<
"Going to clean up garbage in cache dirs" << endl;
1554 progress.
sendTo(progressrcv);
1557 std::list<Pathname> cachedirs;
1558 cachedirs.push_back(_options.repoRawCachePath);
1559 cachedirs.push_back(_options.repoPackagesCachePath);
1560 cachedirs.push_back(_options.repoSolvCachePath);
1562 for_( dir, cachedirs.begin(), cachedirs.end() )
1566 std::list<Pathname> entries;
1571 unsigned sdircount = entries.size();
1572 unsigned sdircurrent = 1;
1573 for_( subdir, entries.begin(), entries.end() )
1578 if ( subdir->basename() == r->escaped_alias() )
1579 { found =
true;
break; }
1584 progress.
set( progress.
val() + sdircurrent * 100 / sdircount );
1589 progress.
set( progress.
val() + 100 );
1599 progress.
sendTo(progressrcv);
1602 MIL <<
"Removing raw metadata cache for " << info.
alias() << endl;
1613 Pathname solvfile = solv_path_for_repoinfo(_options, info) /
"solv";
1615 if ( !
PathInfo(solvfile).isExist() )
1625 if ( toolversion != LIBSOLV_TOOLVERSION )
1634 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1654 MIL <<
"Try adding repo " << info << endl;
1661 if ( _options.probe )
1663 DBG <<
"unknown repository type, probing" << endl;
1664 assert_urls(tosave);
1667 if ( probedtype == RepoType::NONE )
1678 Pathname repofile = generateNonExistingName(
1679 _options.knownReposPath, generateFilename(tosave));
1681 MIL <<
"Saving repo in " << repofile << endl;
1683 std::ofstream file(repofile.
c_str());
1692 tosave.
setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1693 tosave.
setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1699 oinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, tosave ) );
1700 oinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, tosave ) );
1702 reposManip().insert(tosave);
1707 UrlCredentialExtractor( _options.rootDir ).collect( tosave.
baseUrls() );
1712 MIL <<
"done" << endl;
1719 for ( std::list<RepoInfo>::const_iterator it =
repos.begin();
1726 if ( (*it).alias() == (*kit).alias() )
1728 ERR <<
"To be added repo " << (*it).alias() <<
" conflicts with existing repo " << (*kit).alias() << endl;
1745 Pathname repofile = generateNonExistingName(_options.knownReposPath, filename);
1747 MIL <<
"Saving " <<
repos.size() <<
" repo" << (
repos.size() ?
"s" :
"" ) <<
" in " << repofile << endl;
1749 std::ofstream file(repofile.
c_str());
1756 for ( std::list<RepoInfo>::iterator it =
repos.begin();
1760 MIL <<
"Saving " << (*it).alias() << endl;
1761 it->dumpAsIniOn(file);
1762 it->setFilepath(repofile);
1763 it->setMetadataPath( rawcache_path_for_repoinfo( _options, *it ) );
1764 it->setPackagesPath( packagescache_path_for_repoinfo( _options, *it ) );
1765 reposManip().insert(*it);
1770 MIL <<
"done" << endl;
1782 MIL <<
"Going to delete repo " << info.
alias() << endl;
1789 if ( (!info.
alias().empty()) && ( info.
alias() != (*it).alias() ) )
1804 std::list<RepoInfo> filerepos = repositories_in_file(todelete.
filepath());
1805 if ( filerepos.size() == 0
1806 ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.
alias() ) )
1810 if ( ! ( ret == 0 || ret == ENOENT ) )
1815 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1833 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1834 fit != filerepos.end();
1837 if ( (*fit).alias() != todelete.
alias() )
1838 (*fit).dumpAsIniOn(file);
1851 reposManip().erase(todelete);
1852 MIL << todelete.
alias() <<
" successfully deleted." << endl;
1882 std::list<RepoInfo> filerepos = repositories_in_file(toedit.
filepath());
1898 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
1899 fit != filerepos.end();
1904 if ( (*fit).alias() != toedit.
alias() )
1905 (*fit).dumpAsIniOn(file);
1913 const Pathname & solvidx = solv_path_for_repoinfo(_options, newinfo)/
"solv.idx";
1919 newinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1920 newinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1926 oinfo.
setMetadataPath( rawcache_path_for_repoinfo( _options, newinfo ) );
1927 oinfo.
setPackagesPath( packagescache_path_for_repoinfo( _options, newinfo ) );
1929 reposManip().erase(toedit);
1930 reposManip().insert(newinfo);
1932 UrlCredentialExtractor( _options.rootDir ).collect( newinfo.
baseUrls() );
1934 MIL <<
"repo " << alias <<
" modified" << endl;
1943 if ( it !=
repos().end() )
1955 for_( urlit, (*it).baseUrlsBegin(), (*it).baseUrlsEnd() )
1957 if ( (*urlit).asString(urlview) == url.
asString(urlview) )
1974 assert_alias( service );
1983 saveService( toSave );
1987 UrlCredentialExtractor( _options.rootDir ).collect( toSave.
url() );
1989 MIL <<
"added service " << toSave.
alias() << endl;
1996 MIL <<
"Going to delete service " << alias << endl;
2001 if( location.
empty() )
2010 if ( tmpSet.size() == 1 )
2017 MIL << alias <<
" successfully deleted." << endl;
2023 std::ofstream file(location.
c_str());
2030 for_(it, tmpSet.begin(), tmpSet.end())
2032 if( it->alias() != alias )
2033 it->dumpAsIniOn(file);
2036 MIL << alias <<
" successfully deleted from file " << location << endl;
2040 RepoCollector rcollector;
2042 boost::make_function_output_iterator( bind( &RepoCollector::collect, &rcollector, _1 ) ) );
2044 for_(rit, rcollector.repos.begin(), rcollector.repos.end())
2057 if ( !it->enabled() )
2071 assert_alias( service );
2072 assert_url( service );
2073 MIL <<
"Going to refresh service '" << service.
alias() <<
"', url: " << service.
url() <<
", opts: " << options_r << endl;
2084 if ( (lrf+=service.
ttl()) > now )
2086 MIL <<
"Skip: '" << service.
alias() <<
"' metadata valid until " << lrf << endl;
2091 WAR <<
"Force: '" << service.
alias() <<
"' metadata last refresh in the future: " << lrf << endl;
2098 bool serviceModified =
false;
2106 if ( type != ServiceType::NONE )
2109 serviceModified =
true;
2114 std::string servicesTargetDistro = _options.servicesTargetDistro;
2115 if ( servicesTargetDistro.empty() )
2119 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << endl;
2123 RepoCollector collector(servicesTargetDistro);
2136 ServiceRepos( _options.rootDir, service, bind( &RepoCollector::collect, &collector, _1 ) );
2141 uglyHack.first =
true;
2142 uglyHack.second = e;
2144 if ( service.
ttl() != origTtl )
2146 if ( !service.
ttl() )
2148 serviceModified =
true;
2156 for_( it, collector.repos.begin(), collector.repos.end() )
2159 it->setAlias(
str::form(
"%s:%s", service.
alias().c_str(), it->alias().c_str() ) );
2161 it->setService( service.
alias() );
2164 newRepoStates[it->alias()] = *it;
2172 if ( !it->path().empty() )
2174 if ( it->path() !=
"/" )
2179 if ( it->baseUrlsEmpty() )
2182 if ( !path.
empty() )
2184 it->setBaseUrl( std::move(url) );
2186 else if ( !path.
empty() )
2189 for (
Url & url : urls )
2193 it->setBaseUrls( std::move(urls) );
2200 RepoInfoList oldRepos;
2205 for_( oldRepo, oldRepos.begin(), oldRepos.end() )
2207 if ( ! foundAliasIn( oldRepo->alias(), collector.repos ) )
2209 if ( oldRepo->enabled() )
2212 const auto & last = service.
repoStates().find( oldRepo->alias() );
2213 if ( last != service.
repoStates().end() && ! last->second.enabled )
2215 DBG <<
"Service removes user enabled repo " << oldRepo->alias() << endl;
2217 serviceModified =
true;
2220 DBG <<
"Service removes enabled repo " << oldRepo->alias() << endl;
2223 DBG <<
"Service removes disabled repo " << oldRepo->alias() << endl;
2231 UrlCredentialExtractor urlCredentialExtractor( _options.rootDir );
2232 for_( it, collector.repos.begin(), collector.repos.end() )
2238 TriBool toBeEnabled( indeterminate );
2239 DBG <<
"Service request to " << (it->enabled()?
"enable":
"disable") <<
" service repo " << it->alias() << endl;
2243 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() << endl;
2255 DBG <<
"User request to enable service repo " << it->alias() << endl;
2261 serviceModified =
true;
2265 DBG <<
"User request to disable service repo " << it->alias() << endl;
2266 toBeEnabled =
false;
2270 RepoInfoList::iterator oldRepo( findAlias( it->alias(), oldRepos ) );
2271 if ( oldRepo == oldRepos.end() )
2276 if ( ! indeterminate(toBeEnabled) )
2277 it->setEnabled( (
bool ) toBeEnabled );
2279 DBG <<
"Service adds repo " << it->alias() <<
" " << (it->enabled()?
"enabled":
"disabled") << endl;
2285 bool oldRepoModified =
false;
2287 if ( indeterminate(toBeEnabled) )
2291 if ( oldRepo->enabled() == it->enabled() )
2292 toBeEnabled = it->enabled();
2295 toBeEnabled = it->enabled();
2296 DBG <<
"Opt RefreshService_restoreStatus " << it->alias() <<
" forces " << (toBeEnabled?
"enabled":
"disabled") << endl;
2300 const auto & last = service.
repoStates().find( oldRepo->alias() );
2301 if ( last == service.
repoStates().end() || last->second.enabled != it->enabled() )
2302 toBeEnabled = it->enabled();
2305 toBeEnabled = oldRepo->enabled();
2306 DBG <<
"User modified service repo " << it->alias() <<
" may stay " << (toBeEnabled?
"enabled":
"disabled") << endl;
2312 if ( toBeEnabled == oldRepo->enabled() )
2314 DBG <<
"Service repo " << it->alias() <<
" stays " << (oldRepo->enabled()?
"enabled":
"disabled") << endl;
2316 else if ( toBeEnabled )
2318 DBG <<
"Service repo " << it->alias() <<
" gets enabled" << endl;
2319 oldRepo->setEnabled(
true );
2320 oldRepoModified =
true;
2324 DBG <<
"Service repo " << it->alias() <<
" gets disabled" << endl;
2325 oldRepo->setEnabled(
false );
2326 oldRepoModified =
true;
2332 if ( oldRepo->rawName() != it->rawName() )
2334 DBG <<
"Service repo " << it->alias() <<
" gets new NAME " << it->rawName() << endl;
2335 oldRepo->setName( it->rawName() );
2336 oldRepoModified =
true;
2340 if ( oldRepo->autorefresh() != it->autorefresh() )
2342 DBG <<
"Service repo " << it->alias() <<
" gets new AUTOREFRESH " << it->autorefresh() << endl;
2343 oldRepo->setAutorefresh( it->autorefresh() );
2344 oldRepoModified =
true;
2348 if ( oldRepo->priority() != it->priority() )
2350 DBG <<
"Service repo " << it->alias() <<
" gets new PRIORITY " << it->priority() << endl;
2351 oldRepo->setPriority( it->priority() );
2352 oldRepoModified =
true;
2358 urlCredentialExtractor.extract( newUrls );
2359 if ( oldRepo->rawBaseUrls() != newUrls )
2361 DBG <<
"Service repo " << it->alias() <<
" gets new URLs " << newUrls << endl;
2362 oldRepo->setBaseUrls( std::move(newUrls) );
2363 oldRepoModified =
true;
2369 if ( service.
type() == ServiceType::PLUGIN )
2373 oldRepo->getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
2374 it-> getRawGpgChecks( ngpg[0], ngpg[1], ngpg[2] );
2375#define Z_CHKGPG(I,N) \
2376 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \
2378 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \
2379 oldRepo->set##N##Check( ngpg[I] ); \
2380 oldRepoModified = true; \
2389 if ( oldRepoModified )
2400 serviceModified =
true;
2407 serviceModified =
true;
2412 if ( service.
type() != ServiceType::PLUGIN )
2414 if ( service.
ttl() )
2417 serviceModified =
true;
2420 if ( serviceModified )
2427 if ( uglyHack.first )
2429 throw( uglyHack.second );
2437 MIL <<
"Going to modify service " << oldAlias << endl;
2443 if ( service.
type() == ServiceType::PLUGIN )
2451 if( location.
empty() )
2461 std::ofstream file(location.
c_str());
2462 for_(it, tmpSet.begin(), tmpSet.end())
2464 if( *it != oldAlias )
2465 it->dumpAsIniOn(file);
2474 UrlCredentialExtractor( _options.rootDir ).collect( service.
url() );
2478 if ( oldAlias != service.
alias()
2481 std::vector<RepoInfo> toModify;
2483 for_( it, toModify.begin(), toModify.end() )
2490 const auto & last = service.
repoStates().find( it->alias() );
2492 it->setEnabled( last->second.enabled );
2495 it->setEnabled(
false );
2498 if ( oldAlias != service.
alias() )
2499 it->setService(service.
alias());
2552 {
return _pimpl->repoEmpty(); }
2555 {
return _pimpl->repoSize(); }
2558 {
return _pimpl->repoBegin(); }
2561 {
return _pimpl->repoEnd(); }
2564 {
return _pimpl->getRepo( alias ); }
2567 {
return _pimpl->hasRepo( alias ); }
2577 std::string host( url_r.
getHost() );
2578 if ( ! host.empty() )
2590 {
return _pimpl->metadataStatus( info ); }
2593 {
return _pimpl->checkIfToRefreshMetadata( info, url, policy ); }
2596 {
return _pimpl->metadataPath( info ); }
2599 {
return _pimpl->packagesPath( info ); }
2602 {
return _pimpl->refreshMetadata( info, policy, progressrcv ); }
2605 {
return _pimpl->cleanMetadata( info, progressrcv ); }
2608 {
return _pimpl->cleanPackages( info, progressrcv ); }
2611 {
return _pimpl->cacheStatus( info ); }
2614 {
return _pimpl->buildCache( info, policy, progressrcv ); }
2617 {
return _pimpl->cleanCache( info, progressrcv ); }
2620 {
return _pimpl->isCached( info ); }
2623 {
return _pimpl->loadFromCache( info, progressrcv ); }
2626 {
return _pimpl->cleanCacheDirGarbage( progressrcv ); }
2629 {
return _pimpl->probe( url, path ); }
2632 {
return _pimpl->probe( url ); }
2635 {
return _pimpl->addRepository( info, progressrcv ); }
2638 {
return _pimpl->addRepositories( url, progressrcv ); }
2641 {
return _pimpl->removeRepository( info, progressrcv ); }
2644 {
return _pimpl->modifyRepository( alias, newinfo, progressrcv ); }
2647 {
return _pimpl->getRepositoryInfo( alias, progressrcv ); }
2650 {
return _pimpl->getRepositoryInfo( url, urlview, progressrcv ); }
2653 {
return _pimpl->serviceEmpty(); }
2656 {
return _pimpl->serviceSize(); }
2659 {
return _pimpl->serviceBegin(); }
2662 {
return _pimpl->serviceEnd(); }
2665 {
return _pimpl->getService( alias ); }
2668 {
return _pimpl->hasService( alias ); }
2671 {
return _pimpl->probeService( url ); }
2674 {
return _pimpl->addService( alias, url ); }
2677 {
return _pimpl->addService( service ); }
2680 {
return _pimpl->removeService( alias ); }
2683 {
return _pimpl->removeService( service ); }
2686 {
return _pimpl->refreshServices( options_r ); }
2689 {
return _pimpl->refreshService( alias, options_r ); }
2692 {
return _pimpl->refreshService( service, options_r ); }
2695 {
return _pimpl->modifyService( oldAlias, service ); }
media::MediaAccessId _mid
scoped_ptr< media::CredentialManager > _cmPtr
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void resetDispose()
Set no dispose function.
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.
void addHistory(const std::string &msg_r)
Add some message text to the history.
void remember(const Exception &old_r)
Store an other Exception as history.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
const std::string & command() const
The command we're executing.
std::vector< std::string > Arguments
int close()
Wait for the progamm to complete.
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.
bool toMax()
Set counter value to current max value (unless no range).
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.
bool toMin()
Set counter value to current min value.
bool set(value_type val_r)
Set new counter value.
What is known about a repository.
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.
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
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.
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.
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
void setType(const repo::RepoType &t)
set the repository type
creates and provides information about known sources.
bool hasRepo(const std::string &alias) const
Return whether there is a known repository for alias.
ServiceSet::const_iterator ServiceConstIterator
void cleanCacheDirGarbage(const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove any subdirectories of cache directories which no longer belong to any of known repositories.
void cleanMetadata(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local metadata.
bool serviceEmpty() const
Gets true if no service is in RepoManager (so no one in specified location)
bool hasService(const std::string &alias) const
Return whether there is a known service for alias.
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
@ REFRESH_NEEDED
refresh is needed
@ REPO_UP_TO_DATE
repository not changed
@ REPO_CHECK_DELAYED
refresh is delayed due to settings
RepoSet::const_iterator RepoConstIterator
void addService(const std::string &alias, const Url &url)
Adds new service by it's alias and url.
bool isCached(const RepoInfo &info) const
Whether a repository exists in cache.
void removeService(const std::string &alias)
Removes service specified by its name.
@ RefreshIfNeededIgnoreDelay
RepoManager(const RepoManagerOptions &options=RepoManagerOptions())
RepoInfo getRepo(const std::string &alias) const
Find RepoInfo by alias or return RepoInfo::noRepo.
repo::ServiceType probeService(const Url &url) const
Probe the type or the service.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
void cleanCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
clean local cache
void refreshServices(const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refreshes all enabled services.
void addRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds a repository to the list of known repositories.
Pathname metadataPath(const RepoInfo &info) const
Path where the metadata is downloaded and kept.
ServiceSet::size_type ServiceSizeType
std::set< RepoInfo > RepoSet
RepoInfo typedefs.
Pathname packagesPath(const RepoInfo &info) const
Path where the rpm packages are downloaded and kept.
RepoStatus cacheStatus(const RepoInfo &info) const
Status of metadata cache.
void addRepositories(const Url &url, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Adds repositores from a repo file to the list of known repositories.
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy=RefreshIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local raw cache.
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r=RefreshServiceOptions())
Refresh specific service.
ServiceConstIterator serviceEnd() const
Iterator to place behind last service in internal storage.
@ RefreshService_forceRefresh
Force refresh even if TTL is not reached.
@ RefreshService_restoreStatus
Force restoring repo enabled/disabled status.
ServiceConstIterator serviceBegin() const
Iterator to first service in internal storage.
RepoSizeType repoSize() const
void modifyRepository(const std::string &alias, const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Modify repository attributes.
Iterable< ServiceConstIterator > services() const
Iterate the known services.
void removeRepository(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Remove the best matching repository from known repos list.
RepoInfo getRepositoryInfo(const std::string &alias, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Find a matching repository info.
ServiceSizeType serviceSize() const
Gets count of service in RepoManager (in specified location)
RepoSet::size_type RepoSizeType
ServiceInfo getService(const std::string &alias) const
Finds ServiceInfo by alias or return ServiceInfo::noService.
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy=RefreshIfNeeded)
Checks whether to refresh metadata for specified repository and url.
RepoConstIterator repoBegin() const
Iterable< RepoConstIterator > repos() const
Iterate the known repositories.
void buildCache(const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local cache.
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
fill to output iterator repositories in service name.
void loadFromCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Load resolvables into the pool.
std::set< ServiceInfo > ServiceSet
ServiceInfo typedefs.
void cleanPackages(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Clean local package cache.
RepoConstIterator repoEnd() const
RepoStatus metadataStatus(const RepoInfo &info) const
Status of local metadata.
void modifyService(const std::string &oldAlias, const ServiceInfo &service)
Modifies service file (rewrites it with new values) and underlying repositories if needed.
static std::string makeStupidAlias(const Url &url_r=Url())
Some stupid string but suitable as alias for your url if nothing better is available.
repo::RepoType probe(const Url &url, const Pathname &path) const
Probe repo metadata 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 it's 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.
static const ServiceInfo noService
Represents an empty service.
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.
static bool schemeIsLocal(const std::string &scheme_r)
hd cd dvd dir file iso
static bool schemeIsPlugin(const std::string &scheme_r)
plugin
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.
Pathname builtinRepoSolvfilesPath() const
The builtin config file value.
bool repo_add_probe() const
Whether repository urls should be probed.
static ZConfig & instance()
Singleton ctor.
Pathname builtinRepoPackagesPath() const
The builtin config file value.
Pathname builtinRepoMetadataPath() const
The builtin config file value.
std::string receiveLine()
Read one line from the input stream.
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 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 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.
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
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
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.
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
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::ostream & operator<<(std::ostream &str, const Exception &obj)
std::list< RepoInfo > readRepoFile(const Url &repo_file)
Parses repo_file and returns a list of RepoInfo objects corresponding to repositories found within th...
std::string asString(const TriBool &val_r, const std::string &istr_r=std::string(), const std::string &tstr_r=std::string(), const std::string &fstr_r=std::string())
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.
RepoManager implementation.
RepoSizeType repoSize() const
void saveService(ServiceInfo &service) const
void refreshService(const std::string &alias, const RefreshServiceOptions &options_r)
void init_knownRepositories()
void addService(const ServiceInfo &service)
repo::ServiceType probeService(const Url &url) const
bool hasRepo(const std::string &alias) const
bool serviceEmpty() const
void refreshServices(const RefreshServiceOptions &options_r)
std::string generateFilename(const ServiceInfo &info) const
const RepoSet & repos() const
RepoInfo getRepositoryInfo(const Url &url, const url::ViewOption &urlview, OPT_PROGRESS)
RepoManagerOptions _options
std::ostream & operator<<(std::ostream &str, const RepoManager::Impl &obj)
Stream output.
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, OPT_PROGRESS)
std::string generateFilename(const RepoInfo &info) const
RepoConstIterator repoEnd() const
Impl * clone() const
clone for RWCOW_pointer
void buildCache(const RepoInfo &info, CacheBuildPolicy policy, OPT_PROGRESS)
ServiceSizeType serviceSize() const
void addRepository(const RepoInfo &info, OPT_PROGRESS)
void loadFromCache(const RepoInfo &info, OPT_PROGRESS)
void addService(const std::string &alias, const Url &url)
void removeService(const std::string &alias)
void getRepositoriesInService(const std::string &alias, OutputIterator out) const
void cleanMetadata(const RepoInfo &info, OPT_PROGRESS)
RepoStatus cacheStatus(const RepoInfo &info) const
void removeRepository(const RepoInfo &info, OPT_PROGRESS)
Pathname packagesPath(const RepoInfo &info) const
void cleanPackages(const RepoInfo &info, OPT_PROGRESS)
RepoConstIterator repoBegin() const
void addRepositories(const Url &url, OPT_PROGRESS)
ServiceInfo getService(const std::string &alias) const
void modifyService(const std::string &oldAlias, const ServiceInfo &newService)
repo::RepoType probeCache(const Pathname &path_r) const
Probe Metadata in a local cache directory.
ServiceConstIterator serviceEnd() const
RepoInfo getRepositoryInfo(const std::string &alias, OPT_PROGRESS)
void touchIndexFile(const RepoInfo &info)
Impl(const RepoManagerOptions &opt)
RefreshCheckStatus checkIfToRefreshMetadata(const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy)
Pathname metadataPath(const RepoInfo &info) const
bool isCached(const RepoInfo &info) const
DefaultIntegral< bool, false > _reposDirty
void cleanCache(const RepoInfo &info, OPT_PROGRESS)
void removeService(const ServiceInfo &service)
void setCacheStatus(const RepoInfo &info, const RepoStatus &status)
ServiceConstIterator serviceBegin() const
void refreshService(const ServiceInfo &service, const RefreshServiceOptions &options_r)
void init_knownServices()
void cleanCacheDirGarbage(OPT_PROGRESS)
repo::RepoType probe(const Url &url, const Pathname &path=Pathname()) const
Probe the metadata type of a repository located at url.
RepoStatus metadataStatus(const RepoInfo &info) const
RepoInfo getRepo(const std::string &alias) const
Pathname generateNonExistingName(const Pathname &dir, const std::string &basefilename) const
Generate a non existing filename in a directory, using a base name.
void modifyRepository(const std::string &alias, const RepoInfo &newinfo_r, OPT_PROGRESS)
bool hasService(const std::string &alias) const
Functor thats filter RepoInfo by service which it belongs to.
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)
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)