From c6fba63aca2cbee02848e5913cddc730e43cee8e Mon Sep 17 00:00:00 2001 From: jbj Date: Sat, 28 Jul 2001 00:33:07 +0000 Subject: [PATCH] - fix: --noscripts is another multimode option. - add tmpdir to configure db3 tmpdir into chroot tree. - permit lazy db opens within chroot. - fix: diddle dbenv path to accomodate backing store reopen in chroot. CVS patchset: 4990 CVS date: 2001/07/28 00:33:07 --- CHANGES | 4 ++ db/mp/mp_fopen.c | 119 +++++++++++++++++++++++++++++++++++++++--------------- doc/manual/macros | 28 ++++++++++++- lib/psm.c | 7 ++++ lib/transaction.c | 9 +++++ macros.in | 8 ++-- rpmdb/db3.c | 81 ++++++++++++++++++++++++++++--------- rpmdb/dbconfig.c | 6 ++- rpmdb/rpmdb.c | 15 +++++-- rpmdb/rpmdb.h | 46 +++++++++++---------- rpmqv.c | 19 +++++++++ 11 files changed, 257 insertions(+), 85 deletions(-) diff --git a/CHANGES b/CHANGES index d5f3f6a..2d8b979 100644 --- a/CHANGES +++ b/CHANGES @@ -193,6 +193,10 @@ - ia64: revert -O0 compilation. - upgrade to db-3.3.11 final. - fix: don't segfault when presented with rpm-2.4.10 packaging (#49688). + - fix: --noscripts is another multimode option. + - add tmpdir to configure db3 tmpdir into chroot tree. + - permit lazy db opens within chroot. + - fix: diddle dbenv path to accomodate backing store reopen in chroot. 4.0 -> 4.0.[12] - add doxygen and lclint annotations most everywhere. diff --git a/db/mp/mp_fopen.c b/db/mp/mp_fopen.c index 3611ded..1db717f 100644 --- a/db/mp/mp_fopen.c +++ b/db/mp/mp_fopen.c @@ -1,13 +1,13 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996, 1997, 1998, 1999, 2000 + * Copyright (c) 1996-2001 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "$Id: mp_fopen.c,v 11.41 2001/01/10 04:50:53 ubell Exp $"; +static const char revid[] = "Id: mp_fopen.c,v 11.54 2001/07/02 01:05:42 bostic Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -25,7 +25,6 @@ static const char revid[] = "$Id: mp_fopen.c,v 11.41 2001/01/10 04:50:53 ubell E #include "mp.h" #ifdef HAVE_RPC -#include "gen_client_ext.h" #include "rpc_client_ext.h" #endif @@ -48,6 +47,9 @@ static int __memp_mf_open __P((DB_MPOOL *, const char *, /* * memp_fopen -- * Open a backing file for the memory pool. + * + * EXTERN: int memp_fopen __P((DB_ENV *, const char *, + * EXTERN: u_int32_t, int, size_t, DB_MPOOL_FINFO *, DB_MPOOLFILE **)); */ int memp_fopen(dbenv, path, flags, mode, pagesize, finfop, retp) @@ -69,7 +71,8 @@ memp_fopen(dbenv, path, flags, mode, pagesize, finfop, retp) #endif PANIC_CHECK(dbenv); - ENV_REQUIRES_CONFIG(dbenv, dbenv->mp_handle, DB_INIT_MPOOL); + ENV_REQUIRES_CONFIG(dbenv, + dbenv->mp_handle, "memp_fopen", DB_INIT_MPOOL); dbmp = dbenv->mp_handle; @@ -132,6 +135,27 @@ __memp_clear_unlink(dbmpf) } /* + * __memp_refcount -- return the current refcount + * + * PUBLIC: void __memp_refcount __P((DB_MPOOLFILE *, db_pgno_t *)); + */ +void +__memp_refcount(dbmpf, cntp) + DB_MPOOLFILE *dbmpf; + db_pgno_t *cntp; +{ + *cntp = dbmpf->mfp->mpf_cnt; +} + +/* + * HACK ALERT: + * rpm needs to carry an open dbenv for a hash database into a chroot. + * db-3.3.11 tries to do an off page hash access through a mempool, which + * tries to reopen the original database path. + */ +const char * chroot_prefix = NULL; + +/* * __memp_fopen -- * Open a backing file for the memory pool; internal version. * @@ -157,7 +181,7 @@ __memp_fopen(dbmp, mfp, path, flags, mode, pagesize, needlock, finfop, retp) u_int32_t mbytes, bytes, oflags; int ret; u_int8_t idbuf[DB_FILE_ID_LEN]; - char *rpath; + char *rpath, *rpath_orig; dbenv = dbmp->dbenv; ret = 0; @@ -208,6 +232,13 @@ __memp_fopen(dbmp, mfp, path, flags, mode, pagesize, needlock, finfop, retp) if ((ret = __db_appname(dbenv, DB_APP_DATA, NULL, path, 0, NULL, &rpath)) != 0) goto err; + + rpath_orig = rpath; +if (chroot_prefix) { + int chrlen = strlen(chroot_prefix); + if (!strncmp(rpath, chroot_prefix, chrlen)) + rpath += chrlen = 1; +} oflags = 0; if (LF_ISSET(DB_CREATE)) oflags |= DB_OSO_CREATE; @@ -306,10 +337,13 @@ __memp_fopen(dbmp, mfp, path, flags, mode, pagesize, needlock, finfop, retp) if (F_ISSET(dbenv, DB_ENV_THREAD)) { if ((ret = __db_mutex_alloc( - dbenv, dbmp->reginfo, &dbmfp->mutexp)) != 0) + dbenv, dbmp->reginfo, 0, &dbmfp->mutexp)) != 0) goto err; - if ((ret = __db_mutex_init( - dbenv, dbmfp->mutexp, 0, MUTEX_THREAD)) != 0) + + if ((ret = __db_shmutex_init(dbenv, dbmfp->mutexp, 0, + MUTEX_THREAD, dbmp->reginfo, + (REGMAINT *)R_ADDR(dbmp->reginfo, + ((MPOOL *)dbmp->reginfo->primary)->maint_off))) != 0) goto err; /* XXX: KEITH: CLOSE THE FILE ON FAILURE? */ @@ -365,7 +399,7 @@ __memp_fopen(dbmp, mfp, path, flags, mode, pagesize, needlock, finfop, retp) } } if (rpath != NULL) - __os_freestr(rpath); + __os_freestr(dbenv, rpath_orig); MUTEX_THREAD_LOCK(dbenv, dbmp->mutexp); TAILQ_INSERT_TAIL(&dbmp->dbmfq, dbmfp, q); @@ -379,13 +413,13 @@ err: /* * never get to here after we have successfully allocated it. */ if (rpath != NULL) - __os_freestr(rpath); + __os_freestr(dbenv, rpath_orig); if (F_ISSET(&dbmfp->fh, DB_FH_VALID)) (void)__os_closehandle(&dbmfp->fh); if (dbmfp != NULL) { if (dbmfp->mutexp != NULL) __db_mutex_free(dbenv, dbmp->reginfo, dbmfp->mutexp); - __os_free(dbmfp, sizeof(DB_MPOOLFILE)); + __os_free(dbenv, dbmfp, sizeof(DB_MPOOLFILE)); } return (ret); } @@ -506,6 +540,8 @@ __memp_mf_open(dbmp, path, pagesize, last_pgno, finfop, flags, retp) memcpy(p, finfop->fileid, DB_FILE_ID_LEN); F_SET(mfp, MP_CAN_MMAP); + if (LF_ISSET(DB_EXTENT)) + F_SET(mfp, MP_EXTENT); } /* Copy the page cookie into shared memory. */ @@ -542,20 +578,16 @@ mem_err: __db_err(dbmp->dbenv, /* * memp_fclose -- * Close a backing file for the memory pool. + * + * EXTERN: int memp_fclose __P((DB_MPOOLFILE *)); */ int memp_fclose(dbmfp) DB_MPOOLFILE *dbmfp; { DB_ENV *dbenv; - DB_MPOOL *dbmp; - MPOOLFILE *mfp; - char *rpath; - int ret, t_ret; - dbmp = dbmfp->dbmp; - dbenv = dbmp->dbenv; - ret = 0; + dbenv = dbmfp->dbmp->dbenv; PANIC_CHECK(dbenv); @@ -564,6 +596,27 @@ memp_fclose(dbmfp) return (__dbcl_memp_fclose(dbmfp)); #endif + return (__memp_fclose(dbmfp, 1)); +} + +/* + * PUBLIC: int __memp_fclose __P((DB_MPOOLFILE *, int)); + */ +int +__memp_fclose(dbmfp, needlock) + DB_MPOOLFILE *dbmfp; + int needlock; +{ + DB_ENV *dbenv; + DB_MPOOL *dbmp; + MPOOLFILE *mfp; + char *rpath; + int ret, t_ret; + + dbmp = dbmfp->dbmp; + dbenv = dbmp->dbenv; + ret = 0; + /* * Remove the DB_MPOOLFILE from the queue. This has to happen before * we perform any action that can fail, otherwise __memp_close may @@ -618,8 +671,8 @@ memp_fclose(dbmfp) if (F_ISSET(&dbmfp->fh, DB_FH_VALID) && (t_ret = __os_closehandle(&dbmfp->fh)) != 0) { __db_err(dbenv, "%s: %s", __memp_fn(dbmfp), db_strerror(t_ret)); - if (ret != 0) - t_ret = ret; + if (ret == 0) + ret = t_ret; } /* Discard the thread mutex. */ @@ -630,18 +683,19 @@ memp_fclose(dbmfp) * Discard our reference on the the underlying MPOOLFILE, and close * it if it's no longer useful to anyone. * - * If we're not discarding it, and it's a temp file, this means - * all the outstanding references belong to unflushed buffers. - * (A temp file can only be referenced by one DB_MPOOLFILE). - * We don't care about preserving any of those buffers, so mark - * the MPOOLFILE as dead so that when we try to flush them, - * even the dirty ones just get discarded. + * If it's a temp file, all outstanding references belong to unflushed + * buffers. (A temp file can only be referenced by one DB_MPOOLFILE). + * We don't care about preserving any of those buffers, so mark the + * MPOOLFILE as dead so that even the dirty ones just get discarded + * when we try to flush them. */ - R_LOCK(dbenv, dbmp->reginfo); + if (needlock) + R_LOCK(dbenv, dbmp->reginfo); mfp = dbmfp->mfp; if (--mfp->mpf_cnt == 0) { - if (F_ISSET(mfp, MP_UNLINK)) { + if (F_ISSET(mfp, MP_TEMP | MP_UNLINK)) MEMP_FREMOVE(mfp); + if (F_ISSET(mfp, MP_UNLINK)) { if ((t_ret = __db_appname(dbmp->dbenv, DB_APP_DATA, NULL, R_ADDR(dbmp->reginfo, mfp->path_off), 0, NULL, &rpath)) != 0 && ret == 0) @@ -649,17 +703,16 @@ memp_fclose(dbmfp) if (t_ret == 0 && (t_ret = __os_unlink(dbmp->dbenv, rpath) != 0 && ret == 0)) ret = t_ret; - __os_free(rpath, 0); + __os_free(dbenv, rpath, 0); } if (mfp->block_cnt == 0) __memp_mf_discard(dbmp, mfp); } - else if (F_ISSET(mfp, MP_TEMP)) - MEMP_FREMOVE(mfp); - R_UNLOCK(dbenv, dbmp->reginfo); + if (needlock) + R_UNLOCK(dbenv, dbmp->reginfo); /* Discard the DB_MPOOLFILE structure. */ - __os_free(dbmfp, sizeof(DB_MPOOLFILE)); + __os_free(dbenv, dbmfp, sizeof(DB_MPOOLFILE)); return (ret); } diff --git a/doc/manual/macros b/doc/manual/macros index d296ca1b..ff6bd34 100644 --- a/doc/manual/macros +++ b/doc/manual/macros @@ -146,7 +146,31 @@ or The %{...} form allows you to place the expansion adjacent to other text. The % form, if a parameterized macro, will do argc/argv processing -of the rest of the line as described above. +of the rest of the line as described above. Normally you will likely want +to invoke a parameterized macro by using the % form so that +parameters are expanded properly. + +Example: +\verbatim + %define mymacro() (echo -n "My arg is %1" ; sleep %1 ; echo done.) +\endverbatim + +Usage: + +\verbatim + %mymacro 5 +\endverbatim + +This expands to: + +\verbatim + (echo -n "My arg is 5" ; sleep 5 ; echo done.) +\endverbatim + +This will cause all occurances of %1 in the macro definition to be +replaced by the first argument to the macro, but only if the macro +is invoked as "%mymacro 5". Invoking as "%{mymacro} 5" will not work +as desired in this case. \subsection macros_commandline Command Line Options @@ -227,7 +251,7 @@ packaging similar to the autoconf variables that are used in building packages: %_libdir %{_exec_prefix}/lib %_includedir %{_prefix}/include %_oldincludedir /usr/include - %_infodir %{_prefix}/include + %_infodir %{_prefix}/info %_mandir %{_prefix}/man \endverbatim diff --git a/lib/psm.c b/lib/psm.c index 822e8f4..f49beed 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -13,6 +13,7 @@ #include "rpmlead.h" /* writeLead proto */ #include "signature.h" /* signature constants */ #include "misc.h" +#include "rpmdb.h" /* XXX for db_chrootDone */ #include "debug.h" /*@access Header @*/ /* compared with NULL */ @@ -27,6 +28,8 @@ extern int _fsm_debug; /*@=redecl@*/ +extern const char * chroot_prefix; + int rpmVersionCompare(Header first, Header second) { const char * one, * two; @@ -1854,6 +1857,8 @@ assert(psm->mi == NULL); rc = chroot(ts->rootDir); /*@=unrecog@*/ psm->chrootDone = ts->chrootDone = 1; + if (ts->rpmdb) ts->rpmdb->db_chrootDone = 1; + chroot_prefix = ts->rootDir; } break; case PSM_CHROOT_OUT: @@ -1863,6 +1868,8 @@ assert(psm->mi == NULL); rc = chroot("."); /*@=unrecog@*/ psm->chrootDone = ts->chrootDone = 0; + if (ts->rpmdb) ts->rpmdb->db_chrootDone = 0; + chroot_prefix = NULL; (void) chdir(ts->currDir); } break; diff --git a/lib/transaction.c b/lib/transaction.c index 5cd7e10..4ff0fc0 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -14,6 +14,8 @@ #include "misc.h" /* XXX stripTrailingChar, splitString, currentDirectory */ #include "rpmdb.h" +extern const char * chroot_prefix; + /* XXX FIXME: merge with existing (broken?) tests in system.h */ /* portability fiddles */ #if STATFS_IN_SYS_STATVFS @@ -1555,6 +1557,7 @@ int rpmRunTransactions( rpmTransactionSet ts, ts->currDir = _free(ts->currDir); ts->currDir = currentDirectory(); ts->chrootDone = 0; + if (ts->rpmdb) ts->rpmdb->db_chrootDone = 0; ts->id = time(NULL); memset(psm, 0, sizeof(*psm)); @@ -1757,13 +1760,17 @@ int rpmRunTransactions( rpmTransactionSet ts, } tsi = tsFreeIterator(tsi); +#ifdef DYING /* Open all database indices before installing. */ (void) rpmdbOpenAll(ts->rpmdb); +#endif if (!ts->chrootDone) { (void) chdir("/"); /*@-unrecog@*/ chroot(ts->rootDir); /*@=unrecog@*/ ts->chrootDone = 1; + if (ts->rpmdb) ts->rpmdb->db_chrootDone = 1; + chroot_prefix = ts->rootDir; } ht = htCreate(totalFileCount * 2, 0, 0, fpHashFunction, fpEqual); @@ -1926,6 +1933,8 @@ int rpmRunTransactions( rpmTransactionSet ts, if (ts->chrootDone) { /*@-unrecog@*/ chroot("."); /*@-unrecog@*/ ts->chrootDone = 0; + if (ts->rpmdb) ts->rpmdb->db_chrootDone = 0; + chroot_prefix = NULL; (void) chdir(ts->currDir); } diff --git a/macros.in b/macros.in index e9d8470..0c2fc72 100644 --- a/macros.in +++ b/macros.in @@ -1,7 +1,7 @@ #/*! \page config_macros Default configuration: /usr/lib/rpm/macros # \verbatim # -# $Id: macros.in,v 1.85 2001/07/14 20:09:56 jbj Exp $ +# $Id: macros.in,v 1.86 2001/07/28 00:33:07 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 @@ -379,17 +379,17 @@ # XXX Use a CDB database model for concurrent access (under development, # cursor teardown with signals needs work, much more besides.) #%__dbi_other usedbenv create joinenv cdb mpool \ -# mp_mmapsize=8Mb mp_size=512Kb verify usecursors +# mp_mmapsize=8Mb mp_size=512Kb verify # XXX Use transactions and logs for rpmdb durability (no clue yet): #%__dbi_other usedbenv create joinenv mpool txn log \ -# mp_mmapsize=8Mb mp_size=512Kb verify usecursors +# mp_mmapsize=8Mb mp_size=512Kb verify # XXX enable at your own risk, CDB access to rpmdb isn't cooked yet. #%__dbi_cdb create joinenv cdb mpool # XXX The "traditional" rpmdb shared/exclusive fcntl(2) lock on Packages model: -%__dbi_other verify usecursors %{?__dbi_cdb} +%__dbi_other verify %{?_tmppath:tmpdir=%{_tmppath}} %{?__dbi_cdb} # Note: adding nofsync here speeds up --rebuilddb a lot. %__dbi_rebuild nofsync !log !txn !cdb diff --git a/rpmdb/db3.c b/rpmdb/db3.c index 9dcb658..bcd479c 100644 --- a/rpmdb/db3.c +++ b/rpmdb/db3.c @@ -237,6 +237,18 @@ static int db_init(dbiIndex dbi, const char * dbhome, xx = dbenv->set_shm_key(dbenv, dbi->dbi_shmkey); xx = cvtdberr(dbi, "dbenv->set_shm_key", xx, _debug); } + if (dbi->dbi_tmpdir) { + const char * root; + const char * tmpdir; + + root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root); + if ((root[0] == '/' && root[1] == '\0') || rpmdb->db_chrootDone) + root = NULL; + tmpdir = rpmGenPath(root, dbi->dbi_tmpdir, NULL); + xx = dbenv->set_tmp_dir(dbenv, tmpdir); + xx = cvtdberr(dbi, "dbenv->set_tmp_dir", rc, _debug); + tmpdir = _free(tmpdir); + } } #if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR != 0 @@ -600,6 +612,8 @@ static int db3close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags) { rpmdb rpmdb = dbi->dbi_rpmdb; const char * urlfn = NULL; + const char * root; + const char * home; const char * dbhome; const char * dbfile; const char * dbsubfile; @@ -608,10 +622,19 @@ static int db3close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags) flags = 0; /* XXX unused */ - urlfn = rpmGenPath( - (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root), - (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home), - NULL); + /* + * Get the prefix/root component and directory path. + */ + root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root); + if ((root[0] == '/' && root[1] == '\0') || rpmdb->db_chrootDone) + root = NULL; + home = (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home); + + /* + * Either the root or directory components may be a URL. Concatenate, + * convert the URL to a path, and add the name of the file. + */ + urlfn = rpmGenPath(root, home, NULL); (void) urlPath(urlfn, &dbhome); if (dbi->dbi_temporary) { dbfile = NULL; @@ -652,19 +675,25 @@ static int db3close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags) rc = db_env_create(&dbenv, 0); rc = cvtdberr(dbi, "db_env_create", rc, _debug); - if (rc) goto exit; - - if (dbenv) /* XXX can't happen. */ + if (rc || dbenv == NULL) goto exit; + + if (dbi->dbi_tmpdir) { + const char * tmpdir = rpmGenPath(root, dbi->dbi_tmpdir, NULL); + rc = dbenv->set_tmp_dir(dbenv, tmpdir); + rc = cvtdberr(dbi, "dbenv->set_tmp_dir", rc, _debug); + tmpdir = _free(tmpdir); + if (rc) goto exit; + } + rc = dbenv->open(dbenv, dbhome, DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_USE_ENVIRON, 0); rc = cvtdberr(dbi, "dbenv->open", rc, _debug); if (rc) goto exit; - if (dbenv) { - rc = db_create(&db, dbenv, 0); - rc = cvtdberr(dbi, "db_create", rc, _debug); + rc = db_create(&db, dbenv, 0); + rc = cvtdberr(dbi, "db_create", rc, _debug); - if (db != NULL) { + if (db != NULL) { const char * dbf = rpmGetPath(dbhome, "/", dbfile, NULL); rc = db->verify(db, dbf, NULL, NULL, flags); @@ -680,11 +709,10 @@ static int db3close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags) if (rc == 0 && xx) rc = xx; dbf = _free(dbf); - } - xx = dbenv->close(dbenv, 0); - xx = cvtdberr(dbi, "dbenv->close", xx, _debug); - if (rc == 0 && xx) rc = xx; } + xx = dbenv->close(dbenv, 0); + xx = cvtdberr(dbi, "dbenv->close", xx, _debug); + if (rc == 0 && xx) rc = xx; } exit: @@ -704,6 +732,8 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip) extern struct _dbiVec db3vec; /*@=nestedextern@*/ const char * urlfn = NULL; + const char * root; + const char * home; const char * dbhome; const char * dbfile; const char * dbsubfile; @@ -719,16 +749,29 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip) if (dbip) *dbip = NULL; + + /* + * Parse db configuration parameters. + */ if ((dbi = db3New(rpmdb, rpmtag)) == NULL) /*@-nullstate@*/ return 1; /*@=nullstate@*/ dbi->dbi_api = DB_VERSION_MAJOR; - urlfn = rpmGenPath( - (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root), - (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home), - NULL); + /* + * Get the prefix/root component and directory path. + */ + root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root); + if ((root[0] == '/' && root[1] == '\0') || rpmdb->db_chrootDone) + root = NULL; + home = (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home); + + /* + * Either the root or directory components may be a URL. Concatenate, + * convert the URL to a path, and add the name of the file. + */ + urlfn = rpmGenPath(root, home, NULL); (void) urlPath(urlfn, &dbhome); if (dbi->dbi_temporary) { dbfile = NULL; diff --git a/rpmdb/dbconfig.c b/rpmdb/dbconfig.c index 7540c89..4914214 100644 --- a/rpmdb/dbconfig.c +++ b/rpmdb/dbconfig.c @@ -124,6 +124,8 @@ struct dbOption rdbOptions[] = { NULL, NULL }, { "shmkey", 0,POPT_ARG_LONG, &db3dbi.dbi_shmkey, 0, NULL, NULL }, + { "tmpdir", 0,POPT_ARG_STRING, &db3dbi.dbi_tmpdir, 0, + NULL, NULL }, { "host", 0,POPT_ARG_STRING, &db3dbi.dbi_host, 0, NULL, NULL }, @@ -487,8 +489,8 @@ dbiIndex db3New(rpmdb rpmdb, int rpmtag) if (!dbi->dbi_use_dbenv) { /* db3 dbenv is always used now. */ dbi->dbi_use_dbenv = 1; dbi->dbi_eflags |= (DB_INIT_MPOOL|DB_JOINENV); - dbi->dbi_mp_mmapsize = 16 * 1024 * 1024; - dbi->dbi_mp_size = 1 * 1024 * 1024; + dbi->dbi_mp_mmapsize = 8 * 1024 * 1024; + dbi->dbi_mp_size = 512 * 1024; dbi->dbi_tear_down = 1; } diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index bc69d45..7c87d5a 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -742,14 +742,12 @@ static int unblockSignals(/*@unused@*/ rpmdb db, sigset_t * oldMask) #define _DB_PERMS 0644 #define _DB_MAJOR -1 -#define _DB_REMOVE_ENV 0 -#define _DB_FILTER_DUPS 0 #define _DB_ERRPFX "rpmdb" /*@-fullinitblock@*/ /*@observer@*/ static struct rpmdb_s dbTemplate = { _DB_ROOT, _DB_HOME, _DB_FLAGS, _DB_MODE, _DB_PERMS, - _DB_MAJOR, _DB_REMOVE_ENV, _DB_FILTER_DUPS, _DB_ERRPFX + _DB_MAJOR, _DB_ERRPFX }; /*@=fullinitblock@*/ @@ -2840,11 +2838,15 @@ static int rpmdbRemoveDatabase(const char * rootdir, const char * base = tagName(dbiTags[i]); sprintf(filename, "%s/%s/%s", rootdir, dbpath, base); (void)rpmCleanPath(filename); + if (!rpmfileexists(filename)) + continue; xx = unlink(filename); } for (i = 0; i < 16; i++) { sprintf(filename, "%s/%s/__db.%03d", rootdir, dbpath, i); (void)rpmCleanPath(filename); + if (!rpmfileexists(filename)) + continue; xx = unlink(filename); } break; @@ -2856,6 +2858,8 @@ static int rpmdbRemoveDatabase(const char * rootdir, const char * base = db1basename(dbiTags[i]); sprintf(filename, "%s/%s/%s", rootdir, dbpath, base); (void)rpmCleanPath(filename); + if (!rpmfileexists(filename)) + continue; xx = unlink(filename); base = _free(base); } @@ -2934,10 +2938,15 @@ static int rpmdbMoveDatabase(const char * rootdir, (void)rpmCleanPath(ofilename); if (!rpmfileexists(ofilename)) continue; + xx = unlink(ofilename); sprintf(nfilename, "%s/%s/__db.%03d", rootdir, newdbpath, i); (void)rpmCleanPath(nfilename); +#ifdef DYING if ((xx = Rename(ofilename, nfilename)) != 0) rc = 1; +#else + xx = unlink(nfilename); +#endif } break; case 2: diff --git a/rpmdb/rpmdb.h b/rpmdb/rpmdb.h index 1a413a3..01b6305 100644 --- a/rpmdb/rpmdb.h +++ b/rpmdb/rpmdb.h @@ -198,10 +198,11 @@ struct _dbiVec { * Describes an index database (implemented on Berkeley db3 functionality). */ struct _dbiIndex { -/*@null@*/ const char * dbi_root; -/*@null@*/ const char * dbi_home; -/*@null@*/ const char * dbi_file; +/*@null@*/ const char * dbi_root; /*!< chroot(2) component of path */ +/*@null@*/ const char * dbi_home; /*!< directory component of path */ +/*@null@*/ const char * dbi_file; /*!< file component of path */ /*@null@*/ const char * dbi_subfile; +/*@null@*/ const char * dbi_tmpdir; /*!< temporary directory */ int dbi_ecflags; /*!< db_env_create flags */ int dbi_cflags; /*!< db_create flags */ @@ -291,11 +292,11 @@ struct _dbiIndex { unsigned int dbi_lastoffset; /*!< db1 with falloc.c needs this */ -/*@only@*//*@null@*/ void * dbi_db; /*!< dbi handle */ -/*@only@*//*@null@*/ void * dbi_dbenv; /*!< */ -/*@only@*//*@null@*/ void * dbi_dbinfo; /*!< */ +/*@only@*//*@null@*/ void * dbi_db; /*!< Berkeley DB handle */ +/*@only@*//*@null@*/ void * dbi_dbenv; /*!< Berkeley DB_ENV handle */ +/*@only@*//*@null@*/ void * dbi_dbinfo; /*!< (unused) */ /*@only@*//*@null@*/ void * dbi_rmw; /*!< db cursor (with DB_WRITECURSOR) */ -/*@only@*//*@null@*/ void * dbi_stats; /*!< */ +/*@only@*//*@null@*/ void * dbi_stats; /*!< Berkeley db statistics */ /*@observer@*/ const struct _dbiVec * dbi_vec; /*!< private methods */ @@ -305,27 +306,28 @@ struct _dbiIndex { * Describes the collection of index databases used by rpm. */ struct rpmdb_s { -/*@owned@*/ const char *db_root; /*!< path prefix */ -/*@owned@*/ const char *db_home; /*!< directory path */ - int db_flags; - int db_mode; /*!< open mode */ - int db_perms; /*!< open permissions */ - int db_api; /*!< Berkeley API type */ - int db_remove_env; - int db_filter_dups; -/*@owned@*/ const char *db_errpfx; - void (*db_errcall) (const char *db_errpfx, char *buffer) +/*@owned@*/ const char * db_root;/*!< path prefix */ +/*@owned@*/ const char * db_home;/*!< directory path */ + int db_flags; + int db_mode; /*!< open mode */ + int db_perms; /*!< open permissions */ + int db_api; /*!< Berkeley API type */ +/*@owned@*/ const char * db_errpfx; + int db_remove_env; + int db_filter_dups; + int db_chrootDone; /*!< If chroot(2) done, ignore db_root. */ + void (*db_errcall) (const char *db_errpfx, char *buffer) /*@*/; /*@shared@*/ FILE * db_errfile; -/*@only@*/ void * (*db_malloc) (size_t nbytes) +/*@only@*/ void * (*db_malloc) (size_t nbytes) /*@*/; -/*@only@*/ void * (*db_realloc) (/*@only@*//*@null@*/ void * ptr, +/*@only@*/ void * (*db_realloc) (/*@only@*//*@null@*/ void * ptr, size_t nbytes) /*@*/; - void (*db_free) (/*@only@*/ void * ptr) + void (*db_free) (/*@only@*/ void * ptr) /*@modifies *ptr @*/; - int db_ndbi; - dbiIndex *_dbi; + int db_ndbi; /*!< No. of tag indices. */ + dbiIndex * _dbi; /*!< Tag indices. */ }; /* for RPM's internal use only */ diff --git a/rpmqv.c b/rpmqv.c index 439be7e..8d1166d 100755 --- a/rpmqv.c +++ b/rpmqv.c @@ -16,6 +16,7 @@ #define POPT_NODEPS 1025 #define POPT_FORCE 1026 #define POPT_NOMD5 1027 +#define POPT_NOSCRIPTS 1028 #ifdef IAM_RPMBT #include "build.h" @@ -158,6 +159,7 @@ static struct poptOption optionsTable[] = { #if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT) { NULL, 'i', POPT_ARGFLAG_DOC_HIDDEN, 0, 'i', NULL, NULL}, { "nodeps", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NODEPS, NULL, NULL}, + { "noscripts", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NOSCRIPTS, NULL, NULL}, { "nomd5", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NOMD5, NULL, NULL}, { "force", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_FORCE, NULL, NULL}, #endif @@ -526,6 +528,23 @@ int main(int argc, const char ** argv) #endif /*@-ifempty@*/ ; break; + + case POPT_NOSCRIPTS: +#ifdef IAM_RPMQV + if (bigMode == MODE_VERIFY || qva->qva_mode == 'V') + qva->qva_flags |= VERIFY_SCRIPT; + else +#endif +#ifdef IAM_RPMEIU + if ((bigMode & MODES_IE) || + (ia->installInterfaceFlags & + (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL|INSTALL_ERASE))) + ia->transFlags |= (_noTransScripts | _noTransTriggers); + else +#endif + /*@-ifempty@*/ ; + break; + #endif /* IAM_RPMQV || IAM_RPMEIU || IAM_RPMBT */ case GETOPT_DEFINEMACRO: -- 2.7.4