RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES macros.in rpm/rpmdb/ db3.c rpmdb.c rpmdb.h

From: Jeff Johnson <jbj@rpm5.org>
Date: Fri 14 Dec 2007 - 04:35:49 CET
Message-Id: <20071214033549.0C37B34845A@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   14-Dec-2007 04:35:49
  Branch: HEAD                             Handle: 2007121403354800

  Modified files:
    rpm                     CHANGES macros.in
    rpm/rpmdb               db3.c rpmdb.c rpmdb.h

  Log:
    - add Foo:Bar:Baz indices for now.
    - permit arbitrary tags to be indexed by "Name", not Tag_0x12345678.
    - permit tag aliases in rpmdb index names (Filedigests <-> Filemd5s).
    - remember (and use) the configured dbi names, not tagName() returns.
    - fix: configure rpmdb indices using Filedigests, not older Filemd5s.

  Summary:
    Revision    Changes     Path
    1.1986      +5  -0      rpm/CHANGES
    1.209       +3  -3      rpm/macros.in
    1.83        +27 -19     rpm/rpmdb/db3.c
    1.227       +111 -69    rpm/rpmdb/rpmdb.c
    1.70        +14 -2      rpm/rpmdb/rpmdb.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1985 -r1.1986 CHANGES
  --- rpm/CHANGES	13 Dec 2007 23:17:57 -0000	1.1985
  +++ rpm/CHANGES	14 Dec 2007 03:35:48 -0000	1.1986
  @@ -1,4 +1,9 @@
   5.0b1 -> 5.0b2:
  +    - jbj: add Foo:Bar:Baz indices for now.
  +    - jbj: permit arbitrary tags to be indexed by "Name", not Tag_0x12345678.
  +    - jbj: permit tag aliases in rpmdb index names (Filedigests <-> Filemd5s).
  +    - jbj: remember (and use) the configured dbi names, not tagName() returns.
  +    - jbj: fix: configure rpmdb indices using Filedigests, not older Filemd5s.
       - jbj: insure that he->tag is set for use by format extensions.
       - rse: do not segfault on invalid usages like "rpm -qa '!name=foo'"
       - jbj: fix: explicit rpmtsOpenDB on -Kvv code paths.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/macros.in
  ============================================================================
  $ cvs diff -u -r1.208 -r1.209 macros.in
  --- rpm/macros.in	7 Dec 2007 19:54:18 -0000	1.208
  +++ rpm/macros.in	14 Dec 2007 03:35:48 -0000	1.209
  @@ -1,7 +1,7 @@
   #/*! \page config_macros Default configuration: @USRLIBRPM@/macros
   # \verbatim
   #
  -# $Id: macros.in,v 1.208 2007/12/07 19:54:18 jbj Exp $
  +# $Id: macros.in,v 1.209 2007/12/14 03:35:48 jbj Exp $
   #
   # This is a global RPM configuration file. All changes made here will
   # be lost when the rpm package is upgraded. Any per-system configuration
  @@ -663,8 +663,8 @@
   
   # database tag configuration
   %_dbi_tags                      %{expand:%%{_dbi_tags_%{_dbapi_used}}}
  -%_dbi_tags_3                    Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername:Dirnames:Requireversion:Provideversion:Installtid:Sigmd5:Sha1header:Filemd5s:Pubkeys:Packagecolor:Nvra:Sourcepkgid
  -%_dbi_tags_4                    Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername:Dirnames:Requireversion:Provideversion:Installtid:Sigmd5:Sha1header:Filemd5s:Pubkeys:Packagecolor:Nvra:Sourcepkgid
  +%_dbi_tags_3                    Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername:Dirnames:Requireversion:Provideversion:Installtid:Sigmd5:Sha1header:Filedigests:Pubkeys:Packagecolor:Nvra:Sourcepkgid:Foo:Bar:Baz
  +%_dbi_tags_4                    Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername:Dirnames:Requireversion:Provideversion:Installtid:Sigmd5:Sha1header:Filedigests:Pubkeys:Packagecolor:Nvra:Sourcepkgid
   
   # database configuration: Berkeley-DB [dbapi 3 hooks]
   %_dbi_config_3                  %{_dbi_btconfig}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/db3.c
  ============================================================================
  $ cvs diff -u -r1.82 -r1.83 db3.c
  --- rpm/rpmdb/db3.c	6 Dec 2007 14:47:50 -0000	1.82
  +++ rpm/rpmdb/db3.c	14 Dec 2007 03:35:48 -0000	1.83
  @@ -174,22 +174,27 @@
   /*@=globuse =mustmod @*/
   
   /**
  - * Return (possibly renamed) tagName. Handles Filedigests -> Filemd5s renaming.
  - * @param value		tag value
  + * Return (possibly renamed) tagName. Handles arbitrary tags.
  + * @param rpmdb		rpm database
  + * @param dbi		rpm database index
    * @return		tag string
    */
   /*@observer@*/
  -static const char * mapTagName(int value)
  +static const char * mapTagName(rpmdb rpmdb, dbiIndex dbi)
   	/*@*/
   {
  -    const char * s = tagName(value);
  -    if (s == NULL)
  -	s = "";
  -#ifdef	NOTYET
  -    else if (!strcmp(s, "Filedigests"))
  -	s = "Filemd5s";
  -#endif
  -    return s;
  +    dbiTagStore dbiTags = rpmdb->db_tags;
  +    int dbix = 0;
  +
  +    if (dbiTags != NULL)
  +    while (dbix < rpmdb->db_ndbi) {
  +	if (dbi->dbi_rpmtag == dbiTags->tag)
  +	    return dbiTags->str;
  +	dbiTags++;
  +	dbix++;
  +    }
  +    /* XXX should never reach here */
  +    return tagName(dbi->dbi_rpmtag);
   }
   
   static int db_fini(dbiIndex dbi, const char * dbhome,
  @@ -937,6 +942,7 @@
       const char * dbfile;
       const char * dbsubfile;
       DB * db = dbi->dbi_db;
  +    const char * dbiBN = mapTagName(rpmdb, dbi);
       int _printit;
       int rc = 0, xx;
   
  @@ -964,9 +970,9 @@
       } else {
   #ifdef	HACK	/* XXX necessary to support dbsubfile */
   	dbfile = (dbi->dbi_file ? dbi->dbi_file : db3basename);
  -	dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : mapTagName(dbi->dbi_rpmtag));
  +	dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : dbiBN);
   #else
  -	dbfile = (dbi->dbi_file ? dbi->dbi_file : mapTagName(dbi->dbi_rpmtag));
  +	dbfile = (dbi->dbi_file ? dbi->dbi_file : dbiBN);
   	dbsubfile = NULL;
   #endif
       }
  @@ -979,7 +985,7 @@
   	db = dbi->dbi_db = NULL;
   
   	rpmlog(RPMLOG_DEBUG, D_("closed   db index       %s/%s\n"),
  -		dbhome, (dbfile ? dbfile : mapTagName(dbi->dbi_rpmtag)));
  +		dbhome, (dbfile ? dbfile : dbiBN));
   
       }
   
  @@ -1052,7 +1058,7 @@
   
   		rpmlog(RPMLOG_DEBUG, D_("verified db index       %s/%s\n"),
   			(dbhome ? dbhome : ""),
  -			(dbfile ? dbfile : mapTagName(dbi->dbi_rpmtag)));
  +			(dbfile ? dbfile : dbiBN));
   
   	        /*
   		 * The DB handle may not be accessed again after
  @@ -1091,6 +1097,7 @@
       const char * dbhome;
       const char * dbfile;
       const char * dbsubfile;
  +    const char * dbiBN;
       dbiIndex dbi = NULL;
       int rc = 0;
       int xx;
  @@ -1117,6 +1124,7 @@
   	/*@=nullstate@*/
       /*@=mods@*/
       dbi->dbi_api = DB_VERSION_MAJOR;
  +    dbiBN = mapTagName(rpmdb, dbi);
   
       /*
        * Get the prefix/root component and directory path.
  @@ -1140,9 +1148,9 @@
       } else {
   #ifdef	HACK	/* XXX necessary to support dbsubfile */
   	dbfile = (dbi->dbi_file ? dbi->dbi_file : db3basename);
  -	dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : mapTagName(dbi->dbi_rpmtag));
  +	dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : dbiBN);
   #else
  -	dbfile = (dbi->dbi_file ? dbi->dbi_file : mapTagName(dbi->dbi_rpmtag));
  +	dbfile = (dbi->dbi_file ? dbi->dbi_file : dbiBN);
   	dbsubfile = NULL;
   #endif
       }
  @@ -1249,7 +1257,7 @@
        */
       if ((oflags & DB_CREATE) && (oflags & DB_RDONLY)) {
   	/* dbhome is writable, and DB->open flags may conflict. */
  -	const char * dbfn = (dbfile ? dbfile : mapTagName(dbi->dbi_rpmtag));
  +	const char * dbfn = (dbfile ? dbfile : dbiBN);
   	/*@-mods@*/
   	const char * dbf = rpmGetPath(dbhome, "/", dbfn, NULL);
   	/*@=mods@*/
  @@ -1361,7 +1369,7 @@
       }
   
       rpmlog(RPMLOG_DEBUG, D_("opening  db index       %s/%s %s mode=0x%x\n"),
  -		dbhome, (dbfile ? dbfile : mapTagName(dbi->dbi_rpmtag)),
  +		dbhome, (dbfile ? dbfile : dbiBN),
   		prDbiOpenFlags(oflags, 0), dbi->dbi_mode);
   
       if (rc == 0) {
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/rpmdb.c
  ============================================================================
  $ cvs diff -u -r1.226 -r1.227 rpmdb.c
  --- rpm/rpmdb/rpmdb.c	8 Dec 2007 16:30:49 -0000	1.226
  +++ rpm/rpmdb/rpmdb.c	14 Dec 2007 03:35:48 -0000	1.227
  @@ -178,19 +178,38 @@
   #endif
   
   /**
  + * Destroy dbiTagStore array.
  + * @param dbiTags	dbi tag storage
  + * @param dbiNTags	no. of dbi tags
  + * @return		NULL always
  + */
  +static /*@null@*/
  +dbiTagStore dbiTagStoreFree(/*@only@*/ dbiTagStore dbiTags, size_t dbiNTags)
  +	/*@modifies dbiTags @*/
  +{
  +    if (dbiTags != NULL) {
  +	int i;
  +	for (i = 0; i < dbiNTags; i++)
  +	    dbiTags[i].str = _free(dbiTags[i].str);
  +	dbiTags = _free(dbiTags);
  +    }
  +    return NULL;
  +}
  +
  +/**
    * Return dbi index used for rpm tag.
    * @param db		rpm database
    * @param rpmtag	rpm header tag
    * @return		dbi index, -1 on error
    */
  -static int dbiTagToDbix(rpmdb db, int rpmtag)
  +static int dbiTagToDbix(rpmdb db, rpmTag rpmtag)
   	/*@*/
   {
       int dbix;
   
  -    if (db->db_tagn != NULL)
  +    if (db->db_tags != NULL)
       for (dbix = 0; dbix < db->db_ndbi; dbix++) {
  -	if (rpmtag != db->db_tagn[dbix])
  +	if (rpmtag != db->db_tags[dbix].tag)
   	    continue;
   	return dbix;
       }
  @@ -201,18 +220,20 @@
    * Initialize database (index, tag) tuple from configuration.
    */
   /*@-exportheader@*/
  -static void dbiTagsInit(/*@null@*/int ** dbiTagsP, /*@null@*/int * dbiTagsMaxP)
  +static void dbiTagsInit(/*@null@*/ dbiTagStore * dbiTagsP,
  +		/*@null@*/ size_t * dbiNTagsP)
   	/*@globals rpmGlobalMacroContext, h_errno @*/
  -	/*@modifies dbiTagsP, dbiTagsMaxP, rpmGlobalMacroContext @*/
  +	/*@modifies *dbiTagsP, *dbiNTagsP, rpmGlobalMacroContext @*/
   {
   /*@observer@*/
       static const char * const _dbiTagStr_default =
   	"Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername:Dirnames:Requireversion:Provideversion:Installtid:Sigmd5:Sha1header:Filemd5s:Depends:Pubkeys";
  -    int * dbiTags = NULL;
  -    int dbiTagsMax = 0;
  +    dbiTagStore dbiTags = NULL;
  +    size_t dbiNTags = 0;
       char * dbiTagStr = NULL;
       char * o, * oe;
  -    int dbix, rpmtag, bingo;
  +    rpmTag rpmtag;
  +    int dbix, bingo;
   
       dbiTagStr = rpmExpand("%{?_dbi_tags}", NULL);
       if (!(dbiTagStr && *dbiTagStr)) {
  @@ -222,7 +243,9 @@
   
       /* Always allocate package index */
       dbiTags = xcalloc(1, sizeof(*dbiTags));
  -    dbiTags[dbiTagsMax++] = RPMDBI_PACKAGES;
  +    dbiTags[dbiNTags].str = xstrdup("Packages");
  +    dbiTags[dbiNTags].tag = RPMDBI_PACKAGES;
  +    dbiNTags++;
   
       for (o = dbiTagStr; o && *o; o = oe) {
   	while (*o && xisspace((int)*o))
  @@ -238,16 +261,11 @@
   	if (oe && *oe)
   	    *oe++ = '\0';
   	rpmtag = tagValue(o);
  -	if (rpmtag < 0) {
  -	    rpmlog(RPMLOG_WARNING,
  -		_("dbiTagsInit: unrecognized tag name: \"%s\" ignored\n"), o);
  -	    continue;
  -	}
   
   	bingo = 0;
   	if (dbiTags != NULL)
  -	for (dbix = 0; dbix < dbiTagsMax; dbix++) {
  -	    if (rpmtag == dbiTags[dbix]) {
  +	for (dbix = 0; dbix < dbiNTags; dbix++) {
  +	    if (rpmtag == dbiTags[dbix].tag) {
   		bingo = 1;
   		/*@innerbreak@*/ break;
   	    }
  @@ -255,16 +273,22 @@
   	if (bingo)
   	    continue;
   
  -	dbiTags = xrealloc(dbiTags, (dbiTagsMax + 1) * sizeof(*dbiTags)); /* XXX memory leak */
  -	dbiTags[dbiTagsMax++] = rpmtag;
  +	dbiTags = xrealloc(dbiTags, (dbiNTags + 1) * sizeof(*dbiTags));
  +	dbiTags[dbiNTags].str = xstrdup(o);
  +	dbiTags[dbiNTags].tag = rpmtag;
  +	dbiNTags++;
       }
   
  -    if (dbiTagsMaxP != NULL)
  -	*dbiTagsMaxP = dbiTagsMax;
  +for (dbix = 0; dbix < dbiNTags; dbix++)
  +fprintf(stderr, "%4d %s[%u] 0x%x\n", dbix, dbiTags[dbix].str, dbiTags[dbix].tag, dbiTags[dbix].tag);
  +
  +
  +    if (dbiNTagsP != NULL)
  +	*dbiNTagsP = dbiNTags;
       if (dbiTagsP != NULL)
   	*dbiTagsP = dbiTags;
       else
  -	dbiTags = _free(dbiTags);
  +	dbiTags = dbiTagStoreFree(dbiTags, dbiNTags);
       dbiTagStr = _free(dbiTagStr);
   }
   /*@=exportheader@*/
  @@ -317,6 +341,8 @@
   {
       static int _oneshot = 0;
       int dbix;
  +    dbiTagStore dbiTag;
  +    const char * dbiBN;
       dbiIndex dbi = NULL;
       int _dbapi, _dbapi_rebuild, _dbapi_wanted;
       int rc = 0;
  @@ -338,7 +364,7 @@
   
   /*@-modfilesys@*/
   if (_rpmdb_debug)
  -fprintf(stderr, "==> dbiOpen(%p, %s, 0x%x)\n", db, tagName(rpmtag), flags);
  +fprintf(stderr, "==> dbiOpen(%p, %u, 0x%x)\n", db, rpmtag, flags);
   /*@=modfilesys@*/
   
       if (db == NULL)
  @@ -347,6 +373,8 @@
       dbix = dbiTagToDbix(db, rpmtag);
       if (dbix < 0 || dbix >= db->db_ndbi)
   	return NULL;
  +    dbiTag = db->db_tags + dbix;
  +    dbiBN = (dbiTag->str != NULL ? dbiTag->str : tagName(rpmtag));
   
       /* Is this index already open ? */
   /*@-compdef@*/ /* FIX: db->_dbi may be NULL */
  @@ -374,8 +402,8 @@
   	    static int _printed[32];
   	    if (!_printed[dbix & 0x1f]++)
   		rpmlog(RPMLOG_ERR,
  -			_("cannot open %s index using db%d - %s (%d)\n"),
  -			tagName(rpmtag), _dbapi,
  +			_("cannot open %s(%u) index using db%d - %s (%d)\n"),
  +			dbiBN, rpmtag, _dbapi,
   			(rc > 0 ? strerror(rc) : ""), rc);
   	    _dbapi = -1;
   	}
  @@ -394,8 +422,8 @@
   	if (_dbapi <= 0) {
   	    static int _printed[32];
   	    if (!_printed[dbix & 0x1f]++)
  -		rpmlog(RPMLOG_ERR, _("cannot open %s index\n"),
  -			tagName(rpmtag));
  +		rpmlog(RPMLOG_ERR, _("cannot open %s(%u) index\n"),
  +			dbiBN, rpmtag);
   	    rc = 1;
   	    goto exit;
   	}
  @@ -925,13 +953,15 @@
   
       if (db == NULL) return -2;
   
  -    if (db->db_tagn != NULL && db->_dbi != NULL)
  +    if (db->db_tags != NULL && db->_dbi != NULL)
       for (dbix = 0; dbix < db->db_ndbi; dbix++) {
  -	if (db->db_tagn[dbix] < 0)
  +	dbiTagStore dbiTag = db->db_tags + dbix;
  +	int rpmtag = dbiTag->tag;
  +	if (rpmtag < 0)
   	    continue;
   	if (db->_dbi[dbix] != NULL)
   	    continue;
  -	switch ((db->db_tagn[dbix])) {
  +	switch (rpmtag) {
   	case RPMDBI_AVAILABLE:
   	case RPMDBI_ADDED:
   	case RPMDBI_REMOVED:
  @@ -941,7 +971,7 @@
   	default:
   	    /*@switchbreak@*/ break;
   	}
  -	(void) dbiOpen(db, db->db_tagn[dbix], db->db_flags);
  +	(void) dbiOpen(db, rpmtag, db->db_flags);
       }
       return rc;
   }
  @@ -954,11 +984,11 @@
       if (db == NULL || db->_dbi == NULL)
   	return 0;
   
  -    if (db->db_tagn != NULL)
  +    if (db->db_tags != NULL)
       for (dbix = 0; dbix < db->db_ndbi; dbix++) {
  -	if (db->db_tagn[dbix] != tagn)
  +	if (db->db_tags[dbix].tag != tagn)
   	    continue;
  -	db->db_tagn[dbix] = rpmtag;
  +	db->db_tags[dbix].tag = rpmtag;
   	return 0;
       }
       return 0;
  @@ -972,9 +1002,9 @@
       if (db == NULL || db->_dbi == NULL)
   	return 0;
   
  -    if (db->db_tagn != NULL)
  +    if (db->db_tags != NULL)
       for (dbix = 0; dbix < db->db_ndbi; dbix++) {
  -	if (db->db_tagn[dbix] != rpmtag)
  +	if (db->db_tags[dbix].tag != rpmtag)
   	    continue;
   	if (db->_dbi[dbix] != NULL) {
   	    int xx;
  @@ -1023,7 +1053,7 @@
       db->db_root = _free(db->db_root);
       db->db_home = _free(db->db_home);
       db->db_bits = PBM_FREE(db->db_bits);
  -    db->db_tagn = _free(db->db_tagn);
  +    db->db_tags = dbiTagStoreFree(db->db_tags, db->db_ndbi);
       db->_dbi = _free(db->_dbi);
       db->db_ndbi = 0;
   
  @@ -1171,7 +1201,7 @@
       db->db_errpfx = rpmExpand( (epfx && *epfx ? epfx : _DB_ERRPFX), NULL);
       db->db_remove_env = 0;
       db->db_filter_dups = _db_filter_dups;
  -    dbiTagsInit(&db->db_tagn, &db->db_ndbi);
  +    dbiTagsInit(&db->db_tags, &db->db_ndbi);
       db->_dbi = xcalloc(db->db_ndbi, sizeof(*db->_dbi));
       db->nrefs = 0;
       /*@-globstate@*/
  @@ -1222,13 +1252,14 @@
       {	int dbix;
   
   	rc = 0;
  -	if (db->db_tagn != NULL)
  +	if (db->db_tags != NULL)
   	for (dbix = 0; rc == 0 && dbix < db->db_ndbi; dbix++) {
  +	    dbiTagStore dbiTag = db->db_tags + dbix;
  +	    rpmTag rpmtag = dbiTag->tag;
   	    dbiIndex dbi;
  -	    int rpmtag;
   
   	    /* Filter out temporary databases */
  -	    switch ((rpmtag = db->db_tagn[dbix])) {
  +	    switch (rpmtag) {
   	    case RPMDBI_AVAILABLE:
   	    case RPMDBI_ADDED:
   	    case RPMDBI_REMOVED:
  @@ -2843,14 +2874,18 @@
       {	dbiIndexItem rec = dbiIndexNewItem(hdrNum, 0);
   	int dbix;
   
  -	if (db->db_tagn != NULL)
  +	if (db->db_tags != NULL)
   	for (dbix = 0; dbix < db->db_ndbi; dbix++) {
  +	    dbiTagStore dbiTag = db->db_tags + dbix;
  +	    rpmTag rpmtag = dbiTag->tag;
  +	    const char * dbiBN = (dbiTag->str != NULL
  +		? dbiTag->str : tagName(rpmtag));
   	    dbiIndex dbi;
   	    uint8_t * bin = NULL;
   	    int i;
   
   	    dbi = NULL;
  -	    he->tag = db->db_tagn[dbix];
  +	    he->tag = rpmtag;
   	    he->t = 0;
   	    he->p.ptr = NULL;
   	    he->c = 0;
  @@ -2883,7 +2918,7 @@
   		if (rc) {
   		    rpmlog(RPMLOG_ERR,
   			_("error(%d) setting header #%d record for %s removal\n"),
  -			rc, hdrNum, tagName(dbi->dbi_rpmtag));
  +			rc, hdrNum, dbiBN);
   		} else
   		    rc = dbiDel(dbi, dbcursor, key, data, 0);
   		xx = dbiCclose(dbi, dbcursor, DB_WRITECURSOR);
  @@ -3001,11 +3036,11 @@
   		    if (he->c == 1 && stringvalued) {
   			rpmlog(RPMLOG_DEBUG,
   				D_("removing \"%s\" from %s index.\n"),
  -				(char *)key->data, tagName(dbi->dbi_rpmtag));
  +				(char *)key->data, dbiBN);
   		    } else {
   			rpmlog(RPMLOG_DEBUG,
   				D_("removing %u entries from %s index.\n"),
  -				(unsigned) he->c, tagName(dbi->dbi_rpmtag));
  +				(unsigned) he->c, dbiBN);
   		    }
   		    printed++;
   		}
  @@ -3033,7 +3068,7 @@
   		} else {			/* error */
   		    rpmlog(RPMLOG_ERR,
   			_("error(%d) setting \"%s\" records from %s index\n"),
  -			rc, key->data, tagName(dbi->dbi_rpmtag));
  +			rc, key->data, dbiBN);
   		    ret += 1;
   		    /*@innercontinue@*/ continue;
   		}
  @@ -3054,7 +3089,7 @@
   		    if (rc) {
   			rpmlog(RPMLOG_ERR,
   				_("error(%d) storing record \"%s\" into %s\n"),
  -				rc, key->data, tagName(dbi->dbi_rpmtag));
  +				rc, key->data, dbiBN);
   			ret += 1;
   		    }
   		    data->data = _free(data->data);
  @@ -3064,7 +3099,7 @@
   		    if (rc) {
   			rpmlog(RPMLOG_ERR,
   				_("error(%d) removing record \"%s\" from %s\n"),
  -				rc, key->data, tagName(dbi->dbi_rpmtag));
  +				rc, key->data, dbiBN);
   			ret += 1;
   		    }
   		}
  @@ -3250,8 +3285,11 @@
   	/* Save the header instance. */
   	(void) headerSetInstance(h, hdrNum);
   	
  -	if (db->db_tagn != NULL)
  +	if (db->db_tags != NULL)
   	for (dbix = 0; dbix < db->db_ndbi; dbix++) {
  +	    dbiTagStore dbiTags = db->db_tags + dbix;
  +	    const char * dbiBN = (dbiTags->str != NULL
  +			? dbiTags->str : tagName(dbiTags->tag));
   	    uint8_t * bin = NULL;
   	    rpmTagData requireFlags;
   	    rpmRC rpmrc;
  @@ -3260,7 +3298,7 @@
   	    rpmrc = RPMRC_NOTFOUND;
   	    requireFlags.ptr = NULL;
   	    dbi = NULL;
  -	    he->tag = db->db_tagn[dbix];
  +	    he->tag = dbiTags->tag;
   	    he->t = 0;
   	    he->p.ptr = NULL;
   	    he->c = 0;
  @@ -3481,11 +3519,11 @@
   		    if (he->c == 1 && stringvalued) {
   			rpmlog(RPMLOG_DEBUG,
   				D_("adding \"%s\" to %s index.\n"),
  -				(char *)key->data, tagName(dbi->dbi_rpmtag));
  +				(char *)key->data, dbiBN);
   		    } else {
   			rpmlog(RPMLOG_DEBUG,
   				D_("adding %u entries to %s index.\n"),
  -				(unsigned)he->c, tagName(dbi->dbi_rpmtag));
  +				(unsigned)he->c, dbiBN);
   		    }
   		    printed++;
   		}
  @@ -3506,7 +3544,7 @@
   		} else if (rc != DB_NOTFOUND) {	/* error */
   		    rpmlog(RPMLOG_ERR,
   			_("error(%d) getting \"%s\" records from %s index\n"),
  -			rc, key->data, tagName(dbi->dbi_rpmtag));
  +			rc, key->data, dbiBN);
   		    ret += 1;
   		    /*@innercontinue@*/ continue;
   		}
  @@ -3525,7 +3563,7 @@
   		if (rc) {
   		    rpmlog(RPMLOG_ERR,
   				_("error(%d) storing record %s into %s\n"),
  -				rc, key->data, tagName(dbi->dbi_rpmtag));
  +				rc, key->data, dbiBN);
   		    ret += 1;
   		}
   /*@-unqualifiedtrans@*/
  @@ -3727,7 +3765,7 @@
   
   static int rpmdbRemoveDatabase(const char * prefix,
   		const char * dbpath, int _dbapi,
  -		const int * dbiTags, int dbiTagsMax)
  +		/*@null@*/ const dbiTagStore dbiTags, size_t dbiNTags)
   	/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
   	/*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/
   { 
  @@ -3743,8 +3781,10 @@
   	int i;
   
   	if (dbiTags != NULL)
  -	for (i = 0; i < dbiTagsMax; i++) {
  -	    fn = rpmGetPath(prefix, dbpath, "/", tagName(dbiTags[i]), NULL);
  +	for (i = 0; i < dbiNTags; i++) {
  +	    const char * dbiBN = (dbiTags[i].str != NULL
  +                        ? dbiTags[i].str : tagName(dbiTags[i].tag));
  +	    fn = rpmGetPath(prefix, dbpath, "/", dbiBN, NULL);
   	    if (rpmioFileExists(fn))
   		xx = Unlink(fn);
   	    fn = _free(fn);
  @@ -3776,7 +3816,7 @@
   static int rpmdbMoveDatabase(const char * prefix,
   		const char * olddbpath, int _olddbapi,
   		const char * newdbpath, /*@unused@*/ int _newdbapi,
  -		const int * dbiTags, int dbiTagsMax)
  +		/*@null@*/ const dbiTagStore dbiTags, size_t dbiNTags)
   	/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
   	/*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/
   {
  @@ -3793,11 +3833,13 @@
       {	char *osuffix, *nsuffix;
   	int i;
   	if (dbiTags != NULL)
  -	for (i = 0; i < dbiTagsMax; i++) {
  -	    int rpmtag;
  +	for (i = 0; i < dbiNTags; i++) {
  +	    rpmTag rpmtag = dbiTags[i].tag;
  +	    const char * dbiBN = (dbiTags[i].str != NULL
  +                        ? dbiTags[i].str : tagName(rpmtag));
   
   	    /* Filter out temporary databases */
  -	    switch ((rpmtag = dbiTags[i])) {
  +	    switch (rpmtag) {
   	    case RPMDBI_AVAILABLE:
   	    case RPMDBI_ADDED:
   	    case RPMDBI_REMOVED:
  @@ -3808,8 +3850,8 @@
   		/*@switchbreak@*/ break;
   	    }
   
  -	    ofn = rpmGetPath(prefix, olddbpath, "/", tagName(rpmtag), NULL);
  -	    nfn = rpmGetPath(prefix, newdbpath, "/", tagName(rpmtag), NULL);
  +	    ofn = rpmGetPath(prefix, olddbpath, "/", dbiBN, NULL);
  +	    nfn = rpmGetPath(prefix, newdbpath, "/", dbiBN, NULL);
   
   	    if (!rpmioFileExists(ofn)) {
   	        if (rpmioFileExists(nfn)) {
  @@ -3890,13 +3932,13 @@
       int rc = 0, xx;
       int _dbapi;
       int _dbapi_rebuild;
  -    int * dbiTags = NULL;
  -    int dbiTagsMax = 0;
  +    dbiTagStore dbiTags = NULL;
  +    size_t dbiNTags = 0;
   
       _dbapi = rpmExpandNumeric("%{_dbapi}");
       _dbapi_rebuild = rpmExpandNumeric("%{_dbapi_rebuild}");
   
  -    dbiTagsInit(&dbiTags, &dbiTagsMax);
  +    dbiTagsInit(&dbiTags, &dbiNTags);
   
       /*@-nullpass@*/
       tfn = rpmGetPath("%{?_dbpath}", NULL);
  @@ -4067,12 +4109,12 @@
   		"remains in place\n"));
   
   	xx = rpmdbRemoveDatabase(myprefix, newdbpath, _dbapi_rebuild,
  -			dbiTags, dbiTagsMax);
  +			dbiTags, dbiNTags);
   	rc = 1;
   	goto exit;
       } else if (!nocleanup) {
   	xx = rpmdbMoveDatabase(myprefix, newdbpath, _dbapi_rebuild, dbpath, _dbapi,
  -			dbiTags, dbiTagsMax);
  +			dbiTags, dbiNTags);
   
   	if (xx) {
   	    rpmlog(RPMLOG_ERR, _("failed to replace old database with new "
  @@ -4094,7 +4136,7 @@
       }
       newrootdbpath = _free(newrootdbpath);
       rootdbpath = _free(rootdbpath);
  -    dbiTags = _free(dbiTags);
  +    dbiTags = dbiTagStoreFree(dbiTags, dbiNTags);
       myprefix = _free(myprefix);
   
       return rc;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/rpmdb.h
  ============================================================================
  $ cvs diff -u -r1.69 -r1.70 rpmdb.h
  --- rpm/rpmdb/rpmdb.h	4 Dec 2007 03:38:53 -0000	1.69
  +++ rpm/rpmdb/rpmdb.h	14 Dec 2007 03:35:48 -0000	1.70
  @@ -59,6 +59,10 @@
    */
   typedef /*@abstract@*/ struct _dbiIndex * dbiIndex;
   
  +/** \ingroup rpmdb
  + */
  +typedef struct dbiTagStore_s * dbiTagStore;
  +
   #if defined(_RPMDB_INTERNAL)
   #include <rpmsw.h>
   #if !defined(SWIG)	/* XXX inline dbiFoo() need */
  @@ -423,6 +427,14 @@
   #endif	/* !defined(SWIG) */
   
   /** \ingroup rpmdb
  + */
  +struct dbiTagStore_s {
  +/*@only@*/
  +    const char * str;		/*!< Tag string (might be arbitrary). */
  +    int tag;			/*!< Tag value. */
  +};
  +
  +/** \ingroup rpmdb
    * Describes the collection of index databases used by rpm.
    */
   struct rpmdb_s {
  @@ -464,8 +476,8 @@
       int		db_opens;	/*!< No. of opens for this rpmdb. */
   /*@only@*/ /*@null@*/
       void *	db_dbenv;	/*!< Berkeley DB_ENV handle. */
  -    int *	db_tagn;	/*!< Tag index mappings. */
  -    int		db_ndbi;	/*!< No. of tag indices. */
  +    dbiTagStore	db_tags;	/*!< Tag name/value mappings. */
  +    size_t	db_ndbi;	/*!< No. of tag indices. */
   /*@only@*/ /*@null@*/
       dbiIndex * _dbi;		/*!< Tag indices. */
   
  @@ .
Received on Fri Dec 14 04:35:49 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.