From 28c089d13a72cdc3c879548d3781a3fb81abddc5 Mon Sep 17 00:00:00 2001
From: Janne Grunau <janne-fdr@jannau.net>
Date: Oct 03 2024 19:31:29 +0000
Subject: [PATCH 1/4] Do not build mesa-libxatracker in asahi specific minimal build


Meson setup fails without enabled drivers.

---

diff --git a/mesa.spec b/mesa.spec
index 01ca43f..ae99342 100644
--- a/mesa.spec
+++ b/mesa.spec
@@ -22,7 +22,6 @@
 %dnl build va/vdpau/xa/teflon/nine to avoid issues with vanished packages
 %global with_vdpau  1
 %global with_va     1
-%global with_xa     1
 %global with_nine   1
 
 %ifnarch %{ix86}

From 0157826e4586106eedf24c5eb04e5aa372e556f3 Mon Sep 17 00:00:00 2001
From: Janne Grunau <janne-fdr@jannau.net>
Date: Oct 03 2024 19:32:44 +0000
Subject: [PATCH 2/4] Add "with_nouveau" to build nouveau conditionally


---

diff --git a/mesa.spec b/mesa.spec
index ae99342..ae9b7bd 100644
--- a/mesa.spec
+++ b/mesa.spec
@@ -42,6 +42,7 @@
 %global with_r300 1
 %global with_r600 1
 %global with_nine 1
+%global with_nouveau 1
 %if 0%{?with_vulkan_hw}
 %global with_nvk %{with_vulkan_hw}
 %endif
@@ -473,7 +474,7 @@ export MESON_PACKAGE_CACHE_DIR="%{cargo_registry}/"
   -Dplatforms=x11,wayland \
   -Dosmesa=true \
 %if 0%{?with_hardware}
-  -Dgallium-drivers=swrast,virgl,nouveau%{?with_r300:,r300}%{?with_crocus:,crocus}%{?with_i915:,i915}%{?with_iris:,iris}%{?with_vmware:,svga}%{?with_radeonsi:,radeonsi}%{?with_r600:,r600}%{?with_freedreno:,freedreno}%{?with_etnaviv:,etnaviv}%{?with_tegra:,tegra}%{?with_vc4:,vc4}%{?with_v3d:,v3d}%{?with_lima:,lima}%{?with_panfrost:,panfrost}%{?with_vulkan_hw:,zink}%{?with_asahi:,asahi} \
+  -Dgallium-drivers=swrast,virgl%{?with_nouveau:,nouveau}%{?with_r300:,r300}%{?with_crocus:,crocus}%{?with_i915:,i915}%{?with_iris:,iris}%{?with_vmware:,svga}%{?with_radeonsi:,radeonsi}%{?with_r600:,r600}%{?with_freedreno:,freedreno}%{?with_etnaviv:,etnaviv}%{?with_tegra:,tegra}%{?with_vc4:,vc4}%{?with_v3d:,v3d}%{?with_lima:,lima}%{?with_panfrost:,panfrost}%{?with_vulkan_hw:,zink}%{?with_asahi:,asahi} \
 %else
   -Dgallium-drivers=swrast,virgl \
 %endif
@@ -756,7 +757,9 @@ install -Dpm0644 -t %{buildroot}%{_datadir}/fex-emu/overlays/ mesa-%{_arch}.erof
 %{_libdir}/dri/panfrost_dri.so
 %{_libdir}/dri/panthor_dri.so
 %endif
+%if 0%{?with_nouveau}
 %{_libdir}/dri/nouveau_dri.so
+%endif
 %if 0%{?with_vmware}
 %{_libdir}/dri/vmwgfx_dri.so
 %endif
@@ -800,7 +803,9 @@ install -Dpm0644 -t %{buildroot}%{_datadir}/fex-emu/overlays/ mesa-%{_arch}.erof
 %if 0%{?with_va}
 %files va-drivers
 %{_libdir}/dri/libgallium_drv_video.so
+%if 0%{?with_nouveau}
 %{_libdir}/dri/nouveau_drv_video.so
+%endif
 %if 0%{?with_r600}
 %{_libdir}/dri/r600_drv_video.so
 %endif
@@ -814,7 +819,9 @@ install -Dpm0644 -t %{buildroot}%{_datadir}/fex-emu/overlays/ mesa-%{_arch}.erof
 %files vdpau-drivers
 %dir %{_libdir}/vdpau
 %{_libdir}/vdpau/libvdpau_gallium.so.1*
+%if 0%{?with_nouveau}
 %{_libdir}/vdpau/libvdpau_nouveau.so.1*
+%endif
 %if 0%{?with_r600}
 %{_libdir}/vdpau/libvdpau_r600.so.1*
 %endif

From ad2d9dd45640b0b703de3ce03a4d1c5eca7755bf Mon Sep 17 00:00:00 2001
From: Janne Grunau <janne-fdr@jannau.net>
Date: Oct 03 2024 19:36:58 +0000
Subject: [PATCH 3/4] Turn asahi_minimal into `%bcond` and build it by default on !aarch64


---

diff --git a/mesa.spec b/mesa.spec
index ae9b7bd..12e586e 100644
--- a/mesa.spec
+++ b/mesa.spec
@@ -1,7 +1,7 @@
 %dnl optionally do a minimal asahi specific build
-%dnl global with_asahi_minimal 1
+%bcond asahi_minimal %["%{_arch}" != "aarch64"]
 
-%if 0%{?with_asahi_minimal}
+%if %{with asahi_minimal}
 %global with_hardware  1
 %global with_vulkan_hw 1
 %global with_asahi     1

From 0114cc79c4f4a517a0a55a9c994209ececb2ab9d Mon Sep 17 00:00:00 2001
From: Janne Grunau <janne-fdr@jannau.net>
Date: Oct 03 2024 19:36:58 +0000
Subject: [PATCH 4/4] fex-emu: Sort out dependency data for mesa x86 overlays


- add dependency on fex-emu for the data directory
- supplements fex-emu-rootfs-fedora

---

diff --git a/mesa.spec b/mesa.spec
index 12e586e..2bdc8f7 100644
--- a/mesa.spec
+++ b/mesa.spec
@@ -119,7 +119,7 @@
 Name:           mesa
 Summary:        Mesa graphics libraries
 Version:        %{lua:ver = string.gsub(rpm.expand("%{ver}"), "-", "~"); print(ver)}
-Release:        %autorelease
+Release:        %autorelease -b 2
 License:        MIT AND BSD-3-Clause AND SGI-B-2.0
 URL:            http://www.mesa3d.org
 
@@ -434,7 +434,9 @@ The drivers with support for the Vulkan API.
 Summary:        Mesa driver overlay for FEX-emu
 BuildArch: noarch
 BuildRequires:  erofs-utils
-Provides:       fex-emu-overlay-%{_arch}(mesa) = %{version}-%{release}
+Requires:       fex-emu
+Supplements:    fex-emu-rootfs-fedora
+Provides:       fex-emu-overlay(%{_arch})(mesa) = %{version}-%{release}
 Provides:       bundled(mesa) = %{version}-%{release}
 
 %description fex-emu-overlay-%{_arch}

