- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# build/parseReqs.c

Go to the documentation of this file.

    00001
    00006 #include "system.h"
    00007
    00008 #include <rpmio.h>
    00009 #define _RPMEVR_INTERNAL
    00010 #include "rpmbuild.h"
    00011 #include "debug.h"
    00012
    00013 #define SKIPWHITE(_x)   {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
    00014 #define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
    00015
    00016 rpmRC parseRCPOT(Spec spec, Package pkg, const char *field, rpmTag tagN,
    00017                uint32_t index, rpmsenseFlags tagflags)
    00018 {
    00019     const char *r, *re, *v, *ve;
    00020     char * N, * EVR;
    00021     rpmsenseFlags Flags;
    00022     Header h;
    00023
    00024     switch (tagN) {
    00025     case RPMTAG_PROVIDEFLAGS:
    00026         tagflags |= RPMSENSE_PROVIDES;
    00027         h = pkg->header;
    00028         break;
    00029     case RPMTAG_OBSOLETEFLAGS:
    00030         tagflags |= RPMSENSE_OBSOLETES;
    00031         h = pkg->header;
    00032         break;
    00033     case RPMTAG_CONFLICTFLAGS:
    00034         tagflags |= RPMSENSE_CONFLICTS;
    00035         h = pkg->header;
    00036         break;
    00037     case RPMTAG_BUILDCONFLICTS:
    00038         tagflags |= RPMSENSE_CONFLICTS;
    00039         h = spec->sourceHeader;
    00040         break;
    00041     case RPMTAG_PREREQ:
    00042         tagflags |= RPMSENSE_ANY;
    00043         h = pkg->header;
    00044         break;
    00045     case RPMTAG_TRIGGERPREIN:
    00046         tagflags |= RPMSENSE_TRIGGERPREIN;
    00047         h = pkg->header;
    00048         break;
    00049     case RPMTAG_TRIGGERIN:
    00050         tagflags |= RPMSENSE_TRIGGERIN;
    00051         h = pkg->header;
    00052         break;
    00053     case RPMTAG_TRIGGERPOSTUN:
    00054         tagflags |= RPMSENSE_TRIGGERPOSTUN;
    00055         h = pkg->header;
    00056         break;
    00057     case RPMTAG_TRIGGERUN:
    00058         tagflags |= RPMSENSE_TRIGGERUN;
    00059         h = pkg->header;
    00060         break;
    00061     case RPMTAG_BUILDSUGGESTS:
    00062     case RPMTAG_BUILDENHANCES:
    00063         tagflags |= RPMSENSE_MISSINGOK;
    00064         h = spec->sourceHeader;
    00065         break;
    00066     case RPMTAG_BUILDPREREQ:
    00067     case RPMTAG_BUILDREQUIRES:
    00068         tagflags |= RPMSENSE_ANY;
    00069         h = spec->sourceHeader;
    00070         break;
    00071     case RPMTAG_BUILDPROVIDES:
    00072         tagflags |= RPMSENSE_PROVIDES;
    00073         h = spec->sourceHeader;
    00074         break;
    00075     case RPMTAG_BUILDOBSOLETES:
    00076         tagflags |= RPMSENSE_OBSOLETES;
    00077         h = spec->sourceHeader;
    00078         break;
    00079     default:
    00080     case RPMTAG_REQUIREFLAGS:
    00081         tagflags |= RPMSENSE_ANY;
    00082         h = pkg->header;
    00083         break;
    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         /* Tokens must begin with alphanumeric, _, or / */
    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             rpmlog(RPMLOG_ERR,
    00101                      _("line %d: Dependency \"%s\" must begin with alpha-numeric, '_' or '/': %s\n"),
    00102                      spec->lineNum, spec->line, r);
    00103             return RPMRC_FAIL;
    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         /* Parse EVR */
    00113         v = re;
    00114         SKIPWHITE(v);
    00115         ve = v;
    00116         SKIPNONWHITE(ve);
    00117
    00118         re = v; /* ==> next token (if no EVR found) starts here */
    00119
    00120         /* Check for possible logical operator */
    00121         if (ve > v) {
    00122 /*@-mods@*/
    00123             rpmsenseFlags F = rpmEVRflags(v, &ve);
    00124 /*@=mods@*/
    00125             if (F && r[0] == '/') {
    00126                 rpmlog(RPMLOG_ERR,
    00127                          _("line %d: Versioned file name not permitted: %s\n"),
    00128                          spec->lineNum, spec->line);
    00129                 return RPMRC_FAIL;
    00130             }
    00131             if (F) {
    00132                 /* now parse EVR */
    00133                 v = ve;
    00134                 SKIPWHITE(v);
    00135                 ve = v;
    00136                 SKIPNONWHITE(ve);
    00137             }
    00138             Flags &= ~RPMSENSE_SENSEMASK;
    00139             Flags |= F;
    00140         }
    00141
    00142         if (Flags & RPMSENSE_SENSEMASK) {
    00143             if (*v == '\0' || ve == v) {
    00144                 rpmlog(RPMLOG_ERR, _("line %d: Version required: %s\n"),
    00145                         spec->lineNum, spec->line);
    00146                 return RPMRC_FAIL;
    00147             }
    00148             EVR = xmalloc((ve-v) + 1);
    00149             strncpy(EVR, v, (ve-v));
    00150             EVR[ve-v] = '\0';
    00151             re = ve;    /* ==> next token after EVR string starts here */
    00152         } else
    00153             EVR = NULL;
    00154
    00155         (void) addReqProv(spec, h, tagN, N, EVR, Flags, index);
    00156
    00157         N = _free(N);
    00158         EVR = _free(EVR);
    00159
    00160     }
    00161
    00162     return RPMRC_OK;
    00163 }