mingw64-filesystem/mingw64-find-debuginfo.sh
Ralf Habacker 222d8d5142 Accepting request 1071509 from home:rhabacker:branches:windows:mingw:win64:cmake-fixes
- Update to version 20230309
  * Let cmake macros be based on associated macros from macros.cmake
  * Add support to define a custom rpm macro when running mingw64
    related shell scripts, see mingw64-scripts.sh for details
  * Drop using external dependency generator (boo#1175587)
  * Add mingw64_*.attr files to support actual used dependency generator
  * Fix bug that rpm does not use attribute file for cmake by renaming
    to mingw64_cmake.attr (rpm does not like '-' in those file name
    and keys inside)
  * Extend mingw64_cmake.attr to find cmake support files in
    share subdirectory as required for example by mingw64-dlfcn-win32
  * Print deprecated message when using %_mingw64_makeinstall or
    %__mingw64_cmake
  * Reduce some differences to mingw32 in changes and other files,
    which are mostly indentions, hours, trailing '/', variable
    definition rows - make it easier to compare

OBS-URL: https://build.opensuse.org/request/show/1071509
OBS-URL: https://build.opensuse.org/package/show/windows:mingw:win64/mingw64-filesystem?expand=0&rev=153
2023-03-15 21:41:19 +00:00

103 lines
2.5 KiB
Bash

#!/bin/sh
#mingw64-find-debuginfo.sh - automagically generate debug info and file list
#for inclusion in an rpm spec file for mingw64-* packages.
#
# $PWD package dir below $BUILDDIR
target="mingw64"
host="x86_64-w64-mingw32"
# speed up running objdump, see bug https://bugzilla.opensuse.org/show_bug.cgi?id=1202431
export MALLOC_CHECK_=0
export MALLOC_PERTURB_=0
BUILDDIR=.
if [ -n "$1" ]; then
BUILDDIR="$1"
fi
# 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"
SOURCE_DIR="${ROOT_DIR}/src"
DEBUGSOURCE_DIR="${SOURCE_DIR}/debug"
for f in `find $RPM_BUILD_ROOT -type f -name "*.exe" -or -name "*.dll" | sort`
do
case $("$host-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
echo extracting debug info from $f
# grep all listed source files belonging to this package into temporary source file list.
"$host-objdump" -Wi "$f" | "$host-objdump-srcfiles" | grep $srcdir >>"$SOURCEFILE.tmp"
"$host-objcopy" --only-keep-debug "$f" "$f.debug" || :
pushd `dirname $f`
"$host-objcopy" --add-gnu-debuglink=`basename "$f.debug"` --strip-unneeded `basename "$f"` || :
popd
done
if [ ! -e "$BUILDDIR" ]; then
mkdir -p "$BUILDDIR"
fi
find $RPM_BUILD_ROOT -type f \
-name "*.exe.debug" \
-or -name "*.dll.debug" \
-or -name "*.exe.mdb" \
-or -name "*.dll.mdb" \
| sort \
| sed -n -e "s#^$RPM_BUILD_ROOT##p" > $BUILDDIR/$target-debugfiles.list
echo creating debugsource file structure
destdir=${RPM_BUILD_ROOT}${DEBUGSOURCE_DIR}
if [ ! -e "$destdir" ]; then
install -d "$destdir"
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
install -d "$p"
fi
echo copying $f to $o
install -m 644 $f $o
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