build: use system WebView2 for Windows archive
This commit is contained in:
parent
20952e8477
commit
da76b89856
|
|
@ -1,16 +1,7 @@
|
|||
# .gitignore
|
||||
frontend/node_modules/
|
||||
frontend/dist/
|
||||
build/bin/verstak-desktop
|
||||
build/appicon.png
|
||||
build/windows/
|
||||
build/windows-amd64/
|
||||
build/linux-amd64/
|
||||
build/appimage/
|
||||
build/deb/
|
||||
build/downloads/
|
||||
build/tools/
|
||||
build/webview2-runtime/
|
||||
build/
|
||||
smoke-platform
|
||||
plugins/
|
||||
vendor/
|
||||
|
|
|
|||
15
README.md
15
README.md
|
|
@ -104,16 +104,17 @@ On distributions without FUSE support, use
|
|||
Build the Windows portable ZIP on Linux with MinGW:
|
||||
|
||||
```bash
|
||||
sudo apt install gcc-mingw-w64-x86-64 cabextract zip
|
||||
sudo apt install gcc-mingw-w64-x86-64 zip
|
||||
./scripts/package-windows-portable.sh v0.1.0-alpha.1
|
||||
```
|
||||
|
||||
The script downloads the current x64 Microsoft Fixed Version WebView2 Runtime,
|
||||
bundles it next to `verstak-desktop.exe`, and writes
|
||||
`release/verstak-windows-amd64-<version>.zip`. On Windows, extract the ZIP to a
|
||||
local disk (not a network share) and launch `Verstak.cmd`. No separate WebView2
|
||||
installation or download is required. To make a reproducible build from an
|
||||
already downloaded CAB, set `VERSTAK_WEBVIEW2_CAB=/path/to/FixedVersionRuntime.x64.cab`.
|
||||
The ZIP uses the x64 Evergreen Microsoft WebView2 Runtime installed in Windows
|
||||
and writes `release/verstak-windows-amd64-<version>.zip`. Extract it to a local
|
||||
disk (not a network share) and launch `Verstak.cmd`. Windows 11 and most
|
||||
Windows 10 installations already include this runtime. If Verstak does not
|
||||
start, install the official [Microsoft WebView2 Runtime x64 standalone
|
||||
installer](https://go.microsoft.com/fwlink/p/?LinkId=2124701), then launch it
|
||||
again.
|
||||
|
||||
Each format is listed in `release/SHA256SUMS` after packaging.
|
||||
|
||||
|
|
|
|||
1
main.go
1
main.go
|
|
@ -258,7 +258,6 @@ func main() {
|
|||
app,
|
||||
},
|
||||
}
|
||||
applyPlatformOptions(appOptions)
|
||||
err = wails.Run(appOptions)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -2,12 +2,4 @@
|
|||
setlocal
|
||||
set "ROOT=%~dp0"
|
||||
|
||||
if not exist "%ROOT%webview2\msedgewebview2.exe" (
|
||||
echo The bundled WebView2 runtime is missing.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
icacls "%ROOT%webview2" /grant *S-1-15-2-2:(OI)(CI)(RX) /T /C >nul 2>&1
|
||||
icacls "%ROOT%webview2" /grant *S-1-15-2-1:(OI)(CI)(RX) /T /C >nul 2>&1
|
||||
start "" "%ROOT%verstak-desktop.exe" %*
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
//go:build !windows
|
||||
|
||||
package main
|
||||
|
||||
import "github.com/wailsapp/wails/v2/pkg/options"
|
||||
|
||||
func applyPlatformOptions(_ *options.App) {}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
||||
)
|
||||
|
||||
func applyPlatformOptions(app *options.App) {
|
||||
executablePath, err := os.Executable()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
runtimePath := bundledWebView2Path(executablePath)
|
||||
if _, err := os.Stat(filepath.Join(runtimePath, "msedgewebview2.exe")); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Fixed Version WebView2 runtimes from v120 need these permissions on
|
||||
// unpackaged Windows 10 applications. The archive is extracted by the user,
|
||||
// so the command can update permissions without an installer or download.
|
||||
for _, sid := range []string{"*S-1-15-2-2", "*S-1-15-2-1"} {
|
||||
_ = exec.Command("icacls", runtimePath, "/grant", sid+":(OI)(CI)(RX)", "/T", "/C").Run()
|
||||
}
|
||||
|
||||
app.Windows = &windows.Options{
|
||||
WebviewBrowserPath: runtimePath,
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
package main
|
||||
|
||||
import "path/filepath"
|
||||
|
||||
func bundledWebView2Path(executablePath string) string {
|
||||
return filepath.Join(filepath.Dir(executablePath), "webview2")
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestBundledWebView2PathUsesExecutableDirectory(t *testing.T) {
|
||||
got := bundledWebView2Path("/opt/verstak/verstak-desktop")
|
||||
want := "/opt/verstak/webview2"
|
||||
if got != want {
|
||||
t.Fatalf("bundledWebView2Path() = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
|
@ -55,8 +55,8 @@ fi
|
|||
|
||||
# Wails' -compiler option selects a Go binary, not a C compiler. Cross-CGO
|
||||
# therefore has to be supplied through the standard Go environment instead.
|
||||
# The runtime is bundled by package-windows-portable.sh, so never compile an
|
||||
# Evergreen downloader into the portable executable.
|
||||
# The portable archive uses the installed Evergreen WebView2 Runtime, so never
|
||||
# compile an Evergreen downloader into the executable.
|
||||
CC="$WINDOWS_CC" CGO_ENABLED=1 "$WAILS" build -clean -platform windows/amd64 \
|
||||
-webview2 error -o verstak-desktop.exe
|
||||
|
||||
|
|
|
|||
|
|
@ -3,62 +3,21 @@ set -euo pipefail
|
|||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
VERSION="${1:-}"
|
||||
WEBVIEW2_CAB="${VERSTAK_WEBVIEW2_CAB:-}"
|
||||
WEBVIEW2_URL="${VERSTAK_WEBVIEW2_URL:-}"
|
||||
|
||||
if [[ -z "$VERSION" || ! "$VERSION" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then
|
||||
echo "usage: $0 <version>" >&2
|
||||
echo "example: $0 v0.1.0-alpha.1" >&2
|
||||
exit 2
|
||||
fi
|
||||
for command in cabextract curl python3 zip; do
|
||||
for command in zip; do
|
||||
if ! command -v "$command" >/dev/null; then
|
||||
echo "$command is required to create the Windows portable archive" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "$WEBVIEW2_CAB" ]]; then
|
||||
if [[ -z "$WEBVIEW2_URL" ]]; then
|
||||
WEBVIEW2_URL="$(python3 - <<'PY'
|
||||
import re
|
||||
import sys
|
||||
import urllib.request
|
||||
|
||||
with urllib.request.urlopen('https://developer.microsoft.com/en-us/microsoft-edge/webview2/', timeout=30) as response:
|
||||
page = response.read().decode('utf-8')
|
||||
page = page.replace(r'\u002F', '/')
|
||||
match = re.search(r'"x64","(https://[^\"]+Microsoft\.WebView2\.FixedVersionRuntime[^\"]+\.x64\.cab)"', page)
|
||||
if not match:
|
||||
sys.exit('could not locate the x64 FixedVersionRuntime CAB on the Microsoft WebView2 download page')
|
||||
print(match.group(1))
|
||||
PY
|
||||
)"
|
||||
fi
|
||||
WEBVIEW2_CAB="$ROOT/build/downloads/$(basename "${WEBVIEW2_URL%%\?*}")"
|
||||
mkdir -p "$(dirname "$WEBVIEW2_CAB")"
|
||||
if [[ ! -f "$WEBVIEW2_CAB" ]]; then
|
||||
curl --fail --location --show-error "$WEBVIEW2_URL" -o "$WEBVIEW2_CAB"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -f "$WEBVIEW2_CAB" ]]; then
|
||||
echo "FixedVersionRuntime CAB was not found: $WEBVIEW2_CAB" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"$ROOT/scripts/build-windows.sh"
|
||||
|
||||
RUNTIME_EXTRACT="$ROOT/build/webview2-runtime"
|
||||
rm -rf "$RUNTIME_EXTRACT"
|
||||
mkdir -p "$RUNTIME_EXTRACT"
|
||||
cabextract -q -d "$RUNTIME_EXTRACT" "$WEBVIEW2_CAB"
|
||||
WEBVIEW2_RUNTIME_DIR="$(dirname "$(find "$RUNTIME_EXTRACT" -type f -iname msedgewebview2.exe -print -quit)")"
|
||||
if [[ -z "$WEBVIEW2_RUNTIME_DIR" || ! -f "$WEBVIEW2_RUNTIME_DIR/msedgewebview2.exe" ]]; then
|
||||
echo "FixedVersionRuntime CAB does not contain msedgewebview2.exe" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RELEASE_ROOT="$ROOT/release"
|
||||
STAGING="$RELEASE_ROOT/verstak-windows-amd64-$VERSION"
|
||||
ARCHIVE="$RELEASE_ROOT/verstak-windows-amd64-$VERSION.zip"
|
||||
|
|
@ -67,7 +26,6 @@ mkdir -p "$STAGING"
|
|||
cp -R "$ROOT/build/windows-amd64/." "$STAGING/"
|
||||
install -m 644 "$ROOT/README.md" "$ROOT/LICENSE" "$STAGING/"
|
||||
install -m 644 "$ROOT/packaging/windows/Verstak.cmd" "$STAGING/Verstak.cmd"
|
||||
cp -R "$WEBVIEW2_RUNTIME_DIR" "$STAGING/webview2"
|
||||
|
||||
(cd "$RELEASE_ROOT" && zip -qr "$(basename "$ARCHIVE")" "$(basename "$STAGING")")
|
||||
(cd "$RELEASE_ROOT" && find . -maxdepth 1 -type f \( -name '*.deb' -o -name '*.AppImage' -o -name '*.zip' \) \
|
||||
|
|
|
|||
|
|
@ -18,11 +18,21 @@ grep -Fq 'packaging/deb/control' "$ROOT/scripts/package-deb.sh"
|
|||
grep -Fq 'libwebkit2gtk-4.1-0' "$ROOT/packaging/deb/control"
|
||||
grep -Fq 'appimagetool' "$ROOT/scripts/package-appimage.sh"
|
||||
grep -Fq 'WebKitWebProcess' "$ROOT/scripts/package-appimage.sh"
|
||||
grep -Fq 'FixedVersionRuntime' "$ROOT/scripts/package-windows-portable.sh"
|
||||
grep -Fq 'msedgewebview2.exe' "$ROOT/scripts/package-windows-portable.sh"
|
||||
if grep -Fq 'FixedVersionRuntime' "$ROOT/scripts/package-windows-portable.sh"; then
|
||||
echo "Windows portable archive must not bundle Fixed Version WebView2" >&2
|
||||
exit 1
|
||||
fi
|
||||
if grep -Fq 'msedgewebview2.exe' "$ROOT/scripts/package-windows-portable.sh"; then
|
||||
echo "Windows portable archive must not bundle WebView2 binaries" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -e "$ROOT/platform_options_windows.go" ]]; then
|
||||
echo "Windows runtime override must not be present" >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -Fq 'zip -qr' "$ROOT/scripts/package-windows-portable.sh"
|
||||
grep -Fq 'WebviewBrowserPath' "$ROOT/platform_options_windows.go"
|
||||
grep -Fq 'webview2' "$ROOT/platform_options_windows.go"
|
||||
grep -Fq 'LinkId=2124701' "$ROOT/README.md"
|
||||
grep -Fq 'WebView2 Runtime' "$ROOT/README.md"
|
||||
grep -Fq 'chmod -R a+rX' "$ROOT/scripts/build-linux-bundle.sh"
|
||||
|
||||
echo "desktop package script contracts passed"
|
||||
|
|
|
|||
Loading…
Reference in New Issue