diff options
author | jbj <devnull@localhost> | 2002-03-13 20:01:50 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-03-13 20:01:50 +0000 |
commit | 54945a10c1659c6204410476534babc36e6cf180 (patch) | |
tree | 23f73747a9783e1854dc573dbeebadba6105fefa | |
parent | fb845b7ee7e65bb0523efc6effbb9dd01f5c699e (diff) | |
download | rpm-54945a10c1659c6204410476534babc36e6cf180.tar.gz rpm-54945a10c1659c6204410476534babc36e6cf180.tar.bz2 rpm-54945a10c1659c6204410476534babc36e6cf180.zip |
Factor notify callback function/arg onto per-ts method.
CVS patchset: 5357
CVS date: 2002/03/13 20:01:50
-rw-r--r-- | lib/psm.c | 12 | ||||
-rw-r--r-- | lib/rpminstall.c | 30 | ||||
-rw-r--r-- | lib/rpmlib.h | 24 | ||||
-rw-r--r-- | lib/rpmts.c | 10 | ||||
-rw-r--r-- | lib/transaction.c | 3 | ||||
-rw-r--r-- | python/rpmmodule.c | 5 |
6 files changed, 48 insertions, 36 deletions
@@ -453,11 +453,8 @@ static rpmRC chkdir (const char * dpath, const char * dname) return RPMRC_OK; } -rpmRC rpmInstallSourcePackage(rpmTransactionSet ts, - FD_t fd, - const char ** specFilePtr, - rpmCallbackFunction notify, rpmCallbackData notifyData, - const char ** cookie) +rpmRC rpmInstallSourcePackage(rpmTransactionSet ts, FD_t fd, + const char ** specFilePtr, const char ** cookie) { int scareMem = 1; TFI_t fi = NULL; @@ -473,11 +470,6 @@ rpmRC rpmInstallSourcePackage(rpmTransactionSet ts, rpmRC rc; int i; - /*@-mods -temptrans -assignexpose@*/ - ts->notify = notify; - ts->notifyData = notifyData; - /*@=mods =temptrans =assignexpose@*/ - /*@-mustmod@*/ /* LCL: segfault */ rc = rpmReadPackageFile(ts, fd, "InstallSourcePackage", &h); /*@=mustmod@*/ diff --git a/lib/rpminstall.c b/lib/rpminstall.c index 81359c1fb..849755fd4 100644 --- a/lib/rpminstall.c +++ b/lib/rpminstall.c @@ -217,7 +217,6 @@ int rpmInstall(rpmTransactionSet ts, rpmInstallInterfaceFlags interfaceFlags; rpmprobFilterFlags probFilter; rpmRelocation * relocations; - int notifyFlags; /*@only@*/ /*@null@*/ const char * fileURL = NULL; int stopInstall = 0; const char ** av = NULL; @@ -239,9 +238,12 @@ int rpmInstall(rpmTransactionSet ts, ts->dbmode = (ts->transFlags & RPMTRANS_FLAG_TEST) ? O_RDONLY : (O_RDWR|O_CREAT); - ts->notify = rpmShowProgress; - notifyFlags = interfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 ); - ts->notifyData = (void *) ((long)notifyFlags); + + { int notifyFlags; + notifyFlags = interfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 ); + xx = rpmtsSetNotifyCallback(ts, + rpmShowProgress, (void *) ((long)notifyFlags)); + } if ((eiu->relocations = relocations) != NULL) { while (eiu->relocations->oldPath) @@ -559,8 +561,7 @@ restart: rpmMessage(RPMMESS_DEBUG, _("installing binary packages\n")); /*@-nullstate@*/ /* FIX: ts->rootDir may be NULL? */ - rc = rpmRunTransactions(ts, ts->notify, ts->notifyData, - NULL, &probs, ts->transFlags, probFilter); + rc = rpmRunTransactions(ts, NULL, &probs, ts->transFlags, probFilter); /*@=nullstate@*/ if (rc < 0) { @@ -589,8 +590,7 @@ restart: if (!(ts->transFlags & RPMTRANS_FLAG_TEST)) { #if !defined(__LCLINT__) /* LCL: segfault */ - eiu->rpmrc = rpmInstallSourcePackage(ts, eiu->fd, NULL, - ts->notify, ts->notifyData, NULL); + eiu->rpmrc = rpmInstallSourcePackage(ts, eiu->fd, NULL, NULL); #endif if (eiu->rpmrc != RPMRC_OK) eiu->numFailed++; } @@ -634,6 +634,14 @@ int rpmErase(rpmTransactionSet ts, ts->transFlags = ia->transFlags; interfaceFlags = ia->eraseInterfaceFlags; +#ifdef NOTYET /* XXX no callbacks on erase yet */ + { int notifyFlags; + notifyFlags = interfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 ); + xx = rpmtsSetNotifyCallback(ts, + rpmShowProgress, (void *) ((long)notifyFlags) + } +#endif + ts->nodigests = (ia->qva_flags & VERIFY_DIGEST); ts->nosignatures = (ia->qva_flags & VERIFY_SIGNATURE); @@ -689,8 +697,7 @@ int rpmErase(rpmTransactionSet ts, if (!stopUninstall) { ts->transFlags |= RPMTRANS_FLAG_REVERSE; - numFailed += rpmRunTransactions(ts, NULL, NULL, NULL, &probs, - ts->transFlags, 0); + numFailed += rpmRunTransactions(ts, NULL, &probs, ts->transFlags, 0); } return numFailed; @@ -713,8 +720,7 @@ int rpmInstallSource(rpmTransactionSet ts, const char * arg, fprintf(stdout, _("Installing %s\n"), arg); { - rpmRC rpmrc = rpmInstallSourcePackage(ts, fd, specFile, NULL, NULL, - cookie); + rpmRC rpmrc = rpmInstallSourcePackage(ts, fd, specFile, cookie); rc = (rpmrc == RPMRC_OK ? 0 : 1); } if (rc != 0) { diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 92bc52b50..d61b641fd 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -1291,15 +1291,11 @@ int rpmReadPackageFile(rpmTransactionSet ts, FD_t fd, * @param ts transaction set * @param fd file handle * @retval specFilePtr address of spec file name (or NULL) - * @param notify progress callback - * @param notifyData progress callback private data - * @retval cooke address of cookie pointer (or NULL) + * @retval cookie address of cookie pointer (or NULL) * @return rpmRC return code */ rpmRC rpmInstallSourcePackage(rpmTransactionSet ts, FD_t fd, /*@null@*/ /*@out@*/ const char ** specFilePtr, - /*@null@*/ rpmCallbackFunction notify, - /*@null@*/ rpmCallbackData notifyData, /*@null@*/ /*@out@*/ const char ** cookie) /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/ @@ -1633,14 +1629,26 @@ typedef enum rpmprobFilterFlags_e { } rpmprobFilterFlags; /** \ingroup rpmtrans + * Set transaction notify callback function and argument. + * @warning This call must be made before rpmRunTransactions() for + * install/upgrade/freshen to "work". + * @param ts transaction set + * @param notify progress callback + * @param notifyData progress callback private data + * @return 0 on success + */ +int rpmtsSetNotifyCallback(rpmTransactionSet ts, + /*@observer@*/ rpmCallbackFunction notify, + /*@observer@*/ rpmCallbackData notifyData) + /*@modifies ts @*/; + +/** \ingroup rpmtrans * Process all packages in transaction set. * * @warning The value returned in *newProbs is now refcounted, and should * be free'd using rpmProblemSetFree(). * * @param ts transaction set - * @param notify progress callback - * @param notifyData progress callback private data * @param okProbs previously known problems (or NULL) * @retval newProbs address to return unfiltered problems (or NULL) * @param transFlags bits to control rpmRunTransactions() @@ -1648,8 +1656,6 @@ typedef enum rpmprobFilterFlags_e { * @return 0 on success, -1 on error, >0 with newProbs set */ int rpmRunTransactions(rpmTransactionSet ts, - /*@observer@*/ rpmCallbackFunction notify, - /*@observer@*/ rpmCallbackData notifyData, rpmProblemSet okProbs, /*@out@*/ rpmProblemSet * newProbs, rpmtransFlags transFlags, diff --git a/lib/rpmts.c b/lib/rpmts.c index fbffec528..00cd7802c 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -221,3 +221,13 @@ rpmTransactionSet rpmtransCreateSet(rpmdb db, const char * rootDir) return rpmtsLink(ts, "tsCreate"); } + +int rpmtsSetNotifyCallback(rpmTransactionSet ts, + rpmCallbackFunction notify, rpmCallbackData notifyData) +{ + if (ts != NULL) { + ts->notify = notify; + ts->notifyData = notifyData; + } + return 0; +} diff --git a/lib/transaction.c b/lib/transaction.c index 377069d33..5ebcac8a8 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1025,7 +1025,6 @@ TFI_t teiGetFi(const teIterator tei) #define NOTIFY(_ts, _al) if ((_ts)->notify) (void) (_ts)->notify _al int rpmRunTransactions( rpmTransactionSet ts, - rpmCallbackFunction notify, rpmCallbackData notifyData, rpmProblemSet okProbs, rpmProblemSet * newProbs, rpmtransFlags transFlags, rpmprobFilterFlags ignoreSet) { @@ -1056,8 +1055,6 @@ int rpmRunTransactions( rpmTransactionSet ts, if (ts->transFlags & (RPMTRANS_FLAG_JUSTDB | RPMTRANS_FLAG_MULTILIB)) ts->transFlags |= (_noTransScripts | _noTransTriggers); - ts->notify = notify; - ts->notifyData = notifyData; ts->probs = rpmProblemSetFree(ts->probs); ts->probs = rpmProblemSetCreate(); *newProbs = rpmpsLink(ts->probs, "RunTransactions"); diff --git a/python/rpmmodule.c b/python/rpmmodule.c index fb16a1efe..16e68c4bd 100644 --- a/python/rpmmodule.c +++ b/python/rpmmodule.c @@ -1590,8 +1590,9 @@ static PyObject * rpmtransRun(rpmtransObject * s, PyObject * args) { cbInfo.pythonError = 0; - rc = rpmRunTransactions(s->ts, tsCallback, &cbInfo, NULL, &probs, flags, - ignoreSet); + (void) rpmtsSetNotifyCallback(s->ts, tsCallback, (void *) &cbInfo); + + rc = rpmRunTransactions(s->ts, NULL, &probs, flags, ignoreSet); if (cbInfo.pythonError) { if (rc > 0) |