Fix db return code handling, majorly horked.

Autoconf detection of db-3.1.
Move --all to query/verify popt table.

CVS patchset: 3829
CVS date: 2000/06/11 19:15:27
This commit is contained in:
jbj 2000-06-11 19:15:27 +00:00
parent 812fe27549
commit bed61632d7
11 changed files with 502 additions and 480 deletions

View File

@ -309,28 +309,35 @@ dnl will fail.
AC_CHECK_LIB(port, writev)
DBLIBOBJS=""
libdb3=""
libdb2=""
libdb1=""
PTHREAD=""
dnl Check for Berkeley db3 API.
AC_CHECK_FUNC(db_create, [DBLIBOBJS="$DBLIBOBJS db3.c"],
AC_CHECK_LIB(db, db_create, [LIBS="$LIBS $PTHREAD"; DBLIBOBJS="$DBLIBOBJS db3.c"],
AC_CHECK_LIB(db-3.0, db_create, [LIBS="$LIBS $PTHREAD"; DBLIBOBJS="$DBLIBOBJS db3.c"],,$PTHREAD))
AC_CHECK_LIB(db-3.1, db_create, [LIBS="$LIBS $PTHREAD"; DBLIBOBJS="$DBLIBOBJS db3.c" ; libdb3="-L /usr/lib -ldb-3.1"],
AC_CHECK_LIB(db-3.0, db_create, [LIBS="$LIBS $PTHREAD"; DBLIBOBJS="$DBLIBOBJS db3.c"; libdb3="-L /usr/lib -ldb-3.0"],,$PTHREAD)))
)
dnl Check for Berkeley db2 API.
dnl AC_CHECK_FUNC(db_open, [DBLIBOBJS="$DBLIBOBJS db2.c"],
dnl AC_CHECK_LIB(db, db_open, [LIBS="$LIBS -ldb"; DBLIBOBJS="$DBLIBOBJS db2.c"])
dnl AC_CHECK_LIB(db, db_open, [LIBS="$LIBS"; DBLIBOBJS="$DBLIBOBJS db2.c" ; libdb2="-L /usr/lib -ldb"])
dnl )
dnl Check for Berkeley db1 API retrofit to db2/db3 database.
dnl AC_CHECK_FUNC(dbopen, [DBLIBOBJS="$DBLIBOBJS db1.c"],
dnl AC_CHECK_LIB(db, dbopen, [DBLIBOBJS="$DBLIBOBJS db1.c"])
dnl )
dnl Check for Berkeley db1 API in glibc.
AC_CHECK_LIB(db1, dbopen, [DBLIBOBJS="$DBLIBOBJS db1.c"])
AC_CHECK_LIB(db1, dbopen, [DBLIBOBJS="$DBLIBOBJS db1.c" ; libdb1="-L /usr/lib -ldb1"])
if test X"$DBLIBOBJS" = X; then
AC_MSG_ERROR([sorry rpm requires libdb.a or libdb1.a (from the Berkeley db package)])
AC_MSG_ERROR([sorry rpm requires libdb-3.x.a or libdb1.a (from the Berkeley db package)])
fi
dnl AC_DEFINE_UNQUOTED(DBLIBOBJS, "$DBLIBOBJS")
AC_SUBST(DBLIBOBJS)
AC_SUBST(libdb3)
AC_SUBST(libdb2)
AC_SUBST(libdb1)
for dbi in $DBLIBOBJS; do
case $dbi in

View File

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

View File

@ -446,7 +446,6 @@ static int db_fini(dbiIndex dbi, const char * dbhome, const char * dbfile,
DB_ENV * dbenv = dbi->dbi_dbenv;
#if defined(__USE_DB3)
char **dbconfig = NULL;
int rc;
if (dbenv == NULL) {
@ -466,7 +465,11 @@ static int db_fini(dbiIndex dbi, const char * dbhome, const char * dbfile,
xx = db_env_create(&dbenv, 0);
xx = cvtdberr(dbi, "db_env_create", rc, _debug);
xx = dbenv->remove(dbenv, dbhome, dbconfig, 0);
#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 1
xx = dbenv->remove(dbenv, dbhome, 0);
#else
xx = dbenv->remove(dbenv, dbhome, NULL, 0);
#endif
xx = cvtdberr(dbi, "dbenv->remove", rc, _debug);
if (dbfile)
@ -540,8 +543,12 @@ static int db_init(dbiIndex dbi, const char *dbhome, const char *dbfile,
/* dbenv->set_tx_max(???) */
/* dbenv->set_tx_recover(???) */
if (dbi->dbi_no_fsync) {
#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 1
xx = db_env_set_func_fsync(db3_fsync_disable);
#else
xx = dbenv->set_func_fsync(dbenv, db3_fsync_disable);
xx = cvtdberr(dbi, "dbenv->set_func_fsync", xx, _debug);
#endif
xx = cvtdberr(dbi, "db_env_set_func_fsync", xx, _debug);
}
}
#else /* __USE_DB3 */
@ -554,7 +561,11 @@ static int db_init(dbiIndex dbi, const char *dbhome, const char *dbfile,
#endif /* __USE_DB3 */
#if defined(__USE_DB3)
#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 1
rc = dbenv->open(dbenv, dbhome, eflags, dbi->dbi_perms);
#else
rc = dbenv->open(dbenv, dbhome, NULL, eflags, dbi->dbi_perms);
#endif
rc = cvtdberr(dbi, "dbenv->open", rc, _debug);
if (rc)
goto errxit;

View File

@ -58,12 +58,14 @@ static void rpmQVSourceArgCallback( /*@unused@*/ poptContext con,
struct poptOption rpmQVSourcePoptTable[] = {
{ NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA,
rpmQVSourceArgCallback, 0, NULL, NULL },
{ "all", 'a', 0, 0, 'a',
N_("query/verify all packages"), NULL },
{ "file", 'f', 0, 0, 'f',
N_("query package owning file"), "FILE" },
N_("query/verify package owning file"), "FILE" },
{ "group", 'g', 0, 0, 'g',
N_("query packages in group"), "GROUP" },
N_("query/verify packages in group"), "GROUP" },
{ "package", 'p', 0, 0, 'p',
N_("query a package file"), NULL },
N_("query/verify a package file"), NULL },
{ "query", 'q', 0, NULL, 'q',
N_("rpm query mode"), NULL },
{ "querybynumber", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0,

View File

@ -1363,7 +1363,6 @@ static int rpmdbGrowIterator(rpmdbMatchIterator mi,
{
dbiIndex dbi = NULL;
dbiIndexSet set = NULL;
int i;
int rc;
int xx;
@ -1381,12 +1380,8 @@ static int rpmdbGrowIterator(rpmdbMatchIterator mi,
rc = dbiSearch(dbi, keyp, keylen, &set);
xx = dbiCclose(dbi, NULL, 0);
switch (rc) {
default:
case -1: /* error */
case 1: /* not found */
break;
case 0: /* success */
if (rc == 0) { /* success */
int i;
for (i = 0; i < set->count; i++)
set->recs[i].fpNum = fpNum;
@ -1400,7 +1395,6 @@ static int rpmdbGrowIterator(rpmdbMatchIterator mi,
set->count * sizeof(*(mi->mi_set->recs)));
mi->mi_set->count += set->count;
}
break;
}
if (set)
@ -1476,16 +1470,10 @@ fprintf(stderr, "*** RMW %s %p\n", tagName(rpmtag), dbi->dbi_rmw);
rc = dbiSearch(dbi, keyp, keylen, &set);
xx = dbiCclose(dbi, NULL, 0);
}
switch (rc) {
default:
case -1: /* error */
case 1: /* not found */
if (rc) { /* error/not found */
if (set)
dbiFreeIndexSet(set);
return NULL;
/*@notreached@*/ break;
case 0: /* success */
break;
}
}
@ -1530,19 +1518,14 @@ static inline int removeIndexEntry(dbiIndex dbi, const char * keyp,
rc = dbiSearch(dbi, keyp, 0, &set);
switch (rc) {
case -1: /* error */
rc = 1;
break; /* error message already generated from dbindex.c */
case 1: /* not found */
if (rc < 0) /* not found */
rc = 0;
break;
case 0: /* success */
if (dbiPruneSet(set, rec, 1, sizeof(*rec), 1))
break;
if (dbiUpdateIndex(dbi, keyp, set))
else if (rc > 0) /* error */
rc = 1; /* error message already generated from dbindex.c */
else { /* success */
if (!dbiPruneSet(set, rec, 1, sizeof(*rec), 1) &&
dbiUpdateIndex(dbi, keyp, set))
rc = 1;
break;
}
if (set) {
@ -1697,20 +1680,16 @@ static inline int addIndexEntry(dbiIndex dbi, const char *index, dbiIndexItem re
rc = dbiSearch(dbi, index, 0, &set);
switch (rc) {
default:
case -1: /* error */
rc = 1;
break;
case 1: /* not found */
rc = 0;
set = xcalloc(1, sizeof(*set));
/*@fallthrough@*/
case 0: /* success */
if (rc > 0) {
rc = 1; /* error */
} else {
if (rc < 0) { /* not found */
rc = 0;
set = xcalloc(1, sizeof(*set));
}
dbiAppendSet(set, rec, 1, sizeof(*rec), 0);
if (dbiUpdateIndex(dbi, index, set))
rc = 1;
break;
}
if (set) {

View File

@ -155,6 +155,9 @@ __SSH = @__SSH@
__STRIP = @__STRIP@
__TAR = @__TAR@
l = @l@
libdb1 = @libdb1@
libdb2 = @libdb2@
libdb3 = @libdb3@
testdir = @testdir@
tmpdir = @tmpdir@
varprefix = @varprefix@
@ -228,7 +231,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \

File diff suppressed because it is too large Load Diff

View File

@ -155,6 +155,9 @@ __SSH = @__SSH@
__STRIP = @__STRIP@
__TAR = @__TAR@
l = @l@
libdb1 = @libdb1@
libdb2 = @libdb2@
libdb3 = @libdb3@
testdir = @testdir@
tmpdir = @tmpdir@
varprefix = @varprefix@
@ -334,7 +337,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \

22
rpm.c
View File

@ -100,7 +100,9 @@ extern struct rpmBuildArguments rpmBTArgs;
static struct poptOption optionsTable[] = {
{ "addsign", '\0', 0, 0, GETOPT_ADDSIGN, NULL, NULL},
/* all and allmatches both using 'a' is dumb */
#ifdef DYING
{ "all", 'a', 0, 0, 'a', NULL, NULL},
#endif
{ "allfiles", '\0', 0, &allFiles, 0, NULL, NULL},
{ "allmatches", '\0', 0, &allMatches, 0, NULL, NULL},
{ "badreloc", '\0', 0, &badReloc, 0, NULL, NULL},
@ -539,7 +541,9 @@ int main(int argc, const char ** argv)
{
enum modes bigMode = MODE_UNKNOWN;
QVA_t *qva = &rpmQVArgs;
#ifdef DYING
enum rpmQVSources QVSource = RPMQV_PACKAGE;
#endif
int arg;
int installFlags = 0, uninstallFlags = 0, interfaceFlags = 0;
int verifyFlags;
@ -658,6 +662,7 @@ int main(int argc, const char ** argv)
if (qva->qva_queryFormat) xfree(qva->qva_queryFormat);
memset(qva, 0, sizeof(*qva));
qva->qva_source = RPMQV_PACKAGE;
qva->qva_mode = ' ';
qva->qva_char = ' ';
@ -671,6 +676,7 @@ int main(int argc, const char ** argv)
bigMode = MODE_CHECKSIG;
break;
#ifdef DYING
case 'q':
if (bigMode != MODE_UNKNOWN && bigMode != MODE_QUERY)
argerror(_("only one major mode may be specified"));
@ -683,6 +689,7 @@ int main(int argc, const char ** argv)
argerror(_("only one major mode may be specified"));
bigMode = MODE_VERIFY;
break;
#endif
case 'u':
if (bigMode != MODE_UNKNOWN && bigMode != MODE_UNINSTALL)
@ -728,6 +735,7 @@ int main(int argc, const char ** argv)
upgrade = 1;
break;
#ifdef DYING
case 'p':
if (QVSource != RPMQV_PACKAGE && QVSource != RPMQV_RPM)
argerror(_("one type of query/verify may be performed at a " "time"));
@ -754,6 +762,7 @@ int main(int argc, const char ** argv)
"time"));
QVSource = RPMQV_ALL;
break;
#endif
case GETOPT_RESIGN:
if (bigMode != MODE_UNKNOWN && bigMode != MODE_RESIGN)
@ -849,10 +858,9 @@ int main(int argc, const char ** argv)
}
if (qva->qva_sourceCount) {
if (QVSource != RPMQV_PACKAGE || qva->qva_sourceCount > 1)
if (qva->qva_sourceCount > 1)
argerror(_("one type of query/verify may be performed at a "
"time"));
QVSource = qva->qva_source;
}
if (qva->qva_flags && (bigMode & ~MODES_QV))
@ -861,7 +869,7 @@ int main(int argc, const char ** argv)
if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
argerror(_("unexpected query format"));
if (QVSource != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
argerror(_("unexpected query source"));
if (!(bigMode == MODE_INSTALL) && force)
@ -1174,7 +1182,7 @@ int main(int argc, const char ** argv)
case MODE_QUERY:
qva->qva_prefix = rootdir;
if (QVSource == RPMQV_ALL) {
if (qva->qva_source == RPMQV_ALL) {
if (poptPeekArg(optCon))
argerror(_("extra arguments given for query of all packages"));
@ -1183,7 +1191,7 @@ int main(int argc, const char ** argv)
if (!poptPeekArg(optCon))
argerror(_("no arguments given for query"));
while ((pkg = poptGetArg(optCon)))
ec += rpmQuery(qva, QVSource, pkg);
ec += rpmQuery(qva, qva->qva_source, pkg);
}
break;
@ -1196,7 +1204,7 @@ int main(int argc, const char ** argv)
qva->qva_prefix = rootdir;
qva->qva_flags = verifyFlags;
if (QVSource == RPMQV_ALL) {
if (qva->qva_source == RPMQV_ALL) {
if (poptPeekArg(optCon))
argerror(_("extra arguments given for verify of all packages"));
ec = rpmVerify(qva, RPMQV_ALL, NULL);
@ -1204,7 +1212,7 @@ int main(int argc, const char ** argv)
if (!poptPeekArg(optCon))
argerror(_("no arguments given for verify"));
while ((pkg = poptGetArg(optCon)))
ec += rpmVerify(qva, QVSource, pkg);
ec += rpmVerify(qva, qva->qva_source, pkg);
}
break;
}

20
rpmqv.c
View File

@ -165,7 +165,9 @@ static struct poptOption optionsTable[] = {
#endif
/* XXX colliding options */
#ifdef DYING
{ "all", 'a', 0, 0, 'a', NULL, NULL},
#endif
#if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT)
{ NULL, 'i', 0, 0, 'i', NULL, NULL},
#endif
@ -638,8 +640,10 @@ int main(int argc, const char ** argv)
#ifdef IAM_RPMQV
QVA_t *qva = &rpmQVArgs;
#ifdef DYING
enum rpmQVSources QVSource = RPMQV_PACKAGE;
#endif
#endif
#ifdef IAM_RPMBT
struct rpmBuildArguments *ba = &rpmBTArgs;
@ -760,6 +764,7 @@ int main(int argc, const char ** argv)
#ifdef IAM_RPMQV
if (qva->qva_queryFormat) xfree(qva->qva_queryFormat);
memset(qva, 0, sizeof(*qva));
qva->qva_source = RPMQV_PACKAGE;
qva->qva_mode = ' ';
qva->qva_char = ' ';
#endif
@ -855,6 +860,7 @@ int main(int argc, const char ** argv)
} break;
#endif /* IAM_RPMEIU */
#ifdef DYING
#ifdef IAM_RPMQV
case 'q':
if (bigMode != MODE_UNKNOWN && bigMode != MODE_QUERY)
@ -896,6 +902,7 @@ int main(int argc, const char ** argv)
QVSource = RPMQV_ALL;
break;
#endif /* IAM_RPMQV */
#endif
#ifdef IAM_RPMDB
case GETOPT_REBUILDDB:
@ -998,10 +1005,9 @@ int main(int argc, const char ** argv)
}
if (qva->qva_sourceCount) {
if (QVSource != RPMQV_PACKAGE || qva->qva_sourceCount > 1)
if (qva->qva_sourceCount > 1)
argerror(_("one type of query/verify may be performed at a "
"time"));
QVSource = qva->qva_source;
}
if (qva->qva_flags && (bigMode & ~MODES_QV))
argerror(_("unexpected query flags"));
@ -1009,7 +1015,7 @@ int main(int argc, const char ** argv)
if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
argerror(_("unexpected query format"));
if (QVSource != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
argerror(_("unexpected query source"));
#endif
@ -1459,7 +1465,7 @@ int main(int argc, const char ** argv)
{ const char * pkg;
qva->qva_prefix = rootdir;
if (QVSource == RPMQV_ALL) {
if (qva->qva_source == RPMQV_ALL) {
if (poptPeekArg(optCon))
argerror(_("extra arguments given for query of all packages"));
@ -1468,7 +1474,7 @@ int main(int argc, const char ** argv)
if (!poptPeekArg(optCon))
argerror(_("no arguments given for query"));
while ((pkg = poptGetArg(optCon)))
ec += rpmQuery(qva, QVSource, pkg);
ec += rpmQuery(qva, qva->qva_source, pkg);
}
} break;
@ -1484,7 +1490,7 @@ int main(int argc, const char ** argv)
qva->qva_prefix = rootdir;
qva->qva_flags = verifyFlags;
if (QVSource == RPMQV_ALL) {
if (qva->qva_source == RPMQV_ALL) {
if (poptPeekArg(optCon))
argerror(_("extra arguments given for verify of all packages"));
ec = rpmVerify(qva, RPMQV_ALL, NULL);
@ -1492,7 +1498,7 @@ int main(int argc, const char ** argv)
if (!poptPeekArg(optCon))
argerror(_("no arguments given for verify"));
while ((pkg = poptGetArg(optCon)))
ec += rpmVerify(qva, QVSource, pkg);
ec += rpmVerify(qva, qva->qva_source, pkg);
}
} break;

View File

@ -155,6 +155,9 @@ __SSH = @__SSH@
__STRIP = @__STRIP@
__TAR = @__TAR@
l = @l@
libdb1 = @libdb1@
libdb2 = @libdb2@
libdb3 = @libdb3@
testdir = @testdir@
tmpdir = @tmpdir@
varprefix = @varprefix@
@ -228,7 +231,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \