From b6b6612cfa451a62839e45b69423eb1a16a03f57 Mon Sep 17 00:00:00 2001 From: jbj Date: Tue, 20 Aug 2002 22:05:18 +0000 Subject: [PATCH] - check for interrupt during iteration. - python: add ts.setProbFilter() method, remove ts.run() argument. CVS patchset: 5652 CVS date: 2002/08/20 22:05:18 --- CHANGES | 2 ++ build/files.c | 3 +++ lib/psm.c | 32 +++++++++++++++++++------------- lib/rpmfi.c | 2 ++ lib/rpmrc.c | 8 +++++--- lib/transaction.c | 28 +++++++++++++++------------- python/rpmts-py.c | 50 ++++++++++++++++++++++++++++++++++++++------------ python/rpmts-py.h | 1 + rpm.spec.in | 6 ++++-- rpmdb/header.c | 4 ++-- rpmdb/rpmdb.c | 4 ++++ 11 files changed, 95 insertions(+), 45 deletions(-) diff --git a/CHANGES b/CHANGES index 422099d..d06909f 100644 --- a/CHANGES +++ b/CHANGES @@ -255,6 +255,8 @@ - skip redundant /sbin/ldconfig scripts on upgrade (if possible). - python: stupid typo broke ts.check(). - fix: add epoch to "already installed" check. + - check for interrupt during iteration. + - python: add ts.setProbFilter() method, remove ts.run() argument. 4.0.3 -> 4.0.4: - solaris: translate i86pc to i386 (#57182). diff --git a/build/files.c b/build/files.c index b08cf5e..fb87d58 100644 --- a/build/files.c +++ b/build/files.c @@ -31,6 +31,7 @@ /*@access Header @*/ /*@access rpmfi @*/ +/*@access rpmte @*/ /*@access FD_t @*/ /*@access StringBuf @*/ /* compared with NULL */ @@ -1372,7 +1373,9 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl, if (fi == NULL) return; /* XXX can't happen */ +/*@-onlytrans@*/ fi->te = xcalloc(1, sizeof(*fi->te)); +/*@=onlytrans@*/ fi->te->type = TR_ADDED; fi->dnl = _free(fi->dnl); diff --git a/lib/psm.c b/lib/psm.c index 5631085..c1698a1 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -888,7 +888,7 @@ static pid_t psmWait(rpmpsm psm) /*@modifies psm, fileSystem, internalState @*/ { if (psm->reaper) { - /* XXX FIXME: signal race on psm->reaped prevents pause(3) */ + /*@-infloops@*/ while (psm->reaped == 0) (void) sleep(2); /*@=infloops@*/ @@ -915,7 +915,7 @@ fprintf(stderr, " Wait: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmt /*@unchecked@*/ static int ldconfig_done = 0; -/*@unchecked@*/ /*@observer@*/ +/*@unchecked@*/ /*@observer@*/ /*@null@*/ static const char * ldconfig_path = "/sbin/ldconfig"; /** @@ -940,8 +940,10 @@ static int runScript(rpmpsm psm, Header h, const char * sln, int progArgc, const char ** progArgv, const char * script, int arg1, int arg2) - /*@globals rpmGlobalMacroContext, fileSystem, internalState@*/ - /*@modifies psm, rpmGlobalMacroContext, fileSystem, internalState @*/ + /*@globals ldconfig_done, rpmGlobalMacroContext, + fileSystem, internalState@*/ + /*@modifies psm, ldconfig_done, rpmGlobalMacroContext, + fileSystem, internalState @*/ { const rpmts ts = psm->ts; rpmfi fi = psm->fi; @@ -1259,10 +1261,9 @@ exit: */ static int handleOneTrigger(const rpmpsm psm, Header sourceH, Header triggeredH, int arg2, unsigned char * triggersAlreadyRun) - /*@globals rpmGlobalMacroContext, - fileSystem, internalState@*/ - /*@modifies psm, triggeredH, *triggersAlreadyRun, rpmGlobalMacroContext, - fileSystem, internalState @*/ + /*@globals rpmGlobalMacroContext, fileSystem, internalState@*/ + /*@modifies psm, sourceH, triggeredH, *triggersAlreadyRun, + rpmGlobalMacroContext, fileSystem, internalState @*/ { int scareMem = 1; const rpmts ts = psm->ts; @@ -1299,7 +1300,10 @@ static int handleOneTrigger(const rpmpsm psm, Header sourceH, Header triggeredH, if (!(Flags & psm->sense)) continue; - if (!rpmdsNVRMatchesDep(sourceH, trigger, 1)) + /* + * XXX Trigger on any provided dependency, not just the package NEVR. + */ + if (!rpmdsAnyMatchesDep(sourceH, trigger, 1)) continue; if (!( hge(triggeredH, RPMTAG_TRIGGERINDEX, &tit, @@ -1605,10 +1609,12 @@ int rpmpsmStage(rpmpsm psm, pkgStage stage) assert(psm->mi == NULL); psm->mi = rpmtsInitIterator(ts, RPMTAG_NAME, rpmteN(psm->te), 0); - xx = rpmdbSetIteratorRE(psm->mi, RPMTAG_VERSION, - RPMMIRE_DEFAULT, rpmteV(psm->te)); - xx = rpmdbSetIteratorRE(psm->mi, RPMTAG_RELEASE, - RPMMIRE_DEFAULT, rpmteR(psm->te)); + xx = rpmdbSetIteratorRE(psm->mi, RPMTAG_EPOCH, RPMMIRE_DEFAULT, + rpmteE(psm->te)); + xx = rpmdbSetIteratorRE(psm->mi, RPMTAG_VERSION, RPMMIRE_DEFAULT, + rpmteV(psm->te)); + xx = rpmdbSetIteratorRE(psm->mi, RPMTAG_RELEASE, RPMMIRE_DEFAULT, + rpmteR(psm->te)); while ((psm->oh = rpmdbNextIterator(psm->mi))) { fi->record = rpmdbGetIteratorOffset(psm->mi); diff --git a/lib/rpmfi.c b/lib/rpmfi.c index 1035762..c07ddba 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -997,6 +997,8 @@ rpmfi rpmfiNew(rpmts ts, Header h, rpmTag tagN, int scareMem) } fi = xcalloc(1, sizeof(*fi)); + if (fi == NULL) /* XXX can't happen */ + goto exit; fi->magic = RPMFIMAGIC; fi->Type = Type; diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 1ab7d30..acf6bc6 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -31,7 +31,7 @@ const char * macrofiles = MACROFILES; /*@observer@*/ /*@unchecked@*/ static const char * platform = "/etc/rpm/platform"; -/*@only@*/ /*@unchecked@*/ +/*@only@*/ /*@relnul@*/ /*@unchecked@*/ static const char ** platpat = NULL; /*@unchecked@*/ static int nplatpat = 0; @@ -1645,10 +1645,12 @@ void rpmFreeRpmrc(void) { int i, j, k; +/*@-onlyunqglobaltrans -unqualifiedtrans @*/ if (platpat) for (i = 0; i < nplatpat; i++) platpat[i] = _free(platpat[i]); platpat = _free(platpat); +/*@-onlyunqglobaltrans =unqualifiedtrans @*/ nplatpat = 0; for (i = 0; i < RPM_MACHTABLE_COUNT; i++) { @@ -1708,9 +1710,9 @@ void rpmFreeRpmrc(void) current[OS] = _free(current[OS]); current[ARCH] = _free(current[ARCH]); defaultsInitialized = 0; -/*@-nullstate@*/ /* FIX: current may be NULL */ +/*@-globstate -nullstate@*/ /* FIX: platpat/current may be NULL */ return; -/*@=nullstate@*/ +/*@=globstate =nullstate@*/ } /** \ingroup rpmrc diff --git a/lib/transaction.c b/lib/transaction.c index 514b503..47ef346 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1409,7 +1409,7 @@ rpmMessage(RPMMESS_DEBUG, _("computing file dispositions\n")); /*@-type@*/ /* FIX: rpmte not opaque */ { /*@-noeffectuncon@*/ /* FIX: notify annotations */ - p->fd = ts->notify(fi->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0, + p->fd = ts->notify(p->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0, rpmteKey(p), ts->notifyData); /*@=noeffectuncon@*/ if (rpmteFd(p) != NULL) { @@ -1424,7 +1424,7 @@ rpmMessage(RPMMESS_DEBUG, _("computing file dispositions\n")); if (!(rpmrc == RPMRC_OK || rpmrc == RPMRC_BADSIZE)) { /*@-noeffectuncon@*/ /* FIX: notify annotations */ - p->fd = ts->notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, + p->fd = ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0, rpmteKey(p), ts->notifyData); /*@=noeffectuncon@*/ @@ -1450,12 +1450,14 @@ rpmMessage(RPMMESS_DEBUG, _("computing file dispositions\n")); fi->actions = NULL; fi = rpmfiFree(fi); fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1); - p->fi = fi; - fi->te = p; - fi->fstates = _free(fi->fstates); - fi->fstates = fstates; - fi->actions = _free(fi->actions); - fi->actions = actions; + if (fi != NULL) { /* XXX can't happen */ + fi->te = p; + fi->fstates = _free(fi->fstates); + fi->fstates = fstates; + fi->actions = _free(fi->actions); + fi->actions = actions; + p->fi = fi; + } } psm->fi = rpmfiLink(p->fi, NULL); @@ -1470,23 +1472,23 @@ rpmMessage(RPMMESS_DEBUG, _("computing file dispositions\n")); lastFailKey = pkgKey; } /*@=nullstate@*/ - fi->h = headerFree(fi->h); } else { ourrc++; lastFailKey = pkgKey; } - p->h = headerFree(p->h); - if (gotfd) { /*@-noeffectuncon @*/ /* FIX: check rc */ - (void) ts->notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0, + (void) ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0, rpmteKey(p), ts->notifyData); /*@=noeffectuncon @*/ /*@-type@*/ p->fd = NULL; /*@=type@*/ } + + p->h = headerFree(p->h); + /*@switchbreak@*/ break; case TR_REMOVED: rpmMessage(RPMMESS_DEBUG, "========== --- %s\n", rpmteNEVR(p)); @@ -1507,7 +1509,7 @@ rpmMessage(RPMMESS_DEBUG, _("computing file dispositions\n")); /*@=nullstate@*/ /*@-type@*/ /* FIX: p is almost opaque */ - p->fi = rpmfiFree(fi); + p->fi = rpmfiFree(p->fi); /*@=type@*/ } diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 31fc736..3d78f5d 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -128,12 +128,9 @@ static int _rpmts_debug = 0; * packages. * @return previous transFlags * - * - run(problemSetFilter,callback,data) Attempt to execute a - * transaction set. After the transaction set has been populated - * with install and upgrade actions, it can be executed by invoking - * the run() method. + * - ts.setProbFilter(ignoreSet) Set transaction set problem filter. * @param problemSetFilter - control bit(s) to ignore classes of problems, - * any of + * a logical or of one or more of the following bit(s): * - rpm.RPMPROB_FILTER_IGNOREOS - * - rpm.RPMPROB_FILTER_IGNOREARCH - * - rpm.RPMPROB_FILTER_REPLACEPKG - @@ -142,6 +139,12 @@ static int _rpmts_debug = 0; * - rpm.RPMPROB_FILTER_REPLACEOLDFILES - * - rpm.RPMPROB_FILTER_OLDPACKAGE - * - rpm.RPMPROB_FILTER_DISKSPACE - + * @return previous ignoreSet + * + * - ts.run(callback,data) Attempt to execute a transaction set. + * After the transaction set has been populated with install/upgrade or + * erase actions, the transaction set can be executed by invoking + * the ts.run() method. */ /** \ingroup python @@ -1015,18 +1018,37 @@ fprintf(stderr, "*** rpmts_SetFlags(%p) ts %p transFlags %x\n", s, s->ts, transF /** \ingroup python */ +static PyObject * rpmts_SetProbFilter(rpmtsObject * s, PyObject * args) + /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ +{ + rpmprobFilterFlags ignoreSet = 0; + rpmprobFilterFlags oignoreSet; + + if (!PyArg_ParseTuple(args, "i:ProbFilter", &ignoreSet)) + return NULL; + +if (_rpmts_debug) +fprintf(stderr, "*** rpmts_SetProbFilter(%p) ts %p ignoreSet %x\n", s, s->ts, ignoreSet); + + oignoreSet = s->ignoreSet; + s->ignoreSet = ignoreSet; + + return Py_BuildValue("i", oignoreSet); +} + +/** \ingroup python + */ static PyObject * rpmts_Run(rpmtsObject * s, PyObject * args) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { - int ignoreSet; int rc, i; PyObject * list; rpmps ps; struct rpmtsCallbackType_s cbInfo; - if (!PyArg_ParseTuple(args, "iOO:Run", &ignoreSet, &cbInfo.cb, - &cbInfo.data)) + if (!PyArg_ParseTuple(args, "OO:Run", &cbInfo.cb, &cbInfo.data)) return NULL; cbInfo.tso = s; @@ -1043,9 +1065,9 @@ static PyObject * rpmts_Run(rpmtsObject * s, PyObject * args) if (_rpmts_debug) -fprintf(stderr, "*** rpmts_Run(%p) ts %p ignore %x\n", s, s->ts, ignoreSet); +fprintf(stderr, "*** rpmts_Run(%p) ts %p ignore %x\n", s, s->ts, s->ignoreSet); - rc = rpmtsRun(s->ts, NULL, ignoreSet); + rc = rpmtsRun(s->ts, NULL, s->ignoreSet); ps = rpmtsProblems(s->ts); if (cbInfo.cb) { @@ -1205,8 +1227,12 @@ static struct PyMethodDef rpmts_methods[] = { NULL }, {"setFlags", (PyCFunction) rpmts_SetFlags, METH_VARARGS, "ts.setFlags(transFlags) -> previous transFlags\n\ -- Set control bit(s) for processing a transaction set.\n\ - Note: This method sets bit(s) passed as the first argument to ts.run()\n" }, +- Set control bit(s) for executing ts.run().\n\ + Note: This method replaces the 1st argument to the old ts.run()\n" }, + {"setProbFilter", (PyCFunction) rpmts_SetProbFilter, METH_VARARGS, +"ts.setProbFilter(ignoreSet) -> previous ignoreSet\n\ +- Set control bit(s) for ignoring problems found by ts.run().\n\ + Note: This method replaces the 2nd argument to the old ts.run()\n" }, {"run", (PyCFunction) rpmts_Run, METH_VARARGS, NULL }, {"clean", (PyCFunction) rpmts_Clean, METH_VARARGS, diff --git a/python/rpmts-py.h b/python/rpmts-py.h index 467612a..757e89d 100644 --- a/python/rpmts-py.h +++ b/python/rpmts-py.h @@ -14,6 +14,7 @@ typedef struct rpmtsObject_s { FD_t scriptFd; rpmtsi tsi; rpmElementType tsiFilter; + rpmprobFilterFlags ignoreSet; } rpmtsObject; /*@unchecked@*/ diff --git a/rpm.spec.in b/rpm.spec.in index 47a2c0b..4f6272e 100644 --- a/rpm.spec.in +++ b/rpm.spec.in @@ -17,7 +17,7 @@ Name: rpm %define version @VERSION@ Version: %{version} %{expand: %%define rpm_version %{version}} -Release: 0.84 +Release: 0.85 Group: System Environment/Base Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/rpm-%{rpm_version}.tar.gz Copyright: GPL @@ -519,9 +519,11 @@ fi %{__prefix}/include/popt.h %changelog -* Tue Aug 20 2002 Jeff Johnson 4.1-0.84 +* Tue Aug 20 2002 Jeff Johnson 4.1-0.85 - python: stupid typo broke ts.check(). - fix: add epoch to "already installed" check. +- check for interrupt during iteration. +- python: add ts.setProbFilter() method, remove ts.run() argument. * Mon Aug 19 2002 Jeff Johnson 4.1-0.82 - add --with-efence to configure, check install/upgrade with efence. diff --git a/rpmdb/header.c b/rpmdb/header.c index c2c3aaf..c2ad935 100644 --- a/rpmdb/header.c +++ b/rpmdb/header.c @@ -2683,10 +2683,10 @@ static char * formatValue(sprintfTag tag, Header h, /*@=branchstate@*/ if (tag->arrayCount) { - /*@-observertrans -modobserver@*/ + /*@-branchstate -observertrans -modobserver@*/ if (datafree) data = headerFreeData(data, type); - /*@=observertrans =modobserver@*/ + /*@=branchstate =observertrans =modobserver@*/ countBuf = count; data = &countBuf; diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index 87b37ee..7af2fc6 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -2022,7 +2022,9 @@ static int mireSkip (const rpmdbMatchIterator mi) if (mire->tag != RPMTAG_EPOCH) continue; t = RPM_INT32_TYPE; +/*@-immediatetrans@*/ u.i32p = &zero; +/*@=immediatetrans@*/ c = 1; } @@ -2140,6 +2142,8 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi) if (mi == NULL) return NULL; + (void) checkSignals(); + dbi = dbiOpen(mi->mi_db, RPMDBI_PACKAGES, 0); if (dbi == NULL) return NULL; -- 2.7.4