a76d6c30a2
Copy from Base:System/rpm based on submit request 18841 from user mlschroe OBS-URL: https://build.opensuse.org/request/show/18841 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rpm?expand=0&rev=84
68 lines
2.1 KiB
Diff
68 lines
2.1 KiB
Diff
This patch supports an extension in the condition evaluation.
|
|
If the condition is a format and returns an nonempty string, it is
|
|
assumed to be true.
|
|
This mechanism is used by the weakdeps patch to filter the
|
|
"RPMSENSE_STRONG" flag.
|
|
|
|
Index: lib/headerfmt.c
|
|
===================================================================
|
|
--- lib/headerfmt.c.orig
|
|
+++ lib/headerfmt.c
|
|
@@ -582,8 +582,12 @@ static int parseExpression(headerSprintf
|
|
|
|
*endPtr = chptr;
|
|
|
|
+ token->u.cond.tag.type = NULL;
|
|
+ token->u.cond.tag.format = "";
|
|
token->type = PTOK_COND;
|
|
|
|
+ if ((token->u.cond.tag.type = strchr(str, ':')) != 0)
|
|
+ *token->u.cond.tag.type++ = 0;
|
|
(void) findTag(hsa, token, str);
|
|
|
|
return 0;
|
|
@@ -675,6 +679,7 @@ static char * singleSprintf(headerSprint
|
|
int i, j, found;
|
|
rpm_count_t count, numElements;
|
|
sprintfToken spft;
|
|
+ sprintfTag stag;
|
|
int condNumFormats;
|
|
size_t need;
|
|
|
|
@@ -705,6 +710,18 @@ static char * singleSprintf(headerSprint
|
|
headerIsEntry(hsa->h, token->u.cond.tag.tag)) {
|
|
spft = token->u.cond.ifFormat;
|
|
condNumFormats = token->u.cond.numIfTokens;
|
|
+ if (token->u.cond.tag.fmt) {
|
|
+ /* check if format creates output */
|
|
+ size_t vallen = hsa->vallen;
|
|
+ formatValue(hsa, &token->u.cond.tag, element);
|
|
+ if (hsa->vallen == vallen) {
|
|
+ spft = token->u.cond.elseFormat;
|
|
+ condNumFormats = token->u.cond.numElseTokens;
|
|
+ } else {
|
|
+ hsa->vallen = vallen;
|
|
+ hsa->val[hsa->vallen] = 0;
|
|
+ }
|
|
+ }
|
|
} else {
|
|
spft = token->u.cond.elseFormat;
|
|
condNumFormats = token->u.cond.numElseTokens;
|
|
@@ -728,10 +745,13 @@ static char * singleSprintf(headerSprint
|
|
for (i = 0; i < token->u.array.numTokens; i++, spft++)
|
|
{
|
|
rpmtd td = NULL;
|
|
- if (spft->type != PTOK_TAG ||
|
|
- spft->u.tag.justOne) continue;
|
|
+ if (spft->type != PTOK_TAG && spft->type != PTOK_COND)
|
|
+ continue;
|
|
+ stag = (spft->type == PTOK_COND ? &spft->u.cond.tag : &spft->u.tag);
|
|
+ if (stag->justOne)
|
|
+ continue;
|
|
|
|
- if (!(td = getData(hsa, spft->u.tag.tag))) {
|
|
+ if (!(td = getData(hsa, stag->tag))) {
|
|
continue;
|
|
}
|
|
|