NULL, NULL},
{ "prtpkts", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_print_pkts, -1,
NULL, NULL},
- { "psmdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_psm_debug, -1,
- N_("debug package state machine"), NULL},
{ "rpmaldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmal_debug, -1,
NULL, NULL},
{ "rpmdbdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmdb_debug, -1,
#include "debug.h"
-#define _PSM_DEBUG 0
-int _psm_debug = _PSM_DEBUG;
-
typedef enum pkgStage_e {
PSM_UNKNOWN = 0,
PSM_INIT = 1,
} pkgStage;
-struct rpmpsm_s {
+typedef struct rpmpsm_s {
rpmts ts; /*!< transaction set */
rpmte te; /*!< current transaction element */
rpmfi fi; /*!< transaction element file info */
pkgStage nstage; /*!< Next psm stage. */
int nrefs; /*!< Reference count. */
-};
+} * rpmpsm;
+static rpmpsm rpmpsmNew(rpmts ts, rpmte te);
+static rpmpsm rpmpsmFree(rpmpsm psm);
static rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage);
/**
return rc;
}
-rpmpsm rpmpsmUnlink(rpmpsm psm, const char * msg)
-{
- if (psm == NULL) return NULL;
-if (_psm_debug && msg != NULL)
-fprintf(stderr, "--> psm %p -- %d: %s\n", psm, psm->nrefs, msg);
- psm->nrefs--;
- return NULL;
-}
-
-rpmpsm rpmpsmLink(rpmpsm psm, const char * msg)
-{
- if (psm == NULL) return NULL;
- psm->nrefs++;
-
-if (_psm_debug && msg != NULL)
-fprintf(stderr, "--> psm %p ++ %d %s\n", psm, psm->nrefs, msg);
-
- return psm;
-}
-
-rpmpsm rpmpsmFree(rpmpsm psm)
+static rpmpsm rpmpsmFree(rpmpsm psm)
{
if (psm == NULL)
return NULL;
- if (psm->nrefs > 1)
- return rpmpsmUnlink(psm, RPMDBG_M("rpmpsmFree"));
-
psm->fi = rpmfiFree(psm->fi);
#ifdef NOTYET
psm->te = rpmteFree(psm->te);
#endif
psm->ts = rpmtsFree(psm->ts);
- (void) rpmpsmUnlink(psm, RPMDBG_M("rpmpsmFree"));
-
memset(psm, 0, sizeof(*psm)); /* XXX trash and burn */
psm = _free(psm);
return NULL;
}
-rpmpsm rpmpsmNew(rpmts ts, rpmte te)
+static rpmpsm rpmpsmNew(rpmts ts, rpmte te)
{
rpmpsm psm = xcalloc(1, sizeof(*psm));
psm->fi = rpmfiLink(rpmteFI(te), RPMDBG_M("rpmpsmNew"));
}
- return rpmpsmLink(psm, RPMDBG_M("rpmpsmNew"));
+ return psm;
}
static int rpmpsmNext(rpmpsm psm, pkgStage nstage)
}
}
-rpmRC rpmpsmRun(rpmpsm psm, pkgGoal goal)
+rpmRC rpmpsmRun(rpmts ts, rpmte te, pkgGoal goal)
{
+ rpmpsm psm = rpmpsmNew(ts, te);
rpmRC rc = RPMRC_FAIL;
if (psm) {
break;
}
}
+ rpmpsmFree(psm);
return rc;
}
#include <rpm/rpmte.h>
-extern int _psm_debug;
-
-typedef struct rpmpsm_s * rpmpsm;
-
typedef enum pkgGoal_e {
PKG_NONE = 0,
/* permit using rpmteType() for install + erase goals */
#endif
/**
- * Unreference a package state machine instance.
- * @param psm package state machine
- * @param msg
- * @return NULL always
- */
-RPM_GNUC_INTERNAL
-rpmpsm rpmpsmUnlink (rpmpsm psm,
- const char * msg);
-
-/**
- * Reference a package state machine instance.
- * @param psm package state machine
- * @param msg
- * @return new package state machine reference
- */
-RPM_GNUC_INTERNAL
-rpmpsm rpmpsmLink (rpmpsm psm, const char * msg);
-
-/**
- * Destroy a package state machine.
- * @param psm package state machine
- * @return NULL always
- */
-RPM_GNUC_INTERNAL
-rpmpsm rpmpsmFree(rpmpsm psm);
-
-/**
- * Create and load a package state machine.
- * @param ts transaction set
- * @param te transaction set element
- * @return new package state machine
- */
-RPM_GNUC_INTERNAL
-rpmpsm rpmpsmNew(rpmts ts, rpmte te);
-
-/**
* Package state machine driver.
- * @param psm package state machine data
+ * @param ts transaction set
+ * @param te transaction element
* @param goal state machine goal
* @return 0 on success
*/
RPM_GNUC_INTERNAL
-rpmRC rpmpsmRun(rpmpsm psm, pkgGoal goal);
+rpmRC rpmpsmRun(rpmts ts, rpmte te, pkgGoal goal);
#ifdef __cplusplus
}
{
rpmtsi pi;
rpmte p;
- rpmpsm psm;
int xx;
if (stag != RPMTAG_PRETRANS && stag != RPMTAG_POSTTRANS)
continue;
if (rpmteOpen(p, ts, 0)) {
- psm = rpmpsmNew(ts, p);
/* XXX should %pretrans failure fail the package install? */
- xx = rpmpsmRun(psm, stag);
- psm = rpmpsmFree(psm);
+ xx = rpmpsmRun(ts, p, stag);
rpmteClose(p, ts, 0);
}
}
rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
if (rpmteOpen(p, ts, 1)) {
- rpmpsm psm = rpmpsmNew(ts, p);
- failed = rpmpsmRun(psm, rpmteType(p));
- psm = rpmpsmFree(psm);
+ failed = rpmpsmRun(ts, p, rpmteType(p));
rpmteClose(p, ts, 1);
}
if (failed) {
*/
static int rpmVerifyScript(QVA_t qva, rpmts ts, Header h, FD_t scriptFd)
{
- rpmpsm psm = NULL;
rpmte te = NULL;
int rc = 0;
if (scriptFd != NULL)
rpmtsSetScriptFd(ts, scriptFd);
- /* create psm to run the script */
- psm = rpmpsmNew(ts, te);
- rc = rpmpsmRun(psm, PKG_VERIFY);
- psm = rpmpsmFree(psm);
+ rc = rpmpsmRun(ts, te, PKG_VERIFY);
if (scriptFd != NULL)
rpmtsSetScriptFd(ts, NULL);