rpm
5.4.15
|
#include "system.h"
#include <sys/file.h>
#include <rpmiotypes.h>
#include <rpmlog.h>
#include <rpmpgp.h>
#include <rpmurl.h>
#include <rpmhash.h>
#include <rpmmacro.h>
#include <rpmsq.h>
#include <rpmsx.h>
#include <argv.h>
#include <rpmbf.h>
#include <rpmtypes.h>
#include "header_internal.h"
#include "rpmdb.h"
#include "pkgio.h"
#include "fprint.h"
#include "legacy.h"
#include "debug.h"
Go to the source code of this file.
Data Structures | |
union | _dbswap |
struct | _setSwap_s |
struct | rpmmi_s |
Macros | |
#define | _MIRE_INTERNAL |
#define | _RPMBF_INTERNAL |
#define | _RPMTAG_INTERNAL |
#define | _RPMDB_INTERNAL |
#define | UINT32_T rpmuint32_t |
#define | _DBI_FLAGS 0 |
#define | _DBI_PERMS 0644 |
#define | _DBI_MAJOR -1 |
#define | DB1vec NULL |
#define | DB2vec NULL |
#define | DB3vec NULL |
#define | SQLITEvec NULL |
#define | _DB_ROOT "/" |
#define | _DB_HOME "%{?_dbpath}" |
#define | _DB_FLAGS 0 |
#define | _DB_MODE 0 |
#define | _DB_PERMS 0644 |
#define | _DB_MAJOR 3 |
#define | _DB_ERRPFX "rpmdb" |
Typedefs | |
typedef struct _setSwap_s * | setSwap |
Functions | |
static size_t | dbiTagToDbix (rpmdb db, rpmTag tag) |
Return dbi index used for rpm tag. More... | |
static void | dbiTagsInit (tagStore_t *dbiTagsP, size_t *dbiNTagsP) |
Initialize database (index, tag) tuple from configuration. More... | |
static int | checkfd (const char *devnull, int fdno, int flags) |
dbiIndex | dbiOpen (rpmdb db, rpmTag tag, unsigned int flags) |
static uint64_t | _ntoh_ul (uint64_t ul) |
static uint64_t | _hton_ul (uint64_t ul) |
static uint32_t | _ntoh_ui (uint32_t ui) |
static uint32_t | _hton_ui (uint32_t ui) |
static uint16_t | _ntoh_us (uint16_t us) |
static uint16_t | _hton_us (uint16_t us) |
static int | hdrNumCmp (const void *one, const void *two) |
static int | dbiAppendSet (dbiIndexSet set, const void *recs, int nrecs, size_t recsize, int sortset) |
Append element(s) to set of index database items. More... | |
unsigned int | dbiIndexSetCount (dbiIndexSet set) |
uint32_t | dbiIndexRecordOffset (dbiIndexSet set, unsigned int recno) |
uint32_t | dbiIndexRecordFileNumber (dbiIndexSet set, unsigned int recno) |
dbiIndexSet | dbiFreeIndexSet (dbiIndexSet set) |
int | rpmdbCheckTerminate (int terminate) |
Check rpmdb signal handler for trapped signal and/or requested exit. More... | |
int | rpmdbCheckSignals (void) |
Check for and exit on termination signals. More... | |
static int | blockSignals (rpmdb db, sigset_t *oldMask) |
Block all signals, returning previous signal mask. More... | |
static int | unblockSignals (rpmdb db, sigset_t *oldMask) |
Restore signal mask. More... | |
static const char * | queryHeader (Header h, const char *qfmt) |
Return header query string. More... | |
static int | rpmdbExportHR_MIB (rpmdb db, Header h, int adding) |
Write added/removed header info into %{_hrmib_path}. More... | |
static int | rpmdbExportInfo (rpmdb db, Header h, int adding) |
Write added/removed header info. More... | |
static rpmdb | rpmdbGetPool (rpmioPool pool) |
int | rpmdbOpenAll (rpmdb db) |
Open all database indices. More... | |
int | rpmdbBlockDBI (rpmdb db, int tag) |
Block access to a single database index. More... | |
int | rpmdbCloseDBI (rpmdb db, int tag) |
Close a single database index. More... | |
int | rpmdbClose (rpmdb db) |
Close all database indices and free rpmdb. More... | |
static const char * | rpmdbURIPath (const char *uri) |
Return macro expanded absolute path to rpmdb. More... | |
rpmdb | rpmdbNew (const char *root, const char *home, int mode, mode_t perms, int flags) |
static int | rpmdbOpenDatabase (const char *prefix, const char *dbpath, int _dbapi, rpmdb *dbp, int mode, mode_t perms, int flags) |
int | rpmdbOpen (const char *prefix, rpmdb *dbp, int mode, mode_t perms) |
Open rpm database. More... | |
int | rpmdbCount (rpmdb db, rpmTag tag, const void *keyp, size_t keylen) |
Return number of instances of key in a tag index. More... | |
int | rpmdbCountPackages (rpmdb db, const char *N) |
Return number of instances of package in Name index. More... | |
static const char * | stemEnd (const char *s) |
static const char * | _str2PCREpat (const char *_pre, const char *s, const char *_post) |
static int | dbiMireKeys (rpmdb db, rpmTag tag, rpmMireMode mode, const char *pat, dbiIndexSet *matches, const char ***argvp) |
Retrieve prinary/secondary keys for a pattern match. More... | |
int | rpmdbMireApply (rpmdb db, rpmTag tag, rpmMireMode mode, const char *pat, const char ***argvp) |
Return array of keys matching a pattern. More... | |
int | rpmmiGrowBasename (rpmmi mi, const char *bn) |
Append packages containing common basename to iterator. More... | |
static rpmRC | dbiFindMatches (dbiIndex dbi, const char *pat, dbiIndexSet *matches) |
Attempt partial matches on name[-version[-release]] strings. More... | |
void * | dbiStatsAccumulator (dbiIndex dbi, int opx) |
static int | miFreeHeader (rpmmi mi, dbiIndex dbi) |
Rewrite a header into packages (if necessary) and free the header. More... | |
static void | rpmmiFini (void *_mi) |
static rpmmi | rpmmiGetPool (rpmioPool pool) |
uint32_t | rpmmiInstance (rpmmi mi) |
Return header instance for current position of rpmdb iterator. More... | |
uint32_t | rpmmiBNTag (rpmmi mi) |
Return basename tag for current position of rpmdb iterator. More... | |
unsigned int | rpmmiCount (rpmmi mi) |
Return number of elements in rpm database iterator. More... | |
static int | mireCmp (const void *a, const void *b) |
Compare iterator selectors by rpm tag (qsort/bsearch). More... | |
static char * | mireDup (rpmTag tag, rpmMireMode *modep, const char *pattern) |
Copy pattern, escaping for appropriate mode. More... | |
int | rpmmiAddPattern (rpmmi mi, rpmTag tag, rpmMireMode mode, const char *pattern) |
Add pattern to iterator selector. More... | |
static unsigned char | nibble (char c) |
Convert hex to binary nibble. More... | |
static char * | bin2hex (const void *data, size_t size) |
Convert binary blob to printable hex string. More... | |
static int | mireSkip (const rpmmi mi) |
Return iterator selector match. More... | |
int | rpmmiSetRewrite (rpmmi mi, int rewrite) |
Prepare iterator for lazy writes. More... | |
int | rpmmiSetModified (rpmmi mi, int modified) |
Modify iterator to mark header for lazy write on release. More... | |
static int | rpmmiGet (dbiIndex dbi, DBC *dbcursor, DBT *kp, DBT *pk, DBT *vp, unsigned int flags) |
Header | rpmmiNext (rpmmi mi) |
Return next package header from iteration. More... | |
int | rpmmiSort (rpmmi mi) |
Sort iterator instances. More... | |
int | rpmmiPrune (rpmmi mi, uint32_t *hdrNums, int nHdrNums, int sorted) |
Remove items from set of package instances to iterate. More... | |
int | rpmmiGrow (rpmmi mi, const uint32_t *hdrNums, int nHdrNums) |
Append items to set of package instances to iterate. More... | |
rpmmi | rpmmiInit (rpmdb db, rpmTag tag, const void *keyp, size_t keylen) |
Return database iterator. More... | |
int | rpmdbRemove (rpmdb db, int rid, uint32_t hdrNum, rpmts ts) |
Remove package header from rpm database and indices. More... | |
int | rpmdbAdd (rpmdb db, int iid, Header h, rpmts ts) |
Add package header to rpm database and indices. More... | |
Variables | |
int | _rpmdb_debug = 0 |
int | _rpmmi_debug = 0 |
static struct _dbiVec * | mydbvecs [] |
static union _dbswap | _endian = { 0x11223344 } |
static rpmdb | rpmdbRock |
static rpmmi | rpmmiRock |
rpmioPool | _rpmdbPool |
rpmioPool | _rpmmiPool |
static int | _rpmmi_usermem = 1 |
#define _DB_ERRPFX "rpmdb" |
Definition at line 1004 of file rpmdb.c.
Referenced by rpmdbNew().
#define _DB_FLAGS 0 |
Definition at line 999 of file rpmdb.c.
Referenced by rpmdbNew().
#define _DB_HOME "%{?_dbpath}" |
Definition at line 998 of file rpmdb.c.
Referenced by rpmdbNew().
#define _DB_MAJOR 3 |
Definition at line 1003 of file rpmdb.c.
Referenced by rpmdbNew(), and rpmdbOpen().
#define _DB_MODE 0 |
Definition at line 1000 of file rpmdb.c.
Referenced by rpmdbNew().
#define _DB_PERMS 0644 |
Definition at line 1001 of file rpmdb.c.
Referenced by rpmdbNew().
#define _DB_ROOT "/" |
Definition at line 997 of file rpmdb.c.
Referenced by rpmdbNew().
#define UINT32_T rpmuint32_t |
Definition at line 39 of file rpmdb.c.
Referenced by dbiMireKeys(), miFreeHeader(), rpmdbAdd(), rpmdbCount(), rpmdbRemove(), rpmmiCount(), and rpmmiNext().
typedef struct _setSwap_s * setSwap |
|
inlinestatic |
Definition at line 335 of file rpmdb.c.
References _ntoh_ui().
Referenced by rpmdbAdd(), rpmdbRemove(), rpmmiInit(), rpmmiNext(), and rpmmiPrune().
|
inlinestatic |
Definition at line 317 of file rpmdb.c.
References _ntoh_ul().
|
inlinestatic |
|
inlinestatic |
Definition at line 323 of file rpmdb.c.
References _dbswap::uc, and _dbswap::ui.
Referenced by _hton_ui(), dbiMireKeys(), miFreeHeader(), rpmmiInstance(), and rpmmiNext().
|
inlinestatic |
Definition at line 303 of file rpmdb.c.
References _dbswap::uc, and _dbswap::ul.
Referenced by _hton_ul().
|
inlinestatic |
Definition at line 341 of file rpmdb.c.
References _dbswap::uc, and _dbswap::us.
Referenced by _hton_us().
|
static |
Definition at line 1282 of file rpmdb.c.
References stpcpy(), and xmalloc.
Referenced by dbiFindMatches().
|
static |
Convert binary blob to printable hex string.
data | binary data |
size | size of data in bytes |
Definition at line 2022 of file rpmdb.c.
Referenced by mireSkip().
|
static |
Block all signals, returning previous signal mask.
db | rpm database |
*oldMask | previous sigset |
Definition at line 541 of file rpmdb.c.
Referenced by miFreeHeader(), rpmdbAdd(), and rpmdbRemove().
|
inlinestatic |
|
static |
Append element(s) to set of index database items.
set | set of index database items |
recs | array of items to append to set |
nrecs | number of items |
recsize | size of an array item |
sortset | should resulting set be sorted? |
Definition at line 382 of file rpmdb.c.
References hdrNumCmp(), and xrealloc.
Referenced by dbiMireKeys(), rpmmiGrow(), and rpmmiGrowBasename().
|
static |
Attempt partial matches on name[-version[-release]] strings.
dbi | index database handle (always RPMTAG_NVRA) |
pat | pattern to match against secondary keys |
matches | set of header instances that match |
Definition at line 1536 of file rpmdb.c.
References _, _free(), _str2PCREpat(), DB_NOTFOUND, dbiFreeIndexSet(), dbiMireKeys(), Glob_pattern_p(), mode, ns, rpmlog(), RPMLOG_ERR, RPMMIRE_GLOB, RPMMIRE_PCRE, RPMMIRE_STRCMP, RPMRC_FAIL, RPMRC_NOTFOUND, RPMRC_OK, RPMTAG_FILEPATHS, RPMTAG_NVRA, tagName(), and xstrdup().
Referenced by rpmmiInit().
dbiIndexSet dbiFreeIndexSet | ( | dbiIndexSet | set | ) |
Definition at line 428 of file rpmdb.c.
References _free(), and set().
Referenced by dbiFindMatches(), dbiMireKeys(), rpmmiFini(), rpmmiGrowBasename(), and rpmmiInit().
uint32_t dbiIndexRecordFileNumber | ( | dbiIndexSet | set, |
unsigned int | recno | ||
) |
Definition at line 423 of file rpmdb.c.
Referenced by rpmmiNext().
uint32_t dbiIndexRecordOffset | ( | dbiIndexSet | set, |
unsigned int | recno | ||
) |
Definition at line 418 of file rpmdb.c.
Referenced by rpmmiNext().
unsigned int dbiIndexSetCount | ( | dbiIndexSet | set | ) |
|
static |
Retrieve prinary/secondary keys for a pattern match.
db | rpm database |
tag | rpm tag |
mode | type of pattern match |
pat | pattern to match (NULL iterates all keys). |
*matches | array or primary keys that match (or NULL) |
*argvp | array of secondary keys that match (or NULL) |
Definition at line 1320 of file rpmdb.c.
References _, _free(), _ntoh_ui(), argvAdd(), argvAppend(), argvFree(), b, __db_dbt::data, DB_CURRENT, DB_DBT_PARTIAL, DB_NEXT, DB_NEXT_DUP, DB_NOTFOUND, DB_SET, DB_SET_RANGE, dbiAppendSet(), dbiFreeIndexSet(), dbiOpen(), __db_dbt::dlen, __db_dbt::doff, __db_dbt::flags, mireFree(), mireNew(), mireRegcomp(), mireRegexec(), ns, rpmlog(), RPMLOG_ERR, RPMMIRE_GLOB, RPMMIRE_PCRE, RPMMIRE_REGEX, RPMMIRE_STRCMP, set(), __db_dbt::size, stemEnd(), tagName(), UINT32_T, v, xcalloc(), and xmalloc.
Referenced by dbiFindMatches(), rpmdbMireApply(), and rpmmiGrowBasename().
Definition at line 223 of file rpmdb.c.
References _, checkfd(), dbiTagToDbix(), rpmlog(), RPMLOG_ERR, and tagName().
Referenced by db3open(), dbiMireKeys(), rpmdbAdd(), rpmdbCount(), rpmdbOpenAll(), rpmdbOpenDatabase(), rpmdbRemove(), rpmmiCount(), rpmmiFini(), rpmmiInit(), rpmmiNext(), rpmpsmStage(), rpmtsRebuildDB(), and unsatisfiedDepend().
|
static |
Initialize database (index, tag) tuple from configuration.
Definition at line 94 of file rpmdb.c.
References _free(), RPMDBI_PACKAGES, rpmExpand(), tagStoreFree(), tagValue(), xcalloc(), xisspace(), xrealloc, and xstrdup().
Referenced by rpmdbNew().
|
static |
Definition at line 365 of file rpmdb.c.
References b.
Referenced by dbiAppendSet(), and rpmmiSort().
Rewrite a header into packages (if necessary) and free the header.
Note: this is called from a markReplacedFiles iteration, and must preserve the "join key" (i.e. offset) for the header.
mi | database iterator |
dbi | index database handle |
Definition at line 1633 of file rpmdb.c.
References _, _free(), _ntoh_ui(), blockSignals(), __db_dbt::data, DB_KEYLAST, headerFree(), headerUnload(), len, rpmmi_s::mi_dbc, rpmmi_s::mi_h, rpmmi_s::mi_modified, rpmmi_s::mi_prevoffset, rpmlog(), RPMLOG_ERR, __db_dbt::size, tagName(), UINT32_T, unblockSignals(), and v.
Referenced by rpmmiFini(), and rpmmiNext().
|
static |
Compare iterator selectors by rpm tag (qsort/bsearch).
a | 1st iterator selector |
b | 2nd iterator selector |
Definition at line 1801 of file rpmdb.c.
Referenced by rpmmiAddPattern().
|
static |
Copy pattern, escaping for appropriate mode.
tag | rpm tag |
modep | type of pattern match |
pattern | pattern to duplicate |
Definition at line 1817 of file rpmdb.c.
References RPMMIRE_DEFAULT, RPMMIRE_GLOB, RPMMIRE_REGEX, RPMMIRE_STRCMP, RPMTAG_BASENAMES, RPMTAG_DIRNAMES, RPMTAG_FILEPATHS, xmalloc, and xstrdup().
Referenced by rpmmiAddPattern().
|
static |
Return iterator selector match.
mi | rpm database iterator |
Definition at line 2046 of file rpmdb.c.
References _free(), alloca(), rpmDataType_u::argv, bin2hex(), _HE_s::c, headerGet(), i, j, rpmmi_s::mi_h, rpmmi_s::mi_nre, rpmmi_s::mi_re, mireRegexec(), _HE_s::p, rpmDataType_u::ptr, RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, RPM_UINT16_TYPE, RPM_UINT32_TYPE, RPM_UINT64_TYPE, RPM_UINT8_TYPE, RPMTAG_EPOCH, rpmDataType_u::str, _HE_s::t, _HE_s::tag, rpmDataType_u::ui16p, rpmDataType_u::ui32p, rpmDataType_u::ui64p, rpmDataType_u::ui8p, and xcalloc().
Referenced by rpmmiNext().
|
inlinestatic |
|
inlinestatic |
Return header query string.
h | header |
qfmt | header sprintf format |
Definition at line 579 of file rpmdb.c.
References _, errstr, headerCompoundFormats, headerSprintf(), rpmlog(), RPMLOG_ERR, and str.
Referenced by rpmdbExportHR_MIB().
Add package header to rpm database and indices.
db | rpm database |
iid | install transaction id (iid = 0 or -1 to skip) |
h | header |
ts | (unused) transaction set (or NULL) |
Definition at line 2887 of file rpmdb.c.
References _free(), _hton_ui(), alloca(), blockSignals(), _HE_s::c, __db_dbt::data, DB_KEYLAST, DB_WRITECURSOR, dbiOpen(), headerFree(), headerGet(), headerGetInstance(), headerIsEntry(), headerLink(), headerPut(), headerSetInstance(), headerUnload(), len, _HE_s::p, rpmDataType_u::ptr, RPM_UINT32_TYPE, RPMDBI_ADDED, RPMDBI_AVAILABLE, RPMDBI_DEPCACHE, RPMDBI_PACKAGES, RPMDBI_REMOVED, RPMDBI_SEQNO, RPMRC_FAIL, RPMRC_OK, RPMTAG_INSTALLTID, RPMTAG_PACKAGECOLOR, __db_dbt::size, _HE_s::t, _HE_s::tag, rpmDataType_u::ui32p, UINT32_T, unblockSignals(), and v.
Referenced by ftsCacheUpdate(), rpmcliImportPubkey(), and rpmpsmStage().
int rpmdbBlockDBI | ( | rpmdb | db, |
int | tag | ||
) |
Block access to a single database index.
db | rpm database |
tag | rpm tag (negative to block) |
Definition at line 825 of file rpmdb.c.
Referenced by rpmgiNext().
int rpmdbCheckSignals | ( | void | ) |
Check for and exit on termination signals.
Definition at line 523 of file rpmdb.c.
References D_, EXIT_FAILURE, rpmdbCheckTerminate(), rpmlog(), RPMLOG_DEBUG, and rpmsqCaught.
Referenced by checkSignals(), rpmdbClose(), rpmgiShowMatches(), rpmmiFini(), rpmmiInit(), rpmQueryVerify(), rpmtsAddFingerprints(), rpmtsFindBaseNamesInDB(), rpmtsProcess(), rpmtsRepackage(), and unblockSignals().
int rpmdbCheckTerminate | ( | int | terminate | ) |
Check rpmdb signal handler for trapped signal and/or requested exit.
Clean up any open iterators and databases on termination condition. On non-zero exit any open references to rpmdb are invalid and cannot be accessed anymore, calling process should terminate immediately.
terminate | 0 to only check for signals, 1 to terminate anyway |
Definition at line 476 of file rpmdb.c.
References db, rpmmi_s::mi_next, rpmdbClose(), rpmmiFree(), and rpmsqCaught.
Referenced by rpm_exithook(), rpmdbCheckSignals(), and rpmts_Die().
int rpmdbClose | ( | rpmdb | db | ) |
Close all database indices and free rpmdb.
db | rpm database |
Definition at line 870 of file rpmdb.c.
References _free(), BY, db, L, rpmdbCheckSignals(), rpmdbRock, rpmioPutPool(), rpmsqEnable(), tagStoreFree(), yarnPeekLock(), yarnPossess(), and yarnTwist().
Referenced by rpmdb_dealloc(), rpmdbCheckTerminate(), rpmdbOpenDatabase(), rpmmiFini(), rpmtsCloseDB(), and rpmtsCloseSDB().
int rpmdbCloseDBI | ( | rpmdb | db, |
int | tag | ||
) |
Close a single database index.
db | rpm database |
tag | rpm tag |
Definition at line 843 of file rpmdb.c.
Referenced by _rpmtsCheck().
Return number of instances of key in a tag index.
db | rpm database |
tag | rpm tag |
keyp | key data |
keylen | key data length (0 will use strlen(keyp)) |
Definition at line 1192 of file rpmdb.c.
References _, __db_dbt::data, DB_NOTFOUND, DB_SET, dbiOpen(), rpmlog(), RPMLOG_ERR, __db_dbt::size, tagName(), UINT32_T, and v.
Referenced by rpmdbCountPackages().
int rpmdbCountPackages | ( | rpmdb | db, |
const char * | N | ||
) |
Return number of instances of package in Name index.
db | rpm database |
N | rpm package name |
Definition at line 1242 of file rpmdb.c.
References rpmdbCount(), and RPMTAG_NAME.
Referenced by handleOneTrigger(), rpmpsmStage(), and runTriggers().
Write added/removed header info into %{_hrmib_path}.
db | rpm database |
h | header |
adding | adding an rpmdb header? |
Definition at line 601 of file rpmdb.c.
References _free(), alloca(), errno, Fclose(), Fopen(), headerGet(), _HE_s::p, rpmDataType_u::ptr, queryHeader(), rpmGetPath(), rpmioMkpath(), rpmlog(), RPMLOG_DEBUG, RPMTAG_INSTALLTID, _HE_s::tag, rpmDataType_u::ui32p, Unlink(), Utime(), and xstrdup().
Referenced by rpmdbExportInfo().
Write added/removed header info.
db | rpm database |
h | header |
adding | adding an rpmdb header? |
Definition at line 750 of file rpmdb.c.
References rpmdbExportHR_MIB().
Referenced by rpmdbNew().
Definition at line 775 of file rpmdb.c.
References _rpmdbPool, db, rpmioGetPool(), and rpmioNewPool().
Referenced by rpmdbNew().
int rpmdbMireApply | ( | rpmdb | db, |
rpmTag | tag, | ||
rpmMireMode | mode, | ||
const char * | pat, | ||
const char *** | argvp | ||
) |
Return array of keys matching a pattern.
db | rpm database |
tag | rpm tag |
mode | type of pattern match |
pat | pattern to match |
*argvp | array of keys that match |
Definition at line 1486 of file rpmdb.c.
References dbiMireKeys(), and tagName().
Referenced by rpmdbTriggerGlobs(), rpmtsLoadNVRA(), rpmtsSanityCheck(), and runImmedTriggers().
rpmdb rpmdbNew | ( | const char * | root, |
const char * | home, | ||
int | mode, | ||
mode_t | perms, | ||
int | flags | ||
) |
Definition at line 1008 of file rpmdb.c.
References _, _DB_ERRPFX, _DB_FLAGS, _DB_HOME, _DB_MAJOR, _DB_MODE, _DB_PERMS, _DB_ROOT, _free(), db, dbiTagsInit(), rpmdbExportInfo(), rpmdbGetPool(), rpmdbLink(), rpmdbURIPath(), rpmExpand(), rpmExpandNumeric(), rpmioPutPool(), rpmlog(), RPMLOG_ERR, and xcalloc().
Referenced by rpmdbOpenDatabase().
int rpmdbOpen | ( | const char * | prefix, |
rpmdb * | dbp, | ||
int | mode, | ||
mode_t | perms | ||
) |
Open rpm database.
prefix | path to top of install tree |
dbp | address of rpm database |
mode | open(2) flags: O_RDWR or O_RDONLY (O_CREAT also) |
perms | database permissions |
Definition at line 1179 of file rpmdb.c.
References _DB_MAJOR, rpmdbOpenDatabase(), and rpmExpandNumeric().
Referenced by rpmtsFindPubkey(), rpmtsOpenDB(), and rpmtsOpenSDB().
int rpmdbOpenAll | ( | rpmdb | db | ) |
Open all database indices.
db | rpm database |
Definition at line 791 of file rpmdb.c.
References dbiOpen(), RPMDBI_ADDED, RPMDBI_AVAILABLE, RPMDBI_BTREE, RPMDBI_DEPCACHE, RPMDBI_HASH, RPMDBI_HEAP, RPMDBI_QUEUE, RPMDBI_RECNO, and RPMDBI_REMOVED.
Referenced by rpmtsPrepare().
|
static |
Definition at line 1077 of file rpmdb.c.
References db, dbiOpen(), rpmdbClose(), RPMDBI_ADDED, RPMDBI_AVAILABLE, RPMDBI_DEPCACHE, RPMDBI_PACKAGES, RPMDBI_REMOVED, rpmdbNew(), rpmdbRock, rpmsqEnable(), and RPMTAG_NAME.
Referenced by rpmdbOpen().
Remove package header from rpm database and indices.
db | rpm database |
rid | (unused) remove transaction id (rid = 0 or -1 to skip) |
hdrNum | package instance number in database |
ts | (unused) transaction set (or NULL) |
Definition at line 2776 of file rpmdb.c.
References _, _free(), _hton_ui(), alloca(), blockSignals(), __db_dbt::data, DB_SET, DB_WRITECURSOR, dbiOpen(), headerFree(), headerGet(), headerLink(), _HE_s::p, rpmDataType_u::ptr, RPMDBI_ADDED, RPMDBI_AVAILABLE, RPMDBI_DEPCACHE, RPMDBI_PACKAGES, RPMDBI_REMOVED, RPMDBI_SEQNO, rpmlog(), RPMLOG_DEBUG, RPMLOG_ERR, rpmmiFree(), rpmmiInit(), rpmmiNext(), RPMRC_FAIL, RPMRC_OK, RPMTAG_NVRA, __db_dbt::size, rpmDataType_u::str, _HE_s::tag, UINT32_T, unblockSignals(), and v.
Referenced by rpmpsmStage(), and rpmtsRollback().
|
static |
Return macro expanded absolute path to rpmdb.
uri | desired path |
Definition at line 944 of file rpmdb.c.
References _free(), argvFree(), argvSplit(), PATH_MAX, Realpath(), rpmGetPath(), stpncpy(), URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_MONGO, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), and xstrdup().
Referenced by rpmdbNew().
int rpmmiAddPattern | ( | rpmmi | mi, |
rpmTag | tag, | ||
rpmMireMode | mode, | ||
const char * | pattern | ||
) |
Add pattern to iterator selector.
mi | rpm database iterator |
tag | rpm tag |
mode | type of pattern match |
pattern | pattern to match |
Definition at line 1910 of file rpmdb.c.
References _free(), _mire_debug, _mirePool, rpmmi_s::mi_nre, rpmmi_s::mi_re, mireCmp(), mireDup(), mireFree(), mireGetPool(), mireLink(), mireNew(), mireRegcomp(), rpmExpand(), RPMMIRE_DEFAULT, RPMMIRE_GLOB, RPMMIRE_REGEX, RPMMIRE_STRCMP, tagName(), and xrealloc.
Referenced by IDTXload(), rpmgiInitFilter(), rpmmi_pattern(), rpmmi_Pattern(), and rpmpsmStage().
uint32_t rpmmiBNTag | ( | rpmmi | mi | ) |
Return basename tag for current position of rpmdb iterator.
mi | rpm database iterator |
Definition at line 1756 of file rpmdb.c.
References rpmmi_s::mi_bntag.
Referenced by rpmtsCheckInstalledFiles().
unsigned int rpmmiCount | ( | rpmmi | mi | ) |
Return number of elements in rpm database iterator.
mi | rpm database iterator |
Definition at line 1763 of file rpmdb.c.
References __db_dbt::data, DB_SET, dbiOpen(), rpmmi_s::mi_cflags, rpmmi_s::mi_count, rpmmi_s::mi_db, rpmmi_s::mi_dbc, rpmmi_s::mi_keylen, rpmmi_s::mi_keyp, rpmmi_s::mi_primary, rpmmi_s::mi_rpmtag, __db_dbt::size, UINT32_T, and v.
Referenced by ftsCacheUpdate(), rpmcliInstall(), rpmmi_Count(), rpmmi_count_get(), rpmQueryVerify(), rpmts_AddErase(), and runImmedTriggers().
|
static |
Definition at line 1679 of file rpmdb.c.
References _free(), dbiFreeIndexSet(), dbiOpen(), rpmmi_s::mi_bf, rpmmi_s::mi_db, rpmmi_s::mi_dbc, rpmmi_s::mi_keylen, rpmmi_s::mi_keyp, rpmmi_s::mi_next, rpmmi_s::mi_nre, rpmmi_s::mi_primary, rpmmi_s::mi_re, rpmmi_s::mi_set, miFreeHeader(), mireFreeAll(), rpmbfFree(), rpmdbCheckSignals(), rpmdbClose(), RPMDBI_PACKAGES, and rpmmiRock.
Referenced by rpmmiGetPool().
|
static |
Definition at line 2196 of file rpmdb.c.
References _rpmmi_usermem, __db_dbt::data, DB_BUFFER_SMALL, DB_DBT_USERMEM, errno, __db_dbt::flags, __db_dbt::size, tagName(), and __db_dbt::ulen.
Referenced by rpmmiNext().
Definition at line 1731 of file rpmdb.c.
References rpmmi_s::_item, _rpmmiPool, rpmioGetPool(), rpmioNewPool(), and rpmmiFini().
Referenced by rpmmiInit().
int rpmmiGrow | ( | rpmmi | mi, |
const uint32_t * | hdrNums, | ||
int | nHdrNums | ||
) |
Append items to set of package instances to iterate.
mi | rpm database iterator |
hdrNums | array of package instances |
nHdrNums | number of elements in array |
Definition at line 2479 of file rpmdb.c.
References dbiAppendSet(), rpmmi_s::mi_set, and xcalloc().
int rpmmiGrowBasename | ( | rpmmi | mi, |
const char * | bn | ||
) |
Append packages containing common basename to iterator.
mi | rpm database iterator |
bn | basename key |
Definition at line 1495 of file rpmdb.c.
References dbiAppendSet(), dbiFreeIndexSet(), dbiMireKeys(), hashFunctionString(), i, rpmmi_s::mi_db, rpmmi_s::mi_rpmtag, rpmmi_s::mi_set, RPMMIRE_STRCMP, RPMTAG_BASENAMES, set(), and xcalloc().
Referenced by rpmtsFindBaseNamesInDB().
Return database iterator.
db | rpm database |
tag | rpm tag |
keyp | key data (NULL for sequential access) |
keylen | key data length (0 will use strlen(keyp)) |
Definition at line 2495 of file rpmdb.c.
References _free(), _hton_ui(), _hton_us(), alloca(), __db_dbt::data, DB_SET, dbiFindMatches(), dbiFreeIndexSet(), dbiOpen(), headerFree(), headerGet(), headerLoad(), i, j, len, rpmmi_s::mi_cflags, rpmmi_s::mi_count, rpmmi_s::mi_db, rpmmi_s::mi_dbc, rpmmi_s::mi_h, rpmmi_s::mi_keylen, rpmmi_s::mi_keyp, rpmmi_s::mi_modified, rpmmi_s::mi_next, rpmmi_s::mi_nre, rpmmi_s::mi_offset, rpmmi_s::mi_prevoffset, rpmmi_s::mi_primary, rpmmi_s::mi_re, rpmmi_s::mi_rpmtag, rpmmi_s::mi_set, rpmmi_s::mi_setx, rpmmi_s::mi_sorted, _HE_s::p, rpmDataType_u::ptr, RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, RPM_UINT16_TYPE, RPM_UINT32_TYPE, RPM_UINT64_TYPE, RPM_UINT8_TYPE, rpmdbCheckSignals(), RPMDBI_PACKAGES, rpmdbLink(), rpmioFreePoolItem(), rpmioLinkPoolItem(), rpmmiGetPool(), rpmmiRock, RPMRC_NOTFOUND, RPMTAG_ARCH, RPMTAG_BASENAMES, RPMTAG_DIRNAMES, RPMTAG_DISTEPOCH, RPMTAG_DISTTAG, RPMTAG_FILEPATHS, RPMTAG_GROUP, RPMTAG_NAME, RPMTAG_NVRA, RPMTAG_OS, RPMTAG_PROVIDENAME, RPMTAG_RELEASE, RPMTAG_VERSION, set(), __db_dbt::size, size, stpcpy(), rpmDataType_u::str, _HE_s::tag, tagName(), tagType(), rpmDataType_u::ui16p, rpmDataType_u::ui32p, rpmDataType_u::ui64p, rpmDataType_u::ui8p, v, xcalloc(), xmalloc, xrealloc, and xstrdup().
Referenced by nwlookupTag(), rpmdb_length(), rpmdb_Match(), rpmdb_subscript(), rpmdbRemove(), rpmtsFindBaseNamesInDB(), rpmtsFindPubkey(), rpmtsInitIterator(), rpmtsSolve(), and wnlookupTag().
uint32_t rpmmiInstance | ( | rpmmi | mi | ) |
Return header instance for current position of rpmdb iterator.
mi | rpm database iterator |
Definition at line 1747 of file rpmdb.c.
References _ntoh_ui(), and rpmmi_s::mi_offset.
Referenced by IDTXload(), nwlookupTag(), rpmcliEraseElement(), rpmErase(), rpmgiNext(), rpmmi_Instance(), rpmmi_offset_get(), rpmpsmStage(), rpmts_AddErase(), rpmtsAddObsoletes(), rpmtsAddUpgrades(), rpmtsCheckInstalledFiles(), rpmtsEraseDebuginfo(), rpmtsFindPubkey(), runImmedTriggers(), runTriggersLoop(), and wnlookupTag().
Return next package header from iteration.
mi | rpm database iterator |
< Is 1st header region mmap'd?
< Is 1st header region rdonly?
Definition at line 2252 of file rpmdb.c.
References _, _hton_ui(), _ntoh_ui(), _rpmmi_usermem, __db_dbt::data, DB_NEXT, DB_NEXT_DUP, DB_NOTFOUND, DB_SET, dbiIndexRecordFileNumber(), dbiIndexRecordOffset(), dbiOpen(), headerToken_s::flags, headerCopyLoad(), HEADERFLAG_MAPPED, HEADERFLAG_RDONLY, headerFree(), headerLoad(), headerSetInstance(), headerSetOrigin(), rpmmi_s::mi_bf, rpmmi_s::mi_bntag, rpmmi_s::mi_cflags, rpmmi_s::mi_db, rpmmi_s::mi_dbc, rpmmi_s::mi_h, rpmmi_s::mi_keylen, rpmmi_s::mi_keyp, rpmmi_s::mi_modified, rpmmi_s::mi_offset, rpmmi_s::mi_prevoffset, rpmmi_s::mi_primary, rpmmi_s::mi_rpmtag, rpmmi_s::mi_set, rpmmi_s::mi_setx, miFreeHeader(), mireSkip(), rpmbfChk(), RPMDBI_PACKAGES, rpmlog(), RPMLOG_ERR, rpmmiGet(), __db_dbt::size, tagName(), UINT32_T, and v.
Referenced by checkPackageSet(), IDTXload(), nwlookupTag(), rpmcliEraseElement(), rpmcliInstall(), rpmcliShowMatches(), rpmdb_length(), rpmdb_subscript(), rpmdbRemove(), rpmErase(), rpmgiNext(), rpmmi_each(), rpmmi_iternext(), rpmmi_next(), rpmpsmStage(), rpmteDBHeader(), rpmts_AddErase(), rpmtsAddObsoletes(), rpmtsAddUpgrades(), rpmtsCheckInstalledFiles(), rpmtsEraseDebuginfo(), rpmtsFindPubkey(), rpmtsSanityCheck(), rpmtsSolve(), runImmedTriggers(), runTriggersLoop(), unsatisfiedDepend(), and wnlookupTag().
int rpmmiPrune | ( | rpmmi | mi, |
uint32_t * | hdrNums, | ||
int | nHdrNums, | ||
int | sorted | ||
) |
Remove items from set of package instances to iterate.
mi | rpm database iterator |
hdrNums | array of package instances |
nHdrNums | number of elements in array |
sorted | is the array sorted? (array will be sorted on return) |
Definition at line 2453 of file rpmdb.c.
References _hton_ui(), i, rpmmi_s::mi_bf, rpmbfAdd(), rpmbfNew(), and rpmbfParams().
Referenced by checkPackageSet(), nwlookupTag(), rpmtsAddObsoletes(), rpmtsEraseDebuginfo(), runImmedTriggers(), runTriggersLoop(), unsatisfiedDepend(), and wnlookupTag().
int rpmmiSetModified | ( | rpmmi | mi, |
int | modified | ||
) |
Modify iterator to mark header for lazy write on release.
mi | rpm database iterator |
modified | new value of modified |
Definition at line 2183 of file rpmdb.c.
References rpmmi_s::mi_modified.
int rpmmiSetRewrite | ( | rpmmi | mi, |
int | rewrite | ||
) |
Prepare iterator for lazy writes.
mi | rpm database iterator |
rewrite | new value of rewrite |
Definition at line 2170 of file rpmdb.c.
References DB_WRITECURSOR, and rpmmi_s::mi_cflags.
int rpmmiSort | ( | rpmmi | mi | ) |
Sort iterator instances.
mi | rpm database iterator |
Definition at line 2420 of file rpmdb.c.
References hdrNumCmp(), i, rpmmi_s::mi_set, rpmmi_s::mi_sorted, and rpm_mergesort().
Referenced by rpmtsFindBaseNamesInDB().
|
static |
Definition at line 1248 of file rpmdb.c.
Referenced by dbiMireKeys().
|
static |
Restore signal mask.
db | rpm database |
oldMask | previous sigset |
Definition at line 564 of file rpmdb.c.
References rpmdbCheckSignals().
Referenced by miFreeHeader(), rpmdbAdd(), and rpmdbRemove().
rpmioPool _rpmdbPool |
Definition at line 773 of file rpmdb.c.
Referenced by rpmcliFini(), and rpmdbGetPool().
|
static |
Definition at line 2194 of file rpmdb.c.
Referenced by rpmmiGet(), and rpmmiNext().
rpmioPool _rpmmiPool |
Definition at line 1729 of file rpmdb.c.
Referenced by rpmcliFini(), and rpmmiGetPool().
|
static |
|
static |
Definition at line 471 of file rpmdb.c.
Referenced by rpmdbClose(), and rpmdbOpenDatabase().
|
static |
Definition at line 474 of file rpmdb.c.
Referenced by rpmmiFini(), and rpmmiInit().