Deepsolver
Public Member Functions
Deepsolver::RpmBackEnd Class Reference

The general interface to librpm functions. More...

Inheritance diagram for Deepsolver::RpmBackEnd:
Deepsolver::AbstractPkgBackEnd

List of all members.

Public Member Functions

std::string combineNameAndVer (const std::string &name, const std::string &ver) const override
 Combines the package name and the package version into one string.
AbstractInstalledPkgIterator::Ptr enumInstalledPkg () const override
 Creates an instance of an iterator over the set of installed packages.
std::string getDesignation (const PkgBase &pkg, int epochMode) const override
 Constructs the string designation of the provided package.
std::string getDesignation (const NamedPkgRel &rel) const override
 Constructs the string designation of the package relation.
void initialize () override
 Prepares package back-end for any operations.
std::string makeVer (int epoch, const std::string &ver, const std::string &release, int epochMode) const override
 Constructs a version designating string.
std::string makeVer (const PkgBase &pkg, int epochMode) const override
 Constructs the string designating the package version.
bool matches (const NamedPkgRel &rel, const Pkg &pkg) const override
 Checks if the package suits to the relation.
bool matches (const NamedPkgRel &rel, const NamedPkgRel &provide) const override
 Checks if the provide entry suits to the relation (named form)
bool matches (const IdPkgRel &rel, const IdPkgRel &provide) const override
 Checks if the provide entry suits to the relation (IDs form)
void readPkgFile (const std::string &fileName, PkgFile &pkgFile) const override
 Reads header information from package file on disk.
 RpmBackEnd ()
 The default constructor.
bool theSamePkg (const PkgBase &pkg1, const PkgBase &pkg2) const override
 Checks if two instances represent the same package.
bool transaction (const StringVector &toInstall, const StringVector &toRemove, const StringToStringMap &toUpgrade, const StringToStringMap &toDowngrade) override
 Performs install/remove transaction with given packages.
bool validPkgFileName (const std::string &fileName) const override
 Checks if provided file name is a proper package name.
bool validSourcePkgFileName (const std::string &fileName) const override
 Checks if provided file name is a proper source package name.
int verCmp (const std::string &ver1, const std::string &ver2) const override
 Compares two version strings.
bool verEqual (const std::string &ver1, const std::string &ver2) const override
 Checks the equality of two version values.
bool verGreater (const std::string &ver1, const std::string &ver2) const override
 Checks if one version is newer than another.
bool verOverlap (const VerSubset &ver1, const VerSubset &ver2) const override
 Overlaps two version ranges.
virtual ~RpmBackEnd ()
 The destructor.

Detailed Description

This class covers all functions of librpm needed for proper Deepsolver work. Since Deepsolver purposed by design as universal package manager all package libraries should be used through an abstraction layer represented by AbstractPackageBackEnd class. Be careful, even with abstraction layer user can face compatibility problems due to differences in details implementation.

See also:
AbstractPackageBackEnd

Member Function Documentation

std::string RpmBackEnd::combineNameAndVer ( const std::string &  name,
const std::string &  ver 
) const [override, virtual]
Parameters:
[in]nameThe package name
[in]verThe package version
Returns:
The combined package string

Implements Deepsolver::AbstractPkgBackEnd.

AbstractInstalledPkgIterator::Ptr RpmBackEnd::enumInstalledPkg ( ) const [override, virtual]
Returns:
The iterator over the set of installed packages

Implements Deepsolver::AbstractPkgBackEnd.

std::string Deepsolver::RpmBackEnd::getDesignation ( const PkgBase pkg,
int  epochMode 
) const [override, virtual]
Parameters:
[in]pkgThe package to construct string designation for
[in]Theepoch including mode (can be EpochNever, EpochIfNonZero or EpochAlways)
Returns:
The constructed package designation

Implements Deepsolver::AbstractPkgBackEnd.

std::string Deepsolver::RpmBackEnd::getDesignation ( const NamedPkgRel rel) const [override, virtual]
Parameters:
[in]relThe package relation to construct designation for
Returns:
The constructed package relation designation

Implements Deepsolver::AbstractPkgBackEnd.

void RpmBackEnd::initialize ( ) [override, virtual]

This method should be called before performing any operations with particular package library. For safety reasons it is assumed that invocation is needed for every created instance of the back-end but actually it is not always the case. For example, if RpmBackEnd is used, this method may be called only once using any instance.

Implements Deepsolver::AbstractPkgBackEnd.

std::string Deepsolver::RpmBackEnd::makeVer ( int  epoch,
const std::string &  ver,
const std::string &  release,
int  epochMode 
) const [override, virtual]
Parameters:
[in]epochThe version epoch
[inver The package version
[in]The package release
[in]Theepoch including mode (can be EpochNever, EpochIfNonZero or EpochAlways)
Returns:
The constructed version string

Implements Deepsolver::AbstractPkgBackEnd.

std::string Deepsolver::RpmBackEnd::makeVer ( const PkgBase pkg,
int  epochMode 
) const [override, virtual]
Parameters:
[in]pkgThe package to construct version string for
[in]Theepoch including mode (can be EpochNever, EpochIfNonZero or EpochAlways)
Returns:
The version string for the provided package

Implements Deepsolver::AbstractPkgBackEnd.

bool Deepsolver::RpmBackEnd::matches ( const NamedPkgRel rel,
const Pkg pkg 
) const [override, virtual]
Parameters:
[in]relThe relation
[in]pkgThe package to check for
Returns:
Non-zero if the package matches the relation and zero otherwise

Implements Deepsolver::AbstractPkgBackEnd.

bool Deepsolver::RpmBackEnd::matches ( const NamedPkgRel rel,
const NamedPkgRel provide 
) const [override, virtual]
Parameters:
[in]relThe relation to check with
[in]provideThe provide entry to check
Returns:
Non-zero if the provide entry matches the relation

Implements Deepsolver::AbstractPkgBackEnd.

bool Deepsolver::RpmBackEnd::matches ( const IdPkgRel rel,
const IdPkgRel provide 
) const [override, virtual]
Parameters:
[in]relThe relation to check with
[in]provideThe provide entry to check
Returns:
Non-zero if the provide entry matches the relation

Implements Deepsolver::AbstractPkgBackEnd.

void RpmBackEnd::readPkgFile ( const std::string &  fileName,
PkgFile pkgFile 
) const [override, virtual]
Parameters:
[in]fileNameThe name of the file to read data from
[out]pkgFileThe object to save retrieved data to

Implements Deepsolver::AbstractPkgBackEnd.

bool RpmBackEnd::theSamePkg ( const PkgBase pkg1,
const PkgBase pkg2 
) const [override, virtual]
Parameters:
[in]pkg1The first package to compare
[in]pkg2The second package to compare
Returns:
Non-zero if they represent the same package or zero otherwise

Implements Deepsolver::AbstractPkgBackEnd.

bool RpmBackEnd::transaction ( const StringVector &  toInstall,
const StringVector &  toRemove,
const StringToStringMap &  toUpgrade,
const StringToStringMap &  toDowngrade 
) [override, virtual]

This method gives a way to make desired changes in operating system state. With it everybody can perform a transaction containing any installation, removing, upgrading and downgrading tasks. The main restriction is a requirement that all package dependencies and conflicts must be satisfied. The package to install must be provided with their file names, packages to remove by their names (without a version or any other additional information), packages to upgrade and downgrade must be specified by a string-to-string map from package names to file names.

If a transaction fails this method returns zero. The state of OS after failed transaction is unspecified and package back-end dependent.

Parameters:
[in]toInstallThe file names vector with packages to install
[in]toRemoveThe file names vector with packages to remove
[in]toUpgradeThe map from package names to file names with packages to upgrade
[in]toDowngradeThe map from package names to file names with packages to downgrade
Returns:
Non-zero if a transaction is completed successfully or zero otherwise
Exceptions:
PackageBackEndException

Implements Deepsolver::AbstractPkgBackEnd.

bool RpmBackEnd::validPkgFileName ( const std::string &  fileName) const [override, virtual]
Parameters:
[in]fileNameThe file name to check
Returns:
Non-zero if provided file name is a valid package name and zero otherwise

Implements Deepsolver::AbstractPkgBackEnd.

bool RpmBackEnd::validSourcePkgFileName ( const std::string &  fileName) const [override, virtual]
Parameters:
[in]fileNameThe file name to check
Returns:
Non-zero if provided file name is a valid source package name and zero otherwise

Implements Deepsolver::AbstractPkgBackEnd.

int RpmBackEnd::verCmp ( const std::string &  ver1,
const std::string &  ver2 
) const [override, virtual]
Parameters:
[in]ver1The first version value to compare
[in]ver2The second version value to compare
Returns:
The integer value less than zero if ver1 less than ver2, greater than zero if ver1 greater than ver2 and zero otherwise

Implements Deepsolver::AbstractPkgBackEnd.

bool RpmBackEnd::verEqual ( const std::string &  ver1,
const std::string &  ver2 
) const [override, virtual]
Parameters:
[in]ver1The first string to compare
[in]ver2The second string to compare
Returns:
Non-zero if two strings designate the same value or zero otherwise

Implements Deepsolver::AbstractPkgBackEnd.

bool RpmBackEnd::verGreater ( const std::string &  ver1,
const std::string &  ver2 
) const [override, virtual]
Parameters:
[in]ver1The first string to compare
[in]ver2The second string to compare
Returns:
Non-zero if ver1 is greater than ver2 or zero if ver1 is less or equal ver2

Implements Deepsolver::AbstractPkgBackEnd.

bool RpmBackEnd::verOverlap ( const VerSubset ver1,
const VerSubset ver2 
) const [override, virtual]

This method is not symmetric. If second version range has no epoch indication it assumes the first one may have any. So if this method is used for requires processing, the require entry can go only as second argument.

Parameters:
[in]ver1The first version range to intersect
[in]ver2The second version range to intersect
Returns:
Non-zero if intersection is not empty and zero otherwise

Implements Deepsolver::AbstractPkgBackEnd.