teknoraver / rpms / rpm

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