23#undef ZYPP_BASE_LOGGER_LOGGROUP
24#define ZYPP_BASE_LOGGER_LOGGROUP "librpmDb"
42 D (
const D & ) =
delete;
55 str <<
"{" <<
obj._error <<
"(" <<
obj._root <<
")" <<
obj._dbPath <<
"}";
65 _ts = ::rpmtsCreate();
72 ERR <<
"rpmdbOpen error(" <<
res <<
"): " << *
this << endl;
79 DBG <<
"DBACCESS " << *
this << endl;
103bool librpmDb::_dbBlocked =
true;
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;
486class librpmDb::db_const_iterator::D
489 D (
const D & ) =
delete;
505 librpmDb::dbAccess( _dbptr );
513 WAR <<
"No database access: " << _dberr << endl;
526 ::rpmdbFreeIterator( _mi );
551 _mi = ::rpmdbFreeIterator( _mi );
554 if ( _dbptr && _dbptr->error() )
556 _dberr = _dbptr->error();
557 WAR <<
"Lost database access: " << _dberr << endl;
571 Header
h = ::rpmdbNextIterator( _mi );
600 ::rpmdbAppendIterator( _mi, (
const unsigned *)&
off_r, 1 );
602 ::rpmdbAppendIterator( _mi, &
off_r, 1 );
609 return( _mi ? ::rpmdbGetIteratorOffset( _mi ) : 0 );
616 int ret = ::rpmdbGetIteratorCount( _mi );
647librpmDb::db_const_iterator::~db_const_iterator()
658void librpmDb::db_const_iterator::operator++()
669unsigned librpmDb::db_const_iterator::dbHdrNum()
const
707 str <<
"db_const_iterator(" <<
obj._d._dbptr
708 <<
" Size:" <<
obj._d.size()
709 <<
" HdrNum:" <<
obj._d.offset()
720bool librpmDb::db_const_iterator::findAll()
731bool librpmDb::db_const_iterator::findByFile(
const std::string &
file_r )
742bool librpmDb::db_const_iterator::findByProvides(
const std::string & tag_r )
744 return _d.
init( RPMTAG_PROVIDENAME, tag_r.c_str() );
753bool librpmDb::db_const_iterator::findByRequiredBy(
const std::string & tag_r )
755 return _d.
init( RPMTAG_REQUIRENAME, tag_r.c_str() );
764bool librpmDb::db_const_iterator::findByConflicts(
const std::string & tag_r )
766 return _d.
init( RPMTAG_CONFLICTNAME, tag_r.c_str() );
775bool librpmDb::db_const_iterator::findByName(
const std::string & name_r )
777 return _d.
init( RPMTAG_NAME, name_r.c_str() );
786bool librpmDb::db_const_iterator::findPackage(
const std::string & name_r )
788 if ( !
_d.
init( RPMTAG_NAME, name_r.c_str() ) )
799 if (
operator*()->tag_installtime() > itime )
806 return _d.
set( match );
815bool librpmDb::db_const_iterator::findPackage(
const std::string & name_r,
const Edition & ed_r )
817 if ( !
_d.
init( RPMTAG_NAME, name_r.c_str() ) )
822 if ( ed_r ==
operator*()->tag_edition() )
825 return _d.
set( match );
838bool librpmDb::db_const_iterator::findPackage(
const Package::constPtr & which_r )
843 return findPackage( which_r->name(), which_r->edition() );
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void reset()
Reset to default Ctor values.
TraitsType::constPtrType constPtr
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(Pathname root_r, Pathname dbPath_r, bool readonly_r)
D & operator=(const D &)=delete
D & operator=(D &&)=delete
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
D & operator=(const D &)=delete
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 & operator=(D &&)=delete
D(librpmDb::constPtr dbptr_r)
Manage access to librpm database.
intrusive_ptr< const librpmDb > constPtr
static unsigned dbRelease(bool force_r=false) ZYPP_API
If there are no outstanding references to the database (e.g.
const Pathname & dbPath() const
const Pathname & root() const
static bool globalInit()
Initialize lib librpm (read configfiles etc.).
const RpmHeader::constPtr & operator*() const
Returns the current RpmHeader::constPtr or NULL, if no more entries available.
static std::string stringPath(const Pathname &root_r, const Pathname &sub_r)
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 unsigned blockAccess() ZYPP_API
Blocks further access to rpmdb.
void operator++()
Advance to next RpmHeader::constPtr.
static void unblockAccess() ZYPP_API
Allow access to rpmdb e.g.
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.
std::ostream & dumpOn(std::ostream &str) const override
Dump debug info.
void * dont_call_it() const
Dont call it ;) It's for development and testing only.
static Pathname _defaultRoot
Current root directory for all operations.
friend std::ostream & operator<<(std::ostream &str, const db_const_iterator &obj)
static std::string expand(const std::string ¯o_r)
bool findPackage(const std::string &name_r)
Find package by name.
~librpmDb() override
Destructor.
static void dbAccess()
Access the database at the current default location.
static Pathname suggestedDbPath(const Pathname &root_r)
void unref_to(unsigned refCount_r) const override
Trigger from Rep, after refCount was decreased.
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.