Factor notify callback function/arg onto per-ts method.
CVS patchset: 5357 CVS date: 2002/03/13 20:01:50
This commit is contained in:
parent
fb845b7ee7
commit
54945a10c1
12
lib/psm.c
12
lib/psm.c
|
@ -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@*/
|
||||
|
|
|
@ -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) {
|
||||
|
|
24
lib/rpmlib.h
24
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 @*/
|
||||
|
@ -1632,6 +1628,20 @@ typedef enum rpmprobFilterFlags_e {
|
|||
RPMPROB_FILTER_DISKNODES = (1 << 8) /*!< from --ignoresize */
|
||||
} 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.
|
||||
*
|
||||
|
@ -1639,8 +1649,6 @@ typedef enum rpmprobFilterFlags_e {
|
|||
* 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,
|
||||
|
|
10
lib/rpmts.c
10
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;
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue