Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

RpmDb Class Reference

Interface to the rpm program. More...

#include <RpmDb.h>

Inheritance diagram for RpmDb:

CountedRep Rep List of all members.

Public Types

typedef InstTargetError Error
typedef std::set< std::string > FileList
enum  RpmInstFlag {
  RPMINST_NONE = 0x00, RPMINST_NODOCS = 0x01, RPMINST_NOSCRIPTS = 0x02, RPMINST_FORCE = 0x04,
  RPMINST_NODEPS = 0x08, RPMINST_IGNORESIZE = 0x10, RPMINST_JUSTDB = 0x20, RPMINST_NODIGEST = 0x40,
  RPMINST_NOSIGNATURE = 0x80
}
enum  checkPackageResult {
  CHK_OK = 0x00, CHK_INCORRECT_VERSION = 0x01, CHK_INCORRECT_FILEMD5 = 0x02, CHK_GPGSIG_MISSING = 0x04,
  CHK_MD5SUM_MISSING = 0x08, CHK_INCORRECT_GPGSIG = 0x10, CHK_INCORRECT_PKGMD5 = 0x20, CHK_OTHER_FAILURE = 0x40
}

Public Member Functions

 RpmDb ()
 ~RpmDb ()
const Pathnameroot () const
const PathnamedbPath () const
bool initialized () const
PMError initDatabase (Pathname root_r=Pathname(), Pathname dbPath_r=Pathname())
PMError closeDatabase ()
PMError rebuildDatabase ()
PMError importPubkey (const Pathname &pubkey_r)
PMError importPubkey (const Pathname &keyring_r, const std::string &keyname_r)
std::set< PkgEditionpubkeys () const
bool packagesValid () const
const std::list< PMPackagePtr > & getPackages ()
void traceFileRel (const PkgRelation &rel_r)
bool hasFile (const std::string &file_r) const
bool hasProvides (const std::string &tag_r) const
bool hasRequiredBy (const std::string &tag_r) const
bool hasConflicts (const std::string &tag_r) const
bool hasPackage (const PkgName &name_r) const
PMError getData (const PkgName &name_r, constRpmHeaderPtr &result_r) const
PMError getData (const PkgName &name_r, const PkgEdition &ed_r, constRpmHeaderPtr &result_r) const
unsigned checkPackage (const Pathname &filename, std::string version="", std::string md5="")
PMError installPackage (const Pathname &filename, unsigned flags=0)
PMError removePackage (const std::string &name_r, unsigned flags=0)
PMError removePackage (constPMPackagePtr package, unsigned flags=0)
Pathname getBackupPath (void)
bool backupPackage (const std::string &packageName)
bool backupPackage (const Pathname &filename)
void setBackupPath (const Pathname &path)
void createPackageBackups (bool yes)
bool queryChangedFiles (FileList &fileList, const std::string &packageName)
virtual std::ostream & dumpOn (std::ostream &str) const

Static Public Member Functions

std::string checkPackageResult2string (unsigned code)
bool setInstallationLogfile (const Pathname &filename)

Private Types

typedef std::vector< const
char * > 
RpmArgVec
enum  DbStateInfoBits {
  DbSI_NO_INIT = 0x0000, DbSI_HAVE_V4 = 0x0001, DbSI_MADE_V4 = 0x0002, DbSI_MODIFIED_V4 = 0x0004,
  DbSI_HAVE_V3 = 0x0008, DbSI_HAVE_V3TOV4 = 0x0010, DbSI_MADE_V3TOV4 = 0x0020
}

Private Member Functions

 REP_BODY (RpmDb)
void dbsi_set (DbStateInfoBits &val_r, const unsigned &bits_r) const
void dbsi_clr (DbStateInfoBits &val_r, const unsigned &bits_r) const
bool dbsi_has (const DbStateInfoBits &val_r, const unsigned &bits_r) const
PMError internal_initDatabase (const Pathname &root_r, const Pathname &dbPath_r, DbStateInfoBits &info_r)
void modifyDatabase ()
void run_rpm (const RpmArgVec &options, ExternalProgram::Stderr_Disposition stderr_disp=ExternalProgram::Stderr_To_Stdout)
bool systemReadLine (std::string &line)
int systemStatus ()
void systemKill ()
void processConfigFiles (const std::string &line, const std::string &name, const char *typemsg, const char *difffailmsg, const char *diffgenmsg)

Static Private Member Functions

void removeV4 (const Pathname &dbdir_r, bool v3backup_r)
void removeV3 (const Pathname &dbdir_r, bool v3backup_r)

Private Attributes

DbStateInfoBits _dbStateInfo
Pathname _root
Pathname _dbPath
Packages_packages
FileDeps::FileNames _filerequires
ExternalProgramprocess
int exit_code
Pathname _backuppath
bool _packagebackups
bool _warndirexists

Friends

std::ostream & operator<< (std::ostream &str, const DbStateInfoBits &obj)

Detailed Description

Interface to the rpm program.


Member Typedef Documentation

typedef class InstTargetError RpmDb::Error
 

Default error class

typedef std::set<std::string> RpmDb::FileList
 

typedef std::vector<const char*> RpmDb::RpmArgVec [private]
 


Member Enumeration Documentation

enum RpmDb::checkPackageResult
 

Bits of possible package corruptions

See also:
checkPackage

checkPackageResult2string

Enumeration values:
CHK_OK 
CHK_INCORRECT_VERSION 
CHK_INCORRECT_FILEMD5 
CHK_GPGSIG_MISSING 
CHK_MD5SUM_MISSING 
CHK_INCORRECT_GPGSIG 
CHK_INCORRECT_PKGMD5 
CHK_OTHER_FAILURE 

enum RpmDb::DbStateInfoBits [private]
 

Enumeration values:
DbSI_NO_INIT 
DbSI_HAVE_V4 
DbSI_MADE_V4 
DbSI_MODIFIED_V4 
DbSI_HAVE_V3 
DbSI_HAVE_V3TOV4 
DbSI_MADE_V3TOV4 

enum RpmDb::RpmInstFlag
 

Bits representing rpm installation options, useable as or combination

See also:
installPackage(), removePackage()
Enumeration values:
RPMINST_NONE 
RPMINST_NODOCS 
RPMINST_NOSCRIPTS 
RPMINST_FORCE 
RPMINST_NODEPS 
RPMINST_IGNORESIZE 
RPMINST_JUSTDB 
RPMINST_NODIGEST 
RPMINST_NOSIGNATURE 


Constructor & Destructor Documentation

RpmDb::RpmDb  ) 
 

Constructor. There's no rpmdb access until initDatabase was called.

RpmDb::~RpmDb  ) 
 

Destructor.


Member Function Documentation

bool RpmDb::backupPackage const Pathname filename  ) 
 

queries file for name and then calls above backupPackage function. For convenience.

Parameters:
filename rpm file that is about to be installed

bool RpmDb::backupPackage const std::string &  packageName  ) 
 

create tar.gz of all changed files in a Package

Parameters:
packageName name of the Package to backup
See also:
setBackupPath

unsigned RpmDb::checkPackage const Pathname filename,
std::string  version = "",
std::string  md5 = ""
 

Check rpm with rpm --checksig

Parameters:
filename which file to check
version check if package really contains this version, leave emtpy to skip check
md5 md5sum for whole file, leave empty to skip check (not yet implemented)
Returns:
checkPackageResult

string RpmDb::checkPackageResult2string unsigned  code  )  [static]
 

create error description of bits set according to checkPackageResult

PMError RpmDb::closeDatabase  ) 
 

Block further access to the rpm database and go back to uninitialized state. On update: Decides what to do with any converted database (see initDatabase).

void RpmDb::createPackageBackups bool  yes  )  [inline]
 

whether to create package backups during install or removal

Parameters:
yes true or false

const Pathname& RpmDb::dbPath  )  const [inline]
 

Returns:
Directory that contains the rpmdb (empty if not initialized).

void RpmDb::dbsi_clr DbStateInfoBits val_r,
const unsigned &  bits_r
const [inline, private]
 

bool RpmDb::dbsi_has const DbStateInfoBits val_r,
const unsigned &  bits_r
const [inline, private]
 

void RpmDb::dbsi_set DbStateInfoBits val_r,
const unsigned &  bits_r
const [inline, private]
 

std::ostream & RpmDb::dumpOn std::ostream &  str  )  const [virtual]
 

Dump debug info.

Reimplemented from CountedRep.

Pathname RpmDb::getBackupPath void   )  [inline]
 

get backup dir for rpm config files

PMError RpmDb::getData const PkgName name_r,
const PkgEdition ed_r,
constRpmHeaderPtr &  result_r
const
 

Get an installed packages data from rpmdb. Package is identified by name and edition. Data returned via result are NULL, if packge is not installed (PMError is not set), or RPM database could not be read (PMError is set).

PMError RpmDb::getData const PkgName name_r,
constRpmHeaderPtr &  result_r
const
 

Get an installed packages data from rpmdb. Package is identified by name. Data returned via result are NULL, if packge is not installed (PMError is not set), or RPM database could not be read (PMError is set).

const std::list< PMPackagePtr > & RpmDb::getPackages  ) 
 

If necessary build, and return the list of all installed packages.

bool RpmDb::hasConflicts const std::string &  tag_r  )  const
 

Return true if at least one package conflicts with a certain tag.

bool RpmDb::hasFile const std::string &  file_r  )  const
 

Return true if at least one package owns a certain file.

bool RpmDb::hasPackage const PkgName name_r  )  const
 

Return true if package is installed.

bool RpmDb::hasProvides const std::string &  tag_r  )  const
 

Return true if at least one package provides a certain tag.

bool RpmDb::hasRequiredBy const std::string &  tag_r  )  const
 

Return true if at least one package requires a certain tag.

PMError RpmDb::importPubkey const Pathname keyring_r,
const std::string &  keyname_r
 

Import ascii armored public key keyname_r exported by keyring_r.

PMError RpmDb::importPubkey const Pathname pubkey_r  ) 
 

Import ascii armored public key in file pubkey_r.

PMError RpmDb::initDatabase Pathname  root_r = Pathname(),
Pathname  dbPath_r = Pathname()
 

Prepare access to the rpm database. Optional arguments may denote the root directory for all operations and the directory (below root) that contains the rpmdb (usg. you won't need to set this).

On empty Pathnames the default is used:

root: / dbPath: /var/lib/rpm

Calling initDatabase a second time with different arguments will return an error but leave the database in it's original state.

Converting an old batabase is done if necessary. On update: The converted database will be removed by closeDatabase, if it was not modified (no packages were installed or deleted). Otherwise the new database is kept, and the old one is removed.

bool RpmDb::initialized  )  const [inline]
 

Returns:
Whether we are initialized.

PMError RpmDb::installPackage const Pathname filename,
unsigned  flags = 0
 

install rpm package

Parameters:
filename file to install
flags which rpm options to use
Returns:
success

PMError RpmDb::internal_initDatabase const Pathname root_r,
const Pathname dbPath_r,
DbStateInfoBits info_r
[private]
 

Internal helper for initDatabase.

void RpmDb::modifyDatabase  )  [private]
 

Called before the database is modified by installPackage/removePackage. Invalidates Packages list and moves away any old database.

bool RpmDb::packagesValid  )  const
 

Returns:
Whether the list of installed packages is valid, or you'd better reread it. (NOTE: returns valid, if not initialized).

void RpmDb::processConfigFiles const std::string &  line,
const std::string &  name,
const char *  typemsg,
const char *  difffailmsg,
const char *  diffgenmsg
[private]
 

handle rpm messages like "/etc/testrc saved as /etc/testrc.rpmorig"

Parameters:
line rpm output starting with warning:
name name of package, appears in subject line
typemsg " saved as " or " created as "
difffailmsg what to put into mail if diff failed, must contain two s for the two files
diffgenmsg what to put into mail if diff succeeded, must contain two s for the two files

set< PkgEdition > RpmDb::pubkeys  )  const
 

Return the editions of all installed public keys.

bool RpmDb::queryChangedFiles FileList fileList,
const std::string &  packageName
 

determine which files of an installed package have been modified.

Parameters:
fileList (output) where to store modified files
packageName name of package to query
Returns:
false if package couln't be queried for some reason

PMError RpmDb::rebuildDatabase  ) 
 

Rebuild the rpm database (rpm --rebuilddb).

PMError RpmDb::removePackage constPMPackagePtr  package,
unsigned  flags = 0
 

PMError RpmDb::removePackage const std::string &  name_r,
unsigned  flags = 0
 

remove rpm package

Parameters:
name_r Name of the rpm package to remove.
iflags which rpm options to use
Returns:
success

void RpmDb::removeV3 const Pathname dbdir_r,
bool  v3backup_r
[static, private]
 

Remove the rpm3 database in dbdir_r. Create a backup copy named packages.rpm3 if it does not already exist.

void RpmDb::removeV4 const Pathname dbdir_r,
bool  v3backup_r
[static, private]
 

Remove the rpm4 database in dbdir_r and optionally any backup created on conversion.

RpmDb::REP_BODY RpmDb   )  [private]
 

const Pathname& RpmDb::root  )  const [inline]
 

Returns:
Root directory for all operations (empty if not initialized).

void RpmDb::run_rpm const RpmArgVec options,
ExternalProgram::Stderr_Disposition  stderr_disp = ExternalProgram::Stderr_To_Stdout
[private]
 

Run rpm with the specified arguments and handle stderr.

Parameters:
n_opts The number of arguments
options Array of the arguments, n_opts elements
stderr_disp How to handle stderr, merged with stdout by default

void RpmDb::setBackupPath const Pathname path  ) 
 

set path where package backups are stored

See also:
backupPackage

bool RpmDb::setInstallationLogfile const Pathname filename  )  [static]
 

Set logfile for progress log. Empty filename to disable logging.

void RpmDb::systemKill  )  [private]
 

Forcably kill the system process

bool RpmDb::systemReadLine std::string &  line  )  [private]
 

Read a line from the general rpm query

int RpmDb::systemStatus  )  [private]
 

Return the exit status of the general rpm process, closing the connection if not already done.

void RpmDb::traceFileRel const PkgRelation rel_r  ) 
 

Hack to lookup required and conflicting file relations.


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  str,
const DbStateInfoBits obj
[friend]
 


Member Data Documentation

Pathname RpmDb::_backuppath [private]
 

/var/adm/backup

Pathname RpmDb::_dbPath [private]
 

Directory that contains the rpmdb.

DbStateInfoBits RpmDb::_dbStateInfo [private]
 

Internal state info

FileDeps::FileNames RpmDb::_filerequires [private]
 

bool RpmDb::_packagebackups [private]
 

create package backups?

Packages& RpmDb::_packages [private]
 

Pathname RpmDb::_root [private]
 

Root directory for all operations.

bool RpmDb::_warndirexists [private]
 

whether / was already created

int RpmDb::exit_code [private]
 

The exit code of the rpm process, or -1 if not yet known.

ExternalProgram* RpmDb::process [private]
 

The connection to the rpm process.


The documentation for this class was generated from the following files:
Generated on Fri Nov 9 14:30:33 2007 for yast2-packagemanager by doxygen 1.3.6