libzypp
10.5.0
|
Interface to the rpm program. More...
#include <RpmDb.h>
Public Types | |
enum | checkPackageResult { CHK_OK = 0, CHK_NOTFOUND = 1, CHK_FAIL = 2, CHK_NOTTRUSTED = 3, CHK_NOKEY = 4, CHK_ERROR = 5 } |
checkPackage result More... | |
typedef class InstTargetError | Error |
Default error class. | |
typedef std::set< std::string > | FileList |
Public Member Functions | |
RpmDb () | |
Constructor. | |
~RpmDb () | |
Destructor. | |
Date | timestamp () const |
timestamp of the rpm database (last modification) | |
const Pathname & | root () const |
const Pathname & | dbPath () const |
bool | initialized () const |
void | initDatabase (Pathname root_r=Pathname(), Pathname dbPath_r=Pathname(), bool doRebuild_r=false) |
Prepare access to the rpm database. | |
void | closeDatabase () |
Block further access to the rpm database and go back to uninitialized state. | |
void | rebuildDatabase () |
Rebuild the rpm database (rpm --rebuilddb). | |
void | importPubkey (const PublicKey &pubkey_r) |
Import ascii armored public key in file pubkey_r. | |
void | removePubkey (const PublicKey &pubkey_r) |
Remove a public key from the rpm database. | |
std::list< PublicKey > | pubkeys () const |
Return the long ids of all installed public keys. | |
std::set< Edition > | pubkeyEditions () const |
Return the edition of all installed public keys. | |
std::list< FileInfo > | fileList (const std::string &name_r, const Edition &edition_r) const |
return complete file list for installed package name_r (in FileInfo.filename) if edition_r != Edition::noedition, check for exact edition if full==true, fill all attributes of FileInfo | |
bool | hasFile (const std::string &file_r, const std::string &name_r="") const |
Return true if at least one package owns a certain file (name_r empty) Return true if package name_r owns file file_r (name_r nonempty). | |
std::string | whoOwnsFile (const std::string &file_r) const |
Return name of package owning file or empty string if no installed package owns file. | |
bool | hasProvides (const std::string &tag_r) const |
Return true if at least one package provides a certain tag. | |
bool | hasRequiredBy (const std::string &tag_r) const |
Return true if at least one package requires a certain tag. | |
bool | hasConflicts (const std::string &tag_r) const |
Return true if at least one package conflicts with a certain tag. | |
bool | hasPackage (const std::string &name_r) const |
Return true if package is installed. | |
bool | hasPackage (const std::string &name_r, const Edition &ed_r) const |
Return true if package is installed in a certain edition. | |
void | getData (const std::string &name_r, RpmHeader::constPtr &result_r) const |
Get an installed packages data from rpmdb. | |
void | getData (const std::string &name_r, const Edition &ed_r, RpmHeader::constPtr &result_r) const |
Get an installed packages data from rpmdb. | |
void | importZyppKeyRingTrustedKeys () |
iterates through zypp keyring and import all non existant keys into rpm keyring | |
void | exportTrustedKeysInZyppKeyRing () |
insert all rpm trusted keys into zypp trusted keyring | |
checkPackageResult | checkPackage (const Pathname &path_r) |
Check signature of rpm file on disk. | |
void | installPackage (const Pathname &filename, RpmInstFlags flags=RPMINST_NONE) |
install rpm package | |
void | removePackage (const std::string &name_r, RpmInstFlags flags=RPMINST_NONE) |
remove rpm package | |
void | removePackage (Package::constPtr package, RpmInstFlags flags=RPMINST_NONE) |
Pathname | getBackupPath (void) |
get backup dir for rpm config files | |
bool | backupPackage (const std::string &packageName) |
create tar.gz of all changed files in a Package | |
bool | backupPackage (const Pathname &filename) |
queries file for name and then calls above backupPackage function. | |
void | setBackupPath (const Pathname &path) |
set path where package backups are stored | |
void | createPackageBackups (bool yes) |
whether to create package backups during install or removal | |
bool | queryChangedFiles (FileList &fileList, const std::string &packageName) |
determine which files of an installed package have been modified. | |
virtual std::ostream & | dumpOn (std::ostream &str) const |
Dump debug info. | |
Protected Member Functions | |
void | doRemovePackage (const std::string &name_r, RpmInstFlags flags, callback::SendReport< RpmRemoveReport > &report) |
void | doInstallPackage (const Pathname &filename, RpmInstFlags flags, callback::SendReport< RpmInstallReport > &report) |
void | doRebuildDatabase (callback::SendReport< RebuildDBReport > &report) |
Private Types | |
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 } |
typedef std::vector< const char * > | RpmArgVec |
Private Member Functions | |
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 |
void | internal_initDatabase (const Pathname &root_r, const Pathname &dbPath_r, DbStateInfoBits &info_r) |
Internal helper for initDatabase. | |
void | modifyDatabase () |
Called before the database is modified by installPackage/removePackage. | |
void | run_rpm (const RpmArgVec &options, ExternalProgram::Stderr_Disposition stderr_disp=ExternalProgram::Stderr_To_Stdout) |
Run rpm with the specified arguments and handle stderr. | |
bool | systemReadLine (std::string &line) |
Read a line from the general rpm query. | |
int | systemStatus () |
Return the exit status of the general rpm process, closing the connection if not already done. | |
void | systemKill () |
Forcably kill the system process. | |
void | processConfigFiles (const std::string &line, const std::string &name, const char *typemsg, const char *difffailmsg, const char *diffgenmsg) |
handle rpm messages like "/etc/testrc saved as /etc/testrc.rpmorig" | |
Static Private Member Functions | |
static void | removeV4 (const Pathname &dbdir_r, bool v3backup_r) |
Remove the rpm4 database in dbdir_r and optionally any backup created on conversion. | |
static void | removeV3 (const Pathname &dbdir_r, bool v3backup_r) |
Remove the rpm3 database in dbdir_r. | |
Private Attributes | |
DbStateInfoBits | _dbStateInfo |
Internal state info. | |
Pathname | _root |
Root directory for all operations. | |
Pathname | _dbPath |
Directory that contains the rpmdb. | |
ExternalProgram * | process |
The connection to the rpm process. | |
int | exit_code |
The exit code of the rpm process, or -1 if not yet known. | |
std::string | error_message |
Error message from running rpm as external program. | |
Pathname | _backuppath |
/var/adm/backup | |
bool | _packagebackups |
create package backups? | |
bool | _warndirexists |
whether <_root>/<WARNINGMAILPATH> was already created | |
Friends | |
std::ostream & | operator<< (std::ostream &str, const DbStateInfoBits &obj) |
typedef class InstTargetError zypp::target::rpm::RpmDb::Error |
typedef std::vector<const char*> zypp::target::rpm::RpmDb::RpmArgVec [private] |
typedef std::set<std::string> zypp::target::rpm::RpmDb::FileList |
enum zypp::target::rpm::RpmDb::DbStateInfoBits [private] |
checkPackage result
zypp::target::rpm::RpmDb::RpmDb | ( | ) |
Constructor.
There's no rpmdb access until initDatabase was called.
void zypp::target::rpm::RpmDb::dbsi_set | ( | DbStateInfoBits & | val_r, |
const unsigned & | bits_r | ||
) | const [inline, private] |
void zypp::target::rpm::RpmDb::dbsi_clr | ( | DbStateInfoBits & | val_r, |
const unsigned & | bits_r | ||
) | const [inline, private] |
bool zypp::target::rpm::RpmDb::dbsi_has | ( | const DbStateInfoBits & | val_r, |
const unsigned & | bits_r | ||
) | const [inline, private] |
void zypp::target::rpm::RpmDb::internal_initDatabase | ( | const Pathname & | root_r, |
const Pathname & | dbPath_r, | ||
DbStateInfoBits & | info_r | ||
) | [private] |
void zypp::target::rpm::RpmDb::removeV4 | ( | const Pathname & | dbdir_r, |
bool | v3backup_r | ||
) | [static, private] |
void zypp::target::rpm::RpmDb::removeV3 | ( | const Pathname & | dbdir_r, |
bool | v3backup_r | ||
) | [static, private] |
void zypp::target::rpm::RpmDb::modifyDatabase | ( | ) | [private] |
Date zypp::target::rpm::RpmDb::timestamp | ( | ) | const |
const Pathname& zypp::target::rpm::RpmDb::root | ( | ) | const [inline] |
const Pathname& zypp::target::rpm::RpmDb::dbPath | ( | ) | const [inline] |
bool zypp::target::rpm::RpmDb::initialized | ( | ) | const [inline] |
void zypp::target::rpm::RpmDb::initDatabase | ( | Pathname | root_r = Pathname() , |
Pathname | dbPath_r = Pathname() , |
||
bool | doRebuild_r = false |
||
) |
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.
If the database alredy exists and doRebuild_r
is true, rebuildDatabase is called.
RpmException |
void zypp::target::rpm::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).
RpmException |
void zypp::target::rpm::RpmDb::rebuildDatabase | ( | ) |
Rebuild the rpm database (rpm --rebuilddb).
RpmException |
void zypp::target::rpm::RpmDb::importPubkey | ( | const PublicKey & | pubkey_r | ) |
Import ascii armored public key in file pubkey_r.
RpmException |
void zypp::target::rpm::RpmDb::removePubkey | ( | const PublicKey & | pubkey_r | ) |
Remove a public key from the rpm database.
RpmException |
list< PublicKey > zypp::target::rpm::RpmDb::pubkeys | ( | ) | const |
set< Edition > zypp::target::rpm::RpmDb::pubkeyEditions | ( | ) | const |
list< FileInfo > zypp::target::rpm::RpmDb::fileList | ( | const std::string & | name_r, |
const Edition & | edition_r | ||
) | const |
return complete file list for installed package name_r (in FileInfo.filename) if edition_r != Edition::noedition, check for exact edition if full==true, fill all attributes of FileInfo
bool zypp::target::rpm::RpmDb::hasFile | ( | const std::string & | file_r, |
const std::string & | name_r = "" |
||
) | const |
std::string zypp::target::rpm::RpmDb::whoOwnsFile | ( | const std::string & | file_r | ) | const |
Return name of package owning file or empty string if no installed package owns file.
bool zypp::target::rpm::RpmDb::hasProvides | ( | const std::string & | tag_r | ) | const |
bool zypp::target::rpm::RpmDb::hasRequiredBy | ( | const std::string & | tag_r | ) | const |
bool zypp::target::rpm::RpmDb::hasConflicts | ( | const std::string & | tag_r | ) | const |
bool zypp::target::rpm::RpmDb::hasPackage | ( | const std::string & | name_r | ) | const |
Return true if package is installed.
bool zypp::target::rpm::RpmDb::hasPackage | ( | const std::string & | name_r, |
const Edition & | ed_r | ||
) | const |
Return true if package is installed in a certain edition.
void zypp::target::rpm::RpmDb::getData | ( | const std::string & | name_r, |
RpmHeader::constPtr & | 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).
RpmException | FIXME this and following comment |
void zypp::target::rpm::RpmDb::getData | ( | const std::string & | name_r, |
const Edition & | ed_r, | ||
RpmHeader::constPtr & | 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).
RpmException |
void zypp::target::rpm::RpmDb::importZyppKeyRingTrustedKeys | ( | ) |
void zypp::target::rpm::RpmDb::exportTrustedKeysInZyppKeyRing | ( | ) |
void zypp::target::rpm::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.
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 |
RpmException |
bool zypp::target::rpm::RpmDb::systemReadLine | ( | std::string & | line | ) | [private] |
int zypp::target::rpm::RpmDb::systemStatus | ( | ) | [private] |
void zypp::target::rpm::RpmDb::systemKill | ( | ) | [private] |
void zypp::target::rpm::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"
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 |
RpmDb::checkPackageResult zypp::target::rpm::RpmDb::checkPackage | ( | const Pathname & | path_r | ) |
void zypp::target::rpm::RpmDb::installPackage | ( | const Pathname & | filename, |
RpmInstFlags | flags = RPMINST_NONE |
||
) |
install rpm package
filename | file to install |
flags | which rpm options to use |
RpmException |
void zypp::target::rpm::RpmDb::removePackage | ( | const std::string & | name_r, |
RpmInstFlags | flags = RPMINST_NONE |
||
) |
remove rpm package
name_r | Name of the rpm package to remove. |
iflags | which rpm options to use |
RpmException |
void zypp::target::rpm::RpmDb::removePackage | ( | Package::constPtr | package, |
RpmInstFlags | flags = RPMINST_NONE |
||
) |
Pathname zypp::target::rpm::RpmDb::getBackupPath | ( | void | ) | [inline] |
bool zypp::target::rpm::RpmDb::backupPackage | ( | const std::string & | packageName | ) |
create tar.gz of all changed files in a Package
packageName | name of the Package to backup |
bool zypp::target::rpm::RpmDb::backupPackage | ( | const Pathname & | filename | ) |
void zypp::target::rpm::RpmDb::setBackupPath | ( | const Pathname & | path | ) |
set path where package backups are stored
void zypp::target::rpm::RpmDb::createPackageBackups | ( | bool | yes | ) | [inline] |
bool zypp::target::rpm::RpmDb::queryChangedFiles | ( | FileList & | fileList, |
const std::string & | packageName | ||
) |
virtual std::ostream& zypp::target::rpm::RpmDb::dumpOn | ( | std::ostream & | str | ) | const [virtual] |
Dump debug info.
Reimplemented from zypp::base::ReferenceCounted.
void zypp::target::rpm::RpmDb::doRemovePackage | ( | const std::string & | name_r, |
RpmInstFlags | flags, | ||
callback::SendReport< RpmRemoveReport > & | report | ||
) | [protected] |
void zypp::target::rpm::RpmDb::doInstallPackage | ( | const Pathname & | filename, |
RpmInstFlags | flags, | ||
callback::SendReport< RpmInstallReport > & | report | ||
) | [protected] |
void zypp::target::rpm::RpmDb::doRebuildDatabase | ( | callback::SendReport< RebuildDBReport > & | report | ) | [protected] |
std::ostream& operator<< | ( | std::ostream & | str, |
const DbStateInfoBits & | obj | ||
) | [friend] |
Pathname zypp::target::rpm::RpmDb::_root [private] |
Pathname zypp::target::rpm::RpmDb::_dbPath [private] |
ExternalProgram* zypp::target::rpm::RpmDb::process [private] |
int zypp::target::rpm::RpmDb::exit_code [private] |
std::string zypp::target::rpm::RpmDb::error_message [private] |
Pathname zypp::target::rpm::RpmDb::_backuppath [private] |
bool zypp::target::rpm::RpmDb::_packagebackups [private] |
bool zypp::target::rpm::RpmDb::_warndirexists [private] |