From b74d3a23bcb79b4bec297f42de4d6efe51f11262 Mon Sep 17 00:00:00 2001 From: Anjan Nath Date: Fri, 1 Dec 2023 13:43:51 +0530 Subject: [PATCH] name the executable as crc-background-launcher.exe the background-launcher upstream is released as win32-background-launcher.exe since its function is generic and does nothing crc specific however when we install it and use it to launch the daemon process in background on windows it is useful to name it as crc-background-launcher.exe to make it easy for users to identify it with crc --- packaging/windows/product.wxs.template | 2 +- pkg/crc/cache/cache.go | 13 +++++++------ pkg/crc/cache/cache_windows.go | 6 +++++- pkg/crc/constants/constants.go | 6 +++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packaging/windows/product.wxs.template b/packaging/windows/product.wxs.template index 66d28a7a65..20a3b8b921 100755 --- a/packaging/windows/product.wxs.template +++ b/packaging/windows/product.wxs.template @@ -55,7 +55,7 @@ - + NOT UPGRADINGPRODUCTCODE AND NOT WIX_UPGRADE_DETECTED diff --git a/pkg/crc/cache/cache.go b/pkg/crc/cache/cache.go index 8e3070160e..9bb9fd8cac 100644 --- a/pkg/crc/cache/cache.go +++ b/pkg/crc/cache/cache.go @@ -17,10 +17,11 @@ import ( ) type Cache struct { - executablePath string - archiveURL string - version string - getVersion func(string) (string, error) + executablePath string + archiveURL string + version string + ignoreNameMismatch bool + getVersion func(string) (string, error) } type VersionMismatchError struct { @@ -127,14 +128,14 @@ func (c *Cache) cacheExecutable() error { } } else { extractedFiles = append(extractedFiles, assetTmpFile) - if filepath.Base(assetTmpFile) != c.GetExecutableName() { + if filepath.Base(assetTmpFile) != c.GetExecutableName() && !c.ignoreNameMismatch { logging.Warnf("Executable name is %s but extracted file name is %s", c.GetExecutableName(), filepath.Base(assetTmpFile)) } } // Copy the requested asset into its final destination for _, extractedFilePath := range extractedFiles { - finalExecutablePath := filepath.Join(constants.CrcBinDir, filepath.Base(extractedFilePath)) + finalExecutablePath := filepath.Join(constants.CrcBinDir, c.GetExecutableName()) // If the file exists then remove it (ignore error) first before copy because with `0500` permission // it is not possible to overwrite the file. os.Remove(finalExecutablePath) diff --git a/pkg/crc/cache/cache_windows.go b/pkg/crc/cache/cache_windows.go index 95fc566b20..49b75bdb8f 100644 --- a/pkg/crc/cache/cache_windows.go +++ b/pkg/crc/cache/cache_windows.go @@ -12,7 +12,7 @@ import ( func NewWin32BackgroundLauncherCache() *Cache { url := constants.GetWin32BackgroundLauncherDownloadURL() version := version.GetWin32BackgroundLauncherVersion() - return newCache(constants.Win32BackgroundLauncherPath(), + cache := newCache(constants.Win32BackgroundLauncherPath(), url, version, func(executable string) (string, error) { @@ -23,4 +23,8 @@ func NewWin32BackgroundLauncherCache() *Cache { return strings.TrimSpace(stdOut), nil }, ) + // upstream binary name is win32-background-launcher.exe + // but we want to name it as crc-background-launcher.exe + cache.ignoreNameMismatch = true + return cache } diff --git a/pkg/crc/constants/constants.go b/pkg/crc/constants/constants.go index 7a3a9f0947..486d9e3d63 100644 --- a/pkg/crc/constants/constants.go +++ b/pkg/crc/constants/constants.go @@ -27,7 +27,7 @@ const ( DaemonLogFile = "crcd.log" CrcLandingPageURL = "https://console.redhat.com/openshift/create/local" // #nosec G101 DefaultAdminHelperURLBase = "https://github.com/crc-org/admin-helper/releases/download/v%s/%s" - BackgroundLauncherURL = "https://github.com/crc-org/win32-background-launcher/releases/download/v%s/%s" + BackgroundLauncherURL = "https://github.com/crc-org/win32-background-launcher/releases/download/v%s/win32-background-launcher.exe" DefaultBundleURLBase = "https://mirror.openshift.com/pub/openshift-v4/clients/crc/bundles/%s/%s/%s" DefaultContext = "admin" DaemonHTTPEndpoint = "http://unix/api" @@ -49,7 +49,7 @@ const ( OpenShiftIngressHTTPPort = 80 OpenShiftIngressHTTPSPort = 443 - BackgroundLauncherExecutable = "win32-background-launcher.exe" + BackgroundLauncherExecutable = "crc-background-launcher.exe" ) var adminHelperExecutableForOs = map[string]string{ @@ -196,7 +196,7 @@ func GetKubeAdminPasswordPath() string { func GetWin32BackgroundLauncherDownloadURL() string { return fmt.Sprintf(BackgroundLauncherURL, - version.GetWin32BackgroundLauncherVersion(), BackgroundLauncherExecutable) + version.GetWin32BackgroundLauncherVersion()) } func GetDefaultCPUs(preset crcpreset.Preset) int {