rpm/finddebuginfo.diff

103 lines
3.4 KiB
Diff

SUSE specific find-debuginfo changes.
--- ./scripts/find-debuginfo.sh.orig 2005-07-14 15:52:31.000000000 +0000
+++ ./scripts/find-debuginfo.sh 2006-03-17 13:13:03.000000000 +0000
@@ -14,9 +14,18 @@ debugdir="${RPM_BUILD_ROOT}/usr/lib/debu
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
@@ -25,6 +34,8 @@ do
[ -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,
@@ -34,19 +45,56 @@ do
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
+ *.ko|*.a) strip_option="--strip-debug" ;;
+ esac
+ if test -n "$STRIP_KEEP_SYMTAB" ; then
+ strip_option="--strip-debug"
fi
+ if test "$NO_DEBUGINFO_STRIP_DEBUG" = true ; then
+ strip_option=
+ fi
+ objcopy --add-gnu-debuglink=$debugfn $strip_option $f || :
+ chmod $mode $f
done
+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
+
+
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
-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
+# 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
+
+{
+ 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