2009-04-08 13:11:27 +00:00
|
|
|
#!/bin/sh
|
2014-10-29 10:43:48 +00:00
|
|
|
#mingw64-find-debuginfo.sh - automagically generate debug info and file list
|
2009-04-08 13:11:27 +00:00
|
|
|
#for inclusion in an rpm spec file for mingw64-* packages.
|
2014-10-22 15:39:25 +00:00
|
|
|
target="mingw64"
|
|
|
|
host="x86_64-w64-mingw32"
|
2009-04-08 13:11:27 +00:00
|
|
|
|
2014-10-22 17:10:08 +00:00
|
|
|
BUILDDIR=.
|
2014-10-23 05:33:28 +00:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
BUILDDIR="$1"
|
|
|
|
fi
|
2009-04-08 13:11:27 +00:00
|
|
|
|
2017-07-20 11:19:10 +00:00
|
|
|
# generate separate debuginfo and debugsource or single debug package combining both
|
|
|
|
if [ -n "$2" ]; then
|
|
|
|
SINGLE_DEBUG_PACKAGE=1
|
|
|
|
else
|
|
|
|
SINGLE_DEBUG_PACKAGE=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
SOURCEFILE="$BUILDDIR/$target-debugsources.list"
|
|
|
|
> "$SOURCEFILE"
|
|
|
|
> $SOURCEFILE.tmp
|
|
|
|
|
|
|
|
srcdir=`realpath $PWD`
|
|
|
|
|
|
|
|
ROOT_DIR="/usr/$host/sys-root/mingw"
|
|
|
|
SYMBOL_DIR="${ROOT_DIR}/symbols"
|
|
|
|
SOURCE_DIR="${ROOT_DIR}/src"
|
|
|
|
DEBUGSOURCE_DIR="${SOURCE_DIR}/debug"
|
2014-08-28 13:44:57 +00:00
|
|
|
|
2009-04-08 13:11:27 +00:00
|
|
|
for f in `find $RPM_BUILD_ROOT -type f -name "*.exe" -or -name "*.dll"`
|
|
|
|
do
|
2014-10-22 15:39:25 +00:00
|
|
|
case $("$host-objdump" -h "$f" 2>/dev/null | egrep -o '(debug[\.a-z_]*|gnu.version)') in
|
2009-04-08 13:11:27 +00:00
|
|
|
*debuglink*) continue ;;
|
|
|
|
*debug*) ;;
|
|
|
|
*gnu.version*)
|
|
|
|
echo "WARNING: "`echo $f | sed -e "s,^$RPM_BUILD_ROOT/*,/,"`" is already stripped!"
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
*) continue ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo extracting debug info from $f
|
2014-08-28 08:51:03 +00:00
|
|
|
|
|
|
|
# breakpad symbols
|
2017-07-20 11:19:10 +00:00
|
|
|
symfile=`"$host-gen_sym_files" "$f" "$RPM_BUILD_ROOT$SYMBOL_DIR"`
|
|
|
|
echo $symfile
|
|
|
|
# grep all listed source files belonging to this package into temporary source file list
|
|
|
|
cat $symfile | grep "FILE" | cut -d' ' -f3 | grep $srcdir >> $SOURCEFILE.tmp
|
|
|
|
# remap file path in symbol file to src debug location
|
|
|
|
# we remap all files to make finding src files from other packages possible
|
|
|
|
sed -i "s,$BUILDDIR,$DEBUGSOURCE_DIR,g" $symfile
|
2014-08-28 08:51:03 +00:00
|
|
|
|
2014-10-22 15:39:25 +00:00
|
|
|
"$host-objcopy" --only-keep-debug "$f" "$f.debug" || :
|
2009-04-08 13:11:27 +00:00
|
|
|
pushd `dirname $f`
|
2014-10-22 15:39:25 +00:00
|
|
|
"$host-objcopy" --add-gnu-debuglink=`basename "$f.debug"` --strip-unneeded `basename "$f"` || :
|
2009-04-08 13:11:27 +00:00
|
|
|
popd
|
|
|
|
done
|
|
|
|
|
2014-10-29 10:43:48 +00:00
|
|
|
if [ ! -e "$BUILDDIR" ]; then
|
2014-10-23 05:33:28 +00:00
|
|
|
mkdir -p "$BUILDDIR"
|
|
|
|
fi
|
2014-08-28 08:51:03 +00:00
|
|
|
find $RPM_BUILD_ROOT -type f \
|
|
|
|
-name "*.exe.debug" \
|
|
|
|
-or -name "*.dll.debug" \
|
|
|
|
-or -name "*.exe.mdb" \
|
|
|
|
-or -name "*.dll.mdb" \
|
2014-10-22 15:39:25 +00:00
|
|
|
| sed -n -e "s#^$RPM_BUILD_ROOT##p" >"$BUILDDIR/$target-debugfiles.list"
|
2009-04-08 13:11:27 +00:00
|
|
|
|
2014-08-30 08:59:12 +00:00
|
|
|
if [ -e "$RPM_BUILD_ROOT/$SYMBOL_DIR" ]; then
|
2014-10-22 15:39:25 +00:00
|
|
|
echo "$SYMBOL_DIR" >>"$BUILDDIR/$target-debugfiles.list"
|
2014-08-30 08:59:12 +00:00
|
|
|
fi
|
2017-07-20 11:19:10 +00:00
|
|
|
|
|
|
|
echo creating debugsource file structure
|
|
|
|
|
|
|
|
destdir=${RPM_BUILD_ROOT}${DEBUGSOURCE_DIR}
|
|
|
|
if [ ! -e "$destdir" ]; then
|
2017-07-21 06:35:07 +00:00
|
|
|
install -d "$destdir"
|
2017-07-20 11:19:10 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
for f in `cat $SOURCEFILE.tmp | sort | uniq`
|
|
|
|
do
|
|
|
|
if ! test -f "$f"; then
|
|
|
|
echo "excluded not present file '$f"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
o=`echo $f | sed "s,$BUILDDIR,$destdir,g"`
|
|
|
|
p=`dirname $o`
|
|
|
|
if [ ! -e "$p" ]; then
|
2017-07-21 06:35:07 +00:00
|
|
|
install -d "$p"
|
2017-07-20 11:19:10 +00:00
|
|
|
fi
|
|
|
|
echo copying $f to $o
|
2017-07-21 06:35:07 +00:00
|
|
|
install -m 644 $f $o
|
2017-07-20 11:19:10 +00:00
|
|
|
# create debugsource.list
|
|
|
|
# we do not add each single file, see below
|
|
|
|
# echo $o | sed "s,${RPM_BUILD_ROOT},,g" >> $SOURCEFILE
|
|
|
|
done
|
|
|
|
rm $SOURCEFILE.tmp
|
|
|
|
|
|
|
|
# add package source directory to list of files
|
|
|
|
if [ -e "$RPM_BUILD_ROOT/$DEBUGSOURCE_DIR" ]; then
|
|
|
|
echo "%dir $SOURCE_DIR" >> $SOURCEFILE
|
|
|
|
echo "$DEBUGSOURCE_DIR" >> $SOURCEFILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$SINGLE_DEBUG_PACKAGE" -eq 1; then
|
|
|
|
cat $SOURCEFILE >> $BUILDDIR/$target-debugfiles.list
|
|
|
|
rm $SOURCEFILE*
|
|
|
|
fi
|