CVS patchset: 3697
CVS date: 2000/04/25 19:41:37
This commit is contained in:
jbj 2000-04-25 19:41:37 +00:00
parent 76e42fa65b
commit 9c0c7e9fbd
12 changed files with 915 additions and 766 deletions

View File

@ -35,7 +35,7 @@ falloc.lo: falloc.c $(top_srcdir)/system.h rpmio.h falloc.h
db3.lo: db3.c $(top_srcdir)/system.h rpmlib.h rpmdb.h db3.lo: db3.c $(top_srcdir)/system.h rpmlib.h rpmdb.h
$(LIBTOOL) --mode=compile $(COMPILE) -c $< $(LIBTOOL) --mode=compile $(COMPILE) -c $<
for F in $*.o $*.lo ; do \ for F in $*.o $*.lo ; do \
@__LD@ -r -o $${F}.o $${F} -L/usr/lib -ldb-3.0 ; \ @__LD@ -r -o $${F}.o $${F} -L/usr/lib -ldb-3.0 -lpthread ; \
@__OBJCOPY@ `\ @__OBJCOPY@ `\
@__NM@ -g --defined-only $${F}.o | \ @__NM@ -g --defined-only $${F}.o | \
sed -e '/ [DRTW] /!d' -e 's/.* [DRTW] /-L /' | \ sed -e '/ [DRTW] /!d' -e 's/.* [DRTW] /-L /' | \

322
lib/db0.c
View File

@ -18,6 +18,7 @@ static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
#include "falloc.h" #include "falloc.h"
#include "misc.h" #include "misc.h"
#define DBC void
#include "rpmdb.h" #include "rpmdb.h"
/*@access dbiIndex@*/ /*@access dbiIndex@*/
/*@access dbiIndexSet@*/ /*@access dbiIndexSet@*/
@ -77,55 +78,11 @@ static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit) {
return rc; return rc;
} }
#if defined(__USE_DB2)
static int db_init(const char *home, int dbflags,
DB_ENV **dbenvp, DB_INFO **dbinfop)
{
DB_ENV *dbenv = xcalloc(1, sizeof(*dbenv));
DB_INFO *dbinfo = xcalloc(1, sizeof(*dbinfo));
int rc;
if (dbenvp) *dbenvp = NULL;
if (dbinfop) *dbinfop = NULL;
dbenv->db_errfile = stderr;
dbenv->db_errpfx = "rpmdb";
dbenv->mp_size = 1024 * 1024;
rc = db_appinit(home, NULL, dbenv, dbflags);
if (rc)
goto errxit;
dbinfo->db_pagesize = 1024;
if (dbenvp)
*dbenvp = dbenv;
else
free(dbenv);
if (dbinfop)
*dbinfop = dbinfo;
else
free(dbinfo);
return 0;
errxit:
if (dbenv) free(dbenv);
if (dbinfo) free(dbinfo);
return rc;
}
#endif
static int db0sync(dbiIndex dbi, unsigned int flags) { static int db0sync(dbiIndex dbi, unsigned int flags) {
DB * db = GetDB(dbi); DB * db = GetDB(dbi);
int rc; int rc;
#if defined(__USE_DB2)
rc = db->sync(db, flags); rc = db->sync(db, flags);
#else
rc = db->sync(db, flags);
#endif
switch (rc) { switch (rc) {
default: default:
@ -143,6 +100,11 @@ static int db0sync(dbiIndex dbi, unsigned int flags) {
return rc; return rc;
} }
static int db0byteswapped(dbiIndex dbi)
{
return 0;
}
static int db0SearchIndex(dbiIndex dbi, const void * str, size_t len, static int db0SearchIndex(dbiIndex dbi, const void * str, size_t len,
dbiIndexSet * set) dbiIndexSet * set)
{ {
@ -160,11 +122,7 @@ static int db0SearchIndex(dbiIndex dbi, const void * str, size_t len,
data.data = NULL; data.data = NULL;
data.size = 0; data.size = 0;
#if defined(__USE_DB2)
rc = db->get(db, NULL, &key, &data, 0);
#else
rc = db->get(db, &key, &data, 0); rc = db->get(db, &key, &data, 0);
#endif
switch (rc) { switch (rc) {
default: default:
@ -231,11 +189,7 @@ static int db0UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) {
data.data = dbir; data.data = dbir;
data.size = set->count * sizeof(*dbir); data.size = set->count * sizeof(*dbir);
#if defined(__USE_DB2)
rc = db->put(db, NULL, &key, &data, 0);
#else
rc = db->put(db, &key, &data, 0); rc = db->put(db, &key, &data, 0);
#endif
switch (rc) { switch (rc) {
default: default:
@ -249,11 +203,7 @@ static int db0UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) {
} }
} else { } else {
#if defined(__USE_DB2)
rc = db->del(db, NULL, &key, 0);
#else
rc = db->del(db, &key, 0); rc = db->del(db, &key, 0);
#endif
switch (rc) { switch (rc) {
default: default:
@ -283,15 +233,19 @@ static void * doGetRecord(FD_t pkgs, unsigned int offset)
h = headerRead(pkgs, HEADER_MAGIC_NO); h = headerRead(pkgs, HEADER_MAGIC_NO);
if (h == NULL) return NULL; if (h == NULL)
goto exit;
/* the RPM used to build much of RH 5.1 could produce packages whose /*
file lists did not have leading /'s. Now is a good time to fix * The RPM used to build much of RH 5.1 could produce packages whose
that */ * file lists did not have leading /'s. Now is a good time to fix that.
*/
/* If this tag isn't present, either no files are in the package or /*
we're dealing with a package that has just the compressed file name * If this tag isn't present, either no files are in the package or
list */ * we're dealing with a package that has just the compressed file name
* list.
*/
if (!headerGetEntryMinMemory(h, RPMTAG_OLDFILENAMES, NULL, if (!headerGetEntryMinMemory(h, RPMTAG_OLDFILENAMES, NULL,
(void **) &fileNames, &fileCount)) goto exit; (void **) &fileNames, &fileCount)) goto exit;
@ -319,41 +273,29 @@ static void * doGetRecord(FD_t pkgs, unsigned int offset)
newFileNames, fileCount); newFileNames, fileCount);
} }
/* The file list was moved to a more compressed format which not /*
only saves memory (nice), but gives fingerprinting a nice, fat * The file list was moved to a more compressed format which not
speed boost (very nice). Go ahead and convert old headers to * only saves memory (nice), but gives fingerprinting a nice, fat
the new style (this is a noop for new headers) */ * speed boost (very nice). Go ahead and convert old headers to
* the new style (this is a noop for new headers).
*/
compressFilelist(h); compressFilelist(h);
exit: exit:
uh = headerUnload(h); if (h) {
headerFree(h); uh = headerUnload(h);
headerFree(h);
}
return uh; return uh;
} }
static int db0copen(dbiIndex dbi) { static int db0copen(dbiIndex dbi) {
int rc = 0; int rc = 0;
#if defined(__USE_DB2)
{ DBC * dbcursor = NULL;
rc = dbp->cursor(dbp, NULL, &dbcursor, 0);
if (rc == 0)
dbi->dbi_dbcursor = dbcursor;
}
#endif
dbi->dbi_lastoffset = 0;
return rc; return rc;
} }
static int db0cclose(dbiIndex dbi) { static int db0cclose(dbiIndex dbi) {
int rc = 0; int rc = 0;
#if defined(__USE_DB2)
#endif
dbi->dbi_lastoffset = 0;
return rc;
}
static int db0join(dbiIndex dbi) {
int rc = 1;
return rc; return rc;
} }
@ -361,72 +303,90 @@ static int db0cget(dbiIndex dbi, void ** keyp, size_t * keylen,
void ** datap, size_t * datalen) void ** datap, size_t * datalen)
{ {
DBT key, data; DBT key, data;
DB * db; int rc = 0;
int rc;
if (dbi == NULL) if (dbi == NULL)
return 1; return 1;
if (dbi->dbi_pkgs) { memset(&key, 0, sizeof(key));
if (dbi->dbi_lastoffset == 0) { memset(&data, 0, sizeof(data));
dbi->dbi_lastoffset = fadFirstOffset(dbi->dbi_pkgs); if (keyp) key.data = *keyp;
if (keylen) key.size = *keylen;
if (datap) data.data = *datap;
if (datalen) data.size = *datalen;
if (dbi->dbi_rpmtag == 0) {
unsigned int offset;
unsigned int newSize;
if (key.data == NULL) { /* XXX simulated DB_NEXT */
if (dbi->dbi_lastoffset == 0) {
dbi->dbi_lastoffset = fadFirstOffset(dbi->dbi_pkgs);
} else {
dbi->dbi_lastoffset = fadNextOffset(dbi->dbi_pkgs, dbi->dbi_lastoffset);
}
key.data = &dbi->dbi_lastoffset;
key.size = sizeof(dbi->dbi_lastoffset);
}
memcpy(&offset, key.data, sizeof(offset));
/* XXX hack to pass sizeof header to fadAlloc */
newSize = data.size;
if (offset == 0) { /* XXX simulated offset 0 record */
offset = fadAlloc(dbi->dbi_pkgs, newSize);
if (offset == 0)
return -1;
offset--; /* XXX hack: caller will increment */
/* XXX hack: return offset as data, free in db0cput */
data.data = xmalloc(sizeof(offset));
memcpy(data.data, &offset, sizeof(offset));
data.size = sizeof(offset);
} else { /* XXX simulated retrieval */
data.data = doGetRecord(dbi->dbi_pkgs, offset);
data.size = 0; /* XXX WRONG */
if (data.data == NULL)
rc = 1;
}
} else {
DB * db;
int _printit;
if ((db = dbi->dbi_db) == NULL)
return 1;
if (key.data == NULL) {
rc = db->seq(db, &key, &data, (dbi->dbi_lastoffset++ ? R_NEXT : R_FIRST));
_printit = (rc == 1 ? 0 : _debug);
rc = cvtdberr(dbi, "db->seq", rc, _printit);
} else { } else {
dbi->dbi_lastoffset = fadNextOffset(dbi->dbi_pkgs, dbi->dbi_lastoffset); rc = db->get(db, &key, &data, 0);
_printit = (rc == 1 ? 0 : _debug);
rc = cvtdberr(dbi, "db0cget", rc, _printit);
} }
if (keyp)
*keyp = &dbi->dbi_lastoffset;
if (keylen)
*keylen = sizeof(dbi->dbi_lastoffset);
return 0;
} }
if (dbi->dbi_db == NULL)
return 1;
db = GetDB(dbi);
_mymemset(&key, 0, sizeof(key));
_mymemset(&data, 0, sizeof(data));
key.data = NULL;
key.size = 0;
#if defined(__USE_DB2)
{ DBC * dbcursor;
if ((dbcursor = dbi->dbi_dbcursor) == NULL) {
rc = db2copen(dbi);
if (rc)
return rc;
dbcursor = dbi->dbi_dbcursor;
}
rc = dbcursor->c_get(dbcursor, &key, &data,
(dbi->dbi_lastoffset++ ? DB_NEXT : DB_FIRST));
if (rc == DB_NOTFOUND)
db2cclose(dbcursor)
}
#else
rc = db->seq(db, &key, &data, (dbi->dbi_lastoffset++ ? R_NEXT : R_FIRST));
#endif
switch (rc) { switch (rc) {
default: default:
case RET_ERROR: /* -1 */ case RET_ERROR: /* -1 */
rc = -1;
break;
case RET_SPECIAL: /* 1 */ case RET_SPECIAL: /* 1 */
rc = 1; rc = 1;
if (keyp)
*keyp = NULL;
break; break;
case RET_SUCCESS: /* 0 */ case RET_SUCCESS: /* 0 */
rc = 0; rc = 0;
if (keyp) if (keyp) *keyp = key.data;
*keyp = key.data; if (keylen) *keylen = key.size;
if (datap) *datap = data.data;
if (datalen) *datalen = data.size;
break; break;
} }
return rc; return rc;
} }
static int db0del(dbiIndex dbi, void * keyp, size_t keylen) static int db0cdel(dbiIndex dbi, void * keyp, size_t keylen)
{ {
int rc = 0; int rc = 0;
@ -450,80 +410,86 @@ static int db0del(dbiIndex dbi, void * keyp, size_t keylen)
return rc; return rc;
} }
#ifndef DYING
static int db0get(dbiIndex dbi, void * keyp, size_t keylen, static int db0get(dbiIndex dbi, void * keyp, size_t keylen,
void ** datap, size_t * datalen) void ** datap, size_t * datalen)
{ {
unsigned int newSize = 0; DBT key, data;
int rc = 0; int rc = 0;
if (datap) *datap = NULL; memset(&key, 0, sizeof(key));
if (datalen) { memset(&data, 0, sizeof(data));
/* XXX hack to pass sizeof header to fadAlloc */ if (keyp) key.data = keyp;
newSize = *datalen; if (keylen) key.size = keylen;
*datalen = 0; if (datap) data.data = *datap;
} if (datalen) data.size = *datalen;
if (dbi->dbi_rpmtag == 0) { if (dbi->dbi_rpmtag == 0) {
unsigned int offset; unsigned int offset;
unsigned int newSize;
memcpy(&offset, keyp, sizeof(offset)); memcpy(&offset, key.data, sizeof(offset));
/* XXX hack to pass sizeof header to fadAlloc */
newSize = data.size;
if (offset == 0) { if (offset == 0) { /* XXX simulated offset 0 record */
offset = fadAlloc(dbi->dbi_pkgs, newSize); offset = fadAlloc(dbi->dbi_pkgs, newSize);
if (offset == 0) if (offset == 0)
return -1; return -1;
offset--; /* XXX hack: caller will increment */ offset--; /* XXX hack: caller will increment */
*datap = xmalloc(sizeof(offset)); /* XXX hack: return offset as data, free in db0cput */
memcpy(*datap, &offset, sizeof(offset)); data.data = xmalloc(sizeof(offset));
*datalen = sizeof(offset); memcpy(data.data, &offset, sizeof(offset));
} else { data.size = sizeof(offset);
void * uh = doGetRecord(dbi->dbi_pkgs, offset); } else { /* XXX simulated retrieval */
if (uh == NULL) data.data = doGetRecord(dbi->dbi_pkgs, offset);
return 1; data.size = 0; /* XXX WRONG */
if (datap) if (data.data == NULL)
*datap = uh; rc = 1;
if (datalen)
*datalen = 0; /* XXX WRONG */
} }
} else { } else {
DBT key, data;
DB * db = GetDB(dbi); DB * db = GetDB(dbi);
int _printit;
_mymemset(&key, 0, sizeof(key));
_mymemset(&data, 0, sizeof(data));
key.data = keyp;
key.size = keylen;
data.data = NULL;
data.size = 0;
rc = db->get(db, &key, &data, 0); rc = db->get(db, &key, &data, 0);
rc = cvtdberr(dbi, "db->get", rc, _debug); _printit = (rc == 1 ? 0 : _debug);
rc = cvtdberr(dbi, "db0get", rc, _printit);
}
if (rc == 0) { if (rc == 0) {
*datap = data.data; if (datap) *datap = data.data;
*datalen = data.size; if (datalen) *datalen = data.size;
}
} }
return rc; return rc;
} }
#endif /* DYING */
static int db0put(dbiIndex dbi, void * keyp, size_t keylen, static int db0cput(dbiIndex dbi, void * keyp, size_t keylen,
void * datap, size_t datalen) void * datap, size_t datalen)
{ {
DBT key, data;
int rc = 0; int rc = 0;
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
key.data = keyp;
key.size = keylen;
data.data = datap;
data.size = datalen;
if (dbi->dbi_rpmtag == 0) { if (dbi->dbi_rpmtag == 0) {
unsigned int offset; unsigned int offset;
memcpy(&offset, keyp, sizeof(offset)); memcpy(&offset, key.data, sizeof(offset));
if (offset == 0) { if (offset == 0) { /* XXX simulated offset 0 record */
if (datalen == sizeof(offset)) /* XXX hack: return offset as data, free in db0cput */
free(datap); if (data.size == sizeof(offset)) {
} else { free(data.data);
Header h = headerLoad(datap); }
} else { /* XXX simulated DB_KEYLAST */
Header h = headerLoad(data.data);
int newSize = headerSizeof(h, HEADER_MAGIC_NO); int newSize = headerSizeof(h, HEADER_MAGIC_NO);
(void)Fseek(dbi->dbi_pkgs, offset, SEEK_SET); (void)Fseek(dbi->dbi_pkgs, offset, SEEK_SET);
@ -535,17 +501,8 @@ static int db0put(dbiIndex dbi, void * keyp, size_t keylen,
headerFree(h); headerFree(h);
} }
} else { } else {
DBT key, data;
DB * db = GetDB(dbi); DB * db = GetDB(dbi);
_mymemset(&key, 0, sizeof(key));
_mymemset(&data, 0, sizeof(data));
key.data = keyp;
key.size = keylen;
data.data = datap;
data.size = datalen;
rc = db->put(db, &key, &data, 0); rc = db->put(db, &key, &data, 0);
rc = cvtdberr(dbi, "db->put", rc, _debug); rc = cvtdberr(dbi, "db->put", rc, _debug);
} }
@ -646,11 +603,11 @@ static int db0open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
} }
exit: exit:
if (rc == 0 && dbi->dbi_db != NULL && dbip != NULL) { if (rc == 0 && dbip) {
rc = 0; rc = 0;
*dbip = dbi; *dbip = dbi;
if (_debug < 0) if (_debug < 0)
fprintf(stderr, "*** db%dopen: %s\n", dbi->dbi_major, urlfn); fprintf(stderr, "*** db%dopen: rpmtag %d dbi %p %s\n", dbi->dbi_major, rpmtag, dbi, urlfn);
} else { } else {
rc = 1; rc = 1;
db3Free(dbi); db3Free(dbi);
@ -671,5 +628,6 @@ fprintf(stderr, "*** db%dopen: %s\n", dbi->dbi_major, urlfn);
struct _dbiVec db0vec = { struct _dbiVec db0vec = {
DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH, DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
db0open, db0close, db0sync, db0SearchIndex, db0UpdateIndex, db0open, db0close, db0sync, db0SearchIndex, db0UpdateIndex,
db0del, db0get, db0put, db0copen, db0cclose, db0join, db0cget db0cdel, db0get, db0cput, db0copen, db0cclose, db0cdel, db0cget, db0cput,
db0byteswapped
}; };

783
lib/db3.c

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,9 @@
#include <rpmlib.h> #include <rpmlib.h>
#include "depends.h" #include "depends.h"
#include "rpmdb.h"
#include "misc.h" #include "misc.h"
/*@access rpmdb@*/
/*@access rpmTransactionSet@*/ /*@access rpmTransactionSet@*/
int headerNVR(Header h, const char **np, const char **vp, const char **rp) int headerNVR(Header h, const char **np, const char **vp, const char **rp)
@ -20,35 +20,40 @@ int headerNVR(Header h, const char **np, const char **vp, const char **rp)
return 0; return 0;
} }
static /*@only@*/ char *printDepend(const char * key, const char * keyEVR, static /*@only@*/ char *printDepend(const char * depend, const char * key, const char * keyEVR,
int keyFlags) int keyFlags)
{ {
char *tbuf, *t; char *tbuf, *t;
size_t nb; size_t nb;
nb = 0; nb = 0;
if (depend) nb += strlen(depend) + 1;
if (key) nb += strlen(key); if (key) nb += strlen(key);
if (keyFlags) { if (keyFlags & RPMSENSE_SENSEMASK) {
if (nb) nb++; if (nb) nb++;
if (keyFlags & RPMSENSE_LESS) nb++; if (keyFlags & RPMSENSE_LESS) nb++;
if (keyFlags & RPMSENSE_GREATER) nb++; if (keyFlags & RPMSENSE_GREATER) nb++;
if (keyFlags & RPMSENSE_EQUAL) nb++; if (keyFlags & RPMSENSE_EQUAL) nb++;
} }
if (keyEVR) { if (keyEVR && *keyEVR) {
if (nb) nb++; if (nb) nb++;
nb += strlen(keyEVR); nb += strlen(keyEVR);
} }
t = tbuf = xmalloc(nb + 1); t = tbuf = xmalloc(nb + 1);
if (depend) {
while(*depend) *t++ = *depend++;
*t++ = ' ';
}
if (key) if (key)
while(*key) *t++ = *key++; while(*key) *t++ = *key++;
if (keyFlags) { if (keyFlags & RPMSENSE_SENSEMASK) {
if (t != tbuf) *t++ = ' '; if (t != tbuf) *t++ = ' ';
if (keyFlags & RPMSENSE_LESS) *t++ = '<'; if (keyFlags & RPMSENSE_LESS) *t++ = '<';
if (keyFlags & RPMSENSE_GREATER) *t++ = '>'; if (keyFlags & RPMSENSE_GREATER) *t++ = '>';
if (keyFlags & RPMSENSE_EQUAL) *t++ = '='; if (keyFlags & RPMSENSE_EQUAL) *t++ = '=';
} }
if (keyEVR) { if (keyEVR && *keyEVR) {
if (t != tbuf) *t++ = ' '; if (t != tbuf) *t++ = ' ';
while(*keyEVR) *t++ = *keyEVR++; while(*keyEVR) *t++ = *keyEVR++;
} }
@ -394,8 +399,8 @@ int rpmFLAGS = RPMSENSE_EQUAL;
static int rangesOverlap(const char *AName, const char *AEVR, int AFlags, static int rangesOverlap(const char *AName, const char *AEVR, int AFlags,
const char *BName, const char *BEVR, int BFlags) const char *BName, const char *BEVR, int BFlags)
{ {
const char *aDepend = printDepend(AName, AEVR, AFlags); const char *aDepend = printDepend(NULL, AName, AEVR, AFlags);
const char *bDepend = printDepend(BName, BEVR, BFlags); const char *bDepend = printDepend(NULL, BName, BEVR, BFlags);
char *aEVR, *bEVR; char *aEVR, *bEVR;
const char *aE, *aV, *aR, *bE, *bV, *bR; const char *aE, *aV, *aR, *bE, *bV, *bR;
int result; int result;
@ -884,6 +889,15 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
if (suggestion) *suggestion = NULL; if (suggestion) *suggestion = NULL;
{ mi = rpmdbInitIterator(rpmdep->db, 1, keyDepend, 0);
if (mi) {
rc = rpmdbGetIteratorOffset(mi);
rpmdbFreeIterator(mi);
rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by Depends cache.\n"), keyType, keyDepend+2);
return rc;
}
}
{ const char * rcProvidesString; { const char * rcProvidesString;
const char * start; const char * start;
@ -892,7 +906,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
i = strlen(keyName); i = strlen(keyName);
while ((start = strstr(rcProvidesString, keyName))) { while ((start = strstr(rcProvidesString, keyName))) {
if (isspace(start[i]) || start[i] == '\0' || start[i] == ',') { if (isspace(start[i]) || start[i] == '\0' || start[i] == ',') {
rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by rpmrc provides.\n"), keyType, keyDepend); rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by rpmrc provides.\n"), keyType, keyDepend+2);
goto exit; goto exit;
} }
rcProvidesString = start + 1; rcProvidesString = start + 1;
@ -920,7 +934,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
} }
rpmdbFreeIterator(mi); rpmdbFreeIterator(mi);
if (h) { if (h) {
rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db file lists.\n"), keyType, keyDepend); rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db file lists.\n"), keyType, keyDepend+2);
goto exit; goto exit;
} }
} }
@ -938,7 +952,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
} }
rpmdbFreeIterator(mi); rpmdbFreeIterator(mi);
if (h) { if (h) {
rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db provides.\n"), keyType, keyDepend); rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db provides.\n"), keyType, keyDepend+2);
goto exit; goto exit;
} }
@ -956,7 +970,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
} }
rpmdbFreeIterator(mi); rpmdbFreeIterator(mi);
if (h) { if (h) {
rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db packages.\n"), keyType, keyDepend); rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db packages.\n"), keyType, keyDepend+2);
goto exit; goto exit;
} }
#endif #endif
@ -969,7 +983,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
if (!strcmp(keyName, rpmNAME)) { if (!strcmp(keyName, rpmNAME)) {
i = rangesOverlap(keyName, keyEVR, keyFlags, rpmNAME, rpmEVR, rpmFLAGS); i = rangesOverlap(keyName, keyEVR, keyFlags, rpmNAME, rpmEVR, rpmFLAGS);
if (i) { if (i) {
rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by rpmlib version.\n"), keyType, keyDepend); rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by rpmlib version.\n"), keyType, keyDepend+2);
goto exit; goto exit;
} }
} }
@ -979,10 +993,14 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
*suggestion = alSatisfiesDepend(&rpmdep->availablePackages, NULL, NULL, *suggestion = alSatisfiesDepend(&rpmdep->availablePackages, NULL, NULL,
keyName, keyEVR, keyFlags); keyName, keyEVR, keyFlags);
rpmMessage(RPMMESS_DEBUG, _("%s: %s unsatisfied.\n"), keyType, keyDepend); rpmMessage(RPMMESS_DEBUG, _("%s: %s unsatisfied.\n"), keyType, keyDepend+2);
rc = 1; /* dependency is unsatisfied */ rc = 1; /* dependency is unsatisfied */
exit: exit:
{ dbiIndex dbi;
if ((dbi = dbiOpen(rpmdep->db, 1)) != NULL)
(void) dbiPut(dbi, keyDepend, 0, &rc, sizeof(rc));
}
return rc; return rc;
} }
@ -1018,7 +1036,7 @@ static int checkPackageDeps(rpmTransactionSet rpmdep, struct problemsSet * psp,
if (keyName && strcmp(keyName, requires[i])) if (keyName && strcmp(keyName, requires[i]))
continue; continue;
keyDepend = printDepend(requires[i], requiresEVR[i], requireFlags[i]); keyDepend = printDepend("R", requires[i], requiresEVR[i], requireFlags[i]);
rc = unsatisfiedDepend(rpmdep, " requires", keyDepend, rc = unsatisfiedDepend(rpmdep, " requires", keyDepend,
requires[i], requiresEVR[i], requireFlags[i], &suggestion); requires[i], requiresEVR[i], requireFlags[i], &suggestion);
@ -1081,7 +1099,7 @@ static int checkPackageDeps(rpmTransactionSet rpmdep, struct problemsSet * psp,
if (keyName && strcmp(keyName, conflicts[i])) if (keyName && strcmp(keyName, conflicts[i]))
continue; continue;
keyDepend = printDepend(conflicts[i], conflictsEVR[i], conflictFlags[i]); keyDepend = printDepend("C", conflicts[i], conflictsEVR[i], conflictFlags[i]);
rc = unsatisfiedDepend(rpmdep, "conflicts", keyDepend, rc = unsatisfiedDepend(rpmdep, "conflicts", keyDepend,
conflicts[i], conflictsEVR[i], conflictFlags[i], NULL); conflicts[i], conflictsEVR[i], conflictFlags[i], NULL);

View File

@ -511,9 +511,11 @@ static void *doHeaderUnload(Header h, /*@out@*/int * lengthPtr)
void *headerUnload(Header h) void *headerUnload(Header h)
{ {
void * uh;
int length; int length;
return doHeaderUnload(h, &length); uh = doHeaderUnload(h, &length);
return uh;
} }
/********************************************************************/ /********************************************************************/

View File

@ -102,7 +102,6 @@ static void dbiTagsInit(void)
} }
#define dbiSync(_dbi) (*(_dbi)->dbi_vec->sync) ((_dbi), 0) #define dbiSync(_dbi) (*(_dbi)->dbi_vec->sync) ((_dbi), 0)
#define dbiClose(_dbi) (*(_dbi)->dbi_vec->close) ((_dbi), 0)
/** /**
* Create and initialize element of index database set. * Create and initialize element of index database set.
@ -111,7 +110,7 @@ static void dbiTagsInit(void)
* @return new element * @return new element
*/ */
static inline dbiIndexRecord dbiReturnIndexRecordInstance(unsigned int recOffset, unsigned int fileNumber) { static inline dbiIndexRecord dbiReturnIndexRecordInstance(unsigned int recOffset, unsigned int fileNumber) {
dbiIndexRecord rec = xmalloc(sizeof(*rec)); dbiIndexRecord rec = xcalloc(1, sizeof(*rec));
rec->recOffset = recOffset; rec->recOffset = recOffset;
rec->fileNumber = fileNumber; rec->fileNumber = fileNumber;
return rec; return rec;
@ -264,27 +263,30 @@ static inline void dbiIndexRecordOffsetSave(dbiIndexSet set, int recno, unsigned
set->recs[recno].recOffset = recoff; set->recs[recno].recOffset = recoff;
} }
#ifdef DYING int dbiClose(dbiIndex dbi, int flag) {
dbiIndex dbiNew(rpmdb rpmdb, int rpmtag) { int rc;
dbiIndex dbi = xcalloc(1, sizeof(*dbi));
rc = (*dbi->dbi_vec->close) (dbi, flag);
dbi->dbi_rpmdb = rpmdb; return rc;
dbi->dbi_rpmtag = rpmtag;
dbi->dbi_perms = 0644;
dbi->dbi_jlen = (rpmtag == RPMTAG_BASENAMES ? 2 : 1) * sizeof(int_32);
return dbi;
} }
void dbiFree( /*@only@*/ /*@null@*/ dbiIndex dbi) { int dbiPut(dbiIndex dbi, const void * key, size_t keylen,
if (dbi) { const void * data, size_t datalen)
if (dbi->dbi_errpfx) xfree(dbi->dbi_errpfx); {
if (dbi->dbi_re_source) xfree(dbi->dbi_re_source); dbiIndexSet set = xcalloc(1, sizeof(*set));
if (dbi->dbi_dbenv) free(dbi->dbi_dbenv); size_t nb = (datalen < sizeof(*set->recs) ? datalen : sizeof(*set->recs));
if (dbi->dbi_dbinfo) free(dbi->dbi_dbinfo); int rc;
xfree(dbi);
} set->count = 1;
set->recs = dbiReturnIndexRecordInstance(0, 0);
memcpy(set->recs, data, nb);
rc = (*dbi->dbi_vec->UpdateIndex) (dbi, key, set);
dbiFreeIndexSet(set);
return rc;
} }
#endif
static struct _dbiVec *mydbvecs[] = { static struct _dbiVec *mydbvecs[] = {
DB0vec, DB1vec, DB2vec, DB3vec, NULL DB0vec, DB1vec, DB2vec, DB3vec, NULL
@ -296,7 +298,7 @@ static struct _dbiVec *mydbvecs[] = {
* @param dbix dbi template to use * @param dbix dbi template to use
* @return index database handle * @return index database handle
*/ */
static dbiIndex dbiOpenIndex(rpmdb rpmdb, int rpmtag) dbiIndex dbiOpen(rpmdb rpmdb, int rpmtag)
{ {
int dbix; int dbix;
dbiIndex dbi = NULL; dbiIndex dbi = NULL;
@ -355,7 +357,7 @@ static dbiIndex dbiOpenIndex(rpmdb rpmdb, int rpmtag)
if (rc == 0) { if (rc == 0) {
rpmdb->_dbi[dbix] = dbi; rpmdb->_dbi[dbix] = dbi;
} else if (dbi) { } else if (dbi) {
rpmError(RPMERR_DBOPEN, _("dbiOpenIndex: cannot open %s index"), rpmError(RPMERR_DBOPEN, _("dbiOpen: cannot open %s index"),
tagName(rpmtag)); tagName(rpmtag));
db3Free(dbi); db3Free(dbi);
dbi = NULL; dbi = NULL;
@ -364,20 +366,6 @@ static dbiIndex dbiOpenIndex(rpmdb rpmdb, int rpmtag)
return dbi; return dbi;
} }
#ifdef DYING
/**
* Close index database.
* @param dbi index database handle
*/
static int dbiClose(dbiIndex dbi) {
int rc;
rc = (*dbi->dbi_vec->close) (dbi, 0);
db3Free(dbi);
return rc;
}
#endif
/* XXX depends.c, install.c, query.c, rpminstall.c, transaction.c */ /* XXX depends.c, install.c, query.c, rpminstall.c, transaction.c */
void dbiFreeIndexSet(dbiIndexSet set) { void dbiFreeIndexSet(dbiIndexSet set) {
if (set) { if (set) {
@ -390,17 +378,21 @@ void dbiFreeIndexSet(dbiIndexSet set) {
static sigset_t signalMask; static sigset_t signalMask;
static void blockSignals(void) static void blockSignals(rpmdb rpmdb)
{ {
sigset_t newMask; sigset_t newMask;
sigfillset(&newMask); /* block all signals */ if (!(rpmdb && rpmdb->db_major == 3)) {
sigprocmask(SIG_BLOCK, &newMask, &signalMask); sigfillset(&newMask); /* block all signals */
sigprocmask(SIG_BLOCK, &newMask, &signalMask);
}
} }
static void unblockSignals(void) static void unblockSignals(rpmdb rpmdb)
{ {
sigprocmask(SIG_SETMASK, &signalMask, NULL); if (!(rpmdb && rpmdb->db_major == 3)) {
sigprocmask(SIG_SETMASK, &signalMask, NULL);
}
} }
#define _DB_ROOT "/" #define _DB_ROOT "/"
@ -427,7 +419,7 @@ void rpmdbClose (rpmdb rpmdb)
for (dbix = rpmdb->db_ndbi; --dbix >= 0; ) { for (dbix = rpmdb->db_ndbi; --dbix >= 0; ) {
if (rpmdb->_dbi[dbix] == NULL) if (rpmdb->_dbi[dbix] == NULL)
continue; continue;
dbiClose(rpmdb->_dbi[dbix]); dbiClose(rpmdb->_dbi[dbix], 0);
rpmdb->_dbi[dbix] = NULL; rpmdb->_dbi[dbix] = NULL;
} }
if (rpmdb->db_errpfx) { if (rpmdb->db_errpfx) {
@ -526,7 +518,7 @@ static int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
int rpmtag; int rpmtag;
rpmtag = dbiTags[dbix]; rpmtag = dbiTags[dbix];
dbi = (justCheck ? NULL : dbiOpenIndex(rpmdb, rpmtag)); dbi = dbiOpen(rpmdb, rpmtag);
if (dbi == NULL) if (dbi == NULL)
continue; continue;
@ -551,6 +543,7 @@ static int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
*/ */
if (justCheck) if (justCheck)
break; break;
xx = (*dbi->dbi_vec->copen) (dbi, NULL);
xx = (*dbi->dbi_vec->cget) (dbi, &keyp, NULL, NULL, NULL); xx = (*dbi->dbi_vec->cget) (dbi, &keyp, NULL, NULL, NULL);
if (xx == 0) { if (xx == 0) {
const char * akey = keyp; const char * akey = keyp;
@ -560,7 +553,7 @@ static int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
rc |= 1; rc |= 1;
} }
} }
xx = (*dbi->dbi_vec->cclose) (dbi); xx = (*dbi->dbi_vec->cclose) (dbi, NULL);
} break; } break;
default: default:
break; break;
@ -569,10 +562,10 @@ static int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
} }
exit: exit:
if (!(rc || justCheck || dbp == NULL)) if (rc || justCheck || dbp == NULL)
*dbp = rpmdb;
else
rpmdbClose(rpmdb); rpmdbClose(rpmdb);
else
*dbp = rpmdb;
return rc; return rc;
} }
@ -614,7 +607,7 @@ Header rpmdbGetRecord(rpmdb rpmdb, unsigned int offset)
int rc; int rc;
rpmtag = 0; /* RPMDBI_PACKAGES */ rpmtag = 0; /* RPMDBI_PACKAGES */
dbi = dbiOpenIndex(rpmdb, rpmtag); dbi = dbiOpen(rpmdb, rpmtag);
if (dbi == NULL) if (dbi == NULL)
return NULL; return NULL;
rc = (*dbi->dbi_vec->get) (dbi, keyp, keylen, &uh, &uhlen); rc = (*dbi->dbi_vec->get) (dbi, keyp, keylen, &uh, &uhlen);
@ -654,7 +647,7 @@ static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
fpc = fpCacheCreate(20); fpc = fpCacheCreate(20);
fp1 = fpLookup(fpc, dirName, baseName, 1); fp1 = fpLookup(fpc, dirName, baseName, 1);
dbi = dbiOpenIndex(rpmdb, RPMTAG_BASENAMES); dbi = dbiOpen(rpmdb, RPMTAG_BASENAMES);
rc = dbiSearchIndex(dbi, baseName, 0, &allMatches); rc = dbiSearchIndex(dbi, baseName, 0, &allMatches);
if (rc) { if (rc) {
dbiFreeIndexSet(allMatches); dbiFreeIndexSet(allMatches);
@ -797,7 +790,8 @@ void rpmdbFreeIterator(rpmdbMatchIterator mi)
} else { } else {
int dbix = 0; /* RPMDBI_PACKAGES */ int dbix = 0; /* RPMDBI_PACKAGES */
dbiIndex dbi = mi->mi_rpmdb->_dbi[dbix]; dbiIndex dbi = mi->mi_rpmdb->_dbi[dbix];
(void) (*dbi->dbi_vec->cclose) (dbi); if (dbi)
(void) (*dbi->dbi_vec->cclose) (dbi, NULL);
} }
if (mi->mi_key) { if (mi->mi_key) {
xfree(mi->mi_key); xfree(mi->mi_key);
@ -848,8 +842,8 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi)
{ {
dbiIndex dbi; dbiIndex dbi;
int rpmtag; int rpmtag;
void * uh; void * uh = NULL;
size_t uhlen; size_t uhlen = 0;
void * keyp; void * keyp;
size_t keylen; size_t keylen;
int rc; int rc;
@ -858,16 +852,16 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi)
return NULL; return NULL;
rpmtag = 0; /* RPMDBI_PACKAGES */ rpmtag = 0; /* RPMDBI_PACKAGES */
dbi = dbiOpenIndex(mi->mi_rpmdb, rpmtag); dbi = dbiOpen(mi->mi_rpmdb, rpmtag);
if (dbi == NULL) if (dbi == NULL)
return NULL; return NULL;
keyp = &mi->mi_offset;
keylen = sizeof(mi->mi_offset);
top: top:
/* XXX skip over instances with 0 join key */ /* XXX skip over instances with 0 join key */
do { do {
if (mi->mi_set) { if (mi->mi_set) {
keyp = &mi->mi_offset;
keylen = sizeof(mi->mi_offset);
if (!(mi->mi_setx < mi->mi_set->count)) if (!(mi->mi_setx < mi->mi_set->count))
return NULL; return NULL;
if (mi->mi_dbix != 0) { /* RPMDBI_PACKAGES */ if (mi->mi_dbix != 0) { /* RPMDBI_PACKAGES */
@ -875,8 +869,12 @@ top:
mi->mi_filenum = dbiIndexRecordFileNumber(mi->mi_set, mi->mi_setx); mi->mi_filenum = dbiIndexRecordFileNumber(mi->mi_set, mi->mi_setx);
} }
} else { } else {
rc = (*dbi->dbi_vec->cget) (dbi, &keyp, &keylen, NULL, NULL); keyp = NULL;
if (keyp) keylen = 0;
rc = (*dbi->dbi_vec->cget) (dbi, &keyp, &keylen, &uh, &uhlen);
if (rc == 0 && keyp && mi->mi_setx)
memcpy(&mi->mi_offset, keyp, sizeof(mi->mi_offset)); memcpy(&mi->mi_offset, keyp, sizeof(mi->mi_offset));
/* Terminate on error or end of keys */ /* Terminate on error or end of keys */
@ -890,9 +888,11 @@ top:
return mi->mi_h; return mi->mi_h;
/* Retrieve header */ /* Retrieve header */
rc = (*dbi->dbi_vec->get) (dbi, keyp, keylen, &uh, &uhlen); if (uh == NULL) {
if (rc) rc = (*dbi->dbi_vec->cget) (dbi, &keyp, &keylen, &uh, &uhlen);
return NULL; if (rc)
return NULL;
}
if (mi->mi_h) { if (mi->mi_h) {
headerFree(mi->mi_h); headerFree(mi->mi_h);
@ -1001,7 +1001,7 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb rpmdb, int rpmtag,
dbix = dbiTagToDbix(rpmtag); dbix = dbiTagToDbix(rpmtag);
if (dbix < 0) if (dbix < 0)
return NULL; return NULL;
dbi = dbiOpenIndex(rpmdb, rpmtag); dbi = dbiOpen(rpmdb, rpmtag);
if (dbi == NULL) if (dbi == NULL)
return NULL; return NULL;
@ -1040,13 +1040,12 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb rpmdb, int rpmtag,
} else { } else {
mi->mi_key = NULL; mi->mi_key = NULL;
mi->mi_keylen = 0; mi->mi_keylen = 0;
if (dbi)
dbi->dbi_lastoffset = 0; /* db0: rewind to beginning */
} }
mi->mi_rpmdb = rpmdb; mi->mi_rpmdb = rpmdb;
mi->mi_dbi = dbi; mi->mi_dbi = dbi;
/* XXX falloc has dbi == NULL ) */
assert(!(dbi && dbi->dbi_dbcursor));
mi->mi_dbix = dbix; mi->mi_dbix = dbix;
mi->mi_set = set; mi->mi_set = set;
mi->mi_setx = 0; mi->mi_setx = 0;
@ -1118,7 +1117,7 @@ int rpmdbRemove(rpmdb rpmdb, unsigned int offset, int tolerant)
rpmMessage(RPMMESS_VERBOSE, " --- %s-%s-%s\n", n, v, r); rpmMessage(RPMMESS_VERBOSE, " --- %s-%s-%s\n", n, v, r);
} }
blockSignals(); blockSignals(rpmdb);
{ int dbix; { int dbix;
dbiIndexRecord rec = dbiReturnIndexRecordInstance(offset, 0); dbiIndexRecord rec = dbiReturnIndexRecordInstance(offset, 0);
@ -1132,7 +1131,7 @@ int rpmdbRemove(rpmdb rpmdb, unsigned int offset, int tolerant)
/* XXX FIXME: this forces all indices open */ /* XXX FIXME: this forces all indices open */
rpmtag = dbiTags[dbix]; rpmtag = dbiTags[dbix];
dbi = dbiOpenIndex(rpmdb, rpmtag); dbi = dbiOpen(rpmdb, rpmtag);
if (dbi->dbi_rpmtag == 0) { if (dbi->dbi_rpmtag == 0) {
(void) (*dbi->dbi_vec->del) (dbi, &offset, sizeof(offset)); (void) (*dbi->dbi_vec->del) (dbi, &offset, sizeof(offset));
@ -1206,7 +1205,7 @@ int rpmdbRemove(rpmdb rpmdb, unsigned int offset, int tolerant)
} }
} }
unblockSignals(); unblockSignals(rpmdb);
headerFree(h); headerFree(h);
@ -1267,7 +1266,7 @@ int rpmdbAdd(rpmdb rpmdb, Header h)
if (_noDirTokens) if (_noDirTokens)
expandFilelist(h); expandFilelist(h);
blockSignals(); blockSignals(rpmdb);
{ {
unsigned int firstkey = 0; unsigned int firstkey = 0;
@ -1278,29 +1277,33 @@ int rpmdbAdd(rpmdb rpmdb, Header h)
int rc; int rc;
rpmtag = 0; /* RPMDBI_PACKAGES */ rpmtag = 0; /* RPMDBI_PACKAGES */
dbi = dbiOpenIndex(rpmdb, rpmtag); dbi = dbiOpen(rpmdb, rpmtag);
/* XXX hack to pass sizeof header to fadAlloc */ /* XXX db0: hack to pass sizeof header to fadAlloc */
datap = h; datap = h;
datalen = headerSizeof(h, HEADER_MAGIC_NO); datalen = headerSizeof(h, HEADER_MAGIC_NO);
(void) (*dbi->dbi_vec->copen) (dbi, NULL);
/* Retrieve join key for next header instance. */ /* Retrieve join key for next header instance. */
rc = (*dbi->dbi_vec->get) (dbi, keyp, keylen, (void *)&datap, &datalen); rc = (*dbi->dbi_vec->cget) (dbi, &keyp, &keylen, &datap, &datalen);
offset = 0; offset = 0;
if (rc == 0 && datap) if (rc == 0 && datap)
memcpy(&offset, datap, sizeof(offset)); memcpy(&offset, datap, sizeof(offset));
++offset; ++offset;
if (datap) { if (rc == 0 && datap) {
memcpy(datap, &offset, sizeof(offset)); memcpy(datap, &offset, sizeof(offset));
} else { } else {
datap = &offset; datap = &offset;
datalen = sizeof(offset); datalen = sizeof(offset);
} }
rc = (*dbi->dbi_vec->put) (dbi, keyp, keylen, datap, datalen); rc = (*dbi->dbi_vec->cput) (dbi, keyp, keylen, datap, datalen);
(void) (*dbi->dbi_vec->cclose) (dbi, NULL);
} }
if (rc) { if (rc) {
@ -1320,11 +1323,12 @@ int rpmdbAdd(rpmdb rpmdb, Header h)
/* XXX FIXME: this forces all indices open */ /* XXX FIXME: this forces all indices open */
rpmtag = dbiTags[dbix]; rpmtag = dbiTags[dbix];
dbi = dbiOpenIndex(rpmdb, rpmtag); dbi = dbiOpen(rpmdb, rpmtag);
if (dbi->dbi_rpmtag == 0) { if (dbi->dbi_rpmtag == 0) {
size_t uhlen = headerSizeof(h, HEADER_MAGIC_NO); size_t uhlen = headerSizeof(h, HEADER_MAGIC_NO);
void * uh = headerUnload(h); void * uh = headerUnload(h);
(void) (*dbi->dbi_vec->put) (dbi, &offset, sizeof(offset), uh, uhlen); (void) (*dbi->dbi_vec->put) (dbi, &offset, sizeof(offset), uh, uhlen);
free(uh); free(uh);
@ -1421,7 +1425,7 @@ int rpmdbAdd(rpmdb rpmdb, Header h)
} }
exit: exit:
unblockSignals(); unblockSignals(rpmdb);
return rc; return rc;
} }
@ -1666,7 +1670,7 @@ int findMatches(rpmdb rpmdb, const char * name, const char * version,
int rc; int rc;
int i; int i;
dbi = dbiOpenIndex(rpmdb, RPMTAG_NAME); dbi = dbiOpen(rpmdb, RPMTAG_NAME);
rc = dbiSearchIndex(dbi, name, 0, matches); rc = dbiSearchIndex(dbi, name, 0, matches);
if (rc != 0) { if (rc != 0) {

View File

@ -42,6 +42,14 @@ struct _dbiIndexSet {
int count; /*!< number of records */ int count; /*!< number of records */
}; };
/* XXX hack to get prototypes correct */
#if !defined(DB_VERSION_MAJOR)
#define DB_ENV void
#define DBC void
#define DBT void
#define DB_LSN void
#endif
/** /**
* Private methods for accessing an index database. * Private methods for accessing an index database.
*/ */
@ -120,18 +128,22 @@ struct _dbiVec {
/** /**
*/ */
int (*copen) (dbiIndex dbi); int (*copen) (dbiIndex dbi, DBC ** dbcp);
/** /**
*/ */
int (*cclose) (dbiIndex dbi); int (*cclose) (dbiIndex dbi, DBC * dbcursor);
/** /**
* Delete item using db->del or dbcursor->c_del.
* @param dbi index database handle
* @param keyp key data
* @param keylen key data length
*/ */
int (*join) (dbiIndex dbi); int (*cdel) (dbiIndex dbi, void * keyp, size_t keylen);
/** /**
* Retrieve item using dbcursor->c_get. * Retrieve item using db->get or dbcursor->c_get.
* @param dbi index database handle * @param dbi index database handle
* @param keyp address of key data * @param keyp address of key data
* @param keylen address of key data length * @param keylen address of key data length
@ -141,20 +153,38 @@ struct _dbiVec {
int (*cget) (dbiIndex dbi, void ** keyp, size_t * keylen, int (*cget) (dbiIndex dbi, void ** keyp, size_t * keylen,
void ** datap, size_t * datalen); void ** datap, size_t * datalen);
}; /**
* Save item using db->put or dbcursor->c_put.
* @param dbi index database handle
* @param keyp key data
* @param keylen key data length
* @param datap data pointer
* @param datalen data length
*/
int (*cput) (dbiIndex dbi, void * keyp, size_t keylen,
void * datap, size_t datalen);
/* XXX hack to get prototypes correct */ /**
#if !defined(DB_VERSION_MAJOR) */
#define DB_ENV void int (*byteswapped) (dbiIndex dbi);
#define DBT void
#define DB_LSN void };
#endif
/** /**
* Describes an index database (implemented on Berkeley db[123] API). * Describes an index database (implemented on Berkeley db[123] API).
*/ */
struct _dbiIndex { struct _dbiIndex {
int dbi_flags; /*<! */ const char * dbi_root;
const char * dbi_home;
const char * dbi_file;
const char * dbi_subfile;
int dbi_cflags; /*<! db_create/db_env_create flags */
int dbi_oeflags; /*<! common (db,dbenv}->open flags */
int dbi_eflags; /*<! dbenv->open flags */
int dbi_oflags; /*<! db->open flags */
int dbi_tflags; /*<! dbenv->txn_begin flags */
int dbi_type; /*<! db index type */ int dbi_type; /*<! db index type */
int dbi_mode; /*<! mode to use on open */ int dbi_mode; /*<! mode to use on open */
int dbi_perms; /*<! file permission to use on open */ int dbi_perms; /*<! file permission to use on open */
@ -164,6 +194,7 @@ struct _dbiIndex {
int dbi_use_cursors; int dbi_use_cursors;
int dbi_get_rmw_cursor; int dbi_get_rmw_cursor;
int dbi_no_fsync; int dbi_no_fsync;
int dbi_temporary;
/* dbenv parameters */ /* dbenv parameters */
int dbi_lorder; int dbi_lorder;
@ -221,8 +252,7 @@ struct _dbiIndex {
void * dbi_db; /*<! Berkeley db[123] handle */ void * dbi_db; /*<! Berkeley db[123] handle */
void * dbi_dbenv; void * dbi_dbenv;
void * dbi_dbinfo; void * dbi_dbinfo;
void * dbi_dbjoin; void * dbi_rmw; /*<! db cursor (with DB_WRITECURSOR) */
void * dbi_dbcursor;
void * dbi_pkgs; void * dbi_pkgs;
/*@observer@*/ const struct _dbiVec * dbi_vec; /*<! private methods */ /*@observer@*/ const struct _dbiVec * dbi_vec; /*<! private methods */
@ -235,7 +265,8 @@ struct _dbiIndex {
struct rpmdb_s { struct rpmdb_s {
const char * db_root; /*<! path prefix */ const char * db_root; /*<! path prefix */
const char * db_home; /*<! directory path */ const char * db_home; /*<! directory path */
int db_flags; /*<! */ int db_flags;
int db_mode; /*<! open mode */ int db_mode; /*<! open mode */
int db_perms; /*<! open permissions */ int db_perms; /*<! open permissions */
@ -264,46 +295,84 @@ extern "C" {
#endif #endif
/** /**
* Return base file name for legacy index databases. * Return new configured index database handle instance.
* @param rpmtag rpm tag * @param rpmdb rpm database
* @return base file name
*/ */
char * db0basename(int rpmtag);
/*@only@*/ /*@null@*/ dbiIndex db3New(rpmdb rpmdb, int rpmtag); /*@only@*/ /*@null@*/ dbiIndex db3New(rpmdb rpmdb, int rpmtag);
/**
* Destroy index database handle instance.
* @param dbi index database handle
*/
void db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi); void db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi);
/** /**
* @param db rpm database * Return handle for an index database.
* @param rpmdb rpm database
* @param rpmtag rpm tag
* @return index database handle
*/
dbiIndex dbiOpen(rpmdb rpmdb, int rpmtag);
/**
* Store (key,data) pair in index database.
* @param dbi index database handle
* @param rpmdb rpm database
* @return 0 on success
*/
int dbiPut(dbiIndex dbi, const void * key, size_t keylen, const void * data, size_t datalen);
/**
* Close index database.
* @param dbi index database handle
* @param flag (unused)
* @return 0 on success
*/
int dbiClose(dbiIndex dbi, int flag);
/**
* Return base file name for index database (legacy).
* @param rpmtag rpm tag
* @return base file name
*/
char * db0basename(int rpmtag);
/**
* Remove package header from rpm database and indices.
* @param rpmdb rpm database
* @param offset location in Packages dbi
* @param tolerant (legacy) print error messages?
* @return 0 on success
*/ */
int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant); int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant);
/** /**
* @param db rpm database * Add package header to rpm database and indices.
* @param rpmdb rpm database
* @param rpmtag rpm tag
*/ */
int rpmdbAdd(rpmdb db, Header dbentry); int rpmdbAdd(rpmdb rpmdb, Header dbentry);
/** /**
* @param db rpm database * @param rpmdb rpm database
*/ */
int rpmdbUpdateRecord(rpmdb db, int secOffset, Header secHeader); int rpmdbUpdateRecord(rpmdb rpmdb, int secOffset, Header secHeader);
/** /**
*/ */
unsigned int rpmdbGetIteratorFileNum(rpmdbMatchIterator mi); unsigned int rpmdbGetIteratorFileNum(rpmdbMatchIterator mi);
/** /**
* @param db rpm database * @param rpmdb rpm database
*/ */
int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, /*@out@*/dbiIndexSet * matchList, int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, /*@out@*/dbiIndexSet * matchList,
int numItems); int numItems);
/* XXX only for the benefit of runTransactions() */ /* XXX only for the benefit of runTransactions() */
/** /**
* @param db rpm database * @param rpmdb rpm database
*/ */
int findMatches(rpmdb db, const char * name, const char * version, int findMatches(rpmdb rpmdb, const char * name, const char * version,
const char * release, /*@out@*/ dbiIndexSet * matches); const char * release, /*@out@*/ dbiIndexSet * matches);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -4,9 +4,9 @@
#define EXIT_FAILURE 1 #define EXIT_FAILURE 1
#endif #endif
void *vmefail(void) void *vmefail(size_t size)
{ {
fprintf(stderr, _("memory alloc returned NULL.\n")); fprintf(stderr, _("memory alloc (%u bytes) returned NULL.\n"), size);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/*@notreached@*/ /*@notreached@*/
return NULL; return NULL;
@ -20,7 +20,7 @@ void * xmalloc (size_t size)
if (size == 0) size++; if (size == 0) size++;
value = malloc (size); value = malloc (size);
if (value == 0) if (value == 0)
value = vmefail(); value = vmefail(size);
return value; return value;
} }
@ -31,7 +31,7 @@ void * xcalloc (size_t nmemb, size_t size)
if (nmemb == 0) nmemb++; if (nmemb == 0) nmemb++;
value = calloc (nmemb, size); value = calloc (nmemb, size);
if (value == 0) if (value == 0)
value = vmefail(); value = vmefail(size);
return value; return value;
} }
@ -41,15 +41,16 @@ void * xrealloc (void *ptr, size_t size)
if (size == 0) size++; if (size == 0) size++;
value = realloc (ptr, size); value = realloc (ptr, size);
if (value == 0) if (value == 0)
value = vmefail(); value = vmefail(size);
return value; return value;
} }
char * xstrdup (const char *str) char * xstrdup (const char *str)
{ {
char *newstr = (char *) malloc (strlen(str) + 1); size_t size = strlen(str) + 1;
char *newstr = (char *) malloc (size);
if (newstr == 0) if (newstr == 0)
newstr = (char *) vmefail(); newstr = (char *) vmefail(size);
strcpy (newstr, str); strcpy (newstr, str);
return newstr; return newstr;
} }

View File

@ -1,4 +1,4 @@
# $Id: macros.in,v 1.53 2000/04/23 20:37:57 jbj Exp $ # $Id: macros.in,v 1.54 2000/04/25 19:41:37 jbj Exp $
#============================================================================== #==============================================================================
# Macro naming conventions (preliminary): # Macro naming conventions (preliminary):
# #
@ -212,10 +212,9 @@
# 3 native db3 interface. # 3 native db3 interface.
# -1 db3 -> db2 -> db1 -> db0 (as available). # -1 db3 -> db2 -> db1 -> db0 (as available).
# There are two macros so that --rebuilddb can convert old_db_api -> new_db_api. # There are two macros so that --rebuilddb can convert old_db_api -> new_db_api.
%_dbapi 3 %_dbapi 0
%_dbapi_rebuild 3 %_dbapi_rebuild 3
# This is a colon separated list of tokens for Berkeley db configuration.
# #
# token Berkeley db flag or value # token Berkeley db flag or value
# ================================================= # =================================================
@ -235,21 +234,26 @@
# txn_nosync DB_TXN_NOSYNC # txn_nosync DB_TXN_NOSYNC
# hash DB_HASH # hash DB_HASH
# #
# See http://www.sleepycat.com for Berkeley db-3.0.55 configuration.
#
# The (intended) default value for Red Hat Linux is # The (intended) default value for Red Hat Linux is
# hash:mpool:shared:lock # hash:mpool:shared:lock
# #
# Additional rpm specific configuration:
# teardown Should the DB3 environment be removed after use (experimental)? # teardown Should the DB3 environment be removed after use (experimental)?
# usecursors Should DB3 cursors be used in get/put/del (experimental)? # usecursors Should DB3 cursors be used in get/put/del (experimental)?
# #
%__dbi_flags create:mpool %__dbi_flags mpool
%__dbi_type hash %__dbi_type hash
%__dbi_perms perms=0644 %__dbi_perms perms=0644
%__dbi_major db%{_dbapi} %__dbi_major db%{_dbapi}
%__dbi_other teardown:usecursors %__dbi_other usecursors
%__dbi_verbose verbose %__dbi_verbose verbose
%__dbi_mp_mmapsize mp_mmapsize=16Mb %__dbi_mp_mmapsize mp_mmapsize=16Mb
%__dbi_mp_size mp_size=2Mb %__dbi_mp_size mp_size=2Mb
# This is a colon (or white space) separated list of tokens for Berkeley
# dbi configuration.
%_dbi_config \ %_dbi_config \
%{__dbi_flags}\ %{__dbi_flags}\
%{__dbi_type}\ %{__dbi_type}\
@ -261,6 +265,7 @@
%{__dbi_mp_size}\ %{__dbi_mp_size}\
%{nil} %{nil}
# This is the list of tags for which indices will be built.
%_dbi_indices Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername %_dbi_indices Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername
#============================================================================== #==============================================================================

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-04-23 16:19-0400\n" "POT-Creation-Date: 2000-04-25 15:13-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -1987,156 +1987,166 @@ msgid " failed - "
msgstr "" msgstr ""
#. XXX legacy epoch-less requires/conflicts compatibility #. XXX legacy epoch-less requires/conflicts compatibility
#: lib/depends.c:434 #: lib/depends.c:439
#, c-format #, c-format
msgid "" msgid ""
"the \"B\" dependency needs an epoch (assuming same as \"A\")\n" "the \"B\" dependency needs an epoch (assuming same as \"A\")\n"
"\tA %s\tB %s\n" "\tA %s\tB %s\n"
msgstr "" msgstr ""
#: lib/depends.c:463 #: lib/depends.c:468
#, c-format #, c-format
msgid " %s A %s\tB %s\n" msgid " %s A %s\tB %s\n"
msgstr "" msgstr ""
#: lib/depends.c:792 #: lib/depends.c:797
#, c-format #, c-format
msgid "%s: %s satisfied by added file list.\n" msgid "%s: %s satisfied by added file list.\n"
msgstr "" msgstr ""
#: lib/depends.c:841 #: lib/depends.c:846
#, c-format #, c-format
msgid "%s: %s satisfied by added package.\n" msgid "%s: %s satisfied by added package.\n"
msgstr "" msgstr ""
#: lib/depends.c:844 #: lib/depends.c:849
#, c-format #, c-format
msgid "%s: %s satisfied by added package (shouldn't happen).\n" msgid "%s: %s satisfied by added package (shouldn't happen).\n"
msgstr "" msgstr ""
#: lib/depends.c:862 #: lib/depends.c:867
#, c-format #, c-format
msgid "%s: %s satisfied by added provide.\n" msgid "%s: %s satisfied by added provide.\n"
msgstr "" msgstr ""
#: lib/depends.c:895 #: lib/depends.c:896
#, c-format
msgid "%s: %s satisfied by Depends cache.\n"
msgstr ""
#: lib/depends.c:909
#, c-format #, c-format
msgid "%s: %s satisfied by rpmrc provides.\n" msgid "%s: %s satisfied by rpmrc provides.\n"
msgstr "" msgstr ""
#: lib/depends.c:923 #: lib/depends.c:937
#, c-format #, c-format
msgid "%s: %s satisfied by db file lists.\n" msgid "%s: %s satisfied by db file lists.\n"
msgstr "" msgstr ""
#: lib/depends.c:941 #: lib/depends.c:955
#, c-format #, c-format
msgid "%s: %s satisfied by db provides.\n" msgid "%s: %s satisfied by db provides.\n"
msgstr "" msgstr ""
#: lib/depends.c:959 #: lib/depends.c:973
#, c-format #, c-format
msgid "%s: %s satisfied by db packages.\n" msgid "%s: %s satisfied by db packages.\n"
msgstr "" msgstr ""
#: lib/depends.c:972 #: lib/depends.c:986
#, c-format #, c-format
msgid "%s: %s satisfied by rpmlib version.\n" msgid "%s: %s satisfied by rpmlib version.\n"
msgstr "" msgstr ""
#: lib/depends.c:982 #: lib/depends.c:996
#, c-format #, c-format
msgid "%s: %s unsatisfied.\n" msgid "%s: %s unsatisfied.\n"
msgstr "" msgstr ""
#. requirements are not satisfied. #. requirements are not satisfied.
#: lib/depends.c:1030 #: lib/depends.c:1048
#, c-format #, c-format
msgid "package %s require not satisfied: %s\n" msgid "package %s require not satisfied: %s\n"
msgstr "" msgstr ""
#. conflicts exist. #. conflicts exist.
#: lib/depends.c:1092 #: lib/depends.c:1110
#, c-format #, c-format
msgid "package %s conflicts: %s\n" msgid "package %s conflicts: %s\n"
msgstr "" msgstr ""
#: lib/depends.c:1222 #: lib/depends.c:1240
#, c-format #, c-format
msgid "loop in prerequisite chain: %s" msgid "loop in prerequisite chain: %s"
msgstr "" msgstr ""
#: lib/depends.c:1426 #: lib/depends.c:1444
#, c-format #, c-format
msgid "cannot read header at %d for dependency check" msgid "cannot read header at %d for dependency check"
msgstr "" msgstr ""
#: lib/db0.c:608 #: lib/db0.c:565
#, c-format #, c-format
msgid "bad db file %s" msgid "bad db file %s"
msgstr "" msgstr ""
#: lib/db0.c:617 #: lib/db0.c:574
#, c-format #, c-format
msgid "opening database mode 0x%x in %s\n" msgid "opening database mode 0x%x in %s\n"
msgstr "" msgstr ""
#: lib/db0.c:622 lib/url.c:445 #: lib/db0.c:579 lib/url.c:445
#, c-format #, c-format
msgid "failed to open %s: %s\n" msgid "failed to open %s: %s\n"
msgstr "" msgstr ""
#: lib/db0.c:634 #: lib/db0.c:591
#, c-format #, c-format
msgid "cannot get %s lock on database" msgid "cannot get %s lock on database"
msgstr "" msgstr ""
#: lib/db0.c:635 #: lib/db0.c:592
msgid "exclusive" msgid "exclusive"
msgstr "" msgstr ""
#: lib/db0.c:635 #: lib/db0.c:592
msgid "shared" msgid "shared"
msgstr "" msgstr ""
#: lib/db3.c:243 #: lib/db3.c:249
#, c-format #, c-format
msgid "dbiSetConfig: unrecognized db option: \"%s\" ignored\n" msgid "dbiSetConfig: unrecognized db option: \"%s\" ignored\n"
msgstr "" msgstr ""
#: lib/db3.c:269 #: lib/db3.c:277
#, c-format #, c-format
msgid "%s has invalid numeric value, skipped\n" msgid "%s has invalid numeric value, skipped\n"
msgstr "" msgstr ""
#: lib/db3.c:277 #: lib/db3.c:285
#, c-format #, c-format
msgid "%s has too large or too small long value, skipped\n" msgid "%s has too large or too small long value, skipped\n"
msgstr "" msgstr ""
#: lib/db3.c:285 #: lib/db3.c:293
#, c-format #, c-format
msgid "%s has too large or too small integer value, skipped\n" msgid "%s has too large or too small integer value, skipped\n"
msgstr "" msgstr ""
#: lib/db3.c:440 #: lib/db3.c:456
#, c-format #, c-format
msgid "closed db environment %s/%s(%s)\n" msgid "closed db environment %s/%s(%s)\n"
msgstr "" msgstr ""
#: lib/db3.c:451 #: lib/db3.c:468
#, c-format #, c-format
msgid "removed db environment %s/%s(%s)\n" msgid "removed db environment %s/%s(%s)\n"
msgstr "" msgstr ""
#: lib/db3.c:1050 #: lib/db3.c:505
#, c-format #, c-format
msgid "closed db index %s/%s(%s)\n" msgid "opening db environment %s/%s(%s) %s\n"
msgstr "" msgstr ""
#: lib/db3.c:1225 #: lib/db3.c:1117
#, c-format #, c-format
msgid "opened %s/%s(%s) %s\n" msgid "closed db index %s/%s(%s)\n"
msgstr ""
#: lib/db3.c:1195
#, c-format
msgid "opening db index %s/%s(%s) %s\n"
msgstr "" msgstr ""
#: lib/falloc.c:135 #: lib/falloc.c:135
@ -2150,7 +2160,7 @@ msgid ""
msgstr "" msgstr ""
#: lib/formats.c:69 lib/formats.c:86 lib/formats.c:106 lib/formats.c:138 #: lib/formats.c:69 lib/formats.c:86 lib/formats.c:106 lib/formats.c:138
#: lib/header.c:2188 lib/header.c:2204 lib/header.c:2223 #: lib/header.c:2190 lib/header.c:2206 lib/header.c:2225
msgid "(not a number)" msgid "(not a number)"
msgstr "" msgstr ""
@ -2183,74 +2193,74 @@ msgstr ""
msgid "grabData() RPM_STRING_TYPE count must be 1.\n" msgid "grabData() RPM_STRING_TYPE count must be 1.\n"
msgstr "" msgstr ""
#: lib/header.c:250 lib/header.c:813 #: lib/header.c:250 lib/header.c:815
#, c-format #, c-format
msgid "Data type %d not supported\n" msgid "Data type %d not supported\n"
msgstr "" msgstr ""
#: lib/header.c:1172 #: lib/header.c:1174
#, c-format #, c-format
msgid "Bad count for headerAddEntry(): %d\n" msgid "Bad count for headerAddEntry(): %d\n"
msgstr "" msgstr ""
#: lib/header.c:1581 #: lib/header.c:1583
#, c-format #, c-format
msgid "missing { after %" msgid "missing { after %"
msgstr "" msgstr ""
#: lib/header.c:1609 #: lib/header.c:1611
msgid "missing } after %{" msgid "missing } after %{"
msgstr "" msgstr ""
#: lib/header.c:1621 #: lib/header.c:1623
msgid "empty tag format" msgid "empty tag format"
msgstr "" msgstr ""
#: lib/header.c:1631 #: lib/header.c:1633
msgid "empty tag name" msgid "empty tag name"
msgstr "" msgstr ""
#: lib/header.c:1646 #: lib/header.c:1648
msgid "unknown tag" msgid "unknown tag"
msgstr "" msgstr ""
#: lib/header.c:1672 #: lib/header.c:1674
msgid "] expected at end of array" msgid "] expected at end of array"
msgstr "" msgstr ""
#: lib/header.c:1688 #: lib/header.c:1690
msgid "unexpected ]" msgid "unexpected ]"
msgstr "" msgstr ""
#: lib/header.c:1690 #: lib/header.c:1692
msgid "unexpected }" msgid "unexpected }"
msgstr "" msgstr ""
#: lib/header.c:1744 #: lib/header.c:1746
msgid "? expected in expression" msgid "? expected in expression"
msgstr "" msgstr ""
#: lib/header.c:1751 #: lib/header.c:1753
msgid "{ expected after ? in expression" msgid "{ expected after ? in expression"
msgstr "" msgstr ""
#: lib/header.c:1761 lib/header.c:1796 #: lib/header.c:1763 lib/header.c:1798
msgid "} expected in expression" msgid "} expected in expression"
msgstr "" msgstr ""
#: lib/header.c:1769 #: lib/header.c:1771
msgid ": expected following ? subexpression" msgid ": expected following ? subexpression"
msgstr "" msgstr ""
#: lib/header.c:1783 #: lib/header.c:1785
msgid "{ expected after : in expression" msgid "{ expected after : in expression"
msgstr "" msgstr ""
#: lib/header.c:1804 #: lib/header.c:1806
msgid "| expected at end of expression" msgid "| expected at end of expression"
msgstr "" msgstr ""
#: lib/header.c:1972 #: lib/header.c:1974
msgid "(unknown type)" msgid "(unknown type)"
msgstr "" msgstr ""
@ -2827,22 +2837,22 @@ msgstr ""
msgid "dbiTagsInit: unrecognized tag name: \"%s\" ignored\n" msgid "dbiTagsInit: unrecognized tag name: \"%s\" ignored\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:136 #: lib/rpmdb.c:135
#, c-format #, c-format
msgid "error getting record %s from %s index" msgid "error getting record %s from %s index"
msgstr "" msgstr ""
#: lib/rpmdb.c:157 #: lib/rpmdb.c:156
#, c-format #, c-format
msgid "error storing record %s into %s" msgid "error storing record %s into %s"
msgstr "" msgstr ""
#: lib/rpmdb.c:162 #: lib/rpmdb.c:161
#, c-format #, c-format
msgid "error removing record %s from %s" msgid "error removing record %s from %s"
msgstr "" msgstr ""
#: lib/rpmdb.c:343 #: lib/rpmdb.c:345
msgid "" msgid ""
"\n" "\n"
"--> Please run \"rpm --rebuilddb\" as root to convert your database from\n" "--> Please run \"rpm --rebuilddb\" as root to convert your database from\n"
@ -2850,145 +2860,145 @@ msgid ""
"\n" "\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:358 #: lib/rpmdb.c:360
#, c-format #, c-format
msgid "dbiOpenIndex: cannot open %s index" msgid "dbiOpen: cannot open %s index"
msgstr "" msgstr ""
#: lib/rpmdb.c:481 lib/rpmdb.c:1791 #: lib/rpmdb.c:473 lib/rpmdb.c:1795
msgid "no dbpath has been set" msgid "no dbpath has been set"
msgstr "" msgstr ""
#: lib/rpmdb.c:558 #: lib/rpmdb.c:551
msgid "" msgid ""
"old format database is present; use --rebuilddb to generate a new format " "old format database is present; use --rebuilddb to generate a new format "
"database" "database"
msgstr "" msgstr ""
#. error #. error
#: lib/rpmdb.c:743 #: lib/rpmdb.c:736
#, c-format #, c-format
msgid "cannot retrieve package \"%s\" from db" msgid "cannot retrieve package \"%s\" from db"
msgstr "" msgstr ""
#: lib/rpmdb.c:1077 #: lib/rpmdb.c:1076
#, c-format #, c-format
msgid "key \"%s\" not found in %s" msgid "key \"%s\" not found in %s"
msgstr "" msgstr ""
#: lib/rpmdb.c:1085 #: lib/rpmdb.c:1084
#, c-format #, c-format
msgid "key \"%s\" not removed from %s" msgid "key \"%s\" not removed from %s"
msgstr "" msgstr ""
#: lib/rpmdb.c:1111 #: lib/rpmdb.c:1110
#, c-format #, c-format
msgid "rpmdbRemove: cannot read header at 0x%x" msgid "rpmdbRemove: cannot read header at 0x%x"
msgstr "" msgstr ""
#: lib/rpmdb.c:1145 #: lib/rpmdb.c:1144
#, c-format #, c-format
msgid "removing 0 %s entries.\n" msgid "removing 0 %s entries.\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1152 #: lib/rpmdb.c:1151
#, c-format #, c-format
msgid "removing \"%s\" from %s index.\n" msgid "removing \"%s\" from %s index.\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1160 #: lib/rpmdb.c:1159
#, c-format #, c-format
msgid "removing %d entries in %s index:\n" msgid "removing %d entries in %s index:\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1164 #: lib/rpmdb.c:1163
#, c-format #, c-format
msgid "\t%6d %s\n" msgid "\t%6d %s\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1307 #: lib/rpmdb.c:1310
msgid "cannot allocate new instance in database" msgid "cannot allocate new instance in database"
msgstr "" msgstr ""
#: lib/rpmdb.c:1355 #: lib/rpmdb.c:1359
#, c-format #, c-format
msgid "adding 0 %s entries.\n" msgid "adding 0 %s entries.\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1368 #: lib/rpmdb.c:1372
#, c-format #, c-format
msgid "adding \"%s\" to %s index.\n" msgid "adding \"%s\" to %s index.\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1375 #: lib/rpmdb.c:1379
#, c-format #, c-format
msgid "adding %d entries to %s index:\n" msgid "adding %d entries to %s index:\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1379 #: lib/rpmdb.c:1383
#, c-format #, c-format
msgid "%6d %s\n" msgid "%6d %s\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1697 #: lib/rpmdb.c:1701
#, c-format #, c-format
msgid "cannot read header at %d for lookup" msgid "cannot read header at %d for lookup"
msgstr "" msgstr ""
#: lib/rpmdb.c:1816 #: lib/rpmdb.c:1820
#, c-format #, c-format
msgid "rebuilding database %s into %s\n" msgid "rebuilding database %s into %s\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1820 #: lib/rpmdb.c:1824
#, c-format #, c-format
msgid "temporary database %s already exists" msgid "temporary database %s already exists"
msgstr "" msgstr ""
#: lib/rpmdb.c:1826 #: lib/rpmdb.c:1830
#, c-format #, c-format
msgid "creating directory: %s\n" msgid "creating directory: %s\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1828 #: lib/rpmdb.c:1832
#, c-format #, c-format
msgid "error creating directory %s: %s" msgid "error creating directory %s: %s"
msgstr "" msgstr ""
#: lib/rpmdb.c:1835 #: lib/rpmdb.c:1839
#, c-format #, c-format
msgid "opening old database with dbi_major %d\n" msgid "opening old database with dbi_major %d\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1844 #: lib/rpmdb.c:1848
#, c-format #, c-format
msgid "opening new database with dbi_major %d\n" msgid "opening new database with dbi_major %d\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1866 #: lib/rpmdb.c:1870
#, c-format #, c-format
msgid "record number %d in database is bad -- skipping." msgid "record number %d in database is bad -- skipping."
msgstr "" msgstr ""
#: lib/rpmdb.c:1898 #: lib/rpmdb.c:1902
#, c-format #, c-format
msgid "cannot add record originally at %d" msgid "cannot add record originally at %d"
msgstr "" msgstr ""
#: lib/rpmdb.c:1916 #: lib/rpmdb.c:1920
msgid "failed to rebuild database; original database remains in place\n" msgid "failed to rebuild database; original database remains in place\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1924 #: lib/rpmdb.c:1928
msgid "failed to replace old database with new database!\n" msgid "failed to replace old database with new database!\n"
msgstr "" msgstr ""
#: lib/rpmdb.c:1926 #: lib/rpmdb.c:1930
#, c-format #, c-format
msgid "replace files in %s with files from %s to recover" msgid "replace files in %s with files from %s to recover"
msgstr "" msgstr ""
#: lib/rpmdb.c:1932 #: lib/rpmdb.c:1936
#, c-format #, c-format
msgid "failed to remove directory %s: %s\n" msgid "failed to remove directory %s: %s\n"
msgstr "" msgstr ""

View File

@ -4,9 +4,9 @@
#define EXIT_FAILURE 1 #define EXIT_FAILURE 1
#endif #endif
void *vmefail(void) void *vmefail(size_t size)
{ {
fprintf(stderr, _("memory alloc returned NULL.\n")); fprintf(stderr, _("memory alloc (%u bytes) returned NULL.\n"), size);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/*@notreached@*/ /*@notreached@*/
return NULL; return NULL;
@ -20,7 +20,7 @@ void * xmalloc (size_t size)
if (size == 0) size++; if (size == 0) size++;
value = malloc (size); value = malloc (size);
if (value == 0) if (value == 0)
value = vmefail(); value = vmefail(size);
return value; return value;
} }
@ -31,7 +31,7 @@ void * xcalloc (size_t nmemb, size_t size)
if (nmemb == 0) nmemb++; if (nmemb == 0) nmemb++;
value = calloc (nmemb, size); value = calloc (nmemb, size);
if (value == 0) if (value == 0)
value = vmefail(); value = vmefail(size);
return value; return value;
} }
@ -41,15 +41,16 @@ void * xrealloc (void *ptr, size_t size)
if (size == 0) size++; if (size == 0) size++;
value = realloc (ptr, size); value = realloc (ptr, size);
if (value == 0) if (value == 0)
value = vmefail(); value = vmefail(size);
return value; return value;
} }
char * xstrdup (const char *str) char * xstrdup (const char *str)
{ {
char *newstr = (char *) malloc (strlen(str) + 1); size_t size = strlen(str) + 1;
char *newstr = (char *) malloc (size);
if (newstr == 0) if (newstr == 0)
newstr = (char *) vmefail(); newstr = (char *) vmefail(size);
strcpy (newstr, str); strcpy (newstr, str);
return newstr; return newstr;
} }

View File

@ -204,7 +204,7 @@ char *alloca ();
/*@only@*/ void * xcalloc (size_t nmemb, size_t size); /*@only@*/ void * xcalloc (size_t nmemb, size_t size);
/*@only@*/ void * xrealloc (void *ptr, size_t size); /*@only@*/ void * xrealloc (void *ptr, size_t size);
/*@only@*/ char * xstrdup (const char *str); /*@only@*/ char * xstrdup (const char *str);
void *vmefail(void); void *vmefail(size_t size);
#if HAVE_MCHECK_H #if HAVE_MCHECK_H
#include <mcheck.h> #include <mcheck.h>
@ -213,10 +213,10 @@ void *vmefail(void);
/* Memory allocation via macro defs to get meaningful locations from mtrace() */ /* Memory allocation via macro defs to get meaningful locations from mtrace() */
#if HAVE_MCHECK_H && defined(__GNUC__) #if HAVE_MCHECK_H && defined(__GNUC__)
#define xmalloc(_size) (malloc(_size) ? : vmefail()) #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
#define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail()) #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
#define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail()) #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str))) #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
#endif /* HAVE_MCHECK_H && defined(__GNUC__) */ #endif /* HAVE_MCHECK_H && defined(__GNUC__) */
/* Retrofit glibc __progname */ /* Retrofit glibc __progname */