aboutsummaryrefslogtreecommitdiffstats
path: root/find-debuginfo.sh
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2005-04-26 23:25:40 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2005-04-26 23:25:40 +0000
commit3d18e198d27190a4bfe8acd66518773acc39f4d7 (patch)
tree668f3f5db61491526cefc7d6372f7c5bebc99e90 /find-debuginfo.sh
parent14106b93fcb2cae4a8c164a5b4030b274966b422 (diff)
downloadrpm-setup-3d18e198d27190a4bfe8acd66518773acc39f4d7.tar
rpm-setup-3d18e198d27190a4bfe8acd66518773acc39f4d7.tar.gz
rpm-setup-3d18e198d27190a4bfe8acd66518773acc39f4d7.tar.bz2
rpm-setup-3d18e198d27190a4bfe8acd66518773acc39f4d7.tar.xz
rpm-setup-3d18e198d27190a4bfe8acd66518773acc39f4d7.zip
- import
Diffstat (limited to 'find-debuginfo.sh')
-rwxr-xr-xfind-debuginfo.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/find-debuginfo.sh b/find-debuginfo.sh
new file mode 100755
index 0000000..fd5c8d2
--- /dev/null
+++ b/find-debuginfo.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#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
+fi
+
+LISTFILE=$BUILDDIR/debugfiles.list
+SOURCEFILE=$BUILDDIR/debugsources.list
+
+debugdir="${RPM_BUILD_ROOT}/usr/lib/debug"
+
+echo -n > $SOURCEFILE
+
+[[ -n "$EXCLUDE_FROM_STRIP" ]] && \
+EXCLUDE_REGEXP=`perl -e 'print "(", join("|", @ARGV), ")"' $EXCLUDE_FROM_STRIP`
+
+# Strip ELF binaries
+for f in `find $RPM_BUILD_ROOT -path "${debugdir}" -prune -o -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \
+ sed -n -e 's/^\(.*\):[ ]*.*ELF.* executable.*, 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
+
+ mkdir -p "${debugdn}"
+ echo extracting debug info from $f
+ /usr/lib/rpm/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug -l "$SOURCEFILE" "$f"
+ if test -w "$f"; then
+ eu-strip -f "${debugfn}" "$f" -o $f.stripped || :
+ else
+ chmod u+w "$f"
+ eu-strip -f "${debugfn}" "$f" -o $f.stripped || :
+ chmod u-w "$f"
+ fi
+ [[ -n "$EXCLUDE_REGEXP" ]] && \
+ { echo $f | egrep -qv "$EXCLUDE_REGEXP"; } && mv -f $f.stripped $f
+ rm -f $f.stripped
+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
+
+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