From b26594b1942eec5d19d0d6fe6927f28b3a90fd5a Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 26 Sep 2026 20:44:03 +0300
Subject: [PATCH 79/79] Msys2: Add msys2_env_install.bat helper script

See RM #2297

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 platforms/windows/Makefile.am                 |   1 +
 .../installer_msys2/msys2_env_install.bat     | 122 ++++++++++++++++++
 2 files changed, 123 insertions(+)
 create mode 100644 platforms/windows/installer_msys2/msys2_env_install.bat

diff --git a/platforms/windows/Makefile.am b/platforms/windows/Makefile.am
index 44f0361b23..16e41f009a 100644
--- a/platforms/windows/Makefile.am
+++ b/platforms/windows/Makefile.am
@@ -28,6 +28,7 @@ dist_noinst_DATA = \
 		installer_msys2/freeciv-ruledit.cmd		\
 		installer_msys2/Freeciv.url			\
 		installer_msys2/Makefile.meson			\
+		installer_msys2/msys2_env_install.bat		\
 		installer_cross/create-freeciv-gtk-qt-nsi.sh	\
 		installer_cross/create-freeciv-sdl-nsi.sh	\
 		installer_cross/create-freeciv-ruledit-nsi.sh	\
diff --git a/platforms/windows/installer_msys2/msys2_env_install.bat b/platforms/windows/installer_msys2/msys2_env_install.bat
new file mode 100644
index 0000000000..f32b13ee90
--- /dev/null
+++ b/platforms/windows/installer_msys2/msys2_env_install.bat
@@ -0,0 +1,122 @@
+
+rem %1 should be an already extracted msys2 directory.
+
+rem First just launch the shell for automatic setup
+rem of the environment
+%1\usr\bin\bash.exe -lc ' ' || exit /b
+
+rem Update base environment
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Syu' || exit /b
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Syu' || exit /b
+
+rem Install packages
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Su --needed ^
+make ^
+tar ^
+git ^
+patch ^
+gdb ^
+' || exit /b
+
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Su --needed ^
+mingw-w64-ucrt-x86_64-pkgconf ^
+mingw-w64-ucrt-x86_64-nsis ^
+mingw-w64-ucrt-x86_64-gcc ^
+mingw-w64-ucrt-x86_64-7zip ^
+mingw-w64-ucrt-x86_64-curl ^
+mingw-w64-ucrt-x86_64-icu ^
+mingw-w64-ucrt-x86_64-sqlite3 ^
+mingw-w64-ucrt-x86_64-gtk3 ^
+mingw-w64-ucrt-x86_64-gtk4 ^
+' || exit /b
+
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Su --needed ^
+mingw-w64-ucrt-x86_64-SDL2_mixer ^
+mingw-w64-ucrt-x86_64-SDL2_image ^
+mingw-w64-ucrt-x86_64-SDL2_ttf ^
+mingw-w64-ucrt-x86_64-imagemagick ^
+mingw-w64-ucrt-x86_64-drmingw ^
+mingw-w64-ucrt-x86_64-qt6-base ^
+' || exit /b
+rem mingw-w64-ucrt-x86_64-SDL2_gfx
+
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Su --needed ^
+mingw-w64-ucrt-x86_64-meson ^
+mingw-w64-ucrt-x86_64-tolua ^
+mingw-w64-ucrt-x86_64-qt6-svg ^
+mingw-w64-ucrt-x86_64-wget2 ^
+mingw-w64-ucrt-x86_64-sdl3-image ^
+mingw-w64-ucrt-x86_64-sdl3-ttf ^
+mingw-w64-ucrt-x86_64-sdl3-mixer ^
+' || exit /b
+
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Su --needed ^
+mingw-w64-x86_64-pkgconf ^
+mingw-w64-x86_64-nsis ^
+mingw-w64-x86_64-gcc ^
+mingw-w64-x86_64-7zip ^
+mingw-w64-x86_64-curl ^
+mingw-w64-x86_64-icu ^
+mingw-w64-x86_64-sqlite3 ^
+mingw-w64-x86_64-gtk3 ^
+mingw-w64-x86_64-gtk4 ^
+' || exit /b
+
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Su --needed ^
+mingw-w64-x86_64-qt5-base ^
+mingw-w64-x86_64-SDL2_mixer ^
+mingw-w64-x86_64-SDL2_image ^
+mingw-w64-x86_64-SDL2_ttf ^
+mingw-w64-x86_64-imagemagick ^
+mingw-w64-x86_64-drmingw ^
+' || exit /b
+rem mingw-w64-x86_64-SDL2_gfx
+
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Su --needed ^
+mingw-w64-x86_64-meson ^
+mingw-w64-x86_64-tolua ^
+mingw-w64-x86_64-wget2 ^
+mingw-w64-x86_64-sdl3-image ^
+mingw-w64-x86_64-sdl3-ttf ^
+mingw-w64-x86_64-sdl3-mixer ^
+' || exit /b
+
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Su --needed ^
+mingw-w64-clang-x86_64-pkgconf ^
+mingw-w64-clang-x86_64-nsis ^
+mingw-w64-clang-x86_64-gcc ^
+mingw-w64-clang-x86_64-curl ^
+mingw-w64-clang-x86_64-7zip ^
+mingw-w64-clang-x86_64-icu ^
+mingw-w64-clang-x86_64-sqlite3 ^
+mingw-w64-clang-x86_64-gtk3 ^
+mingw-w64-clang-x86_64-gtk4 ^
+' || exit /b
+
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Su --needed ^
+mingw-w64-clang-x86_64-SDL2_mixer ^
+mingw-w64-clang-x86_64-SDL2_image ^
+mingw-w64-clang-x86_64-SDL2_ttf ^
+mingw-w64-clang-x86_64-imagemagick ^
+mingw-w64-clang-x86_64-drmingw ^
+' || exit /b
+rem mingw-w64-clang-x86_64-SDL2_gfx
+
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Su --needed ^
+mingw-w64-clang-x86_64-qt6-base ^
+mingw-w64-clang-x86_64-meson ^
+mingw-w64-clang-x86_64-tolua ^
+mingw-w64-clang-x86_64-qt6-svg ^
+mingw-w64-clang-x86_64-wget2 ^
+mingw-w64-clang-x86_64-sdl3-image ^
+mingw-w64-clang-x86_64-sdl3-ttf ^
+mingw-w64-clang-x86_64-sdl3-mixer ^
+' || exit /b
+
+rem Update just in case, so everything is certainly
+rem at the same level even if upstream made updates
+rem while we were installing.
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Syu' || exit /b
+
+rem Clear caches
+%1\usr\bin\bash.exe -lc 'pacman --noconfirm -Scc' || exit /b
-- 
2.53.0

