1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
/** \ingroup rpmbuild
* \file build/parseReqs.c
* Parse dependency tag from spec file or from auto-dependency generator.
*/
#include "system.h"
#include "rpmbuild.h"
#include "debug.h"
/**
*/
static struct ReqComp {
const char * token;
rpmsenseFlags sense;
} ReqComparisons[] = {
{ "<=", RPMSENSE_LESS | RPMSENSE_EQUAL},
{ "=<", RPMSENSE_LESS | RPMSENSE_EQUAL},
{ "<", RPMSENSE_LESS},
{ "==", RPMSENSE_EQUAL},
{ "=", RPMSENSE_EQUAL},
{ ">=", RPMSENSE_GREATER | RPMSENSE_EQUAL},
{ "=>", RPMSENSE_GREATER | RPMSENSE_EQUAL},
{ ">", RPMSENSE_GREATER},
{ NULL, 0 },
};
#define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
#define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
int parseRCPOT(Spec spec, Package pkg, const char *field, rpmTag tagN,
int index, rpmsenseFlags tagflags)
{
const char *r, *re, *v, *ve;
char * N, * EVR;
rpmsenseFlags Flags;
Header h;
switch (tagN) {
case RPMTAG_PROVIDEFLAGS:
tagflags |= RPMSENSE_PROVIDES;
h = pkg->header;
break;
case RPMTAG_OBSOLETEFLAGS:
tagflags |= RPMSENSE_OBSOLETES;
h = pkg->header;
break;
case RPMTAG_CONFLICTFLAGS:
tagflags |= RPMSENSE_CONFLICTS;
h = pkg->header;
break;
case RPMTAG_BUILDCONFLICTS:
tagflags |= RPMSENSE_CONFLICTS;
h = spec->buildRestrictions;
break;
case RPMTAG_PREREQ:
tagflags |= RPMSENSE_PREREQ;
h = pkg->header;
break;
case RPMTAG_BUILDPREREQ:
tagflags |= RPMSENSE_PREREQ;
h = spec->buildRestrictions;
break;
case RPMTAG_TRIGGERIN:
tagflags |= RPMSENSE_TRIGGERIN;
h = pkg->header;
break;
case RPMTAG_TRIGGERPOSTUN:
tagflags |= RPMSENSE_TRIGGERPOSTUN;
h = pkg->header;
break;
case RPMTAG_TRIGGERUN:
tagflags |= RPMSENSE_TRIGGERUN;
h = pkg->header;
break;
case RPMTAG_BUILDREQUIRES:
tagflags |= RPMSENSE_ANY;
h = spec->buildRestrictions;
break;
default:
case RPMTAG_REQUIREFLAGS:
tagflags |= RPMSENSE_ANY;
h = pkg->header;
break;
}
for (r = field; *r != '\0'; r = re) {
SKIPWHITE(r);
if (*r == '\0')
break;
Flags = (tagflags & ~RPMSENSE_SENSEMASK);
/* Tokens must begin with alphanumeric, _, or / */
if (!(xisalnum(r[0]) || r[0] == '_' || r[0] == '/')) {
rpmError(RPMERR_BADSPEC,
_("line %d: Dependency tokens must begin with alpha-numeric, '_' or '/': %s\n"),
spec->lineNum, spec->line);
return RPMERR_BADSPEC;
}
re = r;
SKIPNONWHITE(re);
N = xmalloc((re-r) + 1);
strncpy(N, r, (re-r));
N[re-r] = '\0';
/* Parse EVR */
v = re;
SKIPWHITE(v);
ve = v;
SKIPNONWHITE(ve);
re = v; /* ==> next token (if no EVR found) starts here */
/* Check for possible logical operator */
if (ve > v) {
struct ReqComp *rc;
for (rc = ReqComparisons; rc->token != NULL; rc++) {
if ((ve-v) != strlen(rc->token) || strncmp(v, rc->token, (ve-v)))
continue;
if (r[0] == '/') {
rpmError(RPMERR_BADSPEC,
_("line %d: Versioned file name not permitted: %s\n"),
spec->lineNum, spec->line);
return RPMERR_BADSPEC;
}
switch(tagN) {
case RPMTAG_BUILDPREREQ:
case RPMTAG_PREREQ:
case RPMTAG_PROVIDEFLAGS:
case RPMTAG_OBSOLETEFLAGS:
/* Add prereq on rpmlib that has versioned dependencies. */
if (!rpmExpandNumeric("%{?_noVersionedDependencies}"))
(void) rpmlibNeedsFeature(h, "VersionedDependencies", "3.0.3-1");
break;
default:
break;
}
Flags |= rc->sense;
/* now parse EVR */
v = ve;
SKIPWHITE(v);
ve = v;
SKIPNONWHITE(ve);
break;
}
}
if (Flags & RPMSENSE_SENSEMASK) {
if (*v == '\0' || ve == v) {
rpmError(RPMERR_BADSPEC, _("line %d: Version required: %s\n"),
spec->lineNum, spec->line);
return RPMERR_BADSPEC;
}
EVR = xmalloc((ve-v) + 1);
strncpy(EVR, v, (ve-v));
EVR[ve-v] = '\0';
re = ve; /* ==> next token after EVR string starts here */
} else
EVR = NULL;
(void) addReqProv(spec, h, tagN, N, EVR, Flags, index);
N = _free(N);
EVR = _free(EVR);
}
return 0;
}
|