teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.4.2-debugpaths.patch

Paul Nasrat 090344
--- rpm-4.4.2/scripts/find-debuginfo.sh.dbgpaths	2005-07-14 16:52:31.000000000 +0100
Paul Nasrat 090344
+++ rpm-4.4.2/scripts/find-debuginfo.sh	2006-09-07 11:27:08.000000000 +0100
Paul Nasrat 090344
@@ -13,6 +13,11 @@
Paul Nasrat 090344
 
Paul Nasrat 090344
 echo -n > $SOURCEFILE
Paul Nasrat 090344
 
Paul Nasrat 090344
+strip_to_debug()
Paul Nasrat 090344
+{
Paul Nasrat 090344
+  eu-strip --remove-comment -f "$1" "$2" || :
Paul Nasrat 090344
+}
Paul Nasrat 090344
+
Paul Nasrat 090344
 # Strip ELF binaries
Paul Nasrat 090344
 for f in `find $RPM_BUILD_ROOT ! -path "${debugdir}/*.debug" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \
Paul Nasrat 090344
 	sed -n -e 's/^\(.*\):[ 	]*.*ELF.*, not stripped/\1/p'`
Paul Nasrat 090344
@@ -35,16 +40,16 @@
Paul Nasrat 090344
 
Paul Nasrat 090344
 	mkdir -p "${debugdn}"
Paul Nasrat 090344
 	if test -w "$f"; then
Paul Nasrat 090344
-		eu-strip -f "${debugfn}" "$f" || :
Paul Nasrat 090344
+		strip_to_debug "${debugfn}" "$f"
Paul Nasrat 090344
 	else
Paul Nasrat 090344
 		chmod u+w "$f"
Paul Nasrat 090344
-		eu-strip -f "${debugfn}" "$f" || :
Paul Nasrat 090344
+		strip_to_debug "${debugfn}" "$f"
Paul Nasrat 090344
 		chmod u-w "$f"
Paul Nasrat 090344
 	fi
Paul Nasrat 090344
 done
Paul Nasrat 090344
 
Paul Nasrat 090344
 mkdir -p ${RPM_BUILD_ROOT}/usr/src/debug
Paul Nasrat 090344
-cat $SOURCEFILE | (cd $RPM_BUILD_DIR; LANG=C sort -z -u | cpio -pd0m ${RPM_BUILD_ROOT}/usr/src/debug)
Paul Nasrat 090344
+cat $SOURCEFILE | (cd $RPM_BUILD_DIR; LANG=C sort -z -u | cpio -pd0mL ${RPM_BUILD_ROOT}/usr/src/debug)
Paul Nasrat 090344
 # stupid cpio creates new directories in mode 0700, fixup
Paul Nasrat 090344
 find ${RPM_BUILD_ROOT}/usr/src/debug -type d -print0 | xargs -0 chmod a+rx
Paul Nasrat 090344
 
Paul Nasrat 090344
--- rpm-4.4.2/tools/debugedit.c.dbgpaths	2006-09-07 11:21:33.000000000 +0100
Paul Nasrat 090344
+++ rpm-4.4.2/tools/debugedit.c	2006-09-07 11:26:56.000000000 +0100
Paul Nasrat 090344
@@ -1,4 +1,4 @@
Paul Nasrat 090344
-/* Copyright (C) 2001, 2002, 2003 Red Hat, Inc.
Paul Nasrat 090344
+/* Copyright (C) 2001, 2002, 2003, 2005 Red Hat, Inc.
Paul Nasrat 090344
    Written by Alexander Larsson <alexl@redhat.com>, 2002
Paul Nasrat 090344
    Based on code by Jakub Jelinek <jakub@redhat.com>, 2001.
Paul Nasrat 090344
 
Paul Nasrat 090344
@@ -343,13 +343,11 @@
Paul Nasrat 090344
 #define IS_DIR_SEPARATOR(c) ((c)=='/')
Paul Nasrat 090344
 
Paul Nasrat 090344
 static char *
Paul Nasrat 090344
-canonicalize_path (char *s, char *d)
Paul Nasrat 090344
+canonicalize_path (const char *s, char *d)
Paul Nasrat 090344
 {
Paul Nasrat 090344
   char *rv = d;
Paul Nasrat 090344
-  char *sroot, *droot;
Paul Nasrat 090344
-
Paul Nasrat 090344
-  if (d == 0)
Paul Nasrat 090344
-    rv = d = s;
Paul Nasrat 090344
+  const char *sroot;
Paul Nasrat 090344
+  char *droot;
Paul Nasrat 090344
 
Paul Nasrat 090344
   if (IS_DIR_SEPARATOR (*s))
Paul Nasrat 090344
     {
Paul Nasrat 090344
@@ -600,6 +598,7 @@
Paul Nasrat 090344
       unsigned char *srcptr, *buf = NULL;
Paul Nasrat 090344
       size_t base_len = strlen (base_dir);
Paul Nasrat 090344
       size_t dest_len = strlen (dest_dir);
Paul Nasrat 090344
+      size_t shrank = 0;
Paul Nasrat 090344
 
Paul Nasrat 090344
       if (dest_len == base_len)
Paul Nasrat 090344
 	abs_file_cnt = 0;
Paul Nasrat 090344
@@ -611,27 +610,40 @@
Paul Nasrat 090344
 	}
Paul Nasrat 090344
       else
Paul Nasrat 090344
 	ptr = srcptr = dir;
Paul Nasrat 090344
+      unsigned char *srcstart=srcptr;
Paul Nasrat 090344
       while (*srcptr != 0)
Paul Nasrat 090344
 	{
Paul Nasrat 090344
 	  size_t len = strlen (srcptr) + 1;
Paul Nasrat 090344
+	  const unsigned char *readptr = srcptr;
Paul Nasrat 090344
 
Paul Nasrat 090344
 	  if (*srcptr == '/' && has_prefix (srcptr, base_dir))
Paul Nasrat 090344
 	    {
Paul Nasrat 090344
-	      memcpy (ptr, dest_dir, dest_len);
Paul Nasrat 090344
 	      if (dest_len < base_len)
Paul Nasrat 090344
-		{
Paul Nasrat 090344
-		  memmove (ptr + dest_len, srcptr + base_len,
Paul Nasrat 090344
-			   len - base_len);
Paul Nasrat 090344
-		  ptr += dest_len - base_len;
Paul Nasrat 090344
 		  ++abs_dir_cnt;
Paul Nasrat 090344
+	      memcpy (ptr, dest_dir, dest_len);
Paul Nasrat 090344
+	      ptr += dest_len;
Paul Nasrat 090344
+	      readptr += base_len;
Paul Nasrat 090344
 		}
Paul Nasrat 090344
+	  srcptr += len;
Paul Nasrat 090344
+
Paul Nasrat 090344
+	  shrank += srcptr - readptr;
Paul Nasrat 090344
+	  canonicalize_path (readptr, ptr);
Paul Nasrat 090344
+	  len = strlen (ptr) + 1;
Paul Nasrat 090344
+	  shrank -= len;
Paul Nasrat 090344
+	  ptr += len;
Paul Nasrat 090344
+
Paul Nasrat 090344
 	      elf_flagdata (debug_sections[DEBUG_STR].elf_data,
Paul Nasrat 090344
 			    ELF_C_SET, ELF_F_DIRTY);
Paul Nasrat 090344
 	    }
Paul Nasrat 090344
-	  else if (ptr != srcptr)
Paul Nasrat 090344
-	    memmove (ptr, srcptr, len);
Paul Nasrat 090344
-	  srcptr += len;
Paul Nasrat 090344
-	  ptr += len;
Paul Nasrat 090344
+
Paul Nasrat 090344
+      if (shrank > 0)
Paul Nasrat 090344
+	{
Paul Nasrat 090344
+	  if (--shrank == 0)
Paul Nasrat 090344
+	    error (EXIT_FAILURE, 0,
Paul Nasrat 090344
+		   "canonicalization unexpectedly shrank by one character");
Paul Nasrat 090344
+	  memset (ptr, 'X', shrank);
Paul Nasrat 090344
+	  ptr += shrank;
Paul Nasrat 090344
+	  *ptr++ = '\0';
Paul Nasrat 090344
 	}
Paul Nasrat 090344
 
Paul Nasrat 090344
       if (abs_dir_cnt + abs_file_cnt != 0)