teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame 0020-build-files-exec-build-id.patch

Mark Wielaard 915296
diff --git a/build/files.c b/build/files.c
Mark Wielaard 915296
index 6021643..afa01cd 100644
Mark Wielaard 915296
--- a/build/files.c
Mark Wielaard 915296
+++ b/build/files.c
Mark Wielaard 915296
@@ -1711,6 +1711,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
Mark Wielaard 915296
@@ -1732,12 +1745,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
 			}