Skip to content

Commit

Permalink
Update wine to version 10, replace wine64 with wine (#25997)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantecatalfamo authored Feb 7, 2025
1 parent 915b0b3 commit 1a9f401
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
1 change: 1 addition & 0 deletions changes/25872-fleetctl-update-wine-10
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Updated wine to version 10.0 to improve support macOS-to-Windows installer creation on M1 chips.
48 changes: 41 additions & 7 deletions orbit/pkg/packaging/wix/wix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
}
}

Expand All @@ -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")
}

Expand 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
Expand All @@ -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,
Expand All @@ -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")
}

Expand Down Expand Up @@ -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,
Expand All @@ -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")
}

Expand Down
9 changes: 4 additions & 5 deletions scripts/macos-install-wine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down Expand Up @@ -57,4 +57,3 @@ then
else
warn_wine
fi

0 comments on commit 1a9f401

Please sign in to comment.