Change iterator interface to use RPMTAG_FOO rather than RPMDBI_FOO.
CVS patchset: 3687 CVS date: 2000/04/19 22:15:02
This commit is contained in:
parent
dce2eccbd5
commit
f75d794af4
14
lib/db0.c
14
lib/db0.c
|
@ -599,8 +599,8 @@ static int db0open(dbiIndex dbi)
|
|||
DB_INFO * dbinfo = NULL;
|
||||
u_int32_t dbflags;
|
||||
|
||||
dbflags = ( !(dbi->dbi_flags & O_RDWR) ? DB_RDONLY :
|
||||
((dbi->dbi_flags & O_CREAT) ? DB_CREATE : 0));
|
||||
dbflags = ( !(dbi->dbi_mode & O_RDWR) ? DB_RDONLY :
|
||||
((dbi->dbi_mode & O_CREAT) ? DB_CREATE : 0));
|
||||
|
||||
rc = db_init(dbhome, dbflags, &dbenv, &dbinfo);
|
||||
dbi->dbi_dbenv = dbenv;
|
||||
|
@ -619,9 +619,9 @@ static int db0open(dbiIndex dbi)
|
|||
FD_t pkgs;
|
||||
|
||||
rpmMessage(RPMMESS_DEBUG, _("opening database mode 0x%x in %s\n"),
|
||||
dbi->dbi_flags, dbi->dbi_file);
|
||||
dbi->dbi_mode, dbi->dbi_file);
|
||||
|
||||
pkgs = fadOpen(dbi->dbi_file, dbi->dbi_flags, dbi->dbi_perms);
|
||||
pkgs = fadOpen(dbi->dbi_file, dbi->dbi_mode, dbi->dbi_perms);
|
||||
if (Ferror(pkgs)) {
|
||||
rpmError(RPMERR_DBOPEN, _("failed to open %s: %s\n"), dbi->dbi_file,
|
||||
Fstrerror(pkgs));
|
||||
|
@ -631,11 +631,11 @@ static int db0open(dbiIndex dbi)
|
|||
l.l_whence = 0;
|
||||
l.l_start = 0;
|
||||
l.l_len = 0;
|
||||
l.l_type = (dbi->dbi_flags & O_RDWR) ? F_WRLCK : F_RDLCK;
|
||||
l.l_type = (dbi->dbi_mode & O_RDWR) ? F_WRLCK : F_RDLCK;
|
||||
|
||||
if (Fcntl(pkgs, F_SETLK, (void *) &l)) {
|
||||
rpmError(RPMERR_FLOCK, _("cannot get %s lock on database"),
|
||||
((dbi->dbi_flags & O_RDWR) ? _("exclusive") : _("shared")));
|
||||
((dbi->dbi_mode & O_RDWR) ? _("exclusive") : _("shared")));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -644,7 +644,7 @@ static int db0open(dbiIndex dbi)
|
|||
} else {
|
||||
void * dbopeninfo = NULL;
|
||||
|
||||
dbi->dbi_db = dbopen(dbi->dbi_file, dbi->dbi_flags, dbi->dbi_perms,
|
||||
dbi->dbi_db = dbopen(dbi->dbi_file, dbi->dbi_mode, dbi->dbi_perms,
|
||||
dbi_to_dbtype(dbi->dbi_type), dbopeninfo);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -439,8 +439,8 @@ static int db1open(dbiIndex dbi)
|
|||
DB_INFO * dbinfo = NULL;
|
||||
u_int32_t dbflags;
|
||||
|
||||
dbflags = ( !(dbi->dbi_flags & O_RDWR) ? DB_RDONLY :
|
||||
((dbi->dbi_flags & O_CREAT) ? DB_CREATE : 0));
|
||||
dbflags = ( !(dbi->dbi_mode & O_RDWR) ? DB_RDONLY :
|
||||
((dbi->dbi_mode & O_CREAT) ? DB_CREATE : 0));
|
||||
|
||||
rc = db_init(dbhome, dbflags, &dbenv, &dbinfo);
|
||||
dbi->dbi_dbenv = dbenv;
|
||||
|
@ -454,7 +454,7 @@ static int db1open(dbiIndex dbi)
|
|||
dbi->dbi_db = NULL;
|
||||
#else
|
||||
void * dbopeninfo = NULL;
|
||||
dbi->dbi_db = dbopen(dbi->dbi_file, dbi->dbi_flags, dbi->dbi_perms,
|
||||
dbi->dbi_db = dbopen(dbi->dbi_file, dbi->dbi_mode, dbi->dbi_perms,
|
||||
dbi_to_dbtype(dbi->dbi_type), dbopeninfo);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -581,8 +581,8 @@ static int db2open(dbiIndex dbi)
|
|||
else
|
||||
dbfile = dbhome;
|
||||
|
||||
dbflags = ( !(dbi->dbi_flags & O_RDWR) ? DB_RDONLY :
|
||||
((dbi->dbi_flags & O_CREAT) ? DB_CREATE : 0));
|
||||
dbflags = ( !(dbi->dbi_mode & O_RDWR) ? DB_RDONLY :
|
||||
((dbi->dbi_mode & O_CREAT) ? DB_CREATE : 0));
|
||||
|
||||
rc = db_init(dbi, dbhome, dbflags, &dbenv, &dbinfo);
|
||||
|
||||
|
@ -612,7 +612,7 @@ static int db2open(dbiIndex dbi)
|
|||
|
||||
#else
|
||||
void * dbopeninfo = NULL;
|
||||
dbi->dbi_db = dbopen(dbfile, dbi->dbi_flags, dbi->dbi_perms,
|
||||
dbi->dbi_db = dbopen(dbfile, dbi->dbi_mode, dbi->dbi_perms,
|
||||
dbi_to_dbtype(dbi->dbi_type), dbopeninfo);
|
||||
#endif /* __USE_DB2 || __USE_DB3 */
|
||||
|
||||
|
|
27
lib/db3.c
27
lib/db3.c
|
@ -1,7 +1,7 @@
|
|||
#include "system.h"
|
||||
|
||||
static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
|
||||
static int _use_cursors = 0;
|
||||
static int __use_cursors = 0;
|
||||
static int __do_dbcursor_rmw = 0;
|
||||
|
||||
#include <db3/db.h>
|
||||
|
@ -479,7 +479,7 @@ static int db3SearchIndex(dbiIndex dbi, const void * str, size_t len,
|
|||
|
||||
#if defined(__USE_DB2) || defined(__USE_DB3)
|
||||
{ DB_TXN * txnid = NULL;
|
||||
if (!_use_cursors) {
|
||||
if (!__use_cursors) {
|
||||
int _printit;
|
||||
rc = db->get(db, txnid, &key, &data, 0);
|
||||
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
|
||||
|
@ -616,7 +616,7 @@ static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set)
|
|||
}
|
||||
|
||||
#if defined(__USE_DB2) || defined(__USE_DB3)
|
||||
if (!_use_cursors) {
|
||||
if (!__use_cursors) {
|
||||
rc = db->put(db, txnid, &key, &data, 0);
|
||||
rc = cvtdberr(dbi, "db->put", rc, _debug);
|
||||
} else {
|
||||
|
@ -638,7 +638,7 @@ static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set)
|
|||
} else {
|
||||
|
||||
#if defined(__USE_DB2) || defined(__USE_DB3)
|
||||
if (!_use_cursors) {
|
||||
if (!__use_cursors) {
|
||||
rc = db->del(db, txnid, &key, 0);
|
||||
rc = cvtdberr(dbi, "db->del", rc, _debug);
|
||||
} else {
|
||||
|
@ -648,7 +648,7 @@ static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set)
|
|||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = db3c_get(dbi, dbcursor, &key, &data, DB_RMW | DB_SET);
|
||||
rc = db3c_get(dbi, dbcursor, &key, &data, DB_SET);
|
||||
|
||||
/* XXX TODO: loop over duplicates */
|
||||
rc = db3c_del(dbi, dbcursor, 0);
|
||||
|
@ -881,8 +881,8 @@ static int db3open(dbiIndex dbi)
|
|||
else
|
||||
dbfile = dbhome;
|
||||
|
||||
dbflags = ( !(dbi->dbi_flags & O_RDWR) ? DB_RDONLY :
|
||||
((dbi->dbi_flags & O_CREAT) ? DB_CREATE : 0));
|
||||
dbflags = ( !(dbi->dbi_mode & O_RDWR) ? DB_RDONLY :
|
||||
((dbi->dbi_mode & O_CREAT) ? DB_CREATE : 0));
|
||||
|
||||
rc = db_init(dbi, dbhome, dbflags, &dbenv);
|
||||
dbi->dbi_dbinfo = NULL;
|
||||
|
@ -925,10 +925,17 @@ static int db3open(dbiIndex dbi)
|
|||
rc = cvtdberr(dbi, "db->set_dup_compare", rc, _debug);
|
||||
}
|
||||
dbi->dbi_dbinfo = NULL;
|
||||
rc = db->open(db, "packages.db3", dbfile, dbi_to_dbtype(dbi->dbi_type),
|
||||
dbflags, dbi->dbi_perms);
|
||||
#ifndef DYING /* XXX FIXME */
|
||||
rc = db->open(db, "packages.db3", dbfile,
|
||||
dbi_to_dbtype(dbi->dbi_type), dbflags, dbi->dbi_perms);
|
||||
#else
|
||||
rc = db->open(db, "packages.db3",
|
||||
(dbi->dbi_rpmtag ? tagName(dbi->dbi_rpmtag) : "Packages"),
|
||||
dbi_to_dbtype(dbi->dbi_type), dbflags, dbi->dbi_perms);
|
||||
#endif
|
||||
rc = cvtdberr(dbi, "db->open", rc, _debug);
|
||||
|
||||
__use_cursors = rpmExpandNumeric("%{_db3_use_cursors}");
|
||||
__do_dbcursor_rmw = rpmExpandNumeric("%{_db3_dbcursor_rmw}");
|
||||
if (__do_dbcursor_rmw) {
|
||||
DBC * dbcursor = NULL;
|
||||
|
@ -965,7 +972,7 @@ static int db3open(dbiIndex dbi)
|
|||
|
||||
#else /* __USE_DB2 || __USE_DB3 */
|
||||
void * dbopeninfo = NULL;
|
||||
dbi->dbi_db = dbopen(dbfile, dbi->dbi_flags, dbi->dbi_perms,
|
||||
dbi->dbi_db = dbopen(dbfile, dbi->dbi_mode, dbi->dbi_perms,
|
||||
dbi_to_dbtype(dbi->dbi_type), dbopeninfo);
|
||||
#endif /* __USE_DB2 || __USE_DB3 */
|
||||
|
||||
|
|
|
@ -647,7 +647,7 @@ int rpmtransAddPackage(rpmTransactionSet rpmdep, Header h, FD_t fd,
|
|||
{ rpmdbMatchIterator mi;
|
||||
Header h2;
|
||||
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMDBI_NAME, name, 0);
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMTAG_NAME, name, 0);
|
||||
while((h2 = rpmdbNextIterator(mi)) != NULL) {
|
||||
if (rpmVersionCompare(h, h2))
|
||||
removePackage(rpmdep, rpmdbGetIteratorOffset(mi), alNum);
|
||||
|
@ -677,7 +677,7 @@ int rpmtransAddPackage(rpmTransactionSet rpmdep, Header h, FD_t fd,
|
|||
{ rpmdbMatchIterator mi;
|
||||
Header h2;
|
||||
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMDBI_NAME, obsoletes[j], 0);
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMTAG_NAME, obsoletes[j], 0);
|
||||
while((h2 = rpmdbNextIterator(mi)) != NULL) {
|
||||
unsigned int recOffset = rpmdbGetIteratorOffset(mi);
|
||||
if (bsearch(&recOffset,
|
||||
|
@ -908,7 +908,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
|
|||
if (*keyName == '/') {
|
||||
/* keyFlags better be 0! */
|
||||
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMDBI_FILE, keyName, 0);
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMTAG_BASENAMES, keyName, 0);
|
||||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
unsigned int recOffset = rpmdbGetIteratorOffset(mi);
|
||||
if (bsearch(&recOffset,
|
||||
|
@ -925,7 +925,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
|
|||
}
|
||||
}
|
||||
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMDBI_PROVIDES, keyName, 0);
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMTAG_PROVIDENAME, keyName, 0);
|
||||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
unsigned int recOffset = rpmdbGetIteratorOffset(mi);
|
||||
if (bsearch(&recOffset,
|
||||
|
@ -943,7 +943,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
|
|||
}
|
||||
|
||||
#ifdef DYING
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMDBI_NAME, keyName, 0);
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMTAG_NAME, keyName, 0);
|
||||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
unsigned int recOffset = rpmdbGetIteratorOffset(mi);
|
||||
if (bsearch(&recOffset,
|
||||
|
@ -1156,7 +1156,7 @@ static int checkDependentPackages(rpmTransactionSet rpmdep,
|
|||
struct problemsSet * psp, const char * key)
|
||||
{
|
||||
rpmdbMatchIterator mi;
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMDBI_REQUIREDBY, key, 0);
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMTAG_REQUIRENAME, key, 0);
|
||||
return checkPackageSet(rpmdep, psp, key, mi);
|
||||
}
|
||||
|
||||
|
@ -1168,7 +1168,7 @@ static int checkDependentConflicts(rpmTransactionSet rpmdep,
|
|||
|
||||
if (rpmdep->db) { /* XXX is this necessary? */
|
||||
rpmdbMatchIterator mi;
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMDBI_CONFLICTS, key, 0);
|
||||
mi = rpmdbInitIterator(rpmdep->db, RPMTAG_CONFLICTNAME, key, 0);
|
||||
rc = checkPackageSet(rpmdep, psp, key, mi);
|
||||
}
|
||||
|
||||
|
|
|
@ -717,7 +717,7 @@ int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h,
|
|||
scriptArg += 1;
|
||||
|
||||
{ rpmdbMatchIterator mi;
|
||||
mi = rpmdbInitIterator(db, RPMDBI_NAME, name, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
|
||||
rpmdbSetIteratorVersion(mi, version);
|
||||
rpmdbSetIteratorRelease(mi, release);
|
||||
while (rpmdbNextIterator(mi)) {
|
||||
|
|
16
lib/query.c
16
lib/query.c
|
@ -576,7 +576,8 @@ int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg,
|
|||
} break;
|
||||
|
||||
case RPMQV_ALL:
|
||||
mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
|
||||
/* RPMDBI_PACKAGES */
|
||||
mi = rpmdbInitIterator(db, 0, NULL, 0);
|
||||
if (mi == NULL) {
|
||||
fprintf(stderr, _("no packages\n"));
|
||||
retcode = 1;
|
||||
|
@ -586,7 +587,7 @@ int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg,
|
|||
break;
|
||||
|
||||
case RPMQV_GROUP:
|
||||
mi = rpmdbInitIterator(db, RPMDBI_GROUP, arg, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_GROUP, arg, 0);
|
||||
if (mi == NULL) {
|
||||
fprintf(stderr, _("group %s does not contain any packages\n"), arg);
|
||||
retcode = 1;
|
||||
|
@ -596,7 +597,7 @@ int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg,
|
|||
break;
|
||||
|
||||
case RPMQV_TRIGGEREDBY:
|
||||
mi = rpmdbInitIterator(db, RPMDBI_TRIGGER, arg, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_TRIGGERNAME, arg, 0);
|
||||
if (mi == NULL) {
|
||||
fprintf(stderr, _("no package triggers %s\n"), arg);
|
||||
retcode = 1;
|
||||
|
@ -606,7 +607,7 @@ int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg,
|
|||
break;
|
||||
|
||||
case RPMQV_WHATREQUIRES:
|
||||
mi = rpmdbInitIterator(db, RPMDBI_REQUIREDBY, arg, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_REQUIRENAME, arg, 0);
|
||||
if (mi == NULL) {
|
||||
fprintf(stderr, _("no package requires %s\n"), arg);
|
||||
retcode = 1;
|
||||
|
@ -617,7 +618,7 @@ int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg,
|
|||
|
||||
case RPMQV_WHATPROVIDES:
|
||||
if (arg[0] != '/') {
|
||||
mi = rpmdbInitIterator(db, RPMDBI_PROVIDES, arg, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_PROVIDENAME, arg, 0);
|
||||
if (mi == NULL) {
|
||||
fprintf(stderr, _("no package provides %s\n"), arg);
|
||||
retcode = 1;
|
||||
|
@ -628,7 +629,7 @@ int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg,
|
|||
}
|
||||
/*@fallthrough@*/
|
||||
case RPMQV_PATH:
|
||||
mi = rpmdbInitIterator(db, RPMDBI_FILE, arg, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_BASENAMES, arg, 0);
|
||||
if (mi == NULL) {
|
||||
int myerrno = 0;
|
||||
if (access(arg, F_OK) != 0)
|
||||
|
@ -664,7 +665,8 @@ int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg,
|
|||
return 1;
|
||||
}
|
||||
rpmMessage(RPMMESS_DEBUG, _("package record number: %d\n"), recNumber);
|
||||
mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, &recNumber, sizeof(recNumber));
|
||||
/* RPMDBI_PACKAGES */
|
||||
mi = rpmdbInitIterator(db, 0, &recNumber, sizeof(recNumber));
|
||||
if (mi == NULL) {
|
||||
fprintf(stderr, _("record %d could not be read\n"), recNumber);
|
||||
retcode = 1;
|
||||
|
|
|
@ -99,7 +99,8 @@ fprintf(stderr, "*** rpmdbRebuild: filterdbdups %d preferdb %d\n", _filterDbDups
|
|||
rpmdbMatchIterator mi;
|
||||
#define _RECNUM rpmdbGetIteratorOffset(mi)
|
||||
|
||||
mi = rpmdbInitIterator(olddb, RPMDBI_PACKAGES, NULL, 0);
|
||||
/* RPMDBI_PACKAGES */
|
||||
mi = rpmdbInitIterator(olddb, 0, NULL, 0);
|
||||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
|
||||
/* let's sanity check this record a bit, otherwise just skip it */
|
||||
|
@ -122,7 +123,7 @@ fprintf(stderr, "*** rpmdbRebuild: filterdbdups %d preferdb %d\n", _filterDbDups
|
|||
headerNVR(h, &name, &version, &release);
|
||||
|
||||
{ rpmdbMatchIterator mi;
|
||||
mi = rpmdbInitIterator(newdb, RPMDBI_NAME, name, 0);
|
||||
mi = rpmdbInitIterator(newdb, RPMTAG_NAME, name, 0);
|
||||
rpmdbSetIteratorVersion(mi, version);
|
||||
rpmdbSetIteratorRelease(mi, release);
|
||||
while (rpmdbNextIterator(mi)) {
|
||||
|
|
223
lib/rpmdb.c
223
lib/rpmdb.c
|
@ -19,7 +19,8 @@ static int _debug = 0;
|
|||
#include "misc.h"
|
||||
|
||||
extern int _noDirTokens;
|
||||
extern int _useDbiMajor;
|
||||
|
||||
int _useDbiMajor = 3; /* XXX shared with rebuilddb.c */
|
||||
|
||||
#define _DBI_FLAGS 0
|
||||
#define _DBI_PERMS 0644
|
||||
|
@ -50,11 +51,36 @@ struct _dbiIndex rpmdbi[] = {
|
|||
{ "triggerindex.rpm", RPMTAG_TRIGGERNAME, 1*sizeof(int_32),
|
||||
DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
|
||||
{ "obsoletesindex.rpm", RPMTAG_OBSOLETENAME, 1*sizeof(int_32),
|
||||
DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
|
||||
{ "versionindex.rpm", RPMTAG_VERSION, 1*sizeof(int_32),
|
||||
DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
|
||||
{ "releaseindex.rpm", RPMTAG_RELEASE, 1*sizeof(int_32),
|
||||
DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
|
||||
{ NULL }
|
||||
#define RPMDBI_MIN 0
|
||||
#define RPMDBI_MAX 8
|
||||
#define RPMDBI_MAX 11
|
||||
};
|
||||
|
||||
/**
|
||||
* Return dbi index used for rpm tag.
|
||||
* @param rpmtag rpm header tag
|
||||
* @return dbi index, -1 on error
|
||||
*/
|
||||
static int dbiTagToDbix(int rpmtag)
|
||||
{
|
||||
int dbix;
|
||||
|
||||
for (dbix = RPMDBI_MIN; dbix < RPMDBI_MAX; dbix++) {
|
||||
if (rpmtag == rpmdbi[dbix].dbi_rpmtag)
|
||||
return dbix;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define dbiSyncIndex(_dbi) (*(_dbi)->dbi_vec->sync) ((_dbi), 0);
|
||||
|
||||
/**
|
||||
|
@ -243,35 +269,41 @@ static void freeDBI( /*@only@*/ /*@null@*/ dbiIndex dbi) {
|
|||
}
|
||||
}
|
||||
|
||||
int _useDbiMajor = 3; /* XXX shared with rebuilddb.c/rpmdb.c */
|
||||
|
||||
static struct _dbiVec *mydbvecs[] = {
|
||||
DB0vec, DB1vec, DB2vec, DB3vec, NULL
|
||||
};
|
||||
|
||||
/**
|
||||
* Return handle for an index database.
|
||||
* @param filename file name of database
|
||||
* @param flags type of open
|
||||
* @param dbiTemplate template to initialize new dbiIndex
|
||||
* @param rpmdb rpm database
|
||||
* @param dbix dbi template to use
|
||||
* @return index database handle
|
||||
*/
|
||||
static dbiIndex dbiOpenIndex(rpmdb rpmdb, const char * urlfn, int flags, const dbiIndex dbiTemplate)
|
||||
static int dbiOpenIndex(rpmdb rpmdb, int dbix)
|
||||
{
|
||||
dbiIndex dbi;
|
||||
const char * filename;
|
||||
dbiIndex dbiTemplate = rpmdbi + dbix;
|
||||
const char * urlfn;
|
||||
const char * filename = NULL;
|
||||
dbiIndex dbi = NULL;
|
||||
int rc = 0;
|
||||
|
||||
/* Is this index already open ? */
|
||||
if (rpmdb->_dbi[dbix])
|
||||
return 0;
|
||||
if (dbix < 0 || dbix >= RPMDBI_MAX)
|
||||
return 1;
|
||||
|
||||
urlfn = rpmGenPath(rpmdb->db_root, rpmdb->db_home, dbiTemplate->dbi_basename);
|
||||
(void) urlPath(urlfn, &filename);
|
||||
if (*filename == '\0') {
|
||||
if (!(filename && *filename != '\0')) {
|
||||
rpmError(RPMERR_DBOPEN, _("bad db file %s"), urlfn);
|
||||
return NULL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
dbi = newDBI(dbiTemplate);
|
||||
dbi->dbi_file = xstrdup(filename);
|
||||
dbi->dbi_flags = flags;
|
||||
dbi->dbi_major = _useDbiMajor;
|
||||
dbi->dbi_mode = rpmdb->db_mode;
|
||||
dbi->dbi_major = rpmdb->db_major;
|
||||
dbi->dbi_rpmdb = rpmdb;
|
||||
|
||||
switch (dbi->dbi_major) {
|
||||
|
@ -313,17 +345,25 @@ fprintf(stderr, "*** loop db%d rc %d errno %d %s\n", dbi->dbi_major, rc, errno,
|
|||
dbi->dbi_major--; /* XXX don't bother with db_185 */
|
||||
}
|
||||
}
|
||||
_useDbiMajor = dbi->dbi_major;
|
||||
if (rpmdb->db_major == -1)
|
||||
rpmdb->db_major = dbi->dbi_major;
|
||||
break;
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
if (rc == 0) {
|
||||
rpmdb->_dbi[dbix] = dbi;
|
||||
} else {
|
||||
rpmError(RPMERR_DBOPEN, _("cannot open file %s: %s"), urlfn, strerror(errno));
|
||||
freeDBI(dbi);
|
||||
dbi = NULL;
|
||||
}
|
||||
|
||||
return dbi;
|
||||
exit:
|
||||
if (urlfn) {
|
||||
xfree(urlfn);
|
||||
urlfn = NULL;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -454,6 +494,7 @@ static /*@only@*/ rpmdb newRpmdb(const char * root, const char * home,
|
|||
}
|
||||
if (db->db_errpfx)
|
||||
db->db_errpfx = xstrdup(db->db_errpfx);
|
||||
db->db_major = _useDbiMajor;
|
||||
db->db_ndbi = RPMDBI_MAX;
|
||||
return db;
|
||||
|
||||
|
@ -467,7 +508,7 @@ errxit:
|
|||
int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
|
||||
int mode, int perms, int flags)
|
||||
{
|
||||
rpmdb db;
|
||||
rpmdb rpmdb;
|
||||
int rc;
|
||||
int justCheck = flags & RPMDB_FLAG_JUSTCHECK;
|
||||
int minimal = flags & RPMDB_FLAG_MINIMAL;
|
||||
|
@ -477,29 +518,25 @@ int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
|
|||
if (mode & O_WRONLY)
|
||||
return 1;
|
||||
|
||||
db = newRpmdb(prefix, dbpath, mode, perms, flags);
|
||||
rpmdb = newRpmdb(prefix, dbpath, mode, perms, flags);
|
||||
|
||||
{ int dbix;
|
||||
|
||||
rc = 0;
|
||||
for (dbix = RPMDBI_MIN; rc == 0 && dbix < db->db_ndbi; dbix++) {
|
||||
dbiIndex dbiTemplate;
|
||||
for (dbix = RPMDBI_MIN; rc == 0 && dbix < RPMDBI_MAX; dbix++) {
|
||||
dbiIndex dbi;
|
||||
const char * filename;
|
||||
|
||||
dbiTemplate = rpmdbi + dbix;
|
||||
if (!justCheck)
|
||||
(void) dbiOpenIndex(rpmdb, dbix);
|
||||
|
||||
filename = rpmGenPath(db->db_root, db->db_home,
|
||||
dbiTemplate->dbi_basename);
|
||||
|
||||
if (!justCheck || !rpmfileexists(filename)) {
|
||||
db->_dbi[dbix] = dbiOpenIndex(db, filename, db->db_mode, dbiTemplate);
|
||||
}
|
||||
|
||||
if ((dbi = db->_dbi[dbix]) == NULL)
|
||||
if ((dbi = rpmdb->_dbi[dbix]) == NULL)
|
||||
continue;
|
||||
|
||||
switch (dbix) {
|
||||
case 0:
|
||||
if (rpmdb->db_major == 3)
|
||||
goto exit;
|
||||
break;
|
||||
case 1:
|
||||
if (minimal)
|
||||
goto exit;
|
||||
|
@ -535,9 +572,9 @@ int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
|
|||
|
||||
exit:
|
||||
if (!(rc || justCheck || dbp == NULL))
|
||||
*dbp = db;
|
||||
*dbp = rpmdb;
|
||||
else
|
||||
rpmdbClose(db);
|
||||
rpmdbClose(rpmdb);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -556,34 +593,38 @@ int rpmdbOpen (const char * prefix, rpmdb *dbp, int mode, int perms)
|
|||
|
||||
int rpmdbInit (const char * prefix, int perms)
|
||||
{
|
||||
rpmdb db;
|
||||
rpmdb rpmdb = NULL;
|
||||
int rc;
|
||||
|
||||
rc = openDatabase(prefix, NULL, &db, (O_CREAT | O_RDWR), perms, RPMDB_FLAG_JUSTCHECK);
|
||||
if (db) {
|
||||
rpmdbClose(db);
|
||||
db = NULL;
|
||||
rc = openDatabase(prefix, NULL, &rpmdb, (O_CREAT | O_RDWR), perms, RPMDB_FLAG_JUSTCHECK);
|
||||
if (rpmdb) {
|
||||
rpmdbClose(rpmdb);
|
||||
rpmdb = NULL;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* XXX depends.c, install.c, query.c, transaction.c, uninstall.c */
|
||||
Header rpmdbGetRecord(rpmdb db, unsigned int offset)
|
||||
Header rpmdbGetRecord(rpmdb rpmdb, unsigned int offset)
|
||||
{
|
||||
dbiIndex dbi = db->_dbi[RPMDBI_PACKAGES];
|
||||
int dbix;
|
||||
dbiIndex dbi;
|
||||
void * uh;
|
||||
size_t uhlen;
|
||||
void * keyp = &offset;
|
||||
size_t keylen = sizeof(offset);
|
||||
int rc;
|
||||
|
||||
dbix = 0; /* RPMDBI_PACKAGES */
|
||||
(void) dbiOpenIndex(rpmdb, dbix);
|
||||
dbi = rpmdb->_dbi[dbix];
|
||||
rc = (*dbi->dbi_vec->get) (dbi, keyp, keylen, &uh, &uhlen);
|
||||
if (rc)
|
||||
return NULL;
|
||||
return headerLoad(uh);
|
||||
}
|
||||
|
||||
static int rpmdbFindByFile(rpmdb db, const char * filespec,
|
||||
static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
|
||||
/*@out@*/ dbiIndexSet * matches)
|
||||
{
|
||||
const char * dirName;
|
||||
|
@ -592,6 +633,7 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
|
|||
fingerPrint fp1;
|
||||
dbiIndexSet allMatches = NULL;
|
||||
dbiIndexRecord rec = NULL;
|
||||
int dbix;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
|
@ -613,7 +655,8 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
|
|||
fpc = fpCacheCreate(20);
|
||||
fp1 = fpLookup(fpc, dirName, baseName, 1);
|
||||
|
||||
rc = dbiSearchIndex(db->_dbi[RPMDBI_FILE], baseName, 0, &allMatches);
|
||||
dbix = dbiTagToDbix(RPMTAG_BASENAMES);
|
||||
rc = dbiSearchIndex(rpmdb->_dbi[dbix], baseName, 0, &allMatches);
|
||||
if (rc) {
|
||||
dbiFreeIndexSet(allMatches);
|
||||
allMatches = NULL;
|
||||
|
@ -631,7 +674,7 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
|
|||
unsigned int prevoff;
|
||||
Header h;
|
||||
|
||||
if ((h = rpmdbGetRecord(db, offset)) == NULL) {
|
||||
if ((h = rpmdbGetRecord(rpmdb, offset)) == NULL) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
@ -686,12 +729,14 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
|
|||
}
|
||||
|
||||
/* XXX python/upgrade.c, install.c, uninstall.c */
|
||||
int rpmdbCountPackages(rpmdb db, const char * name)
|
||||
int rpmdbCountPackages(rpmdb rpmdb, const char * name)
|
||||
{
|
||||
dbiIndexSet matches = NULL;
|
||||
int dbix;
|
||||
int rc;
|
||||
|
||||
rc = dbiSearchIndex(db->_dbi[RPMDBI_NAME], name, 0, &matches);
|
||||
dbix = dbiTagToDbix(RPMTAG_NAME);
|
||||
rc = dbiSearchIndex(rpmdb->_dbi[dbix], name, 0, &matches);
|
||||
|
||||
switch (rc) {
|
||||
default:
|
||||
|
@ -717,7 +762,7 @@ int rpmdbCountPackages(rpmdb db, const char * name)
|
|||
struct _rpmdbMatchIterator {
|
||||
const void * mi_key;
|
||||
size_t mi_keylen;
|
||||
rpmdb mi_db;
|
||||
rpmdb mi_rpmdb;
|
||||
dbiIndex mi_dbi;
|
||||
int mi_dbix;
|
||||
dbiIndexSet mi_set;
|
||||
|
@ -751,7 +796,8 @@ void rpmdbFreeIterator(rpmdbMatchIterator mi)
|
|||
dbiFreeIndexSet(mi->mi_set);
|
||||
mi->mi_set = NULL;
|
||||
} else {
|
||||
dbiIndex dbi = mi->mi_db->_dbi[RPMDBI_PACKAGES];
|
||||
int dbix = 0; /* RPMDBI_PACKAGES */
|
||||
dbiIndex dbi = mi->mi_rpmdb->_dbi[dbix];
|
||||
(void) (*dbi->dbi_vec->cclose) (dbi);
|
||||
}
|
||||
if (mi->mi_key) {
|
||||
|
@ -802,6 +848,7 @@ void rpmdbSetIteratorVersion(rpmdbMatchIterator mi, const char * version) {
|
|||
Header rpmdbNextIterator(rpmdbMatchIterator mi)
|
||||
{
|
||||
dbiIndex dbi;
|
||||
int dbix;
|
||||
void * uh;
|
||||
size_t uhlen;
|
||||
void * keyp;
|
||||
|
@ -811,7 +858,9 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi)
|
|||
if (mi == NULL)
|
||||
return NULL;
|
||||
|
||||
dbi = mi->mi_db->_dbi[RPMDBI_PACKAGES];
|
||||
dbix = 0; /* RPMDBI_PACKAGES */
|
||||
(void) dbiOpenIndex(mi->mi_rpmdb, dbix);
|
||||
dbi = mi->mi_rpmdb->_dbi[dbix];
|
||||
keyp = &mi->mi_offset;
|
||||
keylen = sizeof(mi->mi_offset);
|
||||
|
||||
|
@ -821,7 +870,7 @@ top:
|
|||
if (mi->mi_set) {
|
||||
if (!(mi->mi_setx < mi->mi_set->count))
|
||||
return NULL;
|
||||
if (mi->mi_dbix != RPMDBI_PACKAGES) {
|
||||
if (mi->mi_dbix != 0) { /* RPMDBI_PACKAGES */
|
||||
mi->mi_offset = dbiIndexRecordOffset(mi->mi_set, mi->mi_setx);
|
||||
mi->mi_filenum = dbiIndexRecordFileNumber(mi->mi_set, mi->mi_setx);
|
||||
}
|
||||
|
@ -907,7 +956,7 @@ static int rpmdbGrowIterator(rpmdbMatchIterator mi,
|
|||
if (!(mi && key))
|
||||
return 1;
|
||||
|
||||
dbi = mi->mi_db->_dbi[mi->mi_dbix];
|
||||
dbi = mi->mi_rpmdb->_dbi[mi->mi_dbix];
|
||||
|
||||
if (keylen == 0)
|
||||
keylen = strlen(key);
|
||||
|
@ -941,18 +990,24 @@ static int rpmdbGrowIterator(rpmdbMatchIterator mi,
|
|||
return rc;
|
||||
}
|
||||
|
||||
rpmdbMatchIterator rpmdbInitIterator(rpmdb db, int dbix, const void * key, size_t keylen)
|
||||
rpmdbMatchIterator rpmdbInitIterator(rpmdb rpmdb, int rpmtag,
|
||||
const void * key, size_t keylen)
|
||||
{
|
||||
rpmdbMatchIterator mi;
|
||||
dbiIndex dbi = NULL;
|
||||
rpmdbMatchIterator mi = NULL;
|
||||
dbiIndexSet set = NULL;
|
||||
dbiIndex dbi;
|
||||
int dbix = dbiTagToDbix(rpmtag);
|
||||
|
||||
dbi = db->_dbi[dbix];
|
||||
if (dbix < 0)
|
||||
return NULL;
|
||||
(void) dbiOpenIndex(rpmdb, dbix);
|
||||
if ((dbi = rpmdb->_dbi[dbix]) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (key) {
|
||||
int rc;
|
||||
if (dbix == RPMDBI_FILE) {
|
||||
rc = rpmdbFindByFile(db, key, &set);
|
||||
if (rpmtag == RPMTAG_BASENAMES) {
|
||||
rc = rpmdbFindByFile(rpmdb, key, &set);
|
||||
} else {
|
||||
rc = dbiSearchIndex(dbi, key, keylen, &set);
|
||||
}
|
||||
|
@ -985,7 +1040,7 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, int dbix, const void * key, size_
|
|||
mi->mi_key = NULL;
|
||||
mi->mi_keylen = 0;
|
||||
}
|
||||
mi->mi_db = db;
|
||||
mi->mi_rpmdb = rpmdb;
|
||||
mi->mi_dbi = dbi;
|
||||
|
||||
/* XXX falloc has dbi == NULL ) */
|
||||
|
@ -1046,11 +1101,11 @@ static inline int removeIndexEntry(dbiIndex dbi, const char * key, dbiIndexRecor
|
|||
}
|
||||
|
||||
/* XXX uninstall.c */
|
||||
int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant)
|
||||
int rpmdbRemove(rpmdb rpmdb, unsigned int offset, int tolerant)
|
||||
{
|
||||
Header h;
|
||||
|
||||
h = rpmdbGetRecord(db, offset);
|
||||
h = rpmdbGetRecord(rpmdb, offset);
|
||||
if (h == NULL) {
|
||||
rpmError(RPMERR_DBCORRUPT, _("rpmdbRemove: cannot read header at 0x%x"),
|
||||
offset);
|
||||
|
@ -1067,13 +1122,15 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant)
|
|||
{ int dbix;
|
||||
dbiIndexRecord rec = dbiReturnIndexRecordInstance(offset, 0);
|
||||
|
||||
for (dbix = RPMDBI_MIN; dbix < db->db_ndbi; dbix++) {
|
||||
for (dbix = RPMDBI_MIN; dbix < rpmdb->db_ndbi; dbix++) {
|
||||
dbiIndex dbi;
|
||||
const char **rpmvals = NULL;
|
||||
int rpmtype = 0;
|
||||
int rpmcnt = 0;
|
||||
|
||||
dbi = db->_dbi[dbix];
|
||||
/* XXX FIXME: this forces all indices open */
|
||||
(void) dbiOpenIndex(rpmdb, dbix);
|
||||
dbi = rpmdb->_dbi[dbix];
|
||||
|
||||
if (dbi->dbi_rpmtag == 0) {
|
||||
(void) (*dbi->dbi_vec->del) (dbi, &offset, sizeof(offset));
|
||||
|
@ -1186,12 +1243,13 @@ static inline int addIndexEntry(dbiIndex dbi, const char *index, dbiIndexRecord
|
|||
}
|
||||
|
||||
/* XXX install.c, rebuilddb.c */
|
||||
int rpmdbAdd(rpmdb db, Header h)
|
||||
int rpmdbAdd(rpmdb rpmdb, Header h)
|
||||
{
|
||||
const char ** baseNames;
|
||||
int count = 0;
|
||||
int type;
|
||||
dbiIndex dbi;
|
||||
int dbix;
|
||||
unsigned int offset;
|
||||
int rc = 0;
|
||||
|
||||
|
@ -1216,7 +1274,9 @@ int rpmdbAdd(rpmdb db, Header h)
|
|||
size_t datalen = 0;
|
||||
int rc;
|
||||
|
||||
dbi = db->_dbi[RPMDBI_PACKAGES];
|
||||
dbix = 0; /* RPMDBI_PACKAGES */
|
||||
(void) dbiOpenIndex(rpmdb, dbix);
|
||||
dbi = rpmdb->_dbi[dbix];
|
||||
|
||||
/* XXX hack to pass sizeof header to fadAlloc */
|
||||
datap = h;
|
||||
|
@ -1248,15 +1308,16 @@ int rpmdbAdd(rpmdb db, Header h)
|
|||
|
||||
/* Now update the indexes */
|
||||
|
||||
{ int dbix;
|
||||
dbiIndexRecord rec = dbiReturnIndexRecordInstance(offset, 0);
|
||||
{ dbiIndexRecord rec = dbiReturnIndexRecordInstance(offset, 0);
|
||||
|
||||
for (dbix = RPMDBI_MIN; dbix < db->db_ndbi; dbix++) {
|
||||
for (dbix = RPMDBI_MIN; dbix < rpmdb->db_ndbi; dbix++) {
|
||||
const char **rpmvals = NULL;
|
||||
int rpmtype = 0;
|
||||
int rpmcnt = 0;
|
||||
|
||||
dbi = db->_dbi[dbix];
|
||||
/* XXX FIXME: this forces all indices open */
|
||||
(void) dbiOpenIndex(rpmdb, dbix);
|
||||
dbi = rpmdb->_dbi[dbix];
|
||||
|
||||
if (dbi->dbi_rpmtag == 0) {
|
||||
size_t uhlen = headerSizeof(h, HEADER_MAGIC_NO);
|
||||
|
@ -1363,14 +1424,14 @@ exit:
|
|||
}
|
||||
|
||||
/* XXX install.c */
|
||||
int rpmdbUpdateRecord(rpmdb db, int offset, Header newHeader)
|
||||
int rpmdbUpdateRecord(rpmdb rpmdb, int offset, Header newHeader)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (rpmdbRemove(db, offset, 1))
|
||||
if (rpmdbRemove(rpmdb, offset, 1))
|
||||
return 1;
|
||||
|
||||
if (rpmdbAdd(db, newHeader))
|
||||
if (rpmdbAdd(rpmdb, newHeader))
|
||||
return 1;
|
||||
|
||||
return rc;
|
||||
|
@ -1498,7 +1559,7 @@ int rpmdbMoveDatabase(const char * rootdir, const char * olddbpath, const char *
|
|||
}
|
||||
|
||||
/* XXX transaction.c */
|
||||
int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList,
|
||||
int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList,
|
||||
int numItems)
|
||||
{
|
||||
rpmdbMatchIterator mi;
|
||||
|
@ -1506,7 +1567,7 @@ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList,
|
|||
Header h;
|
||||
int i;
|
||||
|
||||
mi = rpmdbInitIterator(db, RPMDBI_FILE, NULL, 0);
|
||||
mi = rpmdbInitIterator(rpmdb, RPMTAG_BASENAMES, NULL, 0);
|
||||
|
||||
/* Gather all matches from the database */
|
||||
for (i = 0; i < numItems; i++) {
|
||||
|
@ -1591,14 +1652,18 @@ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList,
|
|||
/* 0 found matches */
|
||||
/* 1 no matches */
|
||||
/* 2 error */
|
||||
int findMatches(rpmdb db, const char * name, const char * version,
|
||||
int findMatches(rpmdb rpmdb, const char * name, const char * version,
|
||||
const char * release, dbiIndexSet * matches)
|
||||
{
|
||||
int dbix;
|
||||
int gotMatches;
|
||||
int rc;
|
||||
int i;
|
||||
|
||||
if ((rc = dbiSearchIndex(db->_dbi[RPMDBI_NAME], name, 0, matches)) != 0) {
|
||||
dbix = dbiTagToDbix(RPMTAG_NAME);
|
||||
(void) dbiOpenIndex(rpmdb, dbix);
|
||||
rc = dbiSearchIndex(rpmdb->_dbi[dbix], name, 0, matches);
|
||||
if (rc != 0) {
|
||||
rc = ((rc == -1) ? 2 : 1);
|
||||
goto exit;
|
||||
}
|
||||
|
@ -1621,7 +1686,7 @@ int findMatches(rpmdb db, const char * name, const char * version,
|
|||
if (recoff == 0)
|
||||
continue;
|
||||
|
||||
h = rpmdbGetRecord(db, recoff);
|
||||
h = rpmdbGetRecord(rpmdb, recoff);
|
||||
if (h == NULL) {
|
||||
rpmError(RPMERR_DBCORRUPT,_("cannot read header at %d for lookup"),
|
||||
recoff);
|
||||
|
@ -1662,7 +1727,7 @@ exit:
|
|||
/* 0 found matches */
|
||||
/* 1 no matches */
|
||||
/* 2 error */
|
||||
int rpmdbFindByLabel(rpmdb db, const char * arg, dbiIndexSet * matches)
|
||||
int rpmdbFindByLabel(rpmdb rpmdb, const char * arg, dbiIndexSet * matches)
|
||||
{
|
||||
char * localarg, * chptr;
|
||||
char * release;
|
||||
|
@ -1671,7 +1736,7 @@ int rpmdbFindByLabel(rpmdb db, const char * arg, dbiIndexSet * matches)
|
|||
if (!strlen(arg)) return 1;
|
||||
|
||||
/* did they give us just a name? */
|
||||
rc = findMatches(db, arg, NULL, NULL, matches);
|
||||
rc = findMatches(rpmdb, arg, NULL, NULL, matches);
|
||||
if (rc != 1) return rc;
|
||||
|
||||
/* maybe a name and a release */
|
||||
|
@ -1683,7 +1748,7 @@ int rpmdbFindByLabel(rpmdb db, const char * arg, dbiIndexSet * matches)
|
|||
if (chptr == localarg) return 1;
|
||||
|
||||
*chptr = '\0';
|
||||
rc = findMatches(db, localarg, chptr + 1, NULL, matches);
|
||||
rc = findMatches(rpmdb, localarg, chptr + 1, NULL, matches);
|
||||
if (rc != 1) return rc;
|
||||
|
||||
/* how about name-version-release? */
|
||||
|
@ -1693,5 +1758,5 @@ int rpmdbFindByLabel(rpmdb db, const char * arg, dbiIndexSet * matches)
|
|||
if (chptr == localarg) return 1;
|
||||
|
||||
*chptr = '\0';
|
||||
return findMatches(db, localarg, chptr + 1, release, matches);
|
||||
return findMatches(rpmdb, localarg, chptr + 1, release, matches);
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ struct _dbiIndex {
|
|||
int dbi_jlen; /*<! size of join key */
|
||||
|
||||
DBI_TYPE dbi_type; /*<! type of access */
|
||||
int dbi_flags; /*<! flags to use on open */
|
||||
int dbi_mode; /*<! mode to use on open */
|
||||
int dbi_perms; /*<! file permission to use on open */
|
||||
int dbi_major; /*<! Berkeley db version major */
|
||||
|
||||
|
|
|
@ -439,14 +439,6 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi);
|
|||
*/
|
||||
/*@only@*/ /*@null@*/ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, int dbix,
|
||||
const void * key, size_t keylen);
|
||||
#define RPMDBI_PACKAGES 0
|
||||
#define RPMDBI_NAME 1
|
||||
#define RPMDBI_FILE 2
|
||||
#define RPMDBI_GROUP 3
|
||||
#define RPMDBI_REQUIREDBY 4
|
||||
#define RPMDBI_PROVIDES 5
|
||||
#define RPMDBI_CONFLICTS 6
|
||||
#define RPMDBI_TRIGGER 7
|
||||
|
||||
/* we pass these around as an array with a sentinel */
|
||||
typedef struct rpmRelocation_s {
|
||||
|
|
|
@ -1278,7 +1278,7 @@ int rpmRunTransactions(rpmTransactionSet ts, rpmCallbackFunction notify,
|
|||
if (!(ignoreSet & RPMPROB_FILTER_OLDPACKAGE)) {
|
||||
rpmdbMatchIterator mi;
|
||||
Header oldH;
|
||||
mi = rpmdbInitIterator(ts->db, RPMDBI_NAME, alp->name, 0);
|
||||
mi = rpmdbInitIterator(ts->db, RPMTAG_NAME, alp->name, 0);
|
||||
while ((oldH = rpmdbNextIterator(mi)) != NULL)
|
||||
ensureOlder(ts->db, alp->h, oldH, probs, alp->key);
|
||||
rpmdbFreeIterator(mi);
|
||||
|
|
|
@ -537,7 +537,7 @@ int runTriggers(const char * root, rpmdb db, int sense, Header h,
|
|||
{ Header triggeredH;
|
||||
rpmdbMatchIterator mi;
|
||||
|
||||
mi = rpmdbInitIterator(db, RPMDBI_TRIGGER, name, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_TRIGGERNAME, name, 0);
|
||||
while((triggeredH = rpmdbNextIterator(mi)) != NULL) {
|
||||
rc |= handleOneTrigger(root, db, sense, h, triggeredH, 0, numPackage,
|
||||
NULL, scriptFd);
|
||||
|
@ -577,7 +577,7 @@ int runImmedTriggers(const char * root, rpmdb db, int sense, Header h,
|
|||
|
||||
if (triggersRun[triggerIndices[i]]) continue;
|
||||
|
||||
mi = rpmdbInitIterator(db, RPMDBI_NAME, name, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
|
||||
|
||||
while((sourceH = rpmdbNextIterator(mi)) != NULL) {
|
||||
rc |= handleOneTrigger(root, db, sense, sourceH, h,
|
||||
|
|
114
po/rpm.pot
114
po/rpm.pot
|
@ -6,7 +6,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2000-04-19 09:49-0400\n"
|
||||
"POT-Creation-Date: 2000-04-19 18:07-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -2553,130 +2553,130 @@ msgstr ""
|
|||
msgid "query of specfile %s failed, can't parse\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:581
|
||||
#: lib/query.c:582
|
||||
msgid "no packages\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:591
|
||||
#: lib/query.c:592
|
||||
#, c-format
|
||||
msgid "group %s does not contain any packages\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:601
|
||||
#: lib/query.c:602
|
||||
#, c-format
|
||||
msgid "no package triggers %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:611
|
||||
#: lib/query.c:612
|
||||
#, c-format
|
||||
msgid "no package requires %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:622
|
||||
#: lib/query.c:623
|
||||
#, c-format
|
||||
msgid "no package provides %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:638
|
||||
#: lib/query.c:639
|
||||
#, c-format
|
||||
msgid "file %s: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:641
|
||||
#: lib/query.c:642
|
||||
#, c-format
|
||||
msgid "file %s is not owned by any package\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:663
|
||||
#: lib/query.c:664
|
||||
#, c-format
|
||||
msgid "invalid package number: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:666
|
||||
#: lib/query.c:667
|
||||
#, c-format
|
||||
msgid "package record number: %d\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:669
|
||||
#: lib/query.c:671
|
||||
#, c-format
|
||||
msgid "record %d could not be read\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:680 lib/rpminstall.c:436
|
||||
#: lib/query.c:682 lib/rpminstall.c:436
|
||||
#, c-format
|
||||
msgid "package %s is not installed\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:683
|
||||
#: lib/query.c:685
|
||||
#, c-format
|
||||
msgid "error looking for package %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:708
|
||||
#: lib/query.c:710
|
||||
msgid "rpmQuery: rpmdbOpen() failed\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:767
|
||||
#: lib/query.c:769
|
||||
msgid "query package owning file"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:769
|
||||
#: lib/query.c:771
|
||||
msgid "query packages in group"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:771
|
||||
#: lib/query.c:773
|
||||
msgid "query a package file"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:775
|
||||
#: lib/query.c:777
|
||||
msgid "query a spec file"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:777
|
||||
#: lib/query.c:779
|
||||
msgid "query the pacakges triggered by the package"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:779
|
||||
#: lib/query.c:781
|
||||
msgid "query the packages which require a capability"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:781
|
||||
#: lib/query.c:783
|
||||
msgid "query the packages which provide a capability"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:820
|
||||
#: lib/query.c:822
|
||||
msgid "list all configuration files"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:822
|
||||
#: lib/query.c:824
|
||||
msgid "list all documentation files"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:824
|
||||
#: lib/query.c:826
|
||||
msgid "dump basic file information"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:826
|
||||
#: lib/query.c:828
|
||||
msgid "list files in package"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:830
|
||||
#: lib/query.c:832
|
||||
msgid "use the following query format"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:832
|
||||
#: lib/query.c:834
|
||||
msgid "substitute i18n sections into spec file"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:834
|
||||
#: lib/query.c:836
|
||||
msgid "display the states of the listed files"
|
||||
msgstr ""
|
||||
|
||||
#: lib/query.c:836
|
||||
#: lib/query.c:838
|
||||
msgid "display a verbose file listing"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rebuilddb.c:34 lib/rpmdb.c:451
|
||||
#: lib/rebuilddb.c:34 lib/rpmdb.c:491
|
||||
msgid "no dbpath has been set"
|
||||
msgstr ""
|
||||
|
||||
|
@ -2710,30 +2710,30 @@ msgstr ""
|
|||
msgid "opening new database with dbi_major %d\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rebuilddb.c:112
|
||||
#: lib/rebuilddb.c:113
|
||||
#, c-format
|
||||
msgid "record number %d in database is bad -- skipping."
|
||||
msgstr ""
|
||||
|
||||
#: lib/rebuilddb.c:144
|
||||
#: lib/rebuilddb.c:145
|
||||
#, c-format
|
||||
msgid "cannot add record originally at %d"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rebuilddb.c:160
|
||||
#: lib/rebuilddb.c:161
|
||||
msgid "failed to rebuild database; original database remains in place\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rebuilddb.c:168
|
||||
#: lib/rebuilddb.c:169
|
||||
msgid "failed to replace old database with new database!\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rebuilddb.c:170
|
||||
#: lib/rebuilddb.c:171
|
||||
#, c-format
|
||||
msgid "replace files in %s with files from %s to recover"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rebuilddb.c:176
|
||||
#: lib/rebuilddb.c:177
|
||||
#, c-format
|
||||
msgid "failed to remove directory %s: %s\n"
|
||||
msgstr ""
|
||||
|
@ -2821,27 +2821,27 @@ msgstr ""
|
|||
msgid "OK"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:89
|
||||
#: lib/rpmdb.c:115
|
||||
#, c-format
|
||||
msgid "error getting record %s from %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:110
|
||||
#: lib/rpmdb.c:136
|
||||
#, c-format
|
||||
msgid "error storing record %s into %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:115
|
||||
#: lib/rpmdb.c:141
|
||||
#, c-format
|
||||
msgid "error removing record %s into %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:267
|
||||
#: lib/rpmdb.c:299
|
||||
#, c-format
|
||||
msgid "bad db file %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:308
|
||||
#: lib/rpmdb.c:340
|
||||
msgid ""
|
||||
"\n"
|
||||
"--> Please run \"rpm --rebuilddb\" as root to convert your database from\n"
|
||||
|
@ -2849,83 +2849,83 @@ msgid ""
|
|||
"\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:321
|
||||
#: lib/rpmdb.c:356
|
||||
#, c-format
|
||||
msgid "cannot open file %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:523
|
||||
#: lib/rpmdb.c:560
|
||||
msgid ""
|
||||
"old format database is present; use --rebuilddb to generate a new format "
|
||||
"database"
|
||||
msgstr ""
|
||||
|
||||
#. error
|
||||
#: lib/rpmdb.c:699
|
||||
#: lib/rpmdb.c:744
|
||||
#, c-format
|
||||
msgid "cannot retrieve package \"%s\" from db"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1021
|
||||
#: lib/rpmdb.c:1076
|
||||
#, c-format
|
||||
msgid "key \"%s\" not found in %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1029
|
||||
#: lib/rpmdb.c:1084
|
||||
#, c-format
|
||||
msgid "key \"%s\" not removed from %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1055
|
||||
#: lib/rpmdb.c:1110
|
||||
#, c-format
|
||||
msgid "rpmdbRemove: cannot read header at 0x%x"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1086
|
||||
#: lib/rpmdb.c:1143
|
||||
#, c-format
|
||||
msgid "removing 0 %s entries.\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1093
|
||||
#: lib/rpmdb.c:1150
|
||||
#, c-format
|
||||
msgid "removing \"%s\" from %s index.\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1101
|
||||
#: lib/rpmdb.c:1158
|
||||
#, c-format
|
||||
msgid "removing %d entries in %s index:\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1105
|
||||
#: lib/rpmdb.c:1162
|
||||
#, c-format
|
||||
msgid "\t%6d %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1245
|
||||
#: lib/rpmdb.c:1305
|
||||
msgid "cannot allocate new instance in database"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1291
|
||||
#: lib/rpmdb.c:1352
|
||||
#, c-format
|
||||
msgid "adding 0 %s entries.\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1304
|
||||
#: lib/rpmdb.c:1365
|
||||
#, c-format
|
||||
msgid "adding \"%s\" to %s index.\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1311
|
||||
#: lib/rpmdb.c:1372
|
||||
#, c-format
|
||||
msgid "adding %d entries to %s index:\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1315
|
||||
#: lib/rpmdb.c:1376
|
||||
#, c-format
|
||||
msgid "%6d %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:1626
|
||||
#: lib/rpmdb.c:1691
|
||||
#, c-format
|
||||
msgid "cannot read header at %d for lookup"
|
||||
msgstr ""
|
||||
|
|
|
@ -856,7 +856,7 @@ static PyObject * rpmdbByName(rpmdbObject * s, PyObject * args) {
|
|||
return handleDbResult(rc, matches);
|
||||
}
|
||||
#else
|
||||
return handleDbResult(rpmdbInitIterator(s->db, RPMDBI_NAME, str, 0));
|
||||
return handleDbResult(rpmdbInitIterator(s->db, RPMTAG_NAME, str, 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -872,7 +872,7 @@ static PyObject * rpmdbByFile(rpmdbObject * s, PyObject * args) {
|
|||
return handleDbResult(rc, matches);
|
||||
}
|
||||
#else
|
||||
return handleDbResult(rpmdbInitIterator(s->db, RPMDBI_FILE, str, 0));
|
||||
return handleDbResult(rpmdbInitIterator(s->db, RPMTAG_BASENAMES, str, 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -888,7 +888,7 @@ static PyObject * rpmdbByProvides(rpmdbObject * s, PyObject * args) {
|
|||
return handleDbResult(rc, matches);
|
||||
}
|
||||
#else
|
||||
return handleDbResult(rpmdbInitIterator(s->db, RPMDBI_PROVIDES, str, 0));
|
||||
return handleDbResult(rpmdbInitIterator(s->db, RPMTAG_PROVIDENAME, str, 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -908,7 +908,8 @@ static int rpmdbLength(rpmdbObject * s) {
|
|||
#else
|
||||
{ rpmdbMatchIterator mi;
|
||||
|
||||
mi = rpmdbInitIterator(s->db, RPMDBI_PACKAGES, NULL, 0);
|
||||
/* RPMDBI_PACKAGES */
|
||||
mi = rpmdbInitIterator(s->db, 0, NULL, 0);
|
||||
/* XXX FIXME: unnecessary header mallocs are side effect here */
|
||||
while (rpmdbNextIterator(mi) != NULL)
|
||||
count++;
|
||||
|
|
|
@ -122,7 +122,8 @@ static void addLostFiles(rpmdb db, struct pkgSet *psp, struct hash_table *ht)
|
|||
#else
|
||||
rpmdbMatchIterator mi;
|
||||
|
||||
mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
|
||||
/* RPMDBI_PACKAGES */
|
||||
mi = rpmdbInitIterator(db, 0, NULL, 0);
|
||||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
#endif
|
||||
|
||||
|
@ -277,7 +278,7 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
|
|||
#else
|
||||
{ rpmdbMatchIterator mi;
|
||||
|
||||
mi = rpmdbInitIterator(db, RPMDBI_NAME, name, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
|
||||
skipThis = (mi ? 0 : 1);
|
||||
rpmErrorSetCallback(errorFunction);
|
||||
while((installedHeader = rpmdbNextIterator(mi)) != NULL) {
|
||||
|
@ -339,7 +340,7 @@ static int findUpgradePackages(rpmdb db, struct pkgSet *psp,
|
|||
}
|
||||
#else
|
||||
{ rpmdbMatchIterator mi;
|
||||
mi = rpmdbInitIterator(db, RPMDBI_NAME, name, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
|
||||
while((installedHeader = rpmdbNextIterator(mi)) != NULL) {
|
||||
if (headerGetEntryMinMemory(installedHeader, RPMTAG_BASENAMES,
|
||||
NULL, (void **) &installedFiles,
|
||||
|
@ -551,7 +552,7 @@ static int unmarkPackagesAlreadyInstalled(rpmdb db, struct pkgSet *psp)
|
|||
#else
|
||||
{ rpmdbMatchIterator mi;
|
||||
|
||||
mi = rpmdbInitIterator(db, RPMDBI_NAME, name, 0);
|
||||
mi = rpmdbInitIterator(db, RPMTAG_NAME, name, 0);
|
||||
rpmErrorSetCallback(errorFunction);
|
||||
while((installedHeader = rpmdbNextIterator(mi)) != NULL) {
|
||||
if (rpmVersionCompare(installedHeader, h) >= 0) {
|
||||
|
|
|
@ -27,7 +27,8 @@ int main(int argc, char ** argv)
|
|||
rpmdbMatchIterator mi;
|
||||
#define _RECNUM rpmdbGetIteratorOffset(mi)
|
||||
|
||||
mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
|
||||
/* RPMDBI_PACKAGES */
|
||||
mi = rpmdbInitIterator(db, 0, NULL, 0);
|
||||
|
||||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue