libzypp  17.25.2
librpmDb.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include "librpm.h"
13 
14 #include <iostream>
15 
16 #include <zypp/base/Logger.h>
17 #include <zypp/PathInfo.h>
21 
22 #undef ZYPP_BASE_LOGGER_LOGGROUP
23 #define ZYPP_BASE_LOGGER_LOGGROUP "librpmDb"
24 
25 using std::endl;
26 
27 namespace zypp
28 {
29 namespace target
30 {
31 namespace rpm
32 {
34 //
35 // CLASS NAME : librpmDb::D
40 {
41  D & operator=( const D & ); // NO ASSIGNMENT!
42  D ( const D & ); // NO COPY!
43 public:
44 
45  const Pathname _root; // root directory for all operations
46  const Pathname _dbPath; // directory (below root) that contains the rpmdb
47  rpmts _ts; // transaction handle, includes database
48  shared_ptr<RpmException> _error; // database error
49 
50  friend std::ostream & operator<<( std::ostream & str, const D & obj )
51  {
52  str << "{" << obj._error << "(" << obj._root << ")" << obj._dbPath << "}";
53  return str;
54  }
55 
56  D( const Pathname & root_r, const Pathname & dbPath_r, bool readonly_r )
57  : _root ( root_r )
58  , _dbPath( dbPath_r )
59  , _ts ( 0 )
60  {
61  _error.reset();
62  // set %_dbpath macro
63  ::addMacro( NULL, "_dbpath", NULL, _dbPath.asString().c_str(), RMIL_CMDLINE );
64 
65  _ts = ::rpmtsCreate();
66  ::rpmtsSetRootDir( _ts, _root.c_str() );
67 
68  // open database (creates a missing one on the fly)
69  int res = ::rpmtsOpenDB( _ts, (readonly_r ? O_RDONLY : O_RDWR ));
70  if ( res )
71  {
72  ERR << "rpmdbOpen error(" << res << "): " << *this << endl;
73  _error = shared_ptr<RpmDbOpenException>(new RpmDbOpenException(_root, _dbPath));
74  rpmtsFree(_ts);
76  return;
77  }
78 
79  DBG << "DBACCESS " << *this << endl;
80  }
81 
82  ~D()
83  {
84  if ( _ts )
85  {
86  ::rpmtsFree(_ts);
87  }
88  }
89 };
90 
92 
94 //
95 // CLASS NAME : librpmDb (ststic interface)
96 //
98 
100 // NOTE: Former variable, but now locked to "/var/lib/rpm".
101 // A custom dbPath is not actually needed and would only work
102 // reliably if libsolv also supports it.
103 // The protected librpmDb ctor would allow to build a db_const_iterator
104 // to access (ro) a database at a custom location.
105 const Pathname librpmDb::_defaultDbPath( "/var/lib/rpm" );
107 bool librpmDb::_dbBlocked ( true );
108 
110 //
111 //
112 // METHOD NAME : librpmDb::globalInit
113 // METHOD TYPE : bool
114 //
116 {
117  static bool initialized = false;
118 
119  if ( initialized )
120  return true;
121 
122  int rc = ::rpmReadConfigFiles( NULL, NULL );
123  if ( rc )
124  {
125  ERR << "rpmReadConfigFiles returned " << rc << endl;
126  return false;
127  }
128 
129  initialized = true; // Necessary to be able to use exand().
130 
131 #define OUTVAL(n) << " (" #n ":" << expand( "%{" #n "}" ) << ")"
132  MIL << "librpm init done:"
133  OUTVAL(_target)
134  OUTVAL(_dbpath)
135  << endl;
136 #undef OUTVAL
137  return initialized;
138 }
139 
141 //
142 //
143 // METHOD NAME : librpmDb::expand
144 // METHOD TYPE : std::string
145 //
146 std::string librpmDb::expand( const std::string & macro_r )
147 {
148  if ( ! globalInit() )
149  return macro_r; // unexpanded
150 
151  char * val = ::rpmExpand( macro_r.c_str(), NULL );
152  if ( !val )
153  return "";
154 
155  std::string ret( val );
156  free( val );
157  return ret;
158 }
159 
161 //
162 //
163 // METHOD NAME : librpmDb::newLibrpmDb
164 // METHOD TYPE : librpmDb *
165 //
167 {
168  // initialize librpm
169  if ( ! globalInit() )
170  {
172  }
173 
174  // open rpmdb
175  librpmDb * ret = 0;
176  try
177  {
178  ret = new librpmDb( _defaultRoot, _defaultDbPath, /*readonly*/true );
179  }
180  catch (const RpmException & excpt_r)
181  {
182  ZYPP_CAUGHT(excpt_r);
183  delete ret;
184  ret = 0;
185  ZYPP_RETHROW(excpt_r);
186  }
187  return ret;
188 }
189 
191 //
192 //
193 // METHOD NAME : librpmDb::dbAccess
194 // METHOD TYPE : PMError
195 //
196 void librpmDb::dbAccess( const Pathname & root_r )
197 {
198  if ( _defaultDb )
199  {
200  // already accessing a database: switching is not allowed.
201  if ( _defaultRoot == root_r )
202  return;
203  else
205  }
206 
207  // got no database: we could switch to a new one (even if blocked!)
208 
209  if ( root_r.empty() || ! root_r.absolute() )
211 
212  PathInfo pi { root_r / _defaultDbPath };
213  if ( pi.isExist() && ! pi.isDir() ) {
214  RpmInvalidRootException excpt { root_r, _defaultDbPath };
215  excpt.addHistory( str::Str() << pi );
216  ZYPP_THROW(excpt);
217  }
218 
219  _defaultRoot = root_r;
220  MIL << "Set new database location: " << stringPath( _defaultRoot, _defaultDbPath ) << endl;
221 
222  return dbAccess();
223 }
224 
226 //
227 //
228 // METHOD NAME : librpmDb::dbAccess
229 // METHOD TYPE : PMError
230 //
232 {
233  if ( _dbBlocked )
234  {
236  }
237 
238  if ( !_defaultDb )
239  {
240  // get access
242  }
243 }
244 
246 //
247 //
248 // METHOD NAME : librpmDb::dbAccess
249 // METHOD TYPE : PMError
250 //
252 {
253  ptr_r = nullptr;
254  dbAccess();
255  ptr_r = _defaultDb;
256 }
257 
259 //
260 //
261 // METHOD NAME : librpmDb::dbRelease
262 // METHOD TYPE : unsigned
263 //
264 unsigned librpmDb::dbRelease( bool force_r )
265 {
266  if ( !_defaultDb )
267  {
268  return 0;
269  }
270 
271  unsigned outstanding = _defaultDb->refCount() - 1; // refCount can't be 0
272 
273  switch ( outstanding )
274  {
275  default:
276  if ( !force_r )
277  {
278  DBG << "dbRelease: keep access, outstanding " << outstanding << endl;
279  break;
280  }
281  // else fall through:
282  case 0:
283  DBG << "dbRelease: release" << (force_r && outstanding ? "(forced)" : "")
284  << ", outstanding " << outstanding << endl;
285 
286  _defaultDb->_d._error = shared_ptr<RpmAccessBlockedException>(new RpmAccessBlockedException(_defaultDb->_d._root, _defaultDb->_d._dbPath));
287  // tag handle invalid
288  _defaultDb = 0;
289  break;
290  }
291 
292  return outstanding;
293 }
294 
296 //
297 //
298 // METHOD NAME : librpmDb::blockAccess
299 // METHOD TYPE : unsigned
300 //
302 {
303  MIL << "Block access" << endl;
304  _dbBlocked = true;
305  return dbRelease( /*force*/true );
306 }
307 
309 //
310 //
311 // METHOD NAME : librpmDb::unblockAccess
312 // METHOD TYPE : void
313 //
315 {
316  MIL << "Unblock access" << endl;
317  _dbBlocked = false;
318 }
319 
321 //
322 //
323 // METHOD NAME : librpmDb::dumpState
324 // METHOD TYPE : ostream &
325 //
326 std::ostream & librpmDb::dumpState( std::ostream & str )
327 {
328  if ( !_defaultDb )
329  {
330  return str << "[librpmDb " << (_dbBlocked?"BLOCKED":"CLOSED") << " " << stringPath( _defaultRoot, _defaultDbPath ) << "]";
331  }
332  return str << "[" << _defaultDb << "]";
333 }
334 
336 //
337 // CLASS NAME : librpmDb (internal database handle interface (nonstatic))
338 //
340 
342 //
343 //
344 // METHOD NAME : librpmDb::librpmDb
345 // METHOD TYPE : Constructor
346 //
347 // DESCRIPTION :
348 //
349 librpmDb::librpmDb( const Pathname & root_r, const Pathname & dbPath_r, bool readonly_r )
350  : _d( * new D( root_r, dbPath_r, readonly_r ) )
351 {}
352 
354 //
355 //
356 // METHOD NAME : librpmDb::~librpmDb
357 // METHOD TYPE : Destructor
358 //
359 // DESCRIPTION :
360 //
362 {
363  delete &_d;
364 }
365 
367 //
368 //
369 // METHOD NAME : librpmDb::unref_to
370 // METHOD TYPE : void
371 //
372 void librpmDb::unref_to( unsigned refCount_r ) const
373 {
374  if ( refCount_r == 1 )
375  {
376  dbRelease();
377  }
378 }
379 
381 //
382 //
383 // METHOD NAME : librpmDb::root
384 // METHOD TYPE : const Pathname &
385 //
386 const Pathname & librpmDb::root() const
387 {
388  return _d._root;
389 }
390 
392 //
393 //
394 // METHOD NAME : librpmDb::dbPath
395 // METHOD TYPE : const Pathname &
396 //
397 const Pathname & librpmDb::dbPath() const
398 {
399  return _d._dbPath;
400 }
401 
403 //
404 //
405 // METHOD NAME : librpmDb::error
406 // METHOD TYPE : PMError
407 //
408 shared_ptr<RpmException> librpmDb::error() const
409 {
410  return _d._error;
411 }
412 
414 //
415 //
416 // METHOD NAME : librpmDb::empty
417 // METHOD TYPE : bool
418 //
419 bool librpmDb::empty() const
420 {
421  return( valid() && ! *db_const_iterator( this ) );
422 }
423 
425 //
426 //
427 // METHOD NAME : librpmDb::size
428 // METHOD TYPE : unsigned
429 //
430 unsigned librpmDb::size() const
431 {
432  unsigned count = 0;
433  if ( valid() )
434  {
435  db_const_iterator it( this );
436  for ( db_const_iterator it( this ); *it; ++it )
437  ++count;
438  }
439  return count;
440 }
441 
443 //
444 //
445 // METHOD NAME : librpmDb::dont_call_it
446 // METHOD TYPE : void *
447 //
449 {
450  return rpmtsGetRdb(_d._ts);
451 }
452 
454 //
455 //
456 // METHOD NAME : librpmDb::dumpOn
457 // METHOD TYPE : ostream &
458 //
459 // DESCRIPTION :
460 //
461 std::ostream & librpmDb::dumpOn( std::ostream & str ) const
462 {
464  return str;
465 }
466 
468 //
469 // CLASS NAME : librpmDb::db_const_iterator::D
474 {
475  D & operator=( const D & ); // NO ASSIGNMENT!
476  D ( const D & ); // NO COPY!
477 public:
478 
480  shared_ptr<RpmException> _dberr;
481 
483  rpmdbMatchIterator _mi;
484 
486  : _dbptr( dbptr_r )
487  , _mi( 0 )
488  {
489  if ( !_dbptr )
490  {
491  try
492  {
494  }
495  catch (const RpmException & excpt_r)
496  {
497  ZYPP_CAUGHT(excpt_r);
498  }
499  if ( !_dbptr )
500  {
501  WAR << "No database access: " << _dberr << endl;
502  }
503  }
504  else
505  {
506  destroy(); // Checks whether _dbptr still valid
507  }
508  }
509 
510  ~D()
511  {
512  if ( _mi )
513  {
514  ::rpmdbFreeIterator( _mi );
515  }
516  }
517 
522  bool create( int rpmtag, const void * keyp = NULL, size_t keylen = 0 )
523  {
524  destroy();
525  if ( ! _dbptr )
526  return false;
527  _mi = ::rpmtsInitIterator( _dbptr->_d._ts, rpmTag(rpmtag), keyp, keylen );
528  return _mi;
529  }
530 
535  bool destroy()
536  {
537  if ( _mi )
538  {
539  _mi = ::rpmdbFreeIterator( _mi );
540  _hptr = 0;
541  }
542  if ( _dbptr && _dbptr->error() )
543  {
544  _dberr = _dbptr->error();
545  WAR << "Lost database access: " << _dberr << endl;
546  _dbptr = 0;
547  }
548  return false;
549  }
550 
555  bool advance()
556  {
557  if ( !_mi )
558  return false;
559  Header h = ::rpmdbNextIterator( _mi );
560  if ( ! h )
561  {
562  destroy();
563  return false;
564  }
565  _hptr = new RpmHeader( h );
566  return true;
567  }
568 
572  bool init( int rpmtag, const void * keyp = NULL, size_t keylen = 0 )
573  {
574  if ( ! create( rpmtag, keyp, keylen ) )
575  return false;
576  return advance();
577  }
578 
583  bool set( int off_r )
584  {
585  if ( ! create( RPMDBI_PACKAGES ) )
586  return false;
587 #ifdef RPMFILEITERMAX // since rpm.4.12
588  ::rpmdbAppendIterator( _mi, (const unsigned *)&off_r, 1 );
589 #else
590  ::rpmdbAppendIterator( _mi, &off_r, 1 );
591 #endif
592  return advance();
593  }
594 
595  unsigned offset()
596  {
597  return( _mi ? ::rpmdbGetIteratorOffset( _mi ) : 0 );
598  }
599 
600  int size()
601  {
602  if ( !_mi )
603  return 0;
604  int ret = ::rpmdbGetIteratorCount( _mi );
605  return( ret ? ret : -1 ); // -1: sequential access
606  }
607 };
608 
610 
612 //
613 // CLASS NAME : librpmDb::Ptr::db_const_iterator
614 //
616 
618 //
619 //
620 // METHOD NAME : librpmDb::db_const_iterator::db_iterator
621 // METHOD TYPE : Constructor
622 //
624  : _d( * new D( dbptr_r ) )
625 {
626  findAll();
627 }
628 
630 //
631 //
632 // METHOD NAME : librpmDb::db_const_iterator::~db_const_iterator
633 // METHOD TYPE : Destructor
634 //
636 {
637  delete &_d;
638 }
639 
641 //
642 //
643 // METHOD NAME : librpmDb::db_const_iterator::operator++
644 // METHOD TYPE : void
645 //
647 {
648  _d.advance();
649 }
650 
652 //
653 //
654 // METHOD NAME : librpmDb::db_const_iterator::dbHdrNum
655 // METHOD TYPE : unsigned
656 //
658 {
659  return _d.offset();
660 }
661 
663 //
664 //
665 // METHOD NAME : librpmDb::db_const_iterator::operator*
666 // METHOD TYPE : const RpmHeader::constPtr &
667 //
669 {
670  return _d._hptr;
671 }
672 
674 //
675 //
676 // METHOD NAME : librpmDb::db_const_iterator::dbError
677 // METHOD TYPE : PMError
678 //
679 shared_ptr<RpmException> librpmDb::db_const_iterator::dbError() const
680 {
681  if ( _d._dbptr )
682  return _d._dbptr->error();
683 
684  return _d._dberr;
685 }
686 
687 /******************************************************************
688 **
689 **
690 ** FUNCTION NAME : operator<<
691 ** FUNCTION TYPE : ostream &
692 */
693 std::ostream & operator<<( std::ostream & str, const librpmDb::db_const_iterator & obj )
694 {
695  str << "db_const_iterator(" << obj._d._dbptr
696  << " Size:" << obj._d.size()
697  << " HdrNum:" << obj._d.offset()
698  << ")";
699  return str;
700 }
701 
703 //
704 //
705 // METHOD NAME : librpmDb::db_const_iterator::findAll
706 // METHOD TYPE : bool
707 //
709 {
710  return _d.init( RPMDBI_PACKAGES );
711 }
712 
714 //
715 //
716 // METHOD NAME : librpmDb::db_const_iterator::findByFile
717 // METHOD TYPE : bool
718 //
719 bool librpmDb::db_const_iterator::findByFile( const std::string & file_r )
720 {
721  return _d.init( RPMTAG_BASENAMES, file_r.c_str() );
722 }
723 
725 //
726 //
727 // METHOD NAME : librpmDb::db_const_iterator::findByProvides
728 // METHOD TYPE : bool
729 //
730 bool librpmDb::db_const_iterator::findByProvides( const std::string & tag_r )
731 {
732  return _d.init( RPMTAG_PROVIDENAME, tag_r.c_str() );
733 }
734 
736 //
737 //
738 // METHOD NAME : librpmDb::db_const_iterator::findByRequiredBy
739 // METHOD TYPE : bool
740 //
741 bool librpmDb::db_const_iterator::findByRequiredBy( const std::string & tag_r )
742 {
743  return _d.init( RPMTAG_REQUIRENAME, tag_r.c_str() );
744 }
745 
747 //
748 //
749 // METHOD NAME : librpmDb::db_const_iterator::findByConflicts
750 // METHOD TYPE : bool
751 //
752 bool librpmDb::db_const_iterator::findByConflicts( const std::string & tag_r )
753 {
754  return _d.init( RPMTAG_CONFLICTNAME, tag_r.c_str() );
755 }
756 
758 //
759 //
760 // METHOD NAME : librpmDb::findByName
761 // METHOD TYPE : bool
762 //
763 bool librpmDb::db_const_iterator::findByName( const std::string & name_r )
764 {
765  return _d.init( RPMTAG_NAME, name_r.c_str() );
766 }
767 
769 //
770 //
771 // METHOD NAME : librpmDb::db_const_iterator::findPackage
772 // METHOD TYPE : bool
773 //
774 bool librpmDb::db_const_iterator::findPackage( const std::string & name_r )
775 {
776  if ( ! _d.init( RPMTAG_NAME, name_r.c_str() ) )
777  return false;
778 
779  if ( _d.size() == 1 )
780  return true;
781 
782  // check installtime on multiple entries
783  int match = 0;
784  time_t itime = 0;
785  for ( ; operator*(); operator++() )
786  {
787  if ( operator*()->tag_installtime() > itime )
788  {
789  match = _d.offset();
790  itime = operator*()->tag_installtime();
791  }
792  }
793 
794  return _d.set( match );
795 }
796 
798 //
799 //
800 // METHOD NAME : librpmDb::db_const_iterator::findPackage
801 // METHOD TYPE : bool
802 //
803 bool librpmDb::db_const_iterator::findPackage( const std::string & name_r, const Edition & ed_r )
804 {
805  if ( ! _d.init( RPMTAG_NAME, name_r.c_str() ) )
806  return false;
807 
808  for ( ; operator*(); operator++() )
809  {
810  if ( ed_r == operator*()->tag_edition() )
811  {
812  int match = _d.offset();
813  return _d.set( match );
814  }
815  }
816 
817  return _d.destroy();
818 }
819 
821 //
822 //
823 // METHOD NAME : librpmDb::db_const_iterator::findPackage
824 // METHOD TYPE : bool
825 //
827 {
828  if ( ! which_r )
829  return _d.destroy();
830 
831  return findPackage( which_r->name(), which_r->edition() );
832 }
833 
834 } // namespace rpm
835 } // namespace target
836 } // namespace zypp
void * dont_call_it() const
Dont call it ;) It&#39;s for development and testing only.
Definition: librpmDb.cc:448
#define MIL
Definition: Logger.h:79
intrusive_ptr< const RpmHeader > constPtr
Definition: RpmHeader.h:64
static bool _dbBlocked
Whether access is blocked (no _defaultDb will be available).
Definition: librpmDb.h:84
static unsigned blockAccess()
Blocks further access to rpmdb.
Definition: librpmDb.cc:301
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:392
void operator++()
Advance to next RpmHeader::constPtr.
Definition: librpmDb.cc:646
bool findByProvides(const std::string &tag_r)
Reset to iterate all packages that provide a certain tag.
Definition: librpmDb.cc:730
#define OUTVAL(n)
static std::string expand(const std::string &macro_r)
Definition: librpmDb.cc:146
bool advance()
Advance to the first/next header in iterator.
Definition: librpmDb.cc:555
shared_ptr< RpmException > _error
Definition: librpmDb.cc:48
static void dbAccess()
Access the database at the current default location.
Definition: librpmDb.cc:231
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
Definition: PtrTypes.h:151
const char * c_str() const
String representation.
Definition: Pathname.h:110
String related utilities and Regular expression matching.
bool findByRequiredBy(const std::string &tag_r)
Reset to iterate all packages that require a certain tag.
Definition: librpmDb.cc:741
librpmDb(const Pathname &root_r, const Pathname &dbPath_r, bool readonly_r)
Private constructor! librpmDb objects are to be created via static interface only.
Definition: librpmDb.cc:349
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
virtual void unref_to(unsigned refCount_r) const
Trigger from Rep, after refCount was decreased.
Definition: librpmDb.cc:372
db_const_iterator(const db_const_iterator &)
friend std::ostream & operator<<(std::ostream &str, const D &obj)
Definition: librpmDb.cc:50
#define ERR
Definition: Logger.h:81
Subclass to retrieve database content.
Definition: librpmDb.h:322
static librpmDb::constPtr _defaultDb
Current rpmdb handle.
Definition: librpmDb.h:79
static librpmDb * newLibrpmDb()
For internal use.
Definition: librpmDb.cc:166
virtual ~librpmDb()
Destructor.
Definition: librpmDb.cc:361
bool empty() const
Test for an empty path.
Definition: Pathname.h:114
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
Definition: Exception.h:400
shared_ptr< RpmException > dbError() const
Return any database error.
Definition: librpmDb.cc:679
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition: String.h:208
const std::string & asString() const
String representation.
Definition: Pathname.h:91
static Pathname _defaultRoot
Current root directory for all operations.
Definition: librpmDb.h:68
bool findByName(const std::string &name_r)
Reset to iterate all packages with a certain name.
Definition: librpmDb.cc:763
#define WAR
Definition: Logger.h:80
static unsigned dbRelease(bool force_r=false)
If there are no outstanding references to the database (e.g.
Definition: librpmDb.cc:264
shared_ptr< RpmException > error() const
Return any database error.
Definition: librpmDb.cc:408
bool absolute() const
Test for an absolute path.
Definition: Pathname.h:116
bool findByFile(const std::string &file_r)
Reset to iterate all packages that own a certain file.
Definition: librpmDb.cc:719
const Pathname & root() const
Definition: librpmDb.cc:386
Just inherits Exception to separate media exceptions.
Definition: RpmException.h:37
Manage access to librpm database.
Definition: librpmDb.h:38
bool findPackage(const std::string &name_r)
Find package by name.
Definition: librpmDb.cc:774
static void unblockAccess()
Allow access to rpmdb e.g.
Definition: librpmDb.cc:314
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Definition: Exception.h:396
bool findAll()
Reset to iterate all packages.
Definition: librpmDb.cc:708
librpmDb internal database handle
Definition: librpmDb.cc:39
const RpmHeader::constPtr & operator*() const
Returns the current RpmHeader::constPtr or NULL, if no more entries available.
Definition: librpmDb.cc:668
static bool globalInit()
Initialize lib librpm (read configfiles etc.).
Definition: librpmDb.cc:115
static const Pathname _defaultDbPath
Current directory (below root) that contains the rpmdb.
Definition: librpmDb.h:74
bool findByConflicts(const std::string &tag_r)
Reset to iterate all packages that conflict with a certain tag.
Definition: librpmDb.cc:752
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:220
D(const Pathname &root_r, const Pathname &dbPath_r, bool readonly_r)
Definition: librpmDb.cc:56
virtual std::ostream & dumpOn(std::ostream &str) const
Dump debug info.
Definition: librpmDb.cc:461
unsigned dbHdrNum() const
Returns the current headers index in database, 0 if no header.
Definition: librpmDb.cc:657
const Pathname & dbPath() const
Definition: librpmDb.cc:397
unsigned size() const
Definition: librpmDb.cc:430
bool init(int rpmtag, const void *keyp=NULL, size_t keylen=0)
Access a dbindex file and advance to the 1st header.
Definition: librpmDb.cc:572
Wrapper class for rpm header struct.
Definition: RpmHeader.h:60
intrusive_ptr< const librpmDb > constPtr
Definition: librpmDb.h:42
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
bool create(int rpmtag, const void *keyp=NULL, size_t keylen=0)
Let iterator access a dbindex file.
Definition: librpmDb.cc:522
static std::ostream & dumpState(std::ostream &str)
Dump debug info.
Definition: librpmDb.cc:326
static std::string stringPath(const Pathname &root_r, const Pathname &sub_r)
Definition: librpmDb.h:127
TraitsType::constPtrType constPtr
Definition: Package.h:38
#define DBG
Definition: Logger.h:78
friend std::ostream & operator<<(std::ostream &str, const ReferenceCounted &obj)
Stream output via dumpOn.