You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
4.0 KiB
124 lines
4.0 KiB
From 8c37dff4ce9c887eda5ad61f78001e87473002ed Mon Sep 17 00:00:00 2001
|
|
From: Panu Matilainen <pmatilai@redhat.com>
|
|
Date: Tue, 16 Nov 2021 11:49:18 +0200
|
|
Subject: [PATCH] Fix spurious %transfiletriggerpostun execution
|
|
(RhBug:2023311)
|
|
|
|
If a package has multiple %transfiletriggerpostun triggers, any one
|
|
of them matching would cause all of them to run, due to disconnect
|
|
in the intel gathering stage: we'd gather all the headers with matching
|
|
files into a lump, and then add any postun triggers found in them,
|
|
but this loses the triggering file information and causes all postuns
|
|
to run.
|
|
|
|
The triggers need to be added while looping over the file matches,
|
|
like runFileTriggers() does. Doing so actually simplifies the code.
|
|
These should really be unified to use the same code, but leaving
|
|
that exercise to another rainy day.
|
|
|
|
Combined with 0988ccb53abf426587d228df5c60c4042da71999 (fix-up).
|
|
---
|
|
lib/rpmtriggers.c | 65 ++++++++++++++++++++++++-----------------------
|
|
1 file changed, 33 insertions(+), 32 deletions(-)
|
|
|
|
diff --git a/lib/rpmtriggers.c b/lib/rpmtriggers.c
|
|
index fc809a65e..8d8f57450 100644
|
|
--- a/lib/rpmtriggers.c
|
|
+++ b/lib/rpmtriggers.c
|
|
@@ -97,19 +97,39 @@ static void rpmtriggersSortAndUniq(rpmtriggers trigs)
|
|
}
|
|
}
|
|
|
|
+static void addTriggers(rpmts ts, Header trigH, rpmsenseFlags filter,
|
|
+ const char *prefix)
|
|
+{
|
|
+ int tix = 0;
|
|
+ rpmds ds;
|
|
+ rpmds triggers = rpmdsNew(trigH, RPMTAG_TRANSFILETRIGGERNAME, 0);
|
|
+
|
|
+ while ((ds = rpmdsFilterTi(triggers, tix))) {
|
|
+ if ((rpmdsNext(ds) >= 0) && (rpmdsFlags(ds) & filter) &&
|
|
+ strcmp(prefix, rpmdsN(ds)) == 0) {
|
|
+ struct rpmtd_s priorities;
|
|
+
|
|
+ if (headerGet(trigH, RPMTAG_TRANSFILETRIGGERPRIORITIES,
|
|
+ &priorities, HEADERGET_MINMEM)) {
|
|
+ rpmtdSetIndex(&priorities, tix);
|
|
+ rpmtriggersAdd(ts->trigs2run, headerGetInstance(trigH),
|
|
+ tix, *rpmtdGetUint32(&priorities));
|
|
+ }
|
|
+ }
|
|
+ rpmdsFree(ds);
|
|
+ tix++;
|
|
+ }
|
|
+ rpmdsFree(triggers);
|
|
+}
|
|
+
|
|
void rpmtriggersPrepPostUnTransFileTrigs(rpmts ts, rpmte te)
|
|
{
|
|
- rpmdbMatchIterator mi;
|
|
rpmdbIndexIterator ii;
|
|
- Header trigH;
|
|
const void *key;
|
|
size_t keylen;
|
|
rpmfiles files;
|
|
- rpmds rpmdsTriggers;
|
|
- rpmds rpmdsTrigger;
|
|
|
|
ii = rpmdbIndexIteratorInit(rpmtsGetRdb(ts), RPMDBI_TRANSFILETRIGGERNAME);
|
|
- mi = rpmdbNewIterator(rpmtsGetRdb(ts), RPMDBI_PACKAGES);
|
|
files = rpmteFiles(te);
|
|
|
|
/* Iterate over file triggers in rpmdb */
|
|
@@ -121,39 +141,20 @@ void rpmtriggersPrepPostUnTransFileTrigs(rpmts ts, rpmte te)
|
|
rpmfi fi = rpmfilesFindPrefix(files, pfx);
|
|
while (rpmfiNext(fi) >= 0) {
|
|
if (RPMFILE_IS_INSTALLED(rpmfiFState(fi))) {
|
|
- /* If yes then store it */
|
|
- rpmdbAppendIterator(mi, rpmdbIndexIteratorPkgOffsets(ii),
|
|
- rpmdbIndexIteratorNumPkgs(ii));
|
|
+ unsigned int npkg = rpmdbIndexIteratorNumPkgs(ii);
|
|
+ const unsigned int *offs = rpmdbIndexIteratorPkgOffsets(ii);
|
|
+ /* Save any postun triggers matching this prefix */
|
|
+ for (int i = 0; i < npkg; i++) {
|
|
+ Header h = rpmdbGetHeaderAt(rpmtsGetRdb(ts), offs[i]);
|
|
+ addTriggers(ts, h, RPMSENSE_TRIGGERPOSTUN, pfx);
|
|
+ headerFree(h);
|
|
+ }
|
|
break;
|
|
}
|
|
}
|
|
rpmfiFree(fi);
|
|
}
|
|
rpmdbIndexIteratorFree(ii);
|
|
-
|
|
- if (rpmdbGetIteratorCount(mi)) {
|
|
- /* Filter triggers and save only trans postun triggers into ts */
|
|
- while ((trigH = rpmdbNextIterator(mi)) != NULL) {
|
|
- int tix = 0;
|
|
- rpmdsTriggers = rpmdsNew(trigH, RPMTAG_TRANSFILETRIGGERNAME, 0);
|
|
- while ((rpmdsTrigger = rpmdsFilterTi(rpmdsTriggers, tix))) {
|
|
- if ((rpmdsNext(rpmdsTrigger) >= 0) &&
|
|
- (rpmdsFlags(rpmdsTrigger) & RPMSENSE_TRIGGERPOSTUN)) {
|
|
- struct rpmtd_s priorities;
|
|
-
|
|
- headerGet(trigH, RPMTAG_TRANSFILETRIGGERPRIORITIES,
|
|
- &priorities, HEADERGET_MINMEM);
|
|
- rpmtdSetIndex(&priorities, tix);
|
|
- rpmtriggersAdd(ts->trigs2run, rpmdbGetIteratorOffset(mi),
|
|
- tix, *rpmtdGetUint32(&priorities));
|
|
- }
|
|
- rpmdsFree(rpmdsTrigger);
|
|
- tix++;
|
|
- }
|
|
- rpmdsFree(rpmdsTriggers);
|
|
- }
|
|
- }
|
|
- rpmdbFreeIterator(mi);
|
|
rpmfilesFree(files);
|
|
}
|
|
|
|
--
|
|
2.35.1
|
|
|