fix: sanity test on specfile fails when encountering i18n chars.
authorjbj <devnull@localhost>
Thu, 22 Jul 1999 19:38:25 +0000 (19:38 +0000)
committerjbj <devnull@localhost>
Thu, 22 Jul 1999 19:38:25 +0000 (19:38 +0000)
CVS patchset: 3198
CVS date: 1999/07/22 19:38:25

CHANGES
build.c
po/rpm.pot

diff --git a/CHANGES b/CHANGES
index 6af7b9c..982301c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,7 @@
        - add pl translation and man pages (PLD team - from Tomasz Kloczko).
        - fix: incomplete cleanup if --rebuilddb fails (#4115).
        - add versions to provides.
+       - fix: sanity test on specfile fails when encountering i18n chars.
 
 3.0.1 -> 3.0.2
        - eliminate armv4 entries from rpmrc (Andrew E. Mileski).
diff --git a/build.c b/build.c
index 0806dfe..833678a 100644 (file)
--- a/build.c
+++ b/build.c
@@ -45,6 +45,44 @@ static int checkSpec(Header h)
     return rc;
 }
 
+/*
+ * Kurwa, durni ameryka?ce sobe zawsze my?l?, ?e ca?y ?wiat mówi po
+ * angielsku...
+ */
+/* XXX this is still a dumb test but at least it's i18n aware */
+static int isSpecFile(const char *specfile)
+{
+    char buf[256];
+    const char * s;
+    FD_t fd;
+    int count;
+    int checking;
+
+    if ((fd = fdOpen(specfile, O_RDONLY, 0)) < 0) {
+       fprintf(stderr, _("Unable to open spec file: %s\n"), specfile);
+       return 0;
+    }
+    count = fdRead(fd, buf, sizeof(buf));
+    fdClose(fd);
+
+    checking = 1;
+    for (s = buf; count--; s++) {
+       switch (*s) {
+       case '\r':
+       case '\n':
+           checking = 1;
+           break;
+       case ':':
+           checking = 0;
+           break;
+       default:
+           if (checking && !(isprint(*s) || isspace(*s))) return 0;
+           break;
+       }
+    }
+    return 1;
+}
+
 static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
        const char *passPhrase, int fromTarball, char *cookie,
        int force, int nodeps)
@@ -52,13 +90,10 @@ static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
     int buildAmount = ba->buildAmount;
     const char *buildRoot = ba->buildRootOverride;
     int test = ba->noBuild;
-
     FILE *f;
     const char * specfile;
     int res = 0;
     struct stat statbuf;
-    char * s;
-    int count, fd;
     char buf[BUFSIZ];
     Spec spec = NULL;
 
@@ -167,23 +202,14 @@ static int buildForTarget(const char *arg, struct rpmBuildArguments *ba,
        fprintf(stderr, _("File is not a regular file: %s\n"), specfile);
        return 1;
     }
-    
-    if ((fd = open(specfile, O_RDONLY)) < 0) {
-       fprintf(stderr, _("Unable to open spec file: %s\n"), specfile);
+
+    /* Try to verify that the file is actually a specfile */
+    if (!isSpecFile(specfile)) {
+       fprintf(stderr, _("File %s does not appear to be a specfile.\n"),
+               specfile);
        return 1;
     }
-    count = read(fd, buf, sizeof(buf) < 128 ? sizeof(buf) : 128);
-    close(fd);
-    s = buf;
-    while(count--) {
-       if (! (isprint(*s) || isspace(*s) || (*s == 0x1b))) {
-           fprintf(stderr, _("File contains non-printable characters(%c): %s\n"), *s,
-                   specfile);
-           return 1;
-       }
-       s++;
-    }
-
+    
     /* Parse the spec file */
 #define        _anyarch(_f)    \
 (((_f)&(RPMBUILD_PREP|RPMBUILD_BUILD|RPMBUILD_INSTALL|RPMBUILD_PACKAGEBINARY)) == 0)
index 866465d..06be4ec 100644 (file)
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-07-22 13:35-0400\n"
+"POT-Creation-Date: 1999-07-22 15:36-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"
@@ -23,101 +23,101 @@ msgstr ""
 msgid "failed build dependencies:\n"
 msgstr ""
 
-#: ../build.c:83 ../build.c:96
+#: ../build.c:62
+#, c-format
+msgid "Unable to open spec file: %s\n"
+msgstr ""
+
+#: ../build.c:118 ../build.c:131
 #, c-format
 msgid "Failed to open tar pipe: %s\n"
 msgstr ""
 
 #. Give up
-#: ../build.c:104
+#: ../build.c:139
 #, c-format
 msgid "Failed to read spec file from %s\n"
 msgstr ""
 
-#: ../build.c:129
+#: ../build.c:164
 #, c-format
 msgid "Failed to rename %s to %s: %s\n"
 msgstr ""
 
-#: ../build.c:167
+#: ../build.c:202
 #, c-format
 msgid "File is not a regular file: %s\n"
 msgstr ""
 
-#: ../build.c:172
-#, c-format
-msgid "Unable to open spec file: %s\n"
-msgstr ""
-
-#: ../build.c:180
+#: ../build.c:208
 #, c-format
-msgid "File contains non-printable characters(%c): %s\n"
+msgid "File %s does not appear to be a specfile.\n"
 msgstr ""
 
 #. parse up the build operators
-#: ../build.c:233
+#: ../build.c:259
 #, c-format
 msgid "Building target platforms: %s\n"
 msgstr ""
 
-#: ../build.c:242
+#: ../build.c:268
 #, c-format
 msgid "Building for target %s\n"
 msgstr ""
 
-#: ../build.c:286
+#: ../build.c:312
 msgid "buildroot already specified"
 msgstr ""
 
-#: ../build.c:292
+#: ../build.c:318
 msgid "--buildarch has been obsoleted.  Use the --target option instead.\n"
 msgstr ""
 
-#: ../build.c:296
+#: ../build.c:322
 msgid "--buildos has been obsoleted.  Use the --target option instead.\n"
 msgstr ""
 
-#: ../build.c:317
+#: ../build.c:343
 msgid "override build architecture"
 msgstr ""
 
-#: ../build.c:319
+#: ../build.c:345
 msgid "override build operating system"
 msgstr ""
 
-#: ../build.c:321
+#: ../build.c:347
 msgid "override build root"
 msgstr ""
 
-#: ../build.c:323 ../rpm.c:457
+#: ../build.c:349 ../rpm.c:457
 msgid "remove build tree when done"
 msgstr ""
 
-#: ../build.c:325
+#: ../build.c:351
 msgid "do not execute any stages of the build"
 msgstr ""
 
-#: ../build.c:327
+#: ../build.c:353
 msgid "do not accept I18N msgstr's from specfile"
 msgstr ""
 
-#: ../build.c:329
+#: ../build.c:355
 msgid "remove sources when done"
 msgstr ""
 
-#: ../build.c:331
+#: ../build.c:357
 msgid "remove specfile when done"
 msgstr ""
 
-#: ../build.c:333 ../rpm.c:455
+#: ../build.c:359 ../rpm.c:455
 msgid "skip straight to specified stage (only for c,i)"
 msgstr ""
 
-#: ../build.c:335
+#: ../build.c:361
 msgid "override target platform"
 msgstr ""
 
-#: ../build.c:337
+#: ../build.c:363
 msgid "lookup I18N strings in specfile catalog"
 msgstr ""