add BuildConflicts: and BuildRequires: in spec file and src rpm.
authorjbj <devnull@localhost>
Wed, 26 May 1999 04:05:33 +0000 (04:05 +0000)
committerjbj <devnull@localhost>
Wed, 26 May 1999 04:05:33 +0000 (04:05 +0000)
CVS patchset: 3079
CVS date: 1999/05/26 04:05:33

CHANGES
build.c
build/parsePreamble.c
build/parseReqs.c
build/rpmbuild.h
lib/rpmlib.h
po/rpm.pot

diff --git a/CHANGES b/CHANGES
index 58bcc6d..73b0238 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,7 @@
 3.0.1 -> 3.0.2
        - eliminate armv4 entries from rpmrc (Andrew E. Mileski).
        - permit multiple "Provides: " lines in rpmrc (#2999).
+       - add BuildConflicts: and BuildRequires: in spec file and src rpm.
 
 3.0 -> 3.0.1
        - fix: %verifyscript resurrected (Shing-Gene Yung).
diff --git a/build.c b/build.c
index 6571606..0806dfe 100644 (file)
--- a/build.c
+++ b/build.c
@@ -31,7 +31,7 @@ static int checkSpec(Header h)
 
     rc = rpmdepCheck(ts, &conflicts, &numConflicts);
     if (rc == 0 && conflicts) {
-       rpmMessage(RPMMESS_ERROR, _("failed build prerequisites:\n"));
+       rpmMessage(RPMMESS_ERROR, _("failed build dependencies:\n"));
        printDepProblems(stderr, conflicts, numConflicts);
        rpmdepFreeConflicts(conflicts, numConflicts);
        rc = 1;
index 35dc1b9..dd199a3 100644 (file)
@@ -502,6 +502,8 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, char *macro,
            return rc;
        }
        break;
+      case RPMTAG_BUILDREQUIRES:
+      case RPMTAG_BUILDCONFLICTS:
       case RPMTAG_BUILDPREREQ:
       case RPMTAG_REQUIREFLAGS:
       case RPMTAG_CONFLICTFLAGS:
@@ -587,7 +589,9 @@ static struct PreambleRec {
     {RPMTAG_BUILDROOT,         0, 0, "buildroot"},
     {RPMTAG_BUILDARCHS,                0, 0, "buildarchitectures"},
     {RPMTAG_BUILDARCHS,                0, 0, "buildarch"},
+    {RPMTAG_BUILDCONFLICTS,    0, 0, "buildconflicts"},
     {RPMTAG_BUILDPREREQ,       0, 0, "buildprereq"},
+    {RPMTAG_BUILDREQUIRES,     0, 0, "buildrequires"},
     {RPMTAG_AUTOREQPROV,       0, 0, "autoreqprov"},
     {RPMTAG_AUTOREQ,           0, 0, "autoreq"},
     {RPMTAG_AUTOPROV,          0, 0, "autoprov"},
index 5cab714..6c00b2b 100644 (file)
@@ -25,119 +25,176 @@ static struct ReqComp {
     { NULL, 0 },
 };
 
-int parseRequiresConflicts(Spec spec, Package pkg, char *field,
+#define        SKIPWHITE(_x)   {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;}
+#define        SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;}
+
+int parseRequiresConflicts(Spec spec, Package pkg, const char *field,
                           int tag, int index)
 {
-    char buf[BUFSIZ], *bufp, *version, *name;
+    const char *r, *re, *v, *ve;
+    char *req, *version;
+    Header h;
     int flags;
-    char *req = NULL;
-    struct ReqComp *rc;
-
-    strcpy(buf, field);
-    bufp = buf;
 
-    while (req || (req = strtok(bufp, " ,\t\n"))) {
-       bufp = NULL;
+    for (r = field; *r; r = re) {
+       SKIPWHITE(r);
+       if (*r == '\0')
+           break;
        
-       if (tag == RPMTAG_CONFLICTFLAGS) {
-           if (req[0] == '/') {
-               rpmError(RPMERR_BADSPEC,
-                        _("line %d: No file names in Conflicts: %s"),
+       switch (tag) {
+       case RPMTAG_CONFLICTFLAGS:
+           if (r[0] == '/') {
+               rpmError(RPMERR_BADSPEC,_("line %d: File name not permitted: %s"),
+                        spec->lineNum, spec->line);
+               return RPMERR_BADSPEC;
+           }
+           flags = RPMSENSE_CONFLICTS;
+           h = pkg->header;
+           break;
+       case RPMTAG_BUILDCONFLICTS:
+           if (r[0] == '/') {
+               rpmError(RPMERR_BADSPEC,_("line %d: File name not permitted: %s"),
                         spec->lineNum, spec->line);
                return RPMERR_BADSPEC;
            }
            flags = RPMSENSE_CONFLICTS;
-           name = "Conflicts";
-       } else if (tag == RPMTAG_PREREQ) {
+           h = spec->buildRestrictions;
+           break;
+       case RPMTAG_PREREQ:
            flags = RPMSENSE_PREREQ;
-           name = "PreReq";
-       } else if (tag == RPMTAG_BUILDPREREQ) {
+           h = pkg->header;
+           break;
+       case RPMTAG_BUILDPREREQ:
            flags = RPMSENSE_PREREQ;
-           name = "BuildPreReq";
-       } else if (tag == RPMTAG_TRIGGERIN) {
+           h = spec->buildRestrictions;
+           break;
+       case RPMTAG_TRIGGERIN:
            flags = RPMSENSE_TRIGGERIN;
-           name = "%triggerin";
-       } else if (tag == RPMTAG_TRIGGERPOSTUN) {
+           h = pkg->header;
+           break;
+       case RPMTAG_TRIGGERPOSTUN:
            flags = RPMSENSE_TRIGGERPOSTUN;
-           name = "%triggerpostun";
-       } else if (tag == RPMTAG_TRIGGERUN) {
+           h = pkg->header;
+           break;
+       case RPMTAG_TRIGGERUN:
            flags = RPMSENSE_TRIGGERUN;
-           name = "%triggerun";
-       } else {
+           h = pkg->header;
+           break;
+       case RPMTAG_BUILDREQUIRES:
            flags = RPMSENSE_ANY;
-           name = "Requires";
+           h = spec->buildRestrictions;
+           break;
+       default:
+       case RPMTAG_REQUIREFLAGS:
+           flags = RPMSENSE_ANY;
+           h = pkg->header;
+           break;
        }
 
-       if ((version = strtok(NULL, " ,\t\n"))) {
-           rc = ReqComparisons;
-           while (rc->token && strcmp(version, rc->token)) {
-               rc++;
+       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);
+
+       /* Check for possible logical operator */
+       if (ve > v) {
+         struct ReqComp *rc;
+         for (rc = ReqComparisons; rc->token != NULL; rc++) {
+           if (strncmp(v, rc->token, (ve-v)))
+               continue;
+
+           if (r[0] == '/') {
+               rpmError(RPMERR_BADSPEC,
+                        _("line %d: Versioned file name not permitted: %s"),
+                        spec->lineNum, spec->line);
+               return RPMERR_BADSPEC;
            }
-           if (rc->token) {
-               if (req[0] == '/') {
-                   rpmError(RPMERR_BADSPEC,
-                            _("line %d: No versions on file names in %s: %s"),
-                            spec->lineNum, name, spec->line);
-                   return RPMERR_BADSPEC;
-               }
-               if (tag == RPMTAG_PREREQ) {
-                   rpmError(RPMERR_BADSPEC,
-                            _("line %d: No versions in PreReq: %s"),
-                            spec->lineNum, spec->line);
-                   return RPMERR_BADSPEC;
-               }
-               /* read a version */
-               flags |= rc->sense;
-               version = strtok(NULL, " ,\t\n");
+           switch(tag) {
+           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;
            }
-       }
+           flags |= rc->sense;
 
-       if ((flags & RPMSENSE_SENSEMASK) && !version) {
-           rpmError(RPMERR_BADSPEC,
-                    _("line %d: Version required in %s: %s"),
-                    spec->lineNum, name, spec->line);
-           return RPMERR_BADSPEC;
+           /* now parse version */
+           v = ve;
+           SKIPWHITE(v);
+           ve = v;
+           SKIPNONWHITE(ve);
+           break;
+         }
        }
 
-       addReqProv(spec,
-           (tag == RPMTAG_BUILDPREREQ ? spec->buildRestrictions : pkg->header),
-           flags, req, (flags & RPMSENSE_SENSEMASK) ? version : NULL, index);
+       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';
+       } else
+           version = NULL;
+
+       addReqProv(spec, h, flags, req, version, index);
 
-       /* If there is no sense, we just read the next token */
-       req = (flags & RPMSENSE_SENSEMASK) ? NULL : version;
+       if (req) free(req);
+       if (version) free(version);
+
+       re = ve;
     }
 
     return 0;
 }
 
-int parseProvidesObsoletes(Spec spec, Package pkg, char *field, int tag)
+int parseProvidesObsoletes(Spec spec, Package pkg, const char *field, int tag)
 {
-    char *prov, buf[BUFSIZ], *line;
+    const char *p, *pe;
+    char *prov;
     int flags;
 
     flags = (tag == RPMTAG_PROVIDES) ? RPMSENSE_PROVIDES : RPMSENSE_OBSOLETES;
 
-    strcpy(buf, field);
-    line = buf;
-    
-    while ((prov = strtok(line, " ,\t\n"))) {
-       if (prov[0] == '/' && tag != RPMTAG_PROVIDES) {
+    for (p = field; *p; p = pe) {
+       SKIPWHITE(p);
+       if (*p == '\0')
+           break;
+
+       if (p[0] == '/' && tag != RPMTAG_PROVIDES) {
            rpmError(RPMERR_BADSPEC,
                     _("line %d: No file names in Obsoletes: %s"),
                     spec->lineNum, spec->line);
            return RPMERR_BADSPEC;
        }
-       if (!(isalnum(prov[0]) || prov[0] == '_') && 
-            (tag == RPMTAG_OBSOLETES || prov[0] != '/')) {
+       if (!(isalnum(p[0]) || p[0] == '_') && 
+            (tag == RPMTAG_OBSOLETES || p[0] != '/')) {
            rpmError(RPMERR_BADSPEC,
-                    _("line %d: %s: tokens must begin with alpha-numeric: %s"),
-                    spec->lineNum,
-                    (tag == RPMTAG_PROVIDES) ? "Provides" : "Obsoletes",
-                    spec->line);
+                    _("line %d: tokens must begin with alpha-numeric: %s"),
+                    spec->lineNum, spec->line);
            return RPMERR_BADSPEC;
        }
+
+       pe = p;
+       SKIPNONWHITE(pe);
+       prov = malloc((pe-p) + 1);
+       strncpy(prov, p, (pe-p));
+       prov[pe-p] = '\0';
        addReqProv(spec, pkg->header, flags, prov, NULL, 0);
-       line = NULL;
+       free(prov);
     }
 
     return 0;
index de57eca..318ff53 100644 (file)
@@ -106,9 +106,9 @@ int parseDescription(Spec spec);
 int parseFiles(Spec spec);
 int parsePreamble(Spec spec, int initialPackage);
 int parsePrep(Spec spec);
-int parseRequiresConflicts(Spec spec, Package pkg, char *field,
+int parseRequiresConflicts(Spec spec, Package pkg, const char *field,
                           int tag, int index);
-int parseProvidesObsoletes(Spec spec, Package pkg, char *field, int tag);
+int parseProvidesObsoletes(Spec spec, Package pkg, const char *field, int tag);
 int parseTrigger(Spec spec, Package pkg, char *field, int tag);
 int parseScript(Spec spec, int parsePart);
 int parseBuildInstallClean(Spec spec, int parsePart);
index a30dd7a..af57fb7 100644 (file)
@@ -132,6 +132,9 @@ extern const struct headerSprintfExtension rpmHeaderFormats[];
 #define        RPMTAG_SOURCEPACKAGE            1106 /* internal */
 #define        RPMTAG_ORIGFILENAMES            1107
 #define        RPMTAG_BUILDPREREQ              1108 /* internal */
+#define        RPMTAG_BUILDREQUIRES            1109 /* internal */
+#define        RPMTAG_BUILDCONFLICTS           1110 /* internal */
+#define        RPMTAG_BUILDMACROS              1111
 
 #define        RPMTAG_EXTERNAL_TAG             1000000
 
index acad66b..c7727bc 100644 (file)
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-05-25 16:14-0400\n"
+"POT-Creation-Date: 1999-05-25 23:43-0400\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -2021,32 +2021,32 @@ msgstr ""
 msgid "line %d: Epoch/Serial field must be a number: %s"
 msgstr ""
 
-#: ../build/parsePreamble.c:524
+#: ../build/parsePreamble.c:526
 #, c-format
 msgid "line %d: Bad BuildArchitecture format: %s"
 msgstr ""
 
-#: ../build/parsePreamble.c:534
+#: ../build/parsePreamble.c:536
 #, c-format
 msgid "Internal error: Bogus tag %d"
 msgstr ""
 
-#: ../build/parsePreamble.c:679
+#: ../build/parsePreamble.c:683
 #, c-format
 msgid "Bad package specification: %s"
 msgstr ""
 
-#: ../build/parsePreamble.c:685
+#: ../build/parsePreamble.c:689
 #, c-format
 msgid "Package already exists: %s"
 msgstr ""
 
-#: ../build/parsePreamble.c:712
+#: ../build/parsePreamble.c:716
 #, c-format
 msgid "line %d: Unknown tag: %s"
 msgstr ""
 
-#: ../build/parsePreamble.c:737
+#: ../build/parsePreamble.c:741
 msgid "Spec file can't use BuildRoot"
 msgstr ""
 
@@ -2110,34 +2110,34 @@ msgstr ""
 msgid "line %d: second %%prep"
 msgstr ""
 
-#: ../build/parseReqs.c:45
+#: ../build/parseReqs.c:47 ../build/parseReqs.c:56
 #, c-format
-msgid "line %d: No file names in Conflicts: %s"
+msgid "line %d: File name not permitted: %s"
 msgstr ""
 
-#: ../build/parseReqs.c:79
+#: ../build/parseReqs.c:115
 #, c-format
-msgid "line %d: No versions on file names in %s: %s"
+msgid "line %d: Versioned file name not permitted: %s"
 msgstr ""
 
-#: ../build/parseReqs.c:85
+#: ../build/parseReqs.c:123
 #, c-format
-msgid "line %d: No versions in PreReq: %s"
+msgid "line %d: Version not permitted: %s"
 msgstr ""
 
-#: ../build/parseReqs.c:97
+#: ../build/parseReqs.c:143
 #, c-format
-msgid "line %d: Version required in %s: %s"
+msgid "line %d: Version required: %s"
 msgstr ""
 
-#: ../build/parseReqs.c:126
+#: ../build/parseReqs.c:179
 #, c-format
 msgid "line %d: No file names in Obsoletes: %s"
 msgstr ""
 
-#: ../build/parseReqs.c:133
+#: ../build/parseReqs.c:186
 #, c-format
-msgid "line %d: %s: tokens must begin with alpha-numeric: %s"
+msgid "line %d: tokens must begin with alpha-numeric: %s"
 msgstr ""
 
 #: ../build/parseScript.c:138
@@ -3110,7 +3110,7 @@ msgstr ""
 msgid "missing ':' at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:656 ../lib/rpmrc.c:729
+#: ../lib/rpmrc.c:656 ../lib/rpmrc.c:730
 #, c-format
 msgid "missing argument for %s at %s:%d"
 msgstr ""
@@ -3125,22 +3125,22 @@ msgstr ""
 msgid "cannot open %s at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:721
+#: ../lib/rpmrc.c:722
 #, c-format
 msgid "missing architecture for %s at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:788
+#: ../lib/rpmrc.c:789
 #, c-format
 msgid "bad option '%s' at %s:%d"
 msgstr ""
 
-#: ../lib/rpmrc.c:1124
+#: ../lib/rpmrc.c:1125
 #, c-format
 msgid "Unknown system: %s\n"
 msgstr ""
 
-#: ../lib/rpmrc.c:1125
+#: ../lib/rpmrc.c:1126
 msgid "Please contact rpm-list@redhat.com\n"
 msgstr ""