2008-04-09 18:18:03 +02:00
|
|
|
---
|
|
|
|
scripts/find-debuginfo.sh | 78 ++++++++++++++++++++++++++++++++++++++--------
|
|
|
|
1 file changed, 65 insertions(+), 13 deletions(-)
|
|
|
|
|
|
|
|
Index: scripts/find-debuginfo.sh
|
|
|
|
===================================================================
|
|
|
|
--- scripts/find-debuginfo.sh.orig
|
2007-04-20 15:59:58 +02:00
|
|
|
+++ scripts/find-debuginfo.sh
|
2008-04-09 18:18:03 +02:00
|
|
|
@@ -14,9 +14,18 @@ debugdir="${RPM_BUILD_ROOT}/usr/lib/debu
|
2006-12-19 00:17:44 +01:00
|
|
|
echo -n > $SOURCEFILE
|
|
|
|
|
|
|
|
# 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'`
|
|
|
|
+for f in `find $RPM_BUILD_ROOT ! -path "${debugdir}/*.debug" -type f \( -perm +111 -or -name "*.so*" -or -name "*.ko" \) `
|
|
|
|
do
|
|
|
|
+ case $(objdump -h $f 2>/dev/null | egrep -o '(debug[\.a-z_]*|gnu.version)') in
|
|
|
|
+ *debuglink*) continue ;;
|
|
|
|
+ *debug*) ;;
|
|
|
|
+ *gnu.version*)
|
|
|
|
+ echo "WARNING: "`echo $f | sed -e "s,^$RPM_BUILD_ROOT/*,/,"`" is already stripped!"
|
|
|
|
+ continue
|
|
|
|
+ ;;
|
|
|
|
+ *) continue ;;
|
|
|
|
+ esac
|
|
|
|
+
|
|
|
|
dn=$(dirname $f | sed -n -e "s#^$RPM_BUILD_ROOT##p")
|
|
|
|
bn=$(basename $f .debug).debug
|
|
|
|
|
2008-04-09 18:18:03 +02:00
|
|
|
@@ -25,6 +34,8 @@ do
|
2006-12-19 00:17:44 +01:00
|
|
|
[ -f "${debugfn}" ] && continue
|
|
|
|
|
|
|
|
echo extracting debug info from $f
|
|
|
|
+ mode=$(stat -c %a $f)
|
|
|
|
+ chmod +w $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,
|
2008-04-09 18:18:03 +02:00
|
|
|
@@ -34,19 +45,60 @@ do
|
2006-12-19 00:17:44 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
mkdir -p "${debugdn}"
|
|
|
|
- if test -w "$f"; then
|
|
|
|
- eu-strip -f "${debugfn}" "$f" || :
|
|
|
|
- else
|
|
|
|
- chmod u+w "$f"
|
|
|
|
- eu-strip -f "${debugfn}" "$f" || :
|
|
|
|
- chmod u-w "$f"
|
|
|
|
+ objcopy --only-keep-debug $f $debugfn || :
|
|
|
|
+ strip_option="--strip-all"
|
|
|
|
+ case "$f" in
|
2008-04-09 18:18:03 +02:00
|
|
|
+ *.ko)
|
2007-04-20 15:59:58 +02:00
|
|
|
+ strip_option="--strip-debug"
|
|
|
|
+ ;;
|
2007-04-23 23:21:13 +02:00
|
|
|
+ *$STRIP_KEEP_SYMTAB*)
|
|
|
|
+ if test -n "$STRIP_KEEP_SYMTAB"; then
|
|
|
|
+ strip_option="--strip-debug"
|
|
|
|
+ fi
|
|
|
|
+ ;;
|
|
|
|
+ esac
|
2006-12-19 00:17:44 +01:00
|
|
|
+ if test "$NO_DEBUGINFO_STRIP_DEBUG" = true ; then
|
|
|
|
+ strip_option=
|
2007-04-20 15:59:58 +02:00
|
|
|
fi
|
2006-12-19 00:17:44 +01:00
|
|
|
+ objcopy --add-gnu-debuglink=$debugfn $strip_option $f || :
|
|
|
|
+ chmod $mode $f
|
2007-04-23 23:21:13 +02:00
|
|
|
done
|
|
|
|
|
2008-01-29 01:44:43 +01:00
|
|
|
+#for f in `find $RPM_BUILD_ROOT ! -path "${debugdir}/*.debug" -type f \( -name "*.exe.mdb" -or -name "*.dll.mdb" \) `
|
|
|
|
+#do
|
|
|
|
+# dn=$(dirname $f | sed -n -e "s#^$RPM_BUILD_ROOT##p")
|
|
|
|
+# case "$dn" in
|
|
|
|
+# /usr/lib/debug/*) continue ;;
|
|
|
|
+# esac
|
|
|
|
+# debugdn="${debugdir}${dn}"
|
|
|
|
+# mkdir -p "${debugdn}"
|
|
|
|
+# mv "$f" "${debugdn}"
|
|
|
|
+#done
|
2007-04-23 23:21:13 +02:00
|
|
|
+
|
2006-12-19 00:17:44 +01:00
|
|
|
+
|
|
|
|
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)
|
|
|
|
-# stupid cpio creates new directories in mode 0700, fixup
|
|
|
|
-find ${RPM_BUILD_ROOT}/usr/src/debug -type d -print0 | xargs -0 chmod a+rx
|
|
|
|
+(cd $RPM_BUILD_DIR; LANG=C sort -z -u | cpio -pd0m ${RPM_BUILD_ROOT}/usr/src/debug) < $SOURCEFILE
|
2008-04-09 18:18:03 +02:00
|
|
|
|
|
|
|
-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
|
2006-12-19 00:17:44 +01:00
|
|
|
+# trying to replace dangling and/or absolute symlink
|
|
|
|
+DBASE=${RPM_BUILD_ROOT}/usr/src/debug
|
|
|
|
+for link in `find $DBASE -type l -printf "%P\n"` ; do
|
|
|
|
+ link_file=`readlink $RPM_BUILD_DIR/$link`
|
|
|
|
+ case $link_file in
|
|
|
|
+ /*) is_abs=true ;;
|
|
|
|
+ *) is_abs= ;;
|
|
|
|
+ esac
|
|
|
|
+ if test ! -e "$DBASE/$link" -o -n "$is_abs" ; then # dangling
|
|
|
|
+ rm -f "$DBASE/$link"
|
|
|
|
+ cp "`readlink -f $RPM_BUILD_DIR/$link`" "$DBASE/$link"
|
|
|
|
+ fi
|
|
|
|
+done
|
2008-04-09 18:18:03 +02:00
|
|
|
+
|
2006-12-19 00:17:44 +01:00
|
|
|
+{
|
|
|
|
+ test -d ${RPM_BUILD_ROOT}/usr/lib/debug && echo /usr/lib/debug
|
|
|
|
+ echo /usr/src/debug
|
|
|
|
+} > $LISTFILE
|
|
|
|
+
|
|
|
|
+for p in $(<$LISTFILE); do
|
|
|
|
+ find $RPM_BUILD_ROOT/$p -type f -print0 | xargs -0 -r chmod 0644
|
|
|
|
+ find $RPM_BUILD_ROOT/$p -type d -print0 | xargs -0 -r chmod 0755
|
|
|
|
+done
|