Check for binaries in noarch packages at build-time
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 23 Jan 2009 12:34:08 +0000 (14:34 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 23 Jan 2009 12:34:08 +0000 (14:34 +0200)
- this will only catch elf files for now, but better than nothing
- default to terminating build (as binaries in noarch package is pretty
  nasty thing to do), permit macro override just in case though
- only works for internal dep generator

build/files.c
macros.in

index 1f5212e..bb57ff0 100644 (file)
@@ -2226,18 +2226,28 @@ int processBinaryFiles(rpmSpec spec, int installSpecialDoc, int test)
     genSourceRpmName(spec);
     
     for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
-       const char *n, *v, *r;
+       const char *n, *v, *r, *a;
        headerPutString(pkg->header, RPMTAG_SOURCERPM, spec->sourceRpmName);
 
        if (pkg->fileList == NULL)
            continue;
 
-       (void) headerNVR(pkg->header, &n, &v, &r);
-       rpmlog(RPMLOG_NOTICE, _("Processing files: %s-%s-%s\n"), n, v, r);
+       (void) headerNEVRA(pkg->header, &n, NULL, &v, &r, &a);
+       rpmlog(RPMLOG_NOTICE, _("Processing files: %s-%s-%s.%s\n"), n, v, r, a);
                   
        if ((rc = processPackageFiles(spec, pkg, installSpecialDoc, test)) != RPMRC_OK ||
            (rc = rpmfcGenerateDepends(spec, pkg)) != RPMRC_OK)
            goto exit;
+
+       if (strcmp(a, "noarch") == 0 && headerGetColor(pkg->header) != 0) {
+           int terminate = rpmExpandNumeric("%{?_binaries_in_noarch_packages_terminate_build}");
+           rpmlog(terminate ? RPMLOG_ERR : RPMLOG_WARNING, 
+                  _("Arch dependent binaries in noarch package\n"));
+           if (terminate) {
+               rc = RPMRC_FAIL;
+               goto exit;
+           }
+       }
     }
 
     /* Now we have in fileList list of files from all packages.
index 417be67..0a573da 100644 (file)
--- a/macros.in
+++ b/macros.in
@@ -379,6 +379,10 @@ package or when debugging this package.\
 %_missing_doc_files_terminate_build    1
 
 #
+# Should binaries in noarch packages terminate a build?
+%_binaries_in_noarch_packages_terminate_build  1
+
+#
 # Program to call for each successfully built and written binary package.
 # The package name is passed to the program as a command-line argument.
 #