*/
extern unsigned int myinstall_instance;
+/**
+ */
+struct rpmpsm_s {
+ struct rpmsqElem sq; /*!< Scriptlet/signal queue element. */
+
+ rpmts ts; /*!< transaction set */
+ rpmte te; /*!< current transaction element */
+ rpmfi fi; /*!< transaction element file info */
+ FD_t cfd; /*!< Payload file handle. */
+ FD_t fd; /*!< Repackage file handle. */
+ Header oh; /*!< Repackage header. */
+ rpmdbMatchIterator mi;
+ const char * stepName;
+ const char * rpmio_flags;
+ const char * failedFile;
+ const char * pkgURL; /*!< Repackage URL. */
+ const char * pkgfn; /*!< Repackage file name. */
+ int scriptTag; /*!< Scriptlet data tag. */
+ int progTag; /*!< Scriptlet interpreter tag. */
+ int npkgs_installed; /*!< No. of installed instances. */
+ int scriptArg; /*!< Scriptlet package arg. */
+ int sense; /*!< One of RPMSENSE_TRIGGER{IN,UN,POSTUN}. */
+ int countCorrection; /*!< 0 if installing, -1 if removing. */
+ int chrootDone; /*!< Was chroot(2) done by pkgStage? */
+ int unorderedSuccessor; /*!< Can the PSM be run asynchronously? */
+ rpmCallbackType what; /*!< Callback type. */
+ unsigned long amount; /*!< Callback amount. */
+ unsigned long total; /*!< Callback total. */
+ rpmRC rc;
+ pkgStage goal;
+ pkgStage stage; /*!< Current psm stage. */
+ pkgStage nstage; /*!< Next psm stage. */
+
+ int nrefs; /*!< Reference count. */
+};
+
int rpmVersionCompare(Header first, Header second)
{
const char * one, * two;
return NULL;
}
+void rpmpsmSetAsync(rpmpsm psm, int async)
+{
+ assert(psm != NULL);
+ psm->unorderedSuccessor = async;
+}
+
+rpmRC rpmpsmScriptStage(rpmpsm psm, rpm_tag_t scriptTag, rpm_tag_t progTag)
+{
+ assert(psm != NULL);
+ psm->scriptTag = scriptTag;
+ psm->progTag = progTag;
+ if (scriptTag == RPMTAG_VERIFYSCRIPT) {
+ psm->stepName = "verify";
+ }
+ return rpmpsmStage(psm, PSM_SCRIPT);
+}
+
+rpmfi rpmpsmSetFI(rpmpsm psm, rpmfi fi)
+{
+ assert(psm != NULL);
+ if (psm->fi != NULL) {
+ psm->fi = rpmfiFree(psm->fi);
+ }
+ if (fi != NULL) {
+ psm->fi = rpmfiLink(fi, RPMDBG_M("rpmpsmSetFI"));
+ }
+ return psm->fi;
+}
+
+rpmts rpmpsmGetTs(rpmpsm psm)
+{
+ return (psm ? psm->ts : NULL);
+}
+
rpmpsm rpmpsmNew(rpmts ts, rpmte te, rpmfi fi)
{
rpmpsm psm = xcalloc(1, sizeof(*psm));
#undef _fs
#undef _fd
-/**
- */
-struct rpmpsm_s {
- struct rpmsqElem sq; /*!< Scriptlet/signal queue element. */
-
- rpmts ts; /*!< transaction set */
- rpmte te; /*!< current transaction element */
- rpmfi fi; /*!< transaction element file info */
- FD_t cfd; /*!< Payload file handle. */
- FD_t fd; /*!< Repackage file handle. */
- Header oh; /*!< Repackage header. */
- rpmdbMatchIterator mi;
- const char * stepName;
- const char * rpmio_flags;
- const char * failedFile;
- const char * pkgURL; /*!< Repackage URL. */
- const char * pkgfn; /*!< Repackage file name. */
- int scriptTag; /*!< Scriptlet data tag. */
- int progTag; /*!< Scriptlet interpreter tag. */
- int npkgs_installed; /*!< No. of installed instances. */
- int scriptArg; /*!< Scriptlet package arg. */
- int sense; /*!< One of RPMSENSE_TRIGGER{IN,UN,POSTUN}. */
- int countCorrection; /*!< 0 if installing, -1 if removing. */
- int chrootDone; /*!< Was chroot(2) done by pkgStage? */
- int unorderedSuccessor; /*!< Can the PSM be run asynchronously? */
- rpmCallbackType what; /*!< Callback type. */
- unsigned long amount; /*!< Callback amount. */
- unsigned long total; /*!< Callback total. */
- rpmRC rc;
- pkgStage goal;
- pkgStage stage; /*!< Current psm stage. */
- pkgStage nstage; /*!< Next psm stage. */
-
- int nrefs; /*!< Reference count. */
-};
-
#ifdef __cplusplus
extern "C" {
#endif
rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage);
#define rpmpsmUNSAFE rpmpsmSTAGE
+/**
+ * Run rpmpsmStage(PSM_SCRIPT) for scriptTag and progTag
+ * @param psm package state machine data
+ * @param scriptTag scriptlet tag to execute
+ * @param progTag scriptlet prog tag to execute
+ * @return 0 on success
+ */
+rpmRC rpmpsmScriptStage(rpmpsm psm, rpm_tag_t scriptTag, rpm_tag_t progTag);
+
+/**
+ * @param psm package state machine data
+ * @param fi new file info pointer (or NULL to dealloc)
+ * @return newly set rpmfi pointer
+ */
+rpmfi rpmpsmSetFI(rpmpsm psm, rpmfi fi);
+
+/**
+ * @param psm package state machine data
+ * @return psm transaction set pointer
+ */
+rpmts rpmpsmGetTs(rpmpsm psm);
+
+void rpmpsmSetAsync(rpmpsm psm, int async);
+
#ifdef __cplusplus
}
#endif
}
psm = rpmpsmNew(ts, p, p->fi);
assert(psm != NULL);
- psm->scriptTag = RPMTAG_PRETRANS;
- psm->progTag = RPMTAG_PRETRANSPROG;
- xx = rpmpsmStage(psm, PSM_SCRIPT);
+ xx = rpmpsmScriptStage(psm, RPMTAG_PRETRANS, RPMTAG_PRETRANSPROG);
psm = rpmpsmFree(psm);
(void) ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
/* FIX: fi reload needs work */
while ((p = rpmtsiNext(pi, 0)) != NULL) {
rpmalKey pkgKey;
- int gotfd;
+ int gotfd, async;
gotfd = 0;
if ((fi = rpmtsiFi(pi)) == NULL)
continue; /* XXX can't happen */
psm = rpmpsmNew(ts, p, fi);
-assert(psm != NULL);
- psm->unorderedSuccessor =
- (rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1) ? 1 : 0);
+ async = (rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1) ? 1 : 0);
+ rpmpsmSetAsync(psm, async);
switch (rpmteType(p)) {
case TR_ADDED:
* XXX Sludge necessary to tranfer existing fstates/actions
* XXX around a recreated file info set.
*/
- psm->fi = rpmfiFree(psm->fi);
+ rpmpsmSetFI(psm, NULL);
{
char * fstates = fi->fstates;
rpmFileAction * actions = fi->actions;
p->fi = fi;
}
}
- psm->fi = rpmfiLink(p->fi, RPMDBG_M("rpmtsRun"));
+ rpmpsmSetFI(psm, p->fi);
/* FIX: psm->fi may be NULL */
if (rpmpsmStage(psm, PSM_PKGINSTALL)) {
p->fi->te = p;
psm = rpmpsmNew(ts, p, p->fi);
assert(psm != NULL);
- psm->scriptTag = RPMTAG_POSTTRANS;
- psm->progTag = RPMTAG_POSTTRANSPROG;
- xx = rpmpsmStage(psm, PSM_SCRIPT);
+ rpmpsmScriptStage(psm, RPMTAG_POSTTRANS, RPMTAG_POSTTRANSPROG);
psm = rpmpsmFree(psm);
(void) ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
return rc;
if (scriptFd != NULL)
- rpmtsSetScriptFd(psm->ts, scriptFd);
+ rpmtsSetScriptFd(rpmpsmGetTs(psm), scriptFd);
- psm->stepName = "verify";
- psm->scriptTag = RPMTAG_VERIFYSCRIPT;
- psm->progTag = RPMTAG_VERIFYSCRIPTPROG;
+ rc = rpmpsmScriptStage(psm, RPMTAG_VERIFYSCRIPT, RPMTAG_VERIFYSCRIPTPROG);
rc = rpmpsmStage(psm, PSM_SCRIPT);
if (scriptFd != NULL)
- rpmtsSetScriptFd(psm->ts, NULL);
+ rpmtsSetScriptFd(rpmpsmGetTs(psm), NULL);
psm = rpmpsmFree(psm);