Panu Matilainen 4a8173
commit fa9fcc89146f08bce3b51d96d0ec9d4175db6978
Panu Matilainen 4a8173
Author: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen 4a8173
Date:   Thu Nov 26 10:22:41 2009 +0200
Panu Matilainen 4a8173
Panu Matilainen 4a8173
    Dont fail build on unrecognized non-executable files (ticket #105)
Panu Matilainen 4a8173
    - Generally only executable files are critical for dependency extraction,
Panu Matilainen 4a8173
      whereas oddball application data files can cause unnecessary build
Panu Matilainen 4a8173
      failure due to libmagic misdetections etc, so just let non-executables
Panu Matilainen 4a8173
      pass with a warning and mark them as unknown data
Panu Matilainen 4a8173
    (cherry picked from commit cfcd1f9bd98d5d0fc46a84931984efec3b9d47e2)
Panu Matilainen 4a8173
Panu Matilainen 4a8173
diff --git a/build/rpmfc.c b/build/rpmfc.c
Panu Matilainen 4a8173
index bcb5383..e4ba6b2 100644
Panu Matilainen 4a8173
--- a/build/rpmfc.c
Panu Matilainen 4a8173
+++ b/build/rpmfc.c
Panu Matilainen 4a8173
@@ -1245,6 +1245,7 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode)
Panu Matilainen 4a8173
     for (fc->ix = 0; fc->ix < fc->nfiles; fc->ix++) {
Panu Matilainen 4a8173
 	const char * ftype;
Panu Matilainen 4a8173
 	rpm_mode_t mode = (fmode ? fmode[fc->ix] : 0);
Panu Matilainen 4a8173
+	int is_executable = (mode & (S_IXUSR|S_IXGRP|S_IXOTH));
Panu Matilainen 4a8173
 
Panu Matilainen 4a8173
 	s = argv[fc->ix];
Panu Matilainen 4a8173
 	slen = strlen(s);
Panu Matilainen 4a8173
@@ -1277,11 +1278,16 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode)
Panu Matilainen 4a8173
 		ftype = magic_file(ms, s);
Panu Matilainen 4a8173
 
Panu Matilainen 4a8173
 	    if (ftype == NULL) {
Panu Matilainen 4a8173
-		rpmlog(RPMLOG_ERR, 
Panu Matilainen 4a8173
+		rpmlog(is_executable ? RPMLOG_ERR : RPMLOG_WARNING, 
Panu Matilainen 4a8173
 		       _("Recognition of file \"%s\" failed: mode %06o %s\n"),
Panu Matilainen 4a8173
 		       s, mode, magic_error(ms));
Panu Matilainen 4a8173
-		magic_close(ms);
Panu Matilainen 4a8173
-		return RPMRC_FAIL;
Panu Matilainen 4a8173
+		/* only executable files are critical to dep extraction */
Panu Matilainen 4a8173
+		if (is_executable) {
Panu Matilainen 4a8173
+		    magic_close(ms);
Panu Matilainen 4a8173
+		    return RPMRC_FAIL;
Panu Matilainen 4a8173
+		}
Panu Matilainen 4a8173
+		/* unrecognized non-executables get treated as "data" */
Panu Matilainen 4a8173
+		ftype = "data";
Panu Matilainen 4a8173
 	    }
Panu Matilainen 4a8173
 	}
Panu Matilainen 4a8173