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>
66#define OPT_PROGRESS const ProgressData::ReceiverFnc & = ProgressData::ReceiverFnc()
71 namespace zypp_readonly_hack {
81 const char * env =
getenv(
"ZYPP_PLUGIN_APPDATA_FORCE_COLLECT");
111 class UrlCredentialExtractor
114 UrlCredentialExtractor( Pathname &
root_r )
118 ~UrlCredentialExtractor()
119 {
if ( _cmPtr )
_cmPtr->save(); }
122 bool collect(
const Url &
url_r )
124 bool ret =
url_r.hasCredentialsInAuthority();
133 template<
class TContainer>
134 bool collect(
const TContainer &
urls_r )
135 {
bool ret =
false;
for (
const Url & url :
urls_r ) {
if ( collect( url ) && !
ret )
ret =
true; }
return ret; }
142 url_r.setPassword( std::string() );
146 template<
class TContainer>
167 MediaMounter(
const Url &
url_r )
186 Pathname getPathName(
const Pathname &
path_r = Pathname() )
const
198 template <
class Iterator>
207 template <
class Container>
212 template <
class Iterator>
221 template <
class Container>
225 template <
class Container>
226 inline typename Container::const_iterator
findAlias(
const std::string &
alias_r,
const Container &
cont_r )
233 std::string filename(
alias_r );
237 filename = Pathname(filename).extend(
"."+
stem_r).asString();
238 MIL <<
"generating filename for " <<
stem_r <<
" [" <<
alias_r <<
"] : '" << filename <<
"'" << endl;
266 bool collect(
const RepoInfo &repo )
275 <<
"' distribution (current distro is '"
281 repos.push_back(repo);
297 MIL <<
"repo file: " << file << endl;
298 RepoCollector collector;
300 return std::move(collector.repos);
315 MIL <<
"directory " << dir << endl;
316 std::list<RepoInfo>
repos;
324 std::list<Pathname> entries;
332 for ( std::list<Pathname>::const_iterator
it = entries.begin();
it != entries.end(); ++
it )
355 if ( info.
alias().empty() )
359 if ( info.
alias()[0] ==
'.')
361 info,
_(
"Repository alias cannot start with dot.")));
366 if ( info.
alias().empty() )
370 if ( info.
alias()[0] ==
'.')
372 info,
_(
"Service alias cannot start with dot.")));
396 {
return(
info_r.filepath().empty() &&
info_r.usesAutoMethadataPaths() ); }
442 class ServiceCollector
445 typedef std::set<ServiceInfo> ServiceSet;
506 ret.repoPackagesCachePath =
root_r/
"packages";
508 ret.knownServicesPath =
root_r/
"services.d";
516#define OUTS(X) str << " " #X "\t" << obj.X << endl
517 str <<
"RepoManagerOptions (" <<
obj.rootDir <<
") {" << endl;
518 OUTS( repoRawCachePath );
519 OUTS( repoSolvCachePath );
520 OUTS( repoPackagesCachePath );
521 OUTS( knownReposPath );
522 OUTS( knownServicesPath );
539 , _pluginRepoverification( _options.pluginsPath/
"repoverification", _options.rootDir )
541 init_knownServices();
542 init_knownRepositories();
548 if ( ( _reposDirty || env::ZYPP_PLUGIN_APPDATA_FORCE_COLLECT() )
549 &&
geteuid() == 0 && ( _options.rootDir.empty() || _options.rootDir ==
"/" ) )
552 std::list<Pathname> entries;
553 filesystem::readdir( entries, _options.pluginsPath/
"appdata",
false );
554 if ( ! entries.empty() )
557 cmd.push_back(
"<" );
558 cmd.push_back(
">" );
559 cmd.push_back(
"PROGRAM" );
562 if ( !
rinfo.enabled() )
564 cmd.push_back(
"-R" );
566 cmd.push_back(
"-t" );
567 cmd.push_back(
rinfo.type().asString() );
568 cmd.push_back(
"-p" );
569 cmd.push_back( (
rinfo.metadataPath()/
rinfo.path()).asString() );
572 for_(
it, entries.begin(), entries.end() )
576 if (
pi.isFile() &&
pi.userMayRX() )
579 cmd[2] =
pi.asString();
595 bool hasRepo(
const std::string & alias )
const
601 return it ==
repos().end() ? RepoInfo::noRepo : *
it;
613 RefreshCheckStatus checkIfToRefreshMetadata(
const RepoInfo & info,
const Url & url, RawMetadataRefreshPolicy
policy );
669 void removeService(
const std::string & alias );
671 { removeService( service.
alias() ); }
673 void refreshServices(
const RefreshServiceOptions &
options_r );
675 void refreshService(
const std::string & alias,
const RefreshServiceOptions &
options_r );
699 filesystem::assert_dir(base);
705 template<
typename OutputIterator>
709 std::copy( boost::make_filter_iterator( filter,
repos().begin(),
repos().end() ),
710 boost::make_filter_iterator( filter,
repos().end(),
repos().end() ),
734 {
return new Impl( *
this ); }
740 {
return str <<
"RepoManager::Impl"; }
744 void RepoManager::Impl::saveService(
ServiceInfo & service )
const
747 Pathname
servfile = generateNonExistingName( _options.knownServicesPath,
748 generateFilename( service ) );
753 std::ofstream file(
servfile.c_str() );
760 MIL <<
"done" << endl;
778 Pathname RepoManager::Impl::generateNonExistingName(
const Pathname & dir,
793 void RepoManager::Impl::init_knownServices()
795 Pathname dir = _options.knownServicesPath;
796 std::list<Pathname> entries;
806 for_(
it, entries.begin(), entries.end() )
833 std::list<std::string> entries;
859 void RepoManager::Impl::init_knownRepositories()
861 MIL <<
"start construct known repos" << endl;
874 _reposX.insert( repoInfo );
880 WAR <<
"Schedule orphaned service repo for deletion: " << repoInfo << endl;
893 MIL <<
"Delete orphaned service repo " << repoInfo.alias() << endl;
899 % repoInfo.alias() );
901 removeRepository( repoInfo );
931 MIL <<
"end construct known repos" << endl;
974 if ( ! status.
empty() )
981 void RepoManager::Impl::touchIndexFile(
const RepoInfo & info )
1023 MIL <<
"Check if to refresh repo " << info.
alias() <<
" at " << url <<
" (" << info.
type() <<
")" << endl;
1025 refreshGeoIPData( { url } );
1034 MIL <<
"No cached metadata, going to refresh" << endl;
1035 return REFRESH_NEEDED;
1038 if ( url.schemeIsVolatile() )
1040 MIL <<
"Never refresh CD/DVD" << endl;
1041 return REPO_UP_TO_DATE;
1044 if (
policy == RefreshForced )
1046 MIL <<
"Forced refresh!" << endl;
1047 return REFRESH_NEEDED;
1050 if ( url.schemeIsLocal() )
1052 policy = RefreshIfNeededIgnoreDelay;
1056 if (
policy != RefreshIfNeededIgnoreDelay )
1071 WAR <<
"Repository '" << info.
alias() <<
"' was refreshed in the future!" << endl;
1075 MIL <<
"Repository '" << info.
alias()
1076 <<
"' has been refreshed less than repo.refresh.delay ("
1078 <<
") minutes ago. Advising to skip refresh" << endl;
1079 return REPO_CHECK_DELAYED;
1084 MIL <<
"Metadata and solv cache don't match. Check data on server..." << endl;
1124 MIL <<
"repo has not changed" << endl;
1125 touchIndexFile( info );
1126 return REPO_UP_TO_DATE;
1130 MIL <<
"repo has changed, going to refresh" << endl;
1131 return REFRESH_NEEDED;
1137 ERR <<
"refresh check failed for " << url << endl;
1141 return REFRESH_NEEDED;
1151 refreshGeoIPData( info.
baseUrls() );
1155 "Valid metadata not found at specified URLs",
1169 if (checkIfToRefreshMetadata(info, url,
policy)!=REFRESH_NEEDED)
1172 MIL <<
"Going to refresh metadata from " << url << endl;
1184 for_(
it, repoBegin(), repoEnd() )
1186 if ( info.
alias() == (*it).alias() )
1212 if(
tmpdir.path().empty() )
1214 Exception ex(
_(
"Can't create metadata cache directory."));
1224 MIL <<
"Creating downloader for [ " << info.
alias() <<
" ]" << endl;
1228 if ( _pluginRepoverification.checkIfNeeded() )
1229 downloader_ptr->setPluginRepoverification( _pluginRepoverification );
1240 for_(
it, repoBegin(), repoEnd() )
1252 MediaMounter media( url );
1276 ERR <<
"Trying another url..." << endl;
1288 ERR <<
"No more urls..." << endl;
1334 refreshMetadata(info, RefreshIfNeeded,
progressrcv );
1339 if ( isCached( info ) )
1341 MIL << info.
alias() <<
" is already cached." << endl;
1346 MIL << info.
alias() <<
" cache is up to date with metadata." << endl;
1347 if (
policy == BuildIfNeeded )
1351 if ( !
PathInfo(base/
"solv.idx").isExist() )
1357 MIL << info.
alias() <<
" cache rebuild is forced" << endl;
1367 progress.name(
str::form(
_(
"Building repository '%s' cache"), info.
label().c_str()));
1375 MIL << info.
alias() <<
" building cache..." << info.
type() << endl;
1419 cmd.push_back(
PathInfo(
"/usr/bin/repo2solv" ).isFile() ?
"repo2solv" :
"repo2solv.sh" );
1421 cmd.push_back(
"-o" );
1423 cmd.push_back(
"-X" );
1430 cmd.push_back(
"-R" );
1464 MIL <<
"Commit cache.." << endl;
1477 repo::RepoType RepoManager::Impl::probe(
const Url & url,
const Pathname & path )
const
1479 MIL <<
"going to probe the repo type at " << url <<
" (" << path <<
")" << endl;
1481 if ( url.getScheme() ==
"dir" && !
PathInfo( url.getPathName()/path ).
isDir() )
1485 MIL <<
"Probed type NONE (not exists) at " << url <<
" (" << path <<
")" << endl;
1503 if (
access.doesFileExist(path/
"/repodata/repomd.xml") )
1505 MIL <<
"Probed type RPMMD at " << url <<
" (" << path <<
")" << endl;
1512 DBG <<
"problem checking for repodata/repomd.xml file" << endl;
1519 if (
access.doesFileExist(path/
"/content") )
1521 MIL <<
"Probed type YAST2 at " << url <<
" (" << path <<
")" << endl;
1528 DBG <<
"problem checking for content file" << endl;
1534 if ( ! ( url.schemeIsDownloading() || url.schemeIsPlugin() ) )
1536 MediaMounter media( url );
1540 MIL <<
"Probed type RPMPLAINDIR at " << url <<
" (" << path <<
")" << endl;
1557 MIL <<
"Probed type NONE at " << url <<
" (" << path <<
")" << endl;
1568 MIL <<
"going to probe the cached repo at " <<
path_r << endl;
1579 MIL <<
"Probed cached type " <<
ret <<
" at " <<
path_r << endl;
1587 MIL <<
"Going to clean up garbage in cache dirs" << endl;
1594 cachedirs.push_back(_options.repoRawCachePath);
1595 cachedirs.push_back(_options.repoPackagesCachePath);
1596 cachedirs.push_back(_options.repoSolvCachePath);
1602 std::list<Pathname> entries;
1609 for_(
subdir, entries.begin(), entries.end() )
1613 for_(
r, repoBegin(), repoEnd() )
1614 if (
subdir->basename() ==
r->escaped_alias() )
1615 {
found =
true;
break; }
1625 progress.set( progress.val() + 100 );
1638 MIL <<
"Removing raw metadata cache for " << info.
alias() << endl;
1670 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1687 progress.name(
str::form(
_(
"Adding repository '%s'"), info.
label().c_str()));
1690 MIL <<
"Try adding repo " << info << endl;
1697 if ( _options.probe )
1699 DBG <<
"unknown repository type, probing" << endl;
1714 Pathname
repofile = generateNonExistingName(
1715 _options.knownReposPath, generateFilename(
tosave));
1719 std::ofstream file(
repofile.c_str());
1726 tosave.dumpAsIniOn(file);
1738 reposManip().insert(
tosave);
1743 UrlCredentialExtractor( _options.rootDir ).collect(
tosave.baseUrls() );
1748 MIL <<
"done" << endl;
1755 for ( std::list<RepoInfo>::const_iterator
it =
repos.begin();
1760 for_ (
kit, repoBegin(), repoEnd() )
1762 if ( (*it).alias() == (*kit).alias() )
1764 ERR <<
"To be added repo " << (*it).alias() <<
" conflicts with existing repo " << (*kit).alias() << endl;
1770 std::string filename = Pathname(url.getPathName()).basename();
1772 if ( filename == Pathname() )
1781 Pathname
repofile = generateNonExistingName(_options.knownReposPath, filename);
1783 MIL <<
"Saving " <<
repos.size() <<
" repo" << (
repos.size() ?
"s" :
"" ) <<
" in " <<
repofile << endl;
1785 std::ofstream file(
repofile.c_str());
1792 for ( std::list<RepoInfo>::iterator
it =
repos.begin();
1796 MIL <<
"Saving " << (*it).alias() << endl;
1797 it->dumpAsIniOn(file);
1801 reposManip().insert(*
it);
1806 MIL <<
"done" << endl;
1818 MIL <<
"Going to delete repo " << info.
alias() << endl;
1820 for_(
it, repoBegin(), repoEnd() )
1825 if ( (!info.
alias().empty()) && ( info.
alias() != (*it).alias() ) )
1851 MIL <<
todelete.alias() <<
" successfully deleted." << endl;
1863 std::ofstream file(
todelete.filepath().c_str());
1869 for ( std::list<RepoInfo>::const_iterator
fit =
filerepos.begin();
1873 if ( (*fit).alias() !=
todelete.alias() )
1874 (*fit).dumpAsIniOn(file);
1888 MIL <<
todelete.alias() <<
" successfully deleted." << endl;
1911 if (
toedit.filepath().empty())
1928 std::ofstream file(
toedit.filepath().c_str());
1934 for ( std::list<RepoInfo>::const_iterator
fit =
filerepos.begin();
1940 if ( (*fit).alias() !=
toedit.alias() )
1941 (*fit).dumpAsIniOn(file);
1965 reposManip().erase(
toedit);
1968 UrlCredentialExtractor( _options.rootDir ).collect(
newinfo.baseUrls() );
1970 MIL <<
"repo " << alias <<
" modified" << endl;
1989 for_(
it, repoBegin(), repoEnd() )
1991 for_(
urlit, (*it).baseUrlsBegin(), (*it).baseUrlsEnd() )
2008 void RepoManager::Impl::addService(
const ServiceInfo & service )
2013 if ( hasService( service.
alias() ) )
2023 UrlCredentialExtractor( _options.rootDir ).collect(
toSave.url() );
2025 MIL <<
"added service " <<
toSave.alias() << endl;
2030 void RepoManager::Impl::removeService(
const std::string & alias )
2032 MIL <<
"Going to delete service " << alias << endl;
2034 const ServiceInfo & service = getService( alias );
2036 Pathname location = service.
filepath();
2037 if( location.empty() )
2046 if (
tmpSet.size() == 1 )
2053 MIL << alias <<
" successfully deleted." << endl;
2059 std::ofstream file(location.c_str());
2068 if(
it->alias() != alias )
2069 it->dumpAsIniOn(file);
2072 MIL << alias <<
" successfully deleted from file " << location << endl;
2077 getRepositoriesInService( alias,
2078 boost::make_function_output_iterator( bind( &RepoCollector::collect, &
rcollector, _1 ) ) );
2081 removeRepository(*
rit);
2090 ServiceSet services( serviceBegin(), serviceEnd() );
2091 for_(
it, services.begin(), services.end() )
2093 if ( !
it->enabled() )
2104 void RepoManager::Impl::refreshService(
const std::string & alias,
const RefreshServiceOptions &
options_r )
2109 MIL <<
"Going to refresh service '" << service.
alias() <<
"', url: " << service.
url() <<
", opts: " <<
options_r << endl;
2111 if ( service.
ttl() && !(
options_r.testFlag( RefreshService_forceRefresh) ||
options_r.testFlag( RefreshService_restoreStatus ) ) )
2114 Date lrf = service.
lrf();
2120 if ( (lrf+=service.
ttl()) > now )
2122 MIL <<
"Skip: '" << service.
alias() <<
"' metadata valid until " << lrf << endl;
2127 WAR <<
"Force: '" << service.
alias() <<
"' metadata last refresh in the future: " << lrf << endl;
2150 std::string servicesTargetDistro = _options.servicesTargetDistro;
2151 if ( servicesTargetDistro.empty() )
2155 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << endl;
2159 RepoCollector collector(servicesTargetDistro);
2172 ServiceRepos( _options.rootDir, service, bind( &RepoCollector::collect, &collector, _1 ) );
2182 if ( !service.
ttl() )
2183 service.
setLrf( Date() );
2192 for_(
it, collector.repos.begin(), collector.repos.end() )
2197 it->setService( service.
alias() );
2208 if ( !
it->path().empty() )
2210 if (
it->path() !=
"/" )
2215 if (
it->baseUrlsEmpty() )
2217 Url url( service.
rawUrl() );
2218 if ( !path.empty() )
2219 url.setPathName( url.getPathName() / path );
2220 it->setBaseUrl( std::move(url) );
2222 else if ( !path.empty() )
2225 for ( Url & url : urls )
2227 url.setPathName( url.getPathName() / path );
2229 it->setBaseUrls( std::move(urls) );
2237 getRepositoriesInService( service.
alias(), std::back_inserter(
oldRepos ) );
2249 if ( last != service.
repoStates().end() && ! last->second.enabled )
2251 DBG <<
"Service removes user enabled repo " <<
oldRepo->alias() << endl;
2256 DBG <<
"Service removes enabled repo " <<
oldRepo->alias() << endl;
2259 DBG <<
"Service removes disabled repo " <<
oldRepo->alias() << endl;
2268 for_(
it, collector.repos.begin(), collector.repos.end() )
2275 DBG <<
"Service request to " << (
it->enabled()?
"enable":
"disable") <<
" service repo " <<
it->alias() << endl;
2277 if (
options_r.testFlag( RefreshService_restoreStatus ) )
2279 DBG <<
"Opt RefreshService_restoreStatus " <<
it->alias() << endl;
2291 DBG <<
"User request to enable service repo " <<
it->alias() << endl;
2301 DBG <<
"User request to disable service repo " <<
it->alias() << endl;
2315 DBG <<
"Service adds repo " <<
it->alias() <<
" " << (
it->enabled()?
"enabled":
"disabled") << endl;
2316 addRepository( *
it );
2327 if (
oldRepo->enabled() ==
it->enabled() )
2329 else if (
options_r.testFlag( RefreshService_restoreStatus ) )
2332 DBG <<
"Opt RefreshService_restoreStatus " <<
it->alias() <<
" forces " << (
toBeEnabled?
"enabled":
"disabled") << endl;
2337 if ( last == service.
repoStates().end() || last->second.enabled !=
it->enabled() )
2342 DBG <<
"User modified service repo " <<
it->alias() <<
" may stay " << (
toBeEnabled?
"enabled":
"disabled") << endl;
2350 DBG <<
"Service repo " <<
it->alias() <<
" stays " << (
oldRepo->enabled()?
"enabled":
"disabled") << endl;
2354 DBG <<
"Service repo " <<
it->alias() <<
" gets enabled" << endl;
2360 DBG <<
"Service repo " <<
it->alias() <<
" gets disabled" << endl;
2368 if (
oldRepo->rawName() !=
it->rawName() )
2370 DBG <<
"Service repo " <<
it->alias() <<
" gets new NAME " <<
it->rawName() << endl;
2376 if (
oldRepo->autorefresh() !=
it->autorefresh() )
2378 DBG <<
"Service repo " <<
it->alias() <<
" gets new AUTOREFRESH " <<
it->autorefresh() << endl;
2379 oldRepo->setAutorefresh(
it->autorefresh() );
2384 if (
oldRepo->priority() !=
it->priority() )
2386 DBG <<
"Service repo " <<
it->alias() <<
" gets new PRIORITY " <<
it->priority() << endl;
2397 DBG <<
"Service repo " <<
it->alias() <<
" gets new URLs " <<
newUrls << endl;
2411#define Z_CHKGPG(I,N) \
2412 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \
2414 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \
2415 oldRepo->set##N##Check( ngpg[I] ); \
2416 oldRepoModified = true; \
2450 if ( service.
ttl() )
2459 modifyService( service.
alias(), service );
2471 void RepoManager::Impl::modifyService(
const std::string & oldAlias,
const ServiceInfo &
newService )
2473 MIL <<
"Going to modify service " << oldAlias << endl;
2487 if( location.empty() )
2497 std::ofstream file(location.c_str());
2500 if( *
it != oldAlias )
2501 it->dumpAsIniOn(file);
2510 UrlCredentialExtractor( _options.rootDir ).collect( service.
url() );
2514 if ( oldAlias != service.
alias()
2517 std::vector<RepoInfo> toModify;
2518 getRepositoriesInService(oldAlias, std::back_inserter(toModify));
2519 for_(
it, toModify.begin(), toModify.end() )
2526 const auto & last = service.
repoStates().find(
it->alias() );
2528 it->setEnabled( last->second.enabled );
2531 it->setEnabled(
false );
2534 if ( oldAlias != service.
alias() )
2535 it->setService(service.
alias());
2537 modifyRepository(
it->alias(), *
it);
2551 if (
access.doesFileExist(
"/repo/repoindex.xml") )
2579 MIL <<
"GeoIp disabled via ZConfig, not refreshing the GeoIP information." << std::endl;
2583 std::vector<std::string>
hosts;
2584 for (
const auto &
baseUrl : urls ) {
2585 const auto &host =
baseUrl.getHost();
2587 hosts.push_back( host );
2592 if (
hosts.empty() ) {
2593 MIL <<
"No configured geoip URL found, not updating geoip data" << std::endl;
2600 MIL <<
"Unable to create cache directory for GeoIP." << std::endl;
2605 MIL <<
"No access rights for the GeoIP cache directory." << std::endl;
2615 auto age = std::chrono::system_clock::now() - std::chrono::system_clock::from_time_t(
pi.mtime() );
2616 if (
age < std::chrono::hours(24) )
2619 MIL <<
"Removing GeoIP file for " <<
entry.name <<
" since it's older than 24hrs." << std::endl;
2625 std::for_each(
hosts.begin(),
hosts.end(), [ & ](
const std::string &hostname ) {
2628 if ( zypp::PathInfo( geoIPCache / hostname ).isExist() ) {
2629 MIL <<
"Skipping GeoIP request for " << hostname <<
" since a valid cache entry exists." << std::endl;
2633 MIL <<
"Query GeoIP for " << hostname << std::endl;
2644 MIL <<
"Ignoring invalid GeoIP hostname: " << hostname << std::endl;
2656 MIL <<
"Failed to query GeoIP from hostname: " << hostname << std::endl;
2659 if ( !file->
empty() ) {
2663 out.open(
fName.asString(), std::ios_base::trunc );
2664 if ( out.is_open() ) {
2665 out << host << std::endl;
2667 MIL <<
"Failed to create/open GeoIP cache file " <<
fName << std::endl;
2674 if (
reader.seekToNode( 1,
"host" ) ) {
2675 const auto &
str =
reader.nodeText().asString();
2683 MIL <<
"Storing geoIP redirection: " << hostname <<
" -> " <<
str << std::endl;
2688 MIL <<
"No host entry or empty file returned for GeoIP, remembering for 24hrs" << std::endl;
2692 MIL <<
"Empty or invalid GeoIP file, not requesting again for 24hrs" << std::endl;
2701 MIL <<
"Failed to query GeoIP data." << std::endl;
2719 {
return _pimpl->repoEmpty(); }
2722 {
return _pimpl->repoSize(); }
2725 {
return _pimpl->repoBegin(); }
2728 {
return _pimpl->repoEnd(); }
2731 {
return _pimpl->getRepo( alias ); }
2734 {
return _pimpl->hasRepo( alias ); }
2738 std::string
ret(
url_r.getScheme() );
2744 std::string host(
url_r.getHost() );
2745 if ( ! host.empty() )
2757 {
return _pimpl->metadataStatus( info ); }
2760 {
return _pimpl->checkIfToRefreshMetadata( info, url,
policy ); }
2763 {
return _pimpl->metadataPath( info ); }
2766 {
return _pimpl->packagesPath( info ); }
2778 {
return _pimpl->cacheStatus( info ); }
2787 {
return _pimpl->isCached( info ); }
2796 {
return _pimpl->probe( url, path ); }
2799 {
return _pimpl->probe( url ); }
2820 {
return _pimpl->serviceEmpty(); }
2823 {
return _pimpl->serviceSize(); }
2826 {
return _pimpl->serviceBegin(); }
2829 {
return _pimpl->serviceEnd(); }
2832 {
return _pimpl->getService( alias ); }
2835 {
return _pimpl->hasService( alias ); }
2838 {
return _pimpl->probeService( url ); }
2841 {
return _pimpl->addService( alias, url ); }
2844 {
return _pimpl->addService( service ); }
2847 {
return _pimpl->removeService( alias ); }
2850 {
return _pimpl->removeService( service ); }
2862 {
return _pimpl->modifyService( oldAlias, service ); }
2865 {
return _pimpl->refreshGeoIPData( urls ); }
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...
void resetDispose()
Set no dispose function.
void reset()
Reset to default Ctor values.
shared_ptr< Impl > _pimpl
Progress callback from another progress.
static const ValueType day
static Date now()
Return the current time.
std::string digest()
get hex string representation of the digest
static const std::string & sha1()
sha1
Base class for Exception.
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
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...
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
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.
Track changing files or directories.
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
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.
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
bool isValid() const
Verifies the Url.
void setScheme(const std::string &scheme)
Set the scheme name in the URL.
static ZConfig & instance()
Singleton ctor.
Wrapper class for stat/lstat.
bool isExist() const
Return whether valid stat info exists.
Pathname dirname() const
Return all but the last component od 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.
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.
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)
int compareCI(const C_Str &lhs, const C_Str &rhs)
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.
bool any_of(const Container &c, Fnc &&cb)
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
std::string asString(const Patch::Category &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 cleanPackages(const RepoInfo &info, OPT_PROGRESS, bool isAutoClean=false)
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 refreshGeoIp(const RepoInfo::url_set &urls)
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
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
void refreshGeoIPData(const RepoInfo::url_set &urls)
Listentry returned by readdir.
Repository type enumeration.
static const RepoType YAST2
static const RepoType RPMMD
static const RepoType NONE
static const RepoType RPMPLAINDIR
Functor replacing repository variables.
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)