00001
00006 #include "system.h"
00007
00008 #define _RPMEVR_INTERNAL
00009 #include "rpmbuild.h"
00010 #include "debug.h"
00011
00012 #define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
00013 #define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
00014
00015 int parseRCPOT(Spec spec, Package pkg, const char *field, rpmTag tagN,
00016 int index, rpmsenseFlags tagflags)
00017 {
00018 const char *r, *re, *v, *ve;
00019 char * N, * EVR;
00020 rpmsenseFlags Flags;
00021 Header h;
00022
00023 switch (tagN) {
00024 case RPMTAG_PROVIDEFLAGS:
00025 tagflags |= RPMSENSE_PROVIDES;
00026 h = pkg->header;
00027 break;
00028 case RPMTAG_OBSOLETEFLAGS:
00029 tagflags |= RPMSENSE_OBSOLETES;
00030 h = pkg->header;
00031 break;
00032 case RPMTAG_CONFLICTFLAGS:
00033 tagflags |= RPMSENSE_CONFLICTS;
00034 h = pkg->header;
00035 break;
00036 case RPMTAG_BUILDCONFLICTS:
00037 tagflags |= RPMSENSE_CONFLICTS;
00038 h = spec->sourceHeader;
00039 break;
00040 case RPMTAG_PREREQ:
00041 tagflags |= RPMSENSE_ANY;
00042 h = pkg->header;
00043 break;
00044 case RPMTAG_TRIGGERPREIN:
00045 tagflags |= RPMSENSE_TRIGGERPREIN;
00046 h = pkg->header;
00047 break;
00048 case RPMTAG_TRIGGERIN:
00049 tagflags |= RPMSENSE_TRIGGERIN;
00050 h = pkg->header;
00051 break;
00052 case RPMTAG_TRIGGERPOSTUN:
00053 tagflags |= RPMSENSE_TRIGGERPOSTUN;
00054 h = pkg->header;
00055 break;
00056 case RPMTAG_TRIGGERUN:
00057 tagflags |= RPMSENSE_TRIGGERUN;
00058 h = pkg->header;
00059 break;
00060 case RPMTAG_BUILDSUGGESTS:
00061 case RPMTAG_BUILDENHANCES:
00062 tagflags |= RPMSENSE_MISSINGOK;
00063 h = spec->sourceHeader;
00064 break;
00065 case RPMTAG_BUILDPREREQ:
00066 case RPMTAG_BUILDREQUIRES:
00067 tagflags |= RPMSENSE_ANY;
00068 h = spec->sourceHeader;
00069 break;
00070 case RPMTAG_BUILDPROVIDES:
00071 tagflags |= RPMSENSE_PROVIDES;
00072 h = spec->sourceHeader;
00073 break;
00074 case RPMTAG_BUILDOBSOLETES:
00075 tagflags |= RPMSENSE_OBSOLETES;
00076 h = spec->sourceHeader;
00077 break;
00078 default:
00079 case RPMTAG_REQUIREFLAGS:
00080 tagflags |= RPMSENSE_ANY;
00081 h = pkg->header;
00082 break;
00083 }
00084
00085
00086 for (r = field; *r != '\0'; r = re) {
00087 size_t nr;
00088 SKIPWHITE(r);
00089 if (*r == '\0')
00090 break;
00091
00092 Flags = (tagflags & ~RPMSENSE_SENSEMASK);
00093
00094
00095 nr = strlen(r);
00096 if (!(xisalnum(r[0]) || r[0] == '_' || r[0] == '/'
00097 || (nr > 2 && r[0] == '!')
00098 || (nr > 3 && r[0] == '%' && r[1] == '{' && r[nr-1] == '}')))
00099 {
00100 rpmError(RPMERR_BADSPEC,
00101 _("line %d: Dependency \"%s\" must begin with alpha-numeric, '_' or '/': %s\n"),
00102 spec->lineNum, spec->line, r);
00103 return RPMERR_BADSPEC;
00104 }
00105
00106 re = r;
00107 SKIPNONWHITE(re);
00108 N = xmalloc((re-r) + 1);
00109 strncpy(N, r, (re-r));
00110 N[re-r] = '\0';
00111
00112
00113 v = re;
00114 SKIPWHITE(v);
00115 ve = v;
00116 SKIPNONWHITE(ve);
00117
00118 re = v;
00119
00120
00121 if (ve > v) {
00122 rpmsenseFlags F = rpmEVRflags(v, &ve);
00123 if (F && r[0] == '/') {
00124 rpmError(RPMERR_BADSPEC,
00125 _("line %d: Versioned file name not permitted: %s\n"),
00126 spec->lineNum, spec->line);
00127 return RPMERR_BADSPEC;
00128 }
00129 if (F) {
00130
00131 v = ve;
00132 SKIPWHITE(v);
00133 ve = v;
00134 SKIPNONWHITE(ve);
00135 }
00136 Flags &= ~RPMSENSE_SENSEMASK;
00137 Flags |= F;
00138 }
00139
00140
00141 if (Flags & RPMSENSE_SENSEMASK) {
00142 if (*v == '\0' || ve == v) {
00143 rpmError(RPMERR_BADSPEC, _("line %d: Version required: %s\n"),
00144 spec->lineNum, spec->line);
00145 return RPMERR_BADSPEC;
00146 }
00147 EVR = xmalloc((ve-v) + 1);
00148 strncpy(EVR, v, (ve-v));
00149 EVR[ve-v] = '\0';
00150 re = ve;
00151 } else
00152 EVR = NULL;
00153
00154
00155 (void) addReqProv(spec, h, tagN, N, EVR, Flags, index);
00156
00157 N = _free(N);
00158 EVR = _free(EVR);
00159
00160 }
00161
00162
00163 return 0;
00164 }