zypp::RepoManager Class Reference

#include <RepoManager.h>

List of all members.

Public Types

enum  RawMetadataRefreshPolicy { RefreshIfNeeded, RefreshForced }
enum  CacheBuildPolicy { BuildIfNeeded, BuildForced }
enum  RepoRemovePolicy

Public Member Functions

 RepoManager (const RepoManagerOptions &options=RepoManagerOptions())
 ~RepoManager ()
 Dtor.
std::list< RepoInfoknownRepositories () const
RepoStatus metadataStatus (const RepoInfo &info) const
bool checkIfToRefreshMetadata (const RepoInfo &info, const Url &url, RawMetadataRefreshPolicy policy=RefreshIfNeeded)
 Checks whether to refresh metadata for specified repository and url.
Pathname metadataPath (const RepoInfo &info) const
void refreshMetadata (const RepoInfo &info, RawMetadataRefreshPolicy policy=RefreshIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
void cleanMetadata (const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
RepoStatus cacheStatus (const RepoInfo &info) const
void buildCache (const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
void cleanCache (const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
bool isCached (const RepoInfo &info) const
Repository createFromCache (const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Repository createFromMetadata (const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
repo::RepoType probe (const Url &url) const
void addRepository (const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
void addRepositories (const Url &url, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
void removeRepository (const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
void modifyRepository (const std::string &alias, const RepoInfo &newinfo, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
RepoInfo getRepositoryInfo (const std::string &alias, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
RepoInfo getRepositoryInfo (const Url &url, const url::ViewOption &urlview=url::ViewOption::DEFAULTS, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())

Protected Member Functions

RepoStatus rawMetadataStatus (const RepoInfo &info)
RepoStatus cacheStatus (const RepoInfo &info)
void touchIndexFile (const RepoInfo &info)
 Update timestamp of repository index file for the specified repository info.

Private Attributes

RWCOW_pointer< Impl_pimpl
 Pointer to implementation.

Friends

std::ostream & operator<< (std::ostream &str, const RepoManager &obj)
 Stream output.

Classes

struct  Impl


Detailed Description

creates and provides information about known sources.

Definition at line 64 of file RepoManager.h.


Member Enumeration Documentation

enum zypp::RepoManager::RawMetadataRefreshPolicy

Enumerator:
RefreshIfNeeded 
RefreshForced 

Definition at line 77 of file RepoManager.h.

enum zypp::RepoManager::CacheBuildPolicy

Enumerator:
BuildIfNeeded 
BuildForced 

Definition at line 83 of file RepoManager.h.

enum zypp::RepoManager::RepoRemovePolicy

Definition at line 89 of file RepoManager.h.


Constructor & Destructor Documentation

zypp::RepoManager::RepoManager ( const RepoManagerOptions options = RepoManagerOptions()  ) 

Definition at line 268 of file RepoManager.cc.

zypp::RepoManager::~RepoManager (  ) 

Dtor.

Definition at line 274 of file RepoManager.cc.


Member Function Documentation

std::list< RepoInfo > zypp::RepoManager::knownRepositories (  )  const

List known repositories.

The known repositories are read from RepoManagerOptions::knownReposPath passed on the Ctor. Which defaults to ZYpp global settings.

Returns:
found list<RepoInfo>

Definition at line 279 of file RepoManager.cc.

References _pimpl, MIL, zypp::rawcache_path_for_repoinfo(), and zypp::repositories_in_dir().

Referenced by addRepositories(), addRepository(), getRepositoryInfo(), refreshMetadata(), and removeRepository().

RepoStatus zypp::RepoManager::metadataStatus ( const RepoInfo info  )  const

Status of local metadata

Definition at line 311 of file RepoManager.cc.

References _pimpl, probe(), zypp::rawcache_path_for_repoinfo(), zypp::repo::RepoType::toEnum(), and zypp::RepoInfo::type().

Referenced by buildCache(), and checkIfToRefreshMetadata().

bool zypp::RepoManager::checkIfToRefreshMetadata ( const RepoInfo info,
const Url url,
RawMetadataRefreshPolicy  policy = RefreshIfNeeded 
)

Checks whether to refresh metadata for specified repository and url.

The need for refresh is evaluated according to the following conditions, in that order:

This method checks the status against the specified url only. If more baseurls are defined for in the RepoInfo, each one must be check individually. Example:

RepoInfo info; // try urls one by one for ( RepoInfo::urls_const_iterator it = info.baseUrlsBegin(); it != info.baseUrlsEnd(); ++it ) { try { // check whether to refresh metadata // if the check fails for this url, it throws, so another url will be checked if (!checkIfToRefreshMetadata(info, *it, policy)) return;

// do the actual refresh } catch (const Exception & e) { ZYPP_CAUGHT(e); ERR << *it << " doesn't look good. Trying another url." << endl; } } // for all urls

handle("No more URLs.");

Parameters:
info 
url 
policy 
Exceptions:
RepoUnknownTypeException 
repo::RepoNoAliasException if can't figure an alias
Exception on unknown error

Definition at line 394 of file RepoManager.cc.

References _pimpl, zypp::RepoInfo::alias(), zypp::assert_alias(), zypp::filesystem::assert_dir(), zypp::RepoStatus::checksum(), DBG, zypp::parser::plaindir::dirStatus(), ERR, zypp::Url::getPathName(), zypp::ZConfig::instance(), zypp::filesystem::TmpDir::makeSibling(), metadataStatus(), MIL, zypp::Date::now(), zypp::RepoInfo::path(), probe(), zypp::rawcache_path_for_repoinfo(), RefreshForced, zypp::ZConfig::repo_refresh_delay(), zypp::RepoStatus::timestamp(), zypp::repo::RepoType::toEnum(), touchIndexFile(), zypp::RepoInfo::type(), ZYPP_CAUGHT, ZYPP_RETHROW, and ZYPP_THROW.

Referenced by refreshMetadata().

Pathname zypp::RepoManager::metadataPath ( const RepoInfo info  )  const

Path where the metadata is downloaded and kept Given a repoinfo, tells where RepoManager will download and keep the raw metadata.

Parameters:
info Repository information
Exceptions:
repo::RepoNoAliasException if can't figure an alias

Definition at line 304 of file RepoManager.cc.

References _pimpl, and zypp::rawcache_path_for_repoinfo().

void zypp::RepoManager::refreshMetadata ( const RepoInfo info,
RawMetadataRefreshPolicy  policy = RefreshIfNeeded,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Refresh local raw cache Will try to download the metadata In case of falure the metadata remains as it was before.

Exceptions:
repo::RepoNoUrlException if no urls are available.
repo::RepoNoAliasException if can't figure an alias
repo::RepoUnknownTypeException if the metadata is unknown
repo::RepoException if the repository is invalid (no valid metadata found at any of baseurls)

Given a downloader, sets the other repos raw metadata path as cache paths for the fetcher, so if another repo has the same file, it will not download it but copy it from the other repository

Definition at line 521 of file RepoManager.cc.

References _, _pimpl, zypp::assert_alias(), zypp::filesystem::assert_dir(), zypp::assert_urls(), zypp::RepoInfo::baseUrlsBegin(), zypp::RepoInfo::baseUrlsEnd(), checkIfToRefreshMetadata(), zypp::RepoStatus::checksum(), zypp::parser::plaindir::dirStatus(), ERR, zypp::Url::getPathName(), knownRepositories(), zypp::filesystem::TmpDir::makeSibling(), MIL, zypp::filesystem::TmpPath::path(), zypp::RepoInfo::path(), probe(), zypp::rawcache_path_for_repoinfo(), zypp::Exception::remember(), zypp::filesystem::rename(), zypp::repo::RepoType::toEnum(), zypp::RepoInfo::type(), url, ZYPP_CAUGHT, and ZYPP_THROW.

void zypp::RepoManager::cleanMetadata ( const RepoInfo info,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Clean local metadata Empty local metadata.

Exceptions:
repo::RepoNoAliasException if can't figure an alias
Exception on unknown error.

Definition at line 636 of file RepoManager.cc.

References _pimpl, zypp::rawcache_path_for_repoinfo(), zypp::filesystem::recursive_rmdir(), zypp::ProgressData::sendTo(), and zypp::ProgressData::toMax().

Referenced by removeRepository().

RepoStatus zypp::RepoManager::cacheStatus ( const RepoInfo info  )  const

Status of metadata cache

Definition at line 815 of file RepoManager.cc.

References _pimpl, zypp::RepoInfo::alias(), zypp::cache::CacheStore::lookupRepository(), and zypp::cache::CacheStore::repositoryStatus().

void zypp::RepoManager::buildCache ( const RepoInfo info,
CacheBuildPolicy  policy = BuildIfNeeded,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Refresh local cache Will try to build the cache from local metadata.

If the cache exists it will be overwriten.

Note:
the local metadata must be valid.
Exceptions:
repo::RepoNoAliasException if can't figure an alias to look in cache
repo::RepoMetadataException if the metadata is not enough to build a cache (empty, incorrect, or refresh needed)
repo::RepoUnknownTypeException 
parser::ParseException if parser encounters an error.
Exception on unknown error.

Definition at line 646 of file RepoManager.cc.

References _, _pimpl, zypp::RepoInfo::alias(), zypp::assert_alias(), BuildIfNeeded, zypp::RepoStatus::checksum(), zypp::cleanCacheInternal(), zypp::cache::CacheStore::commit(), zypp::RepoStatus::empty(), zypp::str::form(), zypp::str::getline(), zypp::cache::CacheStore::isCached(), zypp::cache::CacheStore::lookupOrAppendRepository(), zypp::cache::CacheStore::lookupRepository(), metadataStatus(), MIL, zypp::RepoInfo::name(), zypp::ProgressData::name(), zypp::parser::plaindir::RepoParser::parse(), zypp::parser::susetags::RepoParser::parse(), probe(), zypp::rawcache_path_for_repoinfo(), report, zypp::cache::CacheStore::repositoryStatus(), zypp::ProgressData::sendTo(), zypp::InputStream::stream(), zypp::repo::RepoType::toEnum(), zypp::ProgressData::toMin(), zypp::RepoInfo::type(), zypp::cache::CacheStore::updateRepositoryStatus(), url, and ZYPP_THROW.

void zypp::RepoManager::cleanCache ( const RepoInfo info,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

clean local cache Clean the cached version of the metadata

Note:
the local metadata must be valid.
Exceptions:
repo::RepoNoAliasException if can't figure an alias to look in cache
cache::CacheRecordNotFoundException if the cache could not be cleaned because of repository record not found.
Exception on unknown error.

Definition at line 799 of file RepoManager.cc.

References _pimpl, zypp::cleanCacheInternal(), and zypp::cache::CacheStore::commit().

Referenced by removeRepository().

bool zypp::RepoManager::isCached ( const RepoInfo info  )  const

Whether a repository exists in cache

Parameters:
RepoInfo to be checked.

Definition at line 809 of file RepoManager.cc.

References _pimpl, zypp::RepoInfo::alias(), and zypp::cache::CacheStore::isCached().

Repository zypp::RepoManager::createFromCache ( const RepoInfo info,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Create a repository object from the cache data Creating from cache requires that the repository is refreshed (metadata downloaded) and cached

Exceptions:
repo::RepoNoAliasException if can't figure an alias to look in cache
RepoNotCachedException When the source is not cached.

Definition at line 823 of file RepoManager.cc.

References _, _pimpl, zypp::RepoInfo::alias(), zypp::str::form(), zypp::cache::CacheStore::isCached(), zypp::cache::CacheStore::lookupRepository(), MIL, zypp::RepoInfo::name(), zypp::ProgressData::name(), zypp::repo::cached::RepoOptions::readingResolvablesProgress, report, zypp::ProgressData::sendTo(), and ZYPP_THROW.

Repository zypp::RepoManager::createFromMetadata ( const RepoInfo info,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Create a repository object from raw metadata Creating from cache requires that the repository is refreshed (metadata downloaded)

Exceptions:
Exception If there are errors parsing the raw metadata

repo::RepoType zypp::RepoManager::probe ( const Url url  )  const

Probe repo metadata type.

Todo:
FIXME Should this be private?

Definition at line 751 of file RepoManager.cc.

References zypp::Url::asString(), zypp::MediaSetAccess::doesFileExist(), zypp::media::MediaManager::downloads(), zypp::Url::getPathName(), zypp::Url::getScheme(), zypp::repo::RepoType::NONE, zypp::repo::RepoType::RPMMD, zypp::repo::RepoType::RPMPLAINDIR, zypp::repo::RepoType::YAST2, ZYPP_CAUGHT, and ZYPP_THROW.

Referenced by addRepository(), buildCache(), checkIfToRefreshMetadata(), metadataStatus(), refreshMetadata(), and touchIndexFile().

void zypp::RepoManager::addRepository ( const RepoInfo info,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Adds a repository to the list of known repositories.

Exceptions:
repo::RepoAlreadyExistsException If the repo clash some unique attribute like alias
RepoUnknownType If repository type can't be determined
RepoException If the access to the url fails (while probing).
Exception On other errors.

Definition at line 912 of file RepoManager.cc.

References _, _pimpl, zypp::RepoInfo::alias(), zypp::assert_alias(), zypp::filesystem::assert_dir(), zypp::RepoInfo::baseUrlsBegin(), zypp::RepoInfo::baseUrlsSize(), DBG, zypp::RepoInfo::dumpRepoOn(), zypp::RepoInfo::enabled(), zypp::str::form(), zypp::generate_filename(), zypp::generate_non_existing_name(), zypp::ZConfig::instance(), knownRepositories(), MIL, zypp::RepoInfo::name(), zypp::ProgressData::name(), zypp::media::NONE, probe(), zypp::ZConfig::repo_add_probe(), report, zypp::ProgressData::sendTo(), zypp::ProgressData::set(), zypp::RepoInfo::setType(), zypp::ProgressData::toMax(), zypp::ProgressData::toMin(), zypp::RepoInfo::type(), and ZYPP_THROW.

void zypp::RepoManager::addRepositories ( const Url url,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Adds repositores from a repo file to the list of known repositories.

Parameters:
url Url of the repo file
Exceptions:
repo::RepoAlreadyExistsException If the repo clash some unique attribute like alias
RepoAlreadyExistsException 
MediaException If the access to the url fails
ParseException If the file parsing fails
RepoUnknownType If repository type can't be determined
RepoException ON other repository related errors
Exception On other errors.

Definition at line 971 of file RepoManager.cc.

References _pimpl, zypp::filesystem::assert_dir(), zypp::Url::asString(), ERR, zypp::generate_non_existing_name(), zypp::Url::getPathName(), knownRepositories(), MIL, zypp::readRepoFile(), and ZYPP_THROW.

void zypp::RepoManager::removeRepository ( const RepoInfo info,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Remove the best matching repository from known repos list

Exceptions:
RepoNotFoundException If no repo match

Definition at line 1022 of file RepoManager.cc.

References _, zypp::RepoInfo::alias(), zypp::filesystem::assert_dir(), cleanCache(), cleanMetadata(), zypp::RepoInfo::filepath(), zypp::str::form(), knownRepositories(), MIL, zypp::RepoInfo::name(), zypp::ProgressData::name(), report, zypp::repositories_in_file(), zypp::ProgressData::sendTo(), zypp::filesystem::unlink(), and ZYPP_THROW.

void zypp::RepoManager::modifyRepository ( const std::string &  alias,
const RepoInfo newinfo,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Modify repository attributes

Exceptions:
RepoNotFoundException If no repo match
ParseException If the file parsing fails
Exception On other errors.

Definition at line 1106 of file RepoManager.cc.

References zypp::RepoInfo::alias(), zypp::filesystem::assert_dir(), zypp::RepoInfo::dumpRepoOn(), zypp::RepoInfo::filepath(), getRepositoryInfo(), zypp::repositories_in_file(), and ZYPP_THROW.

RepoInfo zypp::RepoManager::getRepositoryInfo ( const std::string &  alias,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Find a matching repository info

Note:
if multiple repositories incorrectly share the same alias, the first one found will be returned.
Parameters:
alias Repository alias
progressrcv Progress reporting function
Returns:
RepoInfo of the found repository
Exceptions:
RepoNotFoundException If no repo match the alias
ParseException If the file parsing fails
Exception On other errors.

Definition at line 1150 of file RepoManager.cc.

References zypp::RepoInfo::alias(), knownRepositories(), zypp::RepoInfo::setAlias(), and ZYPP_THROW.

Referenced by modifyRepository().

RepoInfo zypp::RepoManager::getRepositoryInfo ( const Url url,
const url::ViewOption urlview = url::ViewOption::DEFAULTS,
const ProgressData::ReceiverFnc progressrcv = ProgressData::ReceiverFnc() 
)

Find repository info by URL.

Parameters:
url URL to find.
urlview url::ViewOption to influence URL matching.
progressrcv Progress receiver function.
Returns:
RepoInfo of the found repository.
Note:
if multpile repositories incorrectly share the same URL, the first one found will be returned.

the string representation of the URLs are compared. The urlview can be used to influence which parts of the URL are to be compared.

Exceptions:
RepoNotFoundException If no repo match
ParseException If the file parsing fails
Exception On other errors.

Definition at line 1168 of file RepoManager.cc.

References zypp::RepoInfo::alias(), zypp::Url::asString(), knownRepositories(), zypp::RepoInfo::setAlias(), zypp::RepoInfo::setBaseUrl(), and ZYPP_THROW.

RepoStatus zypp::RepoManager::rawMetadataStatus ( const RepoInfo info  )  [protected]

RepoStatus zypp::RepoManager::cacheStatus ( const RepoInfo info  )  [protected]

void zypp::RepoManager::touchIndexFile ( const RepoInfo info  )  [protected]

Update timestamp of repository index file for the specified repository info.

Used in checkIfToRefreshMetadata() for repo.refresh.delay feature.

Definition at line 358 of file RepoManager.cc.

References _pimpl, probe(), zypp::rawcache_path_for_repoinfo(), zypp::repo::RepoType::toEnum(), zypp::filesystem::touch(), and zypp::RepoInfo::type().

Referenced by checkIfToRefreshMetadata().


Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  str,
const RepoManager obj 
) [friend]

Stream output.

Definition at line 1193 of file RepoManager.cc.


Member Data Documentation

RWCOW_pointer<Impl> zypp::RepoManager::_pimpl [private]

Pointer to implementation.

Definition at line 389 of file RepoManager.h.

Referenced by addRepositories(), addRepository(), buildCache(), cacheStatus(), checkIfToRefreshMetadata(), cleanCache(), cleanMetadata(), createFromCache(), isCached(), knownRepositories(), metadataPath(), metadataStatus(), zypp::operator<<(), refreshMetadata(), and touchIndexFile().


The documentation for this class was generated from the following files:
Generated on Tue Sep 25 19:23:16 2007 for libzypp by  doxygen 1.5.3