don't spin while waiting for delayed requires/provides input (#3289).
authorjbj <devnull@localhost>
Thu, 17 Jun 1999 15:44:47 +0000 (15:44 +0000)
committerjbj <devnull@localhost>
Thu, 17 Jun 1999 15:44:47 +0000 (15:44 +0000)
common parse for all dependency token syntax.

CVS patchset: 3094
CVS date: 1999/06/17 15:44:47

CHANGES
build/files.c
build/parsePreamble.c
build/parseReqs.c
build/parseScript.c
build/rpmbuild.h
po/rpm.pot

diff --git a/CHANGES b/CHANGES
index 1f0e199..5f4005a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,9 +7,11 @@
        - updated ru translation (Sergey Kubushin).
        - add vpkg-provides.sh (Tim Mooney).
        - don't clobber LDFLAGS in top-level Makefile (Tim Mooney).
-       - build root from cmd line did not set macro %buildroot.
-       - resurrect "rpm -Va --nofiles" (i.e. dependencies only) (#3111)
+       - fix: build root from cmd line did not set macro %buildroot (#1026).
+       - fix: resurrect "rpm -Va --nofiles" (verify dependencies only) (#3111).
        - rpm-devel should require popt (#3125).
+       - don't spin while waiting for delayed requires/provides input (#3289).
+       - common parse for all dependency token syntax.
 
 3.0 -> 3.0.1
        - fix: %verifyscript resurrected (Shing-Gene Yung).
index bf934b5..b8398aa 100644 (file)
@@ -1484,10 +1484,9 @@ static StringBuf getOutputFrom(char *dir, char *argv[],
     int fromProg[2];
     int status;
     void *oldhandler;
-    int bytesWritten;
     StringBuf readBuff;
-    int bytes;
     unsigned char buf[BUFSIZ+1];
+    int done;
 
     oldhandler = signal(SIGPIPE, SIG_IGN);
 
@@ -1527,37 +1526,66 @@ static StringBuf getOutputFrom(char *dir, char *argv[],
     readBuff = newStringBuf();
 
     do {
+       fd_set ibits, obits;
+       struct timeval tv;
+       int nfd, nbw, nbr;
+       int rc;
+
+       done = 0;
+top:
+       /* XXX the select is mainly a timer since all I/O is non-blocking */
+       FD_ZERO(&ibits);
+       FD_ZERO(&obits);
+       if (fromProg[0] >= 0) {
+           FD_SET(fromProg[0], &ibits);
+       }
+       if (toProg[1] >= 0) {
+           FD_SET(toProg[1], &obits);
+       }
+       tv.tv_sec = 1;
+       tv.tv_usec = 0;
+       nfd = ((fromProg[0] > toProg[1]) ? fromProg[0] : toProg[1]);
+       if ((rc = select(nfd, &ibits, &obits, NULL, &tv)) < 0) {
+           if (errno == EINTR)
+               goto top;
+           break;
+       }
+
        /* Write any data to program */
-        if (writeBytesLeft) {
-           if ((bytesWritten =
-                 write(toProg[1], writePtr,
+       if (toProg[1] >= 0 && FD_ISSET(toProg[1], &obits)) {
+          if (writeBytesLeft) {
+           if ((nbw = write(toProg[1], writePtr,
                    (1024<writeBytesLeft) ? 1024 : writeBytesLeft)) < 0) {
                if (errno != EAGAIN) {
                    perror("getOutputFrom()");
                    exit(EXIT_FAILURE);
                }
-               bytesWritten = 0;
+               nbw = 0;
            }
-           writeBytesLeft -= bytesWritten;
-           writePtr += bytesWritten;
-       } else if (toProg[1] >= 0) {    /* close write fd */
+           writeBytesLeft -= nbw;
+           writePtr += nbw;
+         } else if (toProg[1] >= 0) {  /* close write fd */
            close(toProg[1]);
            toProg[1] = -1;
+         }
        }
        
        /* Read any data from prog */
-       while ((bytes = read(fromProg[0], buf, sizeof(buf)-1)) > 0) {
-           buf[bytes] = '\0';
+       while ((nbr = read(fromProg[0], buf, sizeof(buf)-1)) > 0) {
+           buf[nbr] = '\0';
            appendStringBuf(readBuff, buf);
        }
 
        /* terminate on (non-blocking) EOF or error */
-    } while (!(bytes == 0 || (bytes < 0 && errno != EAGAIN)));
+       done = (nbr == 0 || (nbr < 0 && errno != EAGAIN));
+
+    } while (!done);
 
     /* Clean up */
     if (toProg[1] >= 0)
        close(toProg[1]);
-    close(fromProg[0]);
+    if (fromProg[0] >= 0)
+       close(fromProg[0]);
     (void)signal(SIGPIPE, oldhandler);
 
     /* Collect status from prog */
index dd199a3..929be02 100644 (file)
@@ -371,7 +371,7 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, char *macro,
       case RPMTAG_RELEASE:
       case RPMTAG_URL:
        SINGLE_TOKEN_ONLY;
-       /* These are for backward compatibility */
+       /* These macros are for backward compatibility */
        if (tag == RPMTAG_VERSION) {
            if (strchr(field, '-') != NULL) {
                rpmError(RPMERR_BADSPEC, _("line %d: Illegal char '-' in %s: %s"),
@@ -498,17 +498,13 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, char *macro,
        break;
       case RPMTAG_OBSOLETES:
       case RPMTAG_PROVIDES:
-       if ((rc = parseProvidesObsoletes(spec, pkg, field, tag))) {
-           return rc;
-       }
-       break;
       case RPMTAG_BUILDREQUIRES:
       case RPMTAG_BUILDCONFLICTS:
       case RPMTAG_BUILDPREREQ:
       case RPMTAG_REQUIREFLAGS:
       case RPMTAG_CONFLICTFLAGS:
       case RPMTAG_PREREQ:
-       if ((rc = parseRequiresConflicts(spec, pkg, field, tag, 0))) {
+       if ((rc = parseRCPOT(spec, pkg, field, tag, 0))) {
            return rc;
        }
        break;
index 6c00b2b..d7e0b07 100644 (file)
@@ -28,66 +28,86 @@ static struct ReqComp {
 #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)
+int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index)
 {
     const char *r, *re, *v, *ve;
     char *req, *version;
     Header h;
     int flags;
 
+    switch (tag) {
+    case RPMTAG_PROVIDES:
+       flags = RPMSENSE_PROVIDES;
+       h = pkg->header;
+       break;
+    case RPMTAG_OBSOLETES:
+       flags = RPMSENSE_OBSOLETES;
+       h = pkg->header;
+       break;
+    case RPMTAG_CONFLICTFLAGS:
+       flags = RPMSENSE_CONFLICTS;
+       h = pkg->header;
+       break;
+    case RPMTAG_BUILDCONFLICTS:
+       flags = RPMSENSE_CONFLICTS;
+       h = spec->buildRestrictions;
+       break;
+    case RPMTAG_PREREQ:
+       flags = RPMSENSE_PREREQ;
+       h = pkg->header;
+       break;
+    case RPMTAG_BUILDPREREQ:
+       flags = RPMSENSE_PREREQ;
+       h = spec->buildRestrictions;
+       break;
+    case RPMTAG_TRIGGERIN:
+       flags = RPMSENSE_TRIGGERIN;
+       h = pkg->header;
+       break;
+    case RPMTAG_TRIGGERPOSTUN:
+       flags = RPMSENSE_TRIGGERPOSTUN;
+       h = pkg->header;
+       break;
+    case RPMTAG_TRIGGERUN:
+       flags = RPMSENSE_TRIGGERUN;
+       h = pkg->header;
+       break;
+    case RPMTAG_BUILDREQUIRES:
+       flags = RPMSENSE_ANY;
+       h = spec->buildRestrictions;
+       break;
+    default:
+    case RPMTAG_REQUIREFLAGS:
+       flags = RPMSENSE_ANY;
+       h = pkg->header;
+       break;
+    }
+
     for (r = field; *r; r = re) {
        SKIPWHITE(r);
        if (*r == '\0')
            break;
-       
+
+       /* 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 */
        switch (tag) {
+       case RPMTAG_OBSOLETES:
        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;
-           h = spec->buildRestrictions;
-           break;
-       case RPMTAG_PREREQ:
-           flags = RPMSENSE_PREREQ;
-           h = pkg->header;
-           break;
-       case RPMTAG_BUILDPREREQ:
-           flags = RPMSENSE_PREREQ;
-           h = spec->buildRestrictions;
-           break;
-       case RPMTAG_TRIGGERIN:
-           flags = RPMSENSE_TRIGGERIN;
-           h = pkg->header;
-           break;
-       case RPMTAG_TRIGGERPOSTUN:
-           flags = RPMSENSE_TRIGGERPOSTUN;
-           h = pkg->header;
-           break;
-       case RPMTAG_TRIGGERUN:
-           flags = RPMSENSE_TRIGGERUN;
-           h = pkg->header;
-           break;
-       case RPMTAG_BUILDREQUIRES:
-           flags = RPMSENSE_ANY;
-           h = spec->buildRestrictions;
            break;
        default:
-       case RPMTAG_REQUIREFLAGS:
-           flags = RPMSENSE_ANY;
-           h = pkg->header;
            break;
        }
 
@@ -103,6 +123,8 @@ int parseRequiresConflicts(Spec spec, Package pkg, const char *field,
        ve = v;
        SKIPNONWHITE(ve);
 
+       re = v; /* ==> next token (if no version found) starts here */
+
        /* Check for possible logical operator */
        if (ve > v) {
          struct ReqComp *rc;
@@ -117,6 +139,8 @@ int parseRequiresConflicts(Spec spec, Package pkg, const char *field,
                return RPMERR_BADSPEC;
            }
            switch(tag) {
+           case RPMTAG_PROVIDES:
+           case RPMTAG_OBSOLETES:
            case RPMTAG_BUILDPREREQ:
            case RPMTAG_PREREQ:
                rpmError(RPMERR_BADSPEC,
@@ -147,6 +171,7 @@ int parseRequiresConflicts(Spec spec, Package pkg, const char *field,
            version = malloc((ve-v) + 1);
            strncpy(version, v, (ve-v));
            version[ve-v] = '\0';
+           re = ve;    /* ==> next token after version string starts here */
        } else
            version = NULL;
 
@@ -155,46 +180,6 @@ int parseRequiresConflicts(Spec spec, Package pkg, const char *field,
        if (req) free(req);
        if (version) free(version);
 
-       re = ve;
-    }
-
-    return 0;
-}
-
-int parseProvidesObsoletes(Spec spec, Package pkg, const char *field, int tag)
-{
-    const char *p, *pe;
-    char *prov;
-    int flags;
-
-    flags = (tag == RPMTAG_PROVIDES) ? RPMSENSE_PROVIDES : RPMSENSE_OBSOLETES;
-
-    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(p[0]) || p[0] == '_') && 
-            (tag == RPMTAG_OBSOLETES || p[0] != '/')) {
-           rpmError(RPMERR_BADSPEC,
-                    _("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);
-       free(prov);
     }
 
     return 0;
index 7ec9d5d..b2a2119 100644 (file)
@@ -50,7 +50,7 @@ static int addTriggerIndex(Package pkg, char *file, char *script, char *prog)
 
 /* %trigger is a strange combination of %pre and Requires: behavior */
 /* We can handle it by parsing the args before "--" in parseScript. */
-/* We then pass the remaining arguments to parseReqProv, along with */
+/* We then pass the remaining arguments to parseRCPOT, along with   */
 /* an index we just determined.                                     */
 
 int parseScript(Spec spec, int parsePart)
@@ -246,7 +246,7 @@ int parseScript(Spec spec, int parsePart)
        index = addTriggerIndex(pkg, file, p, prog);
 
        /* Generate the trigger tags */
-       if ((rc = parseRequiresConflicts(spec, pkg, reqargs, reqtag, index))) {
+       if ((rc = parseRCPOT(spec, pkg, reqargs, reqtag, index))) {
            freeStringBuf(sb);
            FREE(progArgv);
            FREE(argv);
index 318ff53..2277bed 100644 (file)
@@ -106,9 +106,7 @@ int parseDescription(Spec spec);
 int parseFiles(Spec spec);
 int parsePreamble(Spec spec, int initialPackage);
 int parsePrep(Spec spec);
-int parseRequiresConflicts(Spec spec, Package pkg, const char *field,
-                          int tag, int index);
-int parseProvidesObsoletes(Spec spec, Package pkg, const char *field, int tag);
+int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index);
 int parseTrigger(Spec spec, Package pkg, char *field, int tag);
 int parseScript(Spec spec, int parsePart);
 int parseBuildInstallClean(Spec spec, int parsePart);
index fab5109..8dd11d0 100644 (file)
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-06-16 16:15-0400\n"
+"POT-Creation-Date: 1999-06-17 11:17-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"
@@ -1710,55 +1710,55 @@ msgstr ""
 msgid "Bad owner/group: %s"
 msgstr ""
 
-#: ../build/files.c:1512
+#: ../build/files.c:1511
 #, c-format
 msgid "Couldn't exec %s"
 msgstr ""
 
-#: ../build/files.c:1516
+#: ../build/files.c:1515
 #, c-format
 msgid "Couldn't fork %s"
 msgstr ""
 
-#: ../build/files.c:1566
+#: ../build/files.c:1594
 #, c-format
 msgid "%s failed"
 msgstr ""
 
-#: ../build/files.c:1570
+#: ../build/files.c:1598
 #, c-format
 msgid "failed to write all data to %s"
 msgstr ""
 
-#: ../build/files.c:1604
+#: ../build/files.c:1632
 msgid "Finding provides...\n"
 msgstr ""
 
-#: ../build/files.c:1611
+#: ../build/files.c:1639
 msgid "Failed to find provides"
 msgstr ""
 
-#: ../build/files.c:1630
+#: ../build/files.c:1658
 msgid "Finding requires...\n"
 msgstr ""
 
-#: ../build/files.c:1637
+#: ../build/files.c:1665
 msgid "Failed to find requires"
 msgstr ""
 
-#: ../build/files.c:1671
+#: ../build/files.c:1699
 msgid "Provides:"
 msgstr ""
 
-#: ../build/files.c:1686
+#: ../build/files.c:1714
 msgid "Prereqs:"
 msgstr ""
 
-#: ../build/files.c:1698
+#: ../build/files.c:1726
 msgid "Requires:"
 msgstr ""
 
-#: ../build/files.c:1722
+#: ../build/files.c:1750
 #, c-format
 msgid "Processing files: %s\n"
 msgstr ""
@@ -2015,32 +2015,32 @@ msgstr ""
 msgid "line %d: Epoch/Serial field must be a number: %s"
 msgstr ""
 
-#: ../build/parsePreamble.c:526
+#: ../build/parsePreamble.c:522
 #, c-format
 msgid "line %d: Bad BuildArchitecture format: %s"
 msgstr ""
 
-#: ../build/parsePreamble.c:536
+#: ../build/parsePreamble.c:532
 #, c-format
 msgid "Internal error: Bogus tag %d"
 msgstr ""
 
-#: ../build/parsePreamble.c:683
+#: ../build/parsePreamble.c:679
 #, c-format
 msgid "Bad package specification: %s"
 msgstr ""
 
-#: ../build/parsePreamble.c:689
+#: ../build/parsePreamble.c:685
 #, c-format
 msgid "Package already exists: %s"
 msgstr ""
 
-#: ../build/parsePreamble.c:716
+#: ../build/parsePreamble.c:712
 #, c-format
 msgid "line %d: Unknown tag: %s"
 msgstr ""
 
-#: ../build/parsePreamble.c:741
+#: ../build/parsePreamble.c:737
 msgid "Spec file can't use BuildRoot"
 msgstr ""
 
@@ -2104,36 +2104,31 @@ msgstr ""
 msgid "line %d: second %%prep"
 msgstr ""
 
-#: ../build/parseReqs.c:47 ../build/parseReqs.c:56
+#: ../build/parseReqs.c:95
+#, c-format
+msgid "line %d: tokens must begin with alpha-numeric, '_' or '/': %s"
+msgstr ""
+
+#: ../build/parseReqs.c:106
 #, c-format
 msgid "line %d: File name not permitted: %s"
 msgstr ""
 
-#: ../build/parseReqs.c:115
+#: ../build/parseReqs.c:139
 #, c-format
 msgid "line %d: Versioned file name not permitted: %s"
 msgstr ""
 
-#: ../build/parseReqs.c:123
+#: ../build/parseReqs.c:149
 #, c-format
 msgid "line %d: Version not permitted: %s"
 msgstr ""
 
-#: ../build/parseReqs.c:143
+#: ../build/parseReqs.c:169
 #, c-format
 msgid "line %d: Version required: %s"
 msgstr ""
 
-#: ../build/parseReqs.c:179
-#, c-format
-msgid "line %d: No file names in Obsoletes: %s"
-msgstr ""
-
-#: ../build/parseReqs.c:186
-#, c-format
-msgid "line %d: tokens must begin with alpha-numeric: %s"
-msgstr ""
-
 #: ../build/parseScript.c:138
 #, c-format
 msgid "line %d: triggers must have --: %s"