1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#include "rpmbuild.h"
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
static struct ReqComp {
|
|
|
|
char *token;
|
|
|
|
int sense;
|
|
|
|
} ReqComparisons[] = {
|
|
|
|
{ "<=", RPMSENSE_LESS | RPMSENSE_EQUAL},
|
|
|
|
{ "=<", RPMSENSE_LESS | RPMSENSE_EQUAL},
|
|
|
|
{ "<", RPMSENSE_LESS},
|
|
|
|
|
|
|
|
{ "=", RPMSENSE_EQUAL},
|
|
|
|
|
|
|
|
{ ">=", RPMSENSE_GREATER | RPMSENSE_EQUAL},
|
|
|
|
{ "=>", RPMSENSE_GREATER | RPMSENSE_EQUAL},
|
|
|
|
{ ">", RPMSENSE_GREATER},
|
1999-07-14 05:37:57 +08:00
|
|
|
|
|
|
|
#if defined(RPMSENSE_SERIAL)
|
|
|
|
{ "<=S", RPMSENSE_LESS | RPMSENSE_EQUAL | RPMSENSE_SERIAL},
|
|
|
|
{ "=<S", RPMSENSE_LESS | RPMSENSE_EQUAL | RPMSENSE_SERIAL},
|
|
|
|
{ "<S", RPMSENSE_LESS | RPMSENSE_SERIAL},
|
|
|
|
|
|
|
|
{ "=S", RPMSENSE_EQUAL | RPMSENSE_SERIAL},
|
|
|
|
|
|
|
|
{ ">=S", RPMSENSE_GREATER | RPMSENSE_EQUAL | RPMSENSE_SERIAL},
|
|
|
|
{ "=>S", RPMSENSE_GREATER | RPMSENSE_EQUAL | RPMSENSE_SERIAL},
|
1998-01-13 05:31:29 +08:00
|
|
|
{ ">S", RPMSENSE_GREATER | RPMSENSE_SERIAL},
|
1999-07-14 05:37:57 +08:00
|
|
|
#endif /* RPMSENSE_SERIAL */
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
{ NULL, 0 },
|
|
|
|
};
|
|
|
|
|
1999-05-26 12:05:33 +08:00
|
|
|
#define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;}
|
|
|
|
#define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;}
|
|
|
|
|
1999-06-17 23:44:47 +08:00
|
|
|
int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index)
|
1998-01-13 05:31:29 +08:00
|
|
|
{
|
1999-05-26 12:05:33 +08:00
|
|
|
const char *r, *re, *v, *ve;
|
|
|
|
char *req, *version;
|
|
|
|
Header h;
|
1999-06-20 02:09:49 +08:00
|
|
|
int tagflags, flags;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-06-17 23:44:47 +08:00
|
|
|
switch (tag) {
|
|
|
|
case RPMTAG_PROVIDES:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_PROVIDES;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = pkg->header;
|
|
|
|
break;
|
|
|
|
case RPMTAG_OBSOLETES:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_OBSOLETES;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = pkg->header;
|
|
|
|
break;
|
|
|
|
case RPMTAG_CONFLICTFLAGS:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_CONFLICTS;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = pkg->header;
|
|
|
|
break;
|
|
|
|
case RPMTAG_BUILDCONFLICTS:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_CONFLICTS;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = spec->buildRestrictions;
|
|
|
|
break;
|
|
|
|
case RPMTAG_PREREQ:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_PREREQ;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = pkg->header;
|
|
|
|
break;
|
|
|
|
case RPMTAG_BUILDPREREQ:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_PREREQ;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = spec->buildRestrictions;
|
|
|
|
break;
|
|
|
|
case RPMTAG_TRIGGERIN:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_TRIGGERIN;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = pkg->header;
|
|
|
|
break;
|
|
|
|
case RPMTAG_TRIGGERPOSTUN:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_TRIGGERPOSTUN;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = pkg->header;
|
|
|
|
break;
|
|
|
|
case RPMTAG_TRIGGERUN:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_TRIGGERUN;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = pkg->header;
|
|
|
|
break;
|
|
|
|
case RPMTAG_BUILDREQUIRES:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_ANY;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = spec->buildRestrictions;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case RPMTAG_REQUIREFLAGS:
|
1999-06-20 02:09:49 +08:00
|
|
|
tagflags = RPMSENSE_ANY;
|
1999-06-17 23:44:47 +08:00
|
|
|
h = pkg->header;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-05-26 12:05:33 +08:00
|
|
|
for (r = field; *r; r = re) {
|
|
|
|
SKIPWHITE(r);
|
|
|
|
if (*r == '\0')
|
|
|
|
break;
|
1999-06-17 23:44:47 +08:00
|
|
|
|
1999-06-20 02:09:49 +08:00
|
|
|
flags = tagflags;
|
|
|
|
|
1999-06-17 23:44:47 +08:00
|
|
|
/* Tokens must begin with alphanumeric, _, or / */
|
|
|
|
if (!(isalnum(r[0]) || r[0] == '_' || r[0] == '/')) {
|
|
|
|
rpmError(RPMERR_BADSPEC,
|
|
|
|
_("line %d: Dependency tokens must begin with alpha-numeric, '_' or '/': %s"),
|
|
|
|
spec->lineNum, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't permit file names as args for certain tags */
|
1999-05-26 12:05:33 +08:00
|
|
|
switch (tag) {
|
1999-06-17 23:44:47 +08:00
|
|
|
case RPMTAG_OBSOLETES:
|
1999-05-26 12:05:33 +08:00
|
|
|
case RPMTAG_CONFLICTFLAGS:
|
|
|
|
case RPMTAG_BUILDCONFLICTS:
|
|
|
|
if (r[0] == '/') {
|
|
|
|
rpmError(RPMERR_BADSPEC,_("line %d: File name not permitted: %s"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
1999-05-26 12:05:33 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
1999-05-26 12:05:33 +08:00
|
|
|
re = r;
|
|
|
|
SKIPNONWHITE(re);
|
|
|
|
req = malloc((re-r) + 1);
|
|
|
|
strncpy(req, r, (re-r));
|
|
|
|
req[re-r] = '\0';
|
|
|
|
|
|
|
|
/* Parse version */
|
|
|
|
v = re;
|
|
|
|
SKIPWHITE(v);
|
|
|
|
ve = v;
|
|
|
|
SKIPNONWHITE(ve);
|
|
|
|
|
1999-06-17 23:44:47 +08:00
|
|
|
re = v; /* ==> next token (if no version found) starts here */
|
|
|
|
|
1999-05-26 12:05:33 +08:00
|
|
|
/* Check for possible logical operator */
|
|
|
|
if (ve > v) {
|
|
|
|
struct ReqComp *rc;
|
|
|
|
for (rc = ReqComparisons; rc->token != NULL; rc++) {
|
1999-06-18 22:33:16 +08:00
|
|
|
if ((ve-v) != strlen(rc->token) || strncmp(v, rc->token, (ve-v)))
|
1999-05-26 12:05:33 +08:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (r[0] == '/') {
|
|
|
|
rpmError(RPMERR_BADSPEC,
|
|
|
|
_("line %d: Versioned file name not permitted: %s"),
|
|
|
|
spec->lineNum, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1999-06-18 22:33:16 +08:00
|
|
|
|
1999-05-26 12:05:33 +08:00
|
|
|
switch(tag) {
|
1999-06-17 23:44:47 +08:00
|
|
|
case RPMTAG_PROVIDES:
|
|
|
|
case RPMTAG_OBSOLETES:
|
1999-05-26 12:05:33 +08:00
|
|
|
case RPMTAG_BUILDPREREQ:
|
|
|
|
case RPMTAG_PREREQ:
|
|
|
|
rpmError(RPMERR_BADSPEC,
|
|
|
|
_("line %d: Version not permitted: %s"),
|
|
|
|
spec->lineNum, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1999-05-26 12:05:33 +08:00
|
|
|
flags |= rc->sense;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-05-26 12:05:33 +08:00
|
|
|
/* now parse version */
|
|
|
|
v = ve;
|
|
|
|
SKIPWHITE(v);
|
|
|
|
ve = v;
|
|
|
|
SKIPNONWHITE(ve);
|
|
|
|
break;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
1999-05-26 12:05:33 +08:00
|
|
|
if (flags & RPMSENSE_SENSEMASK) {
|
|
|
|
if (*v == '\0' || ve == v) {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Version required: %s"),
|
|
|
|
spec->lineNum, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
version = malloc((ve-v) + 1);
|
|
|
|
strncpy(version, v, (ve-v));
|
|
|
|
version[ve-v] = '\0';
|
1999-06-17 23:44:47 +08:00
|
|
|
re = ve; /* ==> next token after version string starts here */
|
1999-05-26 12:05:33 +08:00
|
|
|
} else
|
|
|
|
version = NULL;
|
|
|
|
|
|
|
|
addReqProv(spec, h, flags, req, version, index);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-05-26 12:05:33 +08:00
|
|
|
if (req) free(req);
|
|
|
|
if (version) free(version);
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|