Install Wine from Gcenx tarball directly

The homebrew-cask wine-stable approach keeps breaking: Gcenx removes old
releases (10.0, now 11.0), and the 11.0_1 build that replaced 11.0 crashes
mono during `heat.exe` under Wine, breaking MSI builds.

Switch to downloading the Gcenx wine-devel 11.6_1 tarball directly, bypassing
homebrew-cask. Extract into /Applications, strip quarantine, symlink the wine
binary into the Homebrew prefix so it's on PATH.
This commit is contained in:
Scott Gress 2026-04-17 09:40:17 -05:00
parent fc01ebee9a
commit e4494a79f0

View file

@ -5,18 +5,46 @@
set -eo pipefail
brew_wine(){
# Wine reference: https://wiki.winehq.org/MacOS
# Wine can be installed without brew via a distribution such as https://github.com/Gcenx/macOS_Wine_builds/releases/tag/10.0 or by building from source.
# To install a version tied to a specific commit SHA we must create a local tap and install from it after wine 4.6.4 dropped support, see
# https://github.com/Homebrew/brew/pull/20414
TAP_PATH="$(brew --repository)/Library/Taps/fleet/homebrew-local/Casks"
mkdir -p "${TAP_PATH}"
echo "# tap auto-generated by Fleet for installing wine-stable" > "$(dirname "${TAP_PATH}")/README.md"
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-cask/636950e811f5ce2463b0a80af9a59fc4b3254fed/Casks/w/wine-stable.rb
mv wine-stable.rb "${TAP_PATH}/"
brew install --cask fleet/local/wine-stable
xattr -dr com.apple.quarantine "$(brew --prefix)/Caskroom/wine-stable"
# Wine reference: https://wiki.winehq.org/MacOS
# We install from the Gcenx Wine builds tarball directly (rather than via
# homebrew-cask) because the wine-stable / wine-devel casks either don't exist
# or are deprecated, and because pinning a homebrew-cask commit breaks whenever
# Gcenx removes an older release. See https://github.com/fleetdm/fleet/issues/43484.
WINE_VERSION="11.6_1"
WINE_VARIANT="wine-devel"
WINE_TARBALL="${WINE_VARIANT}-${WINE_VERSION}-osx64.tar.xz"
WINE_URL="https://github.com/Gcenx/macOS_Wine_builds/releases/download/${WINE_VERSION}/${WINE_TARBALL}"
WINE_SHA256="737c5bbcef4dab626e6dcb58f3736bf910780de25d53e52e7d7c01e521da725a"
WINE_APP="/Applications/Wine Devel.app"
install_wine(){
tmpdir=$(mktemp -d)
trap 'rm -rf "${tmpdir}"' EXIT
printf "Downloading %s...\n" "${WINE_TARBALL}"
curl -fsSL --retry 3 -o "${tmpdir}/${WINE_TARBALL}" "${WINE_URL}"
printf "Verifying sha256...\n"
echo "${WINE_SHA256} ${tmpdir}/${WINE_TARBALL}" | shasum -a 256 -c -
printf "Extracting to /Applications...\n"
if [ -e "${WINE_APP}" ]; then
rm -rf "${WINE_APP}"
fi
tar -xJf "${tmpdir}/${WINE_TARBALL}" -C /Applications
printf "Stripping quarantine attribute...\n"
xattr -dr com.apple.quarantine "${WINE_APP}" || true
# Put the wine binary on PATH via the Homebrew prefix (already on PATH for
# brew users) so callers like `fleetctl package --type msi` can find it.
brew_bin="$(brew --prefix)/bin"
mkdir -p "${brew_bin}"
ln -sf "${WINE_APP}/Contents/Resources/wine/bin/wine" "${brew_bin}/wine"
printf "Wine installed: "
"${brew_bin}/wine" --version
exit 0
}
@ -27,7 +55,7 @@ while true
do
read -r -p "install> " install
case "$install" in
y|yes|Y|YES) brew_wine ;;
y|yes|Y|YES) install_wine ;;
n|no|N|NO) printf "\nExiting...\n\n"; exit 1 ;;
*) printf "\nPlease enter yes or no at the prompt...\n\n" ;;
esac
@ -52,7 +80,7 @@ then
fi
# check if Homebrew is installed
# check if Homebrew is installed (used to locate a directory on PATH for the wine symlink)
if ! command -v brew > /dev/null 2>&1
then
printf "\nHomebrew is not installed.\nPlease install Homebrew.\nFor instructions, see https://brew.sh/\n\n"; exit 1
@ -62,7 +90,7 @@ fi
# install Wine
if [ "$mode" = 'auto' ]
then
printf "\n%s executed in non-interactive mode.\n\n" "$0"; brew_wine
printf "\n%s executed in non-interactive mode.\n\n" "$0"; install_wine
else
warn_wine
fi