libzypp 17.34.0
|
Manage access to librpm database. More...
#include <zypp/target/rpm/librpmDb.h>
Classes | |
class | D |
librpmDb internal database handle More... | |
Public Types | |
using | Ptr = intrusive_ptr<librpmDb> |
using | constPtr = intrusive_ptr<const librpmDb> |
Public Member Functions | |
~librpmDb () override | |
Destructor. | |
const Pathname & | root () const |
const Pathname & | dbPath () const |
shared_ptr< RpmException > | error () const |
Return any database error. | |
bool | valid () const |
bool | empty () const |
unsigned | size () const |
void * | dont_call_it () const |
Dont call it ;) It's for development and testing only. | |
std::ostream & | dumpOn (std::ostream &str) const override |
Dump debug info. | |
db_const_iterator (librpmDb::constPtr dbptr_r=0) | |
Constructor. | |
~db_const_iterator () | |
Destructor. | |
shared_ptr< RpmException > | dbError () const |
Return any database error. | |
void | operator++ () |
Advance to next RpmHeader::constPtr. | |
unsigned | dbHdrNum () const |
Returns the current headers index in database, 0 if no header. | |
const RpmHeader::constPtr & | operator* () const |
Returns the current RpmHeader::constPtr or NULL, if no more entries available. | |
const RpmHeader::constPtr & | operator-> () const |
Forwards to the current RpmHeader::constPtr. | |
bool | findAll () |
Reset to iterate all packages. | |
bool | findByFile (const std::string &file_r) |
Reset to iterate all packages that own a certain file. | |
bool | findByProvides (const std::string &tag_r) |
Reset to iterate all packages that provide a certain tag. | |
bool | findByRequiredBy (const std::string &tag_r) |
Reset to iterate all packages that require a certain tag. | |
bool | findByConflicts (const std::string &tag_r) |
Reset to iterate all packages that conflict with a certain tag. | |
bool | findByName (const std::string &name_r) |
Reset to iterate all packages with a certain name. | |
bool | findPackage (const std::string &name_r) |
Find package by name. | |
bool | findPackage (const std::string &name_r, const Edition &ed_r) |
Find package by name and edition. | |
bool | findPackage (const Package::constPtr &which_r) |
Abbr. | |
![]() | |
ReferenceCounted () | |
Default ctor. | |
ReferenceCounted (const ReferenceCounted &rhs) | |
Copy ctor. | |
virtual | ~ReferenceCounted () |
Dtor. | |
ReferenceCounted & | operator= (const ReferenceCounted &) |
Assignment. | |
unsigned | refCount () const |
Return reference counter value. | |
void | ref () const |
Add a reference. | |
void | unref () const |
Release a reference. | |
Static Public Member Functions | |
static bool | globalInit () |
Initialize lib librpm (read configfiles etc.). | |
static std::string | expand (const std::string ¯o_r) |
static std::string | stringPath (const Pathname &root_r, const Pathname &sub_r) |
static const Pathname & | defaultRoot () |
static const Pathname & | defaultDbPath () |
static Pathname | suggestedDbPath (const Pathname &root_r) |
static void | dbAccess (const Pathname &root_r) |
Adjust access to the given database location, making it the new default location on success. | |
static void | dbAccess (librpmDb::constPtr &ptr_r) |
Same as &ref dbAccess(), but returns the database handle if avaialble, otherwise NULL. | |
static unsigned | dbRelease (bool force_r=false) ZYPP_API |
If there are no outstanding references to the database (e.g. | |
static unsigned | blockAccess () ZYPP_API |
Blocks further access to rpmdb. | |
static unsigned | blockAccess (const Pathname &root_r, const Pathname &dbPath_r) |
static void | unblockAccess () ZYPP_API |
Allow access to rpmdb e.g. | |
static bool | isBlocked () ZYPP_API |
static std::ostream & | dumpState (std::ostream &str) |
Dump debug info. | |
![]() | |
static void | add_ref (const ReferenceCounted *ptr_r) |
Called by zypp::intrusive_ptr to add a reference. | |
static void | release (const ReferenceCounted *ptr_r) |
Called by zypp::intrusive_ptr to add a reference. | |
Protected Member Functions | |
librpmDb (const Pathname &root_r, const Pathname &dbPath_r, bool readonly_r) | |
Private constructor! librpmDb objects are to be created via static interface only. | |
void | unref_to (unsigned refCount_r) const override |
Trigger from Rep, after refCount was decreased. | |
![]() | |
virtual void | ref_to (unsigned) const |
Trigger derived classes after refCount was increased. | |
Private Member Functions | |
db_const_iterator & | operator= (const db_const_iterator &) |
db_const_iterator (const db_const_iterator &) | |
Static Private Member Functions | |
static void | dbAccess (librpmDb::Ptr &ptr_r) |
INTENTIONALLY UNDEFINED<\B> because of bug in Ptr classes which allows implicit conversion from librpmDb::Ptr to librpmDb::constPtr. | |
static librpmDb * | newLibrpmDb () |
For internal use. | |
static void | dbAccess () |
Access the database at the current default location. | |
Private Attributes | |
D & | _d |
Static Private Attributes | |
static Pathname | _defaultRoot { "/" } |
Current root directory for all operations. | |
static Pathname | _defaultDbPath |
Current directory (below root) that contains the rpmdb. | |
static Pathname | _rpmDefaultDbPath |
_dbpath configured in rpm config. | |
static librpmDb::constPtr | _defaultDb |
Current rpmdb handle. | |
static bool _dbBlocked | ZYPP_API |
Whether access is blocked (no _defaultDb will be available). | |
Friends | |
class | librpmDb |
std::ostream & | operator<< (std::ostream &str, const db_const_iterator &obj) |
Additional Inherited Members | |
![]() | |
void | intrusive_ptr_add_ref (const ReferenceCounted *ptr_r) |
intrusive_ptr hook to add_ref. | |
void | intrusive_ptr_release (const ReferenceCounted *ptr_r) |
intrusive_ptr hook to release. | |
std::ostream & | operator<< (std::ostream &str, const ReferenceCounted &obj) |
Stream output. | |
Manage access to librpm database.
Subclass to retrieve database content.
Definition at line 37 of file librpmDb.h.
Definition at line 40 of file librpmDb.h.
Definition at line 41 of file librpmDb.h.
|
protected |
Private constructor! librpmDb objects are to be created via static interface only.
Definition at line 362 of file librpmDb.cc.
|
override |
zypp::target::rpm::librpmDb::~db_const_iterator | ( | ) |
Destructor.
|
staticprivate |
INTENTIONALLY UNDEFINED<\B> because of bug in Ptr classes which allows implicit conversion from librpmDb::Ptr to librpmDb::constPtr.
Currently we don't want to provide non const handles, as the database is opened READONLY.
RpmException |
|
staticprivate |
For internal use.
Pointer returned should immediately be wrapped into librpmDb::Ptr.
RpmException |
Definition at line 162 of file librpmDb.cc.
|
staticprivate |
Access the database at the current default location.
If necessary (eg. after dbRelease), the database is opened. This just creates the internal handle. Once the handle is passed to e.g. some db_const_iterator, the database will be closed if the last outstanding reference goes out of scope. If no external reference is created, you'll have to explicitly call dbRelease to close the database.
RpmException |
Definition at line 244 of file librpmDb.cc.
|
static |
Initialize lib librpm (read configfiles etc.).
It's called on demand but you may call it anytime.
Definition at line 111 of file librpmDb.cc.
|
static |
Definition at line 142 of file librpmDb.cc.
|
inlinestatic |
Definition at line 130 of file librpmDb.h.
Definition at line 140 of file librpmDb.h.
Definition at line 148 of file librpmDb.h.
RpmInvalidRootException | if root is not an absolute path or no directory for the rpmdb can determined. |
no symlink
Definition at line 190 of file librpmDb.cc.
Adjust access to the given database location, making it the new default location on success.
No relative Pathnames are allowed.
It's not possible to access a database while access is blocked (see blockAccess), but valid Pathnames provided will be stored as new default location.
It's not allowed to switch to another location while a database is accessed. Use dbRelease to force releasing the database first.
RpmException |
Definition at line 219 of file librpmDb.cc.
|
static |
Same as &ref dbAccess(), but returns the database handle if avaialble, otherwise NULL.
This creates an external reference, thus it should not be used longer than necessary. Be prepared that the handle might become invalid (see dbRelease) later.
RpmException |
Definition at line 264 of file librpmDb.cc.
If there are no outstanding references to the database (e.g.
by db_const_iterator), the database is closed. Subsequent calls to dbAccess may however open the database again.
If forced, the internal reference is dropped and it will look like the database was closed. But physically the database will be closed after all outstanding references are gone.
Definition at line 277 of file librpmDb.cc.
|
static |
Blocks further access to rpmdb.
Basically the same as dbRelease( true ), but subsequent calls to dbAccess will fail returning E_RpmDB_access_blocked.
Definition at line 314 of file librpmDb.cc.
|
inlinestatic |
Definition at line 216 of file librpmDb.h.
|
static |
Allow access to rpmdb e.g.
after blockAccess. Subsequent calls to dbAccess will perform.
NOTE: Initially we're in blocked mode. So you must call unblockAccess unblockAccess at least once. Othwise nothing will happen.
Definition at line 327 of file librpmDb.cc.
Definition at line 236 of file librpmDb.h.
|
static |
Dump debug info.
Definition at line 339 of file librpmDb.cc.
|
overrideprotectedvirtual |
Trigger from Rep, after refCount was decreased.
Reimplemented from zypp::base::ReferenceCounted.
Definition at line 385 of file librpmDb.cc.
const Pathname & zypp::target::rpm::librpmDb::root | ( | ) | const |
Definition at line 399 of file librpmDb.cc.
const Pathname & zypp::target::rpm::librpmDb::dbPath | ( | ) | const |
Definition at line 410 of file librpmDb.cc.
shared_ptr< RpmException > zypp::target::rpm::librpmDb::error | ( | ) | const |
Return any database error.
Usg. if the database was blocked by calling dbRelease(true) or blockAccess.
Definition at line 421 of file librpmDb.cc.
|
inline |
Definition at line 305 of file librpmDb.h.
bool zypp::target::rpm::librpmDb::empty | ( | ) | const |
Definition at line 432 of file librpmDb.cc.
unsigned zypp::target::rpm::librpmDb::size | ( | ) | const |
Definition at line 443 of file librpmDb.cc.
void * zypp::target::rpm::librpmDb::dont_call_it | ( | ) | const |
Dont call it ;) It's for development and testing only.
Definition at line 461 of file librpmDb.cc.
|
overridevirtual |
Dump debug info.
Reimplemented from zypp::base::ReferenceCounted.
Definition at line 474 of file librpmDb.cc.
|
private |
|
private |
zypp::target::rpm::librpmDb::db_const_iterator | ( | librpmDb::constPtr | dbptr_r = 0 | ) |
shared_ptr< RpmException > zypp::target::rpm::librpmDb::dbError | ( | ) | const |
Return any database error.
NOTE: If the database gets blocked (see dbRelease) dbError will immediately report this, but an already running iteration will proceed to its end. Then the database is dropped.
void zypp::target::rpm::librpmDb::operator++ | ( | ) |
Advance to next RpmHeader::constPtr.
unsigned zypp::target::rpm::librpmDb::dbHdrNum | ( | ) | const |
Returns the current headers index in database, 0 if no header.
const RpmHeader::constPtr & zypp::target::rpm::librpmDb::operator* | ( | ) | const |
Returns the current RpmHeader::constPtr or NULL, if no more entries available.
|
inline |
Forwards to the current RpmHeader::constPtr.
Definition at line 402 of file librpmDb.h.
bool zypp::target::rpm::librpmDb::findAll | ( | ) |
bool zypp::target::rpm::librpmDb::findByFile | ( | const std::string & | file_r | ) |
Reset to iterate all packages that own a certain file.
bool zypp::target::rpm::librpmDb::findByProvides | ( | const std::string & | tag_r | ) |
Reset to iterate all packages that provide a certain tag.
bool zypp::target::rpm::librpmDb::findByRequiredBy | ( | const std::string & | tag_r | ) |
Reset to iterate all packages that require a certain tag.
bool zypp::target::rpm::librpmDb::findByConflicts | ( | const std::string & | tag_r | ) |
Reset to iterate all packages that conflict with a certain tag.
bool zypp::target::rpm::librpmDb::findByName | ( | const std::string & | name_r | ) |
Reset to iterate all packages with a certain name.
NOTE: Multiple entries for one package installed in different versions are possible but not desired. Usually you'll want to use findPackage instead.
findByName is needed to retrieve pseudo packages like 'gpg-pubkey', which in fact exist in multiple instances.
bool zypp::target::rpm::librpmDb::findPackage | ( | const std::string & | name_r | ) |
Find package by name.
Multiple entries for one package installed in different versions are possible but not desired. If so, the last package installed is returned.
Find package by name and edition.
Commonly used by PMRpmPackageDataProvider.
bool zypp::target::rpm::librpmDb::findPackage | ( | const Package::constPtr & | which_r | ) |
Abbr.
for findPackage( which_r->name(), which_r->edition() );
Definition at line 348 of file librpmDb.h.
|
friend |
|
staticprivate |
|
staticprivate |
Current directory (below root) that contains the rpmdb.
Definition at line 72 of file librpmDb.h.
|
staticprivate |
_dbpath configured in rpm config.
Definition at line 77 of file librpmDb.h.
|
staticprivate |
Current rpmdb handle.
Definition at line 82 of file librpmDb.h.
|
staticprivate |
Whether access is blocked (no _defaultDb will be available).
Definition at line 87 of file librpmDb.h.
|
private |
Definition at line 264 of file librpmDb.h.