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" } ) {
 
   58            MIL << 
"Suggest existing database at " << 
dumpPath( root_r, p ) << endl;
 
   64      MIL << 
"Suggest rpm dbpath " << 
dumpPath( root_r, defaultDbPath ) << endl;
 
 
 
   94  D ( 
const D & ) = 
delete;            
 
  113    ::rpmtsSetRootDir( 
_ts, 
_root.c_str() );
 
  122    int res = ::rpmtsOpenDB( 
_ts, (readonly_r ? O_RDONLY : O_RDWR ) );
 
  124      ERR << 
"rpmdbOpen error(" << res << 
"): " << *
this << endl;
 
 
  131  { ::addMacro( NULL, 
"_dbpath", NULL, dppath_r.
asString().c_str(), RMIL_CMDLINE ); }
 
 
 
  141  static bool initialized = 
false;
 
  146  int rc = ::rpmReadConfigFiles( NULL, NULL );
 
  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();
 
 
  196{ 
return dbAccess( root_r, dbPath_r, 
false ); }
 
 
  199{ 
return dbAccess( root_r, dbPath_r, 
true ); }
 
 
  213  if ( not create_r && not 
dbExists ) {
 
 
  228: 
_d( * new 
D( root_r, dbPath_r, readonly_r ) )
 
 
  233  MIL << 
"Close database " << *
this << endl;
 
 
  244{ 
return _d._dbPath; }
 
 
  247{ 
return ReferenceCounted::dumpOn( 
str ) << 
_d; }
 
 
  256  D ( 
const D & ) = 
delete;            
 
  280      WAR << 
"No database access: " << 
dumpPath( root_r, dbPath_r ) << endl;
 
 
  288  bool create( 
int rpmtag, 
const void * keyp = NULL, 
size_t keylen = 0 )
 
 
  315    Header h = ::rpmdbNextIterator( 
_mi );
 
 
  328  bool init( 
int rpmtag, 
const void * keyp = NULL, 
size_t keylen = 0 )
 
  330    if ( ! 
create( rpmtag, keyp, keylen ) )
 
 
  341    if ( ! 
create( RPMDBI_PACKAGES ) )
 
  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 );
 
  361    return( ret ? ret : -1 ); 
 
 
 
  382: 
_d( * new 
D( 
"/" ) )
 
 
  386: 
_d( * new 
D( root_r ) )
 
 
  390: 
_d( * new 
D( root_r, dbPath_r ) )
 
 
  401{ 
return bool(
_d._dbptr); }
 
 
  407{ 
return _d.offset(); }
 
 
  413{ 
return str << 
"db_const_iterator(" << obj.
_d._dbptr << 
")"; }
 
 
  416{ 
return _d.init( RPMDBI_PACKAGES ); }
 
 
  419{ 
return _d.init( RPMTAG_BASENAMES, file_r.c_str() ); }
 
 
  422{ 
return _d.init( RPMTAG_PROVIDENAME, tag_r.c_str() ); }
 
 
  425{ 
return _d.init( RPMTAG_REQUIRENAME, tag_r.c_str() ); }
 
 
  428{ 
return _d.init( RPMTAG_CONFLICTNAME, tag_r.c_str() ); }
 
 
  431{ 
return _d.init( RPMTAG_NAME, name_r.c_str() ); }
 
 
  435  if ( ! 
_d.init( RPMTAG_NAME, name_r.c_str() ) )
 
  438  if ( 
_d.size() == 1 )
 
  446    if ( 
operator*()->tag_installtime() > itime )
 
  453  return _d.set( match );
 
 
  458  if ( ! 
_d.init( RPMTAG_NAME, name_r.c_str() ) )
 
  463    if ( ed_r == 
operator*()->tag_edition() )
 
  465      int match = 
_d.offset();
 
  466      return _d.set( match );
 
 
  478  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...
Edition represents [epoch:]version[-release]
TraitsType::constPtrType constPtr
Wrapper class for stat/lstat.
bool absolute() const
Test for an absolute path.
const std::string & asString() const
String representation.
bool empty() const
Test for an empty path.
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
Subclass to retrieve rpm 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.
std::ostream & operator<<(std::ostream &str, const librpmDb::db_const_iterator &obj) ZYPP_API
stream output
bool findAll()
Reset to iterate all packages.
bool hasDB() const
Whether an underlying rpmdb exists.
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.
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() ZYPP_DEPRECATED
Open the default rpmdb below the host system (at /).
intrusive_ptr< const librpmDb > constPtr
const Pathname & dbPath() const
const Pathname & root() const
static bool globalInit()
Initialize lib librpm (read configfiles etc.).
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.
static std::string expand(const std::string ¯o_r)
librpmDb(const Pathname &root_r, const Pathname &dbPath_r, bool readonly_r=true)
Private constructor!
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).
~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.
AutoDispose< void > OnScopeExit
#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.