Skip to content

Commit

Permalink
name the executable as crc-background-launcher.exe
Browse files Browse the repository at this point in the history
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
  • Loading branch information
anjannath committed Dec 18, 2023
1 parent 0f2e7e2 commit ce335c0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packaging/windows/product.wxs.template
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<ServiceControl Id="StartAdminHelperService" Name="crcAdminHelper" Start='install' Stop='both' Remove='uninstall' />
</Component>
<Component Id="BackgroundLauncher" Guid="*">
<File Id="BackgroundLauncher" Source="SourceDir\win32-background-launcher.exe" KeyPath="yes" DiskId="1" />
<File Id="BackgroundLauncher" Source="SourceDir\win32-background-launcher.exe" Name="crc-background-launcher.exe" KeyPath="yes" DiskId="1" />
</Component>
<Component Id="AddUserToCrcUsers" Guid="0C793EE7-109A-474B-9651-77E0A83BAF2D" KeyPath="yes">
<Condition>NOT UPGRADINGPRODUCTCODE AND NOT WIX_UPGRADE_DETECTED</Condition>
Expand Down
13 changes: 7 additions & 6 deletions pkg/crc/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion pkg/crc/cache/cache_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
6 changes: 3 additions & 3 deletions pkg/crc/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -49,7 +49,7 @@ const (
OpenShiftIngressHTTPPort = 80
OpenShiftIngressHTTPSPort = 443

BackgroundLauncherExecutable = "win32-background-launcher.exe"
BackgroundLauncherExecutable = "crc-background-launcher.exe"
)

var adminHelperExecutableForOs = map[string]string{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ce335c0

Please sign in to comment.