SOURCES (rpm-4_5): rpm-debuginfo.patch, rpm-new-debuginfo.patch (NEW) build...

arekm arekm at pld-linux.org
Mon Mar 23 09:32:04 CET 2009


Author: arekm                        Date: Mon Mar 23 08:32:04 2009 GMT
Module: SOURCES                       Tag: rpm-4_5
---- Log message:
build-id aware debuginfo finding (but bashizms (TODO))

---- Files affected:
SOURCES:
   rpm-debuginfo.patch (1.15.6.7.2.4 -> 1.15.6.7.2.5) , rpm-new-debuginfo.patch (NONE -> 1.1.2.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/rpm-debuginfo.patch
diff -u SOURCES/rpm-debuginfo.patch:1.15.6.7.2.4 SOURCES/rpm-debuginfo.patch:1.15.6.7.2.5
--- SOURCES/rpm-debuginfo.patch:1.15.6.7.2.4	Sat Oct  4 23:57:00 2008
+++ SOURCES/rpm-debuginfo.patch	Mon Mar 23 09:31:59 2009
@@ -45,108 +45,3 @@
      %{__arch_install_post}\
      %{__os_install_post}\
  %{nil}
---- rpm-4.5.debuginfo/scripts/find-debuginfo.sh	2007-08-31 04:07:02.000000000 +0300
-+++ rpm-4.5/scripts/find-debuginfo.sh	2008-10-05 00:49:03.834523059 +0300
-@@ -1,36 +1,54 @@
- #!/bin/sh
--#find-debuginfo.sh - automagically generate debug info and file list
--#for inclusion in an rpm spec file.
-+# find-debuginfo.sh - automagically generate debug info and file list
-+# for inclusion in an rpm spec file.
- 
--if [ -z "$1" ] ; then BUILDDIR="."
--else BUILDDIR=$1
-+if [ -z "$1" ]; then
-+   	BUILDDIR="."
-+else
-+   	BUILDDIR=$1
- fi
- 
- LISTFILE=$BUILDDIR/debugfiles.list
- SOURCEFILE=$BUILDDIR/debugsources.list
- 
--debugdir="${RPM_BUILD_ROOT}/usr/lib/debug"
--
--echo -n > $SOURCEFILE
-+: > $SOURCEFILE
-+: > $LISTFILE
- 
- strip_to_debug()
- {
--  eu-strip --remove-comment -f "$1" "$2" || :
-+  objcopy --only-keep-debug --remove-section .comment "$2" "$1"
-+  objcopy --add-gnu-debuglink="$1" "$2"
- }
- 
-+if [ ! -d $RPM_BUILD_ROOT ]; then
-+	# no buildroot, exit
-+	exit 0
-+fi
-+
-+filelist=$(find $RPM_BUILD_ROOT ! -path "$RPM_BUILD_ROOT/usr/lib/debug/*.debug" -type f '(' -perm -0100 -or -perm -0010 -or -perm -0001 ')')
-+if [ -z "$filelist" ]; then
-+	# no files, exit
-+	exit 0
-+fi
-+
-+filetypes=$(echo "$filelist" | xargs -r -d'\n' file)
-+elflist=$(echo "$filetypes" | awk -F: '/ELF.*, not stripped/ {print $1}')
-+if [ -z "$elflist" ]; then
-+	# no elf objects, exit
-+	exit 0
-+fi
-+
- # 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'`
--do
--	dn=$(dirname $f | sed -n -e "s#^$RPM_BUILD_ROOT##p")
--	bn=$(basename $f .debug).debug
--
--	debugdn="${debugdir}${dn}"
--	debugfn="${debugdn}/${bn}"
--	[ -f "${debugfn}" ] && continue
-+echo "$elflist" | while read f; do
-+	dn=$(dirname "${f#$RPM_BUILD_ROOT}")
-+	bn=$(basename "$f" .debug).debug
-+
-+	debugdn="$RPM_BUILD_ROOT/usr/lib/debug$dn"
-+	debugfn="$debugdn/$bn"
-+	[ -f "$debugfn" ] && continue
- 
- 	echo extracting debug info from $f
--	/usr/lib/rpm/4.5/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug -l "$SOURCEFILE" "$f"
-+	/usr/lib/rpm/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug -l "$SOURCEFILE" "$f"
- 
- 	# A binary already copied into /usr/lib/debug doesn't get stripped,
- 	# just has its file names collected and adjusted.
-@@ -38,20 +56,21 @@
- 	/usr/lib/debug/*) continue ;;
- 	esac
- 
--	mkdir -p "${debugdn}"
-+	mkdir -p "$debugdn"
- 	if test -w "$f"; then
--		strip_to_debug "${debugfn}" "$f"
-+		strip_to_debug "$debugfn" "$f"
- 	else
- 		chmod u+w "$f"
--		strip_to_debug "${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 -pd0mL ${RPM_BUILD_ROOT}/usr/src/debug)
-+mkdir -p $RPM_BUILD_ROOT/usr/src/debug
-+cat $SOURCEFILE | (cd $RPM_BUILD_DIR; LANG=C sort -z -u | fgrep -zv '<built-in>' | cpio --quiet -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
-+find $RPM_BUILD_ROOT/usr/src/debug -type d -print0 | xargs -0 chmod a+rx
- 
--find ${RPM_BUILD_ROOT}/usr/lib/debug -type f | sed -n -e "s#^$RPM_BUILD_ROOT##p" > $LISTFILE
--find ${RPM_BUILD_ROOT}/usr/src/debug -mindepth 1 -maxdepth 1 | sed -n -e "s#^$RPM_BUILD_ROOT##p" >> $LISTFILE
-+find $RPM_BUILD_ROOT/usr/lib/debug -type f | sed -n -e "s#^$RPM_BUILD_ROOT##p" > $LISTFILE
-+find $RPM_BUILD_ROOT/usr/lib/debug -mindepth 1 -type d | sed -n -e "s#^$RPM_BUILD_ROOT#%dir #p" >> $LISTFILE
-+find $RPM_BUILD_ROOT/usr/src/debug -mindepth 1 -maxdepth 1 | sed -n -e "s#^$RPM_BUILD_ROOT##p" >> $LISTFILE

================================================================
Index: SOURCES/rpm-new-debuginfo.patch
diff -u /dev/null SOURCES/rpm-new-debuginfo.patch:1.1.2.1
--- /dev/null	Mon Mar 23 09:32:06 2009
+++ SOURCES/rpm-new-debuginfo.patch	Mon Mar 23 09:31:58 2009
@@ -0,0 +1,391 @@
+--- rpm-4.5/macros.in.org	2009-03-23 09:25:24.383581794 +0100
++++ rpm-4.5/macros.in	2009-03-23 09:25:19.403234944 +0100
+@@ -183,7 +183,7 @@
+ #	Path to script that creates debug symbols in a /usr/lib/debug
+ #	shadow tree.
+ %__debug_install_post   \
+-   %{_rpmhome}/find-debuginfo.sh %{_builddir}/%{?buildsubdir}\
++   %{_rpmhome}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
+ %{nil}
+ 
+ #	Template for debug information sub-package.
+--- rpm-4.5/scripts/find-debuginfo.sh.org	2009-03-23 09:17:40.543353186 +0100
++++ rpm-4.5/scripts/find-debuginfo.sh	2007-09-06 09:36:38.000000000 +0200
+@@ -1,57 +1,336 @@
+-#!/bin/sh
++#!/bin/bash
+ #find-debuginfo.sh - automagically generate debug info and file list
+ #for inclusion in an rpm spec file.
++#
++# Usage: find-debuginfo.sh [--strict-build-id] [-g]
++#	 		   [-o debugfiles.list]
++#			   [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
++#			   [builddir]
++#
++# The -g flag says to use strip -g instead of full strip on DSOs.
++# The --strict-build-id flag says to exit with failure status if
++# any ELF binary processed fails to contain a build-id note.
++#
++# A single -o switch before any -l or -p switches simply renames
++# the primary output file from debugfiles.list to something else.
++# A -o switch that follows a -p switch or some -l switches produces
++# an additional output file with the debuginfo for the files in
++# the -l filelist file, or whose names match the -p pattern.
++# The -p argument is an egrep-style regexp matching the a file name,
++# and must not use anchors (^ or $).
++#
++# All file names in switches are relative to builddir (. if not given).
++#
++
++# With -g arg, pass it to strip on libraries.
++strip_g=false
++
++# Barf on missing build IDs.
++strict=false
++
++BUILDDIR=.
++out=debugfiles.list
++nout=0
++while [ $# -gt 0 ]; do
++  case "$1" in
++  --strict-build-id)
++    strict=true
++    ;;
++  -g)
++    strip_g=true
++    ;;
++  -o)
++    if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then
++      out=$2
++    else
++      outs[$nout]=$2
++      ((nout++))
++    fi
++    shift
++    ;;
++  -l)
++    lists[$nout]="${lists[$nout]} $2"
++    shift
++    ;;
++  -p)
++    ptns[$nout]=$2
++    shift
++    ;;
++  *)
++    BUILDDIR=$1
++    shift
++    break
++    ;;
++  esac
++  shift
++done
+ 
+-if [ -z "$1" ] ; then BUILDDIR="."
+-else BUILDDIR=$1
+-fi
++i=0
++while ((i < nout)); do
++  outs[$i]="$BUILDDIR/${outs[$i]}"
++  l=''
++  for f in ${lists[$i]}; do
++    l="$l $BUILDDIR/$f"
++  done
++  lists[$i]=$l
++  ((++i))
++done
+ 
+-LISTFILE=$BUILDDIR/debugfiles.list
+-SOURCEFILE=$BUILDDIR/debugsources.list
++LISTFILE="$BUILDDIR/$out"
++SOURCEFILE="$BUILDDIR/debugsources.list"
++LINKSFILE="$BUILDDIR/debuglinks.list"
++
++> "$SOURCEFILE"
++> "$LISTFILE"
++> "$LINKSFILE"
+ 
+ debugdir="${RPM_BUILD_ROOT}/usr/lib/debug"
+ 
+-echo -n > $SOURCEFILE
+-
+ strip_to_debug()
+ {
+-  eu-strip --remove-comment -f "$1" "$2" || :
++  local g=
++  $strip_g && case "$(file -bi "$2")" in
++  application/x-sharedlib,*) g=-g ;;
++  esac
++  eu-strip --remove-comment $g -f "$1" "$2" || exit
++}
++
++# Make a relative symlink to $1 called $3$2
++shopt -s extglob
++link_relative()
++{
++  local t="$1" f="$2" pfx="$3"
++  local fn="${f#/}" tn="${t#/}"
++  local fd td d
++
++  while fd="${fn%%/*}"; td="${tn%%/*}"; [ "$fd" = "$td" ]; do
++    fn="${fn#*/}"
++    tn="${tn#*/}"
++  done
++
++  d="${fn%/*}"
++  if [ "$d" != "$fn" ]; then
++    d="${d//+([!\/])/..}"
++    tn="${d}/${tn}"
++  fi
++
++  mkdir -p "$(dirname "$pfx$f")" && ln -snf "$tn" "$pfx$f"
+ }
+ 
++# Make a symlink in /usr/lib/debug/$2 to $1
++debug_link()
++{
++  local l="/usr/lib/debug$2"
++  local t="$1"
++  echo >> "$LINKSFILE" "$l $t"
++  link_relative "$t" "$l" "$RPM_BUILD_ROOT"
++}
++
++# Make a build-id symlink for id $1 with suffix $3 to file $2.
++make_id_link()
++{
++  local id="$1" file="$2"
++  local idfile=".build-id/${id:0:2}/${id:2}"
++  [ $# -eq 3 ] && idfile="${idfile}$3"
++  local root_idfile="$RPM_BUILD_ROOT/usr/lib/debug/$idfile"
++
++  if [ ! -L "$root_idfile" ]; then
++    debug_link "$file" "/$idfile"
++    return
++  fi
++
++  [ $# -eq 3 ] && return 0
++
++  local other=$(readlink -m "$root_idfile")
++  other=${other#$RPM_BUILD_ROOT}
++  if cmp -s "$root_idfile" "$RPM_BUILD_ROOT$file" ||
++     eu-elfcmp -q "$root_idfile" "$RPM_BUILD_ROOT$file" 2> /dev/null; then
++    # Two copies.  Maybe one has to be setuid or something.
++    echo >&2 "*** WARNING: identical binaries are copied, not linked:"
++    echo >&2 "        $file"
++    echo >&2 "   and  $other"
++  else
++    # This is pathological, break the build.
++    echo >&2 "*** ERROR: same build ID in nonidentical files!"
++    echo >&2 "        $file"
++    echo >&2 "   and  $other"
++    exit 2
++  fi
++}
++
++get_debugfn()
++{
++  dn=$(dirname "${1#$RPM_BUILD_ROOT}")
++  bn=$(basename "$1" .debug).debug
++
++  debugdn=${debugdir}${dn}
++  debugfn=${debugdn}/${bn}
++}
++
++set -o pipefail
++
++strict_error=ERROR
++$strict || strict_error=WARNING
++
+ # 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'`
++find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \
++     		     \( -perm -0100 -or -perm -0010 -or -perm -0001 \) \
++		     -print |
++file -N -f - | sed -n -e 's/^\(.*\):[ 	]*.*ELF.*, not stripped/\1/p' |
++xargs --no-run-if-empty stat -c '%h %D_%i %n' |
++while read nlinks inum f; do
++  get_debugfn "$f"
++  [ -f "${debugfn}" ] && continue
++
++  # If this file has multiple links, keep track and make
++  # the corresponding .debug files all links to one file too.
++  if [ $nlinks -gt 1 ]; then
++    eval linked=\$linked_$inum
++    if [ -n "$linked" ]; then
++      link=$debugfn
++      get_debugfn "$linked"
++      echo "hard linked $link to $debugfn"
++      ln -nf "$debugfn" "$link"
++      continue
++    else
++      eval linked_$inum=\$f
++      echo "file $f has $[$nlinks - 1] other hard links"
++    fi
++  fi
++
++  echo "extracting debug info from $f"
++  id=$(/usr/lib/rpm/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug \
++			      -i -l "$SOURCEFILE" "$f") || exit
++  if [ -z "$id" ]; then
++    echo >&2 "*** ${strict_error}: No build ID note found in $f"
++    $strict && exit 2
++  fi
++
++  # A binary already copied into /usr/lib/debug doesn't get stripped,
++  # just has its file names collected and adjusted.
++  case "$dn" in
++  /usr/lib/debug/*)
++    [ -z "$id" ] || make_id_link "$id" "$dn/$(basename $f)"
++    continue ;;
++  esac
++
++  mkdir -p "${debugdn}"
++  if test -w "$f"; then
++    strip_to_debug "${debugfn}" "$f"
++  else
++    chmod u+w "$f"
++    strip_to_debug "${debugfn}" "$f"
++    chmod u-w "$f"
++  fi
++
++  if [ -n "$id" ]; then
++    make_id_link "$id" "$dn/$(basename $f)"
++    make_id_link "$id" "/usr/lib/debug$dn/$bn" .debug
++  fi
++done || exit
++
++# For each symlink whose target has a .debug file,
++# make a .debug symlink to that file.
++find $RPM_BUILD_ROOT ! -path "${debugdir}/*" -type l -print |
++while read f
+ do
+-	dn=$(dirname $f | sed -n -e "s#^$RPM_BUILD_ROOT##p")
+-	bn=$(basename $f .debug).debug
+-
+-	debugdn="${debugdir}${dn}"
+-	debugfn="${debugdn}/${bn}"
+-	[ -f "${debugfn}" ] && continue
+-
+-	echo extracting debug info from $f
+-	/usr/lib/rpm/4.5/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug -l "$SOURCEFILE" "$f"
+-
+-	# A binary already copied into /usr/lib/debug doesn't get stripped,
+-	# just has its file names collected and adjusted.
+-	case "$dn" in
+-	/usr/lib/debug/*) continue ;;
+-	esac
+-
+-	mkdir -p "${debugdn}"
+-	if test -w "$f"; then
+-		strip_to_debug "${debugfn}" "$f"
+-	else
+-		chmod u+w "$f"
+-		strip_to_debug "${debugfn}" "$f"
+-		chmod u-w "$f"
+-	fi
++  t=$(readlink -m "$f").debug
++  f=${f#$RPM_BUILD_ROOT}
++  t=${t#$RPM_BUILD_ROOT}
++  if [ -f "$debugdir$t" ]; then
++    echo "symlinked /usr/lib/debug$t to /usr/lib/debug${f}.debug"
++    debug_link "/usr/lib/debug$t" "${f}.debug"
++  fi
+ done
+ 
+-mkdir -p ${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
++if [ -s "$SOURCEFILE" ]; then
++  mkdir -p "${RPM_BUILD_ROOT}/usr/src/debug"
++  LC_ALL=C sort -z -u "$SOURCEFILE" | egrep -v -z '(<internal>|<built-in>)$' |
++  (cd "$RPM_BUILD_DIR"; 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 --no-run-if-empty -0 chmod a+rx
++fi
++
++if [ -d "${RPM_BUILD_ROOT}/usr/lib" -o -d "${RPM_BUILD_ROOT}/usr/src" ]; then
++  ((nout > 0)) ||
++  test ! -d "${RPM_BUILD_ROOT}/usr/lib" ||
++  (cd "${RPM_BUILD_ROOT}/usr/lib"; find debug -type d) |
++  sed 's,^,%dir /usr/lib/,' >> "$LISTFILE"
++
++  (cd "${RPM_BUILD_ROOT}/usr"
++   test ! -d lib/debug || find lib/debug ! -type d
++   test ! -d src/debug || find src/debug -mindepth 1 -maxdepth 1
++  ) | sed 's,^,/usr/,' >> "$LISTFILE"
++fi
++
++# Append to $1 only the lines from stdin not already in the file.
++append_uniq()
++{
++  fgrep -f "$1" -x -v >> "$1"
++}
+ 
+-find ${RPM_BUILD_ROOT}/usr/lib/debug -type f | sed -n -e "s#^$RPM_BUILD_ROOT##p" > $LISTFILE
+-find ${RPM_BUILD_ROOT}/usr/src/debug -mindepth 1 -maxdepth 1 | sed -n -e "s#^$RPM_BUILD_ROOT##p" >> $LISTFILE
++# Helper to generate list of corresponding .debug files from a file list.
++filelist_debugfiles()
++{
++  local extra="$1"
++  shift
++  sed 's/^%[a-z0-9_][a-z0-9_]*([^)]*) *//
++s/^%[a-z0-9_][a-z0-9_]* *//
++/^$/d
++'"$extra" "$@"
++}
++
++# Write an output debuginfo file list based on given input file lists.
++filtered_list()
++{
++  local out="$1"
++  shift
++  test $# -gt 0 || return
++  fgrep -f <(filelist_debugfiles 's,^.*$,/usr/lib/debug&.debug,' "$@") \
++  	-x $LISTFILE >> $out
++  sed -n -f <(filelist_debugfiles 's/[\\.*+#]/\\&/g
++h
++s,^.*$,s# &$##p,p
++g
++s,^.*$,s# /usr/lib/debug&.debug$##p,p
++' "$@") "$LINKSFILE" | append_uniq "$out"
++}
++
++# Write an output debuginfo file list based on an egrep-style regexp.
++pattern_list()
++{
++  local out="$1" ptn="$2"
++  test -n "$ptn" || return
++  egrep -x -e "$ptn" "$LISTFILE" >> "$out"
++  sed -n -r "\#^$ptn #s/ .*\$//p" "$LINKSFILE" | append_uniq "$out"
++}
++
++#
++# When given multiple -o switches, split up the output as directed.
++#
++i=0
++while ((i < nout)); do
++  > ${outs[$i]}
++  filtered_list ${outs[$i]} ${lists[$i]}
++  pattern_list ${outs[$i]} "${ptns[$i]}"
++  fgrep -vx -f ${outs[$i]} "$LISTFILE" > "${LISTFILE}.new"
++  mv "${LISTFILE}.new" "$LISTFILE"
++  ((++i))
++done
++if ((nout > 0)); then
++  # Now add the right %dir lines to each output list.
++  (cd "${RPM_BUILD_ROOT}"; find usr/lib/debug -type d) |
++  sed 's#^.*$#\\@^/&/@{h;s@^.*$@%dir /&@p;g;}#' |
++  LC_ALL=C sort -ur > "${LISTFILE}.dirs.sed"
++  i=0
++  while ((i < nout)); do
++    sed -n -f "${LISTFILE}.dirs.sed" "${outs[$i]}" | sort -u > "${outs[$i]}.new"
++    cat "${outs[$i]}" >> "${outs[$i]}.new"
++    mv -f "${outs[$i]}.new" "${outs[$i]}"
++    ((++i))
++  done
++  sed -n -f "${LISTFILE}.dirs.sed" "${LISTFILE}" | sort -u > "${LISTFILE}.new"
++  cat "$LISTFILE" >> "${LISTFILE}.new"
++  mv "${LISTFILE}.new" "$LISTFILE"
++fi
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/rpm-debuginfo.patch?r1=1.15.6.7.2.4&r2=1.15.6.7.2.5&f=u



More information about the pld-cvs-commit mailing list