rpm/debugsource-package.diff

108 lines
3.7 KiB
Diff

Subject: Split sources for debugging into separate -debugsource package
At the moment the -debuginfo package also include the sources where used to
build the binary. The patches moves them into a separate package -debugsource.
---
macros.in | 12 ++++++++++++
scripts/find-debuginfo.sh | 39 ++++++++++++++++++++++++---------------
2 files changed, 36 insertions(+), 15 deletions(-)
Index: b/macros.in
===================================================================
--- a/macros.in
+++ b/macros.in
@@ -179,6 +179,18 @@ Debug information is useful when develop
package or when debugging this package.\
%files debuginfo -f debugfiles.list\
%defattr(-,root,root)\
+\
+%package debugsource\
+Summary: Debug sources for package %{name}\
+Group: Development/Debug\
+AutoReqProv: 0\
+Requires: %{name}-debuginfo = %{version}-%{release}\
+%description debugsource\
+This package provides debug sources for package %{name}.\
+Debug sources are useful when developing applications that use this\
+package or when debugging this package.\
+%files debugsource -f debugsources.list\
+%defattr(-,root,root)\
%{nil}
%_defaultdocdir %{_usr}/doc/packages
Index: b/scripts/find-debuginfo.sh
===================================================================
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -7,11 +7,13 @@ else BUILDDIR=$1
fi
LISTFILE=$BUILDDIR/debugfiles.list
-SOURCEFILE=$BUILDDIR/debugsources.list
+LISTSOURCE=$BUILDDIR/debugsources.list
debugdir="${RPM_BUILD_ROOT}/usr/lib/debug"
+debugsrcdir="${RPM_BUILD_ROOT}/usr/src/debug"
-echo -n > $SOURCEFILE
+[ -d "$TMPDIR" ] || TMPDIR="/tmp"
+SOURCES_TMP=`mktemp $TMPDIR/rpmXXXXXX`
# Strip ELF binaries
for f in `find $RPM_BUILD_ROOT ! -path "${debugdir}/*.debug" -type f \( -perm +111 -or -name "*.so*" -or -name "*.ko" \) `
@@ -36,7 +38,8 @@ do
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"
+ /usr/lib/rpm/debugedit -b "$RPM_BUILD_DIR" -d $(echo ${debugsrcdir} | \
+ sed -n -e "s#^$RPM_BUILD_ROOT##p") -l "$SOURCES_TMP" "$f"
# A binary already copied into /usr/lib/debug doesn't get stripped,
# just has its file names collected and adjusted.
@@ -75,12 +78,25 @@ done
# mv "$f" "${debugdn}"
#done
+# fixup paths, just in case ?!
+find ${debugdir} -type d -print0 | xargs -0 -r chmod 0755
+find ${debugdir} -type f -print0 | xargs -0 -r chmod 0644
+
+find ${debugdir} -mindepth 1 -maxdepth 1 | \
+ sed -n -e "s#^$RPM_BUILD_ROOT##p" > $LISTFILE
-mkdir -p ${RPM_BUILD_ROOT}/usr/src/debug
-(cd $RPM_BUILD_DIR; LANG=C sort -z -u | cpio -pd0m ${RPM_BUILD_ROOT}/usr/src/debug) < $SOURCEFILE
+
+if [ -s "$SOURCES_TMP" ] ; then
+ # strip GCC built-in code from sources list
+ (cd $RPM_BUILD_DIR && LANG=C sort -z -u | grep -z -v "<built-in>" | \
+ cpio -pd0m ${debugsrcdir} ) < $SOURCES_TMP
+ # stupid cpio creates new directories in mode 0700, fixup
+ find ${debugsrcdir} -type d -print0 | xargs -0 -r chmod 0755
+ find ${debugsrcdir} -type f -print0 | xargs -0 -r chmod 0644
+fi
# trying to replace dangling and/or absolute symlink
-DBASE=${RPM_BUILD_ROOT}/usr/src/debug
+DBASE=${debugsrcdir}
for link in `find $DBASE -type l -printf "%P\n"` ; do
link_file=`readlink $RPM_BUILD_DIR/$link`
case $link_file in
@@ -93,12 +109,5 @@ for link in `find $DBASE -type l -printf
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
+find ${debugsrcdir} -mindepth 1 -maxdepth 1 | \
+ sed -n -e "s#^$RPM_BUILD_ROOT##p" > $LISTSOURCE