rpm/rpm-5.4.9-add-filetriggers-regex-matching-support.patch

112 lines
4.2 KiB
Diff
Raw Permalink Normal View History

2013-03-27 12:51:15 +04:00
--- rpm-5.4.9/build/parseReqs.c.trig_pcre~ 2009-06-13 11:07:44.000000000 +0200
+++ rpm-5.4.9/build/parseReqs.c 2012-05-15 03:05:07.438054281 +0200
@@ -110,7 +110,7 @@ rpmRC parseRCPOT(Spec spec, Package pkg,
ix = 0;
if (N[ix] == '!')
ix++;
- if (!(xisalnum(N[ix]) || N[ix] == '_' || N[ix] == '/'
+ if (!(xisalnum(N[ix]) || N[ix] == '_' || N[ix] == '/' || N[ix] == '^'
|| (nr > 5 && N[ix] == '%' && N[ix+1] == '{' && N[nr-1] == '}')))
{
rpmlog(RPMLOG_ERR,
--- rpm-5.4.9/lib/psm.c.trig_pcre~ 2012-05-15 03:05:07.085052367 +0200
+++ rpm-5.4.9/lib/psm.c 2012-05-15 03:07:11.367726113 +0200
@@ -67,6 +67,9 @@
#include "debug.h"
+#define PATT_ISDIR(patt, len) ((patt[0] == '/' && patt[len-1] == '/') || \
+ (patt[0] == '^' && patt[len-1] == '$' && patt[len-2] == '/'))
+
#define _PSM_DEBUG 0
/*@unchecked@*/
int _psm_debug = _PSM_DEBUG;
@@ -1285,11 +1288,11 @@ static rpmRC handleOneTrigger(const rpmp
bingo = 0; /* no trigger to fire. */
depName = (char *) rpmdsN(Tds);
- if (depName[0] == '/') {
+ if (depName[0] == '^' || depName[0] == '/') {
size_t nb = strlen(depName);
- if (Glob_pattern_p(depName, 0)) {
+ if (depName[0] == '^' || Glob_pattern_p(depName, 0)) {
rpmds ds = NULL;
- if (depName[nb-1] == '/') {
+ if (PATT_ISDIR(depName, nb)) {
/* XXX Dirnames w trailing "/" needed. */
if (Dds == NULL)
Dds = rpmdsNew(sourceH, RPMTAG_DIRNAMES, 0x2);
@@ -1300,7 +1303,7 @@ static rpmRC handleOneTrigger(const rpmp
ds = rpmdsLink(Fds, "Triggers");
}
if (mire == NULL)
- mire = mireNew(RPMMIRE_GLOB, 0);
+ mire = mireNew(depName[0] == '^' ? RPMMIRE_PCRE : RPMMIRE_GLOB, 0);
xx = mireRegcomp(mire, depName);
if ((ds = rpmdsInit(ds)) != NULL)
@@ -1318,7 +1321,7 @@ static rpmRC handleOneTrigger(const rpmp
}
/* If not matched, and directory trigger, try dir names. */
- if (!bingo && depName[nb-1] == '/') {
+ if (!bingo && PATT_ISDIR(depName, nb)) {
/* XXX Dirnames w trailing "/" needed. */
if (Dds == NULL)
Dds = rpmdsNew(sourceH, RPMTAG_DIRNAMES, 0x2);
@@ -1401,9 +1404,9 @@ static int rpmdbTriggerGlobs(rpmpsm psm)
if (keys)
for (i = 0; i < nkeys; i++) {
char * t = (char *) keys[i];
- if (!Glob_pattern_p(t, 0))
+ if (!(t[0] == '^' || Glob_pattern_p(t, 0)))
continue;
- xx = mireAppend(RPMMIRE_GLOB, 0, t, NULL,
+ xx = mireAppend(t[0] == '^' ? RPMMIRE_PCRE : RPMMIRE_GLOB, 0, t, NULL,
(miRE *)&psm->Tmires, &psm->nTmires);
xx = argvAdd(&psm->Tpats, t);
}
@@ -1461,7 +1464,7 @@ static rpmRC runTriggersLoop(rpmpsm psm,
const char * pattern = psm->Tpats[j];
if (depName[nName-1] != '/') {
size_t npattern = strlen(pattern);
- depName[nName] = (pattern[npattern-1] == '/') ? '/' : '\0';
+ depName[nName] = PATT_ISDIR(pattern, npattern) ? '/' : '\0';
}
if (mireRegexec(mire, depName, 0) < 0)
/*@innercontinue@*/ continue;
@@ -1634,14 +1637,14 @@ assert(fi->h != NULL);
/* If not limited to NEVRA triggers, use file/dir index. */
if (tagno != RPMTAG_NAME) {
+ size_t nb = strlen(N);
/* XXX if trigger name ends with '/', use dirnames instead. */
- if (N[0] == '/')
- tagno = (N[strlen(N)-1] == '/')
- ? RPMTAG_DIRNAMES : RPMTAG_FILEPATHS;
+ if (N[0] == '^' || N[0] == '/')
+ tagno = (PATT_ISDIR(N, nb)) ? RPMTAG_DIRNAMES : RPMTAG_FILEPATHS;
}
/* XXX For now, permit globs only in unversioned triggers. */
- if ((EVR == NULL || *EVR == '\0') && Glob_pattern_p(N, 0))
- xx = rpmdbMireApply(rpmtsGetRdb(ts), tagno, RPMMIRE_GLOB, N, &keys);
+ if ((EVR == NULL || *EVR == '\0') && (N[0] == '^' || Glob_pattern_p(N, 0)))
+ xx = rpmdbMireApply(rpmtsGetRdb(ts), tagno, N[0] == '^' ? RPMMIRE_PCRE : RPMMIRE_GLOB, N, &keys);
else
xx = argvAdd(&keys, N);
}
@@ -1657,10 +1660,10 @@ assert(fi->h != NULL);
/* If not limited to NEVRA triggers, use file/dir index. */
if (tagno != RPMTAG_NAME) {
+ size_t nb = strlen(Name);
/* XXX if trigger name ends with '/', use dirnames instead. */
- if (Name[0] == '/')
- tagno = (Name[strlen(Name)-1] == '/')
- ? RPMTAG_DIRNAMES : RPMTAG_FILEPATHS;
+ if (Name[0] == '^' || Name[0] == '/')
+ tagno = PATT_ISDIR(Name, nb) ? RPMTAG_DIRNAMES : RPMTAG_FILEPATHS;
}
mi = rpmtsInitIterator(ts, tagno, Name, 0);