wine

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wine runs the game's Windows binaries on macOS and Linux: it finds or downloads a Wine runtime, keeps a private prefix for the launcher, and maps paths between the host and Windows.

Index

Constants

View Source
const DefaultDebug = "-all"

DefaultDebug turns off Wine's debug channels, which are noisy and slow.

Variables

View Source
var DefaultPin = func() Pin {
	if runtime.GOARCH == "amd64" {
		return LinuxPin
	}
	return Pin{}
}()

DefaultPin is the runtime the launcher downloads on this platform. The pinned build is amd64; elsewhere only the system's Wine can be used.

View Source
var ErrNeedsRosetta = errors.New("Wine needs Rosetta 2, which isn't installed")

ErrNeedsRosetta means Rosetta 2 must be installed first; see InstallRosetta.

View Source
var ErrNo32Bit = errors.New("this Wine can't run 32-bit programs")

ErrNo32Bit means a Wine can't run 32-bit programs, as the game is.

View Source
var ErrNoRuntime = errors.New("no Wine runtime for this system")

ErrNoRuntime means no Wine is available on this platform.

View Source
var ErrNotReady = errors.New("Wine needs setting up before the game can start")

ErrNotReady means Wine hasn't been set up yet, or needs setting up again, such as after an update: the setup screen does that.

View Source
var Hosts = append([]string{"github.com"}, fetch.GitHubAssetHosts...)

Hosts are where pinned runtimes download from.

View Source
var LinuxPin = Pin{
	Version: "11.0",
	URL:     "https://github.com/Kron4ek/Wine-Builds/releases/download/11.0/wine-11.0-amd64-wow64.tar.xz",
	Size:    73144724,
	SHA256:  "39574efa1132c3ca0d5c77dd2eddbe4a49cca0d6cc2c290ff4924493a1c40314",
}

LinuxPin is Kron4ek/Wine-Builds' amd64-wow64 build, which runs 32-bit programs without 32-bit host libraries. It still needs the usual system libraries and glibc 2.27 or later.

View Source
var MacPin = Pin{
	Version: "11.0_1",
	URL:     "https://github.com/Gcenx/macOS_Wine_builds/releases/download/11.0_1/wine-stable-11.0_1-osx64.tar.xz",
	Size:    185303032,
	SHA256:  "b50dc50ec7f41d58b115a6b685d4d1315ba3c797bd3aa0f49213f2703cb82388",
}

MacPin is WineHQ's macOS build of Wine Stable, from Gcenx/macOS_Wine_builds: x86_64, running 32- and 64-bit Windows programs, on Apple Silicon through Rosetta 2.

View Source
var MinSystemVersion = [2]int{9, 0}

MinSystemVersion is the oldest system Wine the launcher uses.

Functions

func Env

func Env(parent []string, prefix, debug string, overrides ...string) []string

Env is the environment every Wine call runs with: the parent's, minus any Wine variables of the player's own, plus the prefix and the launcher's settings. debug "" means DefaultDebug; overrides are added to the base DLL overrides, such as "ddraw=n,b".

func InstallHint

func InstallHint() string

InstallHint is the command that installs Wine on this distribution, for a player whose system can't run the downloaded Wine.

func InstallRosetta

func InstallRosetta(ctx context.Context) error

InstallRosetta has nothing to do off macOS.

func NeedsRosetta

func NeedsRosetta(ctx context.Context) bool

NeedsRosetta is false off macOS.

func Paths

func Paths() launch.Paths

Paths maps host paths to drive Z:, for registry values.

func UnixPath

func UnixPath(win string) (string, error)

UnixPath is the host path for a Windows path on drive Z:.

func Unpack

func Unpack(r io.Reader, dest string) error

Unpack extracts a .tar.xz into dest, which must not exist yet. It keeps symbolic links and executable bits, and refuses any entry that would land outside dest: absolute paths, .. components, links pointing out, and writes through a link.

func WinPath

func WinPath(unix string) string

WinPath is how Windows programs under Wine see a host path: Z: and the path with backslashes. The path must be absolute.

Types

type Host

type Host struct {
	Setup Setup
	// TempDir holds files passed to Wine programs, such as .reg files.
	TempDir string
	// contains filtered or unexported fields
}

Host runs the game under Wine: it holds the prefix once Wine is set up, and gives the launcher a registry, a starter and path mapping for it.

func (*Host) Prefix

func (h *Host) Prefix() (*Prefix, error)

Prefix is the ready prefix, or ErrNotReady.

func (*Host) Ready

func (h *Host) Ready(ctx context.Context) bool

Ready reports whether the game can start now, checking for a prefix an earlier run set up. It doesn't download or create anything. The check runs Wine, so it's done without the lock, which launches need.

func (*Host) Registry

func (h *Host) Registry() *Registry

Registry is the game's registry in the prefix.

func (*Host) Run

func (h *Host) Run(ctx context.Context, progress func(Progress)) error

Run sets Wine up, as Setup.Run, and keeps the prefix.

func (*Host) Start

func (h *Host) Start(b launch.Box) error

Start starts a box under Wine, from the box's folder, and lets it run.

With d2gl on in DirectDraw mode, Wine's own ddraw must give way to the one d2gl ships; in Glide mode (-3dfx), the game loads d2gl's glide3x.dll itself. With d2gl off, the game runs windowed: full screen under Wine changes the display mode, which goes badly on macOS.

type Manager

type Manager struct {
	Dir      string
	CacheDir string
	Pin      Pin
	Client   *fetch.Client
}

Manager keeps the launcher's Wine runtimes under Dir, one folder per version, and downloads into CacheDir.

func (Manager) Install

func (m Manager) Install(ctx context.Context, progress fetch.Progress) (*Runtime, error)

Install downloads and unpacks the pinned runtime, unless it's already there and runs. Older versions are removed only once the new one runs. A cancelled or failed download resumes next time.

func (Manager) Installed

func (m Manager) Installed(ctx context.Context) (*Runtime, error)

Installed returns the pinned runtime if it's already unpacked and runs.

type MissingLibraryError

type MissingLibraryError struct{ Library string }

MissingLibraryError means a downloaded Wine can't find a system library.

func (*MissingLibraryError) Error

func (e *MissingLibraryError) Error() string

type Pin

type Pin struct {
	Version string
	URL     string
	Size    int64
	SHA256  string
}

Pin is a Wine build the launcher downloads, fixed by size and SHA-256.

func (Pin) Name

func (p Pin) Name() string

Name is the archive's file name.

type Prefix

type Prefix struct {
	Dir     string
	Runtime *Runtime
	// Debug is WINEDEBUG; "" means DefaultDebug.
	Debug string
	// Log receives the output of every Wine call. Nil discards it.
	Log io.Writer
}

Prefix is the launcher's private Wine prefix: its own Windows registry and drive C:, separate from any the player uses.

func (*Prefix) Check32

func (p *Prefix) Check32(ctx context.Context) error

Check32 runs the 32-bit cmd.exe: the game is 32-bit, and some Wine builds, such as a distribution's 64-bit-only package, can't run it. A check cut short, by a timeout or the player cancelling, says nothing either way and isn't ErrNo32Bit.

func (*Prefix) Command

func (p *Prefix) Command(ctx context.Context, args ...string) *exec.Cmd

Command is wine with args in this prefix, logging its output.

func (*Prefix) Ensure

func (p *Prefix) Ensure(ctx context.Context) (changed bool, err error)

Ensure makes the prefix ready: created on first use, updated when the runtime has changed since, and with drive Z: mapped to /. It reports whether it created or updated it.

func (*Prefix) Env

func (p *Prefix) Env(overrides ...string) []string

Env is the environment for Wine calls in this prefix, with extra DLL overrides.

func (*Prefix) Forget

func (p *Prefix) Forget()

Forget makes the next Ensure check the prefix over, such as after a runtime failed in it.

func (*Prefix) Persist

func (p *Prefix) Persist(ctx context.Context) error

Persist starts the prefix's wineserver, or keeps it, running for 30 seconds after its last program ends, so the registry calls and the game that follow share one server rather than each starting their own.

func (*Prefix) WindowsVersion

func (p *Prefix) WindowsVersion(ctx context.Context) (string, error)

WindowsVersion runs cmd /c ver: proof the prefix runs programs.

type Progress

type Progress struct {
	Step  Step  `json:"step"`
	Done  int64 `json:"done"`
	Total int64 `json:"total"`
}

Progress is Wine setup's progress. Done and Total count download bytes in StepWine; both are 0 otherwise.

type Registry

type Registry struct {
	// Prefix is the prefix to work in, once there is one.
	Prefix func() (*Prefix, error)
	// TempDir holds the .reg files passed to regedit.
	TempDir string
	// contains filtered or unexported fields
}

Registry is the game's registry values in the launcher's Wine prefix, as launch.Registry. Values are read once per launch, by exporting the two keys, and writes are held until Commit imports them all in one go: each regedit is a Windows process start. It never edits the prefix's .reg files directly: the wineserver holds the registry and rewrites them.

regedit /E puts up an error and waits when a key doesn't exist, so the keys are created first; it writes UTF-16, which keeps any path intact, where reg query prints in the console's code page.

func (*Registry) Commit

func (r *Registry) Commit() error

Commit imports the held writes, then forgets what was read, so the next launch reads afresh: the game may change the values while it runs. Writes that fail to import are kept for the next Commit.

func (*Registry) GatewayList

func (r *Registry) GatewayList() ([]string, error)

GatewayList reads the gateway list; none yet is an empty list.

func (*Registry) SetGame

func (r *Registry) SetGame(exe, version string) error

SetGame has Wine report Windows XP to a game older than 1.14, at the next Commit. Under Wine on Apple Silicon, 1.13c's Fog.dll overflows its stack at start-up when told Windows 10, Wine's default; told XP, it starts. A 1.14 game gets Wine's default back.

func (*Registry) SetGatewayList

func (r *Registry) SetGatewayList(values []string) error

SetGatewayList writes the gateway list at the next Commit.

func (*Registry) SetString

func (r *Registry) SetString(name, value string) error

SetString writes a value under the game's own key at the next Commit.

func (*Registry) String

func (r *Registry) String(name string) (string, error)

String reads a value under the game's own key; one not set is "".

type Runtime

type Runtime struct {
	// Version is the pin's version, or "system" plus wine --version.
	Version    string
	Wine       string
	Wineserver string
	// System is Wine the player installed, not one the launcher manages.
	System bool
}

Runtime is a Wine installation.

func SystemWine

func SystemWine(ctx context.Context) (*Runtime, error)

SystemWine is the player's own Wine, if it's on the PATH and recent enough. Whether it runs 32-bit programs is only known once a prefix is made; see Prefix.Check32.

func (*Runtime) WineVersion

func (rt *Runtime) WineVersion(ctx context.Context) (string, error)

WineVersion runs wine --version.

type Setup

type Setup struct {
	Manager   Manager
	PrefixDir string
	Debug     string
	Log       io.Writer
	// UseSystem tries the player's own Wine first (Linux).
	UseSystem bool
}

Setup gets a runtime and a ready prefix.

func (Setup) Quick

func (s Setup) Quick(ctx context.Context) (*Prefix, error)

Quick is the prefix an earlier Run left ready for the current runtime, or ErrNotReady. It doesn't download or create anything.

func (Setup) Run

func (s Setup) Run(ctx context.Context, progress func(Progress)) (*Prefix, error)

Run sets Wine up, or checks it still is: quick once done. progress may be nil.

func (Setup) SystemPrefixDir

func (s Setup) SystemPrefixDir() string

SystemPrefixDir is the prefix used with the system's Wine. It's kept apart from the one the launcher's own Wine uses, so an older system Wine never opens a prefix a newer Wine made (Wine can't take one back a version), and switching between them doesn't update one prefix back and forth.

type Step

type Step string

Step is a part of setting Wine up, as the setup screen lists them.

const (
	// StepWine finds or downloads the runtime.
	StepWine Step = "wine"
	// StepPrefix creates or updates the prefix.
	StepPrefix Step = "prefix"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL