File wine_spec.patch of Package wine

--- wine.spec.920	2024-11-11 04:16:52.989087507 +0500
+++ wine.spec.mine	2024-10-06 18:44:20.000000000 +0500
@@ -1,5 +1,5 @@
 #
-# spec file
+# spec file for package wine
 #
 # Copyright (c) 2024 SUSE LLC
 #
@@ -19,6 +19,8 @@
 %define projectname wine
 %global flavor @BUILD_FLAVOR@%nil
 %define staging 0
+# it's quite broken
+%define use_lto 0
 
 %ifarch x86_64 aarch64
 %define wow64_build 0
@@ -41,8 +43,8 @@
 %endif
 
 # needs to be on top due to usage of %version macro below
-%define realver 9.20
-Version:        9.20
+%define realver 9.19
+Version:        9.19
 Release:        0
 
 %if "%{flavor}" != ""
@@ -66,9 +68,11 @@
 BuildRequires:  llvm
 %endif
 BuildRequires:  cups-devel
+BuildRequires:  linux-glibc-devel
 %if 0%{?suse_version} >= 1550
 BuildRequires:  libcapi20-devel
-BuildRequires:  vkd3d-devel
+# might be older than bundled
+#BuildRequires:  vkd3d-devel
 %endif
 BuildRequires:  FAudio-devel
 BuildRequires:  dbus-1-devel
@@ -105,12 +109,28 @@
 Obsoletes:      wine-mp3 < %version
 %else
 Recommends:     wine-mp3
+# needed for some games' FMVs to work
+Recommends:     gstreamer-plugins-good
+Recommends:     gstreamer-plugins-bad
+Recommends:     gstreamer-plugins-bad-orig-addon
+Recommends:     gstreamer-plugins-good-extra
+Recommends:     gstreamer-plugins-ugly
+Recommends:     gstreamer-plugins-ugly-orig-addon
+%ifarch x86_64
+Recommends:     gstreamer-plugins-bad-32bit
+Recommends:     gstreamer-plugins-bad-orig-addon-32bit
+Recommends:     gstreamer-plugins-good-32bit
+Recommends:     gstreamer-plugins-good-extra-32bit
+Recommends:     gstreamer-plugins-ugly-32bit
+Recommends:     gstreamer-plugins-ugly-orig-addon-32bit
+%endif
 %endif
 BuildRequires:  SDL2-devel
 BuildRequires:  git
 BuildRequires:  ncurses-devel
 BuildRequires:  ocl-icd-devel
 BuildRequires:  openal-soft-devel
+BuildRequires:  opencl-headers
 BuildRequires:  openldap2-devel
 BuildRequires:  openssl-devel
 BuildRequires:  pcsc-lite-devel
@@ -121,14 +141,19 @@
 %if 0%{?suse_version} >= 1550
 %ifarch x86_64
 BuildRequires:  mingw64-cross-gcc
+BuildRequires:  mingw64-gmp-devel
+BuildRequires:  mingw64-winpthreads-devel
 BuildRequires:  mingw64-zlib-devel
 Requires:       mingw64-libz
 %if %{wow64_build}
 BuildRequires:  mingw32-cross-gcc
+BuildRequires:  mingw32-gmp-devel
 %endif
 %endif
 %ifarch %ix86
 BuildRequires:  mingw32-cross-gcc
+BuildRequires:  mingw32-gmp-devel
+BuildRequires:  mingw32-winpthreads-devel
 BuildRequires:  mingw32-zlib-devel
 Requires:       mingw32-libz
 %endif
@@ -140,6 +165,8 @@
 BuildRequires:  pkgconfig(glu)
 BuildRequires:  pkgconfig(libudev)
 BuildRequires:  pkgconfig(libusb-1.0)
+BuildRequires:  pkgconfig(netapi)
+BuildRequires:  pkgconfig(odbc)
 BuildRequires:  pkgconfig(osmesa)
 BuildRequires:  pkgconfig(wayland-client)
 BuildRequires:  pkgconfig(x11)
@@ -177,6 +204,16 @@
 Source8:        wine-rpmlintrc
 # SUSE specific patches
 # - currently none, but add them here
+
+# check out https://github.com/AdelKS/LinuxGamingGuide#esync-fsync
+# wine-tkg patches from https://github.com/Frogging-Family/wine-tkg-git/tree/master/wine-tkg-git/wine-tkg-patches/proton/fsync
+#Patch900:       fsync-unix-mainline.patch
+#Patch901:       fsync-unix-staging.patch
+#Patch902:       fsync-staging-no_alloc_handle.patch
+#Patch903:       fsync_futex_waitv.patch
+Patch904:       server_Abort_waiting_on_a_completion_port_when_closing_it.patch
+Patch910:       lowlatency_audio.patch
+
 Recommends:     wine-gecko >= 2.47.4
 Conflicts:      wine-gecko < 2.47.4
 Recommends:     wine-mono >= 9.2.0
@@ -190,19 +227,21 @@
 Requires:       samba-winbind
 %if "%{flavor}" != "wow64" && "%{flavor}" != "staging-wow64"
 %ifarch x86_64
-Requires:       %{name}-32bit = %{version}
+# setting strict version forces vendor change on desync updates
+Requires:       %{name}-32bit
 %endif
 %endif
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 ExclusiveArch:  %{ix86} x86_64 ppc armv7l armv7hl aarch64
 %if %{staging}
 # upstream patch target version
-%define staging_version 9.20
+%define staging_version 9.19
 Source100:      wine-staging-%{staging_version}.tar.xz
 BuildRequires:  gtk3-devel
-BuildRequires:  libOSMesa-devel
 BuildRequires:  libva-devel
 BuildRequires:  python3
+Obsoletes:      wine
+Provides:       wine = %{version}
 %endif
 # wine bundles multiple unix libraries to be able to build PE files without dependencies
 # current versions are from 7.22 (update this if you update the versions below):
@@ -260,25 +299,42 @@
 
 %prep
 %setup -q -n wine-%{realver}
-%autopatch -p1
+#autopatch -p1
 #
 cp %{S:3} .
 #
 %if %{staging}
 # apply wine staging patch set on top of the wine release.
 tar xf %{SOURCE100}
+# conflicts with newer gstreamer
+rm -v ./wine-staging-%staging_version/patches/mfplat-streaming-support/0008-winegstreamer-Allow-videoconvert-to-parallelize.patch || echo "no bad patch present"
 python3 ./wine-staging-%staging_version/staging/patchinstall.py --all
 %endif
 
+# fsync
+%if %{staging}
+#patch -P 901 -p1 -F2
+#patch -P 902 -p1 -F2
+%else
+#patch -P 900 -p1 -F2
+%endif
+#patch -P 903 -p1 -F2
+# other
+%patch -P 904 -p1 -F2
+%patch -P 910 -p1 -F2
+
+# remove stupid crap that breaks builds randomly
+sed -i -e "/386_set_ldt/d" configure.ac
+
 %build
 # currently not building with LTO
+%if %{use_lto}
+%define _lto_cflags -flto=%{jobs} -ffat-lto-objects -flto-odr-type-merging
+%else
 %define _lto_cflags %{nil}
+%endif
 cat VERSION
 export WIDL_TIME_OVERRIDE="0" 	# for reproducible builds.
-%ifarch %ix86
-# e.g. Steam and other copy protections hate EBP being used for something else.
-export RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fomit-frame-pointer//'`
-%endif
 
 %ifarch aarch64
 # ARM64 now requires clang
@@ -286,13 +342,19 @@
 export CC="/usr/bin/clang"
 %endif
 
-%if %{staging}
 autoreconf -i -f
+# optimize for tier of x86 CPUs with AVX starting from 2012
+%ifarch x86_64 %ix86
+%ifarch x86_64
+# for some reason configure on x86_64 likes to fail with random "illegal instruction"
+export CFLAGS="-march=x86-64 -mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes -mpclmul -mtune=generic"
+%else
+export CFLAGS="-march=x86-64 -mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes -mpclmul"
+%endif
+export CFLAGS="${CFLAGS} -O3 -fPIC -fms-extensions %{_lto_cflags}"
+export CXXFLAGS="${CFLAGS}"
+export LDFLAGS="${LDFLAGS} ${CFLAGS} -pthread -fopenmp -lgomp -Wl,-O1"
 %endif
-# keep just for susepatches with configure changes
-#autoconf
-#autoheader -I include
-CFLAGS="$RPM_OPT_FLAGS" \
 %configure \
 	--with-x \
 %ifarch %{arm}
@@ -328,6 +390,7 @@
 # now included
 echo " obsoletes \"wine-mp3-32bit\""		>> %SOURCE7
 %else
+
 echo " recommends \"wine-mp3-32bit\""		>> %SOURCE7
 %endif
 %if 0%{?suse_version} >= 1310
@@ -421,6 +484,13 @@
         install -c -m 644 *.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
 cd ..
 
+# REMOVE TRASH
+rm -v %{buildroot}%{_datadir}/applications/{wine-notepad,wine-winemine}.desktop
+# https://forum.winehq.org/viewtopic.php?t=3061
+#find %{buildroot}%{_libdir} -iname "*winemenubuilder*" -delete
+# https://askubuntu.com/questions/323437/how-to-prevent-wine-from-adding-file-associations
+sed -i -e "s:winemenubuilder.exe -a -r:winemenubuilder.exe -r:g" %{buildroot}%{_datadir}/wine/wine.inf
+
 # find the implicit dependencies
 %define winedir %_builddir/%projectname-%realver
 cat >%winedir/my-find-requires.sh <<EOF
@@ -459,7 +529,7 @@
 %{_bindir}/winefile
 %{_bindir}/winemine
 %{_bindir}/winepath
-%{_bindir}/wineserver
+%caps(cap_sys_ptrace=eip) %{_bindir}/wineserver
 %{_bindir}/wisotool
 %{_datadir}/wine
 %ifnarch x86_64
@@ -505,7 +575,7 @@
 %{_datadir}/icons/hicolor/scalable/apps/*.svg
 %ifarch %ix86 aarch64
 %{_bindir}/wine
-%{_bindir}/wine-preloader
+%caps(cap_sys_ptrace=eip) %{_bindir}/wine-preloader
 %endif
 %ifarch ppc %arm
 %{_bindir}/wine
@@ -513,10 +583,10 @@
 %ifarch x86_64
 %if %{wow64_build}
 %{_bindir}/wine
-%{_bindir}/wine-preloader
+%caps(cap_sys_ptrace=eip) %{_bindir}/wine-preloader
 %else
 %{_bindir}/wine64
-%{_bindir}/wine64-preloader
+%caps(cap_sys_ptrace=eip) %{_bindir}/wine64-preloader
 %endif
 %endif
 
@@ -562,20 +632,12 @@
 %{_bindir}/wmc
 %{_bindir}/wrc
 %ifnarch aarch64
-%ifarch x86_64
-%if 0%{?suse_version} < 1600
-%{_libdir}/wine/*-unix/*.a
-%endif
-%else
-%{_libdir}/wine/*-unix/*.a
-%endif
-%endif
-%if 0%{?suse_version} >= 1550
 %ifarch %{ix86} x86_64
 %ifarch x86_64
 %dir %{_libdir}/wine/x86_64-windows
 %dir %{_libdir}/wine/x86_64-unix
 %endif
+%{_libdir}/wine/*-unix/*.a
 # only generated with mingw
 %{_libdir}/wine/*-windows/*.a
 %endif
openSUSE Build Service is sponsored by