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" } ) {
93 D (
const D & ) =
delete;
123 ERR <<
"rpmdbOpen error(" <<
res <<
"): " << *
this << endl;
140 static bool initialized =
false;
148 ERR <<
"rpmReadConfigFiles returned " <<
rc << endl;
154 MIL <<
"librpm init done: (_target:" <<
expand(
"%{_target}" ) <<
") (_dbpath:" << rpmDefaultDbPath <<
")" << endl;
165 return std::string( val );
167 return std::string();
172 if ( !
root_r.absolute() )
184 if ( !
root_r.absolute() )
202 if ( !
root_r.absolute() )
232 MIL <<
"Close database " << *
this << endl;
246{
return ReferenceCounted::dumpOn(
str ) <<
_d; }
252class librpmDb::db_const_iterator::D
255 D (
const D & ) =
delete;
314 Header
h = ::rpmdbNextIterator( _mi );
343 ::rpmdbAppendIterator( _mi, (
const unsigned *)&
off_r, 1 );
345 ::rpmdbAppendIterator( _mi, &
off_r, 1 );
352 return( _mi ? ::rpmdbGetIteratorOffset( _mi ) : 0 );
359 int ret = ::rpmdbGetIteratorCount( _mi );
380librpmDb::db_const_iterator::db_const_iterator()
381:
_d( *
new D(
"/" ) )
384librpmDb::db_const_iterator::db_const_iterator(
const Pathname &
root_r )
392librpmDb::db_const_iterator::db_const_iterator( std::nullptr_t )
396librpmDb::db_const_iterator::~db_const_iterator()
399bool librpmDb::db_const_iterator::hasDB()
const
402void librpmDb::db_const_iterator::operator++()
405unsigned librpmDb::db_const_iterator::dbHdrNum()
const
412{
return str <<
"db_const_iterator(" <<
obj._d._dbptr <<
")"; }
414bool librpmDb::db_const_iterator::findAll()
417bool librpmDb::db_const_iterator::findByFile(
const std::string &
file_r )
420bool librpmDb::db_const_iterator::findByProvides(
const std::string &
tag_r )
423bool librpmDb::db_const_iterator::findByRequiredBy(
const std::string & tag_r )
424{
return _d.
init( RPMTAG_REQUIRENAME, tag_r.c_str() ); }
426bool librpmDb::db_const_iterator::findByConflicts(
const std::string & tag_r )
427{
return _d.
init( RPMTAG_CONFLICTNAME, tag_r.c_str() ); }
429bool librpmDb::db_const_iterator::findByName(
const std::string & name_r )
430{
return _d.
init( RPMTAG_NAME, name_r.c_str() ); }
432bool librpmDb::db_const_iterator::findPackage(
const std::string & name_r )
434 if ( !
_d.
init( RPMTAG_NAME, name_r.c_str() ) )
445 if (
operator*()->tag_installtime() > itime )
452 return _d.
set( match );
455bool librpmDb::db_const_iterator::findPackage(
const std::string & name_r,
const Edition & ed_r )
457 if ( !
_d.
init( RPMTAG_NAME, name_r.c_str() ) )
462 if ( ed_r ==
operator*()->tag_edition() )
465 return _d.
set( match );
472bool librpmDb::db_const_iterator::findPackage(
const Package::constPtr & which_r )
477 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.