teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame 0025-build-files.c-Only-check-build-ids-for-executable-fi.patch

Igor Gnatenko 082d5d
From c21bf3aefdcfb22bc3f41888ef090c6d5a45baec Mon Sep 17 00:00:00 2001
Igor Gnatenko 082d5d
From: Mark Wielaard <mark@klomp.org>
Igor Gnatenko 082d5d
Date: Mon, 20 Mar 2017 11:52:00 +0100
Mark Wielaard 284dc3
Subject: [PATCH] build/files.c: Only check build-ids for executable files in
Mark Wielaard 284dc3
 the main package.
Igor Gnatenko 082d5d
Igor Gnatenko 082d5d
generateBuildIDs should mimic what find-debuginfo.sh does. Only check
Igor Gnatenko 082d5d
build-ids for executable files in non-debuginfo packages. This moves the
Igor Gnatenko 082d5d
isDbg check up so the is executeble check can be done when the file is
Igor Gnatenko 082d5d
part of the main package.
Igor Gnatenko 082d5d
Igor Gnatenko 082d5d
This fixes the build of qemu and uboot-tools in fedora. Both ship
Igor Gnatenko 082d5d
non-executable ELF bios files in architecture specific packages.
Igor Gnatenko 082d5d
https://bugzilla.redhat.com/show_bug.cgi?id=1433837
Igor Gnatenko 082d5d
Igor Gnatenko 082d5d
Signed-off-by: Mark Wielaard <mark@klomp.org>
Igor Gnatenko 082d5d
(cherry picked from commit c9035d464a6ac3853b5dc705e0df1734ce915cd4)
Igor Gnatenko 082d5d
---
Igor Gnatenko 082d5d
 build/files.c | 19 ++++++++++++++-----
Igor Gnatenko 082d5d
 1 file changed, 14 insertions(+), 5 deletions(-)
Igor Gnatenko 082d5d
Mark Wielaard 915296
diff --git a/build/files.c b/build/files.c
Igor Gnatenko 082d5d
index 9e58ae547..9f7def78c 100644
Mark Wielaard 915296
--- a/build/files.c
Mark Wielaard 915296
+++ b/build/files.c
Igor Gnatenko 082d5d
@@ -1684,6 +1684,19 @@ static int generateBuildIDs(FileList fl)
Mark Wielaard 915296
     for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
Mark Wielaard 915296
 	struct stat sbuf;
Mark Wielaard 915296
 	if (lstat(flp->diskPath, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
Mark Wielaard 915296
+	    /* We determine whether this is a main or
Mark Wielaard 915296
+	       debug ELF based on path.  */
Mark Wielaard 915296
+	    #define DEBUGPATH "/usr/lib/debug/"
Mark Wielaard 915296
+	    int isDbg = strncmp (flp->cpioPath,
Mark Wielaard 915296
+				 DEBUGPATH, strlen (DEBUGPATH)) == 0;
Mark Wielaard 915296
+
Mark Wielaard 915296
+	    /* For the main package files mimic what find-debuginfo.sh does.
Mark Wielaard 915296
+	       Only check build-ids for executable files. Debug files are
Mark Wielaard 915296
+	       always non-executable. */
Mark Wielaard 915296
+	    if (!isDbg
Mark Wielaard 915296
+		&& (sbuf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0)
Mark Wielaard 915296
+	      continue;
Mark Wielaard 915296
+
Mark Wielaard 915296
 	    int fd = open (flp->diskPath, O_RDONLY);
Mark Wielaard 915296
 	    if (fd >= 0) {
Mark Wielaard 915296
 		/* Only real ELF files, that are ET_EXEC, ET_DYN or
Igor Gnatenko 082d5d
@@ -1705,12 +1718,8 @@ static int generateBuildIDs(FileList fl)
Mark Wielaard 915296
 		       is 128 bits) and 64 bytes (largest sha3 is 512
Mark Wielaard 915296
 		       bits), common is 20 bytes (sha1 is 160 bits). */
Mark Wielaard 915296
 		    if (len >= 16 && len <= 64) {
Mark Wielaard 915296
-			/* We determine whether this is a main or
Mark Wielaard 915296
-			   debug ELF based on path.  */
Mark Wielaard 915296
-			#define DEBUGPATH "/usr/lib/debug/"
Mark Wielaard 915296
 			int addid = 0;
Mark Wielaard 915296
-			if (strncmp (flp->cpioPath,
Mark Wielaard 915296
-				     DEBUGPATH, strlen (DEBUGPATH)) == 0) {
Mark Wielaard 915296
+			if (isDbg) {
Mark Wielaard 915296
 			    needDbg = 1;
Mark Wielaard 915296
 			    addid = 1;
Mark Wielaard 915296
 			}