24#undef ZYPP_BASE_LOGGER_LOGGROUP
25#define ZYPP_BASE_LOGGER_LOGGROUP "librpmDb"
44 ret =
"/usr/lib/sysimage/rpm";
45 WAR <<
"Looks like rpm has no %{_dbpath} set!?! Assuming " <<
ret << endl;
56 for (
auto p : {
"/var/lib/rpm",
"/usr/lib/sysimage/rpm" } ) {
94 D (
const D & ) =
delete;
124 ERR <<
"rpmdbOpen error(" <<
res <<
"): " << *
this << endl;
141 static bool initialized =
false;
149 ERR <<
"rpmReadConfigFiles returned " <<
rc << endl;
155 MIL <<
"librpm init done: (_target:" <<
expand(
"%{_target}" ) <<
") (_dbpath:" << rpmDefaultDbPath <<
")" << endl;
166 return std::string( val );
168 return std::string();
173 if ( !
root_r.absolute() )
185 if ( !
root_r.absolute() )
203 if ( !
root_r.absolute() )
233 MIL <<
"Close database " << *
this << endl;
247{
return ReferenceCounted::dumpOn(
str ) <<
_d; }
253class librpmDb::db_const_iterator::D
256 D (
const D & ) =
delete;
315 Header
h = ::rpmdbNextIterator( _mi );
344 ::rpmdbAppendIterator( _mi, (
const unsigned *)&
off_r, 1 );
346 ::rpmdbAppendIterator( _mi, &
off_r, 1 );
353 return( _mi ? ::rpmdbGetIteratorOffset( _mi ) : 0 );
360 int ret = ::rpmdbGetIteratorCount( _mi );
381librpmDb::db_const_iterator::db_const_iterator()
382:
_d( *
new D(
"/" ) )
385librpmDb::db_const_iterator::db_const_iterator(
const Pathname &
root_r )
393librpmDb::db_const_iterator::db_const_iterator( std::nullptr_t )
397librpmDb::db_const_iterator::~db_const_iterator()
400bool librpmDb::db_const_iterator::hasDB()
const
403void librpmDb::db_const_iterator::operator++()
406unsigned librpmDb::db_const_iterator::dbHdrNum()
const
413{
return str <<
"db_const_iterator(" <<
obj._d._dbptr <<
")"; }
415bool librpmDb::db_const_iterator::findAll()
418bool librpmDb::db_const_iterator::findByFile(
const std::string &
file_r )
421bool librpmDb::db_const_iterator::findByProvides(
const std::string &
tag_r )
424bool librpmDb::db_const_iterator::findByRequiredBy(
const std::string & tag_r )
425{
return _d.
init( RPMTAG_REQUIRENAME, tag_r.c_str() ); }
427bool librpmDb::db_const_iterator::findByConflicts(
const std::string & tag_r )
428{
return _d.
init( RPMTAG_CONFLICTNAME, tag_r.c_str() ); }
430bool librpmDb::db_const_iterator::findByName(
const std::string & name_r )
431{
return _d.
init( RPMTAG_NAME, name_r.c_str() ); }
433bool librpmDb::db_const_iterator::findPackage(
const std::string & name_r )
435 if ( !
_d.
init( RPMTAG_NAME, name_r.c_str() ) )
446 if (
operator*()->tag_installtime() > itime )
453 return _d.
set( match );
456bool librpmDb::db_const_iterator::findPackage(
const std::string & name_r,
const Edition & ed_r )
458 if ( !
_d.
init( RPMTAG_NAME, name_r.c_str() ) )
463 if ( ed_r ==
operator*()->tag_edition() )
466 return _d.
set( match );
473bool librpmDb::db_const_iterator::findPackage(
const Package::constPtr & which_r )
478 return findPackage( which_r->name(), which_r->edition() );
Subclass to retrieve rpm database content.
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
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.
Just inherits Exception to separate media exceptions.
librpmDb internal database handle
friend std::ostream & operator<<(std::ostream &str, const D &obj)
static void macroResetDbpath()
D(Pathname root_r, Pathname dbPath_r, bool readonly_r)
D & operator=(const D &)=delete
static void macroSetDbpath(const Pathname &dppath_r)
D & operator=(D &&)=delete
bool create(int rpmtag, const void *keyp=NULL, size_t keylen=0)
Let iterator access a dbindex file.
RpmHeader::constPtr _hptr
bool destroy()
Reset iterator.
librpmDb::constPtr _dbptr
D(const Pathname &root_r, const Pathname &dbPath_r=Pathname())
Open a specific rpmdb if it exists.
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.
AutoDispose< rpmdbMatchIterator > _mi
bool advance()
Advance to the first/next header in iterator.
D & operator=(D &&)=delete
intrusive_ptr< const librpmDb > constPtr
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.
void operator++()
Advance to next RpmHeader::constPtr.
std::ostream & dumpOn(std::ostream &str) const override
Dump debug info.
static librpmDb::constPtr dbOpenCreate(const Pathname &root_r, const Pathname &dbPath_r=Pathname())
Assert the rpmdb below the system at root_r exists.
friend std::ostream & operator<<(std::ostream &str, const db_const_iterator &obj)
static std::string expand(const std::string ¯o_r)
static void dbAccess(librpmDb::Ptr &ptr_r)
INTENTIONALLY UNDEFINED<\B> because of bug in Ptr classes which allows implicit conversion from librp...
static librpmDb::constPtr dbOpenIf(const Pathname &root_r, const Pathname &dbPath_r=Pathname())
Open the rpmdb below the system at root_r (if it exists).
bool findPackage(const std::string &name_r)
Find package by name.
~librpmDb() override
Destructor.
static Pathname suggestedDbPath(const Pathname &root_r)
static bool dbExists(const Pathname &root_r, const Pathname &dbPath_r=Pathname())
void unref_to(unsigned refCount_r) const override
Trigger from Rep, after refCount was decreased.
String related utilities and Regular expression matching.
const Pathname & rpmDefaultDbPath()
Pathname suggestedDbPath(const Pathname &root_r)
Pathname sanitizedDbPath(const Pathname &root_r, const Pathname &dbPath_r)
bool dbExists(const Pathname &root_r, const Pathname &dbPath_r)
_dumpPath dumpPath(const Pathname &root_r, const Pathname &sub_r)
dumpPath iomaip to dump '(root_r)sub_r' output,
Easy-to use interface to the ZYPP dependency resolver.
#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.