Update wine to version 10, replace wine64 with wine (#25997)

#25872
This commit is contained in:
Dante Catalfamo 2025-02-07 11:05:07 -05:00 committed by GitHub
parent 915b0b3502
commit 1a9f4012b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 12 deletions

View file

@ -0,0 +1 @@
- Updated wine to version 10.0 to improve support macOS-to-Windows installer creation on M1 chips.

View file

@ -9,13 +9,16 @@ import (
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
)
const (
directoryReference = "ORBITROOT"
imageName = "fleetdm/wix:latest"
dockerPlatform = "linux/amd64"
WineCmd = "wine64"
Wine64Cmd = "wine64"
WineCmd = "wine"
)
// Heat runs the WiX Heat command on the provided directory.
@ -39,7 +42,11 @@ func Heat(path string, native bool, localWixDir string) error {
if localWixDir != "" {
heatPath = filepath.Join(localWixDir, `heat.exe`)
if runtime.GOOS == "darwin" {
args = append(args, WineCmd)
wineExec, err := darwinWineExecutable()
if err != nil {
return fmt.Errorf("determining wine executable: %w", err)
}
args = append(args, wineExec)
}
}
@ -56,7 +63,7 @@ func Heat(path string, native bool, localWixDir string) error {
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
if args[0] == WineCmd {
if args[0] == WineCmd || args[0] == Wine64Cmd {
cmd.Env = append(os.Environ(), "WINEDEBUG=-all")
}
@ -71,6 +78,25 @@ func Heat(path string, native bool, localWixDir string) error {
return nil
}
func darwinWineExecutable() (string, error) {
cmdOut, err := exec.Command("wine", "--version").Output()
if err != nil {
return "", fmt.Errorf("running wine to get version information: %w", err)
}
wineVerStr, found := strings.CutPrefix(string(cmdOut), "wine-")
if !found {
return "", fmt.Errorf("Unknown wine version: %q. Is Wine installed? Creating a fleetd agent for Windows (.msi) requires Wine. To install Wine see the script here: https://fleetdm.com/install-wine ", string(cmdOut))
}
wineVersion, err := strconv.ParseInt(strings.Split(wineVerStr, ".")[0], 10, 64)
if err != nil {
return "", fmt.Errorf("Unable to parse wine version: %q. Is Wine installed? Creating a fleetd agent for Windows (.msi) requires Wine. To install Wine see the script here: https://fleetdm.com/install-wine ", wineVerStr)
}
if wineVersion < 10 {
return Wine64Cmd, nil
}
return WineCmd, nil
}
// Candle runs the WiX Candle command on the provided directory.
//
// See
@ -91,7 +117,11 @@ func Candle(path string, native bool, localWixDir string) error {
if localWixDir != "" {
candlePath = filepath.Join(localWixDir, `candle.exe`)
if runtime.GOOS == "darwin" {
args = append(args, WineCmd)
wineExec, err := darwinWineExecutable()
if err != nil {
return fmt.Errorf("determining wine executable: %w", err)
}
args = append(args, wineExec)
}
}
args = append(args,
@ -103,7 +133,7 @@ func Candle(path string, native bool, localWixDir string) error {
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
if args[0] == WineCmd {
if args[0] == WineCmd || args[0] == Wine64Cmd {
cmd.Env = append(os.Environ(), "WINEDEBUG=-all")
}
@ -138,7 +168,11 @@ func Light(path string, native bool, localWixDir string) error {
if localWixDir != "" {
lightPath = filepath.Join(localWixDir, `light.exe`)
if runtime.GOOS == "darwin" {
args = append(args, WineCmd)
wineExec, err := darwinWineExecutable()
if err != nil {
return fmt.Errorf("determining wine executable: %w", err)
}
args = append(args, wineExec)
}
}
args = append(args,
@ -152,7 +186,7 @@ func Light(path string, native bool, localWixDir string) error {
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
if args[0] == WineCmd {
if args[0] == WineCmd || args[0] == Wine64Cmd {
cmd.Env = append(os.Environ(), "WINEDEBUG=-all")
}

View file

@ -5,10 +5,10 @@ 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/9.0 or by building from source.
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-cask/1ecfe82f84e0f3c3c6b741d3ddc19a164c2cb18d/Casks/w/wine-stable.rb
brew install --cask --no-quarantine wine-stable.rb; exit 0
# 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.
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-cask/bad613d274f9a646dace4a4cc7f2512f836be5b4/Casks/w/wine-stable.rb
brew install --cask --no-quarantine wine-stable.rb; exit 0
}
@ -57,4 +57,3 @@ then
else
warn_wine
fi