feat(startup): accept a fixed-version WebView2 carried beside OpsLog
'The Evergreen installer will not install either' moves the problem out of OpsLog's reach: the runtime is a Windows component, and on a managed, offline or otherwise locked-down machine it may simply refuse. Microsoft publishes the same runtime in a FIXED VERSION form — a folder an application carries and points at, needing no installation and no administrator. That is exactly this case, so OpsLog now looks for it beside its own executable and uses it when it is there. The versioned subfolder the download unpacks into is handled, because asking someone to flatten it by hand is one more step to get wrong on a machine where nothing starts. No setting for it: that would be a question asked of the one operator least able to answer it. The folder is either there or it is not. The startup log also records the Windows build — the first thing anyone diagnosing a runtime that will not install is going to ask for.
This commit is contained in:
+53
@@ -160,3 +160,56 @@ func noteLaunchAttempt() {
|
||||
|
||||
// clearLaunchMarker is called once the window is up: the attempt finished.
|
||||
func clearLaunchMarker() { _ = os.Remove(stuckMarkerPath()) }
|
||||
|
||||
// fixedWebView2Path finds a FIXED-VERSION WebView2 runtime shipped beside
|
||||
// OpsLog, or "" when there is none.
|
||||
//
|
||||
// Microsoft publishes the runtime in two forms. Evergreen installs itself into
|
||||
// Windows and updates itself — the normal case, and the one this looks for
|
||||
// first. FIXED VERSION is a folder of files an application carries with it and
|
||||
// points at, needing no installation and no administrator: it exists precisely
|
||||
// for machines where Evergreen cannot be installed, which is not a rare
|
||||
// situation on a managed, offline or otherwise locked-down Windows.
|
||||
//
|
||||
// So: drop the extracted folder next to OpsLog.exe and it is used. Nothing to
|
||||
// configure — a setting for this would be a question asked of the one operator
|
||||
// least able to answer it, on a machine where nothing starts.
|
||||
func fixedWebView2Path() string {
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
base := filepath.Dir(exe)
|
||||
for _, name := range []string{"WebView2", "WebView2Runtime", "webview2"} {
|
||||
dir := filepath.Join(base, name)
|
||||
if p := findWebView2Binary(dir); p != "" {
|
||||
bootLog("using the fixed-version WebView2 runtime in %s", p)
|
||||
return p
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// findWebView2Binary returns dir (or its single versioned subfolder) when it
|
||||
// holds msedgewebview2.exe — the fixed-version download unpacks with the
|
||||
// version as a folder level, and asking someone to flatten it by hand is one
|
||||
// more step to get wrong.
|
||||
func findWebView2Binary(dir string) string {
|
||||
if fileExists(filepath.Join(dir, "msedgewebview2.exe")) {
|
||||
return dir
|
||||
}
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
for _, e := range entries {
|
||||
if !e.IsDir() {
|
||||
continue
|
||||
}
|
||||
sub := filepath.Join(dir, e.Name())
|
||||
if fileExists(filepath.Join(sub, "msedgewebview2.exe")) {
|
||||
return sub
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user