16#include <zypp/base/Logger.h>
17#include <zypp/PathInfo.h>
22#undef ZYPP_BASE_LOGGER_LOGGROUP
23#define ZYPP_BASE_LOGGER_LOGGROUP "librpmDb"
52 str <<
"{" <<
obj._error <<
"(" <<
obj._root <<
")" <<
obj._dbPath <<
"}";
65 _ts = ::rpmtsCreate();
72 ERR <<
"rpmdbOpen error(" <<
res <<
"): " << *
this << endl;
79 DBG <<
"DBACCESS " << *
this << endl;
113 static bool initialized =
false;
121 ERR <<
"rpmReadConfigFiles returned " <<
rc << endl;
151 std::string
ret( val );
192 if ( !
root_r.absolute() )
201 for (
auto p : {
"/var/lib/rpm",
"/usr/lib/sysimage/rpm" } ) {
291 DBG <<
"dbRelease: keep access, outstanding " <<
outstanding << endl;
316 MIL <<
"Block access" << endl;
329 MIL <<
"Unblock access" << endl;
476 ReferenceCounted::dumpOn(
str ) <<
_d;
514 WAR <<
"No database access: " <<
_dberr << endl;
527 ::rpmdbFreeIterator(
_mi );
552 _mi = ::rpmdbFreeIterator(
_mi );
558 WAR <<
"Lost database access: " <<
_dberr << endl;
572 Header
h = ::rpmdbNextIterator(
_mi );
601 ::rpmdbAppendIterator(
_mi, (
const unsigned *)&
off_r, 1 );
603 ::rpmdbAppendIterator(
_mi, &
off_r, 1 );
610 return(
_mi ? ::rpmdbGetIteratorOffset(
_mi ) : 0 );
617 int ret = ::rpmdbGetIteratorCount(
_mi );
695 return _d._dbptr->error();
708 str <<
"db_const_iterator(" <<
obj._d._dbptr
709 <<
" Size:" <<
obj._d.size()
710 <<
" HdrNum:" <<
obj._d.offset()
792 if (
_d.size() == 1 )
798 for ( ; operator*(); operator++() )
800 if (
operator*()->tag_installtime() >
itime )
803 itime = operator*()->tag_installtime();
807 return _d.set( match );
821 for ( ; operator*(); operator++() )
823 if (
ed_r ==
operator*()->tag_edition() )
825 int match =
_d.offset();
826 return _d.set( match );
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void reset()
Reset to default Ctor values.
Edition represents [epoch:]version[-release]
TraitsType::constPtrType constPtr
friend std::ostream & operator<<(std::ostream &str, const ReferenceCounted &obj)
Stream output via dumpOn.
Wrapper class for stat/lstat.
const char * c_str() const
String representation.
const std::string & asString() const
String representation.
Just inherits Exception to separate media exceptions.
librpmDb internal database handle
friend std::ostream & operator<<(std::ostream &str, const D &obj)
D(const Pathname &root_r, const Pathname &dbPath_r, bool readonly_r)
shared_ptr< RpmException > _error
bool create(int rpmtag, const void *keyp=NULL, size_t keylen=0)
Let iterator access a dbindex file.
RpmHeader::constPtr _hptr
bool destroy()
Destroy iterator.
librpmDb::constPtr _dbptr
shared_ptr< RpmException > _dberr
bool set(int off_r)
Create an itertator that contains the database entry located at off_r, and advance to the 1st header.
bool init(int rpmtag, const void *keyp=NULL, size_t keylen=0)
Access a dbindex file and advance to the 1st header.
bool advance()
Advance to the first/next header in iterator.
D(librpmDb::constPtr dbptr_r)
Subclass to retrieve database content.
unsigned dbHdrNum() const
Returns the current headers index in database, 0 if no header.
bool findByProvides(const std::string &tag_r)
Reset to iterate all packages that provide a certain tag.
bool findByName(const std::string &name_r)
Reset to iterate all packages with a certain name.
~db_const_iterator()
Destructor.
bool findByFile(const std::string &file_r)
Reset to iterate all packages that own a certain file.
bool findAll()
Reset to iterate all packages.
const RpmHeader::constPtr & operator*() const
Returns the current RpmHeader::constPtr or NULL, if no more entries available.
bool findByRequiredBy(const std::string &tag_r)
Reset to iterate all packages that require a certain tag.
bool findPackage(const std::string &name_r)
Find package by name.
shared_ptr< RpmException > dbError() const
Return any database error.
void operator++()
Advance to next RpmHeader::constPtr.
bool findByConflicts(const std::string &tag_r)
Reset to iterate all packages that conflict with a certain tag.
db_const_iterator(const db_const_iterator &)
Manage access to librpm database.
static bool _dbBlocked
Whether access is blocked (no _defaultDb will be available).
virtual void unref_to(unsigned refCount_r) const
Trigger from Rep, after refCount was decreased.
const Pathname & dbPath() const
const Pathname & root() const
static bool globalInit()
Initialize lib librpm (read configfiles etc.).
virtual std::ostream & dumpOn(std::ostream &str) const
Dump debug info.
intrusive_ptr< const librpmDb > constPtr
static std::string stringPath(const Pathname &root_r, const Pathname &sub_r)
static unsigned dbRelease(bool force_r=false)
If there are no outstanding references to the database (e.g.
static std::ostream & dumpState(std::ostream &str)
Dump debug info.
static librpmDb::constPtr _defaultDb
Current rpmdb handle.
shared_ptr< RpmException > error() const
Return any database error.
static Pathname _rpmDefaultDbPath
_dbpath configured in rpm config.
static Pathname _defaultDbPath
Current directory (below root) that contains the rpmdb.
static librpmDb * newLibrpmDb()
For internal use.
virtual ~librpmDb()
Destructor.
void * dont_call_it() const
Dont call it ;) It's for development and testing only.
static Pathname _defaultRoot
Current root directory for all operations.
static std::string expand(const std::string ¯o_r)
librpmDb(const Pathname &root_r, const Pathname &dbPath_r, bool readonly_r)
Private constructor! librpmDb objects are to be created via static interface only.
static void dbAccess()
Access the database at the current default location.
static unsigned blockAccess()
Blocks further access to rpmdb.
static Pathname suggestedDbPath(const Pathname &root_r)
static void unblockAccess()
Allow access to rpmdb e.g.
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.