rpmfs fs;
};
-static void rpmteColorDS(rpmte te, rpmTag tag); /* forward declaration */
+/* forward declarations */
+static void rpmteColorDS(rpmte te, rpmTag tag);
+static int rpmteClose(rpmte te, rpmts ts, int reset_fi);
void rpmteCleanDS(rpmte te)
{
return h;
}
-int rpmteOpen(rpmte te, rpmts ts, int reload_fi)
+static int rpmteOpen(rpmte te, rpmts ts, int reload_fi)
{
Header h = NULL;
unsigned int instance;
return (h != NULL);
}
-int rpmteClose(rpmte te, rpmts ts, int reset_fi)
+static int rpmteClose(rpmte te, rpmts ts, int reset_fi)
{
if (te == NULL || ts == NULL)
return 0;
return payload;
}
-int rpmteMarkFailed(rpmte te, rpmts ts)
+static int rpmteMarkFailed(rpmte te, rpmts ts)
{
rpmtsi pi = rpmtsiInit(ts);
rpmte p;
return (te != NULL) ? te->failed : -1;
}
-int rpmteHaveTransScript(rpmte te, rpmTag tag)
+static int rpmteHaveTransScript(rpmte te, rpmTag tag)
{
int rc = 0;
if (tag == RPMTAG_PRETRANS) {
return te->fs;
}
+int rpmteProcess(rpmte te, rpmts ts, pkgGoal goal)
+{
+ /* Only install/erase resets pkg file info */
+ int scriptstage = (goal != PKG_INSTALL && goal != PKG_ERASE);
+ int reset_fi = (scriptstage == 0);
+ int failed = 1;
+
+ /* Dont bother opening for elements without pre/posttrans scripts */
+ if (goal == PKG_PRETRANS || goal == PKG_POSTTRANS) {
+ if (!rpmteHaveTransScript(te, goal)) {
+ return 0;
+ }
+ }
+
+ if (rpmteOpen(te, ts, reset_fi)) {
+ failed = rpmpsmRun(ts, te, goal);
+ rpmteClose(te, ts, reset_fi);
+ }
+
+ /* XXX should %pretrans failure fail the package install? */
+ if (failed && !scriptstage) {
+ failed = rpmteMarkFailed(te, ts);
+ }
+
+ return failed;
+}
FD_t rpmteSetFd(rpmte te, FD_t fd);
RPM_GNUC_INTERNAL
-int rpmteOpen(rpmte te, rpmts ts, int reload_fi);
-
-RPM_GNUC_INTERNAL
-int rpmteClose(rpmte te, rpmts ts, int reset_fi);
-
-RPM_GNUC_INTERNAL
FD_t rpmtePayload(rpmte te);
RPM_GNUC_INTERNAL
-int rpmteMarkFailed(rpmte te, rpmts ts);
-
-RPM_GNUC_INTERNAL
-int rpmteHaveTransScript(rpmte te, rpmTag tag);
+int rpmteProcess(rpmte te, rpmts ts, pkgGoal goal);
RPM_GNUC_INTERNAL
void rpmteAddProblem(rpmte te, rpmProblemType type,
/*
* Run pre/post transaction scripts for transaction set
* param ts Transaction set
- * param stag RPMTAG_PRETRANS or RPMTAG_POSTTRANS
- * return 0 on success, -1 on error (invalid script tag)
+ * param goal PKG_PRETRANS/PKG_POSTTRANS
+ * return 0 on success
*/
-static int runTransScripts(rpmts ts, rpmTag stag)
+static int runTransScripts(rpmts ts, pkgGoal goal)
{
- rpmtsi pi;
rpmte p;
- int xx;
-
- if (stag != RPMTAG_PRETRANS && stag != RPMTAG_POSTTRANS)
- return -1;
-
- pi = rpmtsiInit(ts);
+ rpmtsi pi = rpmtsiInit(ts);
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
- /* Skip elements without pre/posttrans */
- if (!rpmteHaveTransScript(p, stag))
- continue;
-
- if (rpmteOpen(p, ts, 0)) {
- /* XXX should %pretrans failure fail the package install? */
- xx = rpmpsmRun(ts, p, stag);
- rpmteClose(p, ts, 0);
- }
+ rpmteProcess(p, ts, goal);
}
pi = rpmtsiFree(pi);
- return 0;
+ return 0; /* what to do about failures? */
}
/* Add fingerprint for each file not skipped. */
pi = rpmtsiInit(ts);
while ((p = rpmtsiNext(pi, 0)) != NULL) {
- int failed = 1;
+ int failed;
rpmlog(RPMLOG_DEBUG, "========== +++ %s %s-%s 0x%x\n",
rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
- if (rpmteOpen(p, ts, 1)) {
- failed = rpmpsmRun(ts, p, rpmteType(p));
- rpmteClose(p, ts, 1);
- }
+ failed = rpmteProcess(p, ts, rpmteType(p));
if (failed) {
- int fails = rpmteMarkFailed(p, ts);
rpmlog(RPMLOG_ERR, "%s: %s %s\n", rpmteNEVRA(p),
- rpmteTypeString(p), fails > 1 ? _("skipped") : _("failed"));
+ rpmteTypeString(p), failed > 1 ? _("skipped") : _("failed"));
rc++;
}
(void) rpmdbSync(rpmtsGetRdb(ts));
|| (rpmpsNumProblems(tsprobs) &&
(okProbs == NULL || rpmpsTrim(tsprobs, okProbs))))) {
rpmlog(RPMLOG_DEBUG, "running pre-transaction scripts\n");
- runTransScripts(ts, RPMTAG_PRETRANS);
+ runTransScripts(ts, PKG_PRETRANS);
}
tsprobs = rpmpsFree(tsprobs);
/* Run post-transaction scripts unless disabled */
if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_TEST|RPMTRANS_FLAG_NOPOST))) {
rpmlog(RPMLOG_DEBUG, "running post-transaction scripts\n");
- runTransScripts(ts, RPMTAG_POSTTRANS);
+ runTransScripts(ts, PKG_POSTTRANS);
}
/* Finish up... */
#include <rpm/rpmfileutil.h>
#include "lib/misc.h" /* uidToUname(), gnameToGid */
-#include "lib/rpmte_internal.h" /* rpmteOpen(), rpmteClose() */
+#include "lib/rpmte_internal.h" /* rpmteProcess() */
#include "debug.h"
/* fake up a erasure transaction element */
rc = rpmtsAddEraseElement(ts, h, -1);
te = rpmtsElement(ts, 0);
- rpmteOpen(te, ts, 0);
-
- rc = rpmpsmRun(ts, te, PKG_VERIFY);
+
+ rc = rpmteProcess(te, ts, PKG_VERIFY);
/* clean up our fake transaction bits */
- rpmteClose(te, ts, 0);
rpmtsEmpty(ts);
return rc;