Skip to content

Commit

Permalink
add optional webview installer
Browse files Browse the repository at this point in the history
  • Loading branch information
apprehensions committed Feb 9, 2025
1 parent c3cb8ab commit c503436
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmd/vinegar/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (ctl *control) setupControlActions() {
"install-studio": {"Installing Studio", (*bootstrapper).setup},
"uninstall-studio": {"Deleting all deployments", ctl.deleteDeployments},

"init-prefix": {"Initializing Wineprefix", ctl.prefixInit},
"init-prefix": {"Initializing Wineprefix", (*bootstrapper).setupPrefix},
"kill-prefix": {"Killing Wineprefix", ctl.pfx.Kill},
"delete-prefix": {"Deleting Wineprefix", ctl.deletePrefixes},

Expand Down
80 changes: 70 additions & 10 deletions cmd/vinegar/setup.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package main

import (
"fmt"
"strings"
"errors"
"fmt"
"log/slog"
"os"
"path/filepath"
"sort"
"strings"
"sync/atomic"

"github.com/apprehensions/rbxbin"
"github.com/apprehensions/rbxweb/clientsettings"
"github.com/apprehensions/wine/dxvk"
"github.com/apprehensions/wine/webview"
cp "github.com/otiai10/copy"
"github.com/vinegarhq/vinegar/internal/dirs"
"github.com/vinegarhq/vinegar/internal/netutil"
"golang.org/x/sync/errgroup"
cp "github.com/otiai10/copy"
"github.com/apprehensions/wine/dxvk"
)

var studio = clientsettings.WindowsStudio64
Expand Down Expand Up @@ -63,10 +64,6 @@ func (b *bootstrapper) setup() error {
return nil
}

func (ui *ui) prefixInit() error {
return run(ui.pfx.Init())
}

func (b *bootstrapper) setupPrefix() error {
b.message("Setting up Wine")

Expand All @@ -78,10 +75,73 @@ func (b *bootstrapper) setupPrefix() error {
return nil
}

b.message("Initializing Wineprefix")
stop := b.performing()

b.message("Initializing Wineprefix", "dir", b.pfx.Dir())
if err := run(b.pfx.Init()); err != nil {
return err
}

stop()

if err := b.webViewInstall(); err != nil {
return err
}

return nil
}

func (b *bootstrapper) webViewInstall() error {
if b.cfg.Studio.WebView == "" {
return nil
}

name := filepath.Join(dirs.Cache, "webview-"+b.cfg.Studio.WebView+".exe")
if _, err := os.Stat(name); err != nil {
if err := b.webViewDownload(name); err != nil {
return err
}
}

defer b.performing()()
b.message("Installing WebView", "path", name)

return run(webview.Install(b.pfx, name))
}

func (b *bootstrapper) webViewDownload(name string) error {
stop := b.performing()

b.message("Fetching WebView", "upload", b.cfg.Studio.WebView)
d, err := webview.GetDownload(b.cfg.Studio.WebView)
if err != nil {
return err
}

tmp, err := os.CreateTemp("", "unc_msedgestandalone.*.exe")
if err != nil {
return err
}
defer os.Remove(tmp.Name())

if err != nil {
return err
}

stop()
b.message("Downloading WebView", "version", d.Version)
err = netutil.DownloadProgress(d.URL, tmp.Name(), &b.pbar)
if err != nil {
return err
}

cac, err := os.OpenFile(name, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o644)
if err != nil {
return err
}
defer cac.Close()

return b.prefixInit()
return d.Extract(tmp, cac)
}

func (b *bootstrapper) setupOverlay() error {
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Studio struct {
Channel string `toml:"channel"`
Dxvk bool `toml:"dxvk"`
DxvkVersion string `toml:"dxvk_version"`
WebView string `toml:"webview"`
ForcedGpu string `toml:"gpu"`
Renderer string `toml:"renderer"`
Env Environment `toml:"env"`
Expand Down Expand Up @@ -81,6 +82,7 @@ func Default() *Config {
Studio: Studio{
Dxvk: false,
DxvkVersion: "2.5.3",
WebView: "cd7a382c-62c6-46c0-8098-0d50a7953b61",
GameMode: true,
ForcedGpu: "prime-discrete",
Renderer: "Vulkan",
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/altfoxie/drpc v0.0.0-20240929140334-e714e6291275
github.com/apprehensions/rbxbin v0.0.0-20250127194138-e1b385050444
github.com/apprehensions/rbxweb v0.0.0-20240329184049-0bdedc184942
github.com/apprehensions/wine v0.0.0-20250209161324-fb0e0a674896
github.com/apprehensions/wine v0.0.0-20250209200938-16e6e976d70e
github.com/godbus/dbus/v5 v5.1.0
github.com/jwijenbergh/puregotk v0.0.0-20240827133221-51f7e663a5e9
github.com/lmittmann/tint v1.0.7
Expand All @@ -22,6 +22,7 @@ require (
)

require (
github.com/folbricht/pefile v0.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jwijenbergh/purego v0.0.0-20241210143217-aeaa0bfe09e0 // indirect
github.com/otiai10/mint v1.6.3 // indirect
Expand Down
14 changes: 6 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ github.com/apprehensions/rbxbin v0.0.0-20250127194138-e1b385050444 h1:6KRg1JpRJA
github.com/apprehensions/rbxbin v0.0.0-20250127194138-e1b385050444/go.mod h1:FRJLfv2+HPYGcR7xP2VLG4O6QjkFCf05rBcdfUq1j3M=
github.com/apprehensions/rbxweb v0.0.0-20240329184049-0bdedc184942 h1:pNRoIKlv329La+msdHmJSPYYf1y4hY4s5ou2mEQDHqU=
github.com/apprehensions/rbxweb v0.0.0-20240329184049-0bdedc184942/go.mod h1:F7WKRLrQxuRgfXxhwnlFJ059ZBMRxkXxvIhUxP4Qc5g=
github.com/apprehensions/wine v0.0.0-20250206171740-ab07521097ab h1:Zm2vhLcafeuSvHVBH7ucJvFUC5fjBMfaw+Lkt6bhh1U=
github.com/apprehensions/wine v0.0.0-20250206171740-ab07521097ab/go.mod h1:t54gBblDmNAdLoRNLKk/338+JQvCiyt6qS8EUpD3RYw=
github.com/apprehensions/wine v0.0.0-20250208155613-b47818c0f018 h1:fVmFn+ECvfAU8YIiLcJeLcd4a7t0kXVwI6kVUrlk9oQ=
github.com/apprehensions/wine v0.0.0-20250208155613-b47818c0f018/go.mod h1:t54gBblDmNAdLoRNLKk/338+JQvCiyt6qS8EUpD3RYw=
github.com/apprehensions/wine v0.0.0-20250209112853-456b833e523a h1:AT/11Qxa+1d0v0pnWH+gGlRc/G41r7E05IMXwqNxzZ0=
github.com/apprehensions/wine v0.0.0-20250209112853-456b833e523a/go.mod h1:t54gBblDmNAdLoRNLKk/338+JQvCiyt6qS8EUpD3RYw=
github.com/apprehensions/wine v0.0.0-20250209161324-fb0e0a674896 h1:hj0ykrsXMo9vTd8Xd/AXkWzsCflkzX+6zRIDeBeYqjw=
github.com/apprehensions/wine v0.0.0-20250209161324-fb0e0a674896/go.mod h1:t54gBblDmNAdLoRNLKk/338+JQvCiyt6qS8EUpD3RYw=
github.com/apprehensions/wine v0.0.0-20250209195638-d98a2ae4ca19 h1:rP7tlldLsLAI8lm5mpVpcsLaoFxRLrOm7JmwJ4ZrhpE=
github.com/apprehensions/wine v0.0.0-20250209195638-d98a2ae4ca19/go.mod h1:apeIbCtolwZOKOw3jJGFLsnSIzL28Rrs+tM0x3jxJZk=
github.com/apprehensions/wine v0.0.0-20250209200938-16e6e976d70e h1:9KsvxDjgP0mrx0ldLDT9R/KkBOEjz6txyFfxfaEiaxA=
github.com/apprehensions/wine v0.0.0-20250209200938-16e6e976d70e/go.mod h1:apeIbCtolwZOKOw3jJGFLsnSIzL28Rrs+tM0x3jxJZk=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/folbricht/pefile v0.1.0 h1:y9aMwgNlPO/iyp8Izll3Au4XNp7Fi7uDH8OKZ1Nl+lw=
github.com/folbricht/pefile v0.1.0/go.mod h1:QP4MiHKu0BG/jiftQCJoiH+mM1UMNncR3S+HeioLtvc=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
Expand Down

0 comments on commit c503436

Please sign in to comment.