2 * \file build/parseReqs.c
3 * Parse dependency tag from spec file or from auto-dependency generator.
8 #include <rpm/rpmbuild.h>
9 #include <rpm/rpmlog.h>
14 static struct ReqComp {
17 } ReqComparisons[] = {
18 { "<=", RPMSENSE_LESS | RPMSENSE_EQUAL},
19 { "=<", RPMSENSE_LESS | RPMSENSE_EQUAL},
20 { "<", RPMSENSE_LESS},
22 { "==", RPMSENSE_EQUAL},
23 { "=", RPMSENSE_EQUAL},
25 { ">=", RPMSENSE_GREATER | RPMSENSE_EQUAL},
26 { "=>", RPMSENSE_GREATER | RPMSENSE_EQUAL},
27 { ">", RPMSENSE_GREATER},
32 #define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
33 #define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
35 rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpm_tag_t tagN,
36 int index, rpmsenseFlags tagflags)
38 const char *r, *re, *v, *ve;
44 case RPMTAG_PROVIDEFLAGS:
45 tagflags |= RPMSENSE_PROVIDES;
48 case RPMTAG_OBSOLETEFLAGS:
49 tagflags |= RPMSENSE_OBSOLETES;
52 case RPMTAG_CONFLICTFLAGS:
53 tagflags |= RPMSENSE_CONFLICTS;
56 case RPMTAG_BUILDCONFLICTS:
57 tagflags |= RPMSENSE_CONFLICTS;
58 h = spec->buildRestrictions;
61 tagflags |= RPMSENSE_PREREQ;
64 case RPMTAG_BUILDPREREQ:
65 tagflags |= RPMSENSE_PREREQ;
66 h = spec->buildRestrictions;
68 case RPMTAG_TRIGGERPREIN:
69 tagflags |= RPMSENSE_TRIGGERPREIN;
72 case RPMTAG_TRIGGERIN:
73 tagflags |= RPMSENSE_TRIGGERIN;
76 case RPMTAG_TRIGGERPOSTUN:
77 tagflags |= RPMSENSE_TRIGGERPOSTUN;
80 case RPMTAG_TRIGGERUN:
81 tagflags |= RPMSENSE_TRIGGERUN;
84 case RPMTAG_BUILDREQUIRES:
85 tagflags |= RPMSENSE_ANY;
86 h = spec->buildRestrictions;
89 case RPMTAG_REQUIREFLAGS:
90 tagflags |= RPMSENSE_ANY;
95 for (r = field; *r != '\0'; r = re) {
100 Flags = (tagflags & ~RPMSENSE_SENSEMASK);
102 /* Tokens must begin with alphanumeric, _, or / */
103 if (!(xisalnum(r[0]) || r[0] == '_' || r[0] == '/')) {
105 _("line %d: Dependency tokens must begin with alpha-numeric, '_' or '/': %s\n"),
106 spec->lineNum, spec->line);
112 N = xmalloc((re-r) + 1);
113 strncpy(N, r, (re-r));
122 re = v; /* ==> next token (if no EVR found) starts here */
124 /* Check for possible logical operator */
127 for (rc = ReqComparisons; rc->token != NULL; rc++) {
128 if ((ve-v) != strlen(rc->token) || strncmp(v, rc->token, (ve-v)))
133 _("line %d: Versioned file name not permitted: %s\n"),
134 spec->lineNum, spec->line);
139 case RPMTAG_BUILDPREREQ:
141 case RPMTAG_PROVIDEFLAGS:
142 case RPMTAG_OBSOLETEFLAGS:
143 /* Add prereq on rpmlib that has versioned dependencies. */
144 if (!rpmExpandNumeric("%{?_noVersionedDependencies}"))
145 (void) rpmlibNeedsFeature(h, "VersionedDependencies", "3.0.3-1");
161 if (Flags & RPMSENSE_SENSEMASK) {
162 if (*v == '\0' || ve == v) {
163 rpmlog(RPMLOG_ERR, _("line %d: Version required: %s\n"),
164 spec->lineNum, spec->line);
167 EVR = xmalloc((ve-v) + 1);
168 strncpy(EVR, v, (ve-v));
170 re = ve; /* ==> next token after EVR string starts here */
174 (void) addReqProv(spec, h, tagN, N, EVR, Flags, index);