213 lines
8.3 KiB
Diff
213 lines
8.3 KiB
Diff
|
From 31996808c140496c35e3c9543750026292b72287 Mon Sep 17 00:00:00 2001
|
||
|
From: Lubos Kardos <lkardos@redhat.com>
|
||
|
Date: Mon, 23 Nov 2015 15:05:13 +0100
|
||
|
Subject: [PATCH] Add possibility to disable file triggers.
|
||
|
|
||
|
Now options --notriggers, --notriggerin, --notriggerun, --notriggerpostun
|
||
|
disable also file triggers and not only normal trigges. Transaction file
|
||
|
triggers can be also disabled with --nopretrans and --nopostrans options.
|
||
|
|
||
|
Before this patch file triggers weren't disabled when option --test was
|
||
|
specified. That caused unwanted multiple execution of file triggers
|
||
|
in dnf because dnf executes transaction with flag test before executing
|
||
|
transaction for real (rhbz:1282115).
|
||
|
---
|
||
|
lib/psm.c | 97 ++++++++++++++++++++++++++++++-------------------------
|
||
|
lib/transaction.c | 16 ++++++---
|
||
|
2 files changed, 65 insertions(+), 48 deletions(-)
|
||
|
|
||
|
diff --git a/lib/psm.c b/lib/psm.c
|
||
|
index 154237e..08d4919 100644
|
||
|
--- a/lib/psm.c
|
||
|
+++ b/lib/psm.c
|
||
|
@@ -682,21 +682,24 @@ static rpmRC rpmPackageInstall(rpmts ts, rpmpsm psm)
|
||
|
rc = dbAdd(ts, psm->te);
|
||
|
if (rc) break;
|
||
|
|
||
|
- /* Run upper file triggers i. e. with higher priorities */
|
||
|
- /* Run file triggers in other package(s) this package sets off. */
|
||
|
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
|
||
|
- RPMSCRIPT_FILETRIGGER, 1);
|
||
|
- if (rc) break;
|
||
|
-
|
||
|
- /* Run file triggers in this package other package(s) set off. */
|
||
|
- rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
|
||
|
+ if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERIN)) {
|
||
|
+ /* Run upper file triggers i. e. with higher priorities */
|
||
|
+ /* Run file triggers in other package(s) this package sets off. */
|
||
|
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
|
||
|
RPMSCRIPT_FILETRIGGER, 1);
|
||
|
- if (rc) break;
|
||
|
+ if (rc) break;
|
||
|
+
|
||
|
+ /* Run file triggers in this package other package(s) set off. */
|
||
|
+ rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
|
||
|
+ RPMSCRIPT_FILETRIGGER, 1);
|
||
|
+ if (rc) break;
|
||
|
+ }
|
||
|
|
||
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOPOST)) {
|
||
|
rc = runInstScript(psm, RPMTAG_POSTIN);
|
||
|
if (rc) break;
|
||
|
}
|
||
|
+
|
||
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERIN)) {
|
||
|
/* Run triggers in other package(s) this package sets off. */
|
||
|
rc = runTriggers(psm, RPMSENSE_TRIGGERIN);
|
||
|
@@ -705,18 +708,18 @@ static rpmRC rpmPackageInstall(rpmts ts, rpmpsm psm)
|
||
|
/* Run triggers in this package other package(s) set off. */
|
||
|
rc = runImmedTriggers(psm, RPMSENSE_TRIGGERIN);
|
||
|
if (rc) break;
|
||
|
- }
|
||
|
|
||
|
- /* Run lower file triggers i. e. with lower priorities */
|
||
|
- /* Run file triggers in other package(s) this package sets off. */
|
||
|
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
|
||
|
- RPMSCRIPT_FILETRIGGER, 2);
|
||
|
- if (rc) break;
|
||
|
-
|
||
|
- /* Run file triggers in this package other package(s) set off. */
|
||
|
- rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
|
||
|
+ /* Run lower file triggers i. e. with lower priorities */
|
||
|
+ /* Run file triggers in other package(s) this package sets off. */
|
||
|
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
|
||
|
RPMSCRIPT_FILETRIGGER, 2);
|
||
|
- if (rc) break;
|
||
|
+ if (rc) break;
|
||
|
+
|
||
|
+ /* Run file triggers in this package other package(s) set off. */
|
||
|
+ rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
|
||
|
+ RPMSCRIPT_FILETRIGGER, 2);
|
||
|
+ if (rc) break;
|
||
|
+ }
|
||
|
|
||
|
rc = markReplacedFiles(psm);
|
||
|
}
|
||
|
@@ -734,17 +737,17 @@ static rpmRC rpmPackageErase(rpmts ts, rpmpsm psm)
|
||
|
rpmswEnter(rpmtsOp(psm->ts, RPMTS_OP_ERASE), 0);
|
||
|
while (once--) {
|
||
|
|
||
|
- /* Run file triggers in this package other package(s) set off. */
|
||
|
- rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
|
||
|
- RPMSCRIPT_FILETRIGGER, 1);
|
||
|
- if (rc) break;
|
||
|
+ if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERUN)) {
|
||
|
+ /* Run file triggers in this package other package(s) set off. */
|
||
|
+ rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
|
||
|
+ RPMSCRIPT_FILETRIGGER, 1);
|
||
|
+ if (rc) break;
|
||
|
|
||
|
- /* Run file triggers in other package(s) this package sets off. */
|
||
|
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
|
||
|
- RPMSCRIPT_FILETRIGGER, 1);
|
||
|
- if (rc) break;
|
||
|
+ /* Run file triggers in other package(s) this package sets off. */
|
||
|
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
|
||
|
+ RPMSCRIPT_FILETRIGGER, 1);
|
||
|
+ if (rc) break;
|
||
|
|
||
|
- if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERUN)) {
|
||
|
/* Run triggers in this package other package(s) set off. */
|
||
|
rc = runImmedTriggers(psm, RPMSENSE_TRIGGERUN);
|
||
|
if (rc) break;
|
||
|
@@ -757,22 +760,26 @@ static rpmRC rpmPackageErase(rpmts ts, rpmpsm psm)
|
||
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOPREUN))
|
||
|
rc = runInstScript(psm, RPMTAG_PREUN);
|
||
|
|
||
|
- /* Run file triggers in this package other package(s) set off. */
|
||
|
- rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
|
||
|
- RPMSCRIPT_FILETRIGGER, 2);
|
||
|
- if (rc) break;
|
||
|
+ if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERUN)) {
|
||
|
+ /* Run file triggers in this package other package(s) set off. */
|
||
|
+ rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
|
||
|
+ RPMSCRIPT_FILETRIGGER, 2);
|
||
|
+ if (rc) break;
|
||
|
|
||
|
- /* Run file triggers in other package(s) this package sets off. */
|
||
|
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
|
||
|
- RPMSCRIPT_FILETRIGGER, 2);
|
||
|
- if (rc) break;
|
||
|
+ /* Run file triggers in other package(s) this package sets off. */
|
||
|
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
|
||
|
+ RPMSCRIPT_FILETRIGGER, 2);
|
||
|
+ if (rc) break;
|
||
|
+ }
|
||
|
|
||
|
rc = rpmpsmRemove(psm);
|
||
|
if (rc) break;
|
||
|
|
||
|
/* Run file triggers in other package(s) this package sets off. */
|
||
|
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERPOSTUN,
|
||
|
- RPMSCRIPT_FILETRIGGER, 1);
|
||
|
+ if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERPOSTUN)) {
|
||
|
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERPOSTUN,
|
||
|
+ RPMSCRIPT_FILETRIGGER, 1);
|
||
|
+ }
|
||
|
|
||
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOPOSTUN)) {
|
||
|
rc = runInstScript(psm, RPMTAG_POSTUN);
|
||
|
@@ -783,15 +790,17 @@ static rpmRC rpmPackageErase(rpmts ts, rpmpsm psm)
|
||
|
/* Run triggers in other package(s) this package sets off. */
|
||
|
rc = runTriggers(psm, RPMSENSE_TRIGGERPOSTUN);
|
||
|
if (rc) break;
|
||
|
- }
|
||
|
|
||
|
- /* Run file triggers in other package(s) this package sets off. */
|
||
|
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERPOSTUN,
|
||
|
- RPMSCRIPT_FILETRIGGER, 2);
|
||
|
+ /* Run file triggers in other package(s) this package sets off. */
|
||
|
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERPOSTUN,
|
||
|
+ RPMSCRIPT_FILETRIGGER, 2);
|
||
|
+ }
|
||
|
if (rc) break;
|
||
|
|
||
|
- /* Prepare post transaction uninstall triggers */
|
||
|
- rpmtriggersPrepPostUnTransFileTrigs(psm->ts, psm->te);
|
||
|
+ if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_NOPOSTTRANS|RPMTRANS_FLAG_NOTRIGGERPOSTUN))) {
|
||
|
+ /* Prepare post transaction uninstall triggers */
|
||
|
+ rpmtriggersPrepPostUnTransFileTrigs(psm->ts, psm->te);
|
||
|
+ }
|
||
|
|
||
|
rc = dbRemove(ts, psm->te);
|
||
|
}
|
||
|
diff --git a/lib/transaction.c b/lib/transaction.c
|
||
|
index 8f440b7..66888af 100644
|
||
|
--- a/lib/transaction.c
|
||
|
+++ b/lib/transaction.c
|
||
|
@@ -1488,7 +1488,9 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
||
|
goto exit;
|
||
|
}
|
||
|
|
||
|
- if (!rpmpsNumProblems(tsprobs)) {
|
||
|
+ if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_BUILD_PROBS|RPMTRANS_FLAG_NOPRETRANS|
|
||
|
+ RPMTRANS_FLAG_NOTRIGGERUN) || rpmpsNumProblems(tsprobs))) {
|
||
|
+
|
||
|
/* Run file triggers in this package other package(s) set off. */
|
||
|
runFileTriggers(ts, NULL, RPMSENSE_TRIGGERUN,
|
||
|
RPMSCRIPT_TRANSFILETRIGGER, 0);
|
||
|
@@ -1541,11 +1543,17 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
||
|
}
|
||
|
|
||
|
/* Run file triggers in other package(s) this package sets off. */
|
||
|
- runFileTriggers(ts, NULL, RPMSENSE_TRIGGERIN, RPMSCRIPT_TRANSFILETRIGGER, 0);
|
||
|
- runPostUnTransFileTrigs(ts);
|
||
|
+ if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_NOPOSTTRANS|RPMTRANS_FLAG_NOTRIGGERIN))) {
|
||
|
+ runFileTriggers(ts, NULL, RPMSENSE_TRIGGERIN, RPMSCRIPT_TRANSFILETRIGGER, 0);
|
||
|
+ }
|
||
|
+ if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_NOPOSTTRANS|RPMTRANS_FLAG_NOTRIGGERPOSTUN))) {
|
||
|
+ runPostUnTransFileTrigs(ts);
|
||
|
+ }
|
||
|
|
||
|
/* Run file triggers in this package other package(s) set off. */
|
||
|
- runTransScripts(ts, PKG_TRANSFILETRIGGERIN);
|
||
|
+ if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_NOPOSTTRANS|RPMTRANS_FLAG_NOTRIGGERIN))) {
|
||
|
+ runTransScripts(ts, PKG_TRANSFILETRIGGERIN);
|
||
|
+ }
|
||
|
exit:
|
||
|
/* Run post transaction hook for all plugins */
|
||
|
if (TsmPreDone) /* If TsmPre hook has been called, call the TsmPost hook */
|
||
|
--
|
||
|
1.9.3
|
||
|
|