2 * \file build/parseReqs.c
3 * Parse dependency tag from spec file or from auto-dependency generator.
8 #include <rpm/rpmtag.h>
9 #include <rpm/rpmbuild.h>
10 #include <rpm/rpmlog.h>
15 static struct ReqComp {
18 } ReqComparisons[] = {
19 { "<=", RPMSENSE_LESS | RPMSENSE_EQUAL},
20 { "=<", RPMSENSE_LESS | RPMSENSE_EQUAL},
21 { "<", RPMSENSE_LESS},
23 { "==", RPMSENSE_EQUAL},
24 { "=", RPMSENSE_EQUAL},
26 { ">=", RPMSENSE_GREATER | RPMSENSE_EQUAL},
27 { "=>", RPMSENSE_GREATER | RPMSENSE_EQUAL},
28 { ">", RPMSENSE_GREATER},
33 #define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
34 #define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
36 rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTag tagN,
37 int index, rpmsenseFlags tagflags)
39 const char *r, *re, *v, *ve;
45 case RPMTAG_PROVIDEFLAGS:
46 tagflags |= RPMSENSE_PROVIDES;
49 case RPMTAG_OBSOLETEFLAGS:
50 tagflags |= RPMSENSE_OBSOLETES;
53 case RPMTAG_CONFLICTFLAGS:
54 tagflags |= RPMSENSE_CONFLICTS;
57 case RPMTAG_BUILDCONFLICTS:
58 tagflags |= RPMSENSE_CONFLICTS;
59 h = spec->buildRestrictions;
62 tagflags |= RPMSENSE_PREREQ;
65 case RPMTAG_BUILDPREREQ:
66 tagflags |= RPMSENSE_PREREQ;
67 h = spec->buildRestrictions;
69 case RPMTAG_TRIGGERPREIN:
70 tagflags |= RPMSENSE_TRIGGERPREIN;
73 case RPMTAG_TRIGGERIN:
74 tagflags |= RPMSENSE_TRIGGERIN;
77 case RPMTAG_TRIGGERPOSTUN:
78 tagflags |= RPMSENSE_TRIGGERPOSTUN;
81 case RPMTAG_TRIGGERUN:
82 tagflags |= RPMSENSE_TRIGGERUN;
85 case RPMTAG_BUILDREQUIRES:
86 tagflags |= RPMSENSE_ANY;
87 h = spec->buildRestrictions;
90 case RPMTAG_REQUIREFLAGS:
91 tagflags |= RPMSENSE_ANY;
96 for (r = field; *r != '\0'; r = re) {
101 Flags = (tagflags & ~RPMSENSE_SENSEMASK);
103 /* Tokens must begin with alphanumeric, _, or / */
104 if (!(xisalnum(r[0]) || r[0] == '_' || r[0] == '/')) {
106 _("line %d: Dependency tokens must begin with alpha-numeric, '_' or '/': %s\n"),
107 spec->lineNum, spec->line);
113 N = xmalloc((re-r) + 1);
114 strncpy(N, r, (re-r));
123 re = v; /* ==> next token (if no EVR found) starts here */
125 /* Check for possible logical operator */
128 for (rc = ReqComparisons; rc->token != NULL; rc++) {
129 if ((ve-v) != strlen(rc->token) || strncmp(v, rc->token, (ve-v)))
134 _("line %d: Versioned file name not permitted: %s\n"),
135 spec->lineNum, spec->line);
140 case RPMTAG_BUILDPREREQ:
142 case RPMTAG_PROVIDEFLAGS:
143 case RPMTAG_OBSOLETEFLAGS:
144 /* Add prereq on rpmlib that has versioned dependencies. */
145 if (!rpmExpandNumeric("%{?_noVersionedDependencies}"))
146 (void) rpmlibNeedsFeature(h, "VersionedDependencies", "3.0.3-1");
162 if (Flags & RPMSENSE_SENSEMASK) {
163 if (*v == '\0' || ve == v) {
164 rpmlog(RPMLOG_ERR, _("line %d: Version required: %s\n"),
165 spec->lineNum, spec->line);
168 EVR = xmalloc((ve-v) + 1);
169 strncpy(EVR, v, (ve-v));
171 re = ve; /* ==> next token after EVR string starts here */
175 (void) addReqProv(spec, h, tagN, N, EVR, Flags, index);