fsm->digestalgo = rpmfiDigestAlgo(fi);
fsm->psm = psm;
- if (fsm->goal == FSM_PKGINSTALL) {
- fsm->archivePos = 0;
- rpmtsNotify(ts, te, RPMCALLBACK_INST_START,
- fsm->archivePos, fi->archiveSize);
- }
-
fsm->archiveSize = archiveSize;
if (fsm->archiveSize)
*fsm->archiveSize = 0;
break;
case FSM_NOTIFY: /* XXX move from fsm to psm -> tsm */
if (fsm->goal == FSM_PKGINSTALL) {
- rpmts ts = fsmGetTs(fsm);
- rpmte te = fsmGetTe(fsm);
- rpmfi fi = fsmGetFi(fsm);
- if (fsm->cpioPos > fsm->archivePos) {
- fsm->archivePos = fsm->cpioPos;
- rpmtsNotify(ts, te, RPMCALLBACK_INST_PROGRESS,
- fsm->archivePos, fi->archiveSize);
- }
+ rpmpsmNotify(fsm->psm, RPMCALLBACK_INST_PROGRESS, fsm->cpioPos);
}
break;
case FSM_UNDO:
PSM_FINI = 6,
PSM_CREATE = 17,
- PSM_NOTIFY = 22,
PSM_DESTROY = 23,
PSM_SCRIPT = 53,
return psm;
}
+void rpmpsmNotify(rpmpsm psm, int what, rpm_loff_t amount)
+{
+ if (psm) {
+ int changed = 0;
+ if (amount > psm->amount) {
+ psm->amount = amount;
+ changed = 1;
+ }
+ if (what && what != psm->what) {
+ psm->what = what;
+ changed = 1;
+ }
+ if (changed) {
+ rpmtsNotify(psm->ts, psm->te, psm->what, psm->amount, psm->total);
+ }
+ }
+}
+
+
static int runFsm(rpmpsm psm, FD_t payload)
{
int sc, ec;
if (psm->goal == PKG_INSTALL) {
psm->scriptArg = psm->npkgs_installed + 1;
+ psm->amount = 0;
+ psm->total = fi->archiveSize ? fi->archiveSize : 100;
+
/* HACK: reinstall abuses te instance to remove old header */
if (rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEPKG)
markReplacedInstance(ts, psm->te);
}
if (psm->goal == PKG_ERASE) {
psm->scriptArg = psm->npkgs_installed - 1;
+
+ psm->amount = 0;
+ psm->total = rpmfiFC(fi) ? rpmfiFC(fi) : 100;
}
break;
case PSM_PRE:
break;
case PSM_PROCESS:
if (psm->goal == PKG_INSTALL) {
- FD_t payload = NULL;
- int fsmrc;
+ int fsmrc = 0;
if (rpmtsFlags(ts) & RPMTRANS_FLAG_JUSTDB) break;
- /* XXX Synthesize callbacks for packages with no files. */
- if (rpmfiFC(fi) <= 0) {
- rpmtsNotify(ts, psm->te, RPMCALLBACK_INST_START, 0, 100);
- rpmtsNotify(ts, psm->te, RPMCALLBACK_INST_PROGRESS, 100, 100);
- break;
- }
+ rpmpsmNotify(psm, RPMCALLBACK_INST_START, 0);
+ /* make sure first progress call gets made */
+ rpmpsmNotify(psm, RPMCALLBACK_INST_PROGRESS, 0);
- payload = rpmtePayload(psm->te);
- if (payload == NULL) {
- rc = RPMRC_FAIL;
- break;
- }
+ if (rpmfiFC(fi) > 0) {
+ FD_t payload = rpmtePayload(psm->te);
+ if (payload == NULL) {
+ rc = RPMRC_FAIL;
+ break;
+ }
- fsmrc = runFsm(psm, payload);
+ fsmrc = runFsm(psm, payload);
- Fclose(payload);
+ Fclose(payload);
+ }
- /* XXX make sure progress is closed out */
- psm->what = RPMCALLBACK_INST_PROGRESS;
- psm->amount = (fi->archiveSize ? fi->archiveSize : 100);
- psm->total = psm->amount;
- rpmpsmNext(psm, PSM_NOTIFY);
+ /* XXX make sure progress reaches 100% */
+ rpmpsmNotify(psm, 0, psm->total);
+ rpmpsmNotify(psm, RPMCALLBACK_INST_STOP, psm->total);
if (fsmrc) {
rpmlog(RPMLOG_ERR,
}
}
if (psm->goal == PKG_ERASE) {
- int fc = rpmfiFC(fi);
-
if (rpmtsFlags(ts) & RPMTRANS_FLAG_JUSTDB) break;
- /* XXX Synthesize callbacks for packages with no files. */
- if (rpmfiFC(fi) <= 0) {
- rpmtsNotify(ts, psm->te, RPMCALLBACK_UNINST_START, 0, 100);
- rpmtsNotify(ts, psm->te, RPMCALLBACK_UNINST_STOP, 0, 100);
- break;
- }
-
- psm->what = RPMCALLBACK_UNINST_START;
- psm->amount = fc; /* XXX W2DO? looks wrong. */
- psm->total = fc;
- rpmpsmNext(psm, PSM_NOTIFY);
+ rpmpsmNotify(psm, RPMCALLBACK_UNINST_START, 0);
+ /* make sure first progress call gets made */
+ rpmpsmNotify(psm, RPMCALLBACK_INST_PROGRESS, 0);
/* XXX should't we log errors from here? */
- rc = runFsm(psm, NULL) ? RPMRC_FAIL : RPMRC_OK;
-
- psm->what = RPMCALLBACK_UNINST_STOP;
- psm->amount = 0; /* XXX W2DO? looks wrong. */
- psm->total = fc;
- rpmpsmNext(psm, PSM_NOTIFY);
+ if (rpmfiFC(fi) > 0) {
+ rc = runFsm(psm, NULL) ? RPMRC_FAIL : RPMRC_OK;
+ }
+ /* XXX make sure progress reaches 100% */
+ rpmpsmNotify(psm, 0, psm->total);
+ rpmpsmNotify(psm, RPMCALLBACK_UNINST_STOP, psm->total);
}
break;
case PSM_POST:
case PSM_CREATE:
break;
- case PSM_NOTIFY:
- rpmtsNotify(ts, psm->te, psm->what, psm->amount, psm->total);
- break;
case PSM_DESTROY:
break;
case PSM_SCRIPT: /* Run current package scriptlets. */