fix: legacy packages required provides EVR/Flags to be added.

fix: generating provides EVER was broke with epoch.
db3 tuned for installer speed (i.e. no locking, create/remove on fly).
add new_db_api and old_db_api macros to control precisely for db version used.

CVS patchset: 3691
CVS date: 2000/04/21 00:21:15
This commit is contained in:
jbj 2000-04-21 00:21:15 +00:00
parent eca43c56fb
commit ac6c6b7704
7 changed files with 145 additions and 110 deletions

View File

@ -8,6 +8,7 @@ static int __do_dbcursor_rmw = 0;
#include <rpmlib.h>
#include <rpmmacro.h>
#include <rpmurl.h> /* XXX urlPath proto */
#include "rpmdb.h"
/*@access dbiIndex@*/
@ -247,8 +248,6 @@ static int db_fini(dbiIndex dbi)
DB_ENV * dbenv = (DB_ENV *)dbi->dbi_dbenv;
#if defined(__USE_DB3)
char **dbconfig = NULL;
char * dbhome;
char * dbfile;
int rc;
if (dbenv == NULL) {
@ -256,21 +255,20 @@ static int db_fini(dbiIndex dbi)
return 0;
}
dbhome = alloca(strlen(dbi->dbi_file) + 1);
strcpy(dbhome, dbi->dbi_file);
dbfile = strrchr(dbhome, '/');
if (dbfile)
*dbfile++ = '\0';
else
dbfile = dbhome;
rc = dbenv->close(dbenv, 0);
rc = cvtdberr(dbi, "dbenv->close", rc, _debug);
if (__do_dbenv_remove < 0)
__do_dbenv_remove = rpmExpandNumeric("%{_db3_dbenv_remove}");
if (__do_dbenv_remove) {
rpmdb rpmdb = dbi->dbi_rpmdb;
const char * urlfn;
const char * dbhome;
int xx;
urlfn = rpmGenPath(rpmdb->db_root, rpmdb->db_home, NULL);
(void) urlPath(urlfn, &dbhome);
xx = db_env_create(&dbenv, 0);
xx = cvtdberr(dbi, "db_env_create", rc, _debug);
xx = dbenv->remove(dbenv, dbhome, dbconfig, 0);
@ -867,22 +865,21 @@ static int db3open(dbiIndex dbi)
#if defined(__USE_DB2) || defined(__USE_DB3)
DB * db = NULL;
char * dbhome;
char * dbfile;
u_int32_t dbflags;
DB_ENV * dbenv = NULL;
DB_TXN * txnid = NULL;
u_int32_t dbflags;
const char * urlfn;
const char * dbhome;
const char * dbfile = "packages.db3";
const char * dbsubfile;
dbhome = alloca(strlen(dbi->dbi_file) + 1);
strcpy(dbhome, dbi->dbi_file);
dbfile = strrchr(dbhome, '/');
if (dbfile)
*dbfile++ = '\0';
else
dbfile = dbhome;
dbflags = ( !(dbi->dbi_mode & O_RDWR) ? DB_RDONLY :
((dbi->dbi_mode & O_CREAT) ? DB_CREATE : 0));
urlfn = rpmGenPath(rpmdb->db_root, rpmdb->db_home, NULL);
(void) urlPath(urlfn, &dbhome);
dbsubfile = (dbi->dbi_rpmtag ? tagName(dbi->dbi_rpmtag) : "Packages"),
dbflags = 0;
if (!dbi->dbi_mode & O_RDWR) dbflags |= DB_RDONLY;
if ( dbi->dbi_mode & O_CREAT) dbflags |= DB_CREATE;
rc = db_init(dbi, dbhome, dbflags, &dbenv);
dbi->dbi_dbinfo = NULL;
@ -925,14 +922,8 @@ static int db3open(dbiIndex dbi)
rc = cvtdberr(dbi, "db->set_dup_compare", rc, _debug);
}
dbi->dbi_dbinfo = NULL;
#ifndef DYING /* XXX FIXME */
rc = db->open(db, "packages.db3", dbfile,
rc = db->open(db, dbfile, dbsubfile,
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}");

View File

@ -66,8 +66,8 @@ static /*@only@*/ const char *buildEVR(int_32 *e, const char *v, const char *r)
*p = '\0';
if (e) {
sprintf(p, "%d:", *e);
while (*p++)
;
while (*p)
p++;
}
(void) stpcpy( stpcpy( stpcpy(p, v) , "-") , r);
return pEVR;
@ -535,8 +535,8 @@ int headerMatchesDepFlags(Header h, const char *reqName, const char * reqEVR, in
*p = '\0';
if (headerGetEntry(h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL)) {
sprintf(p, "%d:", *epoch);
while (*p++)
;
while (*p)
p++;
}
(void) stpcpy( stpcpy( stpcpy(p, version) , "-") , release);
@ -832,8 +832,8 @@ alFileSatisfiesDepend(struct availableList * al,
*t = '\0';
if (p->epoch) {
sprintf(t, "%d:", *p->epoch);
while (*t++)
;
while (*t)
t++;
}
(void) stpcpy( stpcpy( stpcpy(t, p->version) , "-") , p->release);
rc = rangesOverlap(p->name, pEVR, pFlags, keyName, keyEVR, keyFlags);

View File

@ -828,12 +828,11 @@ void providePackageNVR(Header h)
int_32 * epoch;
const char *pEVR;
char *p;
int pFlags = RPMSENSE_EQUAL;
int_32 pFlags = RPMSENSE_EQUAL;
const char ** provides = NULL;
const char ** providesEVR = NULL;
int_32 * provideFlags = NULL;
int providesCount;
int type;
int i;
int bingo = 1;
@ -843,27 +842,39 @@ void providePackageNVR(Header h)
*p = '\0';
if (headerGetEntry(h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL)) {
sprintf(p, "%d:", *epoch);
while (*p++)
;
while (*p)
p++;
}
(void) stpcpy( stpcpy( stpcpy(p, version) , "-") , release);
/*
* Rpm prior to 3.0.3 does not have versioned provides.
* If no provides version info is available, then just add.
* If no provides at all are available, we can just add.
*/
if (!headerGetEntry(h, RPMTAG_PROVIDEVERSION, &type,
(void **) &providesEVR, &providesCount))
goto exit;
headerGetEntry(h, RPMTAG_PROVIDEFLAGS, &type,
(void **) &provideFlags, &providesCount);
if (!headerGetEntry(h, RPMTAG_PROVIDENAME, &type,
if (!headerGetEntry(h, RPMTAG_PROVIDENAME, NULL,
(void **) &provides, &providesCount)) {
goto exit;
}
/*
* Otherwise, fill in entries on legacy packages.
*/
if (!headerGetEntry(h, RPMTAG_PROVIDEVERSION, NULL,
(void **) &providesEVR, NULL)) {
for (i = 0; i < providesCount; i++) {
char * vdummy = "";
int_32 fdummy = RPMSENSE_ANY;
headerAddOrAppendEntry(h, RPMTAG_PROVIDEVERSION, RPM_STRING_ARRAY_TYPE,
&vdummy, 1);
headerAddOrAppendEntry(h, RPMTAG_PROVIDEFLAGS, RPM_INT32_TYPE,
&fdummy, 1);
}
goto exit;
}
headerGetEntry(h, RPMTAG_PROVIDEFLAGS, NULL,
(void **) &provideFlags, NULL);
for (i = 0; i < providesCount; i++) {
if (!(provideFlags[i] == RPMSENSE_EQUAL &&
!strcmp(name, provides[i]) && !strcmp(pEVR, providesEVR[i])))

View File

@ -23,11 +23,12 @@ int rpmdbRebuild(const char * rootdir)
int failed = 0;
int rc = 0;
int _filterDbDups; /* Filter duplicate entries ? (bug in pre rpm-3.0.4) */
int _preferDbiMajor;
int _old_db_api;
int _new_db_api;
_filterDbDups = rpmExpandNumeric("%{_filterdbdups}");
_preferDbiMajor = rpmExpandNumeric("%{_preferdb}");
fprintf(stderr, "*** rpmdbRebuild: filterdbdups %d preferdb %d\n", _filterDbDups, _preferDbiMajor);
_old_db_api = rpmExpandNumeric("%{_old_db_api}");
_new_db_api = rpmExpandNumeric("%{_new_db_api}");
tfn = rpmGetPath("%{_dbpath}", NULL);
if (!(tfn && tfn[0] != '%')) {
@ -74,11 +75,7 @@ fprintf(stderr, "*** rpmdbRebuild: filterdbdups %d preferdb %d\n", _filterDbDups
goto exit;
}
#if 0
_useDbiMajor = ((_preferDbiMajor >= 0) ? (_preferDbiMajor & 0x03) : -1);
#else
_useDbiMajor = -1;
#endif
_useDbiMajor = ((_old_db_api >= 0) ? (_old_db_api & 0x03) : -1);
rpmMessage(RPMMESS_DEBUG, _("opening old database with dbi_major %d\n"),
_useDbiMajor);
if (openDatabase(rootdir, dbpath, &olddb, O_RDONLY, 0644,
@ -87,7 +84,7 @@ fprintf(stderr, "*** rpmdbRebuild: filterdbdups %d preferdb %d\n", _filterDbDups
goto exit;
}
_useDbiMajor = ((_preferDbiMajor >= 0) ? (_preferDbiMajor & 0x03) : -1);
_useDbiMajor = ((_new_db_api >= 0) ? (_new_db_api & 0x03) : -1);
rpmMessage(RPMMESS_DEBUG, _("opening new database with dbi_major %d\n"),
_useDbiMajor);
if (openDatabase(rootdir, newdbpath, &newdb, O_RDWR | O_CREAT, 0644, 0)) {

View File

@ -60,9 +60,12 @@ struct _dbiIndex rpmdbi[] = {
{ "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 },
{ "dirindex.rpm", RPMTAG_DIRNAMES, 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 11
#define RPMDBI_MAX 12
};
/**
@ -311,15 +314,15 @@ static int dbiOpenIndex(rpmdb rpmdb, int dbix)
case 2:
case 1:
case 0:
if (mydbvecs[dbi->dbi_major] != NULL) {
errno = 0;
rc = (*mydbvecs[dbi->dbi_major]->open) (dbi);
if (rc == 0) {
dbi->dbi_vec = mydbvecs[dbi->dbi_major];
break;
}
if (mydbvecs[dbi->dbi_major] == NULL)
rc = 1;
break;
}
/*@fallthrough@*/
errno = 0;
rc = (*mydbvecs[dbi->dbi_major]->open) (dbi);
if (rc == 0)
dbi->dbi_vec = mydbvecs[dbi->dbi_major];
break;
case -1:
dbi->dbi_major = 4;
while (dbi->dbi_major-- > 0) {
@ -339,7 +342,7 @@ fprintf(stderr, "*** loop db%d rc %d errno %d %s\n", dbi->dbi_major, rc, errno,
fprintf(stderr, "*** FIXME: <message about how to convert db>\n");
fprintf(stderr, _("\n\
--> Please run \"rpm --rebuilddb\" as root to convert your database from\n\
db1 to db2 on-disk format.\n\
db1 to db3 on-disk format.\n\
\n\
"));
dbi->dbi_major--; /* XXX don't bother with db_185 */
@ -470,6 +473,12 @@ static /*@only@*/ rpmdb newRpmdb(const char * root, const char * home,
int mode, int perms, int flags)
{
rpmdb db = xcalloc(sizeof(*db), 1);
static int _initialized = 0;
if (!_initialized) {
_useDbiMajor = rpmExpandNumeric("%{_old_db_api}");
_initialized = 1;
}
*db = dbTemplate; /* structure assignment */

View File

@ -1,4 +1,4 @@
# $Id: macros.in,v 1.51 2000/04/19 16:03:49 jbj Exp $
# $Id: macros.in,v 1.52 2000/04/21 00:21:15 jbj Exp $
#==============================================================================
# Macro naming conventions (preliminary):
#
@ -200,17 +200,44 @@
#
#%vendor
# Preferred db interface:
# Choose db interface:
# 0 linux glibc libdb1 routines.
# 1 db_185.h interface in db2/db3 libdb.a.
# 2 native db2 interface.
# 3 native db3 interface.
%_preferdb 3
%_db3_flags create:mpool
%_db3_dbenv_remove yes
%_db3_use_falloc no
# -1 db3 -> db2 -> db1 -> db0 (as available).
# There are two macros so that --rebuilddb can convert old_db_api -> new_db_api.
%_old_db_api 3
%_new_db_api 3
# Filter duplicate entries in db (needed only to correct bug pre rpm-3.0.4)
# This is a colon separated list of tokens for DB3 open flags.
# recover DB_RECOVER
# recover_fatal DB_RECOVER_FATAL
# create DB_CREATE
# lockdown DB_LOCKDOWN
# cdb DB_INIT_CDB
# lock DB_INIT_LOCK supported
# log DB_INIT_LOG
# mpool DB_INIT_MPOOL supported
# txn DB_INIT_TXN
# nommap DB_NOMMAP
# private DB_PRIVATE supported
# shared DB_SYSTEM_MEM supported (but check /usr/bin/ipcs output)
# thread DB_THREAD
# txn_nosync DB_TXN_NOSYNC
#
# The (intended) default value for Red Hat Linux is
# mpool:shared:lock
#
%_db3_flags create:mpool:private
# Should the DB3 environment be removed after use (experimental)?
%_db3_dbenv_remove yes
# Should DB3 cursors be used in get/put/del operations (experimental)?
%_db3_use_cursors yes
# Filter duplicate entries in db (needed only to correct early rpm-3.0.4 bug)
%_filterdbdups no
#==============================================================================

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-04-19 18:07-0400\n"
"POT-Creation-Date: 2000-04-20 19:57-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"
@ -2676,64 +2676,64 @@ msgstr ""
msgid "display a verbose file listing"
msgstr ""
#: lib/rebuilddb.c:34 lib/rpmdb.c:491
#: lib/rebuilddb.c:36 lib/rpmdb.c:500
msgid "no dbpath has been set"
msgstr ""
#: lib/rebuilddb.c:59
#: lib/rebuilddb.c:61
#, c-format
msgid "rebuilding database %s into %s\n"
msgstr ""
#: lib/rebuilddb.c:63
#: lib/rebuilddb.c:65
#, c-format
msgid "temporary database %s already exists"
msgstr ""
#: lib/rebuilddb.c:69
#: lib/rebuilddb.c:71
#, c-format
msgid "creating directory: %s\n"
msgstr ""
#: lib/rebuilddb.c:71
#: lib/rebuilddb.c:73
#, c-format
msgid "error creating directory %s: %s"
msgstr ""
#: lib/rebuilddb.c:82
#: lib/rebuilddb.c:80
#, c-format
msgid "opening old database with dbi_major %d\n"
msgstr ""
#: lib/rebuilddb.c:91
#: lib/rebuilddb.c:89
#, c-format
msgid "opening new database with dbi_major %d\n"
msgstr ""
#: lib/rebuilddb.c:113
#: lib/rebuilddb.c:111
#, c-format
msgid "record number %d in database is bad -- skipping."
msgstr ""
#: lib/rebuilddb.c:145
#: lib/rebuilddb.c:143
#, c-format
msgid "cannot add record originally at %d"
msgstr ""
#: lib/rebuilddb.c:161
#: lib/rebuilddb.c:159
msgid "failed to rebuild database; original database remains in place\n"
msgstr ""
#: lib/rebuilddb.c:169
#: lib/rebuilddb.c:167
msgid "failed to replace old database with new database!\n"
msgstr ""
#: lib/rebuilddb.c:171
#: lib/rebuilddb.c:169
#, c-format
msgid "replace files in %s with files from %s to recover"
msgstr ""
#: lib/rebuilddb.c:177
#: lib/rebuilddb.c:175
#, c-format
msgid "failed to remove directory %s: %s\n"
msgstr ""
@ -2821,27 +2821,27 @@ msgstr ""
msgid "OK"
msgstr ""
#: lib/rpmdb.c:115
#: lib/rpmdb.c:118
#, c-format
msgid "error getting record %s from %s"
msgstr ""
#: lib/rpmdb.c:136
#: lib/rpmdb.c:139
#, c-format
msgid "error storing record %s into %s"
msgstr ""
#: lib/rpmdb.c:141
#: lib/rpmdb.c:144
#, c-format
msgid "error removing record %s into %s"
msgstr ""
#: lib/rpmdb.c:299
#: lib/rpmdb.c:302
#, c-format
msgid "bad db file %s"
msgstr ""
#: lib/rpmdb.c:340
#: lib/rpmdb.c:343
msgid ""
"\n"
"--> Please run \"rpm --rebuilddb\" as root to convert your database from\n"
@ -2849,83 +2849,83 @@ msgid ""
"\n"
msgstr ""
#: lib/rpmdb.c:356
#: lib/rpmdb.c:359
#, c-format
msgid "cannot open file %s: %s"
msgstr ""
#: lib/rpmdb.c:560
#: lib/rpmdb.c:569
msgid ""
"old format database is present; use --rebuilddb to generate a new format "
"database"
msgstr ""
#. error
#: lib/rpmdb.c:744
#: lib/rpmdb.c:753
#, c-format
msgid "cannot retrieve package \"%s\" from db"
msgstr ""
#: lib/rpmdb.c:1076
#: lib/rpmdb.c:1085
#, c-format
msgid "key \"%s\" not found in %s"
msgstr ""
#: lib/rpmdb.c:1084
#: lib/rpmdb.c:1093
#, c-format
msgid "key \"%s\" not removed from %s"
msgstr ""
#: lib/rpmdb.c:1110
#: lib/rpmdb.c:1119
#, c-format
msgid "rpmdbRemove: cannot read header at 0x%x"
msgstr ""
#: lib/rpmdb.c:1143
#: lib/rpmdb.c:1152
#, c-format
msgid "removing 0 %s entries.\n"
msgstr ""
#: lib/rpmdb.c:1150
#: lib/rpmdb.c:1159
#, c-format
msgid "removing \"%s\" from %s index.\n"
msgstr ""
#: lib/rpmdb.c:1158
#: lib/rpmdb.c:1167
#, c-format
msgid "removing %d entries in %s index:\n"
msgstr ""
#: lib/rpmdb.c:1162
#: lib/rpmdb.c:1171
#, c-format
msgid "\t%6d %s\n"
msgstr ""
#: lib/rpmdb.c:1305
#: lib/rpmdb.c:1314
msgid "cannot allocate new instance in database"
msgstr ""
#: lib/rpmdb.c:1352
#: lib/rpmdb.c:1361
#, c-format
msgid "adding 0 %s entries.\n"
msgstr ""
#: lib/rpmdb.c:1365
#: lib/rpmdb.c:1374
#, c-format
msgid "adding \"%s\" to %s index.\n"
msgstr ""
#: lib/rpmdb.c:1372
#: lib/rpmdb.c:1381
#, c-format
msgid "adding %d entries to %s index:\n"
msgstr ""
#: lib/rpmdb.c:1376
#: lib/rpmdb.c:1385
#, c-format
msgid "%6d %s\n"
msgstr ""
#: lib/rpmdb.c:1691
#: lib/rpmdb.c:1700
#, c-format
msgid "cannot read header at %d for lookup"
msgstr ""